@linxiraos/pi-tui 1.4.11 → 1.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/CHANGELOG.md +33 -240
  2. package/README.md +4 -1
  3. package/THIRD-PARTY-NOTICES.txt +4 -5
  4. package/dist/types/apps/shell-visualizer.d.ts +24 -0
  5. package/dist/types/autocomplete.d.ts +20 -0
  6. package/dist/types/chat/cache-invalidation-marker.d.ts +15 -7
  7. package/dist/types/chat/chat-transcript-builder.d.ts +5 -3
  8. package/dist/types/chat/display-preferences.d.ts +2 -0
  9. package/dist/types/chat/extension-types.d.ts +72 -1
  10. package/dist/types/chat/image-loading.d.ts +2 -2
  11. package/dist/types/chat/messages.d.ts +2 -3
  12. package/dist/types/chat/read-tool-group.d.ts +15 -2
  13. package/dist/types/chat/skill-message.d.ts +1 -0
  14. package/dist/types/chat/spotlight.d.ts +203 -0
  15. package/dist/types/chat/tool-execution.d.ts +26 -5
  16. package/dist/types/chat/transcript-actions.d.ts +11 -0
  17. package/dist/types/chat/transcript-browser.d.ts +9 -0
  18. package/dist/types/chat/transcript-presentation.d.ts +164 -0
  19. package/dist/types/chat/ttsr-notification.d.ts +2 -0
  20. package/dist/types/chrome/message-frame.d.ts +2 -0
  21. package/dist/types/chrome/transcript-container.d.ts +27 -6
  22. package/dist/types/components/loader.d.ts +0 -2
  23. package/dist/types/components/markdown.d.ts +11 -1
  24. package/dist/types/components/settings-list.d.ts +12 -2
  25. package/dist/types/frame-rate.d.ts +18 -0
  26. package/dist/types/index.d.ts +3 -0
  27. package/dist/types/keybinding-matchers.d.ts +4 -1
  28. package/dist/types/kitty-graphics.d.ts +1 -1
  29. package/dist/types/motion-effects.d.ts +10 -0
  30. package/dist/types/native/encode.d.ts +2 -0
  31. package/dist/types/native/measure.d.ts +10 -0
  32. package/dist/types/native/overlay.d.ts +1 -1
  33. package/dist/types/native/quiet.d.ts +5 -0
  34. package/dist/types/native/reconcile.d.ts +6 -1
  35. package/dist/types/native/spans.d.ts +6 -0
  36. package/dist/types/native/state.d.ts +4 -0
  37. package/dist/types/overlays/agent-hub.d.ts +6 -0
  38. package/dist/types/overlays/link-browser.d.ts +55 -0
  39. package/dist/types/overlays/running-subagent-badge.d.ts +1 -4
  40. package/dist/types/overlays/spotlight-sheet.d.ts +36 -0
  41. package/dist/types/prompt/composer-attachments.d.ts +5 -2
  42. package/dist/types/prompt/composer-cache.d.ts +7 -2
  43. package/dist/types/prompt/composer.d.ts +6 -11
  44. package/dist/types/prompt/custom-editor.d.ts +8 -2
  45. package/dist/types/prompt/gradient-highlight.d.ts +2 -2
  46. package/dist/types/prompt/magic-keywords.d.ts +2 -0
  47. package/dist/types/prompt/model-mention-autocomplete.d.ts +9 -7
  48. package/dist/types/prompt/model-mention-syntax.d.ts +6 -0
  49. package/dist/types/prompt/prompt-action-autocomplete.d.ts +2 -1
  50. package/dist/types/prompt/welcome.d.ts +19 -0
  51. package/dist/types/render/extension-links.d.ts +0 -6
  52. package/dist/types/render/index.d.ts +1 -0
  53. package/dist/types/render/link-hints.d.ts +78 -0
  54. package/dist/types/render/render-utils.d.ts +0 -2
  55. package/dist/types/setup/scenes/types.d.ts +8 -0
  56. package/dist/types/setup/scenes/updates.d.ts +6 -0
  57. package/dist/types/setup/wizard.d.ts +7 -2
  58. package/dist/types/spinner-clock.d.ts +34 -0
  59. package/dist/types/status-line/component.d.ts +8 -4
  60. package/dist/types/status-line/host.d.ts +62 -0
  61. package/dist/types/status-line/index.d.ts +1 -0
  62. package/dist/types/status-line/prompt-cache.d.ts +14 -0
  63. package/dist/types/status-line/schema.d.ts +1 -1
  64. package/dist/types/status-line/startup.d.ts +6 -0
  65. package/dist/types/status-line/types.d.ts +8 -21
  66. package/dist/types/theme/schema.d.ts +28 -1
  67. package/dist/types/theme/symbols.d.ts +1 -1
  68. package/dist/types/theme/theme-class.d.ts +12 -2
  69. package/dist/types/theme/theme.d.ts +1 -1
  70. package/dist/types/theme/tui-adapters.d.ts +7 -0
  71. package/dist/types/thinking.d.ts +12 -0
  72. package/dist/types/tools/ask.d.ts +1 -1
  73. package/dist/types/tools/bash.d.ts +21 -0
  74. package/dist/types/tools/find.d.ts +9 -1
  75. package/dist/types/tools/grep.d.ts +2 -1
  76. package/dist/types/tools/grouped-file-output.d.ts +17 -0
  77. package/dist/types/tools/job-widget.d.ts +2 -2
  78. package/dist/types/tools/lsp.d.ts +4 -2
  79. package/dist/types/tools/native-view.d.ts +4 -0
  80. package/dist/types/tools/renderer.d.ts +9 -1
  81. package/dist/types/tools/shell-trace.d.ts +10 -0
  82. package/dist/types/tools/shell-viz-render.d.ts +6 -0
  83. package/dist/types/tools/shell-viz.d.ts +16 -0
  84. package/dist/types/tools/wait.d.ts +2 -2
  85. package/dist/types/tools/web-search-types.d.ts +1 -0
  86. package/dist/types/tools/write.d.ts +2 -0
  87. package/dist/types/tui.d.ts +15 -1
  88. package/package.json +15 -11
  89. package/src/apps/shell-visualizer.d.ts +24 -0
  90. package/src/apps/shell-visualizer.ts +167 -0
  91. package/src/autocomplete.d.ts +20 -0
  92. package/src/autocomplete.ts +14 -0
  93. package/src/chat/assistant-message.ts +11 -6
  94. package/src/chat/cache-invalidation-marker.d.ts +15 -7
  95. package/src/chat/cache-invalidation-marker.ts +18 -9
  96. package/src/chat/chat-transcript-builder.d.ts +5 -3
  97. package/src/chat/chat-transcript-builder.ts +16 -12
  98. package/src/chat/display-preferences.d.ts +2 -0
  99. package/src/chat/display-preferences.ts +3 -0
  100. package/src/chat/extension-types.d.ts +72 -1
  101. package/src/chat/extension-types.ts +74 -1
  102. package/src/chat/image-loading.d.ts +2 -2
  103. package/src/chat/image-loading.ts +2 -2
  104. package/src/chat/messages.d.ts +2 -3
  105. package/src/chat/messages.ts +3 -8
  106. package/src/chat/read-tool-group.d.ts +15 -2
  107. package/src/chat/read-tool-group.ts +201 -41
  108. package/src/chat/skill-message.d.ts +1 -0
  109. package/src/chat/skill-message.ts +4 -0
  110. package/src/chat/spotlight.d.ts +203 -0
  111. package/src/chat/spotlight.ts +460 -0
  112. package/src/chat/tool-execution.d.ts +26 -5
  113. package/src/chat/tool-execution.ts +360 -38
  114. package/src/chat/transcript-actions.d.ts +11 -0
  115. package/src/chat/transcript-actions.ts +13 -1
  116. package/src/chat/transcript-browser.d.ts +9 -0
  117. package/src/chat/transcript-browser.ts +18 -0
  118. package/src/chat/transcript-presentation.d.ts +164 -0
  119. package/src/chat/transcript-presentation.ts +642 -0
  120. package/src/chat/ttsr-notification.d.ts +25 -0
  121. package/src/chat/ttsr-notification.ts +5 -0
  122. package/src/chrome/message-frame.d.ts +2 -0
  123. package/src/chrome/message-frame.ts +7 -0
  124. package/src/chrome/message-notice.d.ts +58 -0
  125. package/src/chrome/transcript-container.d.ts +27 -6
  126. package/src/chrome/transcript-container.ts +317 -66
  127. package/src/components/editor.ts +25 -1
  128. package/src/components/loader.d.ts +0 -2
  129. package/src/components/loader.ts +30 -18
  130. package/src/components/markdown.d.ts +11 -1
  131. package/src/components/markdown.ts +41 -16
  132. package/src/components/settings-list.d.ts +12 -2
  133. package/src/components/settings-list.ts +29 -13
  134. package/src/frame-rate.d.ts +18 -0
  135. package/src/frame-rate.ts +36 -0
  136. package/src/hotkeys-markdown.ts +4 -1
  137. package/src/index.d.ts +3 -0
  138. package/src/index.ts +3 -0
  139. package/src/keybinding-matchers.d.ts +4 -1
  140. package/src/keybinding-matchers.ts +13 -12
  141. package/src/kitty-graphics.d.ts +1 -1
  142. package/src/kitty-graphics.ts +3 -2
  143. package/src/motion-effects.d.ts +10 -0
  144. package/src/motion-effects.ts +27 -0
  145. package/src/native/backend.ts +66 -7
  146. package/src/native/encode.d.ts +2 -0
  147. package/src/native/encode.ts +2 -0
  148. package/src/native/measure.d.ts +10 -0
  149. package/src/native/measure.ts +185 -0
  150. package/src/native/overlay.d.ts +1 -1
  151. package/src/native/overlay.ts +1 -1
  152. package/src/native/quiet.d.ts +5 -0
  153. package/src/native/quiet.ts +105 -0
  154. package/src/native/reconcile.d.ts +6 -1
  155. package/src/native/reconcile.ts +16 -10
  156. package/src/native/spans.d.ts +6 -0
  157. package/src/native/spans.ts +40 -0
  158. package/src/native/state.d.ts +4 -0
  159. package/src/native/state.ts +18 -0
  160. package/src/overlays/agent-hub.ts +15 -2
  161. package/src/overlays/ask-dialog.ts +1 -0
  162. package/src/overlays/btw-history-panel.ts +73 -6
  163. package/src/overlays/link-browser.ts +295 -0
  164. package/src/overlays/running-subagent-badge.ts +2 -9
  165. package/src/overlays/settings-defs.ts +1 -1
  166. package/src/overlays/settings-selector.ts +17 -3
  167. package/src/overlays/spotlight-sheet.ts +478 -0
  168. package/src/overlays/usage-dashboard.ts +6 -5
  169. package/src/prompt/composer-attachments.d.ts +5 -2
  170. package/src/prompt/composer-attachments.ts +6 -6
  171. package/src/prompt/composer-cache.ts +17 -16
  172. package/src/prompt/composer.ts +30 -123
  173. package/src/prompt/custom-editor.ts +17 -13
  174. package/src/prompt/gradient-highlight.d.ts +2 -2
  175. package/src/prompt/gradient-highlight.ts +5 -4
  176. package/src/prompt/magic-keywords.d.ts +2 -0
  177. package/src/prompt/magic-keywords.ts +4 -1
  178. package/src/prompt/model-mention-autocomplete.ts +73 -20
  179. package/src/prompt/model-mention-syntax.d.ts +6 -0
  180. package/src/prompt/model-mention-syntax.ts +9 -0
  181. package/src/prompt/prompt-action-autocomplete.ts +49 -33
  182. package/src/prompt/tips.txt +1 -0
  183. package/src/prompt/welcome.ts +104 -2
  184. package/src/render/extension-links.d.ts +0 -6
  185. package/src/render/extension-links.ts +0 -20
  186. package/src/render/index.d.ts +1 -0
  187. package/src/render/index.ts +1 -0
  188. package/src/render/link-hints.d.ts +78 -0
  189. package/src/render/link-hints.ts +299 -0
  190. package/src/render/render-utils.d.ts +0 -2
  191. package/src/render/render-utils.ts +0 -5
  192. package/src/setup/scenes/glyph.ts +1 -1
  193. package/src/setup/scenes/types.ts +8 -0
  194. package/src/setup/scenes/updates.ts +116 -0
  195. package/src/setup/wizard.ts +19 -8
  196. package/src/spinner-clock.d.ts +34 -0
  197. package/src/spinner-clock.ts +79 -0
  198. package/src/status-line/component.ts +145 -53
  199. package/src/status-line/host.ts +51 -0
  200. package/src/status-line/index.ts +1 -0
  201. package/src/status-line/presets.ts +3 -1
  202. package/src/status-line/prompt-cache.ts +154 -0
  203. package/src/status-line/schema.ts +1 -1
  204. package/src/status-line/segments.ts +33 -22
  205. package/src/status-line/startup.ts +22 -4
  206. package/src/status-line/types.ts +8 -22
  207. package/src/stdin-buffer.ts +89 -46
  208. package/src/terminal-capabilities.ts +3 -3
  209. package/src/terminal.ts +1 -8
  210. package/src/theme/loader.ts +3 -2
  211. package/src/theme/schema.d.ts +28 -1
  212. package/src/theme/schema.ts +30 -1
  213. package/src/theme/symbols.d.ts +1 -1
  214. package/src/theme/symbols.ts +15 -3
  215. package/src/theme/theme-class.d.ts +12 -2
  216. package/src/theme/theme-class.ts +23 -0
  217. package/src/theme/theme-schema.json +1 -1
  218. package/src/theme/theme.d.ts +1 -1
  219. package/src/theme/theme.ts +3 -7
  220. package/src/theme/tui-adapters.d.ts +7 -0
  221. package/src/theme/tui-adapters.ts +33 -1
  222. package/src/thinking.d.ts +12 -0
  223. package/src/thinking.ts +31 -0
  224. package/src/tools/ask.d.ts +1 -1
  225. package/src/tools/ask.ts +99 -38
  226. package/src/tools/ast-edit.ts +51 -32
  227. package/src/tools/ast-grep.ts +31 -19
  228. package/src/tools/bash.d.ts +21 -0
  229. package/src/tools/bash.ts +166 -24
  230. package/src/tools/find.d.ts +9 -1
  231. package/src/tools/find.ts +23 -2
  232. package/src/tools/grep.d.ts +2 -1
  233. package/src/tools/grep.ts +52 -36
  234. package/src/tools/grouped-file-output.d.ts +17 -0
  235. package/src/tools/grouped-file-output.ts +20 -2
  236. package/src/tools/job-widget.d.ts +2 -2
  237. package/src/tools/job-widget.ts +2 -2
  238. package/src/tools/lsp.d.ts +4 -2
  239. package/src/tools/lsp.ts +537 -642
  240. package/src/tools/native-view.d.ts +4 -0
  241. package/src/tools/native-view.ts +8 -2
  242. package/src/tools/renderer.d.ts +9 -1
  243. package/src/tools/renderer.ts +9 -1
  244. package/src/tools/shell-trace.d.ts +10 -0
  245. package/src/tools/shell-trace.ts +80 -0
  246. package/src/tools/shell-viz-render.d.ts +6 -0
  247. package/src/tools/shell-viz-render.ts +156 -0
  248. package/src/tools/shell-viz.d.ts +16 -0
  249. package/src/tools/shell-viz.ts +181 -0
  250. package/src/tools/streaming-output.ts +18 -8
  251. package/src/tools/wait.d.ts +2 -2
  252. package/src/tools/wait.ts +39 -34
  253. package/src/tools/web-search-types.d.ts +1 -0
  254. package/src/tools/web-search-types.ts +1 -0
  255. package/src/tools/write.d.ts +2 -0
  256. package/src/tools/write.ts +2 -0
  257. package/src/tui.d.ts +15 -1
  258. package/src/tui.ts +63 -6
  259. package/src/windows-input-mode.ts +7 -1
  260. package/dist/types/chat/collab-prompt-message.d.ts +0 -14
  261. package/dist/types/chrome/collab-qrcode.d.ts +0 -35
  262. package/src/chat/collab-prompt-message.d.ts +0 -14
  263. package/src/chat/collab-prompt-message.ts +0 -46
  264. package/src/chrome/collab-qrcode.ts +0 -99
@@ -25,9 +25,15 @@ export interface FindHit {
25
25
  /**
26
26
  * How much of a search the judge actually covered. `unavailable`: every judge
27
27
  * request failed, so an empty result is not evidence of absence. `partial`:
28
- * some requests failed. `complete`: none failed (or none were needed).
28
+ * some requests failed, or the call's deadline cut verification short.
29
+ * `complete`: none failed (or none were needed).
29
30
  */
30
31
  export type FindCoverage = "complete" | "partial" | "unavailable";
32
+ /** Verification cut short by the call's deadline: complete passages verified of those routed to it. */
33
+ export interface FindTimeout {
34
+ verified: number;
35
+ passages: number;
36
+ }
31
37
  /** Search accounting reported alongside the hits. */
32
38
  export interface FindStats {
33
39
  /** Eligible files under the root. */
@@ -62,6 +68,8 @@ export interface FindToolDetails {
62
68
  hits: FindHit[];
63
69
  coverage: FindCoverage;
64
70
  stats: FindStats;
71
+ /** Set when the deadline ended verification; the hits are those verified before it. */
72
+ timeout?: FindTimeout;
65
73
  elapsedMs: number;
66
74
  /** Session cwd; hit paths are relative to it. */
67
75
  cwd: string;
@@ -61,7 +61,8 @@ export declare const grepToolRenderer: {
61
61
  }, options: RenderResultContextOptions, uiTheme: Theme, args?: GrepRenderArgs): Component;
62
62
  describeCall(args: GrepRenderArgs): NativeToolView;
63
63
  /**
64
- * Inline (§7.3 grep): `Grep “pattern” 5 matches · 2 files in src`, then
64
+ * Inline (§7.3 grep): `Grep “pattern” in src 5 matches · 2 files`, the scope
65
+ * leading the counts as in the terminal card, then
65
66
  * the matches grouped by file; collapsed shows the first two files.
66
67
  */
67
68
  describeResult(result: {
@@ -154,6 +154,18 @@ export declare function fitGroupsToBudget(groups: readonly (readonly number[])[]
154
154
  * indices lets callers slice parallel arrays (raw lines, styled lines, contexts).
155
155
  */
156
156
  export declare function groupLineIndicesByBlank(rawLines: readonly string[]): number[][];
157
+ /** A code-frame row split after its rule: the gutter (match marker, line number, rule) and the source line. */
158
+ export interface CodeFrameRow {
159
+ gutter: string;
160
+ source: string;
161
+ }
162
+ /**
163
+ * Draw the code-frame rows of consecutive source lines: each gutter in
164
+ * `color`, the sources highlighted in `lang` as one run, so a multi-line
165
+ * string or comment keeps its colors. Without a language the sources take
166
+ * `color` too.
167
+ */
168
+ export declare function renderCodeFrameRun(rows: readonly CodeFrameRow[], lang: string | undefined, color: ThemeColor, theme: Theme): string[];
157
169
  /**
158
170
  * Styled code-frame rows of grouped search output, highlighted in each owning
159
171
  * file's language (`lang` overrides it when the highlighter knows it). A run of
@@ -163,6 +175,11 @@ export declare function groupLineIndicesByBlank(rawLines: readonly string[]): nu
163
175
  * undefined, for the caller to style.
164
176
  */
165
177
  export declare function createCodeFrameStyler(lines: readonly string[], contexts: readonly GroupedLineContext[], color: ThemeColor, theme: Theme, lang?: string): (index: number) => string | undefined;
178
+ /**
179
+ * Search header subject, `pattern in scope`, with `in` dim so the pattern and
180
+ * the scope read as two parts of one subject. Counts follow it as status meta.
181
+ */
182
+ export declare function formatScopedSubject(subject: string | undefined, scope: string | undefined, theme: Theme): string | undefined;
166
183
  /** One event of {@link walkGroupedOutput}: a directory header, a file header, or a non-blank body line. */
167
184
  export type GroupedOutputEvent = {
168
185
  readonly kind: "dir";
@@ -115,7 +115,7 @@ export type JobWidgetBlock = JobWidgetSparkBlock | JobWidgetBarsBlock | JobWidge
115
115
  * a session reload.
116
116
  */
117
117
  export interface JobWidgetView {
118
- /** Short name of what is being watched (`verb-bench · 3 models`). */
118
+ /** Short name of what is being watched (`loadtest · 3 models`). */
119
119
  title: string;
120
120
  headline?: JobWidgetHeadline;
121
121
  /** What the job is doing now: a subagent's stage, or the last line of output. */
@@ -144,7 +144,7 @@ export declare function jobWidgetGlance(view: JobWidgetView): JobWidgetGlance |
144
144
  export declare function jobWidgetSpark(view: JobWidgetView, points?: number): JobWidgetSparkBlock | undefined;
145
145
  /** The entry whose live widget (one a spec drives) saw data last. */
146
146
  export declare function latestJobWidget<T extends JobWidgetEntry>(entries: readonly T[]): T | undefined;
147
- /** The widget as one plain line for tooltips: `verb-bench · 3 models — decode 186 tok/s ▲ 15%`. */
147
+ /** The widget as one plain line for tooltips: `loadtest · 3 models — decode 186 tok/s ▲ 15%`. */
148
148
  export declare function jobWidgetSummary(view: JobWidgetView): string;
149
149
  /** Spans of a glance: muted label, strong number, toned trend. */
150
150
  export declare function jobWidgetGlanceSpans(glance: JobWidgetGlance): TspSpan[];
@@ -43,10 +43,12 @@ export declare enum FileFormatResult {
43
43
  FAILED = "failed",
44
44
  UNSUPPORTED = "unsupported"
45
45
  }
46
+ /** Render the LSP tool call: `LSP: <action> <file:line (symbol)>`. */
46
47
  export declare function renderCall(args: LspParams, _options: RenderResultOptions, theme: Theme): Text;
47
48
  /**
48
- * Render LSP tool result with intelligent formatting based on result type.
49
- * Detects hover, diagnostics, references, symbols, etc. and formats accordingly.
49
+ * Render an LSP result flush: one status line carrying the request and the
50
+ * result counts, over the result rows. Detects locations, hover, diagnostics,
51
+ * references and symbols; anything else is listed line by line.
50
52
  */
51
53
  export declare function renderResult(result: {
52
54
  content: Array<{
@@ -31,6 +31,10 @@ export declare function fileDiffSection(file: {
31
31
  * it), the path with a dim directory and a strong name (cut in the middle),
32
32
  * a quiet `range` suffix (`:13-36`), then an optional count `chip` and a
33
33
  * muted `detail`.
34
+ *
35
+ * A URL is one target, not a directory and a name: its last `/` does not
36
+ * separate a dim parent from a strong basename, and the whole visible text
37
+ * carries the link so a click anywhere on the URL opens it.
34
38
  */
35
39
  export declare function fileRow(filePath: string, p?: {
36
40
  range?: string;
@@ -3,7 +3,7 @@
3
3
  * transcript components. Built-in renderers live beside this file; the
4
4
  * coding-agent tools implement the matching `*Details` payloads.
5
5
  */
6
- import type { TspPreview, TspText, TspTone, TspToolProps } from "@linxiraos/pi-wire";
6
+ import type { ShellTrace, ShellVizPresentation, TspPreview, TspText, TspTone, TspToolProps } from "@linxiraos/pi-wire";
7
7
  import type { NativeChild } from "../native/node.js";
8
8
  import type { Component } from "../tui.js";
9
9
  import type { Theme } from "../theme/theme.js";
@@ -38,6 +38,14 @@ export interface RenderResultOptions {
38
38
  media?: boolean;
39
39
  /** The native host draws raw JSON values (`cx.supports("json")`). Native describe hooks only. */
40
40
  json?: boolean;
41
+ /** The native host draws a live shell trace (`cx.supports("shell")`). Native describe hooks only. */
42
+ shell?: boolean;
43
+ /** Native semantic presentation, decoded and cached by the tool component. */
44
+ shellPresentation?: ShellVizPresentation;
45
+ /** Validated immutable trace associated with shellPresentation. */
46
+ shellTrace?: ShellTrace;
47
+ /** Explicit seeks/resets change this epoch; ordinary playback ticks do not. */
48
+ shellReplayEpoch?: number;
41
49
  }
42
50
  /** Render options for a result, plus the tool-specific context the transcript threads through. */
43
51
  export type RenderResultContextOptions = RenderResultOptions & {
@@ -0,0 +1,10 @@
1
+ import type { ShellVizLayer, ShellVizPreferences, ShellVizView } from "@linxiraos/pi-wire";
2
+ import type { NativeUiEvent } from "../native/node.js";
3
+ /** Canonical ordered views used by the inspector and native event adapter. */
4
+ export declare const SHELL_VIZ_VIEWS: readonly ShellVizView[];
5
+ /** Canonical toggleable semantic layers. */
6
+ export declare const SHELL_VIZ_LAYERS: readonly ShellVizLayer[];
7
+ /** Normalize action/change/selection events to the shared action vocabulary. */
8
+ export declare function shellVizEventAction(event: NativeUiEvent, preferences: ShellVizPreferences): string | undefined;
9
+ /** Apply shared actions; node keys remain opaque and playback values remain numeric. */
10
+ export declare function changeShellVizPreferences(preferences: ShellVizPreferences, action: string, length: number): ShellVizPreferences;
@@ -0,0 +1,6 @@
1
+ import type { ShellVizPresentation } from "@linxiraos/pi-wire";
2
+ import type { Theme } from "../theme/theme.js";
3
+ /** Sanitize untrusted shell source, values and outputs before applying terminal styling. */
4
+ export declare function shellVizText(text: string): string;
5
+ /** Render the canonical presentation; transcript cards and focused inspector share this path. */
6
+ export declare function renderShellVisualization(presentation: ShellVizPresentation, theme: Theme, width: number, includeOutput?: boolean): string[];
@@ -0,0 +1,16 @@
1
+ import { RunTrace, ShellVisualization } from "@linxiraos/pi-natives";
2
+ import type { ShellTrace, ShellVizPreferences, ShellVizPresentation } from "@linxiraos/pi-wire";
3
+ /** Native live-run or restored-trace owner; the UI never holds shell syntax. */
4
+ export type ShellVisualizationSource = RunTrace | ShellVisualization;
5
+ /** Bind the immutable snapshot before publishing it; live paints borrow the actual run. */
6
+ export declare function attachShellTrace(snapshot: ShellTrace, trace: RunTrace): void;
7
+ /** Historical traces restore their canonical native archive only once per snapshot. */
8
+ export declare function shellVisualization(snapshot: ShellTrace): ShellVisualizationSource;
9
+ /** Python-like Pseudo, all layers enabled, one pane, live, paused, normal speed. */
10
+ export declare function defaultShellVizPreferences(): ShellVizPreferences;
11
+ /** Render through native ownership; an explicit replay cursor never uses the normal output sink. */
12
+ export declare function readShellPresentation(source: ShellVisualizationSource, preferences: ShellVizPreferences, snapshot?: ShellTrace, output?: string): ShellVizPresentation;
13
+ /** Node keys are opaque; validation must never invent or reinterpret engine identity. */
14
+ export declare function isShellVizNode(value: unknown): value is string;
15
+ /** Decode semantic display data, never shell syntax or execution state. */
16
+ export declare function decodeShellPresentation(json: string): ShellVizPresentation;
@@ -106,8 +106,8 @@ export interface CoordinationDetails {
106
106
  from?: string;
107
107
  to?: string;
108
108
  receipts?: IrcDeliveryReceipt[];
109
- /** Message consumed by `wait`. */
110
- waited?: IrcMessage | null;
109
+ /** Messages consumed by `wait`, oldest first. */
110
+ waited?: IrcMessage[];
111
111
  jobs?: JobSnapshot[];
112
112
  cancelled?: {
113
113
  id: string;
@@ -20,6 +20,7 @@ export declare const SEARCH_PROVIDER_LABELS: {
20
20
  readonly zai: "Z.AI";
21
21
  readonly exa: "Exa";
22
22
  readonly tinyfish: "TinyFish";
23
+ readonly keenable: "Keenable";
23
24
  readonly jina: "Jina";
24
25
  readonly kagi: "Kagi";
25
26
  readonly tavily: "Tavily";
@@ -22,6 +22,8 @@ export interface WriteToolDetails {
22
22
  message?: CoordinationDetails;
23
23
  proc?: ProcWriteDetails;
24
24
  cfg?: CfgWriteDetails;
25
+ /** Set when the write touched no files: a peer message, a reply, or a background-work cancellation. */
26
+ touchesNoFiles?: boolean;
25
27
  }
26
28
  interface WriteRenderArgs {
27
29
  path?: unknown;
@@ -129,7 +129,9 @@ export interface Component {
129
129
  * an overlay: the sheet's `role` (Tern styles `zeta.overlay.*` roles as
130
130
  * glass sheets, so the component's own root must not draw a second frame),
131
131
  * `head` spans for the sheet's title row, and `size`/`anchor` overriding
132
- * the ones derived from the overlay options.
132
+ * the ones derived from the overlay options. `size` is a width class: on a
133
+ * narrow pane the backend fills it only when the described content is tall
134
+ * (see `NativeBackend`).
133
135
  */
134
136
  nativeOverlay?: {
135
137
  role?: string;
@@ -153,6 +155,12 @@ export interface Component {
153
155
  describeScreen?(cx: DescribeContext): NativeScreen;
154
156
  /** User actions on nodes this component described (toggle, select, activate, custom). */
155
157
  handleNativeEvent?(event: NativeUiEvent): void;
158
+ /**
159
+ * Native transcript blocks drawn right after this one as siblings (a `TranscriptContainer` child only): notes
160
+ * about the block that must show while it is collapsed, such as a tool card's Spotlight notice. The terminal
161
+ * rows never show them. Return the same array while unchanged.
162
+ */
163
+ nativeTrailers?(): readonly Component[];
156
164
  /**
157
165
  * Pure preflight for focused input that must precede TUI-wide input listeners
158
166
  * and debug shortcuts. A true result routes the event to this component first.
@@ -343,6 +351,12 @@ export declare class Container implements Component {
343
351
  render(width: number): readonly string[];
344
352
  describe(_cx: DescribeContext): NativeNode | null;
345
353
  }
354
+ /**
355
+ * `component`'s own native description, or `null` when it draws as rendered rows: it has no
356
+ * `describe`, answers `null`, or is a Container subclass that paints its own rows but inherits the
357
+ * plain column description, which would lose that rendering.
358
+ */
359
+ export declare function ownDescription(component: Component, cx: DescribeContext): NativeNode | null;
346
360
  /**
347
361
  * Merge runs of byte-adjacent SGR sequences (`CSI [0-9;:]* m`) into one. Only
348
362
  * CSI-SGR sequences are touched; text, cursor moves, OSC, hyperlinks and image
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@linxiraos/pi-tui",
4
- "version": "1.4.11",
4
+ "version": "1.4.12",
5
5
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
6
6
  "homepage": "https://linxira-os.github.io/zeta/",
7
7
  "author": "Linxira-OS",
@@ -30,7 +30,7 @@
30
30
  "types": "./dist/types/index.d.ts",
31
31
  "scripts": {
32
32
  "check": "oxlint . && oxfmt --check --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts' && bun run check:types",
33
- "check:types": "tsc -p tsconfig.json --noEmit",
33
+ "check:types": "bun check --no-script -p tsconfig.json",
34
34
  "lint": "oxlint .",
35
35
  "test": "bun test --parallel test/*.test.ts",
36
36
  "fix": "oxlint --fix --fix-suggestions . && bun run fmt",
@@ -38,14 +38,14 @@
38
38
  "gen:glyphs": "bun scripts/gen-glyphs.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@linxiraos/zeta-schema": "1.4.11",
42
- "@linxiraos/pi-agent-core": "1.4.11",
43
- "@linxiraos/pi-ai": "1.4.11",
44
- "@linxiraos/pi-catalog": "1.4.11",
45
- "@linxiraos/pi-natives": "1.4.11",
46
- "@linxiraos/pi-utils": "1.4.11",
47
- "@linxiraos/pi-wire": "1.4.11",
48
- "@linxiraos/zeta-compact": "1.4.11"
41
+ "@linxiraos/zeta-schema": "1.4.12",
42
+ "@linxiraos/pi-agent-core": "1.4.12",
43
+ "@linxiraos/pi-ai": "1.4.12",
44
+ "@linxiraos/pi-catalog": "1.4.12",
45
+ "@linxiraos/pi-natives": "1.4.12",
46
+ "@linxiraos/pi-utils": "1.4.12",
47
+ "@linxiraos/pi-wire": "1.4.12",
48
+ "@linxiraos/zeta-compact": "1.4.12"
49
49
  },
50
50
  "devDependencies": {
51
51
  "kitty-vt-wasm": "^0.2.0"
@@ -102,6 +102,10 @@
102
102
  "types": "./dist/types/native/*.d.ts",
103
103
  "import": "./src/native/*.ts"
104
104
  },
105
- "./*.js": "./src/*.ts"
105
+ "./*.js": "./src/*.ts",
106
+ "./tools/shell-viz": {
107
+ "types": "./dist/types/tools/shell-viz.d.ts",
108
+ "import": "./src/tools/shell-viz.ts"
109
+ }
106
110
  }
107
111
  }
@@ -0,0 +1,24 @@
1
+ import type { ShellVizPresentation } from "@linxiraos/pi-wire";
2
+ import type { DescribeContext, NativeNode, NativeUiEvent } from "../native/node";
3
+ import type { Component } from "../tui";
4
+ /** Focused inspector host; state and replay timers remain owned by the transcript tool call. */
5
+ export interface ShellVisualizerHost {
6
+ presentation(): ShellVizPresentation | undefined;
7
+ replayEpoch(): number;
8
+ liveOrigin(): boolean;
9
+ action(value: string): void;
10
+ close(): void;
11
+ requestRender(): void;
12
+ height(): number;
13
+ }
14
+ /** Keyboard and native inspector for the exact presentation shown in the transcript. */
15
+ export declare class ShellVisualizer implements Component {
16
+ #private;
17
+ readonly host: ShellVisualizerHost;
18
+ constructor(host: ShellVisualizerHost);
19
+ invalidate(): void;
20
+ handleInput(data: string): void;
21
+ handleNativeEvent(event: NativeUiEvent): void;
22
+ describe(cx: DescribeContext): NativeNode;
23
+ render(width: number): string[];
24
+ }
@@ -0,0 +1,167 @@
1
+ import type { ShellVizPresentation } from "@linxiraos/pi-wire";
2
+ import { matchesKey } from "../keys";
3
+ import { node } from "../native/describe";
4
+ import type { DescribeContext, NativeNode, NativeUiEvent } from "../native/node";
5
+ import { formatDuration } from "../render/render-utils";
6
+ import { theme } from "../theme/theme";
7
+ import type { Component } from "../tui";
8
+ import { truncateToWidth, wrapTextWithAnsi } from "../utils";
9
+ import { SHELL_VIZ_LAYERS, SHELL_VIZ_VIEWS, shellVizEventAction } from "../tools/shell-trace";
10
+ import { renderShellVisualization, shellVizText } from "../tools/shell-viz-render";
11
+
12
+ /** Focused inspector host; state and replay timers remain owned by the transcript tool call. */
13
+ export interface ShellVisualizerHost {
14
+ presentation(): ShellVizPresentation | undefined;
15
+ replayEpoch(): number;
16
+ liveOrigin(): boolean;
17
+ action(value: string): void;
18
+ close(): void;
19
+ requestRender(): void;
20
+ height(): number;
21
+ }
22
+
23
+ /** Keyboard and native inspector for the exact presentation shown in the transcript. */
24
+ export class ShellVisualizer implements Component {
25
+ #scroll = 0;
26
+ #detailScroll = 0;
27
+ constructor(readonly host: ShellVisualizerHost) {}
28
+ invalidate(): void {}
29
+ handleInput(data: string): void {
30
+ const presentation = this.host.presentation();
31
+ if (matchesKey(data, "escape") || data === "q") {
32
+ this.host.close();
33
+ return;
34
+ }
35
+ if (!presentation) return;
36
+ const prefs = presentation.preferences;
37
+ const view = Number(data) - 1;
38
+ if (data === "v") {
39
+ this.#scroll = 0;
40
+ this.host.action(`view:${prefs.view === "raw" ? "pseudo" : "raw"}`);
41
+ } else if (/^[1-2]$/.test(data) && SHELL_VIZ_VIEWS[view]) {
42
+ this.#scroll = 0;
43
+ this.host.action(`view:${SHELL_VIZ_VIEWS[view]}`);
44
+ } else if (data === "c") this.host.action("layer:color");
45
+ else if (data === "i") this.host.action("layer:inline");
46
+ else if (data === "d") this.host.action("layer:idioms");
47
+ else if (data === "e") this.host.action("layer:effects");
48
+ else if (data === "u") this.host.action("layer:unwrap");
49
+ else if (data === "s") this.host.action("split");
50
+ else if (data === " ") this.host.action(prefs.playing ? "pause" : "play");
51
+ else if (data === "." || matchesKey(data, "right")) this.host.action("step");
52
+ else if (matchesKey(data, "left")) this.host.action(`seek:${Math.max(0, presentation.timeline.cursor - 1)}`);
53
+ else if (data === "r") this.host.action("reset");
54
+ else if (data === "l") this.host.action("live");
55
+ else if (data === "+" || data === "=") this.host.action(`speed:${prefs.speed < 1 ? 1 : prefs.speed < 2 ? 2 : 4}`);
56
+ else if (data === "-") this.host.action(`speed:${prefs.speed > 2 ? 2 : prefs.speed > 1 ? 1 : 0.5}`);
57
+ else if (matchesKey(data, "home")) this.host.action("seek:0");
58
+ else if (matchesKey(data, "end")) this.host.action(`seek:${presentation.timeline.length}`);
59
+ else if (data === "[") this.#detailScroll = Math.max(0, this.#detailScroll - 1);
60
+ else if (data === "]") this.#detailScroll++;
61
+ else if (matchesKey(data, "pageDown")) this.#scroll += Math.max(1, this.host.height() - 8);
62
+ else if (matchesKey(data, "pageUp"))
63
+ this.#scroll = Math.max(0, this.#scroll - Math.max(1, this.host.height() - 8));
64
+ else if (
65
+ matchesKey(data, "up") ||
66
+ data === "k" ||
67
+ matchesKey(data, "down") ||
68
+ data === "j" ||
69
+ matchesKey(data, "tab")
70
+ ) {
71
+ const nodes = [
72
+ ...new Set(
73
+ presentation.rows.flatMap(row => [
74
+ ...(row.node === undefined ? [] : [row.node]),
75
+ ...row.segments.flatMap(segment => (segment.node === undefined ? [] : [segment.node])),
76
+ ]),
77
+ ),
78
+ ];
79
+ const index = nodes.findIndex(node => node === prefs.selectedNode);
80
+ const direction = matchesKey(data, "up") || data === "k" ? -1 : 1;
81
+ const selected = nodes[(index + direction + nodes.length) % nodes.length];
82
+ if (selected !== undefined) {
83
+ this.#detailScroll = 0;
84
+ this.host.action(`select:${selected}`);
85
+ }
86
+ } else if (matchesKey(data, "enter") && prefs.selectedNode !== undefined) {
87
+ this.#detailScroll = 0;
88
+ this.host.action(`expand:${prefs.selectedNode}`);
89
+ }
90
+ this.host.requestRender();
91
+ }
92
+ handleNativeEvent(event: NativeUiEvent): void {
93
+ if (event.type === "action" && event.act === "close") {
94
+ this.host.close();
95
+ return;
96
+ }
97
+ const presentation = this.host.presentation();
98
+ const action = presentation && shellVizEventAction(event, presentation.preferences);
99
+ if (action) this.host.action(action);
100
+ }
101
+ describe(cx: DescribeContext): NativeNode {
102
+ const presentation = this.host.presentation();
103
+ if (presentation && cx.supports("shell"))
104
+ return node("shell", {
105
+ presentation,
106
+ lang: "bash",
107
+ inspector: true,
108
+ replayEpoch: this.host.replayEpoch(),
109
+ liveOrigin: this.host.liveOrigin(),
110
+ });
111
+ return node("rows", { cols: cx.cols, lines: this.render(cx.cols) });
112
+ }
113
+ render(width: number): string[] {
114
+ const presentation = this.host.presentation();
115
+ if (!presentation) return ["No complete bash command available", "Escape closes"];
116
+ const prefs = presentation.preferences;
117
+ const headings = `v Raw ↔ Pseudo · ${prefs.view === "pseudo" ? "Pseudo" : "Raw"}`;
118
+ const layers = SHELL_VIZ_LAYERS.map(layer => `${layer}:${prefs.layers[layer] ? "on" : "off"}`).join(" ");
119
+ const header = [
120
+ theme.bold("Bash visualizer · Escape closes"),
121
+ headings,
122
+ layers,
123
+ `c/i/d/e/u layers · s split:${prefs.split ? "on" : "off"} · ↑↓/Tab select · Enter details · PgUp/PgDn scroll`,
124
+ `Space ${prefs.playing ? "pause" : "play"} · ←/→ step · r reset · l live · Home/End seek · −/+ speed ${prefs.speed}× · ${formatDuration(presentation.timeline.elapsedNs / 1_000_000)} / ${formatDuration(presentation.timeline.durationNs / 1_000_000)}`,
125
+ ];
126
+ const body = renderShellVisualization(presentation, theme, width);
127
+ const selected = presentation.rows.find(
128
+ row => row.node === prefs.selectedNode || row.segments.some(segment => segment.node === prefs.selectedNode),
129
+ );
130
+ const detail: string[] = [];
131
+ if (selected) {
132
+ if (selected.detail) detail.push(shellVizText(selected.detail));
133
+ for (const segment of selected.segments) {
134
+ if (segment.tip) detail.push(shellVizText(segment.tip));
135
+ const node = segment.node ?? selected.node;
136
+ if (segment.expanded && node !== undefined && prefs.expandedNodes.includes(node))
137
+ detail.push(...segment.expanded.split("\n").map(shellVizText));
138
+ }
139
+ for (const variable of selected.annotations ?? []) {
140
+ detail.push(
141
+ `${shellVizText(variable.name)} = ${shellVizText(JSON.stringify(variable.value))}${variable.scope ? ` (${shellVizText(variable.scope)})` : ""}${variable.fullLength !== undefined && variable.fullLength > Buffer.byteLength(variable.value, "utf8") ? ` [${variable.fullLength} bytes; retained value truncated]` : ""}`,
142
+ );
143
+ }
144
+ for (const effect of selected.effects)
145
+ detail.push(`${shellVizText(effect.label)}: ${shellVizText(effect.why)}`);
146
+ }
147
+ const height = Math.max(8, this.host.height());
148
+ const wrappedDetail = detail.flatMap(line => wrapTextWithAnsi(line, Math.max(1, width)));
149
+ const detailHeight = Math.min(wrappedDetail.length, Math.floor(height / 3));
150
+ this.#detailScroll = Math.max(0, Math.min(this.#detailScroll, wrappedDetail.length - detailHeight));
151
+ const available = Math.max(1, height - header.length - detailHeight - (detailHeight ? 1 : 0));
152
+ this.#scroll = Math.max(0, Math.min(this.#scroll, body.length - available));
153
+ return [
154
+ ...header,
155
+ ...body.slice(this.#scroll, this.#scroll + available),
156
+ ...(detailHeight
157
+ ? [
158
+ theme.fg(
159
+ "dim",
160
+ `Selected details ${this.#detailScroll + 1}–${this.#detailScroll + detailHeight}/${wrappedDetail.length} · [/] scroll`,
161
+ ),
162
+ ...wrappedDetail.slice(this.#detailScroll, this.#detailScroll + detailHeight),
163
+ ]
164
+ : []),
165
+ ].map(line => truncateToWidth(line, width));
166
+ }
167
+ }
@@ -47,6 +47,21 @@ export interface AutocompleteItem {
47
47
  descriptionMatch?: boolean;
48
48
  }
49
49
  type Awaitable<T> = T | Promise<T>;
50
+ /**
51
+ * `^` model mention completion at the cursor. `unhandled` means no mention token there, or
52
+ * another completion outranks it, so the async {@link AutocompleteProvider.getSuggestions} decides.
53
+ */
54
+ export type ModelMentionCompletion = {
55
+ kind: "unhandled";
56
+ } | {
57
+ kind: "no-match";
58
+ } | {
59
+ kind: "matched";
60
+ suggestions: {
61
+ items: AutocompleteItem[];
62
+ prefix: string;
63
+ };
64
+ };
50
65
  export interface SlashCommand {
51
66
  name: string;
52
67
  aliases?: string[];
@@ -94,6 +109,11 @@ export interface AutocompleteProvider {
94
109
  items: AutocompleteItem[];
95
110
  prefix: string;
96
111
  } | null;
112
+ /**
113
+ * Synchronously list `^` model mention completions for the token at the cursor, so a
114
+ * shown mention popup never lags the typed text.
115
+ */
116
+ trySyncModelMentionCompletion?(lines: string[], cursorLine: number, cursorCol: number): ModelMentionCompletion;
97
117
  /**
98
118
  * Synchronously try to expand text immediately before the cursor (no async I/O).
99
119
  * Called after every single-character insert. Implementations MUST cheaply
@@ -236,6 +236,15 @@ export interface AutocompleteItem {
236
236
 
237
237
  type Awaitable<T> = T | Promise<T>;
238
238
 
239
+ /**
240
+ * `^` model mention completion at the cursor. `unhandled` means no mention token there, or
241
+ * another completion outranks it, so the async {@link AutocompleteProvider.getSuggestions} decides.
242
+ */
243
+ export type ModelMentionCompletion =
244
+ | { kind: "unhandled" }
245
+ | { kind: "no-match" }
246
+ | { kind: "matched"; suggestions: { items: AutocompleteItem[]; prefix: string } };
247
+
239
248
  export interface SlashCommand {
240
249
  name: string;
241
250
  aliases?: string[];
@@ -294,6 +303,11 @@ export interface AutocompleteProvider {
294
303
  * the collapsed `/skill:` namespace row. Returns null outside a command-name token or with no match.
295
304
  */
296
305
  trySyncSlashCompletion?(textBeforeCursor: string): { items: AutocompleteItem[]; prefix: string } | null;
306
+ /**
307
+ * Synchronously list `^` model mention completions for the token at the cursor, so a
308
+ * shown mention popup never lags the typed text.
309
+ */
310
+ trySyncModelMentionCompletion?(lines: string[], cursorLine: number, cursorCol: number): ModelMentionCompletion;
297
311
  /**
298
312
  * Synchronously try to expand text immediately before the cursor (no async I/O).
299
313
  * Called after every single-character insert. Implementations MUST cheaply
@@ -27,6 +27,7 @@ import { isNativeRendering } from "../native/state";
27
27
  import { NativeImageCache, nativeMediaNode } from "../native/blobs";
28
28
  import { linkedImageText } from "../prompt/image-references";
29
29
  import { Memo } from "../native/memo";
30
+ import { DEFAULT_SPINNER_INTERVAL_MS, spinnerAnimated, spinnerInterval } from "../spinner-clock";
30
31
  import { EMPTY_LINK_TARGETS, resolveImageOptions } from "../render/render-utils";
31
32
  import { WidthAwareText } from "../render";
32
33
  import { cachedPngConversion, convertImageToPngShared, imagePayloadKey } from "./image-loading";
@@ -796,17 +797,18 @@ export class AssistantMessageComponent extends Container {
796
797
  }
797
798
 
798
799
  #startThinkingAnimation(): void {
799
- // A native terminal clocks the described starburst itself.
800
- if (this.#thinkingDotsTimer || isNativeRendering()) return;
800
+ // A native terminal clocks the described starburst itself; a static spinner holds frame 0.
801
+ if (this.#thinkingDotsTimer || isNativeRendering() || !spinnerAnimated()) return;
801
802
  this.#scheduleThinkingFrame();
802
803
  }
803
804
 
804
805
  /** Eased dwell (ms) for the current pulse frame: a raised cosine over the
805
806
  * 8-frame cycle, continuous across the wrap, so the rotation breathes rather
806
- * than advancing at a fixed interval. */
807
+ * than advancing at a fixed interval. Scaled with `tui.spinnerInterval`. */
807
808
  #thinkingDotsFrameDelay(): number {
808
809
  const phase = (1 - Math.cos((2 * Math.PI * this.#thinkingDotsFrame) / THINKING_DOTS_FRAMES.length)) / 2;
809
- return THINKING_DOTS_FRAME_MS_MIN + (THINKING_DOTS_FRAME_MS_MAX - THINKING_DOTS_FRAME_MS_MIN) * phase;
810
+ const dwell = THINKING_DOTS_FRAME_MS_MIN + (THINKING_DOTS_FRAME_MS_MAX - THINKING_DOTS_FRAME_MS_MIN) * phase;
811
+ return (dwell * spinnerInterval()) / DEFAULT_SPINNER_INTERVAL_MS;
810
812
  }
811
813
 
812
814
  /** Self-rescheduling timeout (not a fixed interval) so each frame can pick its
@@ -822,11 +824,14 @@ export class AssistantMessageComponent extends Container {
822
824
  this.#stopThinkingAnimation();
823
825
  return;
824
826
  }
825
- this.#thinkingDotsFrame = (this.#thinkingDotsFrame + 1) % THINKING_DOTS_FRAMES.length;
827
+ const animated = spinnerAnimated();
828
+ // Spinners went static mid-pulse: settle on frame 0 and stop.
829
+ if (animated) this.#thinkingDotsFrame = (this.#thinkingDotsFrame + 1) % THINKING_DOTS_FRAMES.length;
830
+ else this.#thinkingDotsFrame = 0;
826
831
  if (this.#thinkingDots.setText(this.#thinkingDotsLabel())) {
827
832
  this.#onImageUpdate?.();
828
833
  }
829
- this.#scheduleThinkingFrame();
834
+ if (animated) this.#scheduleThinkingFrame();
830
835
  }
831
836
 
832
837
  #stopThinkingAnimation(): void {
@@ -10,11 +10,16 @@ export interface CacheInvalidation {
10
10
  * reusing.
11
11
  *
12
12
  * The provider reports a warm prefix as `cacheRead`; a model/thinking/tool/
13
- * system-prompt change (or a history rewrite) breaks the prefix, so the next
14
- * request reads nothing from cache and re-pays for the whole prompt. We flag
13
+ * system-prompt change, a history rewrite or an expired entry breaks the
14
+ * prefix, so the next request re-pays for the prompt past the break. We flag
15
15
  * only the transition where a demonstrably warm cache goes cold: the previous
16
- * turn must have actually READ a meaningful prefix back, and this turn's
17
- * `cacheRead` collapsed to zero while it still reprocessed a non-trivial prompt.
16
+ * turn must have actually READ a meaningful prefix back, and this turn read
17
+ * back less than half of it while it still reprocessed a non-trivial prompt.
18
+ *
19
+ * A collapse need not reach zero: the leading system/tool block is shared with
20
+ * every concurrent session on the same prompt, which keeps it warm while this
21
+ * session's history expires, so a cold turn still reads that block (~15k
22
+ * tokens) back while re-writing hundreds of thousands behind it.
18
23
  *
19
24
  * Requiring a prior warm read is deliberate. A turn that merely WROTE the prefix
20
25
  * (`cacheRead` 0) has not proven the cache is live — that is the session's first
@@ -23,11 +28,14 @@ export interface CacheInvalidation {
23
28
  * call outliving the provider's 5-minute cache TTL surfaced a spurious "cache
24
29
  * miss" right under the opening message). It also collapses a run of consecutive
25
30
  * cold turns to the single marker at the moment the cache actually broke, instead
26
- * of repeating the banner on every turn while it re-warms.
31
+ * of repeating the banner on every turn while it re-warms. Measuring the loss
32
+ * against what the predecessor READ (not what it wrote) keeps both guarantees
33
+ * when only the shared block was warm: nothing proven live was lost.
27
34
  *
28
35
  * Returns `undefined` (no marker) for the first turn, turns whose predecessor
29
- * never read a warm prefix, tiny contexts, turns that reused any cache, and —
30
- * crucially — turns on providers with *implicit* best-effort caching. Only an
36
+ * never read a warm prefix, tiny contexts, turns that read back at least half
37
+ * of the predecessor's warm prefix, and — crucially — turns on providers with
38
+ * *implicit* best-effort caching. Only an
31
39
  * explicit, prefix-controlled cache (Anthropic / Bedrock `cache_control`)
32
40
  * re-creates the prefix on a cold turn (`cacheWrite > 0`); implicit caches
33
41
  * (Google / OpenAI / Fireworks) report `cacheWrite: 0` and drop `cacheRead` to