@oh-my-pi/pi-tui 18.13.2 → 18.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/CHANGELOG.md +40 -54
  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 +3 -3
  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 +41 -4
  31. package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
  32. package/dist/types/prompt/welcome.d.ts +6 -2
  33. package/dist/types/render/extension-links.d.ts +65 -0
  34. package/dist/types/render/hyperlink.d.ts +25 -7
  35. package/dist/types/render/index.d.ts +1 -0
  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/splash.d.ts +4 -4
  40. package/dist/types/setup/scenes/types.d.ts +16 -1
  41. package/dist/types/setup/startup-splash.d.ts +1 -1
  42. package/dist/types/setup/wizard-overlay.d.ts +11 -7
  43. package/dist/types/setup/wizard.d.ts +5 -1
  44. package/dist/types/status-line/component.d.ts +1 -1
  45. package/dist/types/status-line/context-usage.d.ts +28 -6
  46. package/dist/types/status-line/host.d.ts +6 -2
  47. package/dist/types/theme/theme.d.ts +0 -23
  48. package/dist/types/tools/bash-interactive.d.ts +6 -0
  49. package/dist/types/tools/bash.d.ts +2 -0
  50. package/dist/types/tools/default-renderer.d.ts +6 -4
  51. package/dist/types/tools/irc.d.ts +6 -0
  52. package/dist/types/tools/json-tree.d.ts +23 -4
  53. package/dist/types/tools/lsp.d.ts +2 -0
  54. package/dist/types/tools/mcp.d.ts +6 -5
  55. package/dist/types/tools/native-view.d.ts +1 -1
  56. package/dist/types/tools/renderer.d.ts +2 -0
  57. package/dist/types/tools/streaming-output.d.ts +11 -0
  58. package/dist/types/tools/task.d.ts +9 -1
  59. package/dist/types/tools/url-scheme-host.d.ts +17 -0
  60. package/dist/types/tools/yield.d.ts +1 -1
  61. package/dist/types/tui.d.ts +7 -2
  62. package/package.json +10 -15
  63. package/src/app-keybindings.ts +15 -0
  64. package/src/apps/session-picker.ts +7 -0
  65. package/src/charts/chart-plan.ts +20 -50
  66. package/src/chat/advisor-message.ts +2 -0
  67. package/src/chat/assistant-message.ts +137 -19
  68. package/src/chat/background-tan-message.ts +4 -0
  69. package/src/chat/bash-execution.ts +6 -0
  70. package/src/chat/chat-transcript-builder.ts +58 -28
  71. package/src/chat/compaction-summary-message.ts +2 -1
  72. package/src/chat/display-preferences.ts +3 -0
  73. package/src/chat/extension-types.ts +34 -0
  74. package/src/chat/reply-write.ts +127 -0
  75. package/src/chat/table-chart.ts +10 -4
  76. package/src/chat/tool-execution.ts +20 -13
  77. package/src/chat/transcript-outline.ts +27 -0
  78. package/src/chat/transcript-render-helpers.ts +66 -24
  79. package/src/chrome/index.ts +1 -0
  80. package/src/chrome/transcript-notice.ts +83 -0
  81. package/src/chrome/transcript-status.ts +29 -29
  82. package/src/components/editor.ts +10 -1
  83. package/src/components/markdown.ts +116 -6
  84. package/src/hotkeys-markdown.ts +1 -0
  85. package/src/native/backend.ts +5 -66
  86. package/src/native/blobs.ts +3 -2
  87. package/src/native/picker.ts +3 -3
  88. package/src/overlays/advisor-config.ts +1 -10
  89. package/src/overlays/annotation-overlay.ts +125 -37
  90. package/src/overlays/annotation-types.ts +24 -0
  91. package/src/overlays/hook-selector.ts +2 -2
  92. package/src/overlays/login-dialog.ts +31 -5
  93. package/src/overlays/model-browser.ts +37 -0
  94. package/src/overlays/model-hub.ts +1 -7
  95. package/src/overlays/model-picker.ts +1 -10
  96. package/src/overlays/oauth-selector.ts +44 -6
  97. package/src/overlays/plan-review-overlay.ts +13 -2
  98. package/src/overlays/rewind-selector.ts +29 -12
  99. package/src/overlays/session-selector.ts +305 -39
  100. package/src/overlays/usage-dashboard.ts +5 -12
  101. package/src/prompt/composer.ts +213 -5
  102. package/src/prompt/custom-editor.ts +6 -1
  103. package/src/prompt/emoji-autocomplete.ts +0 -2
  104. package/src/prompt/interactive-context-helpers.ts +29 -4
  105. package/src/prompt/welcome.ts +31 -45
  106. package/src/render/extension-links.ts +214 -0
  107. package/src/render/hyperlink.ts +65 -9
  108. package/src/render/index.ts +1 -0
  109. package/src/setup/scenes/composer.ts +2 -0
  110. package/src/setup/scenes/glyph.ts +2 -0
  111. package/src/setup/scenes/model.ts +192 -29
  112. package/src/setup/scenes/outro.ts +30 -17
  113. package/src/setup/scenes/sign-in.ts +196 -400
  114. package/src/setup/scenes/splash.ts +25 -21
  115. package/src/setup/scenes/theme.ts +2 -0
  116. package/src/setup/scenes/types.ts +18 -1
  117. package/src/setup/startup-splash.ts +8 -7
  118. package/src/setup/wizard-overlay.ts +164 -33
  119. package/src/setup/wizard.ts +11 -2
  120. package/src/status-line/component.ts +4 -10
  121. package/src/status-line/context-usage.ts +72 -21
  122. package/src/status-line/host.ts +6 -2
  123. package/src/terminal.ts +24 -2
  124. package/src/theme/defaults.json +1 -0
  125. package/src/theme/loader.ts +1 -1
  126. package/src/theme/theme.ts +2 -75
  127. package/src/tools/bash-interactive.ts +6 -1
  128. package/src/tools/bash.ts +2 -0
  129. package/src/tools/default-renderer.ts +9 -6
  130. package/src/tools/eval.ts +14 -4
  131. package/src/tools/irc.ts +6 -0
  132. package/src/tools/job-widget.ts +13 -1
  133. package/src/tools/json-tree.ts +132 -42
  134. package/src/tools/lsp.ts +36 -15
  135. package/src/tools/mcp.ts +20 -12
  136. package/src/tools/native-view.ts +1 -1
  137. package/src/tools/renderer.ts +2 -0
  138. package/src/tools/streaming-output.ts +41 -0
  139. package/src/tools/task.ts +59 -17
  140. package/src/tools/url-scheme-host.ts +21 -0
  141. package/src/tools/yield.ts +18 -9
  142. package/src/tui.ts +43 -15
  143. package/THIRD-PARTY-NOTICES.txt +0 -22901
  144. package/dist/types/theme/defaults/index.d.ts +0 -10289
  145. package/src/theme/defaults/alabaster.json +0 -103
  146. package/src/theme/defaults/amethyst.json +0 -106
  147. package/src/theme/defaults/anthracite.json +0 -103
  148. package/src/theme/defaults/basalt.json +0 -101
  149. package/src/theme/defaults/birch.json +0 -105
  150. package/src/theme/defaults/dark-abyss.json +0 -101
  151. package/src/theme/defaults/dark-arctic.json +0 -114
  152. package/src/theme/defaults/dark-aurora.json +0 -105
  153. package/src/theme/defaults/dark-catppuccin.json +0 -117
  154. package/src/theme/defaults/dark-cavern.json +0 -101
  155. package/src/theme/defaults/dark-celestial.json +0 -116
  156. package/src/theme/defaults/dark-copper.json +0 -105
  157. package/src/theme/defaults/dark-cosmos.json +0 -100
  158. package/src/theme/defaults/dark-cyberpunk.json +0 -112
  159. package/src/theme/defaults/dark-dracula.json +0 -108
  160. package/src/theme/defaults/dark-eclipse.json +0 -101
  161. package/src/theme/defaults/dark-ember.json +0 -105
  162. package/src/theme/defaults/dark-equinox.json +0 -100
  163. package/src/theme/defaults/dark-forest.json +0 -106
  164. package/src/theme/defaults/dark-github.json +0 -115
  165. package/src/theme/defaults/dark-gruvbox.json +0 -122
  166. package/src/theme/defaults/dark-lavender.json +0 -105
  167. package/src/theme/defaults/dark-lunar.json +0 -99
  168. package/src/theme/defaults/dark-midnight.json +0 -105
  169. package/src/theme/defaults/dark-monochrome.json +0 -104
  170. package/src/theme/defaults/dark-monokai.json +0 -108
  171. package/src/theme/defaults/dark-nebula.json +0 -100
  172. package/src/theme/defaults/dark-neon-noir.json +0 -110
  173. package/src/theme/defaults/dark-nord.json +0 -108
  174. package/src/theme/defaults/dark-ocean.json +0 -111
  175. package/src/theme/defaults/dark-one.json +0 -110
  176. package/src/theme/defaults/dark-poimandres.json +0 -125
  177. package/src/theme/defaults/dark-rainforest.json +0 -101
  178. package/src/theme/defaults/dark-reef.json +0 -101
  179. package/src/theme/defaults/dark-retro.json +0 -102
  180. package/src/theme/defaults/dark-rose-pine.json +0 -106
  181. package/src/theme/defaults/dark-sakura.json +0 -105
  182. package/src/theme/defaults/dark-slate.json +0 -105
  183. package/src/theme/defaults/dark-solarized.json +0 -107
  184. package/src/theme/defaults/dark-solstice.json +0 -100
  185. package/src/theme/defaults/dark-starfall.json +0 -101
  186. package/src/theme/defaults/dark-sunset.json +0 -109
  187. package/src/theme/defaults/dark-swamp.json +0 -100
  188. package/src/theme/defaults/dark-synthwave.json +0 -113
  189. package/src/theme/defaults/dark-taiga.json +0 -101
  190. package/src/theme/defaults/dark-terminal.json +0 -105
  191. package/src/theme/defaults/dark-tokyo-night.json +0 -111
  192. package/src/theme/defaults/dark-tundra.json +0 -101
  193. package/src/theme/defaults/dark-twilight.json +0 -101
  194. package/src/theme/defaults/dark-volcanic.json +0 -101
  195. package/src/theme/defaults/graphite.json +0 -102
  196. package/src/theme/defaults/index.ts +0 -203
  197. package/src/theme/defaults/light-arctic.json +0 -117
  198. package/src/theme/defaults/light-aurora-day.json +0 -101
  199. package/src/theme/defaults/light-canyon.json +0 -101
  200. package/src/theme/defaults/light-catppuccin.json +0 -116
  201. package/src/theme/defaults/light-cirrus.json +0 -100
  202. package/src/theme/defaults/light-coral.json +0 -105
  203. package/src/theme/defaults/light-cyberpunk.json +0 -106
  204. package/src/theme/defaults/light-dawn.json +0 -100
  205. package/src/theme/defaults/light-dunes.json +0 -101
  206. package/src/theme/defaults/light-eucalyptus.json +0 -105
  207. package/src/theme/defaults/light-forest.json +0 -110
  208. package/src/theme/defaults/light-frost.json +0 -105
  209. package/src/theme/defaults/light-github.json +0 -125
  210. package/src/theme/defaults/light-glacier.json +0 -101
  211. package/src/theme/defaults/light-gruvbox.json +0 -118
  212. package/src/theme/defaults/light-haze.json +0 -100
  213. package/src/theme/defaults/light-honeycomb.json +0 -105
  214. package/src/theme/defaults/light-lagoon.json +0 -101
  215. package/src/theme/defaults/light-lavender.json +0 -105
  216. package/src/theme/defaults/light-meadow.json +0 -101
  217. package/src/theme/defaults/light-mint.json +0 -105
  218. package/src/theme/defaults/light-monochrome.json +0 -111
  219. package/src/theme/defaults/light-ocean.json +0 -109
  220. package/src/theme/defaults/light-one.json +0 -109
  221. package/src/theme/defaults/light-opal.json +0 -101
  222. package/src/theme/defaults/light-orchard.json +0 -101
  223. package/src/theme/defaults/light-paper.json +0 -105
  224. package/src/theme/defaults/light-poimandres.json +0 -125
  225. package/src/theme/defaults/light-prism.json +0 -100
  226. package/src/theme/defaults/light-retro.json +0 -108
  227. package/src/theme/defaults/light-sand.json +0 -105
  228. package/src/theme/defaults/light-savanna.json +0 -101
  229. package/src/theme/defaults/light-solarized.json +0 -112
  230. package/src/theme/defaults/light-soleil.json +0 -100
  231. package/src/theme/defaults/light-sunset.json +0 -109
  232. package/src/theme/defaults/light-synthwave.json +0 -108
  233. package/src/theme/defaults/light-tokyo-night.json +0 -121
  234. package/src/theme/defaults/light-wetland.json +0 -101
  235. package/src/theme/defaults/light-zenith.json +0 -99
  236. package/src/theme/defaults/limestone.json +0 -104
  237. package/src/theme/defaults/mahogany.json +0 -107
  238. package/src/theme/defaults/marble.json +0 -103
  239. package/src/theme/defaults/obsidian.json +0 -101
  240. package/src/theme/defaults/onyx.json +0 -101
  241. package/src/theme/defaults/pearl.json +0 -103
  242. package/src/theme/defaults/porcelain.json +0 -101
  243. package/src/theme/defaults/quartz.json +0 -106
  244. package/src/theme/defaults/sandstone.json +0 -105
  245. package/src/theme/defaults/titanium.json +0 -100
@@ -5,13 +5,16 @@
5
5
  * here keeps the two byte-for-byte identical.
6
6
  */
7
7
  import type { AgentMessage } from "@oh-my-pi/pi-agent-core";
8
+ import type { TspSpan } from "@oh-my-pi/pi-wire";
8
9
  import { type Component } from "../tui";
9
- import { formatBytes, formatDuration } from "@oh-my-pi/pi-utils";
10
+ import { formatBytes, formatCount, formatDuration } from "@oh-my-pi/pi-utils";
11
+ import { span } from "../native/describe";
10
12
  import type { JobSnapshot } from "../tools/wait";
11
13
  import type { DaemonSnapshot } from "../tools/daemon";
12
14
  import { type CustomMessage, type FileMentionMessage, resolveAbortLabel, shouldRenderAbortReason } from "./messages";
13
15
  import { createIrcMessageCard } from "../tools/wait";
14
16
  import { formatArtifactErrorNotice, type OutputMeta } from "../tools/output-meta";
17
+ import type { OutputArtifactError } from "../tools/streaming-output";
15
18
  import { replaceTabs, TRUNCATE_LENGTHS, truncateToWidth } from "../render/render-utils";
16
19
  import { canonicalizeMessage } from "./thinking-display";
17
20
  import { ToolActivityContainer } from "../chrome/tool-activity";
@@ -58,26 +61,40 @@ export function buildAsyncResultBlock(message: CustomOrHookMessage): ToolActivit
58
61
  const rows: TranscriptStatusRow[] = [];
59
62
  for (const job of jobs) {
60
63
  const jobId = job.jobId ?? "unknown";
61
- const typeLabel = job.type ? `[${job.type}]` : "[job]";
64
+ const type = job.type ?? "job";
62
65
  const duration = typeof job.durationMs === "number" ? formatDuration(job.durationMs) : undefined;
63
66
  rows.push({
64
67
  parts: [
65
68
  { text: `${theme.status.done} Background job completed`, color: "success" },
66
- { text: typeLabel, color: "dim" },
69
+ { text: `[${type}]`, color: "dim" },
67
70
  { text: jobId, color: "accent" },
68
71
  duration ? { text: `(${duration})`, color: "dim" } : undefined,
69
72
  ],
73
+ native: {
74
+ tone: "success",
75
+ message: [span("Background job completed"), ...facts([type, jobId, duration])],
76
+ },
70
77
  });
71
- if (job.meta?.artifactError) {
72
- rows.push({ parts: [{ text: formatArtifactErrorNotice(job.meta.artifactError), color: "warning" }] });
73
- }
74
- }
75
- if (details?.meta?.artifactError) {
76
- rows.push({ parts: [{ text: formatArtifactErrorNotice(details.meta.artifactError), color: "warning" }] });
78
+ if (job.meta?.artifactError) rows.push(artifactErrorRow(job.meta.artifactError));
77
79
  }
80
+ if (details?.meta?.artifactError) rows.push(artifactErrorRow(details.meta.artifactError));
78
81
  return new ToolActivityContainer(new TranscriptStatusBlock(rows));
79
82
  }
80
83
 
84
+ /** The warning row under a background job whose output artifact could not be saved. */
85
+ function artifactErrorRow(error: OutputArtifactError): TranscriptStatusRow {
86
+ const notice = formatArtifactErrorNotice(error);
87
+ return { parts: [{ text: notice, color: "warning" }], native: { tone: "warning", message: [span(notice)] } };
88
+ }
89
+
90
+ /**
91
+ * Native notice spans for a row's trailing facts (kind, id, duration): each
92
+ * after a dim ` · `, absent ones skipped.
93
+ */
94
+ function facts(values: readonly (string | undefined)[]): TspSpan[] {
95
+ return values.flatMap(value => (value ? [span(" · ", "dim"), span(value, "dim")] : []));
96
+ }
97
+
81
98
  /**
82
99
  * Render a `launch-completion` custom message (terminal supervised-process
83
100
  * exits from the launch broker) as a transcript block of one compact
@@ -88,10 +105,15 @@ export function buildLaunchCompletionBlock(message: CustomOrHookMessage): ToolAc
88
105
  const rows: TranscriptStatusRow[] = [];
89
106
  const daemons = details?.daemons ?? [];
90
107
  if (daemons.length === 0 && typeof message.content === "string") {
91
- rows.push({ parts: [{ text: `${theme.status.done} ${message.content}`, color: "dim" }] });
108
+ rows.push({
109
+ parts: [{ text: `${theme.status.done} ${message.content}`, color: "dim" }],
110
+ native: { tone: "success", message: [span(message.content)] },
111
+ });
92
112
  }
93
113
  for (const daemon of daemons) {
94
114
  const failed = daemon.state === "failed" || (daemon.exitCode !== undefined && daemon.exitCode !== 0);
115
+ const label = failed ? "Supervised process failed" : "Supervised process completed";
116
+ const exit = daemon.exitCode !== undefined ? `exit ${daemon.exitCode}` : undefined;
95
117
  const duration =
96
118
  daemon.exitedAt !== undefined && daemon.startedAt !== undefined
97
119
  ? formatDuration(daemon.exitedAt - daemon.startedAt)
@@ -99,12 +121,16 @@ export function buildLaunchCompletionBlock(message: CustomOrHookMessage): ToolAc
99
121
  rows.push({
100
122
  parts: [
101
123
  failed
102
- ? { text: `${theme.status.error} Supervised process failed`, color: "error" }
103
- : { text: `${theme.status.done} Supervised process completed`, color: "success" },
124
+ ? { text: `${theme.status.error} ${label}`, color: "error" }
125
+ : { text: `${theme.status.done} ${label}`, color: "success" },
104
126
  { text: daemon.name, color: "accent" },
105
- daemon.exitCode !== undefined ? { text: `(exit ${daemon.exitCode})`, color: "dim" } : undefined,
127
+ exit ? { text: `(${exit})`, color: "dim" } : undefined,
106
128
  duration ? { text: `(${duration})`, color: "dim" } : undefined,
107
129
  ],
130
+ native: {
131
+ tone: failed ? "error" : "success",
132
+ message: [span(label), span(" "), span(daemon.name, "mono"), ...facts([exit, duration])],
133
+ },
108
134
  });
109
135
  }
110
136
  return new ToolActivityContainer(new TranscriptStatusBlock(rows));
@@ -160,25 +186,30 @@ export function buildIrcMessageCard(message: CustomOrHookMessage, getExpanded: (
160
186
  export function buildFileMentionBlock(files: FileMentionMessage["files"], indent: number): TranscriptBlock {
161
187
  const rows: TranscriptStatusRow[] = [];
162
188
  for (const file of files) {
163
- let suffix: string;
189
+ let detail: string;
164
190
  if (file.skippedReason === "tooLarge" || file.skippedReason === "binary") {
165
191
  const size = typeof file.byteSize === "number" ? formatBytes(file.byteSize) : "unknown size";
166
- suffix = file.skippedReason === "binary" ? `(skipped: binary, ${size})` : `(skipped: ${size})`;
192
+ detail = file.skippedReason === "binary" ? `skipped: binary, ${size}` : `skipped: ${size}`;
167
193
  } else {
168
- suffix = file.image
169
- ? "(image)"
194
+ detail = file.image
195
+ ? "image"
170
196
  : file.lineCount === undefined
171
- ? "(unknown lines)"
172
- : `(${file.lineCount} lines)`;
197
+ ? "unknown lines"
198
+ : formatCount("line", file.lineCount);
173
199
  }
174
200
  rows.push({
175
201
  parts: [
176
- { text: theme.tree.last, color: "dim", rowsOnly: true },
202
+ { text: theme.tree.last, color: "dim" },
177
203
  { text: "Read", color: "muted" },
178
204
  { text: file.path, color: "accent" },
179
- { text: suffix, color: "dim" },
205
+ { text: `(${detail})`, color: "dim" },
180
206
  ],
181
207
  indent,
208
+ native: {
209
+ tone: "info",
210
+ icon: "read",
211
+ message: [span("Read"), span(" "), span(file.path, "path"), ...facts([detail])],
212
+ },
182
213
  });
183
214
  }
184
215
  return new TranscriptStatusBlock(rows);
@@ -207,11 +238,14 @@ export function assistantHasVisibleContent(message: AssistantAgentMessage): bool
207
238
  export function splitAssistantMessageToolTimeline(message: AssistantAgentMessage): {
208
239
  beforeTools: AssistantAgentMessage;
209
240
  afterToolCalls: ReadonlyMap<string, AssistantAgentMessage>;
241
+ /** Index in `message.content` of each after-tool segment's first block, by tool-call id. */
242
+ contentOffsets: ReadonlyMap<string, number>;
210
243
  hasToolCalls: boolean;
211
244
  lastToolCallId?: string;
212
245
  } {
213
246
  const beforeTools: AssistantAgentMessage["content"] = [];
214
247
  const afterToolCalls = new Map<string, AssistantAgentMessage>();
248
+ const contentOffsets = new Map<string, number>();
215
249
  let pendingAfterTool: AssistantAgentMessage["content"] = [];
216
250
  let lastToolCallId: string | undefined;
217
251
  let sawToolCall = false;
@@ -230,11 +264,13 @@ export function splitAssistantMessageToolTimeline(message: AssistantAgentMessage
230
264
  pendingAfterTool = [];
231
265
  };
232
266
 
233
- for (const content of message.content) {
267
+ for (let index = 0; index < message.content.length; index++) {
268
+ const content = message.content[index]!;
234
269
  if (content.type === "toolCall") {
235
270
  flushPendingAfterTool();
236
271
  sawToolCall = true;
237
272
  lastToolCallId = content.id;
273
+ contentOffsets.set(content.id, index + 1);
238
274
  continue;
239
275
  }
240
276
  if (sawToolCall) {
@@ -246,10 +282,16 @@ export function splitAssistantMessageToolTimeline(message: AssistantAgentMessage
246
282
  flushPendingAfterTool();
247
283
 
248
284
  if (!sawToolCall) {
249
- return { beforeTools: message, afterToolCalls, hasToolCalls: false };
285
+ return { beforeTools: message, afterToolCalls, contentOffsets, hasToolCalls: false };
250
286
  }
251
287
 
252
- return { beforeTools: displaySegment(beforeTools), afterToolCalls, hasToolCalls: true, lastToolCallId };
288
+ return {
289
+ beforeTools: displaySegment(beforeTools),
290
+ afterToolCalls,
291
+ contentOffsets,
292
+ hasToolCalls: true,
293
+ lastToolCallId,
294
+ };
253
295
  }
254
296
 
255
297
  /**
@@ -17,5 +17,6 @@ export * from "./shared";
17
17
  export * from "./streaming-panel";
18
18
  export * from "./tool-activity";
19
19
  export * from "./transcript-container";
20
+ export * from "./transcript-notice";
20
21
  export * from "./transcript-status";
21
22
  export * from "./visual-truncate";
@@ -0,0 +1,83 @@
1
+ import type { TspText } from "@oh-my-pi/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 `omp.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 (`omp.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: `omp.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,56 +1,56 @@
1
1
  import type { TspSpan } from "@oh-my-pi/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
+ * (`omp.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: "omp.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: "omp.status-block" },
53
- );
54
54
  return this.#native;
55
55
  }
56
56
  }
@@ -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)) {
@@ -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