zcode-app-cli 3.9.2-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 +1 -0
  2. package/config.example.json +1 -0
  3. package/package.json +3 -3
  4. package/vendor/extraction.json +4 -4
  5. package/vendor/node_modules/@zcode/tui/dist/index.js +750 -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 +660 -220
  9. package/vendor/packages/browser-use-plugin/docs/api.json +2 -2
  10. package/vendor/packages/browser-use-plugin/docs/overview.md +1 -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 +2 -2
  16. package/vendor/packages/browser-use-plugin/skills/control-browser/SKILL.md +2 -2
  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 +6 -3
  21. package/vendor/packages/zcode-cua-plugin/.zcode-plugin/plugin.json +2 -2
  22. package/vendor/packages/zcode-cua-plugin/dist/mcp/server.js +2 -2
  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 +1 -1
  35. package/vendor/zcode.cjs +773 -771
  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))();
@@ -100,6 +100,7 @@ var config_example_default = {
100
100
  ui: {
101
101
  "locale": "auto",
102
102
  "theme": "auto",
103
+ "tuiMode": "regular",
103
104
  "notifications": {
104
105
  "method": "auto",
105
106
  "condition": "unfocused"
@@ -157014,18 +157015,18 @@ function backgroundAgentToolName(name) {
157014
157015
  const normalized = name?.trim().toLowerCase();
157015
157016
  return normalized === "agent" || normalized === "subagent";
157016
157017
  }
157017
- function record$1(value) {
157018
+ function record$2(value) {
157018
157019
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
157019
157020
  }
157020
157021
  function explicitlyBackgroundAgentInput(value) {
157021
- return record$1(value)?.run_in_background === true;
157022
+ return record$2(value)?.run_in_background === true;
157022
157023
  }
157023
157024
  function asyncAgentResult(value) {
157024
- const root = record$1(value);
157025
+ const root = record$2(value);
157025
157026
  return [
157026
157027
  root,
157027
- record$1(root?.output),
157028
- record$1(root?.result)
157028
+ record$2(root?.output),
157029
+ record$2(root?.result)
157029
157030
  ].some((candidate) => candidate?.isAsync === true || candidate?.status === "async_launched" || candidate?.status === "backgrounded" || typeof candidate?.backgroundTaskId === "string");
157030
157031
  }
157031
157032
  function toolScope(event) {
@@ -157451,6 +157452,47 @@ function isWindowedComponent(component) {
157451
157452
  }
157452
157453
  //#endregion
157453
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
+ }
157454
157496
  var ChoiceItemDetails = class {
157455
157497
  item;
157456
157498
  theme;
@@ -157669,11 +157711,13 @@ function choose(ui, host, theme, options) {
157669
157711
  };
157670
157712
  dialog.setSelectionPreview(previewFor(list.getSelectedItem()));
157671
157713
  let settled = false;
157714
+ let overlayHandle;
157672
157715
  const finish = (item) => {
157673
157716
  if (settled) return;
157674
157717
  settled = true;
157675
157718
  options.signal?.removeEventListener("abort", onAbort);
157676
- host.removeChild(dialog);
157719
+ if (overlayHandle) overlayHandle.hide();
157720
+ else host.removeChild(dialog);
157677
157721
  ui.requestRender();
157678
157722
  resolve(item);
157679
157723
  };
@@ -157681,8 +157725,10 @@ function choose(ui, host, theme, options) {
157681
157725
  list.onSelect = (item) => finish(choicesByValue.get(item.value) ?? null);
157682
157726
  list.onSelectionChange = (item) => dialog.setSelectionPreview(previewFor(item));
157683
157727
  list.onCancel = () => finish(null);
157684
- host.addChild(dialog);
157685
- 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);
157686
157732
  ui.requestRender();
157687
157733
  options.signal?.addEventListener("abort", onAbort, { once: true });
157688
157734
  if (options.signal?.aborted) finish(null);
@@ -157694,6 +157740,7 @@ var TextPromptDialog = class {
157694
157740
  input;
157695
157741
  theme;
157696
157742
  help;
157743
+ focused = false;
157697
157744
  constructor(title, prompt, input, theme, help) {
157698
157745
  this.title = title;
157699
157746
  this.prompt = prompt;
@@ -157703,6 +157750,7 @@ var TextPromptDialog = class {
157703
157750
  }
157704
157751
  render(width) {
157705
157752
  const safeWidth = Math.max(1, width);
157753
+ if ("focused" in this.input) this.input.focused = this.focused;
157706
157754
  return [
157707
157755
  ...wrapTerminalText(this.theme.bold(this.title), safeWidth),
157708
157756
  ...wrapTerminalText(this.theme.muted(this.prompt), safeWidth),
@@ -157712,6 +157760,9 @@ var TextPromptDialog = class {
157712
157760
  ...wrapTerminalText(this.theme.muted(this.help), safeWidth)
157713
157761
  ];
157714
157762
  }
157763
+ handleInput(data) {
157764
+ this.input.handleInput?.(data);
157765
+ }
157715
157766
  invalidate() {
157716
157767
  this.input.invalidate();
157717
157768
  }
@@ -157777,19 +157828,23 @@ function promptText(ui, host, theme, options) {
157777
157828
  else input.setValue(options.initialValue);
157778
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 }));
157779
157830
  let settled = false;
157831
+ let overlayHandle;
157780
157832
  const finish = (value) => {
157781
157833
  if (settled) return;
157782
157834
  settled = true;
157783
157835
  options.signal?.removeEventListener("abort", onAbort);
157784
- host.removeChild(dialog);
157836
+ if (overlayHandle) overlayHandle.hide();
157837
+ else host.removeChild(dialog);
157785
157838
  ui.requestRender();
157786
157839
  resolve(value);
157787
157840
  };
157788
157841
  const onAbort = () => finish(null);
157789
157842
  input.onSubmit = (value) => finish(value);
157790
157843
  input.onEscape = () => finish(null);
157791
- host.addChild(dialog);
157792
- 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);
157793
157848
  ui.requestRender();
157794
157849
  options.signal?.addEventListener("abort", onAbort, { once: true });
157795
157850
  if (options.signal?.aborted) finish(null);
@@ -157952,6 +158007,29 @@ function normalizeEvent(value) {
157952
158007
  function isModelCancellationEvent(event) {
157953
158008
  return event.type === "model_request_failed" && (event.reason?.toLowerCase() === "cancelled" || event.errorCode?.toLowerCase() === "model_request_cancelled" || event.exceptionType?.toLowerCase() === "aborterror");
157954
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
+ }
157955
158033
  function responseText(value) {
157956
158034
  if (!isRecord(value)) return void 0;
157957
158035
  return asString(value.response) ?? asString(value.message) ?? asString(value.text);
@@ -161727,11 +161805,11 @@ function findExecutable(name, env = process.env, platform = process.platform) {
161727
161805
  }
161728
161806
  return null;
161729
161807
  }
161730
- function record(value) {
161808
+ function record$1(value) {
161731
161809
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
161732
161810
  }
161733
161811
  function configuredNotifications(config) {
161734
- return record(record(record(config)?.ui)?.notifications);
161812
+ return record$1(record$1(record$1(config)?.ui)?.notifications);
161735
161813
  }
161736
161814
  function notificationSettings(env = process.env, config) {
161737
161815
  const configured = configuredNotifications(config);
@@ -161750,7 +161828,7 @@ async function readStoredNotificationSettings(env = process.env) {
161750
161828
  }
161751
161829
  async function writeNotificationSettings(settings, env = process.env) {
161752
161830
  return await updateUserConfig((config) => {
161753
- const ui = record(config.ui) ?? {};
161831
+ const ui = record$1(config.ui) ?? {};
161754
161832
  ui.notifications = { ...settings };
161755
161833
  config.ui = ui;
161756
161834
  }, env);
@@ -161968,6 +162046,33 @@ var TurnNotifier = class {
161968
162046
  }
161969
162047
  };
161970
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
161971
162076
  //#region packages/zcode-tui/src/selectors.ts
161972
162077
  function pickerRequest(input, commands) {
161973
162078
  const match = /^\/([^\s]+)(?:\s+(.*))?$/u.exec(input.trim());
@@ -163985,7 +164090,16 @@ function resultContent(value, expanded) {
163985
164090
  function errorText(value) {
163986
164091
  if (value instanceof Error) return sanitizeTerminalText(value.message, { preserveSgr: false });
163987
164092
  const direct = asString(value);
163988
- 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;
163989
164103
  }
163990
164104
  function statePresentation(state, theme) {
163991
164105
  const normalized = state.toLowerCase();
@@ -164030,7 +164144,7 @@ function statePresentation(state, theme) {
164030
164144
  }
164031
164145
  function stateBackground(state, theme) {
164032
164146
  const normalized = state.toLowerCase();
164033
- if (normalized === "failed" || normalized === "error" || normalized === "cancelled") return theme.toolErrorBackground;
164147
+ if (normalized === "failed" || normalized === "error") return theme.toolErrorBackground;
164034
164148
  return normalized === "waiting_permission" ? theme.toolPendingBackground : void 0;
164035
164149
  }
164036
164150
  function stylePreview(value, theme, expanded) {
@@ -164064,6 +164178,11 @@ function toolText(options, theme, input = parsedInput(options), expanded = false
164064
164178
  summary && theme.muted(oneLine$2(summary)),
164065
164179
  presentation.suffix && theme.muted(`· ${presentation.suffix}`)
164066
164180
  ].filter(Boolean).join(" ");
164181
+ if (options.state.toLowerCase() === "cancelled") return {
164182
+ header,
164183
+ images: [],
164184
+ truncated: false
164185
+ };
164067
164186
  const sections = [];
164068
164187
  let truncated = false;
164069
164188
  const mutation = mutationInput(options.name, input);
@@ -164706,6 +164825,14 @@ var TurnWorkTracker = class {
164706
164825
  this.awaitingProjection = awaitProjection;
164707
164826
  return this.isActive();
164708
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
+ }
164709
164836
  reconcile(projection) {
164710
164837
  const jobs = projection.backgroundJobs;
164711
164838
  for (const job of jobs) {
@@ -164746,18 +164873,20 @@ var UpdateAvailableView = class extends Box {
164746
164873
  }
164747
164874
  };
164748
164875
  //#endregion
164749
- //#region packages/zcode-tui/src/welcome-banner.ts
164750
- /** A terminal interpretation of the split, diagonal Z in the Desktop app icon. */
164751
- const BRAND_MARK = [
164752
- "█████ ▄███",
164753
- " ▄██▀ ",
164754
- " ▄██▀ ",
164755
- "▄███ █████"
164756
- ];
164757
- const maxInformationWidth = 52;
164758
- const boxTitle = "── SYSTEM INITIATED ";
164759
- function bannerText(value) {
164760
- 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;
164761
164890
  }
164762
164891
  function truncateFromStart(value, width) {
164763
164892
  if (width <= 0) return "";
@@ -164770,84 +164899,116 @@ function truncateFromStart(value, width) {
164770
164899
  }
164771
164900
  return `…${suffix.join("")}`;
164772
164901
  }
164773
- function padTerminalText(value, width) {
164774
- const truncated = truncateToWidth(value, Math.max(0, width), "…");
164775
- return `${truncated}${" ".repeat(Math.max(0, width - visibleWidth(truncated)))}`;
164776
- }
164777
- function boxRule(prefix, width) {
164778
- const content = prefix === "┌" ? boxTitle : "";
164779
- return `${prefix}${content}${"─".repeat(Math.max(0, width - 1 - visibleWidth(content)))}`;
164780
- }
164781
- 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 {
164782
164938
  theme;
164939
+ phase = "welcome";
164783
164940
  branch;
164784
164941
  distributionVersion;
164785
164942
  runtimeVersion;
164786
164943
  workspace;
164944
+ homeDirectory;
164787
164945
  constructor(theme, options) {
164788
164946
  this.theme = theme;
164789
- this.branch = options.branch ? bannerText(options.branch) : void 0;
164790
- this.distributionVersion = options.distributionVersion ? bannerText(options.distributionVersion) : void 0;
164791
- this.runtimeVersion = bannerText(options.runtimeVersion);
164792
- 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));
164793
164967
  }
164794
164968
  render(width) {
164795
- if (width <= 0) return [""];
164796
- 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)];
164797
164976
  }
164798
164977
  invalidate() {}
164799
- renderWide(width) {
164800
- const contentWidth = Math.max(1, width - 1);
164801
- const gap = " ";
164802
- const informationWidth = Math.max(1, contentWidth - 10 - 3);
164803
- const panelWidth = Math.min(informationWidth, maxInformationWidth);
164804
- const panelContentWidth = Math.max(1, panelWidth - 2);
164805
- const primaryVersion = this.distributionVersion ?? this.runtimeVersion;
164806
- const identity = `${this.theme.bold(this.theme.accent("ZCODE"))} ${this.theme.muted(`v${primaryVersion}`)}`;
164807
- const fullVersionLine = this.distributionVersion ? `${identity}${this.theme.muted(` · runtime v${this.runtimeVersion}`)}` : identity;
164808
- const compactVersionLine = this.distributionVersion ? `${identity}${this.theme.muted(` · rt v${this.runtimeVersion}`)}` : identity;
164809
- const versionLine = visibleWidth(fullVersionLine) <= panelContentWidth ? fullVersionLine : compactVersionLine;
164810
- const locationLine = this.locationLine(panelContentWidth);
164811
- const information = [
164812
- this.theme.muted(boxRule("┌", panelWidth)),
164813
- `${this.theme.muted("│")} ${padTerminalText(versionLine, panelContentWidth)}`,
164814
- `${this.theme.muted("│")} ${this.theme.muted(padTerminalText(locationLine, panelContentWidth))}`,
164815
- this.theme.muted(boxRule("└", panelWidth))
164816
- ];
164817
- return BRAND_MARK.map((line, index) => ` ${this.theme.accent(line)}${gap}${information[index] ?? ""}`);
164818
- }
164819
- locationLine(width) {
164820
- if (!this.branch) return truncateFromStart(this.workspace, width);
164821
- const separator = " · ";
164822
- const branchWidth = Math.max(8, Math.min(visibleWidth(`branch ${this.branch}`), Math.floor(width * .45)));
164823
- const branch = truncateToWidth(`branch ${this.branch}`, branchWidth, "…");
164824
- const workspaceWidth = width - visibleWidth(separator) - visibleWidth(branch);
164825
- if (workspaceWidth < 4) return truncateToWidth(branch, width, "…");
164826
- return `${truncateFromStart(this.workspace, workspaceWidth)}${separator}${branch}`;
164827
- }
164828
- renderCompact(width) {
164829
- const contentWidth = Math.max(0, width - 1);
164830
- const primaryVersion = this.distributionVersion ?? this.runtimeVersion;
164831
- const identity = `${this.theme.bold(this.theme.accent("ZCODE"))} ${this.theme.muted(`v${primaryVersion}`)}`;
164832
- const location = [this.workspace, this.branch ? `branch ${this.branch}` : void 0].filter((value) => Boolean(value)).join(" · ");
164833
- return [` ${truncateToWidth(identity, contentWidth)}`, ` ${this.theme.muted(truncateFromStart(location, contentWidth))}`];
164834
- }
164835
164978
  };
164836
- /** A quiet full-width rule separating startup identity from the conversation. */
164837
- var Divider = class {
164838
- char;
164839
- style;
164840
- constructor(char, style) {
164841
- this.char = char;
164842
- 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;
164843
165002
  }
164844
165003
  render(width) {
164845
- if (width <= 0) return [""];
164846
- const baseWidth = Math.max(0, width - 1);
164847
- if (baseWidth < 8) return [` ${this.style(this.char.repeat(baseWidth))}`];
164848
- const prefix = `${this.char.repeat(3)}◆`;
164849
- const suffix = this.char.repeat(Math.max(0, baseWidth - visibleWidth(prefix)));
164850
- 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;
164851
165012
  }
164852
165013
  invalidate() {}
164853
165014
  };
@@ -165270,6 +165431,7 @@ const runtimeCommandSummaries = /* @__PURE__ */ new Map([
165270
165431
  ]);
165271
165432
  const terminalThemeQueryTimeoutMs = 100;
165272
165433
  const exitUsageQueryTimeoutMs = 250;
165434
+ const fullscreenWelcomeTransitionMs = 180;
165273
165435
  const updateAvailableBlockId = "update_available";
165274
165436
  const modelRetryBlockIdPrefix = "model_retry_status";
165275
165437
  const questionBackValue = "__back__";
@@ -165386,6 +165548,63 @@ var ConditionalContainer = class extends Container {
165386
165548
  return this.visible() ? super.render(width) : [];
165387
165549
  }
165388
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
+ }
165389
165608
  var ZCodeTui = class {
165390
165609
  options;
165391
165610
  animateTurnTimer;
@@ -165397,6 +165616,14 @@ var ZCodeTui = class {
165397
165616
  transcript;
165398
165617
  choiceHost = new Container();
165399
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;
165400
165627
  runtimeActivity;
165401
165628
  status;
165402
165629
  turnStatus;
@@ -165439,8 +165666,10 @@ var ZCodeTui = class {
165439
165666
  currentToolGroupBlockId;
165440
165667
  currentToolGroupMessageId;
165441
165668
  pendingAttachments = [];
165669
+ editorHistory = [];
165442
165670
  mode;
165443
165671
  model;
165672
+ tuiMode;
165444
165673
  thoughtLevel;
165445
165674
  modelOptions;
165446
165675
  effortOptions;
@@ -165456,6 +165685,9 @@ var ZCodeTui = class {
165456
165685
  workflowRefreshInFlight = false;
165457
165686
  choiceDepth = 0;
165458
165687
  settingSwitchInFlight = false;
165688
+ fullscreenWelcomeVisible = true;
165689
+ fullscreenWelcomeTransitionTimer;
165690
+ sessionHasContent = false;
165459
165691
  rewindEscapePending = false;
165460
165692
  rewindEscapeTimer;
165461
165693
  rewindFlowActive = false;
@@ -165487,8 +165719,6 @@ var ZCodeTui = class {
165487
165719
  backgroundHandoffInterruptInFlight = false;
165488
165720
  updateCheckAbortController;
165489
165721
  loginRequired;
165490
- loginWarning = new Text("", 1, 0);
165491
- loginHelp = new Text("", 1, 0);
165492
165722
  constructor(options) {
165493
165723
  this.options = options;
165494
165724
  this.animateTurnTimer = turnTimerAnimationEnabled();
@@ -165497,6 +165727,18 @@ var ZCodeTui = class {
165497
165727
  this.distributionVersion = sanitizeTerminalText(process.env.ZCODE_APP_CLI_VERSION?.trim() ?? "", { preserveSgr: false }) || void 0;
165498
165728
  this.theme = createTheme(this.colorsEnabled, initialColorScheme(this.themePreference));
165499
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
+ });
165500
165742
  this.mode = normalizedMode(options.initialMode);
165501
165743
  this.model = modelLabel$1(options.initialModel);
165502
165744
  this.thoughtLevel = options.initialThoughtLevel;
@@ -165504,7 +165746,8 @@ var ZCodeTui = class {
165504
165746
  this.effortOptions = [...options.effortOptions ?? []];
165505
165747
  this.loginRequired = options.loginRequired === true;
165506
165748
  this.skillCatalog = new SkillCatalog(options.listSkills);
165507
- this.ui = new TUI(new ProcessTerminal(), true);
165749
+ this.tuiMode = resolveTuiMode(process.env, { ui: { tuiMode: options.initialTuiMode } });
165750
+ this.ui = this.createTui(this.tuiMode);
165508
165751
  this.notifications = new TurnNotifier({ writeTerminal: (data) => this.ui.terminal.write(data) });
165509
165752
  this.status = new StatusLine();
165510
165753
  this.turnStatus = new FooterBar();
@@ -165534,11 +165777,8 @@ var ZCodeTui = class {
165534
165777
  onRender: () => this.ui.requestRender()
165535
165778
  });
165536
165779
  this.runtimeActivity = new RuntimeActivityView(this.theme);
165537
- this.editor = new Editor(this.ui, this.theme.editor, {
165538
- paddingX: 1,
165539
- autocompleteMaxVisible: 7
165540
- });
165541
- 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));
165542
165782
  this.done = new Promise((resolve) => {
165543
165783
  this.resolveDone = resolve;
165544
165784
  });
@@ -165551,34 +165791,76 @@ var ZCodeTui = class {
165551
165791
  } catch (error) {
165552
165792
  notificationConfigError = error instanceof Error ? error.message : String(error);
165553
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 {}
165554
165805
  const updateCheck = this.distributionVersion ? await readStartupUpdate({ currentVersion: this.distributionVersion }).catch(() => void 0) : void 0;
165555
- this.ui.start();
165556
- await this.resolveTerminalColorScheme();
165557
- this.buildLayout();
165558
- if (notificationConfigError) this.addNotice(`Unable to load notification settings: ${notificationConfigError}`, "warning");
165559
- await this.restoreInitialTranscript();
165560
- if (updateCheck?.availableVersion && this.distributionVersion) this.addUpdateAvailable(this.distributionVersion, updateCheck.availableVersion);
165561
- this.bindInput();
165562
- this.notifications.start();
165563
- this.ui.setFocus(this.editor);
165564
- this.updateMetadata();
165565
- this.updateTurnStatus();
165566
- this.ui.requestRender(true);
165567
- this.startUpdateRefresh(updateCheck);
165568
- if (!this.loginRequired) this.refreshGoal();
165569
- if (!this.loginRequired) this.refreshSessionUsage();
165570
- if (await readSetupPending().catch(() => false)) if (await readConfiguredModelAccess().catch(() => null)) await clearSetupPending().catch(() => {});
165571
- else this.runFirstRunSetup();
165572
- this.scheduleRuntimePoll(0);
165573
- this.loadHistory();
165574
- if (this.options.subscribeSessionEvents) this.unsubscribeSession = this.options.subscribeSessionEvents((event) => {
165575
- this.onSessionEvent(event);
165576
- }) ?? void 0;
165577
- if (this.options.subscribeWorkflowEvents) this.unsubscribeWorkflow = this.options.subscribeWorkflowEvents((event) => {
165578
- this.debugEvent("workflow", event);
165579
- this.refreshWorkflowFromEvent();
165580
- }) ?? void 0;
165581
- 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();
165582
165864
  }
165583
165865
  async resolveTerminalColorScheme() {
165584
165866
  if (!this.colorsEnabled || this.themePreference !== "auto") return;
@@ -165588,43 +165870,251 @@ var ZCodeTui = class {
165588
165870
  if (colorScheme) this.theme.setColorScheme(colorScheme);
165589
165871
  } catch {}
165590
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
+ }
165591
165904
  buildLayout() {
165592
- const workspace = this.options.workspaceDirectory ?? process.cwd();
165593
- const runtimeVersion = sanitizeTerminalText(this.options.version ?? "unknown", { preserveSgr: false });
165594
- this.ui.addChild(new WelcomeBanner(this.theme, {
165595
- branch: this.options.workspaceGitBranch,
165596
- distributionVersion: this.distributionVersion,
165597
- runtimeVersion,
165598
- workspace
165599
- }));
165600
- this.ui.addChild(new Divider("─", this.theme.muted));
165601
- this.ui.addChild(this.loginWarning);
165602
- 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();
165603
165910
  this.updateLoginWarning();
165604
- this.ui.addChild(new Spacer(1));
165605
- this.ui.addChild(this.transcript);
165606
- this.ui.addChild(this.runtimeActivity);
165607
- 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();
165608
165925
  this.composerHost.addChild(this.turnStatus);
165609
165926
  this.composerHost.addChild(this.queuedInputView);
165610
165927
  this.composerHost.addChild(this.attachmentBar);
165611
- this.composerHost.addChild(this.editor);
165928
+ this.composerHost.addChild(this.editorHost);
165612
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);
165613
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);
165614
166030
  const commands = this.autocompleteCommands();
165615
166031
  const workspaceDirectory = this.options.workspaceDirectory ?? process.cwd();
165616
- this.editor.setAutocompleteProvider(new WorkspaceAutocompleteProvider(commands, workspaceDirectory, this.options.listWorkspacePathSuggestions, this.skillCatalog, this.options.listPluginReferences ?? createRuntimePluginReferenceLister(workspaceDirectory)));
165617
- 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
+ }
165618
166109
  }
165619
166110
  updateLoginWarning() {
165620
- const configPath = userConfigPathHint();
165621
- this.loginWarning.setText(this.loginRequired ? this.theme.warning("Model access is not configured.") : "");
165622
- this.loginHelp.setText(this.loginRequired ? this.theme.warning(`Run /login, or configure a custom provider in ${configPath}.`) : "");
166111
+ this.sessionWelcome.setLoginRequired(this.loginRequired);
165623
166112
  }
165624
166113
  setLoginRequired(required) {
165625
166114
  const changed = this.loginRequired !== required;
165626
166115
  this.loginRequired = required;
165627
166116
  this.updateLoginWarning();
166117
+ this.ui.requestRender();
165628
166118
  if (changed && !required) {
165629
166119
  this.refreshGoal();
165630
166120
  this.refreshSessionUsage();
@@ -165690,10 +166180,12 @@ var ZCodeTui = class {
165690
166180
  } catch (error) {
165691
166181
  failure = error instanceof Error ? error.message : String(error);
165692
166182
  } finally {
165693
- this.ui.start();
165694
- this.notifications.start();
165695
- this.ui.setFocus(this.editor);
165696
- 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
+ }
165697
166189
  }
165698
166190
  const access = code === 0 ? await readConfiguredModelAccess() : null;
165699
166191
  if (access) {
@@ -165796,6 +166288,13 @@ var ZCodeTui = class {
165796
166288
  this.clearRewindEscape();
165797
166289
  this.recentSteerCommit = void 0;
165798
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
+ }
165799
166298
  if (matchesKey(data, "up") && this.canEnterAttachmentSelection()) {
165800
166299
  this.enterAttachmentSelection();
165801
166300
  return { consume: true };
@@ -165915,7 +166414,10 @@ var ZCodeTui = class {
165915
166414
  const input = (queuedSubmission?.input ?? rawInput).trim();
165916
166415
  if (!input || this.stopped) return;
165917
166416
  const submission = queuedSubmission ?? protectSubmission(input);
165918
- if (submission.recordHistory) this.editor.addToHistory(input);
166417
+ if (submission.recordHistory) {
166418
+ this.rememberEditorHistory(input);
166419
+ this.editor.addToHistory(input);
166420
+ }
165919
166421
  if (input === "/exit" || input === "/quit") {
165920
166422
  this.stop();
165921
166423
  return;
@@ -166224,9 +166726,9 @@ var ZCodeTui = class {
166224
166726
  pendingInputIds: this.inputQueue.admittedPendingInputIds(),
166225
166727
  reason: "TUI interrupted the active model step to submit steer instructions.",
166226
166728
  reservationId: request.reservationId
166227
- }).then((outcome) => {
166729
+ }).then(() => {
166228
166730
  if (!this.isPendingSteerInterrupt(turnEpoch, abortController)) return;
166229
- if (!isRecord(outcome) || asString(outcome.kind) !== "stopped") abortController.abort();
166731
+ abortController.abort();
166230
166732
  }).catch(() => {
166231
166733
  if (this.isPendingSteerInterrupt(turnEpoch, abortController)) abortController.abort();
166232
166734
  });
@@ -166243,9 +166745,9 @@ var ZCodeTui = class {
166243
166745
  abortController.abort();
166244
166746
  return;
166245
166747
  }
166246
- interruptTurn({ reason: "TUI interrupted the active foreground turn." }).then((outcome) => {
166748
+ interruptTurn({ reason: "TUI interrupted the active foreground turn." }).then(() => {
166247
166749
  if (this.turnAbortController !== abortController || abortController.signal.aborted) return;
166248
- if (!isRecord(outcome) || asString(outcome.kind) !== "stopped") abortController.abort();
166750
+ abortController.abort();
166249
166751
  }).catch(() => {
166250
166752
  if (this.turnAbortController === abortController && !abortController.signal.aborted) abortController.abort();
166251
166753
  });
@@ -166293,6 +166795,7 @@ var ZCodeTui = class {
166293
166795
  emitSessionTerminalTitle(this.options.stdout ?? process.stdout, "");
166294
166796
  this.sessionMetrics = {};
166295
166797
  this.restoreTranscript(restoredMessages(result.restoredMessages));
166798
+ if (this.transcript.blockCount > 0) this.enterSessionRail(true);
166296
166799
  }
166297
166800
  const response = responseText(result);
166298
166801
  if (renderResponse && response) {
@@ -166405,10 +166908,11 @@ var ZCodeTui = class {
166405
166908
  this.updateToolView(tool, "running", event.result, void 0, event.progress);
166406
166909
  } else if (event.kind === "result") {
166407
166910
  const tool = this.ensureToolView(event.toolCallId, event.toolName, event.partId, event.messageId);
166408
- 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);
166409
166913
  } else if (event.kind === "error" && (event.toolCallId || event.toolName)) {
166410
166914
  const tool = this.ensureToolView(event.toolCallId, event.toolName, event.partId, event.messageId);
166411
- 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);
166412
166916
  } else if (event.kind === "closed" && (event.toolCallId || event.toolName)) {
166413
166917
  const tool = this.ensureToolView(event.toolCallId, event.toolName, event.partId, event.messageId);
166414
166918
  if (!tool.view.isTerminal()) this.updateToolView(tool, "complete", event.result, event.error, event.progress);
@@ -166633,7 +167137,7 @@ var ZCodeTui = class {
166633
167137
  display: part.resultDisplay
166634
167138
  } : part.output;
166635
167139
  if (part.output !== void 0 || part.resultDisplay !== void 0) tool.outputText = void 0;
166636
- this.updateToolView(tool, restoredToolState(part.status), result, part.error, {
167140
+ this.updateToolView(tool, isToolCancellation(part.error ?? result) ? "cancelled" : restoredToolState(part.status), result, part.error, {
166637
167141
  parentToolCallId: part.parentToolCallId,
166638
167142
  childToolCallId: part.childToolCallId,
166639
167143
  agentId: part.agentId,
@@ -166744,6 +167248,7 @@ var ZCodeTui = class {
166744
167248
  }
166745
167249
  clearTranscriptProjection() {
166746
167250
  this.transcript.clear();
167251
+ this.resetSessionPresentation();
166747
167252
  this.assistantStream.clear();
166748
167253
  this.currentThinking = void 0;
166749
167254
  this.currentThinkingPartId = void 0;
@@ -166755,6 +167260,7 @@ var ZCodeTui = class {
166755
167260
  this.currentToolGroupMessageId = void 0;
166756
167261
  }
166757
167262
  appendThinking(delta, partId, messageId) {
167263
+ if (delta.trim()) this.enterSessionRail();
166758
167264
  if (partId) {
166759
167265
  let view = this.thinkingParts.get(partId);
166760
167266
  if (!view) {
@@ -166791,6 +167297,7 @@ var ZCodeTui = class {
166791
167297
  }
166792
167298
  addUserMessage(text, attachmentCount = 0, messageId) {
166793
167299
  const safeText = sanitizeTerminalText(text, { preserveSgr: false });
167300
+ this.enterSessionRail();
166794
167301
  const suffix = attachmentCount > 0 ? ` [${attachmentCount} image${attachmentCount === 1 ? "" : "s"}]` : "";
166795
167302
  this.currentToolGroup = void 0;
166796
167303
  this.transcript.addBlock(new Text(`${this.theme.accent("›")} ${safeText}${this.theme.muted(suffix)}`, 1, 0), {
@@ -166801,6 +167308,7 @@ var ZCodeTui = class {
166801
167308
  this.ui.requestRender();
166802
167309
  }
166803
167310
  addAssistantMessage(text, partId, messageId) {
167311
+ this.enterSessionRail();
166804
167312
  this.currentToolGroup = void 0;
166805
167313
  this.transcript.addBlock(new RichMarkdown(text, 1, this.theme), {
166806
167314
  id: partId,
@@ -166859,6 +167367,7 @@ var ZCodeTui = class {
166859
167367
  });
166860
167368
  }
166861
167369
  ensureToolView(toolCallId, toolName, partId, messageId) {
167370
+ this.enterSessionRail();
166862
167371
  const anonymous = !toolCallId ? Array.from(this.toolViews.values()).findLast((tool) => tool.name === (toolName ?? "tool") && !tool.view.isTerminal()) : void 0;
166863
167372
  if (anonymous) {
166864
167373
  if (partId) {
@@ -167215,7 +167724,7 @@ var ZCodeTui = class {
167215
167724
  const submission = this.inputQueue.editLatestFollowUp();
167216
167725
  if (!submission) return;
167217
167726
  this.editor.setText(submission.input);
167218
- this.ui.setFocus(this.editor);
167727
+ this.focusEditor();
167219
167728
  }
167220
167729
  async attachClipboardImage() {
167221
167730
  if (!this.options.readClipboardImage) {
@@ -167260,7 +167769,7 @@ var ZCodeTui = class {
167260
167769
  }
167261
167770
  leaveAttachmentSelection() {
167262
167771
  this.attachmentBar.deactivate();
167263
- this.ui.setFocus(this.editor);
167772
+ this.focusEditor();
167264
167773
  this.ui.requestRender();
167265
167774
  }
167266
167775
  removePendingAttachment(index) {
@@ -167276,7 +167785,7 @@ var ZCodeTui = class {
167276
167785
  syncAttachmentBar() {
167277
167786
  const wasActive = this.attachmentBar.isActive();
167278
167787
  this.attachmentBar.setAttachments(this.pendingAttachments);
167279
- if (wasActive && !this.attachmentBar.isActive()) this.ui.setFocus(this.editor);
167788
+ if (wasActive && !this.attachmentBar.isActive()) this.focusEditor();
167280
167789
  this.ui.requestRender();
167281
167790
  }
167282
167791
  async requestPermission(requestValue, context) {
@@ -167840,6 +168349,7 @@ var ZCodeTui = class {
167840
168349
  const backend = notificationDeliveryLabel(effective.method, diagnostics.backend);
167841
168350
  const methodOverride = Boolean(process.env.ZCODE_TUI_NOTIFICATION_METHOD?.trim());
167842
168351
  const conditionOverride = Boolean(process.env.ZCODE_TUI_NOTIFICATION_CONDITION?.trim());
168352
+ const tuiModeOverride = process.env.ZCODE_TUI_MODE?.trim().toLowerCase();
167843
168353
  const savedConfig = await readUserConfig().then((config) => isRecord(config.model) ? config.model : void 0).catch(() => void 0);
167844
168354
  const savedModelLabel = typeof savedConfig?.main === "string" && savedConfig.main.trim() ? savedConfig.main : void 0;
167845
168355
  const setting = await this.showChoice({
@@ -167861,6 +168371,11 @@ var ZCodeTui = class {
167861
168371
  value: "notification-condition",
167862
168372
  label: "When to notify",
167863
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"}`
167864
168379
  }
167865
168380
  ],
167866
168381
  selectedIndex: selectedSettingIndex
@@ -167872,6 +168387,37 @@ var ZCodeTui = class {
167872
168387
  feedback = "Changes save immediately · Esc closes settings";
167873
168388
  continue;
167874
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
+ }
167875
168421
  selectedSettingIndex = setting.value === "notification-condition" ? 2 : setting.value === "notification-method" ? 1 : 0;
167876
168422
  let next = stored;
167877
168423
  let changedLabel;
@@ -168175,6 +168721,7 @@ var ZCodeTui = class {
168175
168721
  this.lastAssistantText = "";
168176
168722
  this.turnAssistantText = "";
168177
168723
  this.restoreTranscript(restored);
168724
+ if (this.transcript.blockCount > 0) this.enterSessionRail(true);
168178
168725
  this.editor.setText(target.text);
168179
168726
  }
168180
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.";
@@ -168837,7 +169384,7 @@ var ZCodeTui = class {
168837
169384
  return await choose(this.ui, this.choiceHost, this.theme, options);
168838
169385
  } finally {
168839
169386
  this.choiceDepth = Math.max(0, this.choiceDepth - 1);
168840
- this.ui.setFocus(this.editor);
169387
+ this.focusEditor();
168841
169388
  this.ui.requestRender();
168842
169389
  }
168843
169390
  }
@@ -168847,7 +169394,7 @@ var ZCodeTui = class {
168847
169394
  return await promptText(this.ui, this.choiceHost, this.theme, options);
168848
169395
  } finally {
168849
169396
  this.choiceDepth = Math.max(0, this.choiceDepth - 1);
168850
- this.ui.setFocus(this.editor);
169397
+ this.focusEditor();
168851
169398
  this.ui.requestRender();
168852
169399
  }
168853
169400
  }
@@ -168878,7 +169425,10 @@ var ZCodeTui = class {
168878
169425
  } catch {
168879
169426
  break;
168880
169427
  }
168881
- 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
+ }
168882
169432
  }
168883
169433
  async restoreInitialTranscript() {
168884
169434
  if (!this.options.loadSessionTranscript) return;
@@ -169145,7 +169695,10 @@ var ZCodeTui = class {
169145
169695
  this.finalizeUnresolvedTools(unfinishedToolState);
169146
169696
  this.turnDiffs.finishTurn();
169147
169697
  this.currentToolGroup = void 0;
169148
- 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();
169149
169702
  this.activity = void 0;
169150
169703
  this.refreshSessionTerminalTitle();
169151
169704
  this.updateTurnStatus();
@@ -169191,36 +169744,45 @@ var ZCodeTui = class {
169191
169744
  this.updateCheckAbortController?.abort();
169192
169745
  if (this.turnTimer) clearInterval(this.turnTimer);
169193
169746
  if (this.rewindEscapeTimer) clearTimeout(this.rewindEscapeTimer);
169747
+ if (this.fullscreenWelcomeTransitionTimer) clearTimeout(this.fullscreenWelcomeTransitionTimer);
169194
169748
  if (this.runtimeRefreshTimer) clearTimeout(this.runtimeRefreshTimer);
169195
169749
  if (this.runtimePollTimer) clearTimeout(this.runtimePollTimer);
169196
169750
  this.unsubscribeSession?.();
169197
169751
  this.unsubscribeWorkflow?.();
169198
169752
  const elapsedMilliseconds = this.turnStartedAt === void 0 ? this.turnElapsedMilliseconds : Math.max(0, performance.now() - this.turnStartedAt);
169199
- this.notifications.stop();
169200
- this.ui.stop();
169753
+ try {
169754
+ this.notifications.stop();
169755
+ } catch {}
169756
+ try {
169757
+ this.ui.stop();
169758
+ } catch {}
169201
169759
  this.finishStop(elapsedMilliseconds);
169202
169760
  }
169203
169761
  async finishStop(elapsedMilliseconds) {
169204
- await this.refreshExitUsage();
169205
- const summary = buildExitSummary({
169206
- elapsedMilliseconds,
169207
- metrics: this.sessionMetrics,
169208
- sessionId: this.sessionId ?? this.runtimeProjection?.sessionId,
169209
- width: this.ui.terminal.columns
169210
- });
169211
- const lines = [
169212
- summary.divider && this.theme.muted(summary.divider),
169213
- summary.tokenUsage,
169214
- summary.resumeCommand ? `To continue this session, run ${this.theme.accent(summary.resumeCommand)}` : void 0
169215
- ].filter((line) => Boolean(line));
169216
- if (lines.length > 0) try {
169217
- (this.options.stdout ?? process.stdout).write(`${lines.join("\n")}\n`);
169218
- } catch {}
169219
- 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
+ }
169220
169781
  }
169221
169782
  };
169222
169783
  async function runTui(options) {
169784
+ suppressTuiAiSdkWarnings();
169223
169785
  await new ZCodeTui(options).run();
169224
169786
  }
169225
169787
  //#endregion
169226
- export { loginFailureDiagnostic, runTui, shouldSuspendForLoginCommand, shouldUseNoBrowserForLogin, suspendedZaiLoginCommand };
169788
+ export { loginFailureDiagnostic, runTui, shouldSuspendForLoginCommand, shouldUseNoBrowserForLogin, suppressTuiAiSdkWarnings, suspendedZaiLoginCommand };