Model is the top-level TUI model that wraps the chat page.
| 67 | |
| 68 | // Model is the top-level TUI model that wraps the chat page. |
| 69 | type appModel struct { |
| 70 | shutdownDone <-chan struct{} |
| 71 | cleanupOnce sync.Once |
| 72 | |
| 73 | // cleanupAllOnce guards the full cleanupAll shutdown sequence so repeat |
| 74 | // invocations (ExitSessionMsg followed by ExitConfirmedMsg, …) are no-ops: |
| 75 | // they must not stack goroutines behind a wedged cleanup or arm parallel |
| 76 | // safety nets that would each call exit. |
| 77 | cleanupAllOnce sync.Once |
| 78 | |
| 79 | // exitFunc and shutdownTimeout override the shutdown safety net's |
| 80 | // behaviour. Both are zero by default and resolved through |
| 81 | // exitFn()/shutdownTimeoutOrDefault(), which fall back to the package |
| 82 | // defaults (os.Exit / 5s). Tests set them per-model so they can run in |
| 83 | // parallel without mutating package globals. |
| 84 | exitFunc func(int) |
| 85 | shutdownTimeout time.Duration |
| 86 | |
| 87 | supervisor *supervisor.Supervisor |
| 88 | tabBar *tabbar.TabBar |
| 89 | tuiStore *tuistate.Store |
| 90 | |
| 91 | // Per-session chat pages (kept alive for streaming continuity) |
| 92 | chatPages map[string]chat.Page |
| 93 | sessionStates map[string]*service.SessionState |
| 94 | |
| 95 | // Per-session editors (preserved across tab switches for draft text) |
| 96 | editors map[string]editor.Editor |
| 97 | |
| 98 | // Active session (convenience pointers to the currently visible session) |
| 99 | application *app.App |
| 100 | sessionState *service.SessionState |
| 101 | chatPage chat.Page |
| 102 | editor editor.Editor |
| 103 | |
| 104 | // ctx preserves values from the root TUI context (trace context, |
| 105 | // baggage, log attrs) without inheriting cancellation. Bubble Tea |
| 106 | // handlers have no ctx parameter and many calls are persistence/cleanup |
| 107 | // work that must survive shutdown cancellation. |
| 108 | ctx func() context.Context |
| 109 | |
| 110 | // Shared history for command history across all editors |
| 111 | history *history.History |
| 112 | |
| 113 | // UI components |
| 114 | notification notification.Manager |
| 115 | dialogMgr dialog.Manager |
| 116 | statusBar statusbar.StatusBar |
| 117 | completions completion.Manager |
| 118 | |
| 119 | // Speech-to-text |
| 120 | transcriber Transcriber |
| 121 | transcriptCh chan string // bridges transcriber goroutine → Bubble Tea event loop |
| 122 | |
| 123 | // Working state indicator (resize handle spinner) |
| 124 | workingSpinner spinner.Spinner |
| 125 | |
| 126 | // animFrame is the current animation frame, used to rotate the window |
nothing calls this directly
no outgoing calls
no test coverage detected