返回 DeepSeek-Reasonix
capdiag_app.go
根目录 / desktop / capdiag_app.go
1 package main
2
3 import (
4 "reasonix/internal/capdiag"
5 "reasonix/internal/plugin"
6 )
7
8 // CapabilityDiagnostics returns a read-only capability report for the active
9 // workspace. When includeSessionRuntime is true, connected/failed/deferred
10 // status is merged from the active tab Host only — no new MCP processes are
11 // started, and no controller rebuild or session snapshot is triggered.
12 func (a *App) CapabilityDiagnostics(includeSessionRuntime bool) capdiag.Report {
13 root, host := a.activeDiagSnapshot(includeSessionRuntime)
14 opts := capdiag.Options{Root: root, Live: false}
15
16 if !includeSessionRuntime {
17 return capdiag.Collect(opts)
18 }
19
20 opts.RuntimeHost = host
21 if host == nil {
22 return capdiag.CollectWithRuntimeUnavailable(opts)
23 }
24 return capdiag.Collect(opts)
25 }
26
27 // activeDiagSnapshot reads workspace root and optional Host under one lock so
28 // a tab switch cannot pair project A's config with project B's runtime Host.
29 func (a *App) activeDiagSnapshot(includeHost bool) (root string, host *plugin.Host) {
30 a.mu.RLock()
31 defer a.mu.RUnlock()
32 tab := a.activeTabLocked()
33 if tab == nil {
34 return "", nil
35 }
36 root = tab.WorkspaceRoot
37 if includeHost && tab.Ctrl != nil {
38 host = tab.Ctrl.Host()
39 }
40 return root, host
41 }
42
42 lines GO