dsh-code 1.0.2 → 1.0.3

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.
@@ -163,6 +163,8 @@ export interface AppProps {
163
163
  recordHistory(text: string): void;
164
164
  /** Cancel one queued inbox message by identity (Delete on the empty composer). */
165
165
  cancelQueued(messageId: string): void;
166
+ /** Apply the Ctrl+R terminal passthrough to the detected editor (/vscode-keys); resolves to a one-line summary. */
167
+ applyEditorKeys(): Promise<string>;
166
168
  }
167
169
  /** One completion candidate row. */
168
170
  interface CompletionCandidate {
@@ -0,0 +1,105 @@
1
+ /**
2
+ * VS Code-family terminal keybinding repair. VS Code hands Ctrl+R to the
3
+ * workbench (Open Recent) even while an integrated terminal owns focus, so
4
+ * the reasoning-fold key never reaches the TUI. Workspace-scoped keybindings
5
+ * do not exist, so the fix is one user-level keybindings.json rule that
6
+ * forwards the raw Ctrl byte via sendSequence under terminalFocus. This
7
+ * module detects the hosting editor variant, resolves its user
8
+ * keybindings.json, and merges the rule idempotently; pure merge/detect
9
+ * helpers are separated from the fs orchestration so both stay testable.
10
+ * @module @deepseek-ai/dsh-code/editor-keys
11
+ */
12
+ /** Integrated-terminal editor variants this module can repair. */
13
+ export type EditorTerminalFamily = 'vscode' | 'cursor' | 'vscodium' | 'windsurf';
14
+ /**
15
+ * Detect the editor hosting this integrated terminal.
16
+ * @param env - process environment (TERM_PROGRAM decides; case/whitespace tolerant).
17
+ * @returns the family, or undefined outside VS Code-family terminals.
18
+ */
19
+ export declare function detectEditorTerminalFamily(env?: NodeJS.ProcessEnv): EditorTerminalFamily | undefined;
20
+ /**
21
+ * Whether the pty is hosted away from the editor UI (ssh/container/tunnel).
22
+ * Keybindings live on the client machine, so a remote session must never
23
+ * write them server-side.
24
+ */
25
+ export declare function isRemoteTerminalEnv(env?: NodeJS.ProcessEnv): boolean;
26
+ /** Filesystem anchors used to resolve editor config paths (injectable for tests). */
27
+ export interface EditorPathContext {
28
+ /** User home directory. */
29
+ homedir: string;
30
+ /** %APPDATA% on Windows; only read for win32 resolution. */
31
+ appdata?: string;
32
+ /** Node platform qualifier. */
33
+ platform: NodeJS.Platform;
34
+ }
35
+ /**
36
+ * Resolve the user keybindings.json candidates for one family, most likely
37
+ * install first. Only paths that exist on disk are repaired.
38
+ */
39
+ export declare function editorKeybindingCandidates(family: EditorTerminalFamily, context: EditorPathContext): readonly string[];
40
+ /** The one workbench rule that hands Ctrl+R to the focused terminal. */
41
+ export declare const CTRL_R_PASSTHROUGH_RULE: {
42
+ readonly key: "ctrl+r";
43
+ readonly command: "workbench.action.terminal.sendSequence";
44
+ readonly args: {
45
+ readonly text: "\u0012";
46
+ };
47
+ readonly when: "terminalFocus";
48
+ };
49
+ /**
50
+ * Remove // and block comments from one JSONC document. Double-quoted strings
51
+ * survive untouched, so comment markers inside string values are preserved.
52
+ */
53
+ export declare function stripJsoncComments(text: string): string;
54
+ /** Parse one JSONC document; trailing commas are tolerated. */
55
+ export declare function parseJsonc(text: string): unknown;
56
+ /** Outcome of merging the passthrough rule into one keybindings document. */
57
+ export type KeybindingsMerge = {
58
+ readonly status: 'present';
59
+ } | {
60
+ readonly status: 'updated';
61
+ readonly text: string;
62
+ } | {
63
+ readonly status: 'created';
64
+ readonly text: string;
65
+ };
66
+ /**
67
+ * Merge the Ctrl+R passthrough into one keybindings.json document. The raw
68
+ * text is preserved verbatim (comments included); the rule is inserted right
69
+ * after the array opener so it cannot be shadowed by later conflicting user
70
+ * rules. Missing files resolve to a fresh template.
71
+ * @throws when the document does not carry a rule array.
72
+ */
73
+ export declare function mergeCtrlRPassthrough(raw: string | undefined): KeybindingsMerge;
74
+ /** User-level marker file content: the startup hint fires at most once per install. */
75
+ export interface EditorKeysFlag {
76
+ hintShownAt?: string;
77
+ }
78
+ /** Parse one flag file snapshot; missing or corrupt content degrades to unshown. */
79
+ export declare function parseEditorKeysFlag(raw: string | undefined): EditorKeysFlag;
80
+ /** Persist the shown marker; best-effort, the hint is cosmetic and never a gate. */
81
+ export declare function markEditorKeysHintShown(path: string): Promise<void>;
82
+ /** Inputs shared by the apply and startup-hint flows. */
83
+ export interface EditorKeysEnv {
84
+ /** Process environment (TERM_PROGRAM / VSCODE_IPC_HOOK_CLI). */
85
+ env: NodeJS.ProcessEnv;
86
+ /** Filesystem anchors for editor config resolution. */
87
+ paths: EditorPathContext;
88
+ /** Absolute path of the one-shot hint marker under the DSH home. */
89
+ flagPath: string;
90
+ }
91
+ /**
92
+ * Apply the Ctrl+R passthrough to every local keybindings.json of the hosting
93
+ * editor and mark the startup hint shown. Existing files get a .dsh-bak
94
+ * backup before the first write.
95
+ * @returns a one-line user-facing summary.
96
+ * @throws with an actionable message when the environment cannot be repaired.
97
+ */
98
+ export declare function applyCtrlRPassthrough({ env, paths, flagPath }: EditorKeysEnv): Promise<string>;
99
+ /**
100
+ * Resolve the one-shot startup hint for VS Code-family terminals. Fires at
101
+ * most once per install (flag file), never when the passthrough rule is
102
+ * already present, and never in remote ptys where the repair cannot run.
103
+ * @returns the hint line, or undefined to stay silent.
104
+ */
105
+ export declare function resolveEditorKeysStartupHint({ env, paths, flagPath }: EditorKeysEnv): Promise<string | undefined>;
@@ -17,7 +17,11 @@ export interface GitDiffView {
17
17
  export declare function parseGitDiffFiles(text: string): readonly GitDiffFile[];
18
18
  /** Parse the intentionally small, option-safe /diff argument vocabulary. */
19
19
  export declare function parseGitDiffSpec(argument: string): GitDiffSpec;
20
- /** Load one complete textual diff without invoking external diff drivers. */
21
- export declare function loadGitDiff(cwd: string, argument: string): Promise<GitDiffView>;
20
+ /**
21
+ * Load one complete textual diff without invoking external diff drivers.
22
+ * @param signal - aborted by the caller on session switches/quit, killing the
23
+ * git subprocess instead of letting a stale repository's diff land later.
24
+ */
25
+ export declare function loadGitDiff(cwd: string, argument: string, signal?: AbortSignal): Promise<GitDiffView>;
22
26
  /** Review prompt capped before it reaches a provider context window. */
23
27
  export declare function buildReviewPrompt(diff: string, label: string, maxChars?: number): string;
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Same-id reasoning-capability inheritance for hand-declared pi-ai routes:
3
+ * the model catalog inherits capabilities by route key, not by model id, so a
4
+ * relay route listing `gpt-5.5` reads nothing from the installed `openai`
5
+ * catalog entry and materializes as `reasoning: false` until its settings
6
+ * entry declares `reasoningEfforts`. This adapter closes that gap without
7
+ * touching upstream: whenever a pi-ai profile's model entry carries no
8
+ * declaration and its live row advertises no efforts, but the same model id
9
+ * is declared (in a sibling settings entry) or advertised (on another route)
10
+ * elsewhere, the declaration is materialized into settings — verbatim from a
11
+ * sibling declaration when one exists, otherwise as an identity level map
12
+ * (`off` maps to null, every other level to its own name), which is the
13
+ * correct wire spelling for OpenAI-compatible relays. Writes ride the same
14
+ * `settings.mutate` path as the provider panel, so the upstream
15
+ * `assertServiceable` gate still rejects anything invalid atomically.
16
+ *
17
+ * @module @deepseek-ai/dsh-tui/model-capabilities
18
+ */
19
+ import type { Context } from '@deepseek-ai/cordis';
20
+ import { type ModelRow } from './models.ts';
21
+ /** A notice sink structurally compatible with the app bridge's `notify`. */
22
+ export type CapabilityNotice = (text: string, tone?: 'info' | 'warning' | 'error') => void;
23
+ /** One pi-ai provider profile as stored in settings, addressed for mutation. */
24
+ export interface CapabilityProfileSource {
25
+ /** Settings namespace owning the profile (`llm-pi-ai`). */
26
+ readonly settingsNs: string;
27
+ /** Path from the section root to this provider's profile. */
28
+ readonly settingsPath: readonly string[];
29
+ /** Revision of the owning section at read time. */
30
+ readonly revision: number;
31
+ /** Raw model entries, exactly as stored (declaration fields included). */
32
+ readonly models: readonly Record<string, unknown>[];
33
+ }
34
+ /** One planned per-provider models rewrite. */
35
+ export interface CapabilitySyncPlan {
36
+ /** Provider route the plan targets. */
37
+ readonly provider: string;
38
+ /** Settings namespace owning the profile. */
39
+ readonly settingsNs: string;
40
+ /** Path from the section root to the provider profile. */
41
+ readonly settingsPath: readonly string[];
42
+ /** Raw model entries, exactly as stored (declaration fields included). */
43
+ readonly models: readonly Record<string, unknown>[];
44
+ /** Fingerprint of the source models array this plan was derived from. */
45
+ readonly sourceFingerprint: string;
46
+ /** Document revision of the owning section when the plan was derived. */
47
+ readonly sourceRevision: number;
48
+ /** Model ids that gained a declaration, notice-facing. */
49
+ readonly inherited: readonly string[];
50
+ /** `provider/model` labels the declarations came from, notice-facing. */
51
+ readonly sources: readonly string[];
52
+ }
53
+ /**
54
+ * Plan the reasoning declarations to materialize. A model entry inherits
55
+ * when it declares nothing (`reasoningEfforts` absent — a dict or `false` is
56
+ * an explicit choice and is never touched) and its live row advertises no
57
+ * efforts; the donor is the first sibling settings declaration for the same
58
+ * id, copied verbatim so dialect wire spellings survive, otherwise the first
59
+ * other-route row advertising efforts for that id, mapped by identity.
60
+ * Entries never lose fields and keep their key order; a provider appears in
61
+ * the result only when at least one entry changes.
62
+ * @param input - the live model rows and the raw pi-ai profiles from settings.
63
+ * @returns one plan per provider with at least one inheritance.
64
+ */
65
+ export declare function planCapabilitySync(input: {
66
+ readonly rows: readonly ModelRow[];
67
+ readonly profiles: ReadonlyMap<string, CapabilityProfileSource>;
68
+ }): readonly CapabilitySyncPlan[];
69
+ /**
70
+ * Materialize same-id reasoning declarations once per provider. Reads the
71
+ * configurable directory, the redacted settings document, and the live model
72
+ * rows; plans; then writes each provider's merged models array through
73
+ * `settings.mutate` under a fresh revision (writes bump the section
74
+ * revision, so per-plan revisions are re-read). Every failure converges to a
75
+ * single-line notice — the caller's promise never rejects and the session
76
+ * keeps running on the previous configuration.
77
+ * @param ctx - context carrying the `llm` and `settings` services (optional).
78
+ * @param notify - the app bridge's notice sink, when one is live.
79
+ */
80
+ export declare function syncModelCapabilities(ctx: Context, notify?: CapabilityNotice): Promise<void>;
81
+ /** Test seam: forget the applied-write fingerprints. */
82
+ export declare function resetCapabilitySyncState(): void;
@@ -48,6 +48,13 @@ export interface ProviderModelSettings {
48
48
  readonly name?: string;
49
49
  readonly contextWindow?: number;
50
50
  readonly maxTokens?: number;
51
+ /**
52
+ * Remaining entry fields the editor does not model (`reasoningEfforts`,
53
+ * `compat`, `input`, …), carried verbatim so a save preserves them.
54
+ * Populated by {@link loadProviderSettings}; never contains the four
55
+ * modelled keys.
56
+ */
57
+ readonly extras?: Readonly<Record<string, unknown>>;
51
58
  }
52
59
  /** The small, portable subset of a provider profile the terminal edits. */
53
60
  export interface ProviderConfiguration {
@@ -39,3 +39,28 @@ export declare function reasoningLines(text: string, columns: number): readonly
39
39
  export declare function transcriptEntryLines(entry: TranscriptEntry, columns: number, showReasoning?: boolean, reasoningToggleHint?: boolean, showToolDetails?: boolean): readonly StyledLine[];
40
40
  /** Settled-history variant carrying the Ctrl+R reasoning fold. */
41
41
  export declare function settledEntryLines(entry: TranscriptEntry, columns: number, showReasoning: boolean): readonly StyledLine[];
42
+ /** The flexible rows of the live region; chrome (composer/notice/status) is never reduced. */
43
+ export interface LiveAllocation {
44
+ /** Settled tail rows currently rendered in the live tree. */
45
+ readonly live: number;
46
+ /** Rows reserved for the streaming reasoning tail or its marker. */
47
+ readonly reasoning: number;
48
+ /** Rows reserved for the streaming answer tail. */
49
+ readonly answer: number;
50
+ }
51
+ /** A clamped allocation plus the invariant-trip warning that triggered it. */
52
+ export interface LiveAllocationAudit {
53
+ readonly allocation: LiveAllocation;
54
+ readonly warning?: string;
55
+ }
56
+ /**
57
+ * Clamp the live-region allocation so the flexible dynamic rows never exceed
58
+ * the post-chrome budget. By construction the caller derives these rows from
59
+ * the same budget; this is the runtime tripwire for a future edit that breaks
60
+ * that derivation. Reduction order: answer first (the freshest content is the
61
+ * live tail), then reasoning, then settled live rows; nothing goes negative.
62
+ * @param allocation - the intended row allocation.
63
+ * @param dynamicRows - the post-chrome row budget.
64
+ * @returns the clamped allocation and a warning string when clamping fired.
65
+ */
66
+ export declare function clampLiveAllocation(allocation: LiveAllocation, dynamicRows: number): LiveAllocationAudit;
@@ -21,7 +21,7 @@ export interface MdSegment {
21
21
  export interface MdLine {
22
22
  segments: readonly MdSegment[];
23
23
  }
24
- /** Visible width of a run in columns (CJK counts double). */
24
+ /** Visible width of a run in columns (grapheme-cluster and emoji aware). */
25
25
  export declare function visibleColumns(text: string): number;
26
26
  /** Render markdown text into styled lines of at most `width` columns. */
27
27
  export declare function renderMarkdown(text: string, width: number, options?: {
@@ -357,8 +357,11 @@ export declare function createReplayAccumulator(): ReplayAccumulator;
357
357
  * to a sequential fold; only the `entries` container operations are mutable.
358
358
  *
359
359
  * @internal Test-instrumentation path; `projectEvents` is the public entry.
360
+ * @returns whether the event changed the accumulated state — the live store
361
+ * stays silent and keeps its snapshot identity for ignored events, exactly
362
+ * like the copy-on-write reducer returning its input view unchanged.
360
363
  */
361
- export declare function replayProjectEvent(acc: ReplayAccumulator, event: SessionEvent): void;
364
+ export declare function replayProjectEvent(acc: ReplayAccumulator, event: SessionEvent): boolean;
362
365
  /**
363
366
  * Materialize the accumulated fold as a `TranscriptView`, compacting any
364
367
  * retired tombstones. The anchors maps are handed through as-is (their
@@ -367,6 +370,17 @@ export declare function replayProjectEvent(acc: ReplayAccumulator, event: Sessio
367
370
  * @internal Test-instrumentation path; `projectEvents` is the public entry.
368
371
  */
369
372
  export declare function finishReplay(acc: ReplayAccumulator): TranscriptView;
373
+ /**
374
+ * Materialize the accumulated fold as a fresh immutable snapshot for the
375
+ * live store. Unlike {@link finishReplay} — the one-shot replay entry, which
376
+ * hands the accumulator's own arrays through because the accumulator is
377
+ * discarded — every array a renderer can hold is copied here, so later
378
+ * folds never mutate a snapshot already handed out. Same fields, same
379
+ * tombstone compaction.
380
+ *
381
+ * @internal Live-store path; `projectEvents` is the public entry.
382
+ */
383
+ export declare function snapshotReplayView(acc: ReplayAccumulator): TranscriptView;
370
384
  /**
371
385
  * Fold a replayed event history into one view.
372
386
  *
@@ -25,8 +25,8 @@ export declare function singleLineText(text: string): string;
25
25
  /**
26
26
  * Truncate one display-safe row without ever exceeding its physical-column
27
27
  * budget. The ellipsis is included inside the budget, matching Codex's popup
28
- * truncation contract; the previous app-local helper appended it after the
29
- * row was already full and could force an extra terminal wrap.
28
+ * truncation contract; the cut walks grapheme clusters so emoji and
29
+ * combining sequences never split mid-cluster.
30
30
  */
31
31
  export declare function truncateColumns(text: string, columns: number): string;
32
32
  /** A display-safe suffix bounded by terminal rows and columns. */
@@ -37,13 +37,19 @@ export interface DisplayTail {
37
37
  truncated: boolean;
38
38
  }
39
39
  /**
40
- * Keep only the newest display-safe text that fits a terminal rectangle.
41
- * The scan walks backward and stops as soon as the suffix is full, so a long
42
- * reasoning stream does not rescan its entire accumulated prefix per chunk.
43
- * Explicit newlines and terminal wrapping both consume rows; tabs expand to
44
- * two spaces so terminal tab stops (which render at contextual column 8
45
- * boundaries, not at the budgeted cell count) cannot inflate the physical
46
- * row count of the live region.
40
+ * Keep the newest display-safe text that fits a terminal rectangle, wrapping
41
+ * FORWARD from the start of the text and slicing the tail rows.
42
+ *
43
+ * Forward wrapping is what keeps a streaming tail calm: rows already produced
44
+ * never re-wrap as tokens append (a backward scan recomputes every wrap point
45
+ * per chunk and the whole visible block jumps), and the wrap rules match the
46
+ * settled text's renderer so the flush at turn end does not reflow the block
47
+ * a second time. CJK kinsoku applies at both edges: closing punctuation
48
+ * overhangs up to two cells onto the filled row instead of starting the next
49
+ * one (within the caret column the caller reserves), and opening punctuation
50
+ * moves down instead of dangling at a row end. Tabs expand to two spaces so
51
+ * terminal tab stops cannot inflate the physical row count; clusters carry
52
+ * emoji presentation and combining marks whole.
47
53
  * @param text - raw externally sourced text.
48
54
  * @param columns - available terminal columns.
49
55
  * @param rows - available terminal rows.
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Precise terminal-cell width measurement — the single authority every
3
+ * budget, wrap, and truncation path shares. The previous heuristic
4
+ * (`codePoint > 0x2e7f ? 2 : 1)) mis-sized Hangul Jamo (narrow), high
5
+ * non-CJK code points (wide), and emoji: text-default glyphs like ✳ ⚠ ❤
6
+ * counted 2 while terminals draw 1, and VS16 sequences counted 1 while
7
+ * terminals draw 2 — the exact drift class the community dsh-TUI string
8
+ * engine documents (a spinner glyph drifting one column per frame). This
9
+ * module adapts that engine's rules without its Ink-fork renderer: an ASCII
10
+ * fast path, grapheme-cluster iteration via Intl.Segmenter (code-point
11
+ * fallback), a merged East-Asian-Wide/Fullwidth + Emoji_Presentation range
12
+ * table, text-default emoji = 1, VS16 = 2, marks/selectors/ZWJ = 0.
13
+ * @module @deepseek-ai/dsh-code/render/width
14
+ */
15
+ /** Split text into grapheme clusters (code points when Segmenter is absent). */
16
+ export declare function splitGraphemes(text: string): string[];
17
+ /** Terminal-cell width of one grapheme cluster. */
18
+ export declare function graphemeWidth(cluster: string): number;
19
+ /** Terminal-cell width of one code point (surrogate pairs must stay paired). */
20
+ export declare function codePointWidth(char: string): number;
21
+ /**
22
+ * Terminal-cell width of a string: an ASCII fast path avoids the segmenter
23
+ * for the overwhelmingly common case; everything else sums grapheme clusters.
24
+ * Control characters occupy no cells (display sanitization makes them
25
+ * visible escapes before they ever reach a budget).
26
+ * @param text - display-safe or raw text to measure.
27
+ * @returns the column count the terminal will draw.
28
+ */
29
+ export declare function stringWidth(text: string): number;
@@ -102,6 +102,33 @@ export declare function sessionArtifactDirectory(artifact: string, id: string):
102
102
  * @returns the ids to delete, root first.
103
103
  */
104
104
  export declare function collectDeletionSubtree(records: readonly SessionRecord[], id: string): string[];
105
+ /** One validated node of a deletion plan. */
106
+ export interface DeletionPlanNode {
107
+ /** Session id to remove. */
108
+ readonly id: string;
109
+ /** Distance from the deletion root (0 for the root itself). */
110
+ readonly depth: number;
111
+ }
112
+ /** A fully preflighted subtree deletion, or the refusal that produced none. */
113
+ export type SessionDeletionPlan = {
114
+ readonly ok: true;
115
+ readonly nodes: readonly DeletionPlanNode[];
116
+ } | {
117
+ readonly ok: false;
118
+ readonly reason: string;
119
+ };
120
+ /**
121
+ * Plan one session-subtree deletion with NO filesystem side effects: collect
122
+ * the doomed lineage, refuse when the root or ANY member is live (a live
123
+ * child would outlive its deleted parent) or missing from the listing, and
124
+ * order the result children-first so the executor can never leave a deleted
125
+ * parent behind surviving children. Artifact-location guards stay at the
126
+ * call site; this is the pure preflight they complete.
127
+ * @param records - the full directory listing.
128
+ * @param id - the root session id to delete.
129
+ * @returns the ordered plan, or a user-facing refusal reason.
130
+ */
131
+ export declare function planSessionDeletion(records: readonly SessionRecord[], id: string): SessionDeletionPlan;
105
132
  /**
106
133
  * Codex-style relative time for session rows ("now", "5m ago", "3h ago",
107
134
  * "2d ago"; older than a week falls back to the local date).
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Serialized, crash-atomic persistence for the small user-level JSON files
3
+ * under the DSH home (statusline.json, theme.json). Two guarantees the bare
4
+ * floating `writeFile` path could not give:
5
+ *
6
+ * 1. Every save is appended to ONE chain, so rapid consecutive edits land
7
+ * in submission order and the last snapshot is the one on disk (parallel
8
+ * floating writes let an older snapshot finish last and win).
9
+ * 2. Each write goes to a sibling temp file first and is renamed into
10
+ * place, so a crash mid-write can never leave a half-written JSON
11
+ * document behind.
12
+ *
13
+ * The chain itself never rejects: a failed write is reported to that
14
+ * save's caller while later saves keep their turn.
15
+ *
16
+ * @module @deepseek-ai/dsh-code/settings-file
17
+ */
18
+ /** The serialized persistence surface; flush() is handed to the quit sequence. */
19
+ export interface UserSettingsPersistence {
20
+ /**
21
+ * Queue one file snapshot. Resolves when the chain reaches (and renames)
22
+ * it; rejects only to THIS caller when its own write failed.
23
+ */
24
+ save(path: string, text: string): Promise<void>;
25
+ /** Wait for every queued write; safe to call repeatedly. */
26
+ flush(): Promise<void>;
27
+ }
28
+ /**
29
+ * Create the shared settings-write chain. One instance per process keeps
30
+ * every user-level JSON file mutually serialized.
31
+ * @returns the persistence handle.
32
+ */
33
+ export declare function createUserSettingsPersistence(): UserSettingsPersistence;
@@ -3,6 +3,16 @@
3
3
  * and notifies subscribers. The renderer subscribes through
4
4
  * `useSyncExternalStore`; the runner owns event feeding.
5
5
  *
6
+ * Folding runs on the same mutable replay accumulator the persisted-log
7
+ * path uses (`replayProjectEvent`: id-indexed row updates, in-place
8
+ * appends), so a live structural event costs O(1) entry work regardless of
9
+ * transcript length — the copy-on-write fold rebuilt the whole entries
10
+ * array per event, making a growing session quadratic. An immutable
11
+ * `TranscriptView` snapshot is materialized only when a changed view is
12
+ * READ (once per rendered frame under the notification throttle, never per
13
+ * event), and every snapshot copies its arrays, so a view already handed
14
+ * out never observes later folds.
15
+ *
6
16
  * Notification coalescing: the fold stays synchronous — `getView()` always
7
17
  * returns the latest state the moment `apply` returns — but listener
8
18
  * notification is frame-throttled (~16ms) and deduplicated. The zai/GLM
@@ -7,8 +7,13 @@
7
7
  *
8
8
  * This is NOT a second transcript: each child folds to ONE row (label,
9
9
  * running state, bounded last-activity text), capped at
10
- * {@link MAX_SUBAGENT_ROWS}. Rows are advisory display state, rebuilt from
11
- * live events; nothing here persists or replays. Notification is coalesced
10
+ * {@link MAX_SUBAGENT_ROWS}. The cap is a display budget, not a fan-out
11
+ * limit: a new running child evicts the OLDEST settled row when one
12
+ * exists, and while every row is busy the newcomer waits off-screen — but
13
+ * the observed-session total (getTotalSeen) keeps counting, so status
14
+ * totals never under-report the fan-out. Rows are advisory display
15
+ * state, rebuilt from live events; nothing here persists or replays.
16
+ * Notification is coalesced
12
17
  * by the same ~16ms frame throttle as the transcript store (per-burst
13
18
  * microtask notify chained SyncLane rerenders past React's nested update
14
19
  * limit; a bare macrotask merge repaints a whole turn's bursts at once).
@@ -16,7 +21,7 @@
16
21
  * @module @deepseek-ai/dsh-code/subagents
17
22
  */
18
23
  import type { SessionEvent } from '@deepseek-ai/dsh-session';
19
- /** Hard row cap: a fan-out larger than this stays summarized by the head. */
24
+ /** Hard row cap: overflow evicts the oldest settled row; a fully busy feed waits. */
20
25
  export declare const MAX_SUBAGENT_ROWS = 8;
21
26
  /** One live subagent row in the feed. */
22
27
  export interface SubagentRow {
@@ -37,6 +42,11 @@ export interface SubagentFeedView {
37
42
  subscribe(listener: () => void): () => void;
38
43
  /** Read the current rows (identity-stable between changes). */
39
44
  getSnapshot(): readonly SubagentRow[];
45
+ /**
46
+ * Distinct child sessions observed since the last reset. The row cap is
47
+ * a display budget, not a count of the fan-out; totals surface this.
48
+ */
49
+ getTotalSeen(): number;
40
50
  }
41
51
  /**
42
52
  * Fold one child-session event into its feed row (pure).