@denizokcu/haze 1.7.12 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +30 -6
  3. package/SECURITY.md +1 -1
  4. package/bin/haze.js +47 -19
  5. package/dist/buildInfo.json +3 -3
  6. package/dist/cli/chat/BusyBar.d.ts +1 -2
  7. package/dist/cli/chat/ChatHeader.d.ts +6 -0
  8. package/dist/cli/chat/ChatHeader.js +11 -0
  9. package/dist/cli/chat/ChatScreen.d.ts +16 -0
  10. package/dist/cli/chat/ChatScreen.js +399 -0
  11. package/dist/cli/chat/ChatScreenView.d.ts +68 -0
  12. package/dist/cli/chat/ChatScreenView.js +47 -0
  13. package/dist/cli/chat/LiveTail.d.ts +11 -0
  14. package/dist/cli/chat/LiveTail.js +26 -0
  15. package/dist/cli/chat/TaskBar.d.ts +3 -2
  16. package/dist/cli/chat/TaskBar.js +4 -0
  17. package/dist/cli/chat/agentTurnRunner.d.ts +12 -0
  18. package/dist/cli/chat/agentTurnRunner.js +177 -0
  19. package/dist/cli/chat/busyIndicator.js +9 -5
  20. package/dist/cli/chat/chatMetrics.d.ts +7 -0
  21. package/dist/cli/chat/chatMetrics.js +15 -1
  22. package/dist/cli/chat/chatViewModel.d.ts +85 -0
  23. package/dist/cli/chat/chatViewModel.js +66 -0
  24. package/dist/cli/chat/fileMentionSuggestions.d.ts +0 -14
  25. package/dist/cli/chat/fileMentionSuggestions.js +4 -21
  26. package/dist/cli/chat/liveTheme.d.ts +11 -0
  27. package/dist/cli/chat/liveTheme.js +26 -0
  28. package/dist/cli/chat/messageFinalize.d.ts +4 -0
  29. package/dist/cli/chat/messageFinalize.js +8 -0
  30. package/dist/cli/chat/messages.js +1 -1
  31. package/dist/cli/chat/pickerOpeners.d.ts +23 -0
  32. package/dist/cli/chat/pickerOpeners.js +36 -0
  33. package/dist/cli/chat/promptSessionState.d.ts +11 -0
  34. package/dist/cli/chat/promptSessionState.js +39 -0
  35. package/dist/cli/chat/renderMetrics.d.ts +8 -0
  36. package/dist/cli/chat/renderMetrics.js +14 -0
  37. package/dist/cli/chat/resizeGuard.d.ts +11 -0
  38. package/dist/cli/chat/resizeGuard.js +25 -0
  39. package/dist/cli/chat/screenDeps.d.ts +116 -0
  40. package/dist/cli/chat/screenDeps.js +1 -0
  41. package/dist/cli/chat/sessionLifecycle.d.ts +2 -0
  42. package/dist/cli/chat/sessionLifecycle.js +4 -1
  43. package/dist/cli/chat/settingsSelection.d.ts +33 -0
  44. package/dist/cli/chat/settingsSelection.js +46 -0
  45. package/dist/cli/chat/skillNotices.d.ts +18 -0
  46. package/dist/cli/chat/skillNotices.js +26 -0
  47. package/dist/cli/chat/startupInfo.js +1 -1
  48. package/dist/cli/chat/submitPipeline.d.ts +8 -0
  49. package/dist/cli/chat/submitPipeline.js +141 -0
  50. package/dist/cli/chat/terminalControl.js +1 -1
  51. package/dist/cli/chat/toolSummaries.d.ts +29 -0
  52. package/dist/cli/chat/toolSummaries.js +268 -0
  53. package/dist/cli/chat/turnState.d.ts +8 -0
  54. package/dist/cli/chat/turnState.js +1 -0
  55. package/dist/cli/chat/userCommandFlow.d.ts +21 -0
  56. package/dist/cli/chat/userCommandFlow.js +66 -0
  57. package/dist/cli/chat/userCommandRunner.d.ts +14 -0
  58. package/dist/cli/chat/userCommandRunner.js +56 -0
  59. package/dist/cli/chat/wizard/providerHandlers.js +19 -2
  60. package/dist/cli/chat/wizardTrail.d.ts +22 -0
  61. package/dist/cli/chat/wizardTrail.js +55 -0
  62. package/dist/cli/commands/chat.d.ts +1 -13
  63. package/dist/cli/commands/chat.js +10 -798
  64. package/dist/cli/commands/commandHelp.js +7 -5
  65. package/dist/cli/commands/commandSuggest.d.ts +2 -0
  66. package/dist/cli/commands/commandSuggest.js +35 -0
  67. package/dist/cli/commands/commands.js +10 -3
  68. package/dist/cli/commands/formatters.d.ts +1 -23
  69. package/dist/cli/commands/formatters.js +3 -252
  70. package/dist/cli/commands/modelCommand.js +11 -7
  71. package/dist/cli/commands/reasoningCommand.js +3 -3
  72. package/dist/cli/commands/runCommand.js +6 -2
  73. package/dist/cli/commands/streaming/attemptLifecycle.js +1 -0
  74. package/dist/cli/commands/streaming/attemptOutcome.js +7 -2
  75. package/dist/cli/commands/streaming/attemptSetup.d.ts +1 -0
  76. package/dist/cli/commands/streaming/attemptSetup.js +26 -2
  77. package/dist/cli/commands/streaming/goalCheckpoint.d.ts +1 -1
  78. package/dist/cli/commands/streaming/stepProjection.d.ts +59 -0
  79. package/dist/cli/commands/streaming/stepProjection.js +54 -0
  80. package/dist/cli/commands/streaming/streamLoop.js +31 -23
  81. package/dist/cli/commands/streaming/toolGroupRenderer.js +1 -1
  82. package/dist/cli/commands/streaming/toolPartHandlers.js +1 -1
  83. package/dist/cli/commands/streaming.d.ts +3 -1
  84. package/dist/cli/commands/wizardFlow.d.ts +2 -0
  85. package/dist/cli/commands/wizardFlow.js +3 -0
  86. package/dist/cli/index.js +8 -4
  87. package/dist/cli/terminalTitle.js +9 -3
  88. package/dist/config/contextFiles.d.ts +2 -5
  89. package/dist/config/contextFiles.js +1 -1
  90. package/dist/config/inputHistory.js +2 -2
  91. package/dist/config/providerAuth.js +2 -2
  92. package/dist/config/providerModelFacts.js +5 -0
  93. package/dist/config/providerPresets.js +1 -1
  94. package/dist/config/settings.d.ts +7 -0
  95. package/dist/config/settings.js +9 -2
  96. package/dist/config/updateCheck.js +2 -2
  97. package/dist/core/agent/completionController.d.ts +1 -1
  98. package/dist/core/agent/contextBudget.d.ts +1 -1
  99. package/dist/core/agent/goalPolicy.js +8 -2
  100. package/dist/core/agent/overflow.js +5 -0
  101. package/dist/core/agent/toolCapabilities.js +14 -0
  102. package/dist/core/agent/userCommands.d.ts +53 -0
  103. package/dist/core/agent/userCommands.js +116 -0
  104. package/dist/core/agent/workState.d.ts +3 -1
  105. package/dist/core/agent/workState.js +57 -26
  106. package/dist/core/contextFileTypes.d.ts +12 -0
  107. package/dist/core/contextFileTypes.js +1 -0
  108. package/dist/core/graph/buildGraph.js +1 -1
  109. package/dist/core/graph/store.js +1 -1
  110. package/dist/core/limits.d.ts +2 -0
  111. package/dist/core/limits.js +2 -0
  112. package/dist/core/log/llmLog.js +2 -2
  113. package/dist/{config → core/persistence}/privateStorage.js +1 -1
  114. package/dist/core/process/runBoundedProcess.d.ts +7 -4
  115. package/dist/core/process/runBoundedProcess.js +10 -5
  116. package/dist/core/safety/redaction.d.ts +2 -0
  117. package/dist/core/safety/redaction.js +26 -5
  118. package/dist/core/safety/secretPaths.js +12 -3
  119. package/dist/core/safety/urlGuard.js +2 -0
  120. package/dist/core/session/sessionStore.d.ts +8 -1
  121. package/dist/core/session/sessionStore.js +15 -4
  122. package/dist/core/shellOutput/reducers/validation.d.ts +1 -1
  123. package/dist/core/shellOutput/types.d.ts +1 -1
  124. package/dist/{llm → core}/toolResultTypes.d.ts +1 -1
  125. package/dist/core/validation/outputParser.d.ts +1 -1
  126. package/dist/llm/hazeTools.js +2 -0
  127. package/dist/llm/lsp/pool.js +1 -1
  128. package/dist/llm/lsp/workspaceEdit.d.ts +1 -1
  129. package/dist/llm/requestContext.d.ts +3 -0
  130. package/dist/llm/requestContext.js +20 -8
  131. package/dist/llm/systemPrompt.js +10 -3
  132. package/dist/llm/toolGroups.d.ts +534 -0
  133. package/dist/llm/toolGroups.js +57 -0
  134. package/dist/llm/tools/editMatch.d.ts +1 -1
  135. package/dist/llm/tools/failures.d.ts +1 -1
  136. package/dist/llm/tools/fileToolShared.d.ts +1 -1
  137. package/dist/llm/tools/fileToolShared.js +1 -1
  138. package/dist/llm/tools/fileTools.js +1 -1
  139. package/dist/llm/tools/gitTools.d.ts +12 -0
  140. package/dist/llm/tools/gitTools.js +527 -0
  141. package/dist/llm/tools/readRecovery.d.ts +1 -1
  142. package/dist/llm/tools/replaceInFiles.d.ts +1 -1
  143. package/dist/llm/tools/replaceInFiles.js +1 -1
  144. package/dist/llm/tools/taskTool.js +4 -1
  145. package/dist/llm/tools/toolContext.js +5 -2
  146. package/dist/llm/tools/toolContextState.d.ts +1 -1
  147. package/dist/llm/tools/workspaceFile.d.ts +2 -2
  148. package/dist/llm/tools/workspaceFile.js +10 -5
  149. package/dist/skills/SkillRegistry.js +1 -1
  150. package/dist/skills/builder/SkillBuilder.js +1 -1
  151. package/dist/skills/plugins/installer.js +1 -1
  152. package/dist/skills/plugins/runtime.js +1 -1
  153. package/dist/ui/components/MarkdownText.d.ts +14 -0
  154. package/dist/ui/components/MarkdownText.js +77 -12
  155. package/dist/ui/components/NativeIndicators.js +5 -1
  156. package/dist/ui/components/StreamingMarkdownText.d.ts +3 -1
  157. package/dist/ui/components/StreamingMarkdownText.js +39 -11
  158. package/dist/ui/components/TextInput.d.ts +1 -2
  159. package/dist/ui/components/TextInput.js +79 -9
  160. package/dist/ui/components/WizardChoices.d.ts +1 -2
  161. package/dist/ui/components/useInputSuggestions.d.ts +1 -1
  162. package/dist/ui/components/useInputSuggestions.js +1 -1
  163. package/dist/ui/mentionDetection.d.ts +20 -0
  164. package/dist/ui/mentionDetection.js +24 -0
  165. package/dist/ui/terminalColors.d.ts +4 -4
  166. package/dist/ui/terminalColors.js +23 -6
  167. package/dist/ui/terminalSanitize.js +8 -3
  168. package/dist/ui/textGeometry.d.ts +2 -0
  169. package/dist/ui/textGeometry.js +6 -0
  170. package/dist/ui/themes/registry.js +33 -33
  171. package/dist/utils/openPath.js +7 -0
  172. package/package.json +13 -13
  173. /package/dist/{llm/tools → core/ignore}/gitIgnore.d.ts +0 -0
  174. /package/dist/{llm/tools → core/ignore}/gitIgnore.js +0 -0
  175. /package/dist/{config → core}/paths.d.ts +0 -0
  176. /package/dist/{config → core}/paths.js +0 -0
  177. /package/dist/{config → core/persistence}/privateStorage.d.ts +0 -0
  178. /package/dist/{llm → core}/toolResultTypes.js +0 -0
@@ -0,0 +1,399 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useReducer, useRef, useState } from 'react';
3
+ import { useApp, useWindowSize } from 'ink';
4
+ import { addInputHistoryItem, readInputHistory } from '../../config/inputHistory.js';
5
+ import { loadTasks as loadTasksFromStore, clearTasks as clearTasksFromStore } from '../../core/tasks/taskStorage.js';
6
+ import { activeModel } from '../../config/providers.js';
7
+ import { isSkillEnabled } from '../../config/skillSettings.js';
8
+ import { checkpointFromGoalFrontier } from '../commands/streaming/goalCheckpoint.js';
9
+ import { finalizeMessage as finalizeMessageImpl } from './messageFinalize.js';
10
+ import { submit as submitImpl } from './submitPipeline.js';
11
+ import { runAgentTurnWithFollowUps, resumePausedGoal } from './agentTurnRunner.js';
12
+ import { endLog as endLlmLog } from '../../core/log/llmLog.js';
13
+ import { taskBarCollapsePadding } from './TaskBar.js';
14
+ import { createChatShutdown } from './shutdown.js';
15
+ import { createResizeSettler } from './resizeGuard.js';
16
+ import { useChatViewModel } from './chatViewModel.js';
17
+ import { ChatHeaderSubtitle } from './ChatHeader.js';
18
+ import { readRenderMetrics } from './renderMetrics.js';
19
+ import { ChatScreenView } from './ChatScreenView.js';
20
+ import { useLiveMessages } from './liveMessages.js';
21
+ import { createSessionRecorder } from './sessionRecorder.js';
22
+ import { createSessionLifecycle } from './sessionLifecycle.js';
23
+ import { createWizardDispatch, initialWizardUiState, wizardUiReducer } from './wizardDispatch.js';
24
+ import { randomTipIndex, tipsEnabled } from './tips.js';
25
+ import { EMPTY_CONTEXT_USAGE, EMPTY_TOKEN_USAGE } from './turnState.js';
26
+ import { contextFileSignatureMap, prepareUserInput as prepareUserInputPolicy } from './userInput.js';
27
+ import { currentBranchName, runStartupSequence } from './startupSequence.js';
28
+ import { useFollowUpQueue } from './followUpQueue.js';
29
+ import { useBusyIndicator } from './busyIndicator.js';
30
+ import { useTerminalControl } from './terminalControl.js';
31
+ import { modelThinkingLabel } from '../../utils/modelName.js';
32
+ import { commandParts } from '../commands/wizardFlow.js';
33
+ import { backgroundProcessCount, subscribeBackgroundProcesses, teardownBackgroundProcesses } from '../../core/process/backgroundRegistry.js';
34
+ import { loadSkillsWithNotices, initialSkillNoticeState } from './skillNotices.js';
35
+ import { createPickerOpeners } from './pickerOpeners.js';
36
+ import { useSettingsSelection } from './settingsSelection.js';
37
+ import { useLiveTheme } from './liveTheme.js';
38
+ import { useWizardNavigation } from './wizardTrail.js';
39
+ import { usePromptSession } from './promptSessionState.js';
40
+ import { runUserCommandLine } from './userCommandFlow.js';
41
+ function thinkingLabelForSettings(settings) {
42
+ return modelThinkingLabel(activeModel(settings)?.model);
43
+ }
44
+ export function ChatScreen({ debug = false, version, build, continueSession = false, resumeSessionId, noSession = false, onShutdownReady }) {
45
+ const { exit } = useApp();
46
+ const { columns: width, rows: terminalRows } = useWindowSize();
47
+ // The viewport clears on every width change, but the Static replay that
48
+ // re-parses the whole transcript waits for the resize to settle (FE-04).
49
+ // `tick` forces a replay even when the width returns to its settled value,
50
+ // because the clear already removed the history from the viewport.
51
+ const [replay, setReplay] = useState({ tick: 0, width });
52
+ const previousWidth = useRef(width);
53
+ useEffect(() => {
54
+ if (width === previousWidth.current)
55
+ return;
56
+ previousWidth.current = width;
57
+ const settler = createResizeSettler(settled => setReplay(current => ({ tick: current.tick + 1, width: settled })));
58
+ settler.next(width);
59
+ return () => settler.cancel();
60
+ }, [width]);
61
+ const stoppingRef = useRef(false);
62
+ const sealedRef = useRef(false);
63
+ const activeGoalRef = useRef(undefined);
64
+ const quarantineRef = useRef(undefined);
65
+ const nextDisplayOrderRef = useRef(1);
66
+ const withDisplayOrder = (message) => {
67
+ if (message.displayOrder != null)
68
+ return message;
69
+ return { ...message, displayOrder: nextDisplayOrderRef.current++ };
70
+ };
71
+ const withDisplayOrders = (next) => next.map(withDisplayOrder);
72
+ const [messages, setMessagesRaw] = useState([]);
73
+ const setMessages = (updater) => {
74
+ if (stoppingRef.current)
75
+ return;
76
+ setMessagesRaw(previous => withDisplayOrders(typeof updater === 'function' ? updater(previous) : updater));
77
+ };
78
+ const [settingsError, setSettingsError] = useState();
79
+ const conversationRef = useRef([]);
80
+ const lastAssistantTextRef = useRef('');
81
+ const abortControllerRef = useRef(null);
82
+ const sessionRef = useRef(undefined);
83
+ const sessionRecorderRef = useRef(undefined);
84
+ if (!sessionRecorderRef.current)
85
+ sessionRecorderRef.current = createSessionRecorder(() => sessionRef.current);
86
+ // Settings state and the session-pinned model selection live in chat/settingsSelection.ts.
87
+ const { settings, settingsRef, defaultSelectionRef, setSettings, setSettingsRaw, currentModelSelection } = useSettingsSelection({ conversationRef, sessionRecorderRef, setMessages });
88
+ /** Finalize a formerly-live message into the append-only transcript and session record. */
89
+ function finalizeMessage(message) {
90
+ finalizeMessageImpl(screenDeps(), message);
91
+ }
92
+ // Synchronous live-tail store (see chat/liveMessages.ts): stream callbacks
93
+ // that land inside one React batch window must route against fresh state.
94
+ const { liveMessages, addStreaming, patch: patchLiveMessage, drain: drainLiveMessages, clear: clearLiveMessages } = useLiveMessages(finalizeMessage);
95
+ const sessionStartRef = useRef(new Date());
96
+ // The stable PromptSession and its per-model reasoning overrides live in chat/promptSessionState.ts.
97
+ const { currentPromptSession, setSessionReasoningOverride, reasoningOverrideCounter } = usePromptSession(sessionStartRef);
98
+ const workStateRef = useRef(undefined);
99
+ const llmLogRef = useRef(undefined);
100
+ const persistenceWarningShownRef = useRef(false);
101
+ const skillNoticesRef = useRef(initialSkillNoticeState());
102
+ const contextFileSignaturesRef = useRef(new Map());
103
+ const followUps = useFollowUpQueue(text => setMessages(m => [...m, { role: 'system', text }]));
104
+ const [inputHistory, setInputHistory] = useState([]);
105
+ const [debugLogs, setDebugLogs] = useState([]);
106
+ const [contextFiles, setContextFiles] = useState([]);
107
+ const [mode, setModeRaw] = useState('chat');
108
+ // Wizard steps keep a trail so Esc goes back one step (chat/wizardTrail.ts).
109
+ const { setMode, goBack } = useWizardNavigation(setModeRaw);
110
+ const [sessions, setSessions] = useState([]);
111
+ // Busy indicator with a one-second heartbeat: ticks while haze is working so
112
+ // the developer always sees rolling activity (elapsed turn time) even when
113
+ // the model is thinking with no streamed output and no tool is running.
114
+ const { busy, setBusy: setBusyWithHeartbeat, elapsed: busyElapsed } = useBusyIndicator();
115
+ // Fleet depth for the busy row; folded from coordinator events so a
116
+ // minutes-long fan-out turn visibly progresses (workers running/queued).
117
+ const [fleet, setFleet] = useState(undefined);
118
+ const terminalControl = useTerminalControl();
119
+ const [backgroundCount, setBackgroundCount] = useState(backgroundProcessCount);
120
+ const [busyLabel, setBusyLabel] = useState(() => thinkingLabelForSettings(settings));
121
+ const [visibleTasks, setVisibleTasks] = useState([]);
122
+ const [tasksExpanded, setTasksExpanded] = useState(false);
123
+ const [taskBarPadding, setTaskBarPadding] = useState(0);
124
+ const [tokenUsage, setTokenUsage] = useState({ ...EMPTY_TOKEN_USAGE }), [contextUsage, setContextUsage] = useState({ ...EMPTY_CONTEXT_USAGE });
125
+ // A genuinely paused goal (no measurable progress, deadline, or a stalled
126
+ // model stream) — automatic continuation has already been attempted by the
127
+ // goal supervisor. Carries what a one-key resume needs; any new submission
128
+ // clears it.
129
+ const [pausedResume, setPausedResume] = useState(undefined);
130
+ const [skills, setSkills] = useState([]);
131
+ const [branchName, setBranchName] = useState();
132
+ const [graphBuilding, setGraphBuilding] = useState(false);
133
+ const shutdownRef = useRef(undefined);
134
+ if (!shutdownRef.current)
135
+ shutdownRef.current = createChatShutdown({
136
+ stop: () => { stoppingRef.current = true; followUps.clear(); },
137
+ abort: () => abortControllerRef.current?.abort('Chat is exiting.'),
138
+ settle: () => activeGoalRef.current,
139
+ seal: () => {
140
+ drainLiveMessages();
141
+ sealedRef.current = true;
142
+ quarantineRef.current?.();
143
+ },
144
+ flush: () => sessionRecorderRef.current?.flush(),
145
+ endLog: () => {
146
+ const log = llmLogRef.current;
147
+ llmLogRef.current = undefined;
148
+ return log ? endLlmLog(log) : undefined;
149
+ },
150
+ cleanup: async () => {
151
+ await Promise.all([teardownBackgroundProcesses(), clearTasksFromStore()]);
152
+ },
153
+ exit,
154
+ report: message => process.stderr.write(`[haze] ${message}\n`),
155
+ });
156
+ const shutdown = shutdownRef.current;
157
+ useEffect(() => {
158
+ onShutdownReady?.(shutdown);
159
+ return () => { void shutdown(); };
160
+ }, [onShutdownReady, shutdown]);
161
+ // Wizard flow state (selection, drafts, model discovery) in one reducer;
162
+ // this replaced twelve individual useState hooks.
163
+ const [wizardState, updateWizard] = useReducer(wizardUiReducer, undefined, initialWizardUiState);
164
+ useEffect(() => subscribeBackgroundProcesses(() => setBackgroundCount(backgroundProcessCount())), []);
165
+ // One tip per thinking section, shown under the busy label while the model
166
+ // is purely thinking (no tool running) and the user has not disabled tips.
167
+ // A fresh tip is picked each time the model enters thinking mode; no
168
+ // rotation during a single thinking section.
169
+ const [tipIndex, setTipIndex] = useState(() => randomTipIndex());
170
+ const thinkingLabel = thinkingLabelForSettings(settings);
171
+ const showingTip = busy && busyLabel === thinkingLabel && tipsEnabled(settings);
172
+ useEffect(() => {
173
+ if (!showingTip)
174
+ return;
175
+ setTipIndex(current => randomTipIndex(current));
176
+ }, [showingTip]);
177
+ // Refresh the branch at turn boundaries so switching branches during a turn
178
+ // shows up promptly without tight idle polling (CR-026).
179
+ useEffect(() => {
180
+ if (busy)
181
+ return;
182
+ currentBranchName().then(setBranchName).catch(() => setBranchName(undefined));
183
+ }, [busy]);
184
+ // Live theme switching (/themes) lives in chat/liveTheme.ts.
185
+ const settingsThemeLoadedRef = useRef(false);
186
+ useLiveTheme(settings, stoppingRef, settingsThemeLoadedRef);
187
+ useEffect(() => {
188
+ void runStartupSequence({
189
+ version,
190
+ onLoaded({ settings: next, settingsError, branchName: branch, contextFiles: files }) {
191
+ setSettings(next);
192
+ settingsThemeLoadedRef.current = true;
193
+ setSettingsError(settingsError);
194
+ setBranchName(branch);
195
+ setContextFiles(files);
196
+ contextFileSignaturesRef.current = contextFileSignatureMap(files);
197
+ },
198
+ initializeSession: () => sessionLifecycle.initializeSession(),
199
+ refreshSkills,
200
+ addSystemMessage: text => setMessages(m => [...m, { role: 'system', text }]),
201
+ onGraphActivity: setGraphBuilding,
202
+ }).catch(() => undefined);
203
+ readInputHistory().then(setInputHistory).catch(() => undefined);
204
+ loadTasksFromStore().then(setVisibleTasks).catch(() => undefined);
205
+ const branchTimer = setInterval(() => {
206
+ currentBranchName().then(setBranchName).catch(() => setBranchName(undefined));
207
+ }, 15_000);
208
+ return () => clearInterval(branchTimer);
209
+ }, []);
210
+ function persistInputHistory(value) {
211
+ addInputHistoryItem(value).then(setInputHistory).catch(() => undefined);
212
+ }
213
+ async function refreshSkills() {
214
+ const next = await loadSkillsWithNotices(skillNoticesRef.current);
215
+ skillNoticesRef.current = next.state;
216
+ setSkills(next.skills);
217
+ for (const text of next.messages)
218
+ setMessages(messages => [...messages, { role: 'system', text }]);
219
+ return next.skills;
220
+ }
221
+ function skillInvocation(value) {
222
+ if (!value.startsWith('/'))
223
+ return undefined;
224
+ const [name, ...args] = commandParts(value.slice(1));
225
+ if (!name)
226
+ return undefined;
227
+ const skill = skills.find(candidate => candidate.name === name && isSkillEnabled(settings, candidate.name, candidate.source));
228
+ // Candidates are ordered project-first, so disabling a project collision
229
+ // automatically re-surfaces the enabled global skill.
230
+ return skill ? { skill, args: args.join(' ') } : undefined;
231
+ }
232
+ function debugLog(line) {
233
+ if (!debug || stoppingRef.current)
234
+ return;
235
+ setDebugLogs(current => [...current.slice(-7), line]);
236
+ }
237
+ function showPersistenceWarning(error) {
238
+ if (persistenceWarningShownRef.current)
239
+ return;
240
+ persistenceWarningShownRef.current = true;
241
+ const text = error instanceof Error ? error.message : String(error);
242
+ setMessages(messages => [...messages, { role: 'system', text: `Persistence warning: ${text}` }]);
243
+ }
244
+ // Session lifecycle (init/continue/resume/new/clear/compact) lives in a
245
+ // dedicated controller so this component stays orchestration glue (CR-006).
246
+ const sessionLifecycle = createSessionLifecycle({
247
+ version,
248
+ build,
249
+ continueSession,
250
+ resumeSessionId,
251
+ noSession,
252
+ debug,
253
+ contextFiles: () => contextFiles,
254
+ modelSelection: currentModelSelection,
255
+ reasoningByModel: () => currentPromptSession().reasoningByModel,
256
+ onModelSelection: selection => {
257
+ const model = selection ? { provider: selection.provider, model: selection.model } : defaultSelectionRef.current;
258
+ settingsRef.current = { ...settingsRef.current, ...model };
259
+ setSettingsRaw(settingsRef.current);
260
+ },
261
+ sessionRef,
262
+ sessionRecorder: () => sessionRecorderRef.current,
263
+ sessionStartRef,
264
+ conversationRef,
265
+ workStateRef,
266
+ lastAssistantTextRef,
267
+ llmLogRef,
268
+ contextFileSignaturesRef,
269
+ setMessages,
270
+ clearLiveMessages,
271
+ setTokenUsage, setContextUsage,
272
+ manualCompaction: () => settings.manualCompaction ?? 'llm-summary',
273
+ redactSessionSecrets: () => settings.redactSessionSecrets === true,
274
+ // P1 resume path: an unterminated goal frontier detected on resume becomes
275
+ // the same one-key continue affordance the in-process pause uses — the
276
+ // goal continues from the stored frontier without re-sending the request.
277
+ onGoalFrontier: frontier => {
278
+ const checkpoint = checkpointFromGoalFrontier(frontier);
279
+ setPausedResume({ kind: 'incomplete-goal', request: frontier.request, retryAttempt: 0, checkpoint });
280
+ setMessages(m => [...m, { role: 'system', text: `This session ended with an unfinished goal (cycle ${frontier.cycle}, ${frontier.mutationCount} change${frontier.mutationCount === 1 ? '' : 's'} so far). Press R to resume it from where it stopped.` }]);
281
+ },
282
+ debugLog,
283
+ showPersistenceWarning,
284
+ });
285
+ const { openSessionPicker, openPluginPicker } = createPickerOpeners({
286
+ flush: () => sessionRecorderRef.current?.flush() ?? Promise.resolve(),
287
+ onFlushError: showPersistenceWarning,
288
+ setSessions,
289
+ updateWizard,
290
+ setMode,
291
+ setMessages,
292
+ });
293
+ function cancelThinking() {
294
+ if (!busy)
295
+ return;
296
+ abortControllerRef.current?.abort('User pressed Esc.');
297
+ followUps.clear();
298
+ setBusyWithHeartbeat(false);
299
+ }
300
+ function closeInputList() {
301
+ if (mode === 'chat')
302
+ return;
303
+ if (goBack())
304
+ return;
305
+ setMode('chat');
306
+ setSessions([]);
307
+ updateWizard({ type: 'reset' });
308
+ }
309
+ function showWizardMessage(message) {
310
+ if (message)
311
+ setMessages(m => [...m, { role: 'system', text: message }]);
312
+ }
313
+ // Wizard/picker submit dispatch lives in one table-driven module with a
314
+ // shared settings-patch applier (CR-006). Rebuilt every render so handlers
315
+ // see current state without new React state.
316
+ const wizard = createWizardDispatch({
317
+ settings, skills, sessions,
318
+ wizard: wizardState, updateWizard,
319
+ setMode, setSettings,
320
+ showMessage: showWizardMessage, refreshSkills,
321
+ resumeSessionById: sessionLifecycle.resumeSessionById,
322
+ forkSessionById: sessionLifecycle.forkSessionById,
323
+ setBusyLabel, setBusy: setBusyWithHeartbeat,
324
+ idleBusyLabel: thinkingLabelForSettings(settings),
325
+ sessionReasoning: {
326
+ modelSelector: () => { const selection = activeModel(settings); return selection ? `${selection.provider.name}:${selection.model}` : undefined; },
327
+ get: modelSelector => currentPromptSession().reasoningByModel?.[modelSelector],
328
+ set: setSessionReasoningOverride,
329
+ },
330
+ });
331
+ // The submit pipeline (exit shortcut, settings repair, busy queue, wizard,
332
+ // skill invocation, slash commands, agent turn) lives in chat/submitPipeline.ts.
333
+ async function submit(value) {
334
+ return submitImpl(screenDeps(), value);
335
+ }
336
+ // F03: attachment gating and read blessings live in the pure helper
337
+ // (chat/userInput.ts); this wrapper only surfaces its errors as system
338
+ // messages. Applied only to genuine user input, never synthetic control prompts.
339
+ async function prepareUserInput(value) {
340
+ const prepared = await prepareUserInputPolicy(value, settings);
341
+ if (prepared?.error) {
342
+ setMessages(m => [...m, { role: 'system', text: prepared.error }]);
343
+ return undefined;
344
+ }
345
+ return prepared;
346
+ }
347
+ // Turn submission (follow-up drain) and the one-key paused-goal resume live
348
+ // in chat/agentTurnRunner.ts.
349
+ function doAgentTurn(value, displayValue, turnOptions = {}) {
350
+ return runAgentTurnWithFollowUps(screenDeps(), value, displayValue, turnOptions);
351
+ }
352
+ function resumePausedTask() {
353
+ return resumePausedGoal(screenDeps());
354
+ }
355
+ /** Assemble the explicit deps bundle the extracted ChatScreen bodies receive. */
356
+ function screenDeps() {
357
+ return {
358
+ stoppingRef, sealedRef, quarantineRef, activeGoalRef, conversationRef, settingsRef,
359
+ sessionRef, sessionRecorderRef, sessionStartRef, workStateRef, lastAssistantTextRef,
360
+ abortControllerRef, llmLogRef, contextFileSignaturesRef,
361
+ settings, settingsError, contextFiles, mode, busy, pausedResume, visibleTasks,
362
+ setMessages, setSettings, setSettingsError, setMode, setContextFiles,
363
+ setBusy: setBusyWithHeartbeat, setBusyLabel, setTokenUsage, setContextUsage, setFleet,
364
+ setVisibleTasks, setTaskBarPadding, setTasksExpanded, setPausedResume, setDebugLogs, updateWizard,
365
+ currentModelSelection, currentPromptSession, withDisplayOrder, finalizeMessage,
366
+ addStreaming, patchLiveMessage, drainLiveMessages, clearLiveMessages,
367
+ debugLog, showPersistenceWarning, skillInvocation, prepareUserInput, doAgentTurn,
368
+ runUserCommand: command => runUserCommandLine(screenDeps(), command),
369
+ openSessionPicker, openPluginPicker, refreshSkills, setSessionReasoningOverride,
370
+ shutdown, followUps, wizard, sessionLifecycle, terminalControl, noSession,
371
+ };
372
+ }
373
+ // Derived render values (memoised on the identity of their inputs, FE-03)
374
+ // live in chat/chatViewModel.ts; only the header item is composed here.
375
+ const view = useChatViewModel({
376
+ messages, liveMessages, busy, fleet, settings, mode, tokenUsage, backgroundCount, skills, branchName, sessions,
377
+ wizard: wizardState,
378
+ selectedModel: currentModelSelection(),
379
+ sessionReasoning: currentPromptSession().reasoningByModel,
380
+ reasoningOverrideCounter, width, replayWidth: replay.width,
381
+ });
382
+ const staticItems = [{ kind: 'header', key: 'header', subtitle: _jsx(ChatHeaderSubtitle, {}) }, ...view.staticTranscriptItems];
383
+ // The pure screen render (static transcript + dynamic frame) lives in chat/ChatScreenView.tsx.
384
+ return _jsx(ChatScreenView, { version: version, debug: debug, terminalRows: terminalRows, horizontalPadding: view.horizontalPadding, contentWidth: view.contentWidth, replay: { key: `${replay.tick}:${replay.width}`, contentWidth: view.replayContentWidth }, staticItems: staticItems, streamingItems: view.streamingItems, debugLogs: debugLogs, metrics: view.metrics, renderMetricsReader: readRenderMetrics, tokenUsage: tokenUsage, contextUsage: contextUsage, followUps: followUps, visibleTasks: visibleTasks, tasksExpanded: tasksExpanded, taskBarPadding: taskBarPadding, busy: busy, busyLabel: busyLabel, busyElapsed: busyElapsed, busyDetail: view.busyDetail, showingTip: showingTip, tipIndex: tipIndex, graphBuilding: graphBuilding, pausedResume: pausedResume, workspaceLabel: view.workspaceLabel, activeModelName: view.activeModelName, reasoningSuffix: view.reasoningSuffix, placeholder: view.placeholder, mode: mode, inputHistory: inputHistory, inputSuggestions: view.inputSuggestions, onSubmit: submit, onCancel: cancelThinking, onResumeKey: pausedResume != null && !busy ? resumePausedTask : undefined, onInterrupt: () => { void shutdown(); }, onEscape: () => {
385
+ if (busy)
386
+ cancelThinking();
387
+ else
388
+ closeInputList();
389
+ }, onHistoryAdd: persistInputHistory, onToggleTasks: () => {
390
+ if (!tasksExpanded) {
391
+ setTaskBarPadding(0);
392
+ setTasksExpanded(true);
393
+ }
394
+ else {
395
+ setTaskBarPadding(taskBarCollapsePadding(visibleTasks.length));
396
+ setTasksExpanded(false);
397
+ }
398
+ } });
399
+ }
@@ -0,0 +1,68 @@
1
+ import React from 'react';
2
+ import type { Task } from '../../core/tasks/taskStorage.js';
3
+ import { partitionDisplayMessages, type TranscriptStaticItem } from './transcriptPartition.js';
4
+ import { statusBarMetrics } from './chatMetrics.js';
5
+ import { inputSuggestionsForState } from './inputSuggestions.js';
6
+ import { type Mode } from '../commands/chatModes.js';
7
+ import type { TokenUsage } from '../commands/streaming/turnRuntime.js';
8
+ import type { useFollowUpQueue } from './followUpQueue.js';
9
+ import type { PausedResume } from './screenDeps.js';
10
+ import type { ContextUsage } from './turnState.js';
11
+ export type ChatStaticItem = {
12
+ kind: 'header';
13
+ key: string;
14
+ subtitle: React.ReactNode;
15
+ } | TranscriptStaticItem;
16
+ /**
17
+ * The pure render of the chat screen: static transcript plus the dynamic
18
+ * frame. Extracted from `commands/chat.tsx` so the component file stays
19
+ * orchestration glue; every value arrives as an explicit prop.
20
+ */
21
+ export declare function ChatScreenView(props: {
22
+ version: string | undefined;
23
+ debug: boolean;
24
+ terminalRows: number;
25
+ horizontalPadding: number;
26
+ contentWidth: number;
27
+ /** Settled-width identity for the transcript replay: the Static key and the width its Markdown is laid out at. */
28
+ replay: {
29
+ key: string;
30
+ contentWidth: number;
31
+ };
32
+ staticItems: ChatStaticItem[];
33
+ streamingItems: ReturnType<typeof partitionDisplayMessages>['streamingItems'];
34
+ debugLogs: string[];
35
+ metrics: ReturnType<typeof statusBarMetrics>;
36
+ renderMetricsReader: (() => {
37
+ at: number;
38
+ renderTime: number;
39
+ } | undefined) | undefined;
40
+ tokenUsage: TokenUsage;
41
+ contextUsage: ContextUsage;
42
+ followUps: ReturnType<typeof useFollowUpQueue>;
43
+ visibleTasks: Task[];
44
+ tasksExpanded: boolean;
45
+ taskBarPadding: number;
46
+ busy: boolean;
47
+ busyLabel: string;
48
+ busyElapsed: string;
49
+ busyDetail: string | undefined;
50
+ showingTip: boolean;
51
+ tipIndex: number;
52
+ graphBuilding: boolean;
53
+ pausedResume: PausedResume | undefined;
54
+ workspaceLabel: string;
55
+ activeModelName: string;
56
+ reasoningSuffix: string;
57
+ placeholder: string;
58
+ mode: Mode;
59
+ inputHistory: string[];
60
+ inputSuggestions: ReturnType<typeof inputSuggestionsForState>;
61
+ onSubmit: (value: string) => Promise<void>;
62
+ onCancel: () => void;
63
+ onResumeKey: (() => void) | undefined;
64
+ onInterrupt: () => void;
65
+ onEscape: () => void;
66
+ onHistoryAdd: (value: string) => void;
67
+ onToggleTasks: () => void;
68
+ }): React.JSX.Element;
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Box, Static, Text } from 'ink';
3
+ import { ActivitySpinner, StatusNotice } from '../../ui/components/NativeIndicators.js';
4
+ import { Header } from '../../ui/components/Header.js';
5
+ import { TextInput } from '../../ui/components/TextInput.js';
6
+ import { theme } from '../../ui/theme.js';
7
+ import { TaskBar } from './TaskBar.js';
8
+ import { BusyBar } from './BusyBar.js';
9
+ import { DynamicFrame } from './DynamicFrame.js';
10
+ import { AssistantMarkdownChunkView, MessageView } from './messages.js';
11
+ import { LiveTail } from './LiveTail.js';
12
+ import { contextLeftLabel } from './chatMetrics.js';
13
+ import { fileMentionSuggestions } from './fileMentionSuggestions.js';
14
+ import { TIPS } from './tips.js';
15
+ import { MASKED_MODES, PICKER_MODES, SUBMIT_EMPTY_MODES } from '../commands/chatModes.js';
16
+ import { formatTokenCount } from '../../utils/format.js';
17
+ /**
18
+ * The pure render of the chat screen: static transcript plus the dynamic
19
+ * frame. Extracted from `commands/chat.tsx` so the component file stays
20
+ * orchestration glue; every value arrives as an explicit prop.
21
+ */
22
+ export function ChatScreenView(props) {
23
+ const { version, debug, terminalRows, horizontalPadding, contentWidth, replay, staticItems, streamingItems, debugLogs, metrics, renderMetricsReader, tokenUsage, contextUsage, followUps, visibleTasks, tasksExpanded, taskBarPadding, busy, busyLabel, busyElapsed, busyDetail, showingTip, tipIndex, graphBuilding, pausedResume, workspaceLabel, activeModelName, reasoningSuffix, placeholder, mode, inputHistory, inputSuggestions, onSubmit, onCancel, onResumeKey, onInterrupt, onEscape, onHistoryAdd, onToggleTasks, } = props;
24
+ const contextLabel = contextLeftLabel(contextUsage, metrics.effectiveInput);
25
+ return _jsxs(Box, { flexDirection: "column", paddingX: horizontalPadding, children: [_jsx(Static, { items: staticItems, children: item => item.kind === 'header'
26
+ ? _jsx(Header, { subtitle: item.subtitle, version: version }, item.key)
27
+ : item.kind === 'assistant-markdown'
28
+ ? _jsx(AssistantMarkdownChunkView, { message: item.message, content: item.content, width: replay.contentWidth, first: item.first, final: item.final }, item.key)
29
+ : _jsx(MessageView, { message: item.message, width: replay.contentWidth }, item.key) }, replay.key), _jsx(DynamicFrame, { rows: terminalRows, columns: contentWidth, sections: {
30
+ live: streamingItems.length > 0 ? rows => _jsx(LiveTail, { items: streamingItems, width: contentWidth, rows: rows }) : undefined,
31
+ debug: debug ? _jsxs(_Fragment, { children: [debugLogs.map((line, index) => _jsxs(Text, { color: theme.muted, wrap: "truncate-end", children: ["\u2022 ", line] }, index)), metrics.hasTokenBreakdown && _jsxs(Text, { color: theme.muted, wrap: "truncate-end", children: ["Tokens: in=", formatTokenCount(metrics.effectiveInput), " out=", formatTokenCount(metrics.effectiveOutput), " logical=", formatTokenCount(tokenUsage.logicalInputEstimate)] }), renderMetricsReader && (() => {
32
+ const renderMetrics = renderMetricsReader();
33
+ if (!renderMetrics)
34
+ return null;
35
+ const age = Date.now() - renderMetrics.at;
36
+ // Skip the reading once it is clearly stale; it refreshes on the
37
+ // next frame while anything animated keeps the debug panel alive.
38
+ return age < 5_000 ? _jsxs(Text, { color: theme.muted, wrap: "truncate-end", children: ["Ink render: ", renderMetrics.renderTime.toFixed(1), "ms"] }) : null;
39
+ })()] }) : undefined,
40
+ queue: followUps.queued.length > 0 ? _jsxs(_Fragment, { children: [_jsxs(Text, { color: theme.muted, wrap: "truncate-end", children: ["Queued follow-ups: ", followUps.queued.length] }), followUps.queued.map((item, index) => _jsxs(Text, { color: theme.muted, wrap: "truncate-end", children: [index + 1, ". ", item] }, `${index}-${item}`))] }) : undefined,
41
+ tasks: visibleTasks.length > 0 ? _jsx(TaskBar, { tasks: visibleTasks, width: contentWidth, expanded: tasksExpanded, padding: taskBarPadding, maxRows: Math.max(1, terminalRows - 8) }) : undefined,
42
+ activity: busy ? _jsx(BusyBar, { label: busyLabel, elapsed: busyElapsed, detail: busyDetail, tip: showingTip ? TIPS[tipIndex] : undefined })
43
+ : graphBuilding ? _jsxs(Box, { overflow: "hidden", children: [_jsx(ActivitySpinner, {}), _jsx(Box, { flexShrink: 0, width: 1 }), _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: "Building code graph in the background\u2026" })] })
44
+ : pausedResume ? _jsxs(StatusNotice, { variant: "warning", children: ["Press R to resume \u00B7 unfinished goal paused", pausedResume.pauseReason ? ` (${pausedResume.pauseReason})` : ''] }) : undefined,
45
+ status: _jsxs(_Fragment, { children: [_jsxs(Box, { width: "100%", flexDirection: "row", justifyContent: "space-between", flexShrink: 0, children: [_jsx(Text, { color: theme.muted, wrap: "truncate-end", children: workspaceLabel }), _jsxs(Text, { color: theme.muted, wrap: "truncate-start", children: [activeModelName, reasoningSuffix] })] }), _jsxs(Box, { width: "100%", flexDirection: "row", justifyContent: "space-between", flexShrink: 0, children: [_jsx(Text, { color: theme.muted, wrap: "truncate-end", children: metrics.statusDetailLabel }), contextLabel && _jsx(Text, { color: theme.muted, wrap: "truncate-start", children: contextLabel })] })] }),
46
+ }, input: ({ width: inputWidth, inputRows, suggestionRows, onRowsChange }) => _jsx(TextInput, { placeholder: placeholder, disabled: busy && mode !== 'chat', mask: MASKED_MODES.has(mode), historyItems: inputHistory, recordHistory: mode === 'chat', suggestions: inputSuggestions, suggestionMode: PICKER_MODES.has(mode) ? 'always' : 'slash', submitOnEmpty: SUBMIT_EMPTY_MODES.has(mode), width: inputWidth, inputRows: inputRows, suggestionRows: suggestionRows, onRowsChange: onRowsChange, getMentionSuggestions: fileMentionSuggestions, onHistoryAdd: onHistoryAdd, onToggleTasks: onToggleTasks, onCancel: onCancel, onResumeKey: onResumeKey, onInterrupt: onInterrupt, onEscape: onEscape, onSubmit: onSubmit }) })] });
47
+ }
@@ -0,0 +1,11 @@
1
+ import type { TranscriptStreamingItem } from './transcriptPartition.js';
2
+ /**
3
+ * The dynamic tail's streaming items, clamped to the live-region row budget.
4
+ * Items beyond the budget are not dropped silently: one indicator row counts
5
+ * them, so parallel work that is temporarily out of view stays visible (FE-06).
6
+ */
7
+ export declare function LiveTail({ items, width, rows }: {
8
+ items: TranscriptStreamingItem[];
9
+ width: number;
10
+ rows: number;
11
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from 'ink';
3
+ import { MessageView } from './messages.js';
4
+ import { theme } from '../../ui/theme.js';
5
+ /**
6
+ * The dynamic tail's streaming items, clamped to the live-region row budget.
7
+ * Items beyond the budget are not dropped silently: one indicator row counts
8
+ * them, so parallel work that is temporarily out of view stays visible (FE-06).
9
+ */
10
+ export function LiveTail({ items, width, rows }) {
11
+ if (rows <= 0 || items.length === 0)
12
+ return null;
13
+ // Allocate the sum, not a positive minimum for every pending item.
14
+ let count = Math.min(items.length, Math.floor(rows / 2));
15
+ const hidden = items.length - count;
16
+ if (hidden > 0) {
17
+ // The indicator takes one row; give up an item rather than squeeze the
18
+ // remaining ones below a readable two rows (header or content plus one row).
19
+ const available = rows - 1;
20
+ while (count > 0 && Math.floor(available / count) < 2)
21
+ count -= 1;
22
+ }
23
+ const itemRows = count > 0 ? Math.floor((rows - (hidden > 0 ? 1 : 0)) / count) : 0;
24
+ // Keep the newest items: the last one is the active message being streamed.
25
+ return _jsxs(Box, { flexDirection: "column", children: [hidden > 0 ? _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: `+${items.length - count} more` }) : null, items.slice(items.length - count).map(item => _jsx(Box, { maxHeight: itemRows, flexShrink: 0, overflow: "hidden", children: _jsx(MessageView, { message: item.message, width: width, showHeader: item.showHeader, maxVisibleLines: itemRows - 1 }) }, item.key))] });
26
+ }
@@ -1,10 +1,11 @@
1
- import React from 'react';
2
1
  import type { Task } from '../../core/tasks/taskStorage.js';
3
2
  export declare const MAX_VISIBLE_TASKS = 5;
3
+ /** Rows the transcript gains when an expanded task bar collapses back to `MAX_VISIBLE_TASKS` rows. */
4
+ export declare function taskBarCollapsePadding(visibleTasks: number): number;
4
5
  export declare function TaskBar({ tasks, width, expanded, padding, maxRows }: {
5
6
  tasks: Task[];
6
7
  width: number;
7
8
  expanded: boolean;
8
9
  padding: number;
9
10
  maxRows?: number;
10
- }): React.JSX.Element;
11
+ }): import("react").JSX.Element;
@@ -14,6 +14,10 @@ function taskStatusColor(status) {
14
14
  }
15
15
  }
16
16
  export const MAX_VISIBLE_TASKS = 5;
17
+ /** Rows the transcript gains when an expanded task bar collapses back to `MAX_VISIBLE_TASKS` rows. */
18
+ export function taskBarCollapsePadding(visibleTasks) {
19
+ return Math.max(0, visibleTasks + 1 - (Math.min(visibleTasks, MAX_VISIBLE_TASKS) + 1));
20
+ }
17
21
  export function TaskBar({ tasks, width, expanded, padding, maxRows }) {
18
22
  const maxTitleWidth = Math.max(10, width - 6);
19
23
  const inProgress = tasks.filter(t => t.status === 'in_progress');
@@ -0,0 +1,12 @@
1
+ import type { TurnExecutionOptions } from '../commands/streaming.js';
2
+ import type { ChatScreenDeps } from './screenDeps.js';
3
+ /** A user submission: one turn, then every follow-up queued while it ran (ARCH-05). */
4
+ export declare function runAgentTurnWithFollowUps(deps: ChatScreenDeps, value: string, displayValue?: string, turnOptions?: TurnExecutionOptions): Promise<void>;
5
+ /**
6
+ * Explicitly resume a genuinely paused goal (automatic continuation already
7
+ * ran): an idle-stall resume continues the bounded retry pool; an
8
+ * incomplete-goal resume restarts the supervisor from the stored checkpoint
9
+ * (kind selection in chat/userInput.ts). Both ride the preserved
10
+ * conversation — no completed mutations are replayed.
11
+ */
12
+ export declare function resumePausedGoal(deps: ChatScreenDeps): Promise<void>;