@linxiraos/pi-tui 1.4.6 → 1.4.7

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 (278) hide show
  1. package/CHANGELOG.md +194 -195
  2. package/README.md +34 -34
  3. package/dist/types/app-keybindings.d.ts +15 -0
  4. package/dist/types/apps/session-picker.d.ts +5 -0
  5. package/dist/types/charts/chart-plan.d.ts +9 -7
  6. package/dist/types/chat/assistant-message.d.ts +15 -3
  7. package/dist/types/chat/bash-execution.d.ts +2 -0
  8. package/dist/types/chat/display-preferences.d.ts +2 -0
  9. package/dist/types/chat/extension-types.d.ts +31 -0
  10. package/dist/types/chat/reply-write.d.ts +48 -0
  11. package/dist/types/chat/table-chart.d.ts +4 -3
  12. package/dist/types/chat/tool-execution.d.ts +1 -2
  13. package/dist/types/chat/transcript-outline.d.ts +7 -0
  14. package/dist/types/chat/transcript-render-helpers.d.ts +2 -0
  15. package/dist/types/chrome/index.d.ts +1 -0
  16. package/dist/types/chrome/transcript-notice.d.ts +35 -0
  17. package/dist/types/chrome/transcript-status.d.ts +20 -8
  18. package/dist/types/components/editor.d.ts +8 -0
  19. package/dist/types/components/markdown.d.ts +7 -0
  20. package/dist/types/native/blobs.d.ts +2 -1
  21. package/dist/types/native/picker.d.ts +4 -4
  22. package/dist/types/overlays/annotation-overlay.d.ts +7 -1
  23. package/dist/types/overlays/annotation-types.d.ts +28 -0
  24. package/dist/types/overlays/login-dialog.d.ts +5 -1
  25. package/dist/types/overlays/model-browser.d.ts +10 -1
  26. package/dist/types/overlays/oauth-selector.d.ts +23 -0
  27. package/dist/types/overlays/plan-review-overlay.d.ts +2 -0
  28. package/dist/types/overlays/rewind-selector.d.ts +1 -1
  29. package/dist/types/overlays/session-selector.d.ts +22 -2
  30. package/dist/types/prompt/composer.d.ts +43 -0
  31. package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
  32. package/dist/types/render/extension-links.d.ts +65 -0
  33. package/dist/types/render/hyperlink.d.ts +25 -7
  34. package/dist/types/render/index.d.ts +1 -0
  35. package/dist/types/setup/scenes/glyph.d.ts +1 -1
  36. package/dist/types/setup/scenes/model.d.ts +1 -1
  37. package/dist/types/setup/scenes/outro.d.ts +5 -4
  38. package/dist/types/setup/scenes/sign-in.d.ts +13 -8
  39. package/dist/types/setup/scenes/types.d.ts +16 -1
  40. package/dist/types/setup/startup-splash.d.ts +1 -1
  41. package/dist/types/setup/wizard-overlay.d.ts +11 -7
  42. package/dist/types/setup/wizard.d.ts +5 -1
  43. package/dist/types/status-line/component.d.ts +1 -1
  44. package/dist/types/status-line/context-usage.d.ts +28 -6
  45. package/dist/types/status-line/host.d.ts +6 -2
  46. package/dist/types/theme/theme.d.ts +0 -23
  47. package/dist/types/tools/bash-interactive.d.ts +6 -0
  48. package/dist/types/tools/bash.d.ts +2 -0
  49. package/dist/types/tools/default-renderer.d.ts +6 -4
  50. package/dist/types/tools/irc.d.ts +6 -0
  51. package/dist/types/tools/json-tree.d.ts +23 -4
  52. package/dist/types/tools/lsp.d.ts +2 -0
  53. package/dist/types/tools/mcp.d.ts +6 -5
  54. package/dist/types/tools/native-view.d.ts +1 -1
  55. package/dist/types/tools/renderer.d.ts +2 -0
  56. package/dist/types/tools/streaming-output.d.ts +11 -0
  57. package/dist/types/tools/task.d.ts +9 -1
  58. package/dist/types/tools/url-scheme-host.d.ts +17 -0
  59. package/dist/types/tools/yield.d.ts +1 -1
  60. package/dist/types/tui.d.ts +7 -2
  61. package/package.json +10 -14
  62. package/src/app-keybindings.d.ts +15 -0
  63. package/src/app-keybindings.ts +15 -0
  64. package/src/apps/session-picker.ts +7 -0
  65. package/src/charts/chart-plan.d.ts +9 -7
  66. package/src/charts/chart-plan.ts +20 -50
  67. package/src/chat/advisor-message.ts +2 -0
  68. package/src/chat/assistant-message.d.ts +15 -3
  69. package/src/chat/assistant-message.ts +137 -19
  70. package/src/chat/background-tan-message.ts +4 -0
  71. package/src/chat/bash-execution.d.ts +2 -0
  72. package/src/chat/bash-execution.ts +6 -0
  73. package/src/chat/chat-transcript-builder.ts +58 -28
  74. package/src/chat/compaction-summary-message.ts +2 -1
  75. package/src/chat/display-preferences.d.ts +2 -0
  76. package/src/chat/display-preferences.ts +3 -0
  77. package/src/chat/extension-types.d.ts +31 -0
  78. package/src/chat/extension-types.ts +34 -0
  79. package/src/chat/reply-write.d.ts +48 -0
  80. package/src/chat/reply-write.ts +127 -0
  81. package/src/chat/table-chart.d.ts +4 -3
  82. package/src/chat/table-chart.ts +10 -4
  83. package/src/chat/tool-execution.d.ts +1 -2
  84. package/src/chat/tool-execution.ts +20 -13
  85. package/src/chat/transcript-outline.d.ts +7 -0
  86. package/src/chat/transcript-outline.ts +27 -0
  87. package/src/chat/transcript-render-helpers.d.ts +2 -0
  88. package/src/chat/transcript-render-helpers.ts +66 -24
  89. package/src/chrome/index.ts +1 -0
  90. package/src/chrome/transcript-notice.d.ts +35 -0
  91. package/src/chrome/transcript-notice.ts +83 -0
  92. package/src/chrome/transcript-status.d.ts +20 -8
  93. package/src/chrome/transcript-status.ts +29 -29
  94. package/src/components/editor.d.ts +8 -0
  95. package/src/components/editor.ts +10 -1
  96. package/src/components/markdown.d.ts +7 -0
  97. package/src/components/markdown.ts +116 -6
  98. package/src/hotkeys-markdown.ts +1 -0
  99. package/src/native/backend.ts +5 -66
  100. package/src/native/blobs.d.ts +2 -1
  101. package/src/native/blobs.ts +3 -2
  102. package/src/native/picker.d.ts +4 -4
  103. package/src/native/picker.ts +4 -4
  104. package/src/overlays/advisor-config.ts +1 -10
  105. package/src/overlays/annotation-overlay.ts +125 -37
  106. package/src/overlays/annotation-types.ts +24 -0
  107. package/src/overlays/hook-selector.ts +2 -2
  108. package/src/overlays/login-dialog.ts +31 -5
  109. package/src/overlays/mcp-add-wizard.ts +1 -1
  110. package/src/overlays/model-browser.ts +37 -0
  111. package/src/overlays/model-hub.ts +1 -7
  112. package/src/overlays/model-picker.ts +1 -10
  113. package/src/overlays/oauth-selector.ts +44 -6
  114. package/src/overlays/plan-review-overlay.ts +13 -2
  115. package/src/overlays/rewind-selector.ts +29 -12
  116. package/src/overlays/session-selector.ts +313 -42
  117. package/src/overlays/usage-dashboard.ts +5 -12
  118. package/src/prompt/composer.ts +216 -1
  119. package/src/prompt/custom-editor.ts +6 -1
  120. package/src/prompt/emoji-autocomplete.ts +0 -2
  121. package/src/prompt/interactive-context-helpers.ts +29 -4
  122. package/src/render/extension-links.d.ts +65 -0
  123. package/src/render/extension-links.ts +214 -0
  124. package/src/render/hyperlink.d.ts +25 -7
  125. package/src/render/hyperlink.ts +65 -9
  126. package/src/render/index.d.ts +1 -0
  127. package/src/render/index.ts +1 -0
  128. package/src/setup/scenes/composer.ts +2 -0
  129. package/src/setup/scenes/glyph.ts +3 -1
  130. package/src/setup/scenes/model.ts +192 -29
  131. package/src/setup/scenes/outro.ts +33 -15
  132. package/src/setup/scenes/sign-in.ts +196 -400
  133. package/src/setup/scenes/theme.ts +2 -0
  134. package/src/setup/scenes/types.ts +18 -1
  135. package/src/setup/startup-splash.ts +8 -7
  136. package/src/setup/wizard-overlay.ts +164 -35
  137. package/src/setup/wizard.ts +11 -2
  138. package/src/status-line/component.ts +4 -10
  139. package/src/status-line/context-usage.ts +72 -21
  140. package/src/status-line/host.ts +6 -2
  141. package/src/terminal.ts +24 -2
  142. package/src/theme/defaults.json +1 -0
  143. package/src/theme/loader.ts +1 -1
  144. package/src/theme/theme.d.ts +0 -23
  145. package/src/theme/theme.ts +2 -75
  146. package/src/tools/bash-interactive.d.ts +49 -0
  147. package/src/tools/bash-interactive.ts +6 -1
  148. package/src/tools/bash.d.ts +2 -0
  149. package/src/tools/bash.ts +2 -0
  150. package/src/tools/default-renderer.d.ts +6 -4
  151. package/src/tools/default-renderer.ts +9 -6
  152. package/src/tools/eval.ts +14 -4
  153. package/src/tools/irc.d.ts +6 -0
  154. package/src/tools/irc.ts +6 -0
  155. package/src/tools/job-widget.ts +13 -1
  156. package/src/tools/json-tree.d.ts +23 -4
  157. package/src/tools/json-tree.ts +132 -42
  158. package/src/tools/lsp.d.ts +2 -0
  159. package/src/tools/lsp.ts +36 -15
  160. package/src/tools/mcp.d.ts +6 -5
  161. package/src/tools/mcp.ts +20 -12
  162. package/src/tools/native-view.d.ts +1 -1
  163. package/src/tools/native-view.ts +1 -1
  164. package/src/tools/renderer.d.ts +2 -0
  165. package/src/tools/renderer.ts +2 -0
  166. package/src/tools/streaming-output.d.ts +11 -0
  167. package/src/tools/streaming-output.ts +41 -0
  168. package/src/tools/task.d.ts +9 -1
  169. package/src/tools/task.ts +59 -16
  170. package/src/tools/url-scheme-host.d.ts +17 -0
  171. package/src/tools/url-scheme-host.ts +21 -0
  172. package/src/tools/yield.d.ts +1 -1
  173. package/src/tools/yield.ts +18 -9
  174. package/src/tui.d.ts +7 -2
  175. package/src/tui.ts +43 -15
  176. package/dist/types/theme/defaults/index.d.ts +0 -10289
  177. package/src/theme/defaults/alabaster.json +0 -103
  178. package/src/theme/defaults/amethyst.json +0 -106
  179. package/src/theme/defaults/anthracite.json +0 -103
  180. package/src/theme/defaults/basalt.json +0 -101
  181. package/src/theme/defaults/birch.json +0 -105
  182. package/src/theme/defaults/dark-abyss.json +0 -101
  183. package/src/theme/defaults/dark-arctic.json +0 -114
  184. package/src/theme/defaults/dark-aurora.json +0 -105
  185. package/src/theme/defaults/dark-catppuccin.json +0 -117
  186. package/src/theme/defaults/dark-cavern.json +0 -101
  187. package/src/theme/defaults/dark-celestial.json +0 -116
  188. package/src/theme/defaults/dark-copper.json +0 -105
  189. package/src/theme/defaults/dark-cosmos.json +0 -100
  190. package/src/theme/defaults/dark-cyberpunk.json +0 -112
  191. package/src/theme/defaults/dark-dracula.json +0 -108
  192. package/src/theme/defaults/dark-eclipse.json +0 -101
  193. package/src/theme/defaults/dark-ember.json +0 -105
  194. package/src/theme/defaults/dark-equinox.json +0 -100
  195. package/src/theme/defaults/dark-forest.json +0 -106
  196. package/src/theme/defaults/dark-github.json +0 -115
  197. package/src/theme/defaults/dark-gruvbox.json +0 -122
  198. package/src/theme/defaults/dark-lavender.json +0 -105
  199. package/src/theme/defaults/dark-lunar.json +0 -99
  200. package/src/theme/defaults/dark-midnight.json +0 -105
  201. package/src/theme/defaults/dark-monochrome.json +0 -104
  202. package/src/theme/defaults/dark-monokai.json +0 -108
  203. package/src/theme/defaults/dark-nebula.json +0 -100
  204. package/src/theme/defaults/dark-neon-noir.json +0 -110
  205. package/src/theme/defaults/dark-nord.json +0 -108
  206. package/src/theme/defaults/dark-ocean.json +0 -111
  207. package/src/theme/defaults/dark-one.json +0 -110
  208. package/src/theme/defaults/dark-poimandres.json +0 -125
  209. package/src/theme/defaults/dark-rainforest.json +0 -101
  210. package/src/theme/defaults/dark-reef.json +0 -101
  211. package/src/theme/defaults/dark-retro.json +0 -102
  212. package/src/theme/defaults/dark-rose-pine.json +0 -106
  213. package/src/theme/defaults/dark-sakura.json +0 -105
  214. package/src/theme/defaults/dark-slate.json +0 -105
  215. package/src/theme/defaults/dark-solarized.json +0 -107
  216. package/src/theme/defaults/dark-solstice.json +0 -100
  217. package/src/theme/defaults/dark-starfall.json +0 -101
  218. package/src/theme/defaults/dark-sunset.json +0 -109
  219. package/src/theme/defaults/dark-swamp.json +0 -100
  220. package/src/theme/defaults/dark-synthwave.json +0 -113
  221. package/src/theme/defaults/dark-taiga.json +0 -101
  222. package/src/theme/defaults/dark-terminal.json +0 -105
  223. package/src/theme/defaults/dark-tokyo-night.json +0 -111
  224. package/src/theme/defaults/dark-tundra.json +0 -101
  225. package/src/theme/defaults/dark-twilight.json +0 -101
  226. package/src/theme/defaults/dark-volcanic.json +0 -101
  227. package/src/theme/defaults/graphite.json +0 -102
  228. package/src/theme/defaults/index.d.ts +0 -10289
  229. package/src/theme/defaults/index.ts +0 -203
  230. package/src/theme/defaults/light-arctic.json +0 -117
  231. package/src/theme/defaults/light-aurora-day.json +0 -101
  232. package/src/theme/defaults/light-canyon.json +0 -101
  233. package/src/theme/defaults/light-catppuccin.json +0 -116
  234. package/src/theme/defaults/light-cirrus.json +0 -100
  235. package/src/theme/defaults/light-coral.json +0 -105
  236. package/src/theme/defaults/light-cyberpunk.json +0 -106
  237. package/src/theme/defaults/light-dawn.json +0 -100
  238. package/src/theme/defaults/light-dunes.json +0 -101
  239. package/src/theme/defaults/light-eucalyptus.json +0 -105
  240. package/src/theme/defaults/light-forest.json +0 -110
  241. package/src/theme/defaults/light-frost.json +0 -105
  242. package/src/theme/defaults/light-github.json +0 -125
  243. package/src/theme/defaults/light-glacier.json +0 -101
  244. package/src/theme/defaults/light-gruvbox.json +0 -118
  245. package/src/theme/defaults/light-haze.json +0 -100
  246. package/src/theme/defaults/light-honeycomb.json +0 -105
  247. package/src/theme/defaults/light-lagoon.json +0 -101
  248. package/src/theme/defaults/light-lavender.json +0 -105
  249. package/src/theme/defaults/light-meadow.json +0 -101
  250. package/src/theme/defaults/light-mint.json +0 -105
  251. package/src/theme/defaults/light-monochrome.json +0 -111
  252. package/src/theme/defaults/light-ocean.json +0 -109
  253. package/src/theme/defaults/light-one.json +0 -109
  254. package/src/theme/defaults/light-opal.json +0 -101
  255. package/src/theme/defaults/light-orchard.json +0 -101
  256. package/src/theme/defaults/light-paper.json +0 -105
  257. package/src/theme/defaults/light-poimandres.json +0 -125
  258. package/src/theme/defaults/light-prism.json +0 -100
  259. package/src/theme/defaults/light-retro.json +0 -108
  260. package/src/theme/defaults/light-sand.json +0 -105
  261. package/src/theme/defaults/light-savanna.json +0 -101
  262. package/src/theme/defaults/light-solarized.json +0 -112
  263. package/src/theme/defaults/light-soleil.json +0 -100
  264. package/src/theme/defaults/light-sunset.json +0 -109
  265. package/src/theme/defaults/light-synthwave.json +0 -108
  266. package/src/theme/defaults/light-tokyo-night.json +0 -121
  267. package/src/theme/defaults/light-wetland.json +0 -101
  268. package/src/theme/defaults/light-zenith.json +0 -99
  269. package/src/theme/defaults/limestone.json +0 -104
  270. package/src/theme/defaults/mahogany.json +0 -107
  271. package/src/theme/defaults/marble.json +0 -103
  272. package/src/theme/defaults/obsidian.json +0 -101
  273. package/src/theme/defaults/onyx.json +0 -101
  274. package/src/theme/defaults/pearl.json +0 -103
  275. package/src/theme/defaults/porcelain.json +0 -101
  276. package/src/theme/defaults/quartz.json +0 -106
  277. package/src/theme/defaults/sandstone.json +0 -105
  278. package/src/theme/defaults/titanium.json +0 -100
@@ -0,0 +1,83 @@
1
+ import type { TspText } from "@linxiraos/pi-wire";
2
+ import { Spacer } from "../components/spacer";
3
+ import { Text } from "../components/text";
4
+ import { node, text } from "../native/describe";
5
+ import type { NativeNode } from "../native/node";
6
+ import { styledSpans } from "../native/spans";
7
+ import { theme } from "../theme";
8
+ import type { Component } from "../tui";
9
+ import { TranscriptBlock } from "./transcript-container";
10
+
11
+ /** How loud an inline transcript notice is; a native terminal styles it as `zeta.notice.<tone>`. */
12
+ export type NoticeTone = "info" | "success" | "warning" | "error";
13
+
14
+ /** Each tone's default icon. */
15
+ const ICONS: Readonly<Record<NoticeTone, string>> = {
16
+ info: "info",
17
+ success: "success",
18
+ warning: "warning",
19
+ error: "error",
20
+ };
21
+
22
+ /**
23
+ * The word a warning or error leads with: a text terminal writes it
24
+ * (`Warning: …`); a native row leaves it to the icon, whose name it becomes
25
+ * for screen readers.
26
+ */
27
+ const LABELS = { warning: "Warning", error: "Error" } as const;
28
+
29
+ /** Optional parts of a {@link noticeRow}. */
30
+ export interface NoticeRowOptions {
31
+ /** Icon name in place of the tone's own (`read` for a file read, `download` for an update). */
32
+ readonly icon?: string;
33
+ readonly key?: string;
34
+ }
35
+
36
+ /**
37
+ * One inline transcript notice for a native terminal (`zeta.notice.<tone>`): a
38
+ * leading icon beside the wrapped message. Warnings, errors, background-job
39
+ * completions and prompt file reads all draw as this row, so they read alike.
40
+ * The tone colors the icon (an info notice keeps it quiet); the message spans
41
+ * carry emphasis only (`path`, `mono`, `dim`), never the tone itself.
42
+ */
43
+ export function noticeRow(tone: NoticeTone, message: TspText, options: NoticeRowOptions = {}): NativeNode {
44
+ const icon = node("icon", {
45
+ name: options.icon ?? ICONS[tone],
46
+ tone: tone === "info" ? undefined : tone,
47
+ aria: tone === "warning" || tone === "error" ? LABELS[tone] : undefined,
48
+ });
49
+ return node(
50
+ "row",
51
+ { role: `zeta.notice.${tone}`, tone, gap: "sm", align: "start" },
52
+ [icon, text(message, { wrap: "word", grow: 1, shrink: 1 })],
53
+ options.key,
54
+ );
55
+ }
56
+
57
+ /**
58
+ * A transcript block that a native terminal draws as one {@link noticeRow}
59
+ * while a text terminal draws `ansi`.
60
+ */
61
+ export class TranscriptNotice extends TranscriptBlock {
62
+ readonly #native: NativeNode;
63
+
64
+ constructor(native: NativeNode, ansi: readonly Component[]) {
65
+ super();
66
+ for (const child of ansi) this.addChild(child);
67
+ this.#native = native;
68
+ }
69
+
70
+ /**
71
+ * `showWarning` / `showError`: a blank row and the `Warning: …` / `Error: …`
72
+ * line in its color in a text terminal; natively the tone's icon and the
73
+ * message, the label left to the icon.
74
+ */
75
+ static line(tone: "warning" | "error", message: string): TranscriptNotice {
76
+ const line = new Text(`${LABELS[tone]}: ${message}`, 1, 0).setStyleFn(t => theme.fg(tone, t));
77
+ return new TranscriptNotice(noticeRow(tone, styledSpans(message)), [new Spacer(1), line]);
78
+ }
79
+
80
+ override describe(): NativeNode {
81
+ return this.#native;
82
+ }
83
+ }
@@ -1,24 +1,36 @@
1
+ import type { TspSpan } from "@linxiraos/pi-wire";
1
2
  import type { NativeNode } from "../native/node";
2
3
  import { type ThemeColor } from "../theme";
3
4
  import { TranscriptBlock } from "./transcript-container";
4
- /** One themed run of a status row. */
5
+ import { type NoticeTone } from "./transcript-notice";
6
+ /** One themed run of a status row's terminal line. */
5
7
  export interface TranscriptStatusPart {
6
8
  readonly text: string;
7
9
  readonly color: ThemeColor;
8
- /** Glyph art (tree connectors) drawn only in rows; native terminals draw their own structure. */
9
- readonly rowsOnly?: boolean;
10
10
  }
11
- /** One compact transcript status row assembled from themed parts, joined by single spaces. */
11
+ /** A status row in a native terminal: its {@link noticeRow}'s tone, icon and message. */
12
+ export interface TranscriptStatusNative {
13
+ readonly tone: NoticeTone;
14
+ /** Icon name in place of the tone's own. */
15
+ readonly icon?: string;
16
+ readonly message: readonly TspSpan[];
17
+ }
18
+ /**
19
+ * One compact transcript status row: the terminal line's themed parts (joined
20
+ * by single spaces, glyphs and brackets included) and the same row natively.
21
+ */
12
22
  export interface TranscriptStatusRow {
13
23
  readonly parts: readonly (TranscriptStatusPart | undefined)[];
14
24
  readonly indent?: number;
25
+ readonly native: TranscriptStatusNative;
15
26
  }
16
- /** Shared compact status-pill block used by notices and background activity. */
27
+ /**
28
+ * Shared compact status block for background activity and prompt file reads:
29
+ * one themed line per row in a text terminal, one notice row per row natively
30
+ * (`zeta.status-block`).
31
+ */
17
32
  export declare class TranscriptStatusBlock extends TranscriptBlock {
18
33
  #private;
19
34
  constructor(rows: readonly TranscriptStatusRow[]);
20
- /** Append a supplemental line such as an artifact warning. */
21
- addLine(parts: readonly (TranscriptStatusPart | undefined)[], indent?: number): void;
22
- /** One wrapped text line per status row. */
23
35
  describe(): NativeNode;
24
36
  }
@@ -1,56 +1,56 @@
1
1
  import type { TspSpan } from "@linxiraos/pi-wire";
2
2
  import { Text } from "../components/text";
3
- import { col, span, text } from "../native/describe";
3
+ import { col } from "../native/describe";
4
4
  import type { NativeNode } from "../native/node";
5
5
  import { type ThemeColor, theme } from "../theme";
6
6
  import { TranscriptBlock } from "./transcript-container";
7
+ import { type NoticeTone, noticeRow } from "./transcript-notice";
7
8
 
8
- /** One themed run of a status row. */
9
+ /** One themed run of a status row's terminal line. */
9
10
  export interface TranscriptStatusPart {
10
11
  readonly text: string;
11
12
  readonly color: ThemeColor;
12
- /** Glyph art (tree connectors) drawn only in rows; native terminals draw their own structure. */
13
- readonly rowsOnly?: boolean;
14
13
  }
15
14
 
16
- /** One compact transcript status row assembled from themed parts, joined by single spaces. */
15
+ /** A status row in a native terminal: its {@link noticeRow}'s tone, icon and message. */
16
+ export interface TranscriptStatusNative {
17
+ readonly tone: NoticeTone;
18
+ /** Icon name in place of the tone's own. */
19
+ readonly icon?: string;
20
+ readonly message: readonly TspSpan[];
21
+ }
22
+
23
+ /**
24
+ * One compact transcript status row: the terminal line's themed parts (joined
25
+ * by single spaces, glyphs and brackets included) and the same row natively.
26
+ */
17
27
  export interface TranscriptStatusRow {
18
28
  readonly parts: readonly (TranscriptStatusPart | undefined)[];
19
29
  readonly indent?: number;
30
+ readonly native: TranscriptStatusNative;
20
31
  }
21
32
 
22
- /** Shared compact status-pill block used by notices and background activity. */
33
+ /**
34
+ * Shared compact status block for background activity and prompt file reads:
35
+ * one themed line per row in a text terminal, one notice row per row natively
36
+ * (`zeta.status-block`).
37
+ */
23
38
  export class TranscriptStatusBlock extends TranscriptBlock {
24
- readonly #rows: TspSpan[][] = [];
25
- #native: NativeNode | undefined;
39
+ readonly #native: NativeNode;
26
40
 
27
41
  constructor(rows: readonly TranscriptStatusRow[]) {
28
42
  super();
29
- for (const row of rows) this.addLine(row.parts, row.indent);
30
- }
31
-
32
- /** Append a supplemental line such as an artifact warning. */
33
- addLine(parts: readonly (TranscriptStatusPart | undefined)[], indent = 1): void {
34
- const styled: string[] = [];
35
- const spans: TspSpan[] = [];
36
- for (const part of parts) {
37
- if (!part) continue;
38
- styled.push(theme.fg(part.color, part.text));
39
- if (part.rowsOnly) continue;
40
- if (spans.length > 0) spans.push(span(" "));
41
- spans.push(span(part.text, part.color));
43
+ for (const row of rows) {
44
+ const styled = row.parts.flatMap(part => (part ? [theme.fg(part.color, part.text)] : []));
45
+ this.addChild(new Text(styled.join(" "), row.indent ?? 1, 0));
42
46
  }
43
- this.addChild(new Text(styled.join(" "), indent, 0));
44
- this.#rows.push(spans);
45
- this.#native = undefined;
47
+ this.#native = col(
48
+ rows.map(({ native }) => noticeRow(native.tone, native.message, { icon: native.icon })),
49
+ { role: "zeta.status-block" },
50
+ );
46
51
  }
47
52
 
48
- /** One wrapped text line per status row. */
49
53
  override describe(): NativeNode {
50
- this.#native ??= col(
51
- this.#rows.map(spans => text(spans, { wrap: "word" })),
52
- { role: "zeta.status-block" },
53
- );
54
54
  return this.#native;
55
55
  }
56
56
  }
@@ -98,6 +98,14 @@ export declare class Editor implements Component, Focusable {
98
98
  describeDecorations: ((lines: readonly string[]) => readonly TspEditorDecoration[]) | undefined;
99
99
  /** TSP code language of the buffer (`python`, `bash`): the terminal highlights it in the mono face. */
100
100
  describeLanguage: (() => string | undefined) | undefined;
101
+ /** Label the TSP field to disable host-side editing while another input owner handles raw keys. */
102
+ nativeKeyPassthrough: boolean;
103
+ /**
104
+ * Ask the TSP terminal to keep what is typed into this field and draw it at
105
+ * the caret until this clears, then send it: set while startup cannot read
106
+ * input yet (the prompt composer's deferred-input start).
107
+ */
108
+ nativeTypeahead: boolean;
101
109
  /**
102
110
  * TSP chrome around the `editor` node (the prompt composer's chips, mode
103
111
  * chip, send/stop): the root role, the children with `input` placed where
@@ -776,6 +776,14 @@ export class Editor implements Component, Focusable {
776
776
  describeDecorations: ((lines: readonly string[]) => readonly TspEditorDecoration[]) | undefined;
777
777
  /** TSP code language of the buffer (`python`, `bash`): the terminal highlights it in the mono face. */
778
778
  describeLanguage: (() => string | undefined) | undefined;
779
+ /** Label the TSP field to disable host-side editing while another input owner handles raw keys. */
780
+ nativeKeyPassthrough = false;
781
+ /**
782
+ * Ask the TSP terminal to keep what is typed into this field and draw it at
783
+ * the caret until this clears, then send it: set while startup cannot read
784
+ * input yet (the prompt composer's deferred-input start).
785
+ */
786
+ nativeTypeahead = false;
779
787
  /**
780
788
  * TSP chrome around the `editor` node (the prompt composer's chips, mode
781
789
  * chip, send/stop): the root role, the children with `input` placed where
@@ -1894,9 +1902,10 @@ export class Editor implements Component, Focusable {
1894
1902
  decor: decor.decor,
1895
1903
  ghost: ghost ? plainText(ghost) : undefined,
1896
1904
  placeholder: nativePlaceholder || undefined,
1897
- mode: vim ? VIM_MODE_LABELS[vim.mode] : undefined,
1905
+ mode: this.nativeKeyPassthrough ? "PTY" : vim ? VIM_MODE_LABELS[vim.mode] : undefined,
1898
1906
  lang: this.describeLanguage?.(),
1899
1907
  maxLines: this.#maxHeight,
1908
+ typeahead: this.nativeTypeahead || undefined,
1900
1909
  };
1901
1910
  let editor = this.#nativeEditor;
1902
1911
  if (!editor || !sameProps(editor.props, props)) {
@@ -10,6 +10,13 @@ import type { Component } from "../tui";
10
10
  * byte-identical to rendering `text`.
11
11
  */
12
12
  export declare function streamingMarkdownSource(text: string): string;
13
+ /**
14
+ * Whether `text` ends inside a code fence the source never closed. The
15
+ * renderer still draws such a fence's closing border, so a caller publishing a
16
+ * settled source prefix must drop that fabricated row: it is not a prefix of
17
+ * the live block, which reaches the border only once the closer arrives.
18
+ */
19
+ export declare function endsInsideOpenFence(text: string): boolean;
13
20
  /**
14
21
  * Streaming `md` source for a native terminal, minus a still-growing table row:
15
22
  * the unterminated last line when a GFM table (a run of pipe lines holding a
@@ -26,6 +26,12 @@ import { isBareMathEnvironment, latexToUnicode } from "../latex-to-unicode";
26
26
  import { plainText } from "../native/spans";
27
27
  import { md } from "../native/describe";
28
28
  import type { DescribeContext, NativeNode } from "../native/node";
29
+ import {
30
+ extensionLinkScheme,
31
+ extensionLinksVersion,
32
+ formatExtensionLink,
33
+ stripExtensionLinkMarkers,
34
+ } from "../render/extension-links";
29
35
  import type { SymbolTheme } from "../symbols";
30
36
  import { TERMINAL } from "../terminal-capabilities";
31
37
  import { getSymbolTheme, getThemeEpoch } from "../theme/theme";
@@ -136,6 +142,40 @@ function fenceOpenAt(text: string, end: number): boolean {
136
142
  return open !== undefined;
137
143
  }
138
144
 
145
+ /**
146
+ * Whether `text` ends inside a code fence the source never closed. The
147
+ * renderer still draws such a fence's closing border, so a caller publishing a
148
+ * settled source prefix must drop that fabricated row: it is not a prefix of
149
+ * the live block, which reaches the border only once the closer arrives.
150
+ */
151
+ export function endsInsideOpenFence(text: string): boolean {
152
+ return fenceOpenAt(text, text.length);
153
+ }
154
+
155
+ /**
156
+ * Offset of the settled prefix of the still-open fence that `text` ends in, or
157
+ * 0 when it holds none.
158
+ *
159
+ * An open fence's body only ever appends: nothing a later chunk adds can
160
+ * change a line that already ended. Those lines are therefore settled, and a
161
+ * stream may publish them into native scrollback instead of leaving the whole
162
+ * block in the mutable viewport until the closing fence finally arrives — a
163
+ * long streamed code block would otherwise lose every row that left the screen
164
+ * (#9780).
165
+ *
166
+ * The cut lands before the last complete line, not after it: a streamed chunk
167
+ * usually ends on a "\n", and the publisher requires non-blank source past the
168
+ * prefix it publishes, so cutting at the final "\n" would publish nothing on
169
+ * exactly those frames. Once the closing fence has arrived, the retained line
170
+ * is the one in front of it.
171
+ */
172
+ function settledFenceBodyEnd(text: string): number {
173
+ const lastBreak = text.lastIndexOf("\n");
174
+ if (lastBreak <= 0) return 0;
175
+ const cut = text.lastIndexOf("\n", lastBreak - 1) + 1;
176
+ return cut > 0 && fenceOpenAt(text, cut) ? cut : 0;
177
+ }
178
+
139
179
  /**
140
180
  * Streaming `md` source for a native terminal, minus a still-growing table row:
141
181
  * the unterminated last line when a GFM table (a run of pipe lines holding a
@@ -1354,6 +1394,15 @@ function inlineHasOpen(tokens: readonly Token[]): boolean {
1354
1394
  return false;
1355
1395
  }
1356
1396
 
1397
+ /** True when the inline token stream holds a link whose scheme an extension claimed. */
1398
+ function hasExtensionLink(tokens: readonly Token[]): boolean {
1399
+ for (const token of tokens) {
1400
+ if (token.type === "link" && typeof token.href === "string" && extensionLinkScheme(token.href)) return true;
1401
+ if ("tokens" in token && Array.isArray(token.tokens) && hasExtensionLink(token.tokens as Token[])) return true;
1402
+ }
1403
+ return false;
1404
+ }
1405
+
1357
1406
  /** Isolated inline lex of a same-line delta. A single-line delta has no block
1358
1407
  * structure, so the isolated inline pass equals the full lex's inline pass
1359
1408
  * (marked's paragraph tokens run the same `inlineTokens` entry point). */
@@ -2129,6 +2178,7 @@ interface RenderSignature {
2129
2178
  defaultTextStyleId: number;
2130
2179
  imageProtocol: string;
2131
2180
  hyperlinks: boolean;
2181
+ extensionLinks: number;
2132
2182
  textSizing: boolean;
2133
2183
  bgColorProbe: string;
2134
2184
  headingProbe: string;
@@ -2300,6 +2350,8 @@ export class Markdown implements Component {
2300
2350
  #cachedText?: string;
2301
2351
  #cachedWidth?: number;
2302
2352
  #cachedLines?: readonly string[];
2353
+ // Extension-link routing changes how links draw without changing text or width.
2354
+ #cachedExtensionLinks?: number;
2303
2355
  #transientRenderCache = false;
2304
2356
 
2305
2357
  // Streaming-lex cache: the largest blank-line-bounded prefix of #text whose
@@ -2322,6 +2374,12 @@ export class Markdown implements Component {
2322
2374
  // The frozen prefix's leading run in front of the first of those openers:
2323
2375
  // no append can change its tokens, so getLastRenderStableText publishes it.
2324
2376
  #streamSettledText?: string;
2377
+ // The complete lines inside a still-open fence, with the fence's opening
2378
+ // line in front of them: an open fence never reaches a "\n\n" boundary, so
2379
+ // #streamSettledText holds nothing for it and a long streamed code block
2380
+ // would stay unretirable until the closing fence arrived. Kept while the
2381
+ // source extends it, so the published prefix never shrinks.
2382
+ #streamFenceSettledText?: string;
2325
2383
  // The text in front of the newest top-level item of a list that is still
2326
2384
  // streaming as the last block. Once an item's marker line has ended, no
2327
2385
  // append can add to the items in front of it, and #renderList draws each
@@ -2373,6 +2431,9 @@ export class Markdown implements Component {
2373
2431
  #fastTail?: FastTailRecipe; // undefined = disarmed
2374
2432
  // B+ capture plumbing: #renderContentLines records the last rendered paragraph row.
2375
2433
  #lastTailCapture?: { kind: "paragraph"; open: boolean; rowInput: string; rowRaw: string };
2434
+ /** Top-level token index and running count of the extension links drawn in it; see `#renderContentLines`. */
2435
+ #extensionLinkBlock = 0;
2436
+ #extensionLinkOrdinal = 0;
2376
2437
  #ignoreTight = false;
2377
2438
  #native?: { text: string; stream: boolean; node: NativeNode };
2378
2439
  setIgnoreTight(ignore: boolean): this {
@@ -2517,9 +2578,31 @@ export class Markdown implements Component {
2517
2578
  */
2518
2579
  getLastRenderStableText(): string {
2519
2580
  if (!this.#transientRenderCache) return "";
2520
- const settled = this.#streamSettledText ?? "";
2581
+ // An open fence has no "\n\n" boundary, so the block walk above settles
2582
+ // nothing inside it. Its finished lines are settled all the same: no
2583
+ // append can change a line that already ended. Publish them, or a long
2584
+ // streamed code block (SQL, logs) stays unretirable in the mutable
2585
+ // viewport and its top rows are dropped as it outgrows the screen.
2586
+ const source = streamingMarkdownSource(this.#text);
2587
+ let fence = this.#streamFenceSettledText;
2588
+ if (fence !== undefined && !source.startsWith(fence)) {
2589
+ // A non-append edit rewound the text below what was published. Drop
2590
+ // the stored prefix as well: keeping it would fail this check on
2591
+ // every later frame and leave the block unretirable for the rest of
2592
+ // the stream.
2593
+ fence = undefined;
2594
+ this.#streamFenceSettledText = undefined;
2595
+ }
2596
+ const body = settledFenceBodyEnd(source);
2597
+ if (body > (fence?.length ?? 0)) {
2598
+ fence = source.slice(0, body);
2599
+ this.#streamFenceSettledText = fence;
2600
+ }
2601
+ let text = this.#streamSettledText ?? "";
2521
2602
  const list = this.#streamListSettledText;
2522
- return list !== undefined && list.length > settled.length ? list : settled;
2603
+ if (list !== undefined && list.length > text.length) text = list;
2604
+ if (fence !== undefined && fence.length > text.length) text = fence;
2605
+ return text;
2523
2606
  }
2524
2607
 
2525
2608
  get transientRenderCache(): boolean {
@@ -2553,6 +2636,7 @@ export class Markdown implements Component {
2553
2636
  this.#streamingHighlightCache = undefined;
2554
2637
  this.#streamingListCache = undefined;
2555
2638
  this.#streamRewound = undefined;
2639
+ this.#streamFenceSettledText = undefined;
2556
2640
  }
2557
2641
  this.invalidate();
2558
2642
  }
@@ -2914,7 +2998,12 @@ export class Markdown implements Component {
2914
2998
  // instance at the same width (e.g. resize debounce, repeated redraws).
2915
2999
  // Returning the cached reference is load-bearing: parents memoize their
2916
3000
  // concatenation on reference equality.
2917
- if (this.#cachedLines && this.#cachedText === this.#text && this.#cachedWidth === width) {
3001
+ if (
3002
+ this.#cachedLines &&
3003
+ this.#cachedText === this.#text &&
3004
+ this.#cachedWidth === width &&
3005
+ this.#cachedExtensionLinks === extensionLinksVersion()
3006
+ ) {
2918
3007
  return this.#cachedLines;
2919
3008
  }
2920
3009
 
@@ -2927,6 +3016,7 @@ export class Markdown implements Component {
2927
3016
  this.#cachedText = this.#text;
2928
3017
  this.#cachedWidth = width;
2929
3018
  this.#cachedLines = EMPTY_RENDER_LINES;
3019
+ this.#cachedExtensionLinks = extensionLinksVersion();
2930
3020
  return EMPTY_RENDER_LINES;
2931
3021
  }
2932
3022
 
@@ -3011,6 +3101,8 @@ export class Markdown implements Component {
3011
3101
  // into a table on a marker-free delta (`| --` + `--- | -`).
3012
3102
  !FAST_TABLE_DELIM_ROW_RE.test(grownLastLine) &&
3013
3103
  (!markerDelta || (!this.#lastTailCapture?.open && !pairSeamHazard && !inlineHasOpen(deltaTokens!))) &&
3104
+ // Extension link markers are numbered per block; a delta rendered alone can't continue that.
3105
+ !(deltaTokens && hasExtensionLink(deltaTokens)) &&
3014
3106
  !FAST_URL_ANYWHERE_RE.test(seamWindow) &&
3015
3107
  // A link or math span the grown row leaves open renders speculatively closed: re-lex.
3016
3108
  speculativeInlineClose(grownLastLine) === undefined
@@ -3051,6 +3143,7 @@ export class Markdown implements Component {
3051
3143
  this.#cachedText = this.#text;
3052
3144
  this.#cachedWidth = width;
3053
3145
  this.#cachedLines = fastResult;
3146
+ this.#cachedExtensionLinks = signature.extensionLinks;
3054
3147
  this.#fastTail = {
3055
3148
  lines: fastResult,
3056
3149
  source: this.#text,
@@ -3113,6 +3206,7 @@ export class Markdown implements Component {
3113
3206
  this.#cachedText = this.#text;
3114
3207
  this.#cachedWidth = width;
3115
3208
  this.#cachedLines = cached;
3209
+ this.#cachedExtensionLinks = signature.extensionLinks;
3116
3210
  return cached;
3117
3211
  }
3118
3212
  }
@@ -3146,6 +3240,7 @@ export class Markdown implements Component {
3146
3240
  this.#cachedText = this.#text;
3147
3241
  this.#cachedWidth = width;
3148
3242
  this.#cachedLines = result;
3243
+ this.#cachedExtensionLinks = signature.extensionLinks;
3149
3244
 
3150
3245
  const fastEligible =
3151
3246
  this.transientRenderCache &&
@@ -3200,6 +3295,7 @@ export class Markdown implements Component {
3200
3295
  defaultTextStyleId: this.#defaultTextStyle ? objectId(this.#defaultTextStyle) : -1,
3201
3296
  imageProtocol: TERMINAL.imageProtocol ?? "",
3202
3297
  hyperlinks: TERMINAL.hyperlinks,
3298
+ extensionLinks: extensionLinksVersion(),
3203
3299
  textSizing: TERMINAL.textSizing,
3204
3300
  bgColorProbe,
3205
3301
  headingProbe,
@@ -3212,7 +3308,7 @@ export class Markdown implements Component {
3212
3308
  }
3213
3309
 
3214
3310
  #renderCacheKey(normalizedText: string, signature: RenderSignature): string {
3215
- return `${normalizedText}\x00${signature.width}\x00${signature.paddingX}\x00${signature.paddingY}\x00${signature.codeBlockIndent}\x00${signature.themeId}\x00${signature.defaultTextStyleId}\x00${signature.imageProtocol}\x00${signature.hyperlinks ? 1 : 0}\x00${signature.textSizing ? 1 : 0}\x00${signature.bgColorProbe}\x00${signature.headingProbe}\x00${signature.symbolsProbe}`;
3311
+ return `${normalizedText}\x00${signature.width}\x00${signature.paddingX}\x00${signature.paddingY}\x00${signature.codeBlockIndent}\x00${signature.themeId}\x00${signature.defaultTextStyleId}\x00${signature.imageProtocol}\x00${signature.hyperlinks ? 1 : 0}\x00${signature.extensionLinks}\x00${signature.textSizing ? 1 : 0}\x00${signature.bgColorProbe}\x00${signature.headingProbe}\x00${signature.symbolsProbe}`;
3216
3312
  }
3217
3313
 
3218
3314
  #renderStreamingContentLines(
@@ -3288,6 +3384,7 @@ export class Markdown implements Component {
3288
3384
  if (cache.defaultTextStyleId !== signature.defaultTextStyleId) return undefined;
3289
3385
  if (cache.imageProtocol !== signature.imageProtocol) return undefined;
3290
3386
  if (cache.hyperlinks !== signature.hyperlinks) return undefined;
3387
+ if (cache.extensionLinks !== signature.extensionLinks) return undefined;
3291
3388
  if (cache.textSizing !== signature.textSizing) return undefined;
3292
3389
  if (cache.bgColorProbe !== signature.bgColorProbe) return undefined;
3293
3390
  if (cache.headingProbe !== signature.headingProbe) return undefined;
@@ -3378,6 +3475,7 @@ export class Markdown implements Component {
3378
3475
  if (cache.defaultTextStyleId !== signature.defaultTextStyleId) return start;
3379
3476
  if (cache.imageProtocol !== signature.imageProtocol) return start;
3380
3477
  if (cache.hyperlinks !== signature.hyperlinks) return start;
3478
+ if (cache.extensionLinks !== signature.extensionLinks) return start;
3381
3479
  if (cache.textSizing !== signature.textSizing) return start;
3382
3480
  if (cache.bgColorProbe !== signature.bgColorProbe) return start;
3383
3481
  if (cache.headingProbe !== signature.headingProbe) return start;
@@ -3412,6 +3510,10 @@ export class Markdown implements Component {
3412
3510
  const token = tokens[i];
3413
3511
  const nextToken = tokens[i + 1];
3414
3512
  const tokenWrappedRowStart = wrappedLines.length;
3513
+ // Extension links are numbered per top-level block, across its nested inline runs, so
3514
+ // identical links on neighbouring rows draw distinct markers that every render repeats.
3515
+ this.#extensionLinkBlock = i;
3516
+ this.#extensionLinkOrdinal = 0;
3415
3517
  const renderedTokenLines = this.#renderToken(token, contentWidth, nextToken?.type);
3416
3518
  for (const renderedRow of renderedTokenLines) {
3417
3519
  // Lists wrap while their structural prefixes are still available, so
@@ -3864,7 +3966,8 @@ export class Markdown implements Component {
3864
3966
  const headingText = this.#renderInlineTokens(token.tokens || [], this.#proseFgExemptContext(styleContext));
3865
3967
  const headingPlainText = plainInlineTokens(token.tokens || []);
3866
3968
  let styledHeading: string;
3867
- if (headingLevel === 1 && TERMINAL.textSizing) {
3969
+ // A sized heading draws plain text, which would drop a clickable extension link's marker.
3970
+ if (headingLevel === 1 && TERMINAL.textSizing && stripExtensionLinkMarkers(headingText) === headingText) {
3868
3971
  const plainWidth = visibleWidth(headingPlainText);
3869
3972
  if (plainWidth > 0 && 2 * plainWidth <= width) {
3870
3973
  const sizedHeading = encodeTextSizedHeading(headingPlainText, 2);
@@ -4183,8 +4286,15 @@ export class Markdown implements Component {
4183
4286
  token.tokens || [],
4184
4287
  this.#proseFgExemptContext(resolvedStyleContext),
4185
4288
  );
4186
- const styledLinkText = this.#theme.link(this.#theme.underline(linkText));
4187
4289
  const href = typeof token.href === "string" ? token.href : "";
4290
+ // An extension owns this link: no suffix, and no hyperlink the terminal could open.
4291
+ // Its label gets its own (dotted) underline instead of the web-link one.
4292
+ if (href && extensionLinkScheme(href)) {
4293
+ const key = `${this.#extensionLinkBlock}\0${this.#extensionLinkOrdinal++}`;
4294
+ result += formatExtensionLink(this.#theme.link(linkText), href, key) + stylePrefix;
4295
+ break;
4296
+ }
4297
+ const styledLinkText = this.#theme.link(this.#theme.underline(linkText));
4188
4298
  const target = (href && this.#theme.resolveLink?.(href)) || href;
4189
4299
  const clickableLinkText = formatHyperlink(styledLinkText, target);
4190
4300
  // If link text matches href, only show the link once. A missing
@@ -135,6 +135,7 @@ function hotkeyGroups(bindings: HotkeysMarkdownBindings): HotkeyGroup[] {
135
135
  { keys: [act("app.history.search")], action: "Search prompt history" },
136
136
  { keys: [act("app.tools.expand")], action: "Toggle tool output expansion" },
137
137
  { keys: [act("app.tools.toggleVisibility")], action: "Toggle tool activity visibility" },
138
+ { keys: [act("app.links.hint")], action: "Pick an extension link on screen by its tag" },
138
139
  { keys: [act("app.ask.hide")], action: "Hide/show a pending ask question" },
139
140
  { keys: [act("app.approval.approve")], action: "Approve a pending tool call" },
140
141
  { keys: [act("app.thinking.toggle")], action: "Toggle thinking block visibility" },