返回 DeepSeek-Reasonix
chat_tui_watchdog.go
根目录 / internal / cli / chat_tui_watchdog.go
1 package cli
2
3 import (
4 "fmt"
5
6 "reasonix/internal/event"
7 )
8
9 func (m *chatTUI) noteWatchdogRunning() {
10 if m == nil || m.diagnostics == nil {
11 return
12 }
13 ctrl := m.ctrl
14 m.diagnostics.NoteRunning(func() {
15 if ctrl != nil {
16 ctrl.Cancel()
17 }
18 })
19 }
20
21 func (m *chatTUI) noteWatchdogIdle() {
22 if m == nil || m.diagnostics == nil {
23 return
24 }
25 m.diagnostics.NoteIdle()
26 }
27
28 func (m *chatTUI) noteWatchdogHeartbeat(source string) {
29 if m == nil || m.diagnostics == nil {
30 return
31 }
32 m.diagnostics.NoteActiveHeartbeat(source)
33 }
34
35 func watchdogAgentSource(kind event.Kind) string {
36 return fmt.Sprintf("agent:%d", kind)
37 }
38
39 func (m *chatTUI) updateWatchdogStatusProvider() {
40 if m == nil || m.diagnostics == nil || m.ctrl == nil {
41 return
42 }
43 ctrl := m.ctrl
44 m.diagnostics.SetStatusProvider(func() string {
45 st := ctrl.RuntimeStatus()
46 return fmt.Sprintf("running=%v pending_prompt=%v cancel_requested=%v cancellable=%v background_jobs=%d",
47 st.Running, st.PendingPrompt, st.CancelRequested, st.Cancellable, st.BackgroundJobs)
48 })
49 }
50
50 lines GO