Use saved web and Gitea access from a fresh chat

This commit is contained in:
Mark Gregory
2026-11-16 16:18:39 +00:00
parent 00ea78671b
commit 4ebf2b82be
6 changed files with 79 additions and 15 deletions
+12 -4
View File
@@ -20,6 +20,7 @@ final class StudioModel: ObservableObject {
@Published private(set) var managing = false
@Published private(set) var running = false
@Published private(set) var webStatus = ""
@Published private(set) var webSearchLink: URL?
@Published private(set) var knowledgeStatus = ""
var connectedKnowledge: (any MCPToolClient)? {
@@ -177,8 +178,9 @@ final class StudioModel: ObservableObject {
\(toolAttachment.output)
""")
}
let lookup = mcpConnections[.web]?.toolset != nil ? ChatWebLookup(message: text) : nil
let repositoryClient = GiteaRepositoryLookup.matches(text) ?
let lookup = ChatWebLookup(message: text)
let wantsRepositories = GiteaRepositoryLookup.matches(text)
let repositoryClient = wantsRepositories ?
activeToolsets.first(where: { entry in
entry.toolset.tools.contains { $0.name == "list_repositories" }
})?.toolset.client : nil
@@ -188,6 +190,7 @@ final class StudioModel: ObservableObject {
prompt = ""
toolAttachment = nil
status = ""
webSearchLink = nil
webStatus = lookup == nil ? "" : "Looking up web sources…"
knowledgeStatus = knowledge == nil ? "" : "Searching the connected knowledge index…"
running = true
@@ -199,6 +202,7 @@ final class StudioModel: ObservableObject {
let sources = try await lookup.resolve(searchEndpoint: searchEndpoint)
try Task.checkCancellation()
webStatus = sources.status
webSearchLink = sources.browserFallback
systemParts.append(sources.reference)
} catch {
webStatus = ""
@@ -228,10 +232,13 @@ final class StudioModel: ObservableObject {
systemParts.append("External knowledge retrieval failed for this turn. Do not claim to have searched the index.")
}
}
if let repositoryClient {
if wantsRepositories {
webStatus = "Listing Gitea repositories…"
do {
let repositories = try await GiteaRepositoryLookup.references(client: repositoryClient)
let client: any MCPToolClient
if let repositoryClient { client = repositoryClient }
else { client = try await GiteaRepositoryLookup.configuredClient() }
let repositories = try await GiteaRepositoryLookup.references(client: client)
try Task.checkCancellation()
systemParts.append(repositories)
webStatus = "Gitea repositories checked."
@@ -553,6 +560,7 @@ final class StudioModel: ObservableObject {
private func loadMessages() {
messages = []
webStatus = ""
webSearchLink = nil
knowledgeStatus = ""
toolAttachment = nil
documents = []