@denizokcu/haze 1.7.11 → 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 +56 -0
- package/README.md +142 -102
- package/SECURITY.md +1 -1
- package/assets/graph-grammars/NOTICE.md +21 -0
- package/assets/graph-grammars/tree-sitter-javascript.wasm +0 -0
- package/assets/graph-grammars/tree-sitter-tsx.wasm +0 -0
- package/assets/graph-grammars/tree-sitter-typescript.wasm +0 -0
- package/assets/graph-grammars/web-tree-sitter.cjs +4116 -0
- package/assets/graph-grammars/web-tree-sitter.cjs.map +7 -0
- package/assets/graph-grammars/web-tree-sitter.js +4056 -0
- package/assets/graph-grammars/web-tree-sitter.js.map +7 -0
- package/assets/graph-grammars/web-tree-sitter.wasm +0 -0
- package/assets/graph-grammars/web-tree-sitter.wasm.map +55 -0
- 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/inputSuggestions.js +1 -0
- 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 +6 -2
- package/dist/cli/chat/sessionRecorder.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/startupSequence.d.ts +2 -0
- package/dist/cli/chat/startupSequence.js +6 -0
- 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 -795
- package/dist/cli/commands/commandHelp.js +11 -6
- package/dist/cli/commands/commandSuggest.d.ts +2 -0
- package/dist/cli/commands/commandSuggest.js +35 -0
- package/dist/cli/commands/commands.js +12 -3
- package/dist/cli/commands/formatters.d.ts +1 -23
- package/dist/cli/commands/formatters.js +3 -224
- package/dist/cli/commands/graphCommand.d.ts +2 -0
- package/dist/cli/commands/graphCommand.js +60 -0
- package/dist/cli/commands/initCommand.js +14 -0
- 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/agentAttempt.js +11 -1
- package/dist/cli/commands/streaming/attemptLifecycle.js +1 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +8 -3
- package/dist/cli/commands/streaming/attemptSetup.d.ts +4 -0
- package/dist/cli/commands/streaming/attemptSetup.js +34 -5
- package/dist/cli/commands/streaming/goalCheckpoint.d.ts +1 -1
- package/dist/cli/commands/streaming/goalSupervisor.js +5 -3
- package/dist/cli/commands/streaming/prepareStep.js +1 -0
- 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.d.ts +2 -0
- package/dist/cli/commands/streaming/streamLoop.js +34 -23
- package/dist/cli/commands/streaming/toolGroupRenderer.js +1 -1
- package/dist/cli/commands/streaming/toolPartHandlers.js +8 -2
- package/dist/cli/commands/streaming.d.ts +3 -1
- package/dist/cli/commands/streaming.js +5 -0
- 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/compaction.d.ts +1 -0
- package/dist/core/agent/compaction.js +3 -0
- 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/analyze.d.ts +61 -0
- package/dist/core/graph/analyze.js +274 -0
- package/dist/core/graph/buildGraph.d.ts +44 -0
- package/dist/core/graph/buildGraph.js +290 -0
- package/dist/core/graph/digest.d.ts +2 -0
- package/dist/core/graph/digest.js +40 -0
- package/dist/core/graph/extract.d.ts +58 -0
- package/dist/core/graph/extract.js +394 -0
- package/dist/core/graph/model.d.ts +63 -0
- package/dist/core/graph/model.js +96 -0
- package/dist/core/graph/query.d.ts +69 -0
- package/dist/core/graph/query.js +391 -0
- package/dist/core/graph/store.d.ts +64 -0
- package/dist/core/graph/store.js +171 -0
- 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 +22 -11
- 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/untrustedEnvelopes.d.ts +6 -0
- package/dist/core/safety/untrustedEnvelopes.js +17 -2
- 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/core/subagent/executionProfiles.js +4 -4
- package/dist/core/tasks/taskStorage.js +11 -1
- package/dist/{llm → core}/toolResultTypes.d.ts +1 -1
- package/dist/core/validation/outputParser.d.ts +1 -1
- package/dist/core/validation/outputParser.js +16 -8
- package/dist/llm/hazeTools.d.ts +2 -12426
- package/dist/llm/hazeTools.js +4 -0
- package/dist/llm/lsp/pool.js +1 -1
- package/dist/llm/lsp/workspaceEdit.d.ts +1 -1
- package/dist/llm/lspTools.d.ts +3 -12622
- package/dist/llm/requestContext.d.ts +6 -0
- package/dist/llm/requestContext.js +28 -7
- package/dist/llm/subagentRunner.d.ts +2 -308
- package/dist/llm/systemPrompt.js +17 -7
- 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/fetchTool.d.ts +2 -1221
- package/dist/llm/tools/fileToolShared.d.ts +1 -1
- package/dist/llm/tools/fileToolShared.js +1 -1
- package/dist/llm/tools/fileTools.d.ts +2 -7768
- 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/graphAdvisory.d.ts +22 -0
- package/dist/llm/tools/graphAdvisory.js +68 -0
- package/dist/llm/tools/graphTools.d.ts +13 -0
- package/dist/llm/tools/graphTools.js +195 -0
- package/dist/llm/tools/processTool.d.ts +2 -1081
- 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/shellTool.d.ts +2 -1513
- package/dist/llm/tools/storedOutputTool.d.ts +2 -355
- package/dist/llm/tools/taskTool.d.ts +2 -489
- package/dist/llm/tools/taskTool.js +4 -1
- package/dist/llm/tools/toolContext.js +29 -11
- package/dist/llm/tools/toolContextState.d.ts +4 -1
- package/dist/llm/tools/toolContextState.js +2 -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/skills/skillTools.js +4 -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 +22 -19
- /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
package/bin/haze.js
CHANGED
|
@@ -27,6 +27,24 @@ function readJson(file) {
|
|
|
27
27
|
return JSON.parse(readFileSync(path.join(root, file), 'utf8'));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/** readJson that returns undefined instead of throwing (for the --version path). */
|
|
31
|
+
function readJsonSafe(file) {
|
|
32
|
+
try {
|
|
33
|
+
return readJson(file);
|
|
34
|
+
} catch {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** realpathSync that falls back to the given path, so --verbose never throws (OPS-06). */
|
|
40
|
+
function safeRealpath(file) {
|
|
41
|
+
try {
|
|
42
|
+
return realpathSync(file);
|
|
43
|
+
} catch {
|
|
44
|
+
return file ?? 'unknown';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
30
48
|
function readGitHead() {
|
|
31
49
|
const sha = (value) => (/^[0-9a-f]{7,40}$/i.test((value ?? '').trim()) ? value.trim() : undefined);
|
|
32
50
|
const readOptional = (file) => {
|
|
@@ -70,6 +88,35 @@ function readGitHead() {
|
|
|
70
88
|
const problems = [];
|
|
71
89
|
let pkg;
|
|
72
90
|
let build;
|
|
91
|
+
|
|
92
|
+
// Node floor (OPS-06): fail with a clear message instead of a syntax error
|
|
93
|
+
// from dist on old runtimes. Checked before anything that could throw.
|
|
94
|
+
const [nodeMajor, nodeMinor] = process.versions.node.split('.').map(Number);
|
|
95
|
+
if (nodeMajor < 22 || (nodeMajor === 22 && nodeMinor < 13)) {
|
|
96
|
+
process.stderr.write(`haze requires Node >= 22.13 (found ${process.versions.node}).\n`);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// `--version` (optionally `--verbose`) is answered before the staleness gate
|
|
101
|
+
// (OPS-06): provenance must work even while dist is being repaired.
|
|
102
|
+
const argv = process.argv.slice(2);
|
|
103
|
+
if (argv.includes('--version') || argv.includes('-V')) {
|
|
104
|
+
const version = readJsonSafe('package.json')?.version ?? readJsonSafe('dist/buildInfo.json')?.version ?? '0.0.0';
|
|
105
|
+
if (argv.includes('--verbose')) {
|
|
106
|
+
const lines = [
|
|
107
|
+
`Haze ${version}`,
|
|
108
|
+
`commit: ${readJsonSafe('dist/buildInfo.json')?.commit ?? 'unknown'}`,
|
|
109
|
+
...(readJsonSafe('dist/buildInfo.json')?.builtAt ? [`builtAt: ${readJsonSafe('dist/buildInfo.json').builtAt}`] : []),
|
|
110
|
+
`runtime: ${path.join(root, 'dist')}`,
|
|
111
|
+
`executable: ${safeRealpath(process.argv[1])}`,
|
|
112
|
+
`goal supervisor: ${existsSync(path.join(root, 'dist/cli/commands/streaming/goalSupervisor.js')) ? 'enabled' : 'disabled'}`,
|
|
113
|
+
];
|
|
114
|
+
process.stdout.write(`${lines.join('\n')}\n`);
|
|
115
|
+
} else {
|
|
116
|
+
process.stdout.write(`${version}\n`);
|
|
117
|
+
}
|
|
118
|
+
process.exit(0);
|
|
119
|
+
}
|
|
73
120
|
try {
|
|
74
121
|
pkg = readJson('package.json');
|
|
75
122
|
} catch {
|
|
@@ -101,23 +148,4 @@ if (problems.length > 0) {
|
|
|
101
148
|
process.exit(1);
|
|
102
149
|
}
|
|
103
150
|
|
|
104
|
-
const argv = process.argv.slice(2);
|
|
105
|
-
if (argv.includes('--version') || argv.includes('-V')) {
|
|
106
|
-
const version = pkg?.version ?? build?.version ?? '0.0.0';
|
|
107
|
-
if (argv.includes('--verbose')) {
|
|
108
|
-
const lines = [
|
|
109
|
-
`Haze ${version}`,
|
|
110
|
-
`commit: ${build?.commit ?? 'unknown'}`,
|
|
111
|
-
...(build?.builtAt ? [`builtAt: ${build.builtAt}`] : []),
|
|
112
|
-
`runtime: ${path.join(root, 'dist')}`,
|
|
113
|
-
`executable: ${realpathSync(process.argv[1])}`,
|
|
114
|
-
`goal supervisor: ${existsSync(path.join(root, 'dist/cli/commands/streaming/goalSupervisor.js')) ? 'enabled' : 'disabled'}`,
|
|
115
|
-
];
|
|
116
|
-
process.stdout.write(`${lines.join('\n')}\n`);
|
|
117
|
-
} else {
|
|
118
|
-
process.stdout.write(`${version}\n`);
|
|
119
|
-
}
|
|
120
|
-
process.exit(0);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
151
|
import('../dist/cli/index.js');
|
package/dist/buildInfo.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@denizokcu/haze",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"commit": "
|
|
5
|
-
"builtAt": "2026-11-
|
|
3
|
+
"version": "1.8.0",
|
|
4
|
+
"commit": "3f483ff88c29768a11bf8af5b29633e5c4d38382",
|
|
5
|
+
"builtAt": "2026-11-25T22:00:36.341Z"
|
|
6
6
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
/** Spinner ticks stay within this subtree, not the transcript orchestrator. */
|
|
3
2
|
export declare function BusyBar({ label, elapsed, detail, tip }: {
|
|
4
3
|
label: string;
|
|
5
4
|
elapsed: string;
|
|
6
5
|
detail?: string;
|
|
7
6
|
tip?: string;
|
|
8
|
-
}):
|
|
7
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The static welcome paragraph under the header banner. A component (not a
|
|
3
|
+
* module-level element) so `<Text color>` reads the active theme on every
|
|
4
|
+
* render and live `/themes` switches repaint it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function ChatHeaderSubtitle(): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from 'ink';
|
|
3
|
+
import { theme } from '../../ui/theme.js';
|
|
4
|
+
/**
|
|
5
|
+
* The static welcome paragraph under the header banner. A component (not a
|
|
6
|
+
* module-level element) so `<Text color>` reads the active theme on every
|
|
7
|
+
* render and live `/themes` switches repaint it.
|
|
8
|
+
*/
|
|
9
|
+
export function ChatHeaderSubtitle() {
|
|
10
|
+
return (_jsxs(Text, { children: ['A minimal coding agent for your terminal.\n\nStart with chat. Turn repeated work into Markdown skills:\n', _jsx(Text, { color: theme.command, children: "/skills" }), ' — create, enable, disable, validate, or remove skills.\n\nType ', _jsx(Text, { color: theme.command, children: "@" }), ' to browse workspace files. To grant read-only access to a file or directory outside the workspace for this turn, mention a path containing ', _jsx(Text, { color: theme.command, children: "/" }), ' (for example, ', _jsx(Text, { color: theme.command, children: "@../shared/file.ts" }), ' or ', _jsx(Text, { color: theme.command, children: "/tmp/reference.md" }), ').\n\nImage mentions require a vision-capable model. File edits and writes stay inside the workspace.\n\nhaze runs tool calls without confirmation gates. Supervise consequential work as you would any shell session.\n\nShape haze around your workflow as you go.\n\nUse ', _jsx(Text, { color: theme.command, children: "/help" }), ' for commands.'] }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ChatOptions {
|
|
3
|
+
debug?: boolean;
|
|
4
|
+
version?: string;
|
|
5
|
+
/** Safe build provenance (commit, build time) recorded into session headers. */
|
|
6
|
+
build?: {
|
|
7
|
+
commit?: string;
|
|
8
|
+
builtAt?: string;
|
|
9
|
+
};
|
|
10
|
+
continueSession?: boolean;
|
|
11
|
+
resumeSessionId?: string;
|
|
12
|
+
noSession?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function ChatScreen({ debug, version, build, continueSession, resumeSessionId, noSession, onShutdownReady }: ChatOptions & {
|
|
15
|
+
onShutdownReady?: (shutdown: () => Promise<void>) => void;
|
|
16
|
+
}): React.JSX.Element;
|
|
@@ -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;
|