@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.
- package/CHANGELOG.md +38 -0
- package/README.md +30 -6
- package/SECURITY.md +1 -1
- package/bin/haze.js +47 -19
- package/dist/buildInfo.json +3 -3
- package/dist/cli/chat/BusyBar.d.ts +1 -2
- package/dist/cli/chat/ChatHeader.d.ts +6 -0
- package/dist/cli/chat/ChatHeader.js +11 -0
- package/dist/cli/chat/ChatScreen.d.ts +16 -0
- package/dist/cli/chat/ChatScreen.js +399 -0
- package/dist/cli/chat/ChatScreenView.d.ts +68 -0
- package/dist/cli/chat/ChatScreenView.js +47 -0
- package/dist/cli/chat/LiveTail.d.ts +11 -0
- package/dist/cli/chat/LiveTail.js +26 -0
- package/dist/cli/chat/TaskBar.d.ts +3 -2
- package/dist/cli/chat/TaskBar.js +4 -0
- package/dist/cli/chat/agentTurnRunner.d.ts +12 -0
- package/dist/cli/chat/agentTurnRunner.js +177 -0
- package/dist/cli/chat/busyIndicator.js +9 -5
- package/dist/cli/chat/chatMetrics.d.ts +7 -0
- package/dist/cli/chat/chatMetrics.js +15 -1
- package/dist/cli/chat/chatViewModel.d.ts +85 -0
- package/dist/cli/chat/chatViewModel.js +66 -0
- package/dist/cli/chat/fileMentionSuggestions.d.ts +0 -14
- package/dist/cli/chat/fileMentionSuggestions.js +4 -21
- package/dist/cli/chat/liveTheme.d.ts +11 -0
- package/dist/cli/chat/liveTheme.js +26 -0
- package/dist/cli/chat/messageFinalize.d.ts +4 -0
- package/dist/cli/chat/messageFinalize.js +8 -0
- package/dist/cli/chat/messages.js +1 -1
- package/dist/cli/chat/pickerOpeners.d.ts +23 -0
- package/dist/cli/chat/pickerOpeners.js +36 -0
- package/dist/cli/chat/promptSessionState.d.ts +11 -0
- package/dist/cli/chat/promptSessionState.js +39 -0
- package/dist/cli/chat/renderMetrics.d.ts +8 -0
- package/dist/cli/chat/renderMetrics.js +14 -0
- package/dist/cli/chat/resizeGuard.d.ts +11 -0
- package/dist/cli/chat/resizeGuard.js +25 -0
- package/dist/cli/chat/screenDeps.d.ts +116 -0
- package/dist/cli/chat/screenDeps.js +1 -0
- package/dist/cli/chat/sessionLifecycle.d.ts +2 -0
- package/dist/cli/chat/sessionLifecycle.js +4 -1
- package/dist/cli/chat/settingsSelection.d.ts +33 -0
- package/dist/cli/chat/settingsSelection.js +46 -0
- package/dist/cli/chat/skillNotices.d.ts +18 -0
- package/dist/cli/chat/skillNotices.js +26 -0
- package/dist/cli/chat/startupInfo.js +1 -1
- package/dist/cli/chat/submitPipeline.d.ts +8 -0
- package/dist/cli/chat/submitPipeline.js +141 -0
- package/dist/cli/chat/terminalControl.js +1 -1
- package/dist/cli/chat/toolSummaries.d.ts +29 -0
- package/dist/cli/chat/toolSummaries.js +268 -0
- package/dist/cli/chat/turnState.d.ts +8 -0
- package/dist/cli/chat/turnState.js +1 -0
- package/dist/cli/chat/userCommandFlow.d.ts +21 -0
- package/dist/cli/chat/userCommandFlow.js +66 -0
- package/dist/cli/chat/userCommandRunner.d.ts +14 -0
- package/dist/cli/chat/userCommandRunner.js +56 -0
- package/dist/cli/chat/wizard/providerHandlers.js +19 -2
- package/dist/cli/chat/wizardTrail.d.ts +22 -0
- package/dist/cli/chat/wizardTrail.js +55 -0
- package/dist/cli/commands/chat.d.ts +1 -13
- package/dist/cli/commands/chat.js +10 -798
- package/dist/cli/commands/commandHelp.js +7 -5
- package/dist/cli/commands/commandSuggest.d.ts +2 -0
- package/dist/cli/commands/commandSuggest.js +35 -0
- package/dist/cli/commands/commands.js +10 -3
- package/dist/cli/commands/formatters.d.ts +1 -23
- package/dist/cli/commands/formatters.js +3 -252
- package/dist/cli/commands/modelCommand.js +11 -7
- package/dist/cli/commands/reasoningCommand.js +3 -3
- package/dist/cli/commands/runCommand.js +6 -2
- package/dist/cli/commands/streaming/attemptLifecycle.js +1 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +7 -2
- package/dist/cli/commands/streaming/attemptSetup.d.ts +1 -0
- package/dist/cli/commands/streaming/attemptSetup.js +26 -2
- package/dist/cli/commands/streaming/goalCheckpoint.d.ts +1 -1
- package/dist/cli/commands/streaming/stepProjection.d.ts +59 -0
- package/dist/cli/commands/streaming/stepProjection.js +54 -0
- package/dist/cli/commands/streaming/streamLoop.js +31 -23
- package/dist/cli/commands/streaming/toolGroupRenderer.js +1 -1
- package/dist/cli/commands/streaming/toolPartHandlers.js +1 -1
- package/dist/cli/commands/streaming.d.ts +3 -1
- package/dist/cli/commands/wizardFlow.d.ts +2 -0
- package/dist/cli/commands/wizardFlow.js +3 -0
- package/dist/cli/index.js +8 -4
- package/dist/cli/terminalTitle.js +9 -3
- package/dist/config/contextFiles.d.ts +2 -5
- package/dist/config/contextFiles.js +1 -1
- package/dist/config/inputHistory.js +2 -2
- package/dist/config/providerAuth.js +2 -2
- package/dist/config/providerModelFacts.js +5 -0
- package/dist/config/providerPresets.js +1 -1
- package/dist/config/settings.d.ts +7 -0
- package/dist/config/settings.js +9 -2
- package/dist/config/updateCheck.js +2 -2
- package/dist/core/agent/completionController.d.ts +1 -1
- package/dist/core/agent/contextBudget.d.ts +1 -1
- package/dist/core/agent/goalPolicy.js +8 -2
- package/dist/core/agent/overflow.js +5 -0
- package/dist/core/agent/toolCapabilities.js +14 -0
- package/dist/core/agent/userCommands.d.ts +53 -0
- package/dist/core/agent/userCommands.js +116 -0
- package/dist/core/agent/workState.d.ts +3 -1
- package/dist/core/agent/workState.js +57 -26
- package/dist/core/contextFileTypes.d.ts +12 -0
- package/dist/core/contextFileTypes.js +1 -0
- package/dist/core/graph/buildGraph.js +1 -1
- package/dist/core/graph/store.js +1 -1
- package/dist/core/limits.d.ts +2 -0
- package/dist/core/limits.js +2 -0
- package/dist/core/log/llmLog.js +2 -2
- package/dist/{config → core/persistence}/privateStorage.js +1 -1
- package/dist/core/process/runBoundedProcess.d.ts +7 -4
- package/dist/core/process/runBoundedProcess.js +10 -5
- package/dist/core/safety/redaction.d.ts +2 -0
- package/dist/core/safety/redaction.js +26 -5
- package/dist/core/safety/secretPaths.js +12 -3
- package/dist/core/safety/urlGuard.js +2 -0
- package/dist/core/session/sessionStore.d.ts +8 -1
- package/dist/core/session/sessionStore.js +15 -4
- package/dist/core/shellOutput/reducers/validation.d.ts +1 -1
- package/dist/core/shellOutput/types.d.ts +1 -1
- package/dist/{llm → core}/toolResultTypes.d.ts +1 -1
- package/dist/core/validation/outputParser.d.ts +1 -1
- package/dist/llm/hazeTools.js +2 -0
- package/dist/llm/lsp/pool.js +1 -1
- package/dist/llm/lsp/workspaceEdit.d.ts +1 -1
- package/dist/llm/requestContext.d.ts +3 -0
- package/dist/llm/requestContext.js +20 -8
- package/dist/llm/systemPrompt.js +10 -3
- package/dist/llm/toolGroups.d.ts +534 -0
- package/dist/llm/toolGroups.js +57 -0
- package/dist/llm/tools/editMatch.d.ts +1 -1
- package/dist/llm/tools/failures.d.ts +1 -1
- package/dist/llm/tools/fileToolShared.d.ts +1 -1
- package/dist/llm/tools/fileToolShared.js +1 -1
- package/dist/llm/tools/fileTools.js +1 -1
- package/dist/llm/tools/gitTools.d.ts +12 -0
- package/dist/llm/tools/gitTools.js +527 -0
- package/dist/llm/tools/readRecovery.d.ts +1 -1
- package/dist/llm/tools/replaceInFiles.d.ts +1 -1
- package/dist/llm/tools/replaceInFiles.js +1 -1
- package/dist/llm/tools/taskTool.js +4 -1
- package/dist/llm/tools/toolContext.js +5 -2
- package/dist/llm/tools/toolContextState.d.ts +1 -1
- package/dist/llm/tools/workspaceFile.d.ts +2 -2
- package/dist/llm/tools/workspaceFile.js +10 -5
- package/dist/skills/SkillRegistry.js +1 -1
- package/dist/skills/builder/SkillBuilder.js +1 -1
- package/dist/skills/plugins/installer.js +1 -1
- package/dist/skills/plugins/runtime.js +1 -1
- package/dist/ui/components/MarkdownText.d.ts +14 -0
- package/dist/ui/components/MarkdownText.js +77 -12
- package/dist/ui/components/NativeIndicators.js +5 -1
- package/dist/ui/components/StreamingMarkdownText.d.ts +3 -1
- package/dist/ui/components/StreamingMarkdownText.js +39 -11
- package/dist/ui/components/TextInput.d.ts +1 -2
- package/dist/ui/components/TextInput.js +79 -9
- package/dist/ui/components/WizardChoices.d.ts +1 -2
- package/dist/ui/components/useInputSuggestions.d.ts +1 -1
- package/dist/ui/components/useInputSuggestions.js +1 -1
- package/dist/ui/mentionDetection.d.ts +20 -0
- package/dist/ui/mentionDetection.js +24 -0
- package/dist/ui/terminalColors.d.ts +4 -4
- package/dist/ui/terminalColors.js +23 -6
- package/dist/ui/terminalSanitize.js +8 -3
- package/dist/ui/textGeometry.d.ts +2 -0
- package/dist/ui/textGeometry.js +6 -0
- package/dist/ui/themes/registry.js +33 -33
- package/dist/utils/openPath.js +7 -0
- package/package.json +13 -13
- /package/dist/{llm/tools → core/ignore}/gitIgnore.d.ts +0 -0
- /package/dist/{llm/tools → core/ignore}/gitIgnore.js +0 -0
- /package/dist/{config → core}/paths.d.ts +0 -0
- /package/dist/{config → core}/paths.js +0 -0
- /package/dist/{config → core/persistence}/privateStorage.d.ts +0 -0
- /package/dist/{llm → core}/toolResultTypes.js +0 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { runAgentGoal } from '../commands/streaming/goalSupervisor.js';
|
|
2
|
+
import { createQuarantinableCallbacks } from '../commands/streaming/attemptLifecycle.js';
|
|
3
|
+
import { resolveModelSelector } from '../../config/providers.js';
|
|
4
|
+
import { providerEndpointFingerprint } from '../../config/providers.js';
|
|
5
|
+
import { loadTasks as loadTasksFromStore } from '../../core/tasks/taskStorage.js';
|
|
6
|
+
import { accumulateTokenUsage } from './turnState.js';
|
|
7
|
+
import { nextFleetStatus } from './chatMetrics.js';
|
|
8
|
+
import { clearTasks as clearTasksFromStore } from '../../core/tasks/taskStorage.js';
|
|
9
|
+
import { shouldClearCompletedTasks } from './turnState.js';
|
|
10
|
+
import { resumeKindFor } from './userInput.js';
|
|
11
|
+
import { routeQueuedLine } from './userCommandFlow.js';
|
|
12
|
+
/** A user submission: one turn, then every follow-up queued while it ran (ARCH-05). */
|
|
13
|
+
export async function runAgentTurnWithFollowUps(deps, value, displayValue, turnOptions = {}) {
|
|
14
|
+
if (deps.stoppingRef.current)
|
|
15
|
+
return;
|
|
16
|
+
deps.setDebugLogs([]);
|
|
17
|
+
// When every task is already completed, start the new turn with a clean
|
|
18
|
+
// slate: the task bar clears (nothing shown for simple questions) and the
|
|
19
|
+
// model may create fresh todos via writeTasks if the new question warrants.
|
|
20
|
+
if (shouldClearCompletedTasks(deps.visibleTasks)) {
|
|
21
|
+
deps.setVisibleTasks([]);
|
|
22
|
+
deps.setTasksExpanded(false);
|
|
23
|
+
deps.setTaskBarPadding(0);
|
|
24
|
+
await clearTasksFromStore().catch(() => undefined);
|
|
25
|
+
}
|
|
26
|
+
await runSingleAgentTurn(deps, value, displayValue, turnOptions);
|
|
27
|
+
for (let next = deps.followUps.takeNext(); !deps.stoppingRef.current && next !== undefined; next = deps.followUps.takeNext()) {
|
|
28
|
+
// A queued `!` line is a user command, not a prompt.
|
|
29
|
+
const routed = await routeQueuedLine(deps, next);
|
|
30
|
+
if (routed.handled)
|
|
31
|
+
continue;
|
|
32
|
+
const preparedFollowUp = await deps.prepareUserInput(routed.value);
|
|
33
|
+
if (!preparedFollowUp)
|
|
34
|
+
continue;
|
|
35
|
+
await runSingleAgentTurn(deps, preparedFollowUp.value, preparedFollowUp.displayValue, preparedFollowUp.options);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Explicitly resume a genuinely paused goal (automatic continuation already
|
|
40
|
+
* ran): an idle-stall resume continues the bounded retry pool; an
|
|
41
|
+
* incomplete-goal resume restarts the supervisor from the stored checkpoint
|
|
42
|
+
* (kind selection in chat/userInput.ts). Both ride the preserved
|
|
43
|
+
* conversation — no completed mutations are replayed.
|
|
44
|
+
*/
|
|
45
|
+
export async function resumePausedGoal(deps) {
|
|
46
|
+
const resume = deps.pausedResume;
|
|
47
|
+
if (!resume || deps.busy)
|
|
48
|
+
return;
|
|
49
|
+
deps.setPausedResume(undefined);
|
|
50
|
+
deps.setMessages(m => [...m, { role: 'system', text: 'Resuming the unfinished goal; completed work is preserved in the conversation.' }]);
|
|
51
|
+
await runSingleAgentTurn(deps, resume.request, undefined, {}, resumeKindFor(resume));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Run one physical agent turn under the logical-goal supervisor. Extracted
|
|
55
|
+
* from `chat.tsx` (CR-006 pattern): recoverable-incomplete turns continue
|
|
56
|
+
* automatically; an explicit `resumeExisting` restarts a genuinely paused
|
|
57
|
+
* goal from its checkpoint/retry pool. Behavior is unchanged — pure code
|
|
58
|
+
* motion over the explicit deps bundle.
|
|
59
|
+
*/
|
|
60
|
+
async function runSingleAgentTurn(deps, value, displayValue, turnOptions = {}, resumeExisting) {
|
|
61
|
+
const { stoppingRef, sealedRef, quarantineRef, activeGoalRef, conversationRef, settingsRef, sessionRecorderRef, contextFiles, settings, withDisplayOrder, addStreaming, patchLiveMessage, drainLiveMessages, finalizeMessage, setMessages, setBusy, setBusyLabel, debugLog, lastAssistantTextRef, abortControllerRef, workStateRef, setTokenUsage, setContextUsage, setFleet, setVisibleTasks, setTaskBarPadding, contextFileSignaturesRef, llmLogRef, showPersistenceWarning, setPausedResume, currentModelSelection, currentPromptSession, } = deps;
|
|
62
|
+
if (stoppingRef.current)
|
|
63
|
+
return;
|
|
64
|
+
const sessionRecorder = sessionRecorderRef.current;
|
|
65
|
+
const selection = currentModelSelection();
|
|
66
|
+
if (!selection) {
|
|
67
|
+
setMessages(m => [...m, { role: 'system', text: 'No model selected for this session. Run /model to choose one.' }]);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
sessionRecorder.recordModelSelection(selection);
|
|
71
|
+
// The logical-goal supervisor owns this submission: recoverable-incomplete
|
|
72
|
+
// physical turns (including step/tool budget boundaries) continue
|
|
73
|
+
// automatically; per-turn limits stay safety boundaries. An explicit
|
|
74
|
+
// resumeFrom restarts a genuinely paused goal from its checkpoint/pool.
|
|
75
|
+
const goalOptions = {
|
|
76
|
+
request: value,
|
|
77
|
+
displayValue,
|
|
78
|
+
contextFiles,
|
|
79
|
+
session: currentPromptSession(),
|
|
80
|
+
modelOverride: `${selection.provider}:${selection.model}`,
|
|
81
|
+
escalationModel: settings.escalationModel,
|
|
82
|
+
callbacks: {
|
|
83
|
+
addMessage: (msg) => {
|
|
84
|
+
const ordered = withDisplayOrder(msg);
|
|
85
|
+
if (ordered.streaming) {
|
|
86
|
+
addStreaming(ordered);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
finalizeMessage(ordered);
|
|
90
|
+
},
|
|
91
|
+
updateMessage: (id, update) => {
|
|
92
|
+
if (patchLiveMessage(id, update))
|
|
93
|
+
return;
|
|
94
|
+
setMessages(m => m.map(msg => msg.id === id ? { ...msg, ...update } : msg));
|
|
95
|
+
},
|
|
96
|
+
setConversation: (msgs) => {
|
|
97
|
+
conversationRef.current = msgs;
|
|
98
|
+
sessionRecorder.recordConversation(msgs);
|
|
99
|
+
},
|
|
100
|
+
onModelTransition: (selector, msgs) => {
|
|
101
|
+
const resolved = resolveModelSelector(settingsRef.current, selector);
|
|
102
|
+
if (resolved.status === 'found')
|
|
103
|
+
sessionRecorder.recordModelTransition(msgs, { provider: resolved.provider.name, model: resolved.model, endpointFingerprint: providerEndpointFingerprint(resolved.provider) });
|
|
104
|
+
},
|
|
105
|
+
setBusy,
|
|
106
|
+
setBusyLabel,
|
|
107
|
+
debugLog,
|
|
108
|
+
getConversation: () => conversationRef.current,
|
|
109
|
+
getLastAssistantText: () => lastAssistantTextRef.current,
|
|
110
|
+
setLastAssistantText: (text) => { lastAssistantTextRef.current = text; },
|
|
111
|
+
setAbortController: (controller) => {
|
|
112
|
+
abortControllerRef.current = controller;
|
|
113
|
+
if (stoppingRef.current)
|
|
114
|
+
controller?.abort('Chat is exiting.');
|
|
115
|
+
},
|
|
116
|
+
setWorkState: (state) => {
|
|
117
|
+
workStateRef.current = state;
|
|
118
|
+
sessionRecorder.recordWorkState(state);
|
|
119
|
+
},
|
|
120
|
+
compactConversation: deps.sessionLifecycle.compactConversation,
|
|
121
|
+
recordCompaction: (entry) => sessionRecorder.recordCompactEntry(entry),
|
|
122
|
+
recordTokenUsage: (usage) => {
|
|
123
|
+
setTokenUsage(current => accumulateTokenUsage(current, usage));
|
|
124
|
+
},
|
|
125
|
+
recordContextUsage: (tokens) => setContextUsage?.(current => ({ windowTokens: current.windowTokens, usedTokens: tokens, estimated: false })),
|
|
126
|
+
onEvent: (event) => {
|
|
127
|
+
sessionRecorder.recordEvent(event);
|
|
128
|
+
if (event.type === 'context_budget')
|
|
129
|
+
setContextUsage?.(current => ({ ...current, windowTokens: event.contextWindowTokens }));
|
|
130
|
+
else if (event.type === 'subagent_state')
|
|
131
|
+
setFleet(current => nextFleetStatus(current, event));
|
|
132
|
+
else if (event.type === 'goal_end')
|
|
133
|
+
setFleet(undefined);
|
|
134
|
+
},
|
|
135
|
+
onTasksChanged: () => {
|
|
136
|
+
loadTasksFromStore().then(t => {
|
|
137
|
+
if (stoppingRef.current)
|
|
138
|
+
return;
|
|
139
|
+
setVisibleTasks(t);
|
|
140
|
+
setTaskBarPadding(0);
|
|
141
|
+
}).catch(() => undefined);
|
|
142
|
+
},
|
|
143
|
+
contextFileSignatures: contextFileSignaturesRef.current,
|
|
144
|
+
log: llmLogRef.current,
|
|
145
|
+
},
|
|
146
|
+
...(resumeExisting ? { resumeFrom: resumeExisting } : {}),
|
|
147
|
+
// Durable goal ledger (P1): every supervisor boundary appends to the
|
|
148
|
+
// session JSONL so a crash or restart leaves a resumable frontier.
|
|
149
|
+
goalLedger: { append: (entry) => { if (!sealedRef.current)
|
|
150
|
+
sessionRecorder.recordGoalEntry(entry); } },
|
|
151
|
+
...(turnOptions.attachments || turnOptions.blessedPaths || turnOptions.ephemeralControl || turnOptions.subagentOverrides ? { turnOptions } : {})
|
|
152
|
+
};
|
|
153
|
+
const guarded = createQuarantinableCallbacks(goalOptions.callbacks);
|
|
154
|
+
quarantineRef.current = guarded.quarantine;
|
|
155
|
+
const goalPromise = runAgentGoal({ ...goalOptions, callbacks: guarded.callbacks });
|
|
156
|
+
activeGoalRef.current = goalPromise;
|
|
157
|
+
const goalResult = await goalPromise;
|
|
158
|
+
activeGoalRef.current = undefined;
|
|
159
|
+
if (stoppingRef.current)
|
|
160
|
+
return goalResult;
|
|
161
|
+
await sessionRecorder.flush().catch(showPersistenceWarning);
|
|
162
|
+
await llmLogRef.current?.writer?.flush().catch(showPersistenceWarning);
|
|
163
|
+
// Turn boundary: an aborted or forcibly-settled attempt is quarantined
|
|
164
|
+
// before it can emit the finalizing update, so settle anything still in
|
|
165
|
+
// the live tail now; the streamed text is preserved verbatim in <Static>.
|
|
166
|
+
drainLiveMessages();
|
|
167
|
+
// Only a genuinely paused goal (supervisor already attempted automatic
|
|
168
|
+
// continuation) exposes the one-key resume affordance; it stays until the
|
|
169
|
+
// user submits something else.
|
|
170
|
+
if (goalResult.resume?.kind === 'model-stream-idle')
|
|
171
|
+
setPausedResume({ kind: 'model-stream-idle', request: goalResult.resume.request, retryAttempt: goalResult.resume.retryAttempt });
|
|
172
|
+
else if (goalResult.resume?.kind === 'incomplete-goal')
|
|
173
|
+
setPausedResume({ kind: 'incomplete-goal', request: goalResult.resume.checkpoint.request, retryAttempt: 0, checkpoint: goalResult.resume.checkpoint, pauseReason: goalResult.stopReason === 'context-exhausted' || goalResult.stopReason === 'goal-deadline' || goalResult.stopReason === 'no-progress' ? goalResult.stopReason : undefined });
|
|
174
|
+
else
|
|
175
|
+
setPausedResume(undefined);
|
|
176
|
+
return goalResult;
|
|
177
|
+
}
|
|
@@ -26,11 +26,15 @@ export function useBusyIndicator() {
|
|
|
26
26
|
// re-renders this component, refreshing the elapsed label below.
|
|
27
27
|
useAnimation({ interval: 1000, isActive: busy && !screenReader });
|
|
28
28
|
function setBusy(nextBusy) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
// Functional update so two setBusy calls inside one React batch both see
|
|
30
|
+
// the current flag and the timer starts once (FE-10).
|
|
31
|
+
setBusyState(current => {
|
|
32
|
+
if (nextBusy && !current)
|
|
33
|
+
turnStartedAtRef.current = Date.now();
|
|
34
|
+
if (!nextBusy)
|
|
35
|
+
turnStartedAtRef.current = undefined;
|
|
36
|
+
return nextBusy;
|
|
37
|
+
});
|
|
34
38
|
}
|
|
35
39
|
return { busy, setBusy, elapsed: busyElapsedLabel(turnStartedAtRef.current) };
|
|
36
40
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ModelMessage } from 'ai';
|
|
2
2
|
import type { Message } from '../commands/streaming.js';
|
|
3
3
|
import type { TokenUsage } from '../commands/streaming/turnRuntime.js';
|
|
4
|
+
import type { ContextUsage } from './turnState.js';
|
|
4
5
|
export declare function toolCallCount(messages: Message[]): number;
|
|
5
6
|
export declare function compactHomePath(filePath: string, home?: string): string;
|
|
6
7
|
export declare function displayMessagesFromConversation(conversation: ModelMessage[]): Message[];
|
|
@@ -24,6 +25,12 @@ export declare function statusBarMetrics(input: {
|
|
|
24
25
|
statusDetailLabel: string;
|
|
25
26
|
hasTokenBreakdown: boolean;
|
|
26
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* `NN% context left` for the status bar. Uses the provider-measured request size
|
|
30
|
+
* once a step has reported; before that falls back to the transcript estimate
|
|
31
|
+
* (`fallbackUsedTokens`), marked `~` when it is a nonzero guess.
|
|
32
|
+
*/
|
|
33
|
+
export declare function contextLeftLabel(usage: ContextUsage, fallbackUsedTokens: number): string | undefined;
|
|
27
34
|
export interface FleetStatus {
|
|
28
35
|
running: number;
|
|
29
36
|
queued: number;
|
|
@@ -60,6 +60,20 @@ export function statusBarMetrics(input) {
|
|
|
60
60
|
const hasTokenBreakdown = tokenUsage.systemPrompt > 0 || tokenUsage.messages > 0 || tokenUsage.toolSchemas > 0 || effectiveInput > 0 || effectiveOutput > 0;
|
|
61
61
|
return { assistantMessages, toolsUsed, effectiveInput, effectiveOutput, inputEstimated, outputEstimated, statusDetailLabel, hasTokenBreakdown };
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* `NN% context left` for the status bar. Uses the provider-measured request size
|
|
65
|
+
* once a step has reported; before that falls back to the transcript estimate
|
|
66
|
+
* (`fallbackUsedTokens`), marked `~` when it is a nonzero guess.
|
|
67
|
+
*/
|
|
68
|
+
export function contextLeftLabel(usage, fallbackUsedTokens) {
|
|
69
|
+
const windowTokens = usage.windowTokens;
|
|
70
|
+
if (!windowTokens || windowTokens <= 0)
|
|
71
|
+
return undefined;
|
|
72
|
+
const measured = usage.usedTokens != null;
|
|
73
|
+
const usedTokens = Math.max(0, Math.min(windowTokens, usage.usedTokens ?? fallbackUsedTokens));
|
|
74
|
+
const left = Math.round((1 - usedTokens / windowTokens) * 100);
|
|
75
|
+
return `${!measured && usedTokens > 0 ? '~' : ''}${left}% context left`;
|
|
76
|
+
}
|
|
63
77
|
/**
|
|
64
78
|
* Rolling fleet depth for the busy row, folded from coordinator events.
|
|
65
79
|
* `queued` events report the queue length after enqueue; each later `started`
|
|
@@ -91,7 +105,7 @@ export function busyDetailLabel(input) {
|
|
|
91
105
|
}
|
|
92
106
|
const fleet = input.fleet;
|
|
93
107
|
if (fleet && (fleet.running > 0 || fleet.queued > 0)) {
|
|
94
|
-
parts.push(`
|
|
108
|
+
parts.push(`subagents ${fleet.running} running${fleet.queued > 0 ? `, ${fleet.queued} queued` : ''}`); // UX-21: one noun — "subagent" — for the fleet's parallel agents
|
|
95
109
|
}
|
|
96
110
|
return parts.length > 0 ? parts.join(' · ') : undefined;
|
|
97
111
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { HazeSettings } from '../../config/settings.js';
|
|
2
|
+
import type { SessionSummary } from '../../core/session/sessionStore.js';
|
|
3
|
+
import type { LoadedSkill } from '../../skills/types.js';
|
|
4
|
+
import type { PromptSession } from '../../llm/systemPrompt.js';
|
|
5
|
+
import type { Message } from '../commands/streaming.js';
|
|
6
|
+
import type { TokenUsage } from '../commands/streaming/turnRuntime.js';
|
|
7
|
+
import { type Mode } from '../commands/chatModes.js';
|
|
8
|
+
import { type FleetStatus } from './chatMetrics.js';
|
|
9
|
+
import type { WizardUiState } from './wizard/uiState.js';
|
|
10
|
+
/** The session's pinned `provider:model` selection, when one is recorded. */
|
|
11
|
+
export type ModelSelection = {
|
|
12
|
+
provider: string;
|
|
13
|
+
model: string;
|
|
14
|
+
endpointFingerprint?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Status-bar model name and reasoning suffix for the current screen state.
|
|
18
|
+
* Pure: the name marks a selection that no longer resolves, and the suffix
|
|
19
|
+
* shows the level that will actually be requested (`(no reasoning parameter)`
|
|
20
|
+
* for `unset`, `(provider default)` when the protocol cannot carry a level).
|
|
21
|
+
*/
|
|
22
|
+
export declare function modelStatusFor(input: {
|
|
23
|
+
settings: HazeSettings;
|
|
24
|
+
selectedModel: ModelSelection | undefined;
|
|
25
|
+
sessionReasoning: PromptSession['reasoningByModel'];
|
|
26
|
+
}): {
|
|
27
|
+
activeModelName: string;
|
|
28
|
+
reasoningSuffix: string;
|
|
29
|
+
};
|
|
30
|
+
/** Horizontal chrome for the live frame (`width`) and the settled Static replay (`replayWidth`). */
|
|
31
|
+
export declare function chatLayoutFor(width: number, replayWidth: number): {
|
|
32
|
+
horizontalPadding: number;
|
|
33
|
+
contentWidth: number;
|
|
34
|
+
replayContentWidth: number;
|
|
35
|
+
};
|
|
36
|
+
export interface ChatViewModelInput {
|
|
37
|
+
messages: Message[];
|
|
38
|
+
liveMessages: Message[];
|
|
39
|
+
busy: boolean;
|
|
40
|
+
fleet: FleetStatus | undefined;
|
|
41
|
+
settings: HazeSettings;
|
|
42
|
+
mode: Mode;
|
|
43
|
+
tokenUsage: TokenUsage;
|
|
44
|
+
backgroundCount: number;
|
|
45
|
+
skills: LoadedSkill[];
|
|
46
|
+
branchName: string | undefined;
|
|
47
|
+
sessions: SessionSummary[];
|
|
48
|
+
wizard: WizardUiState;
|
|
49
|
+
selectedModel: ModelSelection | undefined;
|
|
50
|
+
/** `reasoningByModel` of the current session; a new object identity re-derives the suffix and the picker suggestions. */
|
|
51
|
+
sessionReasoning: PromptSession['reasoningByModel'];
|
|
52
|
+
/** Bumped by `/reasoning`; it only forces the re-render that re-reads `sessionReasoning`. */
|
|
53
|
+
reasoningOverrideCounter: number;
|
|
54
|
+
width: number;
|
|
55
|
+
replayWidth: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Everything `ChatScreen` derives for one render. The heavy work is memoised on
|
|
59
|
+
* the identity of its inputs (FE-03): the 1 Hz busy heartbeat and every stream
|
|
60
|
+
* delta re-render the screen, but only changed messages may re-run Markdown
|
|
61
|
+
* root chunking.
|
|
62
|
+
*/
|
|
63
|
+
export declare function useChatViewModel(input: ChatViewModelInput): {
|
|
64
|
+
horizontalPadding: number;
|
|
65
|
+
contentWidth: number;
|
|
66
|
+
replayContentWidth: number;
|
|
67
|
+
busyDetail: string | undefined;
|
|
68
|
+
staticTranscriptItems: import("./transcriptPartition.js").TranscriptStaticItem[];
|
|
69
|
+
streamingItems: import("./transcriptPartition.js").TranscriptStreamingItem[];
|
|
70
|
+
placeholder: string;
|
|
71
|
+
activeModelName: string;
|
|
72
|
+
reasoningSuffix: string;
|
|
73
|
+
workspaceLabel: string;
|
|
74
|
+
metrics: {
|
|
75
|
+
assistantMessages: number;
|
|
76
|
+
toolsUsed: number;
|
|
77
|
+
effectiveInput: number;
|
|
78
|
+
effectiveOutput: number;
|
|
79
|
+
inputEstimated: boolean;
|
|
80
|
+
outputEstimated: boolean;
|
|
81
|
+
statusDetailLabel: string;
|
|
82
|
+
hasTokenBreakdown: boolean;
|
|
83
|
+
};
|
|
84
|
+
inputSuggestions: import("../../ui/components/TextInput.js").TextInputSuggestion[];
|
|
85
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { activeModel } from '../../config/providers.js';
|
|
3
|
+
import { resolveProviderReasoning } from '../../config/providerReasoning.js';
|
|
4
|
+
import { isSkillEnabled } from '../../config/skillSettings.js';
|
|
5
|
+
import { isStoredReasoning, resolveReasoningChoice } from '../../core/agent/reasoningPolicy.js';
|
|
6
|
+
import { placeholderForMode } from '../commands/chatModes.js';
|
|
7
|
+
import { busyDetailLabel, compactHomePath, statusBarMetrics } from './chatMetrics.js';
|
|
8
|
+
import { inputSuggestionsForState } from './inputSuggestions.js';
|
|
9
|
+
import { partitionDisplayMessages } from './transcriptPartition.js';
|
|
10
|
+
/**
|
|
11
|
+
* Status-bar model name and reasoning suffix for the current screen state.
|
|
12
|
+
* Pure: the name marks a selection that no longer resolves, and the suffix
|
|
13
|
+
* shows the level that will actually be requested (`(no reasoning parameter)`
|
|
14
|
+
* for `unset`, `(provider default)` when the protocol cannot carry a level).
|
|
15
|
+
*/
|
|
16
|
+
export function modelStatusFor(input) {
|
|
17
|
+
const { settings, selectedModel } = input;
|
|
18
|
+
const activeSelection = activeModel(settings);
|
|
19
|
+
const activeModelName = selectedModel ? `${selectedModel.provider}:${selectedModel.model}${activeSelection ? '' : ' (unavailable)'}` : 'unconfigured';
|
|
20
|
+
const activeSelector = activeSelection ? `${activeSelection.provider.name}:${activeSelection.model}` : undefined;
|
|
21
|
+
const effectiveReasoning = activeSelector
|
|
22
|
+
? resolveReasoningChoice(input.sessionReasoning?.[activeSelector], isStoredReasoning(settings.reasoning) ? settings.reasoning : undefined)
|
|
23
|
+
: undefined;
|
|
24
|
+
const reasoningSuffix = effectiveReasoning
|
|
25
|
+
? effectiveReasoning.level === undefined
|
|
26
|
+
? ' (no reasoning parameter)'
|
|
27
|
+
: activeSelection && resolveProviderReasoning(activeSelection.provider, activeSelection.model, effectiveReasoning.level).effective === 'disabled'
|
|
28
|
+
? ' (provider default)'
|
|
29
|
+
: ` (${effectiveReasoning.level})`
|
|
30
|
+
: '';
|
|
31
|
+
return { activeModelName, reasoningSuffix };
|
|
32
|
+
}
|
|
33
|
+
/** Horizontal chrome for the live frame (`width`) and the settled Static replay (`replayWidth`). */
|
|
34
|
+
export function chatLayoutFor(width, replayWidth) {
|
|
35
|
+
const horizontalPadding = width >= 12 ? 1 : 0;
|
|
36
|
+
return {
|
|
37
|
+
horizontalPadding,
|
|
38
|
+
contentWidth: Math.max(1, width - horizontalPadding * 2),
|
|
39
|
+
replayContentWidth: Math.max(1, replayWidth - (replayWidth >= 12 ? 1 : 0) * 2),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Everything `ChatScreen` derives for one render. The heavy work is memoised on
|
|
44
|
+
* the identity of its inputs (FE-03): the 1 Hz busy heartbeat and every stream
|
|
45
|
+
* delta re-render the screen, but only changed messages may re-run Markdown
|
|
46
|
+
* root chunking.
|
|
47
|
+
*/
|
|
48
|
+
export function useChatViewModel(input) {
|
|
49
|
+
const { messages, liveMessages, busy, fleet, settings, mode, tokenUsage, backgroundCount, skills, branchName, sessions, wizard, selectedModel, sessionReasoning, reasoningOverrideCounter, width, replayWidth } = input;
|
|
50
|
+
void reasoningOverrideCounter;
|
|
51
|
+
const activeLiveMessages = useMemo(() => liveMessages.filter(message => !message.hidden), [liveMessages]);
|
|
52
|
+
// Recomputed each busy heartbeat (1 Hz) alongside the elapsed label; the
|
|
53
|
+
// streaming-rate estimate rides the already-live message text, so no extra
|
|
54
|
+
// timer or token bookkeeping is introduced.
|
|
55
|
+
const busyDetail = busy ? busyDetailLabel({ messages: activeLiveMessages, fleet }) : undefined;
|
|
56
|
+
const { staticItems: staticTranscriptItems, streamingItems } = useMemo(() => partitionDisplayMessages([...messages, ...liveMessages].filter(message => !message.hidden)), [messages, liveMessages]);
|
|
57
|
+
const placeholder = placeholderForMode(mode, busy);
|
|
58
|
+
const { activeModelName, reasoningSuffix } = modelStatusFor({ settings, selectedModel, sessionReasoning });
|
|
59
|
+
const workspaceLabel = `${compactHomePath(process.cwd())}${branchName ? ` (${branchName})` : ''}`;
|
|
60
|
+
const enabledSkillCount = useMemo(() => new Set(skills.filter(skill => isSkillEnabled(settings, skill.name, skill.source)).map(skill => skill.name)).size, [skills, settings]);
|
|
61
|
+
const metrics = useMemo(() => statusBarMetrics({ messages: [...messages, ...liveMessages], tokenUsage, enabledSkillCount, backgroundProcessCount: backgroundCount }), [messages, liveMessages, tokenUsage, enabledSkillCount, backgroundCount]);
|
|
62
|
+
const { modelProviderFilter, discoveredModels, suggestedModels, selectedProviderName, providerDraft, selectedSkillName, selectedLspName, selectedMcpName, plugins, selectedPluginName, pluginCollectionEntries } = wizard;
|
|
63
|
+
const inputSuggestions = useMemo(() => inputSuggestionsForState({ mode, settings, skills, sessions, selectedProviderName, modelProviderFilter, providerDraftName: providerDraft.name, discoveredModels, suggestedModels, selectedSkillName, selectedLspName, selectedMcpName, plugins, selectedPluginName, pluginCollectionEntries, sessionReasoning }), [mode, settings, skills, sessions, selectedProviderName, modelProviderFilter, providerDraft.name, discoveredModels, suggestedModels, selectedSkillName, selectedLspName, selectedMcpName, plugins, selectedPluginName, pluginCollectionEntries, sessionReasoning]);
|
|
64
|
+
const layout = chatLayoutFor(width, replayWidth);
|
|
65
|
+
return { busyDetail, staticTranscriptItems, streamingItems, placeholder, activeModelName, reasoningSuffix, workspaceLabel, metrics, inputSuggestions, ...layout };
|
|
66
|
+
}
|
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
import type { TextInputSuggestion } from '../../ui/components/TextInput.js';
|
|
2
|
-
export interface MentionContext {
|
|
3
|
-
/** Full token including the leading `@`. */
|
|
4
|
-
token: string;
|
|
5
|
-
/** Index in the source string where the `@` sits. */
|
|
6
|
-
start: number;
|
|
7
|
-
/** Index one past the last char of the token. */
|
|
8
|
-
end: number;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Find the `@token` (if any) at the given cursor position. The cursor may
|
|
12
|
-
* sit anywhere inside the token or directly after its last char — both
|
|
13
|
-
* count as "inside" so the user can keep typing or completing.
|
|
14
|
-
*/
|
|
15
|
-
export declare function detectMentionAtCursor(value: string, cursor: number): MentionContext | undefined;
|
|
16
2
|
export interface FileMentionSuggestionsOptions {
|
|
17
3
|
/** Override the workspace root for tests. Defaults to `process.cwd()`. */
|
|
18
4
|
workspaceRoot?: string;
|
|
@@ -1,36 +1,19 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { walkDir } from '../../utils/fs.js';
|
|
4
|
-
import { createIgnoreClassifier } from '../../
|
|
4
|
+
import { createIgnoreClassifier } from '../../core/ignore/gitIgnore.js';
|
|
5
5
|
import { workspaceRoot } from '../../utils/path.js';
|
|
6
6
|
/**
|
|
7
7
|
* Tab-completion support for `@`-mention paths (F04 AC1).
|
|
8
8
|
*
|
|
9
9
|
* Mention completion is cursor-aware partial replacement — unlike slash
|
|
10
10
|
* commands, the suggestion replaces only the `@token` at the cursor, not the
|
|
11
|
-
* whole input. Detection runs in the TextInput layer;
|
|
12
|
-
* filesystem listing (bounded, `.gitignore`-aware) and
|
|
11
|
+
* whole input. Detection runs in the TextInput layer (`ui/mentionDetection.ts`);
|
|
12
|
+
* this module owns the filesystem listing (bounded, `.gitignore`-aware) and
|
|
13
|
+
* stays UI-agnostic.
|
|
13
14
|
*/
|
|
14
15
|
/** Cap so completion stays responsive in large repos (F04 AC5). */
|
|
15
16
|
const MAX_MENTION_SUGGESTIONS = 20;
|
|
16
|
-
/** Characters allowed inside a `@token` while it is being typed. */
|
|
17
|
-
const MENTION_TOKEN_PATTERN = /@[\w./~-]*/g;
|
|
18
|
-
/**
|
|
19
|
-
* Find the `@token` (if any) at the given cursor position. The cursor may
|
|
20
|
-
* sit anywhere inside the token or directly after its last char — both
|
|
21
|
-
* count as "inside" so the user can keep typing or completing.
|
|
22
|
-
*/
|
|
23
|
-
export function detectMentionAtCursor(value, cursor) {
|
|
24
|
-
for (const match of value.matchAll(MENTION_TOKEN_PATTERN)) {
|
|
25
|
-
if (match.index === undefined)
|
|
26
|
-
continue;
|
|
27
|
-
const start = match.index;
|
|
28
|
-
const end = start + match[0].length;
|
|
29
|
-
if (cursor >= start && cursor <= end)
|
|
30
|
-
return { token: match[0], start, end };
|
|
31
|
-
}
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
17
|
/**
|
|
35
18
|
* Strip the leading `@` and split the query into parent directory + prefix.
|
|
36
19
|
* `@src/f` → `{parentDir: 'src', prefix: 'f'}`; `@` → `{parentDir: '.', prefix: ''}`.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HazeSettings } from '../../config/settings.js';
|
|
2
|
+
/**
|
|
3
|
+
* Live theme switching, extracted from `ChatScreen` (ARCH-05): whenever the
|
|
4
|
+
* settings' theme name changes (/themes), re-resolve and adopt it so the whole
|
|
5
|
+
* UI repaints without a restart. Ink <Static> history stays as-rendered, so
|
|
6
|
+
* already-printed text keeps its old colors; the terminal defaults (OSC 10/11)
|
|
7
|
+
* follow the new theme. Skipped until `settingsThemeLoadedRef` is set —
|
|
8
|
+
* `chatCommand()` already resolved the theme before the first render, and the
|
|
9
|
+
* pre-load {} state would briefly flash the default theme.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useLiveTheme(settings: HazeSettings, stoppingRef: React.MutableRefObject<boolean>, settingsThemeLoadedRef: React.MutableRefObject<boolean>): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { setActiveTheme, resolveTheme, theme, DEFAULT_THEME_NAME } from '../../ui/theme.js';
|
|
3
|
+
import { applyTerminalColors } from '../../ui/terminalColors.js';
|
|
4
|
+
/**
|
|
5
|
+
* Live theme switching, extracted from `ChatScreen` (ARCH-05): whenever the
|
|
6
|
+
* settings' theme name changes (/themes), re-resolve and adopt it so the whole
|
|
7
|
+
* UI repaints without a restart. Ink <Static> history stays as-rendered, so
|
|
8
|
+
* already-printed text keeps its old colors; the terminal defaults (OSC 10/11)
|
|
9
|
+
* follow the new theme. Skipped until `settingsThemeLoadedRef` is set —
|
|
10
|
+
* `chatCommand()` already resolved the theme before the first render, and the
|
|
11
|
+
* pre-load {} state would briefly flash the default theme.
|
|
12
|
+
*/
|
|
13
|
+
export function useLiveTheme(settings, stoppingRef, settingsThemeLoadedRef) {
|
|
14
|
+
const activeThemeName = settings.theme ?? DEFAULT_THEME_NAME;
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!settingsThemeLoadedRef.current || stoppingRef.current)
|
|
17
|
+
return;
|
|
18
|
+
try {
|
|
19
|
+
setActiveTheme(resolveTheme(activeThemeName));
|
|
20
|
+
applyTerminalColors(theme.foreground, theme.background);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// Malformed theme names were reported at startup; keep the resolved default.
|
|
24
|
+
}
|
|
25
|
+
}, [activeThemeName, stoppingRef, settingsThemeLoadedRef]);
|
|
26
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Message } from '../commands/streaming.js';
|
|
2
|
+
import type { ChatScreenDeps } from './screenDeps.js';
|
|
3
|
+
/** Finalize a formerly-live message into the append-only transcript and session record. */
|
|
4
|
+
export declare function finalizeMessage(deps: ChatScreenDeps, message: Message): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Finalize a formerly-live message into the append-only transcript and session record. */
|
|
2
|
+
export function finalizeMessage(deps, message) {
|
|
3
|
+
if (message.hidden || deps.sealedRef.current)
|
|
4
|
+
return;
|
|
5
|
+
const ordered = deps.withDisplayOrder(message);
|
|
6
|
+
deps.setMessages(m => [...m, ordered]);
|
|
7
|
+
deps.sessionRecorderRef.current?.recordUiMessage(ordered);
|
|
8
|
+
}
|
|
@@ -205,7 +205,7 @@ function StreamingClampedText({ text, width, maxVisibleLines }) {
|
|
|
205
205
|
export const MessageView = React.memo(function MessageView({ message, width, showHeader = true, maxVisibleLines }) {
|
|
206
206
|
if (maxVisibleLines != null && message.role !== 'tool') {
|
|
207
207
|
return _jsxs(Box, { flexDirection: "column", flexShrink: 0, maxHeight: maxVisibleLines + (showHeader ? 1 : 0), overflow: "hidden", children: [showHeader && _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: message.role === 'assistant' ? 'haze' : message.role === 'user' ? 'You asked' : 'Info' }), message.role === 'assistant'
|
|
208
|
-
? _jsx(StreamingMarkdownText, { content: message.text, width: width, maxVisibleLines: maxVisibleLines })
|
|
208
|
+
? _jsx(StreamingMarkdownText, { content: message.text, width: width, maxVisibleLines: maxVisibleLines, streaming: message.streaming })
|
|
209
209
|
: _jsx(StreamingClampedText, { text: message.text, width: width, maxVisibleLines: maxVisibleLines })] });
|
|
210
210
|
}
|
|
211
211
|
if (message.role === 'user') {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { type SessionSummary } from '../../core/session/sessionStore.js';
|
|
3
|
+
import type { Mode } from '../commands/chatModes.js';
|
|
4
|
+
import type { Message } from '../commands/streaming.js';
|
|
5
|
+
import type { WizardUiAction } from './wizardDispatch.js';
|
|
6
|
+
export type PickerOpenerDeps = {
|
|
7
|
+
/** Flushes the active session before listing so it is visible to the picker. */
|
|
8
|
+
flush: () => Promise<unknown>;
|
|
9
|
+
onFlushError: (error: unknown) => void;
|
|
10
|
+
setSessions: (sessions: SessionSummary[]) => void;
|
|
11
|
+
updateWizard: (action: WizardUiAction) => void;
|
|
12
|
+
setMode: (mode: Mode) => void;
|
|
13
|
+
setMessages: (updater: React.SetStateAction<Message[]>) => void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Openers for the session and plugin pickers, extracted from `ChatScreen`
|
|
17
|
+
* (ARCH-05). They only load data and route to the matching mode; the picker
|
|
18
|
+
* submit handling stays in `wizardDispatch.ts`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createPickerOpeners(deps: PickerOpenerDeps): {
|
|
21
|
+
openSessionPicker: () => Promise<void>;
|
|
22
|
+
openPluginPicker: () => Promise<void>;
|
|
23
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { listSessions } from '../../core/session/sessionStore.js';
|
|
2
|
+
import { MAX_SESSION_PICKER_RESULTS } from '../commands/sessionPicker.js';
|
|
3
|
+
import { listInstalledPlugins } from '../commands/pluginCommand.js';
|
|
4
|
+
/**
|
|
5
|
+
* Openers for the session and plugin pickers, extracted from `ChatScreen`
|
|
6
|
+
* (ARCH-05). They only load data and route to the matching mode; the picker
|
|
7
|
+
* submit handling stays in `wizardDispatch.ts`.
|
|
8
|
+
*/
|
|
9
|
+
export function createPickerOpeners(deps) {
|
|
10
|
+
async function openSessionPicker() {
|
|
11
|
+
await deps.flush().catch(deps.onFlushError);
|
|
12
|
+
const next = await listSessions();
|
|
13
|
+
deps.setSessions(next);
|
|
14
|
+
deps.updateWizard({ type: 'set', key: 'selectedSessionId', value: undefined });
|
|
15
|
+
if (next.length === 0) {
|
|
16
|
+
deps.setMessages(m => [...m, { role: 'system', text: 'No saved sessions found for this workspace.' }]);
|
|
17
|
+
deps.setMode('chat');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
deps.setMode('sessions');
|
|
21
|
+
const hidden = Math.max(0, next.length - MAX_SESSION_PICKER_RESULTS);
|
|
22
|
+
deps.setMessages(m => [...m, { role: 'system', text: `Choose a saved session (newest first)${hidden ? `. Showing ${MAX_SESSION_PICKER_RESULTS} of ${next.length}; ${hidden} older sessions are hidden.` : '.'}` }]);
|
|
23
|
+
}
|
|
24
|
+
async function openPluginPicker() {
|
|
25
|
+
try {
|
|
26
|
+
deps.updateWizard({ type: 'plugins', value: await listInstalledPlugins() });
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
deps.setMessages(m => [...m, { role: 'system', text: `Could not list installed plugins: ${error instanceof Error ? error.message : String(error)}` }]);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
deps.setMode('plugins');
|
|
33
|
+
deps.setMessages(m => [...m, { role: 'system', text: 'Choose install plugin, inspect plugin, or an installed plugin to manage. Only skills activate; no scripts, hooks, or MCP servers run.' }]);
|
|
34
|
+
}
|
|
35
|
+
return { openSessionPicker, openPluginPicker };
|
|
36
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PromptSession } from '../../llm/systemPrompt.js';
|
|
2
|
+
import type { StoredReasoningSetting } from '../../core/agent/reasoningPolicy.js';
|
|
3
|
+
/**
|
|
4
|
+
* The stable per-session PromptSession plus the per-model reasoning overrides
|
|
5
|
+
* stored on it, extracted from `ChatScreen` (ARCH-05).
|
|
6
|
+
*/
|
|
7
|
+
export declare function usePromptSession(sessionStartRef: React.MutableRefObject<Date>): {
|
|
8
|
+
currentPromptSession: () => PromptSession;
|
|
9
|
+
setSessionReasoningOverride: (modelSelector: string, setting: StoredReasoningSetting | undefined) => void;
|
|
10
|
+
reasoningOverrideCounter: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useRef, useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The stable per-session PromptSession plus the per-model reasoning overrides
|
|
4
|
+
* stored on it, extracted from `ChatScreen` (ARCH-05).
|
|
5
|
+
*/
|
|
6
|
+
export function usePromptSession(sessionStartRef) {
|
|
7
|
+
// Stable PromptSession object across turns so per-session flags (the
|
|
8
|
+
// context-fallback warning key) persist; rebuilt when a new session starts,
|
|
9
|
+
// detected by sessionStartRef identity (the lifecycle controller replaces
|
|
10
|
+
// the Date on new/resume/continue).
|
|
11
|
+
const promptSessionRef = useRef({ identity: undefined, value: { cwd: process.cwd() } });
|
|
12
|
+
// Session per-model reasoning overrides live on the stable PromptSession
|
|
13
|
+
// object; this counter only forces a re-render so the status bar updates.
|
|
14
|
+
const [reasoningOverrideCounter, setReasoningOverrideCounter] = useState(0);
|
|
15
|
+
/**
|
|
16
|
+
* The PromptSession shared by every turn of the active session. Returning a
|
|
17
|
+
* stable object (not a fresh literal per turn) is what makes once-per-session
|
|
18
|
+
* affordances actually once-per-session; a new session identity yields a
|
|
19
|
+
* fresh object so they fire again at its start.
|
|
20
|
+
*/
|
|
21
|
+
function currentPromptSession() {
|
|
22
|
+
if (promptSessionRef.current.identity !== sessionStartRef.current) {
|
|
23
|
+
promptSessionRef.current = { identity: sessionStartRef.current, value: { start: sessionStartRef.current, cwd: process.cwd() } };
|
|
24
|
+
}
|
|
25
|
+
return promptSessionRef.current.value;
|
|
26
|
+
}
|
|
27
|
+
function setSessionReasoningOverride(modelSelector, setting) {
|
|
28
|
+
const session = currentPromptSession();
|
|
29
|
+
if (setting === undefined) {
|
|
30
|
+
if (session.reasoningByModel)
|
|
31
|
+
delete session.reasoningByModel[modelSelector];
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
session.reasoningByModel = { ...session.reasoningByModel, [modelSelector]: setting };
|
|
35
|
+
}
|
|
36
|
+
setReasoningOverrideCounter(count => count + 1);
|
|
37
|
+
}
|
|
38
|
+
return { currentPromptSession, setSessionReasoningOverride, reasoningOverrideCounter };
|
|
39
|
+
}
|