zcode-app-cli 3.9.1-16 → 3.10.1-17

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 (36) hide show
  1. package/bin/zcode.js +18 -0
  2. package/config.example.json +15 -0
  3. package/package.json +3 -3
  4. package/vendor/extraction.json +4 -4
  5. package/vendor/node_modules/@zcode/tui/dist/index.js +767 -188
  6. package/vendor/node_modules/@zcode/tui/package.json +1 -1
  7. package/vendor/packages/browser-use-plugin/.zcode-plugin/plugin.json +1 -1
  8. package/vendor/packages/browser-use-plugin/dist/mcp/server.js +891 -475
  9. package/vendor/packages/browser-use-plugin/docs/api.json +7 -2
  10. package/vendor/packages/browser-use-plugin/docs/overview.md +4 -1
  11. package/vendor/packages/browser-use-plugin/docs/playwright.md +4 -6
  12. package/vendor/packages/browser-use-plugin/docs/safety.md +1 -1
  13. package/vendor/packages/browser-use-plugin/docs/workflow.md +1 -1
  14. package/vendor/packages/browser-use-plugin/package.json +1 -1
  15. package/vendor/packages/browser-use-plugin/scripts/browser-client.mjs +65 -9
  16. package/vendor/packages/browser-use-plugin/skills/control-browser/SKILL.md +6 -3
  17. package/vendor/packages/document-skills-plugin/.zcode-plugin/plugin.json +2 -2
  18. package/vendor/packages/document-skills-plugin/agents/judge.md +51 -0
  19. package/vendor/packages/document-skills-plugin/package.json +4 -4
  20. package/vendor/packages/document-skills-plugin/skills/pptx/SKILL.md +9 -4
  21. package/vendor/packages/zcode-cua-plugin/.zcode-plugin/plugin.json +3 -3
  22. package/vendor/packages/zcode-cua-plugin/dist/mcp/server.js +573 -1023
  23. package/vendor/packages/zcode-cua-plugin/node_modules/koffi/build/koffi/linux_x64/koffi.node +0 -0
  24. package/vendor/packages/zcode-cua-plugin/node_modules/koffi/index.d.ts +288 -0
  25. package/vendor/packages/zcode-cua-plugin/node_modules/koffi/index.js +634 -0
  26. package/vendor/packages/zcode-cua-plugin/node_modules/koffi/package.json +38 -0
  27. package/vendor/packages/zcode-cua-plugin/package.json +1 -1
  28. package/vendor/packages/zcode-cua-plugin/scripts/build-mcp.mjs +3 -1
  29. package/vendor/packages/zcode-cua-plugin/scripts/bump-zcode-cua-producer.mjs +4 -4
  30. package/vendor/packages/zcode-cua-plugin/scripts/check-cua-baseline.mjs +2 -2
  31. package/vendor/packages/zcode-cua-plugin/scripts/check-version-coherence.mjs +4 -4
  32. package/vendor/packages/zcode-cua-plugin/scripts/sync-cache.mjs +9 -2
  33. package/vendor/packages/zcode-cua-plugin/scripts/sync-skill-from-zcode-cua.mjs +7 -7
  34. package/vendor/packages/zcode-cua-plugin/skills/{zcode-computer-use → computer-use}/SKILL.md +56 -13
  35. package/vendor/zcode.cjs +776 -775
  36. package/zcode-runtime.lock.json +3 -3
@@ -1,11 +1,11 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { spawn } from "node:child_process";
3
3
  import { accessSync, appendFileSync, closeSync, constants, fstatSync, openSync, readSync } from "node:fs";
4
+ import { constants as constants$1, homedir } from "node:os";
4
5
  import { basename, dirname, extname, isAbsolute, join, posix, resolve, sep, win32 } from "node:path";
5
6
  import { randomUUID } from "node:crypto";
6
7
  import { copyFile, link, mkdir, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
7
- import { homedir } from "node:os";
8
- import { Box, CombinedAutocompleteProvider, Container, Editor, Image, Input, Markdown, ProcessTerminal, SelectList, Spacer, TUI, Text, decodeKittyPrintable, getKeybindings, isKeyRelease, matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
8
+ import { Box, CombinedAutocompleteProvider, Container, Editor, Image, Input, Markdown, ProcessTerminal, ScrollView, SelectList, Spacer, Text, TuiAltScreen, TuiMainScreen, VStack, decodeKittyPrintable, getKeybindings, isKeyRelease, isViewportTUI, matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
9
9
  import { isDeepStrictEqual } from "node:util";
10
10
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
11
11
  var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
@@ -22,6 +22,23 @@ var config_example_default = {
22
22
  "headers": {},
23
23
  "models": {
24
24
  "glm-5.3": { "name": "GLM-5.3" },
25
+ "glm-5.3-flash": {
26
+ "name": "GLM-5.3-Flash",
27
+ "attachment": true,
28
+ "supportsImages": true,
29
+ "supportsPdf": true,
30
+ "supportsVideo": true,
31
+ "limit": { "context": 1e6 },
32
+ "modalities": {
33
+ "input": [
34
+ "text",
35
+ "image",
36
+ "video",
37
+ "pdf"
38
+ ],
39
+ "output": ["text"]
40
+ }
41
+ },
25
42
  "glm-5.2": { "name": "GLM-5.2" },
26
43
  "glm-5.1": { "name": "GLM-5.1" },
27
44
  "glm-5-turbo": { "name": "GLM-5-Turbo" }
@@ -83,6 +100,7 @@ var config_example_default = {
83
100
  ui: {
84
101
  "locale": "auto",
85
102
  "theme": "auto",
103
+ "tuiMode": "regular",
86
104
  "notifications": {
87
105
  "method": "auto",
88
106
  "condition": "unfocused"
@@ -156997,18 +157015,18 @@ function backgroundAgentToolName(name) {
156997
157015
  const normalized = name?.trim().toLowerCase();
156998
157016
  return normalized === "agent" || normalized === "subagent";
156999
157017
  }
157000
- function record$1(value) {
157018
+ function record$2(value) {
157001
157019
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
157002
157020
  }
157003
157021
  function explicitlyBackgroundAgentInput(value) {
157004
- return record$1(value)?.run_in_background === true;
157022
+ return record$2(value)?.run_in_background === true;
157005
157023
  }
157006
157024
  function asyncAgentResult(value) {
157007
- const root = record$1(value);
157025
+ const root = record$2(value);
157008
157026
  return [
157009
157027
  root,
157010
- record$1(root?.output),
157011
- record$1(root?.result)
157028
+ record$2(root?.output),
157029
+ record$2(root?.result)
157012
157030
  ].some((candidate) => candidate?.isAsync === true || candidate?.status === "async_launched" || candidate?.status === "backgrounded" || typeof candidate?.backgroundTaskId === "string");
157013
157031
  }
157014
157032
  function toolScope(event) {
@@ -157434,6 +157452,47 @@ function isWindowedComponent(component) {
157434
157452
  }
157435
157453
  //#endregion
157436
157454
  //#region packages/zcode-tui/src/choice-dialog.ts
157455
+ const fullscreenDialogContentMaxWidth = 100;
157456
+ var FullscreenDialogSurface = class {
157457
+ dialog;
157458
+ theme;
157459
+ focused = false;
157460
+ constructor(dialog, theme) {
157461
+ this.dialog = dialog;
157462
+ this.theme = theme;
157463
+ }
157464
+ render(width) {
157465
+ const safeWidth = Math.max(1, width);
157466
+ if ("focused" in this.dialog) this.dialog.focused = this.focused;
157467
+ const inset = safeWidth >= 12 ? 2 : 0;
157468
+ const contentWidth = Math.max(1, Math.min(fullscreenDialogContentMaxWidth, safeWidth - inset * 2));
157469
+ const prefix = " ".repeat(inset);
157470
+ const rule = this.theme.muted("─".repeat(safeWidth));
157471
+ return [
157472
+ rule,
157473
+ ...this.dialog.render(contentWidth).map((line) => truncateToWidth(`${prefix}${line}`, safeWidth, "", true)),
157474
+ rule
157475
+ ];
157476
+ }
157477
+ handleInput(data) {
157478
+ this.dialog.handleInput?.(data);
157479
+ }
157480
+ invalidate() {
157481
+ this.dialog.invalidate();
157482
+ }
157483
+ };
157484
+ function showFullscreenDialog(ui, theme, dialog) {
157485
+ if (ui.mode !== "fullscreen" || typeof ui.showOverlay !== "function") return void 0;
157486
+ const surface = new FullscreenDialogSurface(dialog, theme);
157487
+ return {
157488
+ focus: surface,
157489
+ handle: ui.showOverlay(surface, {
157490
+ anchor: "bottom-left",
157491
+ maxHeight: "100%",
157492
+ width: "100%"
157493
+ })
157494
+ };
157495
+ }
157437
157496
  var ChoiceItemDetails = class {
157438
157497
  item;
157439
157498
  theme;
@@ -157652,11 +157711,13 @@ function choose(ui, host, theme, options) {
157652
157711
  };
157653
157712
  dialog.setSelectionPreview(previewFor(list.getSelectedItem()));
157654
157713
  let settled = false;
157714
+ let overlayHandle;
157655
157715
  const finish = (item) => {
157656
157716
  if (settled) return;
157657
157717
  settled = true;
157658
157718
  options.signal?.removeEventListener("abort", onAbort);
157659
- host.removeChild(dialog);
157719
+ if (overlayHandle) overlayHandle.hide();
157720
+ else host.removeChild(dialog);
157660
157721
  ui.requestRender();
157661
157722
  resolve(item);
157662
157723
  };
@@ -157664,8 +157725,10 @@ function choose(ui, host, theme, options) {
157664
157725
  list.onSelect = (item) => finish(choicesByValue.get(item.value) ?? null);
157665
157726
  list.onSelectionChange = (item) => dialog.setSelectionPreview(previewFor(item));
157666
157727
  list.onCancel = () => finish(null);
157667
- host.addChild(dialog);
157668
- ui.setFocus(dialog);
157728
+ const fullscreenDialog = showFullscreenDialog(ui, theme, dialog);
157729
+ if (fullscreenDialog) overlayHandle = fullscreenDialog.handle;
157730
+ else host.addChild(dialog);
157731
+ ui.setFocus(fullscreenDialog?.focus ?? dialog);
157669
157732
  ui.requestRender();
157670
157733
  options.signal?.addEventListener("abort", onAbort, { once: true });
157671
157734
  if (options.signal?.aborted) finish(null);
@@ -157677,6 +157740,7 @@ var TextPromptDialog = class {
157677
157740
  input;
157678
157741
  theme;
157679
157742
  help;
157743
+ focused = false;
157680
157744
  constructor(title, prompt, input, theme, help) {
157681
157745
  this.title = title;
157682
157746
  this.prompt = prompt;
@@ -157686,6 +157750,7 @@ var TextPromptDialog = class {
157686
157750
  }
157687
157751
  render(width) {
157688
157752
  const safeWidth = Math.max(1, width);
157753
+ if ("focused" in this.input) this.input.focused = this.focused;
157689
157754
  return [
157690
157755
  ...wrapTerminalText(this.theme.bold(this.title), safeWidth),
157691
157756
  ...wrapTerminalText(this.theme.muted(this.prompt), safeWidth),
@@ -157695,6 +157760,9 @@ var TextPromptDialog = class {
157695
157760
  ...wrapTerminalText(this.theme.muted(this.help), safeWidth)
157696
157761
  ];
157697
157762
  }
157763
+ handleInput(data) {
157764
+ this.input.handleInput?.(data);
157765
+ }
157698
157766
  invalidate() {
157699
157767
  this.input.invalidate();
157700
157768
  }
@@ -157760,19 +157828,23 @@ function promptText(ui, host, theme, options) {
157760
157828
  else input.setValue(options.initialValue);
157761
157829
  const dialog = new TextPromptDialog(sanitizeTerminalText(options.title, { preserveSgr: false }), sanitizeTerminalText(options.prompt, { preserveSgr: false }), input, theme, sanitizeTerminalText(options.help ?? "Enter confirm · Esc cancel", { preserveSgr: false }));
157762
157830
  let settled = false;
157831
+ let overlayHandle;
157763
157832
  const finish = (value) => {
157764
157833
  if (settled) return;
157765
157834
  settled = true;
157766
157835
  options.signal?.removeEventListener("abort", onAbort);
157767
- host.removeChild(dialog);
157836
+ if (overlayHandle) overlayHandle.hide();
157837
+ else host.removeChild(dialog);
157768
157838
  ui.requestRender();
157769
157839
  resolve(value);
157770
157840
  };
157771
157841
  const onAbort = () => finish(null);
157772
157842
  input.onSubmit = (value) => finish(value);
157773
157843
  input.onEscape = () => finish(null);
157774
- host.addChild(dialog);
157775
- ui.setFocus(input);
157844
+ const fullscreenDialog = showFullscreenDialog(ui, theme, dialog);
157845
+ if (fullscreenDialog) overlayHandle = fullscreenDialog.handle;
157846
+ else host.addChild(dialog);
157847
+ ui.setFocus(fullscreenDialog?.focus ?? dialog);
157776
157848
  ui.requestRender();
157777
157849
  options.signal?.addEventListener("abort", onAbort, { once: true });
157778
157850
  if (options.signal?.aborted) finish(null);
@@ -157935,6 +158007,29 @@ function normalizeEvent(value) {
157935
158007
  function isModelCancellationEvent(event) {
157936
158008
  return event.type === "model_request_failed" && (event.reason?.toLowerCase() === "cancelled" || event.errorCode?.toLowerCase() === "model_request_cancelled" || event.exceptionType?.toLowerCase() === "aborterror");
157937
158009
  }
158010
+ const toolCancellationValues = /* @__PURE__ */ new Set([
158011
+ "aborterror",
158012
+ "cancelled",
158013
+ "canceled",
158014
+ "tool_cancelled",
158015
+ "tool_canceled"
158016
+ ]);
158017
+ function isToolCancellation(value) {
158018
+ if (value instanceof Error) return toolCancellationValues.has(value.name.toLowerCase()) || /\b(?:tool|command|process|bash)\b.{0,40}\b(?:cancelled|canceled)\b/iu.test(value.message);
158019
+ if (typeof value === "string") {
158020
+ const normalized = value.trim().toLowerCase();
158021
+ return toolCancellationValues.has(normalized) || /\b(?:tool|command|process|bash)\b.{0,40}\b(?:cancelled|canceled)\b/iu.test(value);
158022
+ }
158023
+ if (!isRecord(value)) return false;
158024
+ if ([
158025
+ value.type,
158026
+ value.code,
158027
+ value.name,
158028
+ value.status,
158029
+ value.reason
158030
+ ].some((marker) => typeof marker === "string" && toolCancellationValues.has(marker.trim().toLowerCase()))) return true;
158031
+ return value.error !== value && isToolCancellation(value.error);
158032
+ }
157938
158033
  function responseText(value) {
157939
158034
  if (!isRecord(value)) return void 0;
157940
158035
  return asString(value.response) ?? asString(value.message) ?? asString(value.text);
@@ -161710,11 +161805,11 @@ function findExecutable(name, env = process.env, platform = process.platform) {
161710
161805
  }
161711
161806
  return null;
161712
161807
  }
161713
- function record(value) {
161808
+ function record$1(value) {
161714
161809
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
161715
161810
  }
161716
161811
  function configuredNotifications(config) {
161717
- return record(record(record(config)?.ui)?.notifications);
161812
+ return record$1(record$1(record$1(config)?.ui)?.notifications);
161718
161813
  }
161719
161814
  function notificationSettings(env = process.env, config) {
161720
161815
  const configured = configuredNotifications(config);
@@ -161733,7 +161828,7 @@ async function readStoredNotificationSettings(env = process.env) {
161733
161828
  }
161734
161829
  async function writeNotificationSettings(settings, env = process.env) {
161735
161830
  return await updateUserConfig((config) => {
161736
- const ui = record(config.ui) ?? {};
161831
+ const ui = record$1(config.ui) ?? {};
161737
161832
  ui.notifications = { ...settings };
161738
161833
  config.ui = ui;
161739
161834
  }, env);
@@ -161951,6 +162046,33 @@ var TurnNotifier = class {
161951
162046
  }
161952
162047
  };
161953
162048
  //#endregion
162049
+ //#region packages/zcode-tui/src/tui-mode.ts
162050
+ function record(value) {
162051
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
162052
+ }
162053
+ function configuredTuiMode(config) {
162054
+ const value = record(record(config)?.ui)?.tuiMode;
162055
+ return typeof value === "string" ? value : void 0;
162056
+ }
162057
+ function tuiMode(value) {
162058
+ if (typeof value !== "string") return void 0;
162059
+ const normalized = value.trim().toLowerCase();
162060
+ return normalized === "regular" || normalized === "fullscreen" ? normalized : void 0;
162061
+ }
162062
+ function resolveTuiMode(env = process.env, config) {
162063
+ return tuiMode(env.ZCODE_TUI_MODE) ?? tuiMode(configuredTuiMode(config)) ?? "regular";
162064
+ }
162065
+ async function readTuiMode(env = process.env) {
162066
+ return resolveTuiMode(env, await readUserConfig(env));
162067
+ }
162068
+ async function writeTuiMode(mode, env = process.env) {
162069
+ return await updateUserConfig((config) => {
162070
+ const ui = record(config.ui) ?? {};
162071
+ ui.tuiMode = mode;
162072
+ config.ui = ui;
162073
+ }, env);
162074
+ }
162075
+ //#endregion
161954
162076
  //#region packages/zcode-tui/src/selectors.ts
161955
162077
  function pickerRequest(input, commands) {
161956
162078
  const match = /^\/([^\s]+)(?:\s+(.*))?$/u.exec(input.trim());
@@ -163968,7 +164090,16 @@ function resultContent(value, expanded) {
163968
164090
  function errorText(value) {
163969
164091
  if (value instanceof Error) return sanitizeTerminalText(value.message, { preserveSgr: false });
163970
164092
  const direct = asString(value);
163971
- return direct ? sanitizeTerminalText(direct, { preserveSgr: false }) : stringify(value);
164093
+ if (direct) return sanitizeTerminalText(direct, { preserveSgr: false });
164094
+ if (!isRecord(value)) return stringify(value);
164095
+ const message = asString(value.message) ?? asString(value.detail) ?? asString(value.description);
164096
+ if (message) return sanitizeTerminalText(message, { preserveSgr: false });
164097
+ if (value.error !== value) {
164098
+ const nested = errorText(value.error);
164099
+ if (nested) return nested;
164100
+ }
164101
+ const code = asString(value.code) ?? asString(value.type) ?? asString(value.name);
164102
+ return code ? sanitizeTerminalText(code, { preserveSgr: false }) : void 0;
163972
164103
  }
163973
164104
  function statePresentation(state, theme) {
163974
164105
  const normalized = state.toLowerCase();
@@ -164013,7 +164144,7 @@ function statePresentation(state, theme) {
164013
164144
  }
164014
164145
  function stateBackground(state, theme) {
164015
164146
  const normalized = state.toLowerCase();
164016
- if (normalized === "failed" || normalized === "error" || normalized === "cancelled") return theme.toolErrorBackground;
164147
+ if (normalized === "failed" || normalized === "error") return theme.toolErrorBackground;
164017
164148
  return normalized === "waiting_permission" ? theme.toolPendingBackground : void 0;
164018
164149
  }
164019
164150
  function stylePreview(value, theme, expanded) {
@@ -164047,6 +164178,11 @@ function toolText(options, theme, input = parsedInput(options), expanded = false
164047
164178
  summary && theme.muted(oneLine$2(summary)),
164048
164179
  presentation.suffix && theme.muted(`· ${presentation.suffix}`)
164049
164180
  ].filter(Boolean).join(" ");
164181
+ if (options.state.toLowerCase() === "cancelled") return {
164182
+ header,
164183
+ images: [],
164184
+ truncated: false
164185
+ };
164050
164186
  const sections = [];
164051
164187
  let truncated = false;
164052
164188
  const mutation = mutationInput(options.name, input);
@@ -164689,6 +164825,14 @@ var TurnWorkTracker = class {
164689
164825
  this.awaitingProjection = awaitProjection;
164690
164826
  return this.isActive();
164691
164827
  }
164828
+ cancel() {
164829
+ this.foregroundActive = false;
164830
+ this.awaitingProjection = false;
164831
+ this.projectionToolActive = false;
164832
+ this.projectionTurnActive = false;
164833
+ this.turnId = void 0;
164834
+ this.taskIds.clear();
164835
+ }
164692
164836
  reconcile(projection) {
164693
164837
  const jobs = projection.backgroundJobs;
164694
164838
  for (const job of jobs) {
@@ -164729,18 +164873,20 @@ var UpdateAvailableView = class extends Box {
164729
164873
  }
164730
164874
  };
164731
164875
  //#endregion
164732
- //#region packages/zcode-tui/src/welcome-banner.ts
164733
- /** A terminal interpretation of the split, diagonal Z in the Desktop app icon. */
164734
- const BRAND_MARK = [
164735
- "█████ ▄███",
164736
- " ▄██▀ ",
164737
- " ▄██▀ ",
164738
- "▄███ █████"
164739
- ];
164740
- const maxInformationWidth = 52;
164741
- const boxTitle = "── SYSTEM INITIATED ";
164742
- function bannerText(value) {
164743
- return sanitizeTerminalText(value, { preserveSgr: false }).replace(/\s+/gu, " ").trim();
164876
+ //#region packages/zcode-tui/src/fullscreen-header.ts
164877
+ function clean(value) {
164878
+ return (value ? sanitizeTerminalText(value, { preserveSgr: false }).replace(/\s+/gu, " ").trim() : "") || void 0;
164879
+ }
164880
+ function normalizePath(value) {
164881
+ return value.replaceAll("\\", "/");
164882
+ }
164883
+ function displayWorkspacePath(workspace, homeDirectory = homedir()) {
164884
+ const path = normalizePath(clean(workspace) ?? "");
164885
+ const home = normalizePath(clean(homeDirectory) ?? "").replace(/\/+$/u, "");
164886
+ if (!path || !home) return path;
164887
+ if (path === home) return "~";
164888
+ if (path.startsWith(`${home}/`)) return `~${path.slice(home.length)}`;
164889
+ return path;
164744
164890
  }
164745
164891
  function truncateFromStart(value, width) {
164746
164892
  if (width <= 0) return "";
@@ -164753,84 +164899,116 @@ function truncateFromStart(value, width) {
164753
164899
  }
164754
164900
  return `…${suffix.join("")}`;
164755
164901
  }
164756
- function padTerminalText(value, width) {
164757
- const truncated = truncateToWidth(value, Math.max(0, width), "…");
164758
- return `${truncated}${" ".repeat(Math.max(0, width - visibleWidth(truncated)))}`;
164759
- }
164760
- function boxRule(prefix, width) {
164761
- const content = prefix === "┌" ? boxTitle : "";
164762
- return `${prefix}${content}${"─".repeat(Math.max(0, width - 1 - visibleWidth(content)))}`;
164763
- }
164764
- var WelcomeBanner = class {
164902
+ function locationText(workspace, branch, width, homeDirectory) {
164903
+ const path = displayWorkspacePath(workspace, homeDirectory);
164904
+ if (!branch) return truncateFromStart(path, width);
164905
+ const separator = " · ";
164906
+ const branchText = truncateToWidth(branch, Math.min(visibleWidth(branch), Math.max(8, Math.floor(width * .36))), "…");
164907
+ const pathWidth = width - visibleWidth(separator) - visibleWidth(branchText);
164908
+ if (pathWidth <= 0) return truncateToWidth(branchText, width, "…");
164909
+ return `${truncateFromStart(path, pathWidth)}${separator}${branchText}`;
164910
+ }
164911
+ function fit(value, width) {
164912
+ return truncateToWidth(value, Math.max(0, width), "…");
164913
+ }
164914
+ function horizontalRail(content, width, theme) {
164915
+ const safeWidth = Math.max(1, width);
164916
+ if (safeWidth < 5) return fit(content, safeWidth);
164917
+ const left = "── ";
164918
+ const body = fit(content, Math.max(1, safeWidth - visibleWidth(left) - 2));
164919
+ const fill = "─".repeat(Math.max(1, safeWidth - visibleWidth(left) - visibleWidth(body) - 1));
164920
+ return fit(`${theme.muted(left)}${body}${theme.muted(` ${fill}`)}`, safeWidth);
164921
+ }
164922
+ function frameRule(edge, title, width, theme) {
164923
+ const [left, right] = edge === "top" ? ["╭─ ", "╮"] : ["╰─ ", "╯"];
164924
+ const fixedWidth = visibleWidth(left) + visibleWidth(right) + 2;
164925
+ if (width < fixedWidth) return fit(theme.muted("─".repeat(Math.max(1, width))), width);
164926
+ const body = fit(title, Math.max(1, width - fixedWidth));
164927
+ const fill = "─".repeat(Math.max(1, width - visibleWidth(left) - visibleWidth(body) - visibleWidth(right) - 1));
164928
+ return fit(`${theme.muted(left)}${body}${theme.muted(` ${fill}${right}`)}`, width);
164929
+ }
164930
+ function frameContent(content, width, theme) {
164931
+ if (width < 4) return fit(content, width);
164932
+ const innerWidth = width - 4;
164933
+ const body = fit(content, innerWidth);
164934
+ const padding = " ".repeat(Math.max(0, innerWidth - visibleWidth(body)));
164935
+ return `${theme.muted("│ ")}${body}${padding}${theme.muted(" │")}`;
164936
+ }
164937
+ var FullscreenHeader = class {
164765
164938
  theme;
164939
+ phase = "welcome";
164766
164940
  branch;
164767
164941
  distributionVersion;
164768
164942
  runtimeVersion;
164769
164943
  workspace;
164944
+ homeDirectory;
164770
164945
  constructor(theme, options) {
164771
164946
  this.theme = theme;
164772
- this.branch = options.branch ? bannerText(options.branch) : void 0;
164773
- this.distributionVersion = options.distributionVersion ? bannerText(options.distributionVersion) : void 0;
164774
- this.runtimeVersion = bannerText(options.runtimeVersion);
164775
- this.workspace = bannerText(options.workspace);
164947
+ this.branch = clean(options.branch);
164948
+ this.distributionVersion = clean(options.distributionVersion);
164949
+ this.runtimeVersion = clean(options.runtimeVersion) ?? "unknown";
164950
+ this.workspace = clean(options.workspace) ?? "";
164951
+ this.homeDirectory = options.homeDirectory ?? homedir();
164952
+ }
164953
+ setPhase(phase) {
164954
+ this.phase = phase;
164955
+ }
164956
+ getPhase() {
164957
+ return this.phase;
164958
+ }
164959
+ location(width) {
164960
+ return locationText(this.workspace, this.branch, Math.max(0, width), this.homeDirectory);
164961
+ }
164962
+ identity(width, includeVersion = true) {
164963
+ const brand = this.theme.bold(this.theme.accent("◆ ZCODE"));
164964
+ if (!includeVersion) return fit(brand, Math.max(0, width));
164965
+ const version = this.distributionVersion ?? this.runtimeVersion;
164966
+ return fit(`${brand} ${this.theme.muted(`v${version}`)}`, Math.max(0, width));
164776
164967
  }
164777
164968
  render(width) {
164778
- if (width <= 0) return [""];
164779
- return width >= 48 ? this.renderWide(width) : this.renderCompact(width);
164969
+ const safeWidth = Math.max(1, width);
164970
+ if (this.phase === "welcome") return [horizontalRail(this.identity(safeWidth, true), safeWidth, this.theme)];
164971
+ if (this.phase === "transition") return [horizontalRail(this.identity(safeWidth, false), safeWidth, this.theme)];
164972
+ const identity = this.identity(safeWidth, false);
164973
+ const separator = " ";
164974
+ const location = this.location(Math.max(0, safeWidth - visibleWidth(identity) - visibleWidth(separator) - 6));
164975
+ return [horizontalRail(`${identity}${separator}${this.theme.muted(location)}`, safeWidth, this.theme)];
164780
164976
  }
164781
164977
  invalidate() {}
164782
- renderWide(width) {
164783
- const contentWidth = Math.max(1, width - 1);
164784
- const gap = " ";
164785
- const informationWidth = Math.max(1, contentWidth - 10 - 3);
164786
- const panelWidth = Math.min(informationWidth, maxInformationWidth);
164787
- const panelContentWidth = Math.max(1, panelWidth - 2);
164788
- const primaryVersion = this.distributionVersion ?? this.runtimeVersion;
164789
- const identity = `${this.theme.bold(this.theme.accent("ZCODE"))} ${this.theme.muted(`v${primaryVersion}`)}`;
164790
- const fullVersionLine = this.distributionVersion ? `${identity}${this.theme.muted(` · runtime v${this.runtimeVersion}`)}` : identity;
164791
- const compactVersionLine = this.distributionVersion ? `${identity}${this.theme.muted(` · rt v${this.runtimeVersion}`)}` : identity;
164792
- const versionLine = visibleWidth(fullVersionLine) <= panelContentWidth ? fullVersionLine : compactVersionLine;
164793
- const locationLine = this.locationLine(panelContentWidth);
164794
- const information = [
164795
- this.theme.muted(boxRule("┌", panelWidth)),
164796
- `${this.theme.muted("│")} ${padTerminalText(versionLine, panelContentWidth)}`,
164797
- `${this.theme.muted("│")} ${this.theme.muted(padTerminalText(locationLine, panelContentWidth))}`,
164798
- this.theme.muted(boxRule("└", panelWidth))
164799
- ];
164800
- return BRAND_MARK.map((line, index) => ` ${this.theme.accent(line)}${gap}${information[index] ?? ""}`);
164801
- }
164802
- locationLine(width) {
164803
- if (!this.branch) return truncateFromStart(this.workspace, width);
164804
- const separator = " · ";
164805
- const branchWidth = Math.max(8, Math.min(visibleWidth(`branch ${this.branch}`), Math.floor(width * .45)));
164806
- const branch = truncateToWidth(`branch ${this.branch}`, branchWidth, "…");
164807
- const workspaceWidth = width - visibleWidth(separator) - visibleWidth(branch);
164808
- if (workspaceWidth < 4) return truncateToWidth(branch, width, "…");
164809
- return `${truncateFromStart(this.workspace, workspaceWidth)}${separator}${branch}`;
164810
- }
164811
- renderCompact(width) {
164812
- const contentWidth = Math.max(0, width - 1);
164813
- const primaryVersion = this.distributionVersion ?? this.runtimeVersion;
164814
- const identity = `${this.theme.bold(this.theme.accent("ZCODE"))} ${this.theme.muted(`v${primaryVersion}`)}`;
164815
- const location = [this.workspace, this.branch ? `branch ${this.branch}` : void 0].filter((value) => Boolean(value)).join(" · ");
164816
- return [` ${truncateToWidth(identity, contentWidth)}`, ` ${this.theme.muted(truncateFromStart(location, contentWidth))}`];
164817
- }
164818
164978
  };
164819
- /** A quiet full-width rule separating startup identity from the conversation. */
164820
- var Divider = class {
164821
- char;
164822
- style;
164823
- constructor(char, style) {
164824
- this.char = char;
164825
- this.style = style;
164979
+ /** One-time startup content that belongs to the transcript, not the chrome. */
164980
+ var SessionWelcome = class {
164981
+ theme;
164982
+ location;
164983
+ identity;
164984
+ loginRequired;
164985
+ includeIdentity;
164986
+ transitioning = false;
164987
+ constructor(theme, location, identity, options = {}) {
164988
+ this.theme = theme;
164989
+ this.location = location;
164990
+ this.identity = identity;
164991
+ this.loginRequired = options.loginRequired === true;
164992
+ this.includeIdentity = options.includeIdentity !== false;
164993
+ }
164994
+ setLoginRequired(required) {
164995
+ this.loginRequired = required;
164996
+ }
164997
+ setIncludeIdentity(include) {
164998
+ this.includeIdentity = include;
164999
+ }
165000
+ setTransitioning(transitioning) {
165001
+ this.transitioning = transitioning;
164826
165002
  }
164827
165003
  render(width) {
164828
- if (width <= 0) return [""];
164829
- const baseWidth = Math.max(0, width - 1);
164830
- if (baseWidth < 8) return [` ${this.style(this.char.repeat(baseWidth))}`];
164831
- const prefix = `${this.char.repeat(3)}◆`;
164832
- const suffix = this.char.repeat(Math.max(0, baseWidth - visibleWidth(prefix)));
164833
- return [` ${this.style(truncateToWidth(prefix + suffix, baseWidth))}`];
165004
+ const safeWidth = Math.max(1, width);
165005
+ const frameWidth = Math.max(1, Math.min(safeWidth, 76));
165006
+ const innerWidth = Math.max(1, frameWidth - 4);
165007
+ const content = [frameRule("top", this.includeIdentity ? this.identity(Math.max(1, frameWidth - 8)) : this.theme.bold("Workspace"), frameWidth, this.theme), frameContent(this.theme.muted(this.location(innerWidth)), frameWidth, this.theme)];
165008
+ if (this.loginRequired) content.push(frameContent(this.theme.warning("Model access is not configured · Run /login."), frameWidth, this.theme));
165009
+ content.push(frameContent(this.theme.bold("Ask a task about this workspace"), frameWidth, this.theme), frameRule("bottom", this.theme.muted("/help commands · /status details"), frameWidth, this.theme));
165010
+ const lines = content.map((line) => truncateToWidth(line, safeWidth, "…"));
165011
+ return this.transitioning ? lines.map((line) => this.theme.muted(sanitizeTerminalText(line, { preserveSgr: false }))) : lines;
164834
165012
  }
164835
165013
  invalidate() {}
164836
165014
  };
@@ -165253,6 +165431,7 @@ const runtimeCommandSummaries = /* @__PURE__ */ new Map([
165253
165431
  ]);
165254
165432
  const terminalThemeQueryTimeoutMs = 100;
165255
165433
  const exitUsageQueryTimeoutMs = 250;
165434
+ const fullscreenWelcomeTransitionMs = 180;
165256
165435
  const updateAvailableBlockId = "update_available";
165257
165436
  const modelRetryBlockIdPrefix = "model_retry_status";
165258
165437
  const questionBackValue = "__back__";
@@ -165369,6 +165548,63 @@ var ConditionalContainer = class extends Container {
165369
165548
  return this.visible() ? super.render(width) : [];
165370
165549
  }
165371
165550
  };
165551
+ /**
165552
+ * AI SDK emits its warning banner through console.info when no handler is
165553
+ * installed. In the interactive TUI that stdout write is terminal content,
165554
+ * so suppress only the default banner while preserving a runtime-provided
165555
+ * structured warning handler.
165556
+ */
165557
+ function suppressTuiAiSdkWarnings() {
165558
+ const global = globalThis;
165559
+ if (typeof global.AI_SDK_LOG_WARNINGS === "function") return;
165560
+ try {
165561
+ global.AI_SDK_LOG_WARNINGS = false;
165562
+ } catch {}
165563
+ }
165564
+ suppressTuiAiSdkWarnings();
165565
+ /**
165566
+ * The upstream alternate-screen renderer intentionally reserves Home/End and
165567
+ * PageUp/PageDown for viewport navigation. ZCode's composer is a real editor,
165568
+ * so it needs the same priority as a modal overlay while it has focus.
165569
+ */
165570
+ var ZCodeAltScreen = class extends TuiAltScreen {
165571
+ viewportInputDeferral;
165572
+ currentInput;
165573
+ setViewportInputDeferral(deferral) {
165574
+ this.viewportInputDeferral = deferral;
165575
+ }
165576
+ setCurrentInput(data) {
165577
+ this.currentInput = data;
165578
+ }
165579
+ isOverlayFocused() {
165580
+ if (super.isOverlayFocused()) return true;
165581
+ return this.viewportInputDeferral?.(this.currentInput ?? "") === true;
165582
+ }
165583
+ };
165584
+ /** Feed focus reports to the notifier before the TUI's own input listeners. */
165585
+ var NotifyingProcessTerminal = class extends ProcessTerminal {
165586
+ beforeInput;
165587
+ afterInput;
165588
+ constructor(beforeInput, afterInput) {
165589
+ super();
165590
+ this.beforeInput = beforeInput;
165591
+ this.afterInput = afterInput;
165592
+ }
165593
+ start(onInput, onResize) {
165594
+ super.start((data) => {
165595
+ this.beforeInput(data);
165596
+ try {
165597
+ onInput(data);
165598
+ } finally {
165599
+ this.afterInput?.();
165600
+ }
165601
+ }, onResize);
165602
+ }
165603
+ };
165604
+ function signalExitCode(signal) {
165605
+ const number = constants$1.signals[signal];
165606
+ return typeof number === "number" ? 128 + number : 1;
165607
+ }
165372
165608
  var ZCodeTui = class {
165373
165609
  options;
165374
165610
  animateTurnTimer;
@@ -165380,6 +165616,14 @@ var ZCodeTui = class {
165380
165616
  transcript;
165381
165617
  choiceHost = new Container();
165382
165618
  composerHost = new ConditionalContainer(() => this.choiceDepth === 0);
165619
+ headerHost = new Container();
165620
+ transcriptHost = new Container();
165621
+ sessionWelcomeHost = new ConditionalContainer(() => this.tuiMode === "fullscreen" && this.fullscreenWelcomeVisible);
165622
+ editorHost = new Container();
165623
+ fullscreenHeader;
165624
+ sessionWelcome;
165625
+ fullscreenTranscript;
165626
+ fullscreenLayout;
165383
165627
  runtimeActivity;
165384
165628
  status;
165385
165629
  turnStatus;
@@ -165422,8 +165666,10 @@ var ZCodeTui = class {
165422
165666
  currentToolGroupBlockId;
165423
165667
  currentToolGroupMessageId;
165424
165668
  pendingAttachments = [];
165669
+ editorHistory = [];
165425
165670
  mode;
165426
165671
  model;
165672
+ tuiMode;
165427
165673
  thoughtLevel;
165428
165674
  modelOptions;
165429
165675
  effortOptions;
@@ -165439,6 +165685,9 @@ var ZCodeTui = class {
165439
165685
  workflowRefreshInFlight = false;
165440
165686
  choiceDepth = 0;
165441
165687
  settingSwitchInFlight = false;
165688
+ fullscreenWelcomeVisible = true;
165689
+ fullscreenWelcomeTransitionTimer;
165690
+ sessionHasContent = false;
165442
165691
  rewindEscapePending = false;
165443
165692
  rewindEscapeTimer;
165444
165693
  rewindFlowActive = false;
@@ -165470,8 +165719,6 @@ var ZCodeTui = class {
165470
165719
  backgroundHandoffInterruptInFlight = false;
165471
165720
  updateCheckAbortController;
165472
165721
  loginRequired;
165473
- loginWarning = new Text("", 1, 0);
165474
- loginHelp = new Text("", 1, 0);
165475
165722
  constructor(options) {
165476
165723
  this.options = options;
165477
165724
  this.animateTurnTimer = turnTimerAnimationEnabled();
@@ -165480,6 +165727,18 @@ var ZCodeTui = class {
165480
165727
  this.distributionVersion = sanitizeTerminalText(process.env.ZCODE_APP_CLI_VERSION?.trim() ?? "", { preserveSgr: false }) || void 0;
165481
165728
  this.theme = createTheme(this.colorsEnabled, initialColorScheme(this.themePreference));
165482
165729
  this.transcript = new Transcript(this.theme.searchMatch);
165730
+ const workspace = options.workspaceDirectory ?? process.cwd();
165731
+ const runtimeVersion = sanitizeTerminalText(options.version ?? "unknown", { preserveSgr: false });
165732
+ this.fullscreenHeader = new FullscreenHeader(this.theme, {
165733
+ branch: options.workspaceGitBranch,
165734
+ distributionVersion: this.distributionVersion,
165735
+ runtimeVersion,
165736
+ workspace
165737
+ });
165738
+ this.sessionWelcome = new SessionWelcome(this.theme, (width) => this.fullscreenHeader.location(width), (width) => this.fullscreenHeader.identity(width), {
165739
+ loginRequired: options.loginRequired === true,
165740
+ includeIdentity: true
165741
+ });
165483
165742
  this.mode = normalizedMode(options.initialMode);
165484
165743
  this.model = modelLabel$1(options.initialModel);
165485
165744
  this.thoughtLevel = options.initialThoughtLevel;
@@ -165487,7 +165746,8 @@ var ZCodeTui = class {
165487
165746
  this.effortOptions = [...options.effortOptions ?? []];
165488
165747
  this.loginRequired = options.loginRequired === true;
165489
165748
  this.skillCatalog = new SkillCatalog(options.listSkills);
165490
- this.ui = new TUI(new ProcessTerminal(), true);
165749
+ this.tuiMode = resolveTuiMode(process.env, { ui: { tuiMode: options.initialTuiMode } });
165750
+ this.ui = this.createTui(this.tuiMode);
165491
165751
  this.notifications = new TurnNotifier({ writeTerminal: (data) => this.ui.terminal.write(data) });
165492
165752
  this.status = new StatusLine();
165493
165753
  this.turnStatus = new FooterBar();
@@ -165517,11 +165777,8 @@ var ZCodeTui = class {
165517
165777
  onRender: () => this.ui.requestRender()
165518
165778
  });
165519
165779
  this.runtimeActivity = new RuntimeActivityView(this.theme);
165520
- this.editor = new Editor(this.ui, this.theme.editor, {
165521
- paddingX: 1,
165522
- autocompleteMaxVisible: 7
165523
- });
165524
- this.assistantStream = new AssistantStream(this.theme, (component, blockOptions) => this.transcript.addBlock(component, blockOptions));
165780
+ this.editor = this.createEditor(this.ui);
165781
+ this.assistantStream = new AssistantStream(this.theme, (component, blockOptions) => this.addTranscriptBlock(component, blockOptions));
165525
165782
  this.done = new Promise((resolve) => {
165526
165783
  this.resolveDone = resolve;
165527
165784
  });
@@ -165534,34 +165791,76 @@ var ZCodeTui = class {
165534
165791
  } catch (error) {
165535
165792
  notificationConfigError = error instanceof Error ? error.message : String(error);
165536
165793
  }
165794
+ try {
165795
+ const configEnv = { ...process.env };
165796
+ delete configEnv.ZCODE_TUI_MODE;
165797
+ const fromConfig = await readTuiMode(configEnv);
165798
+ const effective = resolveTuiMode(process.env, { ui: { tuiMode: this.options.initialTuiMode ?? fromConfig } });
165799
+ if (effective !== this.tuiMode) {
165800
+ this.ui = this.createTui(effective);
165801
+ this.tuiMode = effective;
165802
+ this.editor = this.createEditor(this.ui);
165803
+ }
165804
+ } catch {}
165537
165805
  const updateCheck = this.distributionVersion ? await readStartupUpdate({ currentVersion: this.distributionVersion }).catch(() => void 0) : void 0;
165538
- this.ui.start();
165539
- await this.resolveTerminalColorScheme();
165540
- this.buildLayout();
165541
- if (notificationConfigError) this.addNotice(`Unable to load notification settings: ${notificationConfigError}`, "warning");
165542
- await this.restoreInitialTranscript();
165543
- if (updateCheck?.availableVersion && this.distributionVersion) this.addUpdateAvailable(this.distributionVersion, updateCheck.availableVersion);
165544
- this.bindInput();
165545
- this.notifications.start();
165546
- this.ui.setFocus(this.editor);
165547
- this.updateMetadata();
165548
- this.updateTurnStatus();
165549
- this.ui.requestRender(true);
165550
- this.startUpdateRefresh(updateCheck);
165551
- if (!this.loginRequired) this.refreshGoal();
165552
- if (!this.loginRequired) this.refreshSessionUsage();
165553
- if (await readSetupPending().catch(() => false)) if (await readConfiguredModelAccess().catch(() => null)) await clearSetupPending().catch(() => {});
165554
- else this.runFirstRunSetup();
165555
- this.scheduleRuntimePoll(0);
165556
- this.loadHistory();
165557
- if (this.options.subscribeSessionEvents) this.unsubscribeSession = this.options.subscribeSessionEvents((event) => {
165558
- this.onSessionEvent(event);
165559
- }) ?? void 0;
165560
- if (this.options.subscribeWorkflowEvents) this.unsubscribeWorkflow = this.options.subscribeWorkflowEvents((event) => {
165561
- this.debugEvent("workflow", event);
165562
- this.refreshWorkflowFromEvent();
165563
- }) ?? void 0;
165564
- await this.done;
165806
+ const onSigint = () => this.handleSignal("SIGINT");
165807
+ const onSigterm = () => this.handleSignal("SIGTERM");
165808
+ const onSighup = () => this.handleSignal("SIGHUP");
165809
+ process.once("SIGINT", onSigint);
165810
+ process.once("SIGTERM", onSigterm);
165811
+ if (process.platform !== "win32") process.once("SIGHUP", onSighup);
165812
+ let startAttempted = false;
165813
+ try {
165814
+ if (this.stopped) {
165815
+ await this.done;
165816
+ return;
165817
+ }
165818
+ startAttempted = true;
165819
+ this.ui.start();
165820
+ if (this.stopped) {
165821
+ await this.done;
165822
+ return;
165823
+ }
165824
+ await this.resolveTerminalColorScheme();
165825
+ this.buildLayout();
165826
+ if (notificationConfigError) this.addNotice(`Unable to load notification settings: ${notificationConfigError}`, "warning");
165827
+ await this.restoreInitialTranscript();
165828
+ if (this.transcript.blockCount > 0) this.enterSessionRail(true);
165829
+ if (updateCheck?.availableVersion && this.distributionVersion) this.addUpdateAvailable(this.distributionVersion, updateCheck.availableVersion);
165830
+ this.bindInput();
165831
+ this.notifications.start();
165832
+ this.focusEditor();
165833
+ this.updateMetadata();
165834
+ this.updateTurnStatus();
165835
+ this.ui.requestRender(true);
165836
+ this.startUpdateRefresh(updateCheck);
165837
+ if (!this.loginRequired) this.refreshGoal();
165838
+ if (!this.loginRequired) this.refreshSessionUsage();
165839
+ if (await readSetupPending().catch(() => false)) if (await readConfiguredModelAccess().catch(() => null)) await clearSetupPending().catch(() => {});
165840
+ else this.runFirstRunSetup();
165841
+ this.scheduleRuntimePoll(0);
165842
+ this.loadHistory();
165843
+ if (this.options.subscribeSessionEvents) this.unsubscribeSession = this.options.subscribeSessionEvents((event) => {
165844
+ this.onSessionEvent(event);
165845
+ }) ?? void 0;
165846
+ if (this.options.subscribeWorkflowEvents) this.unsubscribeWorkflow = this.options.subscribeWorkflowEvents((event) => {
165847
+ this.debugEvent("workflow", event);
165848
+ this.refreshWorkflowFromEvent();
165849
+ }) ?? void 0;
165850
+ await this.done;
165851
+ } finally {
165852
+ process.off("SIGINT", onSigint);
165853
+ process.off("SIGTERM", onSigterm);
165854
+ if (process.platform !== "win32") process.off("SIGHUP", onSighup);
165855
+ if (startAttempted && !this.stopped) {
165856
+ this.stop();
165857
+ await this.done;
165858
+ }
165859
+ }
165860
+ }
165861
+ handleSignal(signal) {
165862
+ process.exitCode = signalExitCode(signal);
165863
+ if (!this.stopped) this.stop();
165565
165864
  }
165566
165865
  async resolveTerminalColorScheme() {
165567
165866
  if (!this.colorsEnabled || this.themePreference !== "auto") return;
@@ -165571,43 +165870,251 @@ var ZCodeTui = class {
165571
165870
  if (colorScheme) this.theme.setColorScheme(colorScheme);
165572
165871
  } catch {}
165573
165872
  }
165873
+ createTui(mode) {
165874
+ let fullscreenTui;
165875
+ const terminal = new NotifyingProcessTerminal((data) => {
165876
+ fullscreenTui?.setCurrentInput(data);
165877
+ this.notifications?.handleInput(data);
165878
+ }, () => fullscreenTui?.setCurrentInput(void 0));
165879
+ if (mode !== "fullscreen") return new TuiMainScreen(terminal, true);
165880
+ const tui = new ZCodeAltScreen(terminal, true, void 0, {
165881
+ copySelection: async (text) => {
165882
+ const writeClipboardText = this.options.writeClipboardText;
165883
+ if (!writeClipboardText) return false;
165884
+ try {
165885
+ await writeClipboardText(text);
165886
+ return true;
165887
+ } catch {
165888
+ return false;
165889
+ }
165890
+ },
165891
+ mouse: true,
165892
+ wheelScrollLines: 3
165893
+ });
165894
+ fullscreenTui = tui;
165895
+ tui.setViewportInputDeferral((data) => {
165896
+ const focused = tui.getFocusedComponent();
165897
+ if (focused === this.attachmentBar) return matchesKey(data, "home") || matchesKey(data, "end");
165898
+ if (focused !== this.editor) return false;
165899
+ if (matchesKey(data, "home") || matchesKey(data, "end") || matchesKey(data, "ctrl+home") || matchesKey(data, "ctrl+end")) return true;
165900
+ return matchesKey(data, "pageUp") || matchesKey(data, "pageDown") || matchesKey(data, "ctrl+pageUp") || matchesKey(data, "ctrl+pageDown");
165901
+ });
165902
+ return tui;
165903
+ }
165574
165904
  buildLayout() {
165575
- const workspace = this.options.workspaceDirectory ?? process.cwd();
165576
- const runtimeVersion = sanitizeTerminalText(this.options.version ?? "unknown", { preserveSgr: false });
165577
- this.ui.addChild(new WelcomeBanner(this.theme, {
165578
- branch: this.options.workspaceGitBranch,
165579
- distributionVersion: this.distributionVersion,
165580
- runtimeVersion,
165581
- workspace
165582
- }));
165583
- this.ui.addChild(new Divider("─", this.theme.muted));
165584
- this.ui.addChild(this.loginWarning);
165585
- this.ui.addChild(this.loginHelp);
165905
+ const fullscreen = isViewportTUI(this.ui);
165906
+ this.fullscreenHeader.setPhase(fullscreen && this.fullscreenWelcomeVisible ? "welcome" : "rail");
165907
+ this.sessionWelcome.setLoginRequired(this.loginRequired);
165908
+ this.sessionWelcome.setIncludeIdentity(!fullscreen);
165909
+ this.headerHost.clear();
165586
165910
  this.updateLoginWarning();
165587
- this.ui.addChild(new Spacer(1));
165588
- this.ui.addChild(this.transcript);
165589
- this.ui.addChild(this.runtimeActivity);
165590
- this.ui.addChild(this.choiceHost);
165911
+ if (!fullscreen) {
165912
+ if (!this.sessionHasContent) this.mountRegularSessionWelcome();
165913
+ }
165914
+ this.transcriptHost.clear();
165915
+ this.sessionWelcomeHost.clear();
165916
+ if (fullscreen) this.sessionWelcome.setIncludeIdentity(false);
165917
+ this.sessionWelcomeHost.addChild(this.sessionWelcome);
165918
+ if (fullscreen) this.transcriptHost.addChild(this.sessionWelcomeHost);
165919
+ this.transcriptHost.addChild(this.transcript);
165920
+ this.transcriptHost.addChild(this.runtimeActivity);
165921
+ this.transcriptHost.addChild(this.choiceHost);
165922
+ this.editorHost.clear();
165923
+ this.editorHost.addChild(this.editor);
165924
+ this.composerHost.clear();
165591
165925
  this.composerHost.addChild(this.turnStatus);
165592
165926
  this.composerHost.addChild(this.queuedInputView);
165593
165927
  this.composerHost.addChild(this.attachmentBar);
165594
- this.composerHost.addChild(this.editor);
165928
+ this.composerHost.addChild(this.editorHost);
165595
165929
  this.composerHost.addChild(this.status);
165930
+ this.mountLayout();
165931
+ }
165932
+ enterSessionRail(immediate = false) {
165933
+ this.sessionHasContent = true;
165934
+ if (this.tuiMode !== "fullscreen") return;
165935
+ const phase = this.fullscreenHeader.getPhase();
165936
+ if (phase === "rail") {
165937
+ this.fullscreenWelcomeVisible = false;
165938
+ this.sessionWelcome.setTransitioning(false);
165939
+ return;
165940
+ }
165941
+ if (phase === "transition" && !immediate) return;
165942
+ if (this.fullscreenWelcomeTransitionTimer) {
165943
+ clearTimeout(this.fullscreenWelcomeTransitionTimer);
165944
+ this.fullscreenWelcomeTransitionTimer = void 0;
165945
+ }
165946
+ if (immediate || !this.animateTurnTimer) {
165947
+ this.fullscreenWelcomeVisible = false;
165948
+ this.sessionWelcome.setTransitioning(false);
165949
+ this.fullscreenHeader.setPhase("rail");
165950
+ this.ui.requestRender(true);
165951
+ return;
165952
+ }
165953
+ this.sessionWelcome.setTransitioning(true);
165954
+ this.fullscreenHeader.setPhase("transition");
165955
+ this.ui.requestRender();
165956
+ this.fullscreenWelcomeTransitionTimer = setTimeout(() => {
165957
+ this.fullscreenWelcomeTransitionTimer = void 0;
165958
+ if (this.stopped || this.tuiMode !== "fullscreen") return;
165959
+ this.fullscreenWelcomeVisible = false;
165960
+ this.sessionWelcome.setTransitioning(false);
165961
+ this.fullscreenHeader.setPhase("rail");
165962
+ this.ui.requestRender();
165963
+ }, fullscreenWelcomeTransitionMs);
165964
+ this.fullscreenWelcomeTransitionTimer.unref?.();
165965
+ }
165966
+ resetSessionPresentation() {
165967
+ if (this.fullscreenWelcomeTransitionTimer) {
165968
+ clearTimeout(this.fullscreenWelcomeTransitionTimer);
165969
+ this.fullscreenWelcomeTransitionTimer = void 0;
165970
+ }
165971
+ this.sessionHasContent = false;
165972
+ this.fullscreenWelcomeVisible = true;
165973
+ this.fullscreenHeader.setPhase("welcome");
165974
+ this.sessionWelcome.setTransitioning(false);
165975
+ if (this.tuiMode === "regular") this.mountRegularSessionWelcome();
165976
+ this.ui.requestRender();
165977
+ }
165978
+ mountRegularSessionWelcome() {
165979
+ this.headerHost.clear();
165980
+ this.sessionWelcome.setIncludeIdentity(true);
165981
+ this.headerHost.addChild(this.sessionWelcome);
165982
+ this.headerHost.addChild(new Spacer(1));
165983
+ }
165984
+ addTranscriptBlock(component, options = {}) {
165985
+ this.enterSessionRail();
165986
+ return this.transcript.addBlock(component, options);
165987
+ }
165988
+ mountLayout() {
165989
+ if (isViewportTUI(this.ui)) {
165990
+ this.fullscreenTranscript ??= new ScrollView(this.transcriptHost, {
165991
+ follow: "end",
165992
+ primary: true,
165993
+ overscroll: "chain",
165994
+ scrollbar: "always"
165995
+ });
165996
+ this.fullscreenLayout ??= new VStack([
165997
+ {
165998
+ component: this.fullscreenHeader,
165999
+ basis: 1,
166000
+ shrink: 0,
166001
+ minSize: 1
166002
+ },
166003
+ {
166004
+ component: this.fullscreenTranscript,
166005
+ basis: 0,
166006
+ grow: 1,
166007
+ minSize: 1
166008
+ },
166009
+ {
166010
+ component: this.composerHost,
166011
+ basis: "auto",
166012
+ shrink: 1,
166013
+ minSize: 1
166014
+ }
166015
+ ]);
166016
+ this.ui.setLayoutRoot(this.fullscreenLayout);
166017
+ return;
166018
+ }
166019
+ this.ui.clear();
166020
+ this.ui.addChild(this.headerHost);
166021
+ this.ui.addChild(this.transcriptHost);
165596
166022
  this.ui.addChild(this.composerHost);
166023
+ }
166024
+ createEditor(tui) {
166025
+ const editor = new Editor(tui, this.theme.editor, {
166026
+ paddingX: 1,
166027
+ autocompleteMaxVisible: 7
166028
+ });
166029
+ for (const input of [...this.editorHistory].reverse()) editor.addToHistory(input);
165597
166030
  const commands = this.autocompleteCommands();
165598
166031
  const workspaceDirectory = this.options.workspaceDirectory ?? process.cwd();
165599
- this.editor.setAutocompleteProvider(new WorkspaceAutocompleteProvider(commands, workspaceDirectory, this.options.listWorkspacePathSuggestions, this.skillCatalog, this.options.listPluginReferences ?? createRuntimePluginReferenceLister(workspaceDirectory)));
165600
- this.editor.onSubmit = (text) => void this.submit(text);
166032
+ editor.setAutocompleteProvider(new WorkspaceAutocompleteProvider(commands, workspaceDirectory, this.options.listWorkspacePathSuggestions, this.skillCatalog, this.options.listPluginReferences ?? createRuntimePluginReferenceLister(workspaceDirectory)));
166033
+ editor.onSubmit = (text) => void this.submit(text);
166034
+ return editor;
166035
+ }
166036
+ focusEditor() {
166037
+ this.ui.setFocus(this.editor);
166038
+ }
166039
+ rememberEditorHistory(input) {
166040
+ const trimmed = input.trim();
166041
+ if (!trimmed || this.editorHistory[0] === trimmed) return;
166042
+ this.editorHistory.unshift(trimmed);
166043
+ if (this.editorHistory.length > 100) this.editorHistory.pop();
166044
+ }
166045
+ async switchTuiMode(next) {
166046
+ if (this.settingSwitchInFlight) return;
166047
+ if (next === this.tuiMode) return;
166048
+ if (this.activeSubmissions > 0 || this.turnAbortController) {
166049
+ this.addNotice("Wait for the active turn before switching display mode.", "warning");
166050
+ return;
166051
+ }
166052
+ this.settingSwitchInFlight = true;
166053
+ const savedDraft = this.editor.getText();
166054
+ const hadSessionContent = this.sessionHasContent || this.transcript.blockCount > 0;
166055
+ const previousUi = this.ui;
166056
+ const previousMode = this.tuiMode;
166057
+ let previousStopped = false;
166058
+ try {
166059
+ this.notifications.stop();
166060
+ previousStopped = true;
166061
+ this.ui.stop({ preserveScreen: true });
166062
+ this.ui = this.createTui(next);
166063
+ this.tuiMode = next;
166064
+ this.sessionHasContent = hadSessionContent;
166065
+ this.fullscreenWelcomeVisible = !hadSessionContent;
166066
+ this.fullscreenHeader.setPhase(hadSessionContent ? "rail" : "welcome");
166067
+ this.editor = this.createEditor(this.ui);
166068
+ this.fullscreenTranscript = void 0;
166069
+ this.fullscreenLayout = void 0;
166070
+ this.buildLayout();
166071
+ this.ui.start();
166072
+ this.bindInput();
166073
+ this.focusEditor();
166074
+ if (savedDraft) this.editor.setText(savedDraft);
166075
+ this.ui.requestRender(true);
166076
+ this.notifications.start();
166077
+ try {
166078
+ await writeTuiMode(next);
166079
+ } catch (error) {
166080
+ this.addNotice(error instanceof Error ? error.message : String(error), "error");
166081
+ }
166082
+ } catch (error) {
166083
+ if (this.ui !== previousUi || previousStopped) {
166084
+ if (this.ui !== previousUi) try {
166085
+ this.ui.stop({ preserveScreen: true });
166086
+ } catch {}
166087
+ this.ui = previousUi;
166088
+ this.tuiMode = previousMode;
166089
+ this.sessionHasContent = hadSessionContent;
166090
+ this.fullscreenWelcomeVisible = previousMode === "fullscreen" ? !hadSessionContent : true;
166091
+ this.fullscreenHeader.setPhase(hadSessionContent ? "rail" : "welcome");
166092
+ this.fullscreenTranscript = void 0;
166093
+ this.fullscreenLayout = void 0;
166094
+ this.editor = this.createEditor(this.ui);
166095
+ if (savedDraft) this.editor.setText(savedDraft);
166096
+ this.buildLayout();
166097
+ try {
166098
+ this.ui.start();
166099
+ this.bindInput();
166100
+ this.focusEditor();
166101
+ this.notifications.start();
166102
+ this.ui.requestRender(true);
166103
+ } catch {}
166104
+ }
166105
+ this.addNotice(`Display mode switch failed: ${error instanceof Error ? error.message : String(error)}`, "error");
166106
+ } finally {
166107
+ this.settingSwitchInFlight = false;
166108
+ }
165601
166109
  }
165602
166110
  updateLoginWarning() {
165603
- const configPath = userConfigPathHint();
165604
- this.loginWarning.setText(this.loginRequired ? this.theme.warning("Model access is not configured.") : "");
165605
- this.loginHelp.setText(this.loginRequired ? this.theme.warning(`Run /login, or configure a custom provider in ${configPath}.`) : "");
166111
+ this.sessionWelcome.setLoginRequired(this.loginRequired);
165606
166112
  }
165607
166113
  setLoginRequired(required) {
165608
166114
  const changed = this.loginRequired !== required;
165609
166115
  this.loginRequired = required;
165610
166116
  this.updateLoginWarning();
166117
+ this.ui.requestRender();
165611
166118
  if (changed && !required) {
165612
166119
  this.refreshGoal();
165613
166120
  this.refreshSessionUsage();
@@ -165673,10 +166180,12 @@ var ZCodeTui = class {
165673
166180
  } catch (error) {
165674
166181
  failure = error instanceof Error ? error.message : String(error);
165675
166182
  } finally {
165676
- this.ui.start();
165677
- this.notifications.start();
165678
- this.ui.setFocus(this.editor);
165679
- this.ui.requestRender(true);
166183
+ if (!this.stopped) {
166184
+ this.ui.start();
166185
+ this.notifications.start();
166186
+ this.focusEditor();
166187
+ this.ui.requestRender(true);
166188
+ }
165680
166189
  }
165681
166190
  const access = code === 0 ? await readConfiguredModelAccess() : null;
165682
166191
  if (access) {
@@ -165779,6 +166288,13 @@ var ZCodeTui = class {
165779
166288
  this.clearRewindEscape();
165780
166289
  this.recentSteerCommit = void 0;
165781
166290
  }
166291
+ const focusedComponent = this.ui.getFocusedComponent?.();
166292
+ if (this.tuiMode === "fullscreen" && this.fullscreenTranscript && focusedComponent === this.editor && !this.editor.getText() && (matchesKey(data, "pageUp") || matchesKey(data, "pageDown"))) {
166293
+ if (matchesKey(data, "pageUp")) this.fullscreenTranscript.scrollBy(-Math.max(1, this.fullscreenTranscript.viewportHeight - 4));
166294
+ else this.fullscreenTranscript.scrollBy(Math.max(1, this.fullscreenTranscript.viewportHeight - 4));
166295
+ this.ui.requestRender();
166296
+ return { consume: true };
166297
+ }
165782
166298
  if (matchesKey(data, "up") && this.canEnterAttachmentSelection()) {
165783
166299
  this.enterAttachmentSelection();
165784
166300
  return { consume: true };
@@ -165898,7 +166414,10 @@ var ZCodeTui = class {
165898
166414
  const input = (queuedSubmission?.input ?? rawInput).trim();
165899
166415
  if (!input || this.stopped) return;
165900
166416
  const submission = queuedSubmission ?? protectSubmission(input);
165901
- if (submission.recordHistory) this.editor.addToHistory(input);
166417
+ if (submission.recordHistory) {
166418
+ this.rememberEditorHistory(input);
166419
+ this.editor.addToHistory(input);
166420
+ }
165902
166421
  if (input === "/exit" || input === "/quit") {
165903
166422
  this.stop();
165904
166423
  return;
@@ -166207,9 +166726,9 @@ var ZCodeTui = class {
166207
166726
  pendingInputIds: this.inputQueue.admittedPendingInputIds(),
166208
166727
  reason: "TUI interrupted the active model step to submit steer instructions.",
166209
166728
  reservationId: request.reservationId
166210
- }).then((outcome) => {
166729
+ }).then(() => {
166211
166730
  if (!this.isPendingSteerInterrupt(turnEpoch, abortController)) return;
166212
- if (!isRecord(outcome) || asString(outcome.kind) !== "stopped") abortController.abort();
166731
+ abortController.abort();
166213
166732
  }).catch(() => {
166214
166733
  if (this.isPendingSteerInterrupt(turnEpoch, abortController)) abortController.abort();
166215
166734
  });
@@ -166226,9 +166745,9 @@ var ZCodeTui = class {
166226
166745
  abortController.abort();
166227
166746
  return;
166228
166747
  }
166229
- interruptTurn({ reason: "TUI interrupted the active foreground turn." }).then((outcome) => {
166748
+ interruptTurn({ reason: "TUI interrupted the active foreground turn." }).then(() => {
166230
166749
  if (this.turnAbortController !== abortController || abortController.signal.aborted) return;
166231
- if (!isRecord(outcome) || asString(outcome.kind) !== "stopped") abortController.abort();
166750
+ abortController.abort();
166232
166751
  }).catch(() => {
166233
166752
  if (this.turnAbortController === abortController && !abortController.signal.aborted) abortController.abort();
166234
166753
  });
@@ -166276,6 +166795,7 @@ var ZCodeTui = class {
166276
166795
  emitSessionTerminalTitle(this.options.stdout ?? process.stdout, "");
166277
166796
  this.sessionMetrics = {};
166278
166797
  this.restoreTranscript(restoredMessages(result.restoredMessages));
166798
+ if (this.transcript.blockCount > 0) this.enterSessionRail(true);
166279
166799
  }
166280
166800
  const response = responseText(result);
166281
166801
  if (renderResponse && response) {
@@ -166388,10 +166908,11 @@ var ZCodeTui = class {
166388
166908
  this.updateToolView(tool, "running", event.result, void 0, event.progress);
166389
166909
  } else if (event.kind === "result") {
166390
166910
  const tool = this.ensureToolView(event.toolCallId, event.toolName, event.partId, event.messageId);
166391
- this.updateToolView(tool, toolSucceeded(event.result) ? "complete" : "failed", event.result, void 0, event.progress);
166911
+ const cancelled = isToolCancellation(event.result);
166912
+ this.updateToolView(tool, cancelled ? "cancelled" : toolSucceeded(event.result) ? "complete" : "failed", event.result, void 0, event.progress);
166392
166913
  } else if (event.kind === "error" && (event.toolCallId || event.toolName)) {
166393
166914
  const tool = this.ensureToolView(event.toolCallId, event.toolName, event.partId, event.messageId);
166394
- this.updateToolView(tool, "failed", event.result, event.error, event.progress);
166915
+ this.updateToolView(tool, isToolCancellation(event.error ?? event.result) ? "cancelled" : "failed", event.result, event.error, event.progress);
166395
166916
  } else if (event.kind === "closed" && (event.toolCallId || event.toolName)) {
166396
166917
  const tool = this.ensureToolView(event.toolCallId, event.toolName, event.partId, event.messageId);
166397
166918
  if (!tool.view.isTerminal()) this.updateToolView(tool, "complete", event.result, event.error, event.progress);
@@ -166616,7 +167137,7 @@ var ZCodeTui = class {
166616
167137
  display: part.resultDisplay
166617
167138
  } : part.output;
166618
167139
  if (part.output !== void 0 || part.resultDisplay !== void 0) tool.outputText = void 0;
166619
- this.updateToolView(tool, restoredToolState(part.status), result, part.error, {
167140
+ this.updateToolView(tool, isToolCancellation(part.error ?? result) ? "cancelled" : restoredToolState(part.status), result, part.error, {
166620
167141
  parentToolCallId: part.parentToolCallId,
166621
167142
  childToolCallId: part.childToolCallId,
166622
167143
  agentId: part.agentId,
@@ -166727,6 +167248,7 @@ var ZCodeTui = class {
166727
167248
  }
166728
167249
  clearTranscriptProjection() {
166729
167250
  this.transcript.clear();
167251
+ this.resetSessionPresentation();
166730
167252
  this.assistantStream.clear();
166731
167253
  this.currentThinking = void 0;
166732
167254
  this.currentThinkingPartId = void 0;
@@ -166738,6 +167260,7 @@ var ZCodeTui = class {
166738
167260
  this.currentToolGroupMessageId = void 0;
166739
167261
  }
166740
167262
  appendThinking(delta, partId, messageId) {
167263
+ if (delta.trim()) this.enterSessionRail();
166741
167264
  if (partId) {
166742
167265
  let view = this.thinkingParts.get(partId);
166743
167266
  if (!view) {
@@ -166774,6 +167297,7 @@ var ZCodeTui = class {
166774
167297
  }
166775
167298
  addUserMessage(text, attachmentCount = 0, messageId) {
166776
167299
  const safeText = sanitizeTerminalText(text, { preserveSgr: false });
167300
+ this.enterSessionRail();
166777
167301
  const suffix = attachmentCount > 0 ? ` [${attachmentCount} image${attachmentCount === 1 ? "" : "s"}]` : "";
166778
167302
  this.currentToolGroup = void 0;
166779
167303
  this.transcript.addBlock(new Text(`${this.theme.accent("›")} ${safeText}${this.theme.muted(suffix)}`, 1, 0), {
@@ -166784,6 +167308,7 @@ var ZCodeTui = class {
166784
167308
  this.ui.requestRender();
166785
167309
  }
166786
167310
  addAssistantMessage(text, partId, messageId) {
167311
+ this.enterSessionRail();
166787
167312
  this.currentToolGroup = void 0;
166788
167313
  this.transcript.addBlock(new RichMarkdown(text, 1, this.theme), {
166789
167314
  id: partId,
@@ -166842,6 +167367,7 @@ var ZCodeTui = class {
166842
167367
  });
166843
167368
  }
166844
167369
  ensureToolView(toolCallId, toolName, partId, messageId) {
167370
+ this.enterSessionRail();
166845
167371
  const anonymous = !toolCallId ? Array.from(this.toolViews.values()).findLast((tool) => tool.name === (toolName ?? "tool") && !tool.view.isTerminal()) : void 0;
166846
167372
  if (anonymous) {
166847
167373
  if (partId) {
@@ -167198,7 +167724,7 @@ var ZCodeTui = class {
167198
167724
  const submission = this.inputQueue.editLatestFollowUp();
167199
167725
  if (!submission) return;
167200
167726
  this.editor.setText(submission.input);
167201
- this.ui.setFocus(this.editor);
167727
+ this.focusEditor();
167202
167728
  }
167203
167729
  async attachClipboardImage() {
167204
167730
  if (!this.options.readClipboardImage) {
@@ -167243,7 +167769,7 @@ var ZCodeTui = class {
167243
167769
  }
167244
167770
  leaveAttachmentSelection() {
167245
167771
  this.attachmentBar.deactivate();
167246
- this.ui.setFocus(this.editor);
167772
+ this.focusEditor();
167247
167773
  this.ui.requestRender();
167248
167774
  }
167249
167775
  removePendingAttachment(index) {
@@ -167259,7 +167785,7 @@ var ZCodeTui = class {
167259
167785
  syncAttachmentBar() {
167260
167786
  const wasActive = this.attachmentBar.isActive();
167261
167787
  this.attachmentBar.setAttachments(this.pendingAttachments);
167262
- if (wasActive && !this.attachmentBar.isActive()) this.ui.setFocus(this.editor);
167788
+ if (wasActive && !this.attachmentBar.isActive()) this.focusEditor();
167263
167789
  this.ui.requestRender();
167264
167790
  }
167265
167791
  async requestPermission(requestValue, context) {
@@ -167823,6 +168349,7 @@ var ZCodeTui = class {
167823
168349
  const backend = notificationDeliveryLabel(effective.method, diagnostics.backend);
167824
168350
  const methodOverride = Boolean(process.env.ZCODE_TUI_NOTIFICATION_METHOD?.trim());
167825
168351
  const conditionOverride = Boolean(process.env.ZCODE_TUI_NOTIFICATION_CONDITION?.trim());
168352
+ const tuiModeOverride = process.env.ZCODE_TUI_MODE?.trim().toLowerCase();
167826
168353
  const savedConfig = await readUserConfig().then((config) => isRecord(config.model) ? config.model : void 0).catch(() => void 0);
167827
168354
  const savedModelLabel = typeof savedConfig?.main === "string" && savedConfig.main.trim() ? savedConfig.main : void 0;
167828
168355
  const setting = await this.showChoice({
@@ -167844,6 +168371,11 @@ var ZCodeTui = class {
167844
168371
  value: "notification-condition",
167845
168372
  label: "When to notify",
167846
168373
  description: conditionOverride ? `Current: ${effective.condition} · Saved: ${stored.condition} (environment override)` : `Current: ${stored.condition}`
168374
+ },
168375
+ {
168376
+ value: "tui-mode",
168377
+ label: "Display mode",
168378
+ description: tuiModeOverride === "fullscreen" || tuiModeOverride === "regular" ? `Current: ${this.tuiMode === "fullscreen" ? "Fullscreen" : "Regular"} (environment override)` : `Current: ${this.tuiMode === "fullscreen" ? "Fullscreen" : "Regular"}`
167847
168379
  }
167848
168380
  ],
167849
168381
  selectedIndex: selectedSettingIndex
@@ -167855,6 +168387,37 @@ var ZCodeTui = class {
167855
168387
  feedback = "Changes save immediately · Esc closes settings";
167856
168388
  continue;
167857
168389
  }
168390
+ if (setting.value === "tui-mode") {
168391
+ selectedSettingIndex = 3;
168392
+ const selected = await this.showChoice({
168393
+ title: "Display mode",
168394
+ prompt: "Switch between regular and fullscreen TUI.",
168395
+ help: "Up/Down choose · Enter apply · Esc back",
168396
+ items: [{
168397
+ value: "regular",
168398
+ label: "Regular",
168399
+ description: "Scrollback-style output (default)"
168400
+ }, {
168401
+ value: "fullscreen",
168402
+ label: "Fullscreen",
168403
+ description: "Alternate screen with scrollable transcript and scrollbars"
168404
+ }],
168405
+ selectedIndex: this.tuiMode === "fullscreen" ? 1 : 0
168406
+ });
168407
+ if (!selected) {
168408
+ feedback = "No changes · Esc closes settings";
168409
+ continue;
168410
+ }
168411
+ const next = selected.value;
168412
+ if (next === this.tuiMode) {
168413
+ feedback = "Display mode unchanged";
168414
+ continue;
168415
+ }
168416
+ await this.switchTuiMode(next);
168417
+ feedback = this.tuiMode === next ? `Display mode: ${next} · applied` : "Could not switch display mode";
168418
+ selectedSettingIndex = 3;
168419
+ continue;
168420
+ }
167858
168421
  selectedSettingIndex = setting.value === "notification-condition" ? 2 : setting.value === "notification-method" ? 1 : 0;
167859
168422
  let next = stored;
167860
168423
  let changedLabel;
@@ -168158,6 +168721,7 @@ var ZCodeTui = class {
168158
168721
  this.lastAssistantText = "";
168159
168722
  this.turnAssistantText = "";
168160
168723
  this.restoreTranscript(restored);
168724
+ if (this.transcript.blockCount > 0) this.enterSessionRail(true);
168161
168725
  this.editor.setText(target.text);
168162
168726
  }
168163
168727
  const label = scope === "both" ? "Conversation and workspace rewound. The selected input was restored to the editor." : scope === "conversation" ? "Conversation rewound. The selected input was restored to the editor." : "Workspace files rewound. Conversation history was kept.";
@@ -168820,7 +169384,7 @@ var ZCodeTui = class {
168820
169384
  return await choose(this.ui, this.choiceHost, this.theme, options);
168821
169385
  } finally {
168822
169386
  this.choiceDepth = Math.max(0, this.choiceDepth - 1);
168823
- this.ui.setFocus(this.editor);
169387
+ this.focusEditor();
168824
169388
  this.ui.requestRender();
168825
169389
  }
168826
169390
  }
@@ -168830,7 +169394,7 @@ var ZCodeTui = class {
168830
169394
  return await promptText(this.ui, this.choiceHost, this.theme, options);
168831
169395
  } finally {
168832
169396
  this.choiceDepth = Math.max(0, this.choiceDepth - 1);
168833
- this.ui.setFocus(this.editor);
169397
+ this.focusEditor();
168834
169398
  this.ui.requestRender();
168835
169399
  }
168836
169400
  }
@@ -168861,7 +169425,10 @@ var ZCodeTui = class {
168861
169425
  } catch {
168862
169426
  break;
168863
169427
  }
168864
- for (const input of history.reverse()) this.editor.addToHistory(input);
169428
+ for (const input of history.reverse()) {
169429
+ this.rememberEditorHistory(input);
169430
+ this.editor.addToHistory(input);
169431
+ }
168865
169432
  }
168866
169433
  async restoreInitialTranscript() {
168867
169434
  if (!this.options.loadSessionTranscript) return;
@@ -169128,7 +169695,10 @@ var ZCodeTui = class {
169128
169695
  this.finalizeUnresolvedTools(unfinishedToolState);
169129
169696
  this.turnDiffs.finishTurn();
169130
169697
  this.currentToolGroup = void 0;
169131
- if (!this.turnWork.finishForeground(Boolean(this.options.readRuntimeProjection))) this.settleTurnTiming();
169698
+ if (unfinishedToolState === "cancelled") {
169699
+ this.turnWork.cancel();
169700
+ this.settleTurnTiming();
169701
+ } else if (!this.turnWork.finishForeground(Boolean(this.options.readRuntimeProjection))) this.settleTurnTiming();
169132
169702
  this.activity = void 0;
169133
169703
  this.refreshSessionTerminalTitle();
169134
169704
  this.updateTurnStatus();
@@ -169174,36 +169744,45 @@ var ZCodeTui = class {
169174
169744
  this.updateCheckAbortController?.abort();
169175
169745
  if (this.turnTimer) clearInterval(this.turnTimer);
169176
169746
  if (this.rewindEscapeTimer) clearTimeout(this.rewindEscapeTimer);
169747
+ if (this.fullscreenWelcomeTransitionTimer) clearTimeout(this.fullscreenWelcomeTransitionTimer);
169177
169748
  if (this.runtimeRefreshTimer) clearTimeout(this.runtimeRefreshTimer);
169178
169749
  if (this.runtimePollTimer) clearTimeout(this.runtimePollTimer);
169179
169750
  this.unsubscribeSession?.();
169180
169751
  this.unsubscribeWorkflow?.();
169181
169752
  const elapsedMilliseconds = this.turnStartedAt === void 0 ? this.turnElapsedMilliseconds : Math.max(0, performance.now() - this.turnStartedAt);
169182
- this.notifications.stop();
169183
- this.ui.stop();
169753
+ try {
169754
+ this.notifications.stop();
169755
+ } catch {}
169756
+ try {
169757
+ this.ui.stop();
169758
+ } catch {}
169184
169759
  this.finishStop(elapsedMilliseconds);
169185
169760
  }
169186
169761
  async finishStop(elapsedMilliseconds) {
169187
- await this.refreshExitUsage();
169188
- const summary = buildExitSummary({
169189
- elapsedMilliseconds,
169190
- metrics: this.sessionMetrics,
169191
- sessionId: this.sessionId ?? this.runtimeProjection?.sessionId,
169192
- width: this.ui.terminal.columns
169193
- });
169194
- const lines = [
169195
- summary.divider && this.theme.muted(summary.divider),
169196
- summary.tokenUsage,
169197
- summary.resumeCommand ? `To continue this session, run ${this.theme.accent(summary.resumeCommand)}` : void 0
169198
- ].filter((line) => Boolean(line));
169199
- if (lines.length > 0) try {
169200
- (this.options.stdout ?? process.stdout).write(`${lines.join("\n")}\n`);
169201
- } catch {}
169202
- this.resolveDone();
169762
+ try {
169763
+ await this.refreshExitUsage();
169764
+ const summary = buildExitSummary({
169765
+ elapsedMilliseconds,
169766
+ metrics: this.sessionMetrics,
169767
+ sessionId: this.sessionId ?? this.runtimeProjection?.sessionId,
169768
+ width: this.ui.terminal.columns
169769
+ });
169770
+ const lines = [
169771
+ summary.divider && this.theme.muted(summary.divider),
169772
+ summary.tokenUsage,
169773
+ summary.resumeCommand ? `To continue this session, run ${this.theme.accent(summary.resumeCommand)}` : void 0
169774
+ ].filter((line) => Boolean(line));
169775
+ if (lines.length > 0) try {
169776
+ (this.options.stdout ?? process.stdout).write(`${lines.join("\n")}\n`);
169777
+ } catch {}
169778
+ } catch {} finally {
169779
+ this.resolveDone();
169780
+ }
169203
169781
  }
169204
169782
  };
169205
169783
  async function runTui(options) {
169784
+ suppressTuiAiSdkWarnings();
169206
169785
  await new ZCodeTui(options).run();
169207
169786
  }
169208
169787
  //#endregion
169209
- export { loginFailureDiagnostic, runTui, shouldSuspendForLoginCommand, shouldUseNoBrowserForLogin, suspendedZaiLoginCommand };
169788
+ export { loginFailureDiagnostic, runTui, shouldSuspendForLoginCommand, shouldUseNoBrowserForLogin, suppressTuiAiSdkWarnings, suspendedZaiLoginCommand };