Add local file previews to chat and split the Toolbox layout
This commit is contained in:
+14
-13
@@ -230,7 +230,6 @@ struct MCPSettings: View {
|
||||
@State private var importingConfig = false
|
||||
@State private var configStatus = ""
|
||||
@State private var selected: MCPConnectionID?
|
||||
@State private var scrollRequest = UUID()
|
||||
@State private var tool = ""
|
||||
@State private var arguments = "{}"
|
||||
@State private var confirm = false
|
||||
@@ -241,7 +240,7 @@ struct MCPSettings: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ScrollViewReader { proxy in
|
||||
HSplitView {
|
||||
Form {
|
||||
Section("Built-In Tools") {
|
||||
connectionRow(.web, title: BuiltInWebTools.name, subtitle: "Retrieve pages and search via SearXNG", icon: "globe") {
|
||||
@@ -250,7 +249,7 @@ struct MCPSettings: View {
|
||||
}
|
||||
}
|
||||
Section("Custom MCP Servers") {
|
||||
HStack {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Button("Import mcp.json…") { importingConfig = true }
|
||||
Button("Use LM Studio Config") {
|
||||
loadConfig(FileManager.default.homeDirectoryForCurrentUser.appending(path: ".lmstudio/mcp.json"))
|
||||
@@ -291,6 +290,10 @@ struct MCPSettings: View {
|
||||
connect: connectManual)
|
||||
}
|
||||
}
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.frame(minWidth: 300, idealWidth: 340)
|
||||
Form {
|
||||
if let selection, let state = studio.mcpConnections[selection], let toolset = state.toolset {
|
||||
Section("Run a Tool") {
|
||||
Picker("Connected server", selection: Binding(
|
||||
@@ -327,9 +330,14 @@ struct MCPSettings: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.id("mcp-tool-inspector")
|
||||
} else {
|
||||
ContentUnavailableView("Select a connected server", systemImage: "wrench.and.screwdriver",
|
||||
description: Text("Connect a server on the left to see and run its tools."))
|
||||
}
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.frame(minWidth: 320)
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.fileImporter(isPresented: $importingConfig, allowedContentTypes: [.json]) { result in
|
||||
do { loadConfig(try result.get()) }
|
||||
@@ -348,13 +356,7 @@ struct MCPSettings: View {
|
||||
}
|
||||
selectFirstTool()
|
||||
}
|
||||
.onChange(of: selection) { _, value in
|
||||
selectFirstTool()
|
||||
if value != nil { withAnimation { proxy.scrollTo("mcp-tool-inspector", anchor: .bottom) } }
|
||||
}
|
||||
.onChange(of: scrollRequest) { _, _ in
|
||||
withAnimation { proxy.scrollTo("mcp-tool-inspector", anchor: .bottom) }
|
||||
}
|
||||
.onChange(of: selection) { _, _ in selectFirstTool() }
|
||||
.onChange(of: tool) { _, _ in arguments = "{}" }
|
||||
.onChange(of: endpoint) { _, _ in studio.disconnectMCP(.manual) }
|
||||
.onChange(of: transport) { _, _ in studio.disconnectMCP(.manual) }
|
||||
@@ -371,7 +373,6 @@ struct MCPSettings: View {
|
||||
} message: {
|
||||
Text("Send these arguments to \(selection.flatMap { studio.mcpConnections[$0]?.toolset?.name } ?? "the server"):\n\(arguments.prefix(800))")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func connectionRow(
|
||||
@@ -388,7 +389,7 @@ struct MCPSettings: View {
|
||||
Button("Cancel") { studio.cancelMCP(id) }
|
||||
} else if let toolset = state?.toolset {
|
||||
Text("\(toolset.tools.count) tools · Connected").font(.caption).foregroundStyle(.green)
|
||||
Button("Tools") { selected = id; scrollRequest = UUID() }
|
||||
Button("Tools") { selected = id }
|
||||
Button("Disconnect") { studio.disconnectMCP(id) }
|
||||
} else {
|
||||
Button(local ? "Start & Connect" : "Connect") {
|
||||
|
||||
Reference in New Issue
Block a user