Retrieve live web search results and show chat diagnostics
This commit is contained in:
@@ -70,6 +70,7 @@ struct ChatView: View {
|
||||
@State private var showingPerformance = false
|
||||
@State private var showingWorkspace = false
|
||||
@State private var showingToolbox = false
|
||||
@AppStorage("chatDebugOutput") private var showDebugOutput = false
|
||||
@AppStorage("composerSpellCheck") private var spellCheck = true
|
||||
@AppStorage("composerAutoCorrect") private var autoCorrect = false
|
||||
@AppStorage("studioChatSize") private var chatSize = 14
|
||||
@@ -236,6 +237,16 @@ struct ChatView: View {
|
||||
Text(activity.joined(separator: " · "))
|
||||
.font(.caption).foregroundStyle(.secondary).lineLimit(2).textSelection(.enabled)
|
||||
}
|
||||
if showDebugOutput, !studio.webDiagnostics.isEmpty {
|
||||
ScrollView {
|
||||
Text(studio.webDiagnostics.joined(separator: "\n"))
|
||||
.font(.system(.caption, design: .monospaced))
|
||||
.textSelection(.enabled)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.frame(maxHeight: 96)
|
||||
.accessibilityLabel("Web lookup debug output")
|
||||
}
|
||||
if let link = studio.webSearchLink {
|
||||
Link("Open search in browser", destination: link).font(.caption)
|
||||
}
|
||||
@@ -246,6 +257,13 @@ struct ChatView: View {
|
||||
.background(.background, in: RoundedRectangle(cornerRadius: 8))
|
||||
.overlay(RoundedRectangle(cornerRadius: 8).strokeBorder(.quaternary))
|
||||
HStack {
|
||||
Menu {
|
||||
Toggle("Show Debug Output", isOn: $showDebugOutput)
|
||||
} label: {
|
||||
Label("Chat Diagnostics", systemImage: "ladybug")
|
||||
}
|
||||
.labelStyle(.iconOnly)
|
||||
.fixedSize()
|
||||
Button("Attach Files", systemImage: "paperclip", action: pickLocalFile)
|
||||
.labelStyle(.iconOnly).buttonStyle(.bordered)
|
||||
.help("Attach a local file or folder listing").disabled(studio.running)
|
||||
@@ -1747,11 +1765,11 @@ struct WebToolsView: View {
|
||||
results = try await WebSearch.results(endpoint: source, query: term)
|
||||
if results.isEmpty { status = "No usable search results." }
|
||||
}
|
||||
}.disabled(operation != nil || endpoint.isEmpty || query.isEmpty)
|
||||
}.disabled(operation != nil || query.isEmpty)
|
||||
Button("Search in Browser") { searchInBrowser() }.disabled(query.isEmpty)
|
||||
if operation != nil { Button("Cancel") { operation?.cancel() } }
|
||||
}
|
||||
Text("In-app search requires a SearXNG server with JSON output enabled.")
|
||||
Text("Search uses Bing by default. Enter a SearXNG URL to use your own instance.")
|
||||
.foregroundStyle(.secondary)
|
||||
ForEach(results) { result in
|
||||
VStack(alignment: .leading, spacing: 5) {
|
||||
|
||||
Reference in New Issue
Block a user