Keep multiple MCP toolsets connected and restore workspace navigation

This commit is contained in:
Mark Gregory
2026-11-16 15:57:58 +00:00
parent 06e3291edb
commit f7b1083f39
8 changed files with 405 additions and 246 deletions
+51 -13
View File
@@ -235,12 +235,14 @@ struct ChatView: View {
Button {
showingToolbox = true
} label: {
Label(studio.activeToolset == nil ? "Toolbox" : "1 Active Toolset",
let count = studio.activeToolsets.count
Label(count == 0 ? "Toolbox" : count == 1 ? "1 Active Toolset" : "\(count) Active Toolsets",
systemImage: "wrench.and.screwdriver")
}
.buttonStyle(.bordered)
if let toolset = studio.activeToolset {
Text("\(toolset.name) · \(toolset.tools.count) tools").lineLimit(1).foregroundStyle(.secondary)
if !studio.activeToolsets.isEmpty {
let servers = studio.activeToolsets.map { $0.toolset.name }.joined(separator: ", ")
Text(servers).lineLimit(2).foregroundStyle(.secondary).help(servers)
}
if studio.activeStack != nil || studio.activeSkill != nil ||
studio.activeContext != nil || studio.activeWebClip != nil {
@@ -1221,6 +1223,27 @@ struct ToolboxSheet: View {
struct WorkspaceResourcesView: View {
@Environment(\.dismiss) private var dismiss
@ObservedObject var studio: StudioModel
@State private var page: Page? = .stacks
private enum Page: String, CaseIterable, Identifiable {
case stacks = "Knowledge Stacks"
case skills = "Skills"
case contexts = "Contexts"
case prompts = "Prompt Library"
case clips = "Web Clips"
var id: Self { self }
var icon: String {
switch self {
case .stacks: "square.stack.3d.up"
case .skills: "bolt"
case .contexts: "doc.text"
case .prompts: "text.bubble"
case .clips: "link"
}
}
}
var body: some View {
VStack(spacing: 0) {
@@ -1230,18 +1253,29 @@ struct WorkspaceResourcesView: View {
Button("Done") { dismiss() }
}
.padding()
TabView {
KnowledgeStacksView(studio: studio).tabItem { Label("Stacks", systemImage: "square.stack.3d.up") }
WorkspaceSnippetsView(studio: studio, kind: .skill).tabItem { Label("Skills", systemImage: "bolt") }
WorkspaceSnippetsView(studio: studio, kind: .context).tabItem { Label("Contexts", systemImage: "doc.text") }
WorkspaceSnippetsView(studio: studio, kind: .prompt).tabItem { Label("Prompts", systemImage: "text.bubble") }
WorkspaceSnippetsView(studio: studio, kind: .webClip).tabItem { Label("Web Clips", systemImage: "link") }
Divider()
HSplitView {
List(Page.allCases, selection: $page) { entry in
Label(entry.rawValue, systemImage: entry.icon).tag(entry)
}
.listStyle(.sidebar)
.frame(minWidth: 175, idealWidth: 190, maxWidth: 235)
Group {
switch page ?? .stacks {
case .stacks: KnowledgeStacksView(studio: studio)
case .skills: WorkspaceSnippetsView(studio: studio, kind: .skill).id(Page.skills)
case .contexts: WorkspaceSnippetsView(studio: studio, kind: .context).id(Page.contexts)
case .prompts: WorkspaceSnippetsView(studio: studio, kind: .prompt).id(Page.prompts)
case .clips: WorkspaceSnippetsView(studio: studio, kind: .webClip).id(Page.clips)
}
}
.frame(minWidth: 590, maxWidth: .infinity, maxHeight: .infinity)
}
if !studio.workspaceStatus.isEmpty {
Text(studio.workspaceStatus).foregroundStyle(.red).textSelection(.enabled).padding(8)
}
}
.frame(width: 720, height: 560)
.frame(width: 840, height: 570)
}
}
@@ -1259,11 +1293,15 @@ struct KnowledgeStacksView: View {
Form {
Section("Knowledge Stacks") {
HStack {
TextField("New stack name", text: $name)
Button("Create") {
TextField("New stack name", text: $name, prompt: Text("Enter a name for the stack"))
.labelsHidden()
.textFieldStyle(.roundedBorder)
.accessibilityLabel("New stack name")
Button("Create Stack") {
selected = studio.createStack(name.trimmingCharacters(in: .whitespacesAndNewlines))
name = ""
}.disabled(name.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || busy)
}.buttonStyle(.borderedProminent)
.disabled(name.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || busy)
}
Picker("Manage stack", selection: $selected) {
Text("Select a stack").tag(UUID?.none)