@dsh-cc/tui 0.5.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/LICENSE +201 -0
- package/README.md +144 -0
- package/lib/bash-history.d.ts +31 -0
- package/lib/bash-history.d.ts.map +1 -0
- package/lib/bash-history.js +94 -0
- package/lib/bash-history.js.map +1 -0
- package/lib/compact-fold.d.ts +35 -0
- package/lib/compact-fold.d.ts.map +1 -0
- package/lib/compact-fold.js +60 -0
- package/lib/compact-fold.js.map +1 -0
- package/lib/components/arg-completers.d.ts +22 -0
- package/lib/components/arg-completers.d.ts.map +1 -0
- package/lib/components/arg-completers.js +75 -0
- package/lib/components/arg-completers.js.map +1 -0
- package/lib/components/code-theme.d.ts +25 -0
- package/lib/components/code-theme.d.ts.map +1 -0
- package/lib/components/code-theme.js +137 -0
- package/lib/components/code-theme.js.map +1 -0
- package/lib/components/completion.d.ts +50 -0
- package/lib/components/completion.d.ts.map +1 -0
- package/lib/components/completion.js +279 -0
- package/lib/components/completion.js.map +1 -0
- package/lib/components/diff-card.d.ts +29 -0
- package/lib/components/diff-card.d.ts.map +1 -0
- package/lib/components/diff-card.js +175 -0
- package/lib/components/diff-card.js.map +1 -0
- package/lib/components/diff-hunks.d.ts +44 -0
- package/lib/components/diff-hunks.d.ts.map +1 -0
- package/lib/components/diff-hunks.js +188 -0
- package/lib/components/diff-hunks.js.map +1 -0
- package/lib/components/editor-history.d.ts +23 -0
- package/lib/components/editor-history.d.ts.map +1 -0
- package/lib/components/editor-history.js +29 -0
- package/lib/components/editor-history.js.map +1 -0
- package/lib/components/markdown-theme.d.ts +11 -0
- package/lib/components/markdown-theme.d.ts.map +1 -0
- package/lib/components/markdown-theme.js +29 -0
- package/lib/components/markdown-theme.js.map +1 -0
- package/lib/components/masked-input.d.ts +24 -0
- package/lib/components/masked-input.d.ts.map +1 -0
- package/lib/components/masked-input.js +168 -0
- package/lib/components/masked-input.js.map +1 -0
- package/lib/components/overlay-host.d.ts +31 -0
- package/lib/components/overlay-host.d.ts.map +1 -0
- package/lib/components/overlay-host.js +128 -0
- package/lib/components/overlay-host.js.map +1 -0
- package/lib/components/overlays.d.ts +94 -0
- package/lib/components/overlays.d.ts.map +1 -0
- package/lib/components/overlays.js +450 -0
- package/lib/components/overlays.js.map +1 -0
- package/lib/components/provider-box.d.ts +23 -0
- package/lib/components/provider-box.d.ts.map +1 -0
- package/lib/components/provider-box.js +164 -0
- package/lib/components/provider-box.js.map +1 -0
- package/lib/components/read-group.d.ts +51 -0
- package/lib/components/read-group.d.ts.map +1 -0
- package/lib/components/read-group.js +105 -0
- package/lib/components/read-group.js.map +1 -0
- package/lib/components/root-bash.d.ts +36 -0
- package/lib/components/root-bash.d.ts.map +1 -0
- package/lib/components/root-bash.js +112 -0
- package/lib/components/root-bash.js.map +1 -0
- package/lib/components/root-types.d.ts +42 -0
- package/lib/components/root-types.d.ts.map +1 -0
- package/lib/components/root-types.js +8 -0
- package/lib/components/root-types.js.map +1 -0
- package/lib/components/root-utils.d.ts +22 -0
- package/lib/components/root-utils.d.ts.map +1 -0
- package/lib/components/root-utils.js +45 -0
- package/lib/components/root-utils.js.map +1 -0
- package/lib/components/root.d.ts +25 -0
- package/lib/components/root.d.ts.map +1 -0
- package/lib/components/root.js +357 -0
- package/lib/components/root.js.map +1 -0
- package/lib/components/theme.d.ts +61 -0
- package/lib/components/theme.d.ts.map +1 -0
- package/lib/components/theme.js +99 -0
- package/lib/components/theme.js.map +1 -0
- package/lib/components/transcript.d.ts +43 -0
- package/lib/components/transcript.d.ts.map +1 -0
- package/lib/components/transcript.js +203 -0
- package/lib/components/transcript.js.map +1 -0
- package/lib/components/working-line.d.ts +35 -0
- package/lib/components/working-line.d.ts.map +1 -0
- package/lib/components/working-line.js +66 -0
- package/lib/components/working-line.js.map +1 -0
- package/lib/effort-catalog.d.ts +27 -0
- package/lib/effort-catalog.d.ts.map +1 -0
- package/lib/effort-catalog.js +36 -0
- package/lib/effort-catalog.js.map +1 -0
- package/lib/export-markdown.d.ts +18 -0
- package/lib/export-markdown.d.ts.map +1 -0
- package/lib/export-markdown.js +124 -0
- package/lib/export-markdown.js.map +1 -0
- package/lib/harness/approval-preview.d.ts +33 -0
- package/lib/harness/approval-preview.d.ts.map +1 -0
- package/lib/harness/approval-preview.js +179 -0
- package/lib/harness/approval-preview.js.map +1 -0
- package/lib/harness/boot-banner.d.ts +14 -0
- package/lib/harness/boot-banner.d.ts.map +1 -0
- package/lib/harness/boot-banner.js +89 -0
- package/lib/harness/boot-banner.js.map +1 -0
- package/lib/harness/driver-agent.d.ts +78 -0
- package/lib/harness/driver-agent.d.ts.map +1 -0
- package/lib/harness/driver-agent.js +314 -0
- package/lib/harness/driver-agent.js.map +1 -0
- package/lib/harness/driver-agents.d.ts +20 -0
- package/lib/harness/driver-agents.d.ts.map +1 -0
- package/lib/harness/driver-agents.js +123 -0
- package/lib/harness/driver-agents.js.map +1 -0
- package/lib/harness/driver-approvals.d.ts +38 -0
- package/lib/harness/driver-approvals.d.ts.map +1 -0
- package/lib/harness/driver-approvals.js +277 -0
- package/lib/harness/driver-approvals.js.map +1 -0
- package/lib/harness/driver-bash.d.ts +15 -0
- package/lib/harness/driver-bash.d.ts.map +1 -0
- package/lib/harness/driver-bash.js +73 -0
- package/lib/harness/driver-bash.js.map +1 -0
- package/lib/harness/driver-catalog.d.ts +84 -0
- package/lib/harness/driver-catalog.d.ts.map +1 -0
- package/lib/harness/driver-catalog.js +256 -0
- package/lib/harness/driver-catalog.js.map +1 -0
- package/lib/harness/driver-ctx.d.ts +462 -0
- package/lib/harness/driver-ctx.d.ts.map +1 -0
- package/lib/harness/driver-ctx.js +11 -0
- package/lib/harness/driver-ctx.js.map +1 -0
- package/lib/harness/driver-hud.d.ts +31 -0
- package/lib/harness/driver-hud.d.ts.map +1 -0
- package/lib/harness/driver-hud.js +204 -0
- package/lib/harness/driver-hud.js.map +1 -0
- package/lib/harness/driver-live.d.ts +36 -0
- package/lib/harness/driver-live.d.ts.map +1 -0
- package/lib/harness/driver-live.js +44 -0
- package/lib/harness/driver-live.js.map +1 -0
- package/lib/harness/driver-modal.d.ts +52 -0
- package/lib/harness/driver-modal.d.ts.map +1 -0
- package/lib/harness/driver-modal.js +78 -0
- package/lib/harness/driver-modal.js.map +1 -0
- package/lib/harness/driver-mode.d.ts +35 -0
- package/lib/harness/driver-mode.d.ts.map +1 -0
- package/lib/harness/driver-mode.js +84 -0
- package/lib/harness/driver-mode.js.map +1 -0
- package/lib/harness/driver-pickers.d.ts +48 -0
- package/lib/harness/driver-pickers.d.ts.map +1 -0
- package/lib/harness/driver-pickers.js +249 -0
- package/lib/harness/driver-pickers.js.map +1 -0
- package/lib/harness/driver-promote.d.ts +29 -0
- package/lib/harness/driver-promote.d.ts.map +1 -0
- package/lib/harness/driver-promote.js +36 -0
- package/lib/harness/driver-promote.js.map +1 -0
- package/lib/harness/driver-queue.d.ts +19 -0
- package/lib/harness/driver-queue.d.ts.map +1 -0
- package/lib/harness/driver-queue.js +281 -0
- package/lib/harness/driver-queue.js.map +1 -0
- package/lib/harness/driver-run-local.d.ts +32 -0
- package/lib/harness/driver-run-local.d.ts.map +1 -0
- package/lib/harness/driver-run-local.js +366 -0
- package/lib/harness/driver-run-local.js.map +1 -0
- package/lib/harness/driver-sessions.d.ts +28 -0
- package/lib/harness/driver-sessions.d.ts.map +1 -0
- package/lib/harness/driver-sessions.js +386 -0
- package/lib/harness/driver-sessions.js.map +1 -0
- package/lib/harness/driver.d.ts +22 -0
- package/lib/harness/driver.d.ts.map +1 -0
- package/lib/harness/driver.js +459 -0
- package/lib/harness/driver.js.map +1 -0
- package/lib/harness/preset.d.ts +32 -0
- package/lib/harness/preset.d.ts.map +1 -0
- package/lib/harness/preset.js +34 -0
- package/lib/harness/preset.js.map +1 -0
- package/lib/harness/session-list.d.ts +65 -0
- package/lib/harness/session-list.d.ts.map +1 -0
- package/lib/harness/session-list.js +91 -0
- package/lib/harness/session-list.js.map +1 -0
- package/lib/harness/shell-output.d.ts +44 -0
- package/lib/harness/shell-output.d.ts.map +1 -0
- package/lib/harness/shell-output.js +90 -0
- package/lib/harness/shell-output.js.map +1 -0
- package/lib/harness/statusline-cc-transcript.d.ts +51 -0
- package/lib/harness/statusline-cc-transcript.d.ts.map +1 -0
- package/lib/harness/statusline-cc-transcript.js +191 -0
- package/lib/harness/statusline-cc-transcript.js.map +1 -0
- package/lib/harness/statusline-command.d.ts +54 -0
- package/lib/harness/statusline-command.d.ts.map +1 -0
- package/lib/harness/statusline-command.js +161 -0
- package/lib/harness/statusline-command.js.map +1 -0
- package/lib/harness/statusline-payload.d.ts +79 -0
- package/lib/harness/statusline-payload.d.ts.map +1 -0
- package/lib/harness/statusline-payload.js +93 -0
- package/lib/harness/statusline-payload.js.map +1 -0
- package/lib/harness/statusline-settings.d.ts +47 -0
- package/lib/harness/statusline-settings.d.ts.map +1 -0
- package/lib/harness/statusline-settings.js +57 -0
- package/lib/harness/statusline-settings.js.map +1 -0
- package/lib/harness/statusline-wiring.d.ts +45 -0
- package/lib/harness/statusline-wiring.d.ts.map +1 -0
- package/lib/harness/statusline-wiring.js +247 -0
- package/lib/harness/statusline-wiring.js.map +1 -0
- package/lib/harness/usage-view.d.ts +84 -0
- package/lib/harness/usage-view.d.ts.map +1 -0
- package/lib/harness/usage-view.js +199 -0
- package/lib/harness/usage-view.js.map +1 -0
- package/lib/harness/worktree-exit.d.ts +105 -0
- package/lib/harness/worktree-exit.d.ts.map +1 -0
- package/lib/harness/worktree-exit.js +168 -0
- package/lib/harness/worktree-exit.js.map +1 -0
- package/lib/history.d.ts +50 -0
- package/lib/history.d.ts.map +1 -0
- package/lib/history.js +139 -0
- package/lib/history.js.map +1 -0
- package/lib/index.d.ts +63 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +54 -0
- package/lib/index.js.map +1 -0
- package/lib/input.d.ts +158 -0
- package/lib/input.d.ts.map +1 -0
- package/lib/input.js +400 -0
- package/lib/input.js.map +1 -0
- package/lib/invariant.d.ts +14 -0
- package/lib/invariant.d.ts.map +1 -0
- package/lib/invariant.js +20 -0
- package/lib/invariant.js.map +1 -0
- package/lib/mode-cycle.d.ts +22 -0
- package/lib/mode-cycle.d.ts.map +1 -0
- package/lib/mode-cycle.js +32 -0
- package/lib/mode-cycle.js.map +1 -0
- package/lib/model-catalog.d.ts +22 -0
- package/lib/model-catalog.d.ts.map +1 -0
- package/lib/model-catalog.js +45 -0
- package/lib/model-catalog.js.map +1 -0
- package/lib/packaged-preset.d.ts +32 -0
- package/lib/packaged-preset.d.ts.map +1 -0
- package/lib/packaged-preset.js +94 -0
- package/lib/packaged-preset.js.map +1 -0
- package/lib/plugin.d.ts +11 -0
- package/lib/plugin.d.ts.map +1 -0
- package/lib/plugin.js +88 -0
- package/lib/plugin.js.map +1 -0
- package/lib/profile.d.ts +4 -0
- package/lib/profile.d.ts.map +1 -0
- package/lib/profile.js +7 -0
- package/lib/profile.js.map +1 -0
- package/lib/project-sessions.d.ts +29 -0
- package/lib/project-sessions.d.ts.map +1 -0
- package/lib/project-sessions.js +60 -0
- package/lib/project-sessions.js.map +1 -0
- package/lib/project.d.ts +75 -0
- package/lib/project.d.ts.map +1 -0
- package/lib/project.js +196 -0
- package/lib/project.js.map +1 -0
- package/lib/provider-actions.d.ts +37 -0
- package/lib/provider-actions.d.ts.map +1 -0
- package/lib/provider-actions.js +417 -0
- package/lib/provider-actions.js.map +1 -0
- package/lib/provider-command.d.ts +109 -0
- package/lib/provider-command.d.ts.map +1 -0
- package/lib/provider-command.js +220 -0
- package/lib/provider-command.js.map +1 -0
- package/lib/provider-detail.d.ts +15 -0
- package/lib/provider-detail.d.ts.map +1 -0
- package/lib/provider-detail.js +201 -0
- package/lib/provider-detail.js.map +1 -0
- package/lib/provider-flow.d.ts +191 -0
- package/lib/provider-flow.d.ts.map +1 -0
- package/lib/provider-flow.js +192 -0
- package/lib/provider-flow.js.map +1 -0
- package/lib/provider-presets.d.ts +32 -0
- package/lib/provider-presets.d.ts.map +1 -0
- package/lib/provider-presets.js +105 -0
- package/lib/provider-presets.js.map +1 -0
- package/lib/provider-read.d.ts +63 -0
- package/lib/provider-read.d.ts.map +1 -0
- package/lib/provider-read.js +115 -0
- package/lib/provider-read.js.map +1 -0
- package/lib/provider-settings.d.ts +30 -0
- package/lib/provider-settings.d.ts.map +1 -0
- package/lib/provider-settings.js +65 -0
- package/lib/provider-settings.js.map +1 -0
- package/lib/resume-target.d.ts +59 -0
- package/lib/resume-target.d.ts.map +1 -0
- package/lib/resume-target.js +143 -0
- package/lib/resume-target.js.map +1 -0
- package/lib/slash.d.ts +44 -0
- package/lib/slash.d.ts.map +1 -0
- package/lib/slash.js +81 -0
- package/lib/slash.js.map +1 -0
- package/lib/state/driver-types.d.ts +505 -0
- package/lib/state/driver-types.d.ts.map +1 -0
- package/lib/state/driver-types.js +8 -0
- package/lib/state/driver-types.js.map +1 -0
- package/lib/state/driver-usage-types.d.ts +59 -0
- package/lib/state/driver-usage-types.d.ts.map +1 -0
- package/lib/state/driver-usage-types.js +8 -0
- package/lib/state/driver-usage-types.js.map +1 -0
- package/lib/statusline.d.ts +63 -0
- package/lib/statusline.d.ts.map +1 -0
- package/lib/statusline.js +97 -0
- package/lib/statusline.js.map +1 -0
- package/lib/store/pickers.d.ts +34 -0
- package/lib/store/pickers.d.ts.map +1 -0
- package/lib/store/pickers.js +111 -0
- package/lib/store/pickers.js.map +1 -0
- package/lib/store/provider-panel.d.ts +107 -0
- package/lib/store/provider-panel.d.ts.map +1 -0
- package/lib/store/provider-panel.js +151 -0
- package/lib/store/provider-panel.js.map +1 -0
- package/lib/store/question.d.ts +21 -0
- package/lib/store/question.d.ts.map +1 -0
- package/lib/store/question.js +59 -0
- package/lib/store/question.js.map +1 -0
- package/lib/store/queue.d.ts +27 -0
- package/lib/store/queue.d.ts.map +1 -0
- package/lib/store/queue.js +34 -0
- package/lib/store/queue.js.map +1 -0
- package/lib/store/session.d.ts +73 -0
- package/lib/store/session.d.ts.map +1 -0
- package/lib/store/session.js +172 -0
- package/lib/store/session.js.map +1 -0
- package/lib/store/subagents.d.ts +16 -0
- package/lib/store/subagents.d.ts.map +1 -0
- package/lib/store/subagents.js +44 -0
- package/lib/store/subagents.js.map +1 -0
- package/lib/store/todos.d.ts +35 -0
- package/lib/store/todos.d.ts.map +1 -0
- package/lib/store/todos.js +68 -0
- package/lib/store/todos.js.map +1 -0
- package/lib/store/usage.d.ts +15 -0
- package/lib/store/usage.d.ts.map +1 -0
- package/lib/store/usage.js +27 -0
- package/lib/store/usage.js.map +1 -0
- package/lib/store/views.d.ts +419 -0
- package/lib/store/views.d.ts.map +1 -0
- package/lib/store/views.js +3 -0
- package/lib/store/views.js.map +1 -0
- package/lib/store.d.ts +19 -0
- package/lib/store.d.ts.map +1 -0
- package/lib/store.js +10 -0
- package/lib/store.js.map +1 -0
- package/lib/terminal/lease.d.ts +33 -0
- package/lib/terminal/lease.d.ts.map +1 -0
- package/lib/terminal/lease.js +99 -0
- package/lib/terminal/lease.js.map +1 -0
- package/lib/tool-card.d.ts +75 -0
- package/lib/tool-card.d.ts.map +1 -0
- package/lib/tool-card.js +109 -0
- package/lib/tool-card.js.map +1 -0
- package/lib/tool-verbs.d.ts +12 -0
- package/lib/tool-verbs.d.ts.map +1 -0
- package/lib/tool-verbs.js +29 -0
- package/lib/tool-verbs.js.map +1 -0
- package/lib/transcript.d.ts +40 -0
- package/lib/transcript.d.ts.map +1 -0
- package/lib/transcript.js +413 -0
- package/lib/transcript.js.map +1 -0
- package/lib/working-line.d.ts +44 -0
- package/lib/working-line.d.ts.map +1 -0
- package/lib/working-line.js +56 -0
- package/lib/working-line.js.map +1 -0
- package/package.json +72 -0
- package/presets/cc/.dsh-cc-managed.json +5 -0
- package/presets/cc/agent.cordis.yml +524 -0
- package/presets/cc/preset.yml +3 -0
- package/scripts/stage-preset.mjs +26 -0
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* View-layer types for the TUI store: transcript rows, overlay/picker views,
|
|
3
|
+
* and the aggregate TuiState. Pure types — no reducer logic lives here.
|
|
4
|
+
* @module @dsh-cc/tui/store/views
|
|
5
|
+
*/
|
|
6
|
+
import type { FileDiff } from '../tool-card.ts';
|
|
7
|
+
import type { TurnAnchor } from '../working-line.ts';
|
|
8
|
+
import type { ProviderPanelState } from './provider-panel.ts';
|
|
9
|
+
export type TranscriptRow = {
|
|
10
|
+
kind: 'user';
|
|
11
|
+
text: string;
|
|
12
|
+
seq?: number;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'assistant';
|
|
15
|
+
text: string;
|
|
16
|
+
seq?: number;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'thinking';
|
|
19
|
+
text: string;
|
|
20
|
+
seq?: number;
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'tool';
|
|
23
|
+
callId: string;
|
|
24
|
+
name: string;
|
|
25
|
+
args: string;
|
|
26
|
+
title: string;
|
|
27
|
+
body?: string;
|
|
28
|
+
result?: string;
|
|
29
|
+
error?: boolean;
|
|
30
|
+
running: boolean;
|
|
31
|
+
/** Structured file diffs from a presenter's diff-card view; rendered as hunks. */
|
|
32
|
+
diffs?: readonly FileDiff[];
|
|
33
|
+
seq?: number;
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'banner';
|
|
36
|
+
/** Pre-styled UI chrome (boot whale art); rendered verbatim, no theme wrap. */
|
|
37
|
+
text: string;
|
|
38
|
+
/**
|
|
39
|
+
* No `seq`: like the boot status row, the banner survives compaction.
|
|
40
|
+
* Markdown export skips it entirely.
|
|
41
|
+
*/
|
|
42
|
+
seq?: number;
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'status';
|
|
45
|
+
text: string;
|
|
46
|
+
/**
|
|
47
|
+
* Marks this status row as an error so the renderer paints it red instead
|
|
48
|
+
* of dim. Set by `turn/end` error folding; plain status notices stay dim.
|
|
49
|
+
*/
|
|
50
|
+
error?: boolean;
|
|
51
|
+
seq?: number;
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'compact';
|
|
54
|
+
/** `'manual'` when a /compact command drove it, `'auto'` for pressure compaction. */
|
|
55
|
+
trigger: 'manual' | 'auto';
|
|
56
|
+
/** Shadowed history item count (from the compaction/summary metering). */
|
|
57
|
+
items: number;
|
|
58
|
+
/** Heuristic tokens the compaction shadowed. */
|
|
59
|
+
tokens: number;
|
|
60
|
+
/** Extracted `<compacted-summary>` body; '' when unavailable. */
|
|
61
|
+
summary: string;
|
|
62
|
+
seq?: number;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Structured payload preview attached to an approval prompt, recovered from
|
|
66
|
+
* the paired tool/call event: the shell command, the affected file diffs, or
|
|
67
|
+
* the pretty-printed raw arguments. `none` degrades to tool name + reason.
|
|
68
|
+
*/
|
|
69
|
+
export type ApprovalPreview = {
|
|
70
|
+
kind: 'command';
|
|
71
|
+
command: string;
|
|
72
|
+
} | {
|
|
73
|
+
kind: 'diff';
|
|
74
|
+
diffs: readonly FileDiff[];
|
|
75
|
+
} | {
|
|
76
|
+
kind: 'args';
|
|
77
|
+
json: string;
|
|
78
|
+
} | {
|
|
79
|
+
kind: 'none';
|
|
80
|
+
};
|
|
81
|
+
export interface ApprovalView {
|
|
82
|
+
toolName: string;
|
|
83
|
+
reason?: string;
|
|
84
|
+
/** Structured payload preview for the call under review. */
|
|
85
|
+
preview?: ApprovalPreview;
|
|
86
|
+
/** Modal entries waiting behind this one in the approval queue; absent for a lone head. */
|
|
87
|
+
pendingCount?: number;
|
|
88
|
+
}
|
|
89
|
+
export interface QuestionOptionView {
|
|
90
|
+
label: string;
|
|
91
|
+
description?: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Live view of an ask-user-question prompt: the full first question item
|
|
95
|
+
* (text, detail markdown, option descriptions, multiSelect, intent) plus the
|
|
96
|
+
* interaction state the overlay mutates as the user navigates.
|
|
97
|
+
*/
|
|
98
|
+
export interface QuestionView {
|
|
99
|
+
header: string;
|
|
100
|
+
/** The item's question text. */
|
|
101
|
+
question: string;
|
|
102
|
+
/** Supporting detail (plan markdown for plan-review intents). */
|
|
103
|
+
detail?: string;
|
|
104
|
+
options: readonly QuestionOptionView[];
|
|
105
|
+
/** Whether more than one option may be selected. */
|
|
106
|
+
multiSelect: boolean;
|
|
107
|
+
intent?: {
|
|
108
|
+
kind: 'plan-review';
|
|
109
|
+
approve: string;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Focused row: an index into `options`, or `options.length` for the
|
|
113
|
+
* trailing free-text ("Other") row.
|
|
114
|
+
*/
|
|
115
|
+
focused: number;
|
|
116
|
+
/** Toggled labels (multiSelect) — single-select resolves on pick. */
|
|
117
|
+
selected: readonly string[];
|
|
118
|
+
/** Free-text buffer for the "Other" row. */
|
|
119
|
+
custom: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* One LLM adapter entry shown in the `/model` picker. Mirrors the harness
|
|
123
|
+
* {@link CatalogEntry} but lives in the view layer (harness-import-free).
|
|
124
|
+
*/
|
|
125
|
+
export interface CatalogEntryView {
|
|
126
|
+
provider: string;
|
|
127
|
+
id: string;
|
|
128
|
+
name: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Live view of the `/model` picker overlay: the catalog rows, the focused
|
|
132
|
+
* index, and the active model route (if any) so the renderer can mark it.
|
|
133
|
+
*/
|
|
134
|
+
export interface ModelPickerView {
|
|
135
|
+
entries: readonly CatalogEntryView[];
|
|
136
|
+
focused: number;
|
|
137
|
+
current?: {
|
|
138
|
+
provider: string;
|
|
139
|
+
model: string;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Live view of the `/effort` picker overlay: the reasoning-effort levels of
|
|
144
|
+
* the active model plus the trailing reserved entry (the literal
|
|
145
|
+
* `'default'`), the focused index, and the current effort (if any) so the
|
|
146
|
+
* renderer can mark it. Plain strings — branding to `ReasoningEffortId`
|
|
147
|
+
* happens at the driver's write seam.
|
|
148
|
+
*/
|
|
149
|
+
export interface EffortPickerView {
|
|
150
|
+
entries: readonly string[];
|
|
151
|
+
focused: number;
|
|
152
|
+
current: string | undefined;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* One row in the `/permissions` picker. Mirrors the command package's
|
|
156
|
+
* permission-mode option (`id`/`label`/`detail`) but lives in the view
|
|
157
|
+
* layer so the overlay can render without importing the host surface.
|
|
158
|
+
*/
|
|
159
|
+
export interface PermissionPickerEntryView {
|
|
160
|
+
id: string;
|
|
161
|
+
label: string;
|
|
162
|
+
detail: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Live view of the `/permissions` picker overlay: the five CC rule-engine
|
|
166
|
+
* modes, the focused index, the current mode (so the renderer can mark it),
|
|
167
|
+
* and an optional in-overlay confirmation step for `bypassPermissions`.
|
|
168
|
+
*/
|
|
169
|
+
export interface PermissionPickerView {
|
|
170
|
+
entries: readonly PermissionPickerEntryView[];
|
|
171
|
+
focused: number;
|
|
172
|
+
current: string;
|
|
173
|
+
confirmingBypass?: true;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* One session entry shown in the `/resume` picker. Mirrors the harness
|
|
177
|
+
* persistence header but lives in the view layer (harness-import-free).
|
|
178
|
+
*/
|
|
179
|
+
export interface SessionEntryView {
|
|
180
|
+
id: string;
|
|
181
|
+
cwd?: string;
|
|
182
|
+
createdAt: number;
|
|
183
|
+
/** Last-activity mtime from persistence when the backend can observe it. */
|
|
184
|
+
updatedAtMs?: number;
|
|
185
|
+
/** Async-decorated session title; absent until the title read lands. */
|
|
186
|
+
title?: string;
|
|
187
|
+
/** Parent session id when this entry is a fork/child. */
|
|
188
|
+
parentSession?: string;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Live view of the `/resume` session-switcher overlay: the filtered,
|
|
192
|
+
* last-active-first session list, the focused index, a `switching` flag that
|
|
193
|
+
* dims input while a switch is in flight, the current session id (marked
|
|
194
|
+
* with `●`), the typed query filter, and the visibility scope. `sessions` is
|
|
195
|
+
* the visible list only — the full list stays in the driver and
|
|
196
|
+
* `totalCount` carries its length for the empty-cwd-scope hint.
|
|
197
|
+
*/
|
|
198
|
+
export interface SessionSwitcherView {
|
|
199
|
+
sessions: readonly SessionEntryView[];
|
|
200
|
+
focused: number;
|
|
201
|
+
switching: boolean;
|
|
202
|
+
currentId: string;
|
|
203
|
+
/** Free-text filter typed inside the picker ('' when none). */
|
|
204
|
+
query: string;
|
|
205
|
+
/** Visibility scope: this project's cwd (default) or every project. */
|
|
206
|
+
scope: 'cwd' | 'all';
|
|
207
|
+
/**
|
|
208
|
+
* The cwd the project scope was derived from. Rows whose recorded cwd
|
|
209
|
+
* differs (worktree / subdirectory sessions of the same project) surface
|
|
210
|
+
* their cwd basename even in cwd scope.
|
|
211
|
+
*/
|
|
212
|
+
cwd?: string;
|
|
213
|
+
/** Length of the unfiltered list, for the "Tab to view all (N)" hint. */
|
|
214
|
+
totalCount?: number;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* One observed subagent run. `subagent/start` and `subagent/end` are global
|
|
218
|
+
* (process-scoped) observe-only snapshots paired by `runId`; the driver
|
|
219
|
+
* folds them into this view without calling `listChildren` — tracking is
|
|
220
|
+
* event-only, so it stays composition-agnostic.
|
|
221
|
+
*/
|
|
222
|
+
export interface SubagentRunView {
|
|
223
|
+
runId: string;
|
|
224
|
+
provider: string;
|
|
225
|
+
sessionId: string;
|
|
226
|
+
/**
|
|
227
|
+
* Continuable (resumable) epochs park on `subagent/end` — the activation is
|
|
228
|
+
* torn down but the session lives; one-shot runs end as `done`.
|
|
229
|
+
*/
|
|
230
|
+
status: 'running' | 'parked' | 'done';
|
|
231
|
+
/** Present once the `subagent/end` snapshot lands. */
|
|
232
|
+
stopReason?: string;
|
|
233
|
+
/**
|
|
234
|
+
* True when the child session carries a continuable descriptor, so a later
|
|
235
|
+
* `subagent/start` for the same `sessionId` is a cold-resume of this row.
|
|
236
|
+
*/
|
|
237
|
+
resumable?: boolean;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Live statusline HUD fed by the sessionProjections change feed:
|
|
241
|
+
* context-occupancy percent and cumulative token totals. Both fields are
|
|
242
|
+
* optional — the footer omits whatever the current composition lacks.
|
|
243
|
+
*/
|
|
244
|
+
export interface HudView {
|
|
245
|
+
/** Context occupancy, 0-100 integer; absent until a window is known. */
|
|
246
|
+
contextPercent?: number;
|
|
247
|
+
/** Cumulative provider-reported token totals. */
|
|
248
|
+
tokens?: {
|
|
249
|
+
input: number;
|
|
250
|
+
output: number;
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Raw occupancy behind `contextPercent` for exact rendering. The numerator
|
|
254
|
+
* is the projected token count — never back-derived from the rounded
|
|
255
|
+
* percent. `window` is absent when the projection does not report one.
|
|
256
|
+
*/
|
|
257
|
+
contextTokens?: {
|
|
258
|
+
readonly used: number;
|
|
259
|
+
readonly window?: number;
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* One todo from the session's todo list. Mirrors the harness projection's
|
|
264
|
+
* item shape but lives in the view layer (harness-import-free).
|
|
265
|
+
*/
|
|
266
|
+
export interface TodoItemView {
|
|
267
|
+
content: string;
|
|
268
|
+
status: 'pending' | 'in_progress' | 'completed';
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Live view of the Ctrl+T todo panel overlay: only the interaction state the
|
|
272
|
+
* panel mutates (the focused row index); the rows come from `state.todos`.
|
|
273
|
+
*/
|
|
274
|
+
export interface TodoPanelView {
|
|
275
|
+
focused: number;
|
|
276
|
+
}
|
|
277
|
+
/** Cumulative token usage across the four provider-reported buckets. */
|
|
278
|
+
export interface UsageTotalsView {
|
|
279
|
+
input: number;
|
|
280
|
+
output: number;
|
|
281
|
+
cacheRead?: number;
|
|
282
|
+
cacheWrite?: number;
|
|
283
|
+
}
|
|
284
|
+
/** Context composition by role: system prompt, tool output, messages. */
|
|
285
|
+
export interface UsageBreakdownView {
|
|
286
|
+
system: number;
|
|
287
|
+
tools: number;
|
|
288
|
+
messages: number;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Live `/usage` panel content, folded from the tokenUsage, contextPressure,
|
|
292
|
+
* and contextBreakdown projections. Every section is optional — the panel
|
|
293
|
+
* degrades each missing one to a dim `n/a` independently.
|
|
294
|
+
*/
|
|
295
|
+
export interface UsageView {
|
|
296
|
+
totals?: UsageTotalsView;
|
|
297
|
+
/** Context tokens currently projected into the window. */
|
|
298
|
+
contextUsed?: number;
|
|
299
|
+
/** Context window size; absent when the projection does not report one. */
|
|
300
|
+
contextWindow?: number;
|
|
301
|
+
breakdown?: UsageBreakdownView;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Marker for the open `/usage` panel overlay — pure display with no focus or
|
|
305
|
+
* navigation state; the content comes from `state.usage`.
|
|
306
|
+
*/
|
|
307
|
+
export type UsagePanelView = Record<string, never>;
|
|
308
|
+
/**
|
|
309
|
+
* Live view of the `/quit` worktree-exit confirmation overlay: the session
|
|
310
|
+
* descriptor under decision, the removal evidence shown next to the
|
|
311
|
+
* destructive option, and the focused row (`0` keep, `1` remove, `2`
|
|
312
|
+
* cancel). `busy` marks an in-flight removal — keys stay swallowed.
|
|
313
|
+
* Plain fields only: the store must not import from harness/.
|
|
314
|
+
*/
|
|
315
|
+
export interface WorktreeExitView {
|
|
316
|
+
/** Canonical repository root (where `.claude/worktrees` lives). */
|
|
317
|
+
repoRoot: string;
|
|
318
|
+
/** Absolute worktree path (the session cwd). */
|
|
319
|
+
worktreePath: string;
|
|
320
|
+
/** The branch checked out in the worktree. */
|
|
321
|
+
branch: string;
|
|
322
|
+
/** True when created via the launcher's `--worktree` (branch is owned). */
|
|
323
|
+
managed: boolean;
|
|
324
|
+
/** Whether removal may also delete the backing branch. */
|
|
325
|
+
ownsBranch: boolean;
|
|
326
|
+
/** Managed sessions only: the commit the worktree was created from. */
|
|
327
|
+
baseHead?: string;
|
|
328
|
+
/** Uncommitted changes; undefined when the probe failed. */
|
|
329
|
+
dirtyFiles?: number;
|
|
330
|
+
/** Managed sessions only: commits past baseHead; undefined when unknown. */
|
|
331
|
+
commitsAhead?: number;
|
|
332
|
+
/** Focused option row: 0 keep, 1 remove, 2 cancel. */
|
|
333
|
+
focused: number;
|
|
334
|
+
/** Removal in flight. */
|
|
335
|
+
busy: boolean;
|
|
336
|
+
}
|
|
337
|
+
/** Number of rows in the worktree-exit overlay (keep / remove / cancel). */
|
|
338
|
+
export declare const WORKTREE_EXIT_OPTION_COUNT = 3;
|
|
339
|
+
/**
|
|
340
|
+
* Live view of the `/provider` overlay home (§4.2): the two-section list
|
|
341
|
+
* rows, the focused cursor, and a transient message line. Reuses the pure
|
|
342
|
+
* panel state directly — the list phase is the only phase this unit wires.
|
|
343
|
+
*/
|
|
344
|
+
export type ProviderPanelView = ProviderPanelState;
|
|
345
|
+
export interface TuiState {
|
|
346
|
+
rows: TranscriptRow[];
|
|
347
|
+
draft: string;
|
|
348
|
+
busy: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Anchor of the currently-running turn (drives the working line): absent
|
|
351
|
+
* while idle. `busy` alone cannot back the line — it flips false on the
|
|
352
|
+
* first assistant/message fold and jitters within a turn.
|
|
353
|
+
*/
|
|
354
|
+
turn?: TurnAnchor;
|
|
355
|
+
permissionMode: string;
|
|
356
|
+
notice?: string;
|
|
357
|
+
approval?: ApprovalView;
|
|
358
|
+
question?: QuestionView;
|
|
359
|
+
modelPicker?: ModelPickerView;
|
|
360
|
+
/** Open `/effort` picker overlay; absent while closed. */
|
|
361
|
+
effortPicker?: EffortPickerView;
|
|
362
|
+
/** Open `/permissions` picker overlay; absent while closed. */
|
|
363
|
+
permissionPicker?: PermissionPickerView;
|
|
364
|
+
sessionSwitcher?: SessionSwitcherView;
|
|
365
|
+
/**
|
|
366
|
+
* Outbox of texts submitted while the agent was busy: rendered as pending
|
|
367
|
+
* chips, flushed into the next turn on durable `turn/end` (or injected
|
|
368
|
+
* immediately via Ctrl+S). Idle submits bypass the outbox entirely.
|
|
369
|
+
*/
|
|
370
|
+
queued: readonly string[];
|
|
371
|
+
/** Whether thinking rows render expanded (Ctrl+O). Collapsed by default. */
|
|
372
|
+
thinkingExpanded: boolean;
|
|
373
|
+
/**
|
|
374
|
+
* Whether tool rows render their output (body/result/diffs) expanded
|
|
375
|
+
* (Ctrl+O). Expanded by default — collapsing is opt-in via the toggle.
|
|
376
|
+
*/
|
|
377
|
+
toolOutputExpanded: boolean;
|
|
378
|
+
/** Whether compact rows render their summary body (Ctrl+O). Collapsed by default. */
|
|
379
|
+
compactExpanded: boolean;
|
|
380
|
+
/**
|
|
381
|
+
* Metering carried from the `compaction/summary` event to the immediately
|
|
382
|
+
* following surface replacement, so the compact row can show how much the
|
|
383
|
+
* checkpoint shadowed. Cleared when a replace consumes it.
|
|
384
|
+
*/
|
|
385
|
+
pendingCompact?: {
|
|
386
|
+
items: number;
|
|
387
|
+
tokens: number;
|
|
388
|
+
sourceCommandId?: string;
|
|
389
|
+
};
|
|
390
|
+
/** Observed subagent runs (newest appended; capped at 20). */
|
|
391
|
+
subagents: readonly SubagentRunView[];
|
|
392
|
+
/** Statusline HUD (context %, token totals) from the projections feed. */
|
|
393
|
+
hud?: HudView;
|
|
394
|
+
/** Session todo list (whole-list last-wins; absent before the first write). */
|
|
395
|
+
todos?: readonly TodoItemView[];
|
|
396
|
+
/** Open Ctrl+T todo panel; absent while closed. */
|
|
397
|
+
todoPanel?: TodoPanelView;
|
|
398
|
+
/** Live usage snapshot (token totals, context occupancy, breakdown). */
|
|
399
|
+
usage?: UsageView;
|
|
400
|
+
/** Open `/usage` panel; absent while closed. */
|
|
401
|
+
usagePanel?: UsagePanelView;
|
|
402
|
+
/** Open `/quit` worktree-exit confirmation overlay; absent while closed. */
|
|
403
|
+
worktreeExit?: WorktreeExitView;
|
|
404
|
+
/** Open `/provider` panel; absent while closed. */
|
|
405
|
+
providerPanel?: ProviderPanelView;
|
|
406
|
+
/**
|
|
407
|
+
* Latest `session/title` event text (framework-generated session summary),
|
|
408
|
+
* folded last-wins. Drives the terminal window title; absent until the
|
|
409
|
+
* first title lands. Log-only: never produces a transcript row.
|
|
410
|
+
*/
|
|
411
|
+
title?: string;
|
|
412
|
+
/**
|
|
413
|
+
* Timestamp (`Date.now()`) of the last idle Ctrl+C press — the anchor for
|
|
414
|
+
* the double-press-to-exit window. Never cleared: a stale anchor simply
|
|
415
|
+
* falls outside the window, so the next press starts a new attempt.
|
|
416
|
+
*/
|
|
417
|
+
lastExitAttemptAt?: number;
|
|
418
|
+
}
|
|
419
|
+
//# sourceMappingURL=views.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"views.d.ts","sourceRoot":"","sources":["../../src/store/views.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAE7D,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAChD;IACA,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,C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AA;IAC3B,qFAAqF;IACrF,eAAe,EAAE,OAAO,CAAA;IACxB;;;;OAIG;IACH,cAAc,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5E,8DAA8D;IAC9D,SAAS,EAAE,SAAS,eAAe,EAAE,CAAA;IACrC,0EAA0E;IAC1E,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,+EAA+E;IAC/E,KAAK,CAAC,EAAE,SAAS,YAAY,EAAE,CAAA;IAC/B,mDAAmD;IACnD,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB,wEAAwE;IACxE,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,gDAAgD;IAChD,UAAU,CAAC,EAAE,cAAc,CAAA;IAC3B,4EAA4E;IAC5E,YAAY,CAAC,EAAE,gBAAgB,CAAA;IAC/B,mDAAmD;IACnD,aAAa,CAAC,EAAE,iBAAiB,CAAA;IACjC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"views.js","sourceRoot":"","sources":["../../src/store/views.ts"],"names":[],"mappings":"AA8UA,4EAA4E;AAC5E,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAA"}
|
package/lib/store.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory TUI view model. Session events fold into rows here; nothing
|
|
3
|
+
* is written back to the durable log.
|
|
4
|
+
*
|
|
5
|
+
* Implementation lives in the store/ domain modules; this file is the
|
|
6
|
+
* public barrel — import from here, never from store/* internals.
|
|
7
|
+
* @module @dsh-cc/tui/store
|
|
8
|
+
*/
|
|
9
|
+
export type { ApprovalPreview, ApprovalView, CatalogEntryView, EffortPickerView, HudView, ModelPickerView, PermissionPickerEntryView, PermissionPickerView, ProviderPanelView, QuestionOptionView, QuestionView, SessionEntryView, SessionSwitcherView, SubagentRunView, TodoItemView, TodoPanelView, TranscriptRow, TuiState, UsageBreakdownView, UsagePanelView, UsageTotalsView, UsageView, WorktreeExitView, } from './store/views.ts';
|
|
10
|
+
export { WORKTREE_EXIT_OPTION_COUNT } from './store/views.ts';
|
|
11
|
+
export { clearRows, clearTurn, createInitialState, markExitAttempt, resetTurnStep, setApproval, setBusy, setDraft, setHud, setNotice, setPermissionMode, setSessionTitle, setTurnActive, toggleGlobalCollapse, toggleThinking, upsertRow, } from './store/session.ts';
|
|
12
|
+
export { focusEffortPicker, focusModelPicker, focusPermissionPicker, focusSessionSwitcher, moveEffortPickerFocus, moveModelPickerFocus, movePermissionPickerFocus, moveSessionSwitcherFocus, moveWorktreeExitFocus, setEffortPicker, setModelPicker, setPermissionPicker, setSessionSwitcher, setWorktreeExit, } from './store/pickers.ts';
|
|
13
|
+
export { backspaceQuestionText, focusQuestionOption, moveQuestionFocus, setQuestion, toggleQuestionOption, typeQuestionText, } from './store/question.ts';
|
|
14
|
+
export { clearQueue, dequeue, enqueue, popQueued } from './store/queue.ts';
|
|
15
|
+
export { countRunningSubagents, upsertSubagent } from './store/subagents.ts';
|
|
16
|
+
export { closeTodoPanel, moveTodoPanelFocus, openTodoPanel, setTodoPanel, setTodos, todoSummary, } from './store/todos.ts';
|
|
17
|
+
export { moveCursor, openProviderPanel, setProviderOverlay, } from './store/provider-panel.ts';
|
|
18
|
+
export { closeUsagePanel, openUsagePanel, setUsage } from './store/usage.ts';
|
|
19
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,YAAY,EACV,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,eAAe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eAAe,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA"}
|
package/lib/store.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { WORKTREE_EXIT_OPTION_COUNT } from "./store/views.js";
|
|
2
|
+
export { clearRows, clearTurn, createInitialState, markExitAttempt, resetTurnStep, setApproval, setBusy, setDraft, setHud, setNotice, setPermissionMode, setSessionTitle, setTurnActive, toggleGlobalCollapse, toggleThinking, upsertRow, } from "./store/session.js";
|
|
3
|
+
export { focusEffortPicker, focusModelPicker, focusPermissionPicker, focusSessionSwitcher, moveEffortPickerFocus, moveModelPickerFocus, movePermissionPickerFocus, moveSessionSwitcherFocus, moveWorktreeExitFocus, setEffortPicker, setModelPicker, setPermissionPicker, setSessionSwitcher, setWorktreeExit, } from "./store/pickers.js";
|
|
4
|
+
export { backspaceQuestionText, focusQuestionOption, moveQuestionFocus, setQuestion, toggleQuestionOption, typeQuestionText, } from "./store/question.js";
|
|
5
|
+
export { clearQueue, dequeue, enqueue, popQueued } from "./store/queue.js";
|
|
6
|
+
export { countRunningSubagents, upsertSubagent } from "./store/subagents.js";
|
|
7
|
+
export { closeTodoPanel, moveTodoPanelFocus, openTodoPanel, setTodoPanel, setTodos, todoSummary, } from "./store/todos.js";
|
|
8
|
+
export { moveCursor, openProviderPanel, setProviderOverlay, } from "./store/provider-panel.js";
|
|
9
|
+
export { closeUsagePanel, openUsagePanel, setUsage } from "./store/usage.js";
|
|
10
|
+
//# sourceMappingURL=store.js.map
|
package/lib/store.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EACL,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,WAAW,EACX,OAAO,EACP,QAAQ,EACR,MAAM,EACN,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,SAAS,GACV,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,GAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC1E,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC5E,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,WAAW,GACZ,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-writer terminal lease: raw mode + DEC-mode reset on every exit path.
|
|
3
|
+
* Replaces ad-hoc setRawMode/process.on wiring with a checked handle so a
|
|
4
|
+
* second mount fails loudly instead of double-registering handlers.
|
|
5
|
+
* @module @dsh-cc/tui/terminal/lease
|
|
6
|
+
*/
|
|
7
|
+
export interface TerminalLeaseOptions {
|
|
8
|
+
fullscreen?: boolean;
|
|
9
|
+
onSignal?: (signal: NodeJS.Signals) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface TerminalLease {
|
|
12
|
+
release(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare class TerminalLeaseError extends Error {
|
|
15
|
+
constructor(message: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Active lease, if any. Test-only introspection so a leaked mount is visible.
|
|
19
|
+
*/
|
|
20
|
+
export declare function activeLease(): TerminalLease | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Force-release any held lease. Test isolation helper — never ship in runtime
|
|
23
|
+
* paths. Calls `release()` so listeners come down and stdout is reset.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resetTerminalForTests(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Acquire the terminal: enable raw mode on stdin (when it is a TTY), arm
|
|
28
|
+
* exit/SIGINT/SIGTERM handlers that reset the terminal, and return a handle.
|
|
29
|
+
* A second acquire while a lease is held throws `TerminalLeaseError` —
|
|
30
|
+
* double-mount is a loud bug, not a silent overwrite.
|
|
31
|
+
*/
|
|
32
|
+
export declare function acquireTerminal(options?: TerminalLeaseOptions): TerminalLease;
|
|
33
|
+
//# sourceMappingURL=lease.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lease.d.ts","sourceRoot":"","sources":["../../src/terminal/lease.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,KAAK,IAAI,CAAA;CAC5C;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,IAAI,IAAI,CAAA;CAChB;AAED,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAID;;GAEG;AACH,wBAAgB,WAAW,IAAI,aAAa,GAAG,SAAS,CAEvD;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,aAAa,CA0D7E"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-writer terminal lease: raw mode + DEC-mode reset on every exit path.
|
|
3
|
+
* Replaces ad-hoc setRawMode/process.on wiring with a checked handle so a
|
|
4
|
+
* second mount fails loudly instead of double-registering handlers.
|
|
5
|
+
* @module @dsh-cc/tui/terminal/lease
|
|
6
|
+
*/
|
|
7
|
+
const RESET = [
|
|
8
|
+
'\x1b[?1000l',
|
|
9
|
+
'\x1b[?1002l',
|
|
10
|
+
'\x1b[?1003l',
|
|
11
|
+
'\x1b[?1006l',
|
|
12
|
+
'\x1b[?2004l',
|
|
13
|
+
'\x1b[?25h',
|
|
14
|
+
].join('');
|
|
15
|
+
const EXIT_ALT = '\x1b[?1049l';
|
|
16
|
+
export class TerminalLeaseError extends Error {
|
|
17
|
+
constructor(message) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = 'TerminalLeaseError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
let current;
|
|
23
|
+
/**
|
|
24
|
+
* Active lease, if any. Test-only introspection so a leaked mount is visible.
|
|
25
|
+
*/
|
|
26
|
+
export function activeLease() {
|
|
27
|
+
return current;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Force-release any held lease. Test isolation helper — never ship in runtime
|
|
31
|
+
* paths. Calls `release()` so listeners come down and stdout is reset.
|
|
32
|
+
*/
|
|
33
|
+
export function resetTerminalForTests() {
|
|
34
|
+
current?.release();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Acquire the terminal: enable raw mode on stdin (when it is a TTY), arm
|
|
38
|
+
* exit/SIGINT/SIGTERM handlers that reset the terminal, and return a handle.
|
|
39
|
+
* A second acquire while a lease is held throws `TerminalLeaseError` —
|
|
40
|
+
* double-mount is a loud bug, not a silent overwrite.
|
|
41
|
+
*/
|
|
42
|
+
export function acquireTerminal(options) {
|
|
43
|
+
if (current !== undefined) {
|
|
44
|
+
throw new TerminalLeaseError('terminal lease already held');
|
|
45
|
+
}
|
|
46
|
+
const fullscreen = options?.fullscreen === true;
|
|
47
|
+
const onSignal = options?.onSignal;
|
|
48
|
+
const stdin = process.stdin;
|
|
49
|
+
const didSetRaw = typeof stdin.setRawMode === 'function' && stdin.isTTY === true;
|
|
50
|
+
if (didSetRaw) {
|
|
51
|
+
stdin.setRawMode(true);
|
|
52
|
+
}
|
|
53
|
+
const writeReset = () => {
|
|
54
|
+
const payload = fullscreen ? RESET + EXIT_ALT : RESET;
|
|
55
|
+
try {
|
|
56
|
+
process.stdout.write(payload);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Best-effort: a closed fd must not throw out of an exit handler.
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const onExit = () => {
|
|
63
|
+
writeReset();
|
|
64
|
+
};
|
|
65
|
+
const onSignalHandler = (signal) => {
|
|
66
|
+
try {
|
|
67
|
+
onSignal?.(signal);
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
release();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
process.on('exit', onExit);
|
|
74
|
+
process.on('SIGINT', onSignalHandler);
|
|
75
|
+
process.on('SIGTERM', onSignalHandler);
|
|
76
|
+
let released = false;
|
|
77
|
+
function release() {
|
|
78
|
+
if (released)
|
|
79
|
+
return;
|
|
80
|
+
released = true;
|
|
81
|
+
current = undefined;
|
|
82
|
+
writeReset();
|
|
83
|
+
process.off('exit', onExit);
|
|
84
|
+
process.off('SIGINT', onSignalHandler);
|
|
85
|
+
process.off('SIGTERM', onSignalHandler);
|
|
86
|
+
if (didSetRaw) {
|
|
87
|
+
try {
|
|
88
|
+
stdin.setRawMode(false);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Best-effort: a closed fd must not throw.
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const lease = { release };
|
|
96
|
+
current = lease;
|
|
97
|
+
return lease;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=lease.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lease.js","sourceRoot":"","sources":["../../src/terminal/lease.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,KAAK,GAAG;IACZ,aAAa;IACb,aAAa;IACb,aAAa;IACb,aAAa;IACb,aAAa;IACb,WAAW;CACZ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAEV,MAAM,QAAQ,GAAG,aAAa,CAAA;AAW9B,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAA;IAClC,CAAC;CACF;AAED,IAAI,OAAkC,CAAA;AAEtC;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,EAAE,OAAO,EAAE,CAAA;AACpB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,OAA8B;IAC5D,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,kBAAkB,CAAC,6BAA6B,CAAC,CAAA;IAC7D,CAAC;IACD,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,KAAK,IAAI,CAAA;IAC/C,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAA;IAElC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;IAC3B,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC,UAAU,KAAK,UAAU,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,CAAA;IAChF,IAAI,SAAS,EAAE,CAAC;QACd,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IAC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