Add user-controlled local file access in chat
This commit is contained in:
@@ -1023,6 +1023,8 @@ enum DockerCommand {
|
||||
|
||||
struct LocalToolsView: View {
|
||||
@ObservedObject var studio: StudioModel
|
||||
@AppStorage("chatFileAccessFolder") private var chatFileAccessFolder = ""
|
||||
@State private var confirmFullAccess = false
|
||||
@State private var line = "docker ps"
|
||||
@State private var pending: [String]?
|
||||
@State private var output = ""
|
||||
@@ -1036,6 +1038,26 @@ struct LocalToolsView: View {
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
Section("Chat File Access") {
|
||||
LabeledContent("Access", value: chatFileAccessFolder.isEmpty ? "Off" :
|
||||
chatFileAccessFolder == "/" ? "Any readable location" : chatFileAccessFolder)
|
||||
HStack {
|
||||
Button("Choose Folder…") {
|
||||
let panel = NSOpenPanel()
|
||||
panel.canChooseDirectories = true
|
||||
panel.canChooseFiles = false
|
||||
panel.begin { result in
|
||||
if result == .OK, let url = panel.url { chatFileAccessFolder = url.path }
|
||||
}
|
||||
}
|
||||
Button("Allow Any Readable Location…") { confirmFullAccess = true }
|
||||
if !chatFileAccessFolder.isEmpty {
|
||||
Button("Turn Off") { chatFileAccessFolder = "" }
|
||||
}
|
||||
}
|
||||
Text("In chat, use /read followed by a file path, or /ls followed by a folder path. The selected model receives the preview. macOS privacy permissions still apply.")
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
Section("Docker") {
|
||||
TextField("Command", text: $line, prompt: Text("docker ps --all"))
|
||||
.font(.system(.body, design: .monospaced))
|
||||
@@ -1098,6 +1120,12 @@ struct LocalToolsView: View {
|
||||
}
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.alert("Allow chat to read from any location?", isPresented: $confirmFullAccess) {
|
||||
Button("Allow Read Access") { chatFileAccessFolder = "/" }
|
||||
Button("Cancel", role: .cancel) {}
|
||||
} message: {
|
||||
Text("A file you ask chat to read may be included in a request to your selected model, including a remote model.")
|
||||
}
|
||||
.fileImporter(isPresented: $picking, allowedContentTypes: [.item, .folder]) { result in
|
||||
preview = ""
|
||||
fileStatus = ""
|
||||
|
||||
Reference in New Issue
Block a user