@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
@@ -489,6 +489,8 @@ export const themeSetupScene: SetupScene = {
489
489
  get title(): string {
490
490
  return tuiText("setupThemeTitle", "Pick a theme");
491
491
  },
492
+ step: "Theme",
492
493
  minVersion: 1,
494
+ ansiOnly: true,
493
495
  mount: host => new ThemeSceneController(host),
494
496
  };
@@ -39,7 +39,6 @@ export interface SetupHost extends SetupUiHost {
39
39
  saveColorBlindMode(enabled: boolean): void;
40
40
  saveTheme(mode: "dark" | "light", name: string): void;
41
41
  captureBrowserSession(request: OAuthBrowserSessionRequest, signal?: AbortSignal): Promise<string>;
42
- copyToClipboard(text: string): Promise<void>;
43
42
  openInBrowser(url: string): void;
44
43
  markComplete(version: number): Promise<void>;
45
44
  playWelcomeIntro(): void;
@@ -81,11 +80,29 @@ export interface SetupSceneController extends Component {
81
80
  routeMouse?(event: SgrMouseEvent, line: number, col: number): void;
82
81
  }
83
82
 
83
+ /**
84
+ * Role of the sheet (`picker` or `overlay`) an interactive scene presents in a
85
+ * TSP terminal. The terminal's setup stylesheet seats it under the wizard's
86
+ * brand and stepper instead of floating it over a dimmed page.
87
+ */
88
+ export const SETUP_SHEET_ROLE = "zeta.setup.sheet";
89
+
90
+ /** Surface role of the setup page (wizard and startup splash) in a TSP terminal. */
91
+ export const SETUP_SURFACE_ROLE = "zeta.app.setup";
92
+
84
93
  /** Versioned onboarding scene definition. */
85
94
  export interface SetupScene {
86
95
  id: string;
87
96
  title: string;
97
+ /** Short label for the wizard's stepper (`Sign in`, `Model`). */
98
+ step: string;
88
99
  minVersion: number;
100
+ /**
101
+ * Configures something only the cell-grid renderer draws (glyphs, composer
102
+ * shape, theme). A TSP terminal draws those itself, so the wizard skips the
103
+ * scene while a native surface is live.
104
+ */
105
+ ansiOnly?: boolean;
89
106
  shouldRun?(ctx: SetupHost): boolean | Promise<boolean>;
90
107
  mount(host: SetupSceneHost): SetupSceneController;
91
108
  }
@@ -1,10 +1,8 @@
1
1
  import { type Component, type OverlayFocusOwner } from "../tui";
2
2
  import { matchesKey } from "../keys";
3
- import { col } from "../native/describe";
4
- import type { NativeNode, NativeUiEvent } from "../native/node";
5
- import { Memo } from "../native/memo";
3
+ import type { NativeNode, NativeScreen, NativeUiEvent } from "../native/node";
6
4
  import { isNativeRendering } from "../native/state";
7
- import type { SetupUiHost } from "./scenes/types";
5
+ import { SETUP_SURFACE_ROLE, type SetupUiHost } from "./scenes/types";
8
6
  import { describeSetupSplash, renderSetupSplash, SETUP_SPLASH_MS, SETUP_TICK_MS } from "./scenes/splash";
9
7
 
10
8
  /** Timing controls for the standalone startup animation. */
@@ -19,7 +17,6 @@ class StartupSplashComponent implements Component, OverlayFocusOwner {
19
17
  #timer: NodeJS.Timeout | undefined;
20
18
  /** Native path: one-shot at the end of the splash; the terminal clocks the motion. */
21
19
  #deadline: NodeJS.Timeout | undefined;
22
- #native = new Memo();
23
20
  #done = Promise.withResolvers<void>();
24
21
  #disposed = false;
25
22
  readonly #durationMs: number;
@@ -67,9 +64,13 @@ class StartupSplashComponent implements Component, OverlayFocusOwner {
67
64
  return renderSetupSplash(Math.max(1, width), Math.max(1, this.ctx.ui.terminal.rows), elapsedMs);
68
65
  }
69
66
 
67
+ /** The setup page's splash, on a screen surface of the setup page's role. */
68
+ describeScreen(): NativeScreen {
69
+ return { role: SETUP_SURFACE_ROLE, main: [this], dock: [] };
70
+ }
71
+
70
72
  describe(): NativeNode {
71
- const splash = describeSetupSplash();
72
- return this.#native.get([splash], () => col([splash], { grow: 1, role: "zeta.app.startup-splash" }));
73
+ return describeSetupSplash();
73
74
  }
74
75
 
75
76
  handleNativeEvent(event: NativeUiEvent): void {
@@ -7,16 +7,23 @@ import { padToWidth } from "../render/utils";
7
7
  import { tuiText, tuiTextFmt } from "../i18n";
8
8
  import { routeSgrMouseInput, type SgrMouseEvent } from "../mouse";
9
9
  import { APP_NAME } from "@linxiraos/pi-utils";
10
- import { gradientLogo, logoNode, ZETA_LOGO } from "../prompt/welcome";
10
+ import { gradientLogo, ZETA_LOGO } from "../prompt/welcome";
11
11
  import { theme } from "../theme/theme";
12
- import { col, node, span, text } from "../native/describe";
13
- import type { NativeNode, NativeUiEvent } from "../native/node";
12
+ import { col, keyed, node, row, span, text } from "../native/describe";
13
+ import type { DescribeContext, NativeChild, NativeNode, NativeScreen, NativeUiEvent } from "../native/node";
14
14
  import { Memo } from "../native/memo";
15
+ import { actionButton } from "../native/overlay";
15
16
  import { isNativeRendering } from "../native/state";
16
17
  import type { SetupHost } from "./scenes/types";
17
18
  import { describeSetupOutro, renderSetupOutro, SETUP_OUTRO_MS } from "./scenes/outro";
18
19
  import { describeSetupSplash, renderSetupSplash, SETUP_SPLASH_MS, SETUP_TICK_MS } from "./scenes/splash";
19
- import type { SetupScene, SetupSceneController, SetupSceneHost, SetupSceneResult } from "./scenes/types";
20
+ import {
21
+ SETUP_SURFACE_ROLE,
22
+ type SetupScene,
23
+ type SetupSceneController,
24
+ type SetupSceneHost,
25
+ type SetupSceneResult,
26
+ } from "./scenes/types";
20
27
 
21
28
  type WizardPhase = "splash" | "transition" | "scene" | "outro" | "done";
22
29
 
@@ -35,6 +42,30 @@ const PHASE_LIMIT_MS: Partial<Record<WizardPhase, number>> = {
35
42
  /** Nothing left to show once the wizard completed. */
36
43
  const DONE_NODE = col([]);
37
44
 
45
+ /** Whether `scene` is asked under the current renderer: a TSP surface draws `ansiOnly` settings itself. */
46
+ export function setupSceneApplies(scene: SetupScene): boolean {
47
+ return !scene.ansiOnly || !isNativeRendering();
48
+ }
49
+
50
+ /** Stepper state of one step: before, at, or after the active scene. */
51
+ type StepState = "done" | "current" | "next";
52
+
53
+ const STEP_TONE = { done: "success", current: "accent", next: "muted" } as const;
54
+
55
+ /** One stepper entry: a disc (check once done, else the step number) and the label. */
56
+ function stepNode(label: string, position: number, state: StepState): NativeNode {
57
+ const disc =
58
+ state === "done"
59
+ ? node("icon", { name: "check", role: "zeta.setup.step.disc" })
60
+ : text(String(position + 1), { wrap: "none", role: "zeta.setup.step.disc" });
61
+ return node(
62
+ "row",
63
+ { align: "center", gap: "xs", role: "zeta.setup.step", tone: STEP_TONE[state] },
64
+ [disc, text(label, { wrap: "none", role: "zeta.setup.step.label" })],
65
+ `step:${position}`,
66
+ );
67
+ }
68
+
38
69
  function sceneFooterHint(): string {
39
70
  const navKeys = editorKeys("tui.select.up", "tui.select.down");
40
71
  return `${navKeys} select · ${editorKey("tui.select.confirm")} confirm · ${editorKey("tui.select.cancel")} skip · ${formatKeyHint("ctrl+c")} exit setup`;
@@ -76,8 +107,11 @@ export class SetupWizardComponent implements Component, OverlayFocusOwner {
76
107
  #timer: NodeJS.Timeout | undefined;
77
108
  /** Native path: one-shot at the end of a timed phase; the terminal clocks the motion. */
78
109
  #deadline: NodeJS.Timeout | undefined;
110
+ #nativeHead = new Memo();
79
111
  #nativeScene = new Memo();
80
112
  #nativeRoot = new Memo();
113
+ /** Display name of the default model the outro reports; `null` once looked up and absent. */
114
+ #outroModel: string | null | undefined;
81
115
  #done = Promise.withResolvers<void>();
82
116
  #disposed = false;
83
117
  /** Screen row where the active scene's body began in the last rendered frame. */
@@ -90,7 +124,11 @@ export class SetupWizardComponent implements Component, OverlayFocusOwner {
90
124
  ) {}
91
125
 
92
126
  run(): Promise<void> {
93
- this.#phase = this.scenes.length === 0 ? "outro" : "splash";
127
+ if (!this.scenes.some(setupSceneApplies)) {
128
+ this.#complete();
129
+ return this.#done.promise;
130
+ }
131
+ this.#phase = "splash";
94
132
  this.#phaseStartedAt = performance.now();
95
133
  this.#startTimer();
96
134
  this.ctx.ui.requestRender();
@@ -104,6 +142,7 @@ export class SetupWizardComponent implements Component, OverlayFocusOwner {
104
142
  }
105
143
 
106
144
  invalidate(): void {
145
+ this.#nativeHead.clear();
107
146
  this.#nativeScene.clear();
108
147
  this.#activeScene?.invalidate?.();
109
148
  }
@@ -207,13 +246,18 @@ export class SetupWizardComponent implements Component, OverlayFocusOwner {
207
246
  return this.#fitToScreen(lines, safeWidth, height);
208
247
  }
209
248
 
249
+ /** The wizard is a page of its own: a screen surface styled by {@link SETUP_SURFACE_ROLE}. */
250
+ describeScreen(_cx: DescribeContext): NativeScreen {
251
+ return { role: SETUP_SURFACE_ROLE, main: [this], dock: [] };
252
+ }
253
+
210
254
  /**
211
- * Fullscreen description: splash, the active scene inside the wizard
212
- * frame (brand header, step counter, title, footer hints), or the outro.
213
- * The splash→scene dissolve is a row effect with no native counterpart, so
214
- * a transition describes as the scene.
255
+ * Fullscreen description: splash, the active scene under the setup
256
+ * header (brand, stepper, Exit setup), or the outro. The splash→scene
257
+ * dissolve is a row effect with no native counterpart, so a transition
258
+ * describes as the scene.
215
259
  */
216
- describe(): NativeNode {
260
+ describe(cx: DescribeContext): NativeNode {
217
261
  let content: NativeNode;
218
262
  switch (this.#phase) {
219
263
  case "splash":
@@ -221,10 +265,10 @@ export class SetupWizardComponent implements Component, OverlayFocusOwner {
221
265
  break;
222
266
  case "transition":
223
267
  case "scene":
224
- content = this.#describeScene();
268
+ content = this.#describeScene(cx.supports("picker"));
225
269
  break;
226
270
  case "outro":
227
- content = describeSetupOutro();
271
+ content = describeSetupOutro(this.#outroModelName());
228
272
  break;
229
273
  case "done":
230
274
  content = DONE_NODE;
@@ -242,53 +286,133 @@ export class SetupWizardComponent implements Component, OverlayFocusOwner {
242
286
  if (event.type !== "action") return;
243
287
  if (event.act === "skip" && this.#phase === "splash") this.#beginScene();
244
288
  else if (event.act === "continue" && this.#phase === "outro") this.#complete();
289
+ else if (event.act === "exit" && (this.#phase === "scene" || this.#phase === "transition")) this.#beginOutro();
290
+ }
291
+
292
+ /**
293
+ * The steps the stepper and the ANSI counter show: every scene that
294
+ * applies to the current renderer, plus the active one (so a renderer
295
+ * switch mid-scene never orphans it), and the active one's position.
296
+ */
297
+ #steps(): { scenes: SetupScene[]; current: number } {
298
+ const scenes: SetupScene[] = [];
299
+ let current = 0;
300
+ this.scenes.forEach((scene, index) => {
301
+ if (index === this.#sceneIndex) current = scenes.length;
302
+ if (index === this.#sceneIndex || setupSceneApplies(scene)) scenes.push(scene);
303
+ });
304
+ return { scenes, current };
305
+ }
306
+
307
+ /**
308
+ * The setup header, a fixed-height row: the compact brand lockup (the
309
+ * builtin `zeta` mark and wordmark), the stepper of the applicable scenes
310
+ * (done = check in the success tone, current = accent, upcoming = muted,
311
+ * hairline connectors between), and a quiet Exit setup button (⌃C).
312
+ */
313
+ #describeHead(): NativeNode {
314
+ return this.#nativeHead.get([this.#sceneIndex], () => {
315
+ const { scenes, current } = this.#steps();
316
+ const steps: NativeChild[] = [];
317
+ scenes.forEach((scene, position) => {
318
+ if (position > 0) {
319
+ steps.push(
320
+ node(
321
+ "rule",
322
+ { role: "zeta.setup.step.line", tone: position <= current ? "success" : "muted" },
323
+ undefined,
324
+ `line:${position}`,
325
+ ),
326
+ );
327
+ }
328
+ steps.push(
329
+ stepNode(scene.step, position, position < current ? "done" : position === current ? "current" : "next"),
330
+ );
331
+ });
332
+ return keyed(
333
+ row(
334
+ [
335
+ keyed(
336
+ row(
337
+ [
338
+ node(
339
+ "image",
340
+ { builtin: "zeta", alt: APP_NAME, w: 22, role: "zeta.setup.mark" },
341
+ undefined,
342
+ "logo",
343
+ ),
344
+ keyed(
345
+ text([span(APP_NAME, "strong")], { wrap: "none", role: "zeta.setup.brand.name" }),
346
+ "name",
347
+ ),
348
+ keyed(
349
+ text([span("Setup", "muted")], { wrap: "none", role: "zeta.setup.brand.label" }),
350
+ "label",
351
+ ),
352
+ ],
353
+ { align: "center", role: "zeta.setup.brand" },
354
+ ),
355
+ "brand",
356
+ ),
357
+ keyed(row(steps, { align: "center", role: "zeta.setup.steps" }), "steps"),
358
+ actionButton("Exit setup", "exit", { keys: "ctrl+c" }),
359
+ ],
360
+ { align: "center", role: "zeta.setup.head" },
361
+ ),
362
+ "head",
363
+ );
364
+ });
245
365
  }
246
366
 
247
- #describeScene(): NativeNode {
367
+ /**
368
+ * The scene page: the setup header over the body. A terminal that draws
369
+ * `picker` sheets gets the active scene alone (its sheet, titled with the
370
+ * scene, hoists into the layer and sits under the header); otherwise the
371
+ * scene title and subtitle head the scene's inline content.
372
+ */
373
+ #describeScene(pickers: boolean): NativeNode {
248
374
  const scene = this.scenes[this.#sceneIndex];
249
375
  const active = this.#activeScene;
250
376
  const title = active?.title ?? scene?.title ?? "Setup";
251
377
  const subtitle = active?.subtitle;
252
- const footer = sceneFooterHint();
253
- return this.#nativeScene.get([this.#sceneIndex, this.scenes.length, active, title, subtitle, footer], () => {
254
- const heading: NativeNode[] = [text([span(title, "strong")])];
255
- if (subtitle) heading.push(text([span(subtitle, "muted")]));
378
+ const head = this.#describeHead();
379
+ return this.#nativeScene.get([head, active, title, subtitle, pickers], () => {
380
+ const body: NativeChild[] = [];
381
+ if (!pickers) {
382
+ body.push(keyed(text([span(title, "strong")], { role: "zeta.setup.title" }), "title"));
383
+ if (subtitle)
384
+ body.push(keyed(text([span(subtitle, "muted")], { role: "zeta.setup.subtitle" }), "subtitle"));
385
+ }
386
+ if (active) body.push(active);
256
387
  return col(
257
388
  [
258
- col(
259
- [
260
- logoNode(ZETA_LOGO, false),
261
- text([span(APP_NAME, "accent strong")], { wrap: "none" }),
262
- text([span(`Setup step ${this.#sceneIndex + 1} of ${this.scenes.length}`, "muted")], {
263
- wrap: "none",
264
- }),
265
- ],
266
- { align: "center" },
267
- ),
268
- col(heading),
389
+ head,
269
390
  // Keyed by scene so a new scene's nodes never reuse the previous one's ids.
270
- node("col", { grow: 1 }, active ? [active] : [], `body:${scene?.id ?? this.#sceneIndex}`),
271
- col([text([span(footer, "dim")])], { align: "center" }),
391
+ node("col", { grow: 1, role: "zeta.setup.body" }, body, `body:${scene?.id ?? this.#sceneIndex}`),
272
392
  ],
273
- { gap: "md", grow: 1, role: "zeta.setup.scene" },
393
+ { grow: 1, role: "zeta.setup.scene" },
274
394
  );
275
395
  });
276
396
  }
277
397
 
398
+ /** The default model's display name for the outro, looked up once per outro. */
399
+ #outroModelName(): string | undefined {
400
+ if (this.#outroModel === undefined) this.#outroModel = this.ctx.getModels().current?.name ?? null;
401
+ return this.#outroModel ?? undefined;
402
+ }
403
+
278
404
  #renderScene(width: number, height: number): string[] {
279
405
  const scene = this.scenes[this.#sceneIndex];
280
406
  const title = this.#activeScene?.title ?? scene?.title ?? tuiText("setupFallbackTitle", "Setup");
281
407
  const subtitle = this.#activeScene?.subtitle;
408
+ const { scenes: steps, current } = this.#steps();
282
409
  const contentWidth = Math.max(MIN_CONTENT_WIDTH, width - SCENE_MARGIN_X * 2);
283
410
  const logo = gradientLogo(ZETA_LOGO, 0);
284
411
  const header = [
285
412
  ...logo.map(line => centerLine(line, width)),
286
413
  centerLine(theme.bold(theme.fg("accent", APP_NAME)), width),
287
414
  centerLine(
288
- theme.fg(
289
- "muted",
290
- tuiTextFmt("setupStepFmt", "Setup step %s of %s", this.#sceneIndex + 1, this.scenes.length),
291
- ),
415
+ theme.fg("muted", tuiTextFmt("setupStepFmt", "Setup step %s of %s", current + 1, steps.length)),
292
416
  width,
293
417
  ),
294
418
  "",
@@ -373,6 +497,10 @@ export class SetupWizardComponent implements Component, OverlayFocusOwner {
373
497
  #mountSceneController(targetPhase: "scene" | "transition"): void {
374
498
  if (this.#disposed) return;
375
499
  this.#unmountActiveScene();
500
+ // Decided at mount time, so a native surface opened or closed mid-wizard is honored.
501
+ while (this.#sceneIndex < this.scenes.length && !setupSceneApplies(this.scenes[this.#sceneIndex])) {
502
+ this.#sceneIndex += 1;
503
+ }
376
504
  if (this.#sceneIndex >= this.scenes.length) {
377
505
  this.#beginOutro();
378
506
  return;
@@ -428,6 +556,7 @@ export class SetupWizardComponent implements Component, OverlayFocusOwner {
428
556
  if (this.#phase === "done") return;
429
557
  this.#unmountActiveScene();
430
558
  this.#phase = "outro";
559
+ this.#outroModel = undefined;
431
560
  this.#phaseStartedAt = performance.now();
432
561
  this.ctx.ui.setFocus(this);
433
562
  this.#startTimer();
@@ -6,7 +6,7 @@ import { modelSetupScene } from "./scenes/model";
6
6
  import { providersSetupScene } from "./scenes/sign-in";
7
7
  import { themeSetupScene } from "./scenes/theme";
8
8
  import type { SetupScene } from "./scenes/types";
9
- import { SetupWizardComponent } from "./wizard-overlay";
9
+ import { SetupWizardComponent, setupSceneApplies } from "./wizard-overlay";
10
10
 
11
11
  export type { SetupScene, SetupSceneController, SetupSceneHost, SetupSceneResult } from "./scenes/types";
12
12
 
@@ -70,13 +70,22 @@ export interface RunSetupWizardOptions {
70
70
  playWelcomeIntro?: boolean;
71
71
  }
72
72
 
73
- /** Own the fullscreen setup overlay until its scenes and outro finish. */
73
+ /**
74
+ * Own the fullscreen setup overlay until its scenes and outro finish. When
75
+ * none of `scenes` applies to the current renderer (a TSP surface skips
76
+ * `ansiOnly` ones) nothing is shown, but completion is still persisted.
77
+ */
74
78
  export async function runSetupWizard(
75
79
  ctx: SetupHost,
76
80
  scenes: readonly SetupScene[] = ALL_SCENES,
77
81
  options: RunSetupWizardOptions = {},
78
82
  ): Promise<void> {
79
83
  if (scenes.length === 0) return;
84
+ if (!scenes.some(setupSceneApplies)) {
85
+ if (options.markComplete !== false) await ctx.markComplete(CURRENT_SETUP_VERSION);
86
+ if (options.playWelcomeIntro !== false) ctx.playWelcomeIntro();
87
+ return;
88
+ }
80
89
  const component = new SetupWizardComponent(ctx, scenes);
81
90
  const overlay = ctx.ui.showOverlay(component, {
82
91
  width: "100%",
@@ -828,8 +828,6 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
828
828
  #codexResetSnapshots = new Map<string, CodexResetUsageSnapshot>();
829
829
  #onCodexResetFireworks: ((event: CodexResetFireworksEvent) => void) | undefined;
830
830
  #onResetExpiryNotice: ((notice: string) => void) | undefined;
831
- /** Conversations already warned about expiring saved resets: later refreshes stay quiet. */
832
- #resetExpiryNoticedSessions = new Set<string>();
833
831
  // Context-usage memo. The status line redraws on every agent event, so the
834
832
  // hot path must not recompute context tokens unless an input changed.
835
833
  // `getContextUsage()` anchors on the last assistant's real prompt-token
@@ -1249,7 +1247,7 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
1249
1247
  this.#onCodexResetFireworks = handler;
1250
1248
  }
1251
1249
 
1252
- /** Set the callback that presents the first pool-wide saved-reset expiry warning, or clear it with `undefined`. */
1250
+ /** Set the callback that presents pool-wide saved-reset expiry warnings, or clear it with `undefined`. */
1253
1251
  setResetExpiryNoticeHandler(handler: ((notice: string) => void) | undefined): void {
1254
1252
  this.#onResetExpiryNotice = handler;
1255
1253
  }
@@ -2132,7 +2130,7 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
2132
2130
  }
2133
2131
 
2134
2132
  #noticeResetExpiry(session: TSession, reports: unknown): void {
2135
- // A focused subagent's view is not a conversation the user started; warn in their own.
2133
+ // A focused subagent's view is not a conversation the user started; leave the warning for their own.
2136
2134
  if (
2137
2135
  this.#focusedAgentId !== undefined ||
2138
2136
  !this.#onResetExpiryNotice ||
@@ -2141,8 +2139,6 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
2141
2139
  ) {
2142
2140
  return;
2143
2141
  }
2144
- const sessionId = session.sessionManager.getSessionId();
2145
- if (this.#resetExpiryNoticedSessions.has(sessionId)) return;
2146
2142
  // fetchUsageReports supplies normalized rows; keep only entries shaped like reports.
2147
2143
  const usageReports = reports.filter(
2148
2144
  (report): report is UsageReport =>
@@ -2152,10 +2148,8 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
2152
2148
  "limits" in report &&
2153
2149
  Array.isArray(report.limits),
2154
2150
  );
2155
- const notice = this.host.resetExpiryNotice(usageReports, Date.now());
2156
- if (!notice) return;
2157
- this.#resetExpiryNoticedSessions.add(sessionId);
2158
- this.#onResetExpiryNotice(notice);
2151
+ const notice = this.host.resetExpiryNotice(session, usageReports, Date.now());
2152
+ if (notice) this.#onResetExpiryNotice(notice);
2159
2153
  }
2160
2154
 
2161
2155
  #observeLateUsageRefresh(session: TSession, reportsPromise: Promise<unknown>, sequence: number): void {