@builder.io/buildercode 0.3.5 → 0.3.8

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 (2) hide show
  1. package/dist/cli.mjs +1867 -1134
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -51101,7 +51101,7 @@ function parameterize(strings, ...values) {
51101
51101
  * @param values Expressions extracted from template string
51102
51102
  * @returns A `ParameterizedString` object that can be passed into `captureMessage` or Sentry.logger.X methods.
51103
51103
  */
51104
- const fmt = parameterize;
51104
+ const fmt$1 = parameterize;
51105
51105
  //#endregion
51106
51106
  //#region ../../node_modules/@sentry/core/build/esm/utils/sdkMetadata.js
51107
51107
  /**
@@ -53095,7 +53095,7 @@ var exports_exports = /* @__PURE__ */ __exportAll({
53095
53095
  debug: () => debug$3,
53096
53096
  error: () => error,
53097
53097
  fatal: () => fatal,
53098
- fmt: () => fmt,
53098
+ fmt: () => fmt$1,
53099
53099
  info: () => info,
53100
53100
  trace: () => trace$1,
53101
53101
  warn: () => warn
@@ -244266,7 +244266,7 @@ const LIB_CACHE = /* @__PURE__ */ new Map();
244266
244266
  const PENDING_LIB_CACHE = /* @__PURE__ */ new Map();
244267
244267
  const NODE_MODULE_CACHE = /* @__PURE__ */ new Map();
244268
244268
  const TSCONFIG_CACHE = /* @__PURE__ */ new Map();
244269
- const pkgVersion = process.env.OVERRIDE_VERSION ?? "0.3.5";
244269
+ const pkgVersion = process.env.OVERRIDE_VERSION ?? "0.3.8";
244270
244270
  //#endregion
244271
244271
  //#region ../dev-tools/core/detect-frameworks.ts
244272
244272
  async function detectFrameworks$1(sys) {
@@ -290208,7 +290208,7 @@ function wc$1({ parent: e }) {
290208
290208
  default: return !1;
290209
290209
  }
290210
290210
  }
290211
- function _c$16({ parent: e, grandparent: t }) {
290211
+ function _c$17({ parent: e, grandparent: t }) {
290212
290212
  return t?.type === "JSXAttribute" && e.type === "JSXExpressionContainer" && t.name.type === "JSXIdentifier" && t.name.name === "css";
290213
290213
  }
290214
290214
  async function co(e, t, r) {
@@ -295224,7 +295224,7 @@ var init_estree = __esmMin((() => {
295224
295224
  (e, t) => e.type === "CallExpression" && e.callee.type === "Identifier" && e.callee.name === "Component" && t === "arguments",
295225
295225
  (e, t) => e.type === "Decorator" && t === "expression"
295226
295226
  ];
295227
- po$1 = (e) => Oc$1(e) || wc$1(e) || _c$16(e) || oo$2(e);
295227
+ po$1 = (e) => Oc$1(e) || wc$1(e) || _c$17(e) || oo$2(e);
295228
295228
  Es$6 = 0;
295229
295229
  fo = mo.bind(void 0, "html"), yo = mo.bind(void 0, "angular");
295230
295230
  jc = [
@@ -399401,7 +399401,7 @@ function xc(t, e, s = {}) {
399401
399401
  let r = It(t, s.backwards ? e - 1 : e, s);
399402
399402
  return r !== Gt(t, r, s);
399403
399403
  }
399404
- function _c$15(t, e) {
399404
+ function _c$16(t, e) {
399405
399405
  if (e === !1) return !1;
399406
399406
  if (t.charAt(e) === "/" && t.charAt(e + 1) === "*") {
399407
399407
  for (let s = e + 2; s < t.length; ++s) if (t.charAt(s) === "*" && t.charAt(s + 1) === "/") return s + 2;
@@ -405226,7 +405226,7 @@ https://evilmartians.com/chronicles/postcss-8-plugin-migration`));
405226
405226
  ` || t === "\r" || t === "\u2028" || t === "\u2029";
405227
405227
  Gt = vc;
405228
405228
  Yt = xc;
405229
- xi$1 = _c$15;
405229
+ xi$1 = _c$16;
405230
405230
  _i = bc;
405231
405231
  Vt$1 = Ec;
405232
405232
  De = Oc;
@@ -520772,13 +520772,7 @@ Tips:
520772
520772
  ...this.#lastAICommits,
520773
520773
  ...allCommits
520774
520774
  };
520775
- if (!(await this.#emitGitStatus())?.currentCommit) {
520776
- this.#sys.Sentry?.captureException(/* @__PURE__ */ new Error(`Failed to get current commit hash after revert`), { tags: {
520777
- operation: "codegen-git",
520778
- endpoint: "revertToCommitHash"
520779
- } });
520780
- return;
520781
- }
520775
+ await this.#emitGitStatus();
520782
520776
  this.requestRefresh();
520783
520777
  await this.#completionFinalize({ lastCommit: serializeGitSnapshot(allCommits) });
520784
520778
  }
@@ -521191,6 +521185,7 @@ Tips:
521191
521185
  this.#preventMessageFlush = false;
521192
521186
  this.clearMessageQueue();
521193
521187
  this.queueGitStatusReminder({ trigger: "session-start" });
521188
+ this.#emitter.emit("step", this.#getSessionEvent());
521194
521189
  }
521195
521190
  async clearMessageQueue(emitUserMessages = false) {
521196
521191
  const userMessages = [];
@@ -521531,7 +521526,7 @@ Make the necessary changes and try again.`
521531
521526
  options: {
521532
521527
  sys: this.#sys,
521533
521528
  credentials: this.#credentials,
521534
- position: agent?.position ?? `${basePosition}-agent`,
521529
+ position: agent?.position ?? `${basePosition}-${subagentType}`,
521535
521530
  mode,
521536
521531
  includeMemories,
521537
521532
  modelOverride: agent?.inheritSessionModel && (this.#lastModelOverride ?? this.#modelOverride) ? this.#lastModelOverride ?? this.#modelOverride : resolveModelShortcut(resolvedModel) ?? this.#lastModelOverride ?? this.#modelOverride,
@@ -521576,7 +521571,10 @@ Make the necessary changes and try again.`
521576
521571
  checkpointCommitHash = (await this.#emitGitStatus())?.currentCommit;
521577
521572
  }
521578
521573
  const subagent_type = agentConfig.subagent_type;
521579
- const agentSession = new CodeGenSession(agentConfig.options);
521574
+ const agentSession = new CodeGenSession({
521575
+ ...agentConfig.options,
521576
+ git: false
521577
+ });
521580
521578
  const subAgentId = options.sessionId ?? options.resume ?? sessionId;
521581
521579
  const agentPromise = Promise.withResolvers();
521582
521580
  this.#runningSubAgents.set(subAgentId, {
@@ -521625,7 +521623,7 @@ Make the necessary changes and try again.`
521625
521623
  });
521626
521624
  }
521627
521625
  if (step.type === "tool") timeline.onToolCall(step.name, step.id, step.content);
521628
- if (step.type === "planning") timeline.onThinking(step.content);
521626
+ if (step.type === "thinking") timeline.onThinking(step.content);
521629
521627
  if (step.type === "tool_result") {
521630
521628
  const prevFrameCount = timeline.getFrameCount();
521631
521629
  timeline.onToolResult(step.result, getLastCursorPosition());
@@ -522620,11 +522618,9 @@ Make the necessary changes and try again.`
522620
522618
  this.#isCheckingGitStatus--;
522621
522619
  }
522622
522620
  }
522623
- #replayTurns() {
522621
+ #getSessionEvent() {
522624
522622
  const sessionContext = this.getSessionContext();
522625
- const turns = sessionContext.turns;
522626
- const steps = [];
522627
- steps.push({
522623
+ return {
522628
522624
  type: "session",
522629
522625
  title: sessionContext.title,
522630
522626
  beforeCommit: sessionContext.beforeCommit,
@@ -522644,7 +522640,12 @@ Make the necessary changes and try again.`
522644
522640
  isSkill: instruction.isSkill ?? instruction.filePath?.toLowerCase().includes("/skills/") ?? false
522645
522641
  })),
522646
522642
  hasPlanToApply: this.#hasPlanToApply
522647
- });
522643
+ };
522644
+ }
522645
+ #replayTurns() {
522646
+ const turns = this.getSessionContext().turns;
522647
+ const steps = [];
522648
+ steps.push(this.#getSessionEvent());
522648
522649
  if (Object.keys(this.#lastMetadata).length > 0) steps.push({
522649
522650
  type: "metadata",
522650
522651
  ...this.#lastMetadata
@@ -522709,7 +522710,7 @@ Make the necessary changes and try again.`
522709
522710
  }
522710
522711
  } catch {}
522711
522712
  } else if (action.type === "thinking") steps.push({
522712
- type: "planning",
522713
+ type: "thinking",
522713
522714
  content: action.content
522714
522715
  });
522715
522716
  else if (action.type === "text") steps.push({
@@ -523116,6 +523117,7 @@ Make the necessary changes and try again.`
523116
523117
  let includeUserMessage = true;
523117
523118
  let hasChanges = false;
523118
523119
  let needGitStatus = false;
523120
+ let navigatePreviewCalled = false;
523119
523121
  let userInput;
523120
523122
  let validationCount = 0;
523121
523123
  let healthIssueCount = 0;
@@ -523169,6 +523171,7 @@ Make the necessary changes and try again.`
523169
523171
  errors = 0;
523170
523172
  hasChanges ||= filesChanged;
523171
523173
  needGitStatus ||= filesChanged;
523174
+ navigatePreviewCalled ||= completionResult.navigatePreviewCalled;
523172
523175
  totalCompletions += completions;
523173
523176
  this.#pendingValidation ||= filesChanged;
523174
523177
  this.#currentMessage = void 0;
@@ -523283,7 +523286,7 @@ failed with code ${result.code}`,
523283
523286
  }
523284
523287
  await this.#commitAccumulatedChanges(true);
523285
523288
  const shouldRefresh = this.#fusionConfig?.refreshPreview ?? true;
523286
- if (hasChanges && shouldRefresh) this.requestRefresh();
523289
+ if (hasChanges && shouldRefresh && !navigatePreviewCalled) this.requestRefresh();
523287
523290
  }
523288
523291
  }
523289
523292
  async #generateCompletion(sessionContext, userInput, signal, onStep) {
@@ -523293,13 +523296,7 @@ failed with code ${result.code}`,
523293
523296
  const url = this.getLastTurn()?.nextUrl ?? this.#initialUrl;
523294
523297
  let filesChanged = false;
523295
523298
  let completions = 0;
523296
- onStep({
523297
- type: "start",
523298
- id: "",
523299
- name: "thinking",
523300
- title: "Thinking",
523301
- content: ""
523302
- });
523299
+ let navigatePreviewCalled = false;
523303
523300
  try {
523304
523301
  const artifacts = this.#onGoingArtifacts = [];
523305
523302
  if (!sessionContext.beforeCommit) {
@@ -523370,6 +523367,7 @@ failed with code ${result.code}`,
523370
523367
  projectId: this.#projectId,
523371
523368
  branchName: this.#branchName,
523372
523369
  repoHash: this.#repoHash,
523370
+ repoBranch: this.#aiBranch,
523373
523371
  pingEvents: true,
523374
523372
  workingDirectory: this.#bashWorkingDirectory,
523375
523373
  beforeCommit,
@@ -523458,6 +523456,7 @@ failed with code ${result.code}`,
523458
523456
  const turnState = lastTurn = await this.#finalizeTurn(sessionContext, json, lastTurn, beforeCommit);
523459
523457
  for (const action of json.actions ?? []) if (action.type === "tool_result") {
523460
523458
  if (action.filePath === "ExitPlanMode") this.#hasPlanToApply = true;
523459
+ if (action.filePath === "NavigatePreview") navigatePreviewCalled = true;
523461
523460
  onStep({
523462
523461
  type: "tool_result",
523463
523462
  result: {
@@ -523520,7 +523519,7 @@ failed with code ${result.code}`,
523520
523519
  };
523521
523520
  const closedAction = (json) => {
523522
523521
  if (json.type === "thinking") onStep({
523523
- type: "planning",
523522
+ type: "thinking",
523524
523523
  content: json.content
523525
523524
  });
523526
523525
  if (json.type === "server_tool_result") {
@@ -523606,6 +523605,7 @@ failed with code ${result.code}`,
523606
523605
  return {
523607
523606
  completions,
523608
523607
  filesChanged,
523608
+ navigatePreviewCalled,
523609
523609
  shouldContinue: shouldContinue || lastTurn.actions.some((a) => a.type === "tool") || lastTurn.autoContinue
523610
523610
  };
523611
523611
  } finally {
@@ -526250,7 +526250,10 @@ ${truncateLines(plan ?? "", 500)}
526250
526250
  isError: false,
526251
526251
  toolResult: isDeepResearch ? `Tech spec is about to be presented to the user. Do not communicate anything else, just acknowledge that the tech spec has been presented. Do not call any other tools.` : `Plan is about to be presented to the user. Waiting for user approval to proceed with implementation. Do not communicate anything else, just acknowledge that the plan has been presented. Do not start implementing anything yet or call any other tools.`,
526252
526252
  title: "Plan presented",
526253
- structuredResult: { sessionMode: toolContext.sessionMode }
526253
+ structuredResult: {
526254
+ sessionMode: toolContext.sessionMode,
526255
+ plan
526256
+ }
526254
526257
  };
526255
526258
  }
526256
526259
  async function proposeConfig(toolContext, input) {
@@ -526810,6 +526813,11 @@ async function getRipgrepExecutable(sys) {
526810
526813
  if (sys.existsSync(pkgBundledRgPath)) return pkgBundledRgPath;
526811
526814
  }
526812
526815
  } catch (error) {}
526816
+ try {
526817
+ const execDir = path$6.dirname(process.execPath);
526818
+ const siblingRgPath = path$6.join(execDir, rgFilename);
526819
+ if (sys.existsSync(siblingRgPath)) return siblingRgPath;
526820
+ } catch {}
526813
526821
  try {
526814
526822
  const platformKey = process.platform === "win32" ? "win32-x64" : `${process.platform}-${process.arch}`;
526815
526823
  const vendoredRgPath = path$6.join(__dirname$1, "..", "vendors", platformKey, rgFilename);
@@ -528439,6 +528447,7 @@ async function* completionStream(sys, credentials, body, signal, debug) {
528439
528447
  const res = await safeFetch(url, {
528440
528448
  method: "POST",
528441
528449
  body: json,
528450
+ keepalive: true,
528442
528451
  headers: {
528443
528452
  "Content-Type": "application/json",
528444
528453
  Authorization: `Bearer ${credentials.builderPrivateKey}`
@@ -530378,7 +530387,9 @@ async function getFusionConfig(sys, args) {
530378
530387
  "netlify *",
530379
530388
  "node *",
530380
530389
  "tsx *",
530381
- "builderio *"
530390
+ "builderio *",
530391
+ "builder *",
530392
+ "open *"
530382
530393
  ]
530383
530394
  };
530384
530395
  if (args.configJson) try {
@@ -531908,341 +531919,534 @@ var ScrollView = (0, import_react.forwardRef)(({ onScroll, onViewportSizeChange,
531908
531919
  });
531909
531920
  });
531910
531921
  //#endregion
531911
- //#region ../../node_modules/ink-multiline-input/dist/index.js
531912
- function expandTabs(text, tabSize) {
531913
- return text.replace(/\t/g, " ".repeat(tabSize));
531922
+ //#region src/hooks/useTextInput.ts
531923
+ const MOUSE_RE = /^\[<(\d+);\d+;\d+[Mm]/;
531924
+ function getLineStart(text, cursor) {
531925
+ return text.slice(0, cursor).lastIndexOf("\n") + 1;
531926
+ }
531927
+ function getLineEnd(text, cursor) {
531928
+ const next = text.slice(cursor).indexOf("\n");
531929
+ return next === -1 ? text.length : cursor + next;
531930
+ }
531931
+ function isOnFirstLine(text, cursor) {
531932
+ return !text.slice(0, cursor).includes("\n");
531933
+ }
531934
+ function isOnLastLine(text, cursor) {
531935
+ return !text.slice(cursor).includes("\n");
531936
+ }
531937
+ function getPrevWordStart(text, cursor) {
531938
+ let i = cursor - 1;
531939
+ while (i > 0 && /\s/.test(text[i])) i--;
531940
+ while (i > 0 && !/\s/.test(text[i - 1])) i--;
531941
+ return Math.max(0, i);
531942
+ }
531943
+ function getNextWordEnd(text, cursor) {
531944
+ let i = cursor;
531945
+ const len = text.length;
531946
+ while (i < len && /\s/.test(text[i])) i++;
531947
+ while (i < len && !/\s/.test(text[i])) i++;
531948
+ return i;
531914
531949
  }
531915
- function normalizeLineEndings(text) {
531916
- if (text == null) return "";
531917
- return text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
531950
+ function getPrevLineIndex(text, cursor) {
531951
+ const lines = text.split("\n");
531952
+ let pos = 0, lineIdx = 0, col = 0;
531953
+ for (let i = 0; i < lines.length; i++) {
531954
+ const lineEnd = pos + lines[i].length;
531955
+ if (cursor >= pos && cursor <= lineEnd) {
531956
+ lineIdx = i;
531957
+ col = cursor - pos;
531958
+ break;
531959
+ }
531960
+ pos = lineEnd + 1;
531961
+ }
531962
+ if (lineIdx === 0) return cursor;
531963
+ const targetLine = lines[lineIdx - 1];
531964
+ let newIdx = 0;
531965
+ for (let i = 0; i < lineIdx - 1; i++) newIdx += lines[i].length + 1;
531966
+ return newIdx + Math.min(col, targetLine.length);
531918
531967
  }
531919
- var MeasureBox = ({ children, onHeightChange }) => {
531920
- const ref = (0, import_react.useRef)(null);
531921
- const lastHeightRef = (0, import_react.useRef)(void 0);
531922
- (0, import_react.useEffect)(() => {
531923
- if (ref.current) {
531924
- const { height } = measureElement(ref.current);
531925
- if (lastHeightRef.current !== height) {
531926
- lastHeightRef.current = height;
531927
- onHeightChange?.(height);
531928
- }
531968
+ function getNextLineIndex(text, cursor) {
531969
+ const lines = text.split("\n");
531970
+ let pos = 0, lineIdx = 0, col = 0;
531971
+ for (let i = 0; i < lines.length; i++) {
531972
+ const lineEnd = pos + lines[i].length;
531973
+ if (cursor >= pos && cursor <= lineEnd) {
531974
+ lineIdx = i;
531975
+ col = cursor - pos;
531976
+ break;
531929
531977
  }
531930
- });
531931
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
531932
- ref,
531933
- flexShrink: 0,
531934
- flexGrow: 0,
531935
- width: "100%",
531936
- children
531937
- });
531938
- };
531939
- var ControlledMultilineInput = ({ value, rows, maxRows, highlightStyle, textStyle, placeholder = "", mask, showCursor = true, focus = true, tabSize = 4, cursorIndex = 0, highlight, refreshKey }) => {
531940
- const [scrollOffset, setScrollOffset] = (0, import_react.useState)(0);
531941
- const [contentHeight, setContentHeight] = (0, import_react.useState)(0);
531942
- const [markerHeight, setMarkerHeight] = (0, import_react.useState)(0);
531943
- const formatText = (0, import_react.useCallback)((text, isPlaceholder = false) => {
531944
- const normalized = normalizeLineEndings(text);
531945
- if (!isPlaceholder && mask) return normalized.replace(/[^\n]/g, mask);
531946
- return expandTabs(normalized, tabSize);
531947
- }, [tabSize, mask]);
531948
- const { preCursor, postCursor } = (0, import_react.useMemo)(() => {
531949
- if (!value) {
531950
- if (placeholder && !focus) return {
531951
- preCursor: [{
531952
- value: formatText(placeholder, true),
531953
- type: "placeholder"
531954
- }],
531955
- postCursor: []
531956
- };
531957
- return {
531958
- preCursor: [{
531959
- value: " ",
531960
- type: "cursor"
531961
- }],
531962
- postCursor: []
531963
- };
531978
+ pos = lineEnd + 1;
531979
+ }
531980
+ if (lineIdx >= lines.length - 1) return cursor;
531981
+ const targetLine = lines[lineIdx + 1];
531982
+ let newIdx = 0;
531983
+ for (let i = 0; i <= lineIdx; i++) newIdx += lines[i].length + 1;
531984
+ return newIdx + Math.min(col, targetLine.length);
531985
+ }
531986
+ function useTextInput(options = {}) {
531987
+ const { onSubmit, onChange, onScrollUp, onScrollDown, onTab, isActive = true, getIsMenuActive, submitDisabled = false, disableHistory = false } = options;
531988
+ const [value, setValueState] = (0, import_react.useState)("");
531989
+ const [cursorIndex, setCursorIndex] = (0, import_react.useState)(0);
531990
+ const [pasteLength, setPasteLength] = (0, import_react.useState)(0);
531991
+ const [history, setHistory] = (0, import_react.useState)([]);
531992
+ const [historyIndex, setHistoryIndex] = (0, import_react.useState)(-1);
531993
+ const [historyDraft, setHistoryDraft] = (0, import_react.useState)("");
531994
+ const valueRef = (0, import_react.useRef)(value);
531995
+ const cursorRef = (0, import_react.useRef)(cursorIndex);
531996
+ const historyRef = (0, import_react.useRef)(history);
531997
+ const historyIndexRef = (0, import_react.useRef)(historyIndex);
531998
+ const historyDraftRef = (0, import_react.useRef)(historyDraft);
531999
+ valueRef.current = value;
532000
+ cursorRef.current = cursorIndex;
532001
+ historyRef.current = history;
532002
+ historyIndexRef.current = historyIndex;
532003
+ historyDraftRef.current = historyDraft;
532004
+ const applyValue = (0, import_react.useCallback)((val, cursor) => {
532005
+ const nextCursor = cursor ?? val.length;
532006
+ setValueState(val);
532007
+ setCursorIndex(nextCursor);
532008
+ onChange?.(val);
532009
+ }, [onChange]);
532010
+ const setValue = (0, import_react.useCallback)((val_0, cursorPos) => {
532011
+ applyValue(val_0, cursorPos);
532012
+ }, [applyValue]);
532013
+ const clear = (0, import_react.useCallback)(() => {
532014
+ setValueState("");
532015
+ setCursorIndex(0);
532016
+ setPasteLength(0);
532017
+ setHistoryIndex(-1);
532018
+ setHistoryDraft("");
532019
+ onChange?.("");
532020
+ }, [onChange]);
532021
+ useInput((input, key) => {
532022
+ const val_1 = valueRef.current;
532023
+ const cursor_0 = cursorRef.current;
532024
+ const isMenuActive = getIsMenuActive?.() ?? false;
532025
+ const match = input.match(MOUSE_RE);
532026
+ if (match) {
532027
+ const button = parseInt(match[1], 10);
532028
+ if (button === 64) onScrollUp?.();
532029
+ else if (button === 65) onScrollDown?.();
532030
+ return;
531964
532031
  }
531965
- const textBefore = value.slice(0, cursorIndex);
531966
- const textAfter = value.slice(cursorIndex);
531967
- if (!focus) return {
531968
- preCursor: [{ value: formatText(value) }],
531969
- postCursor: []
531970
- };
531971
- if (!(highlight && highlight.end > highlight.start && highlight.start >= 0 && highlight.end <= value.length)) {
531972
- const formattedBefore = formatText(textBefore);
531973
- const formattedAfter = formatText(textAfter);
531974
- const lineStart = formattedBefore.lastIndexOf("\n") + 1;
531975
- const lineEnd = formattedAfter.indexOf("\n");
531976
- return {
531977
- preCursor: [
531978
- { value: formattedBefore.slice(0, lineStart) },
531979
- {
531980
- value: formattedBefore.slice(lineStart),
531981
- type: "highlight"
531982
- },
531983
- {
531984
- value: showCursor && focus ? " " : "",
531985
- type: "cursor"
531986
- }
531987
- ],
531988
- postCursor: [{
531989
- value: formattedAfter.slice(0, lineEnd),
531990
- type: "highlight"
531991
- }, { value: formattedAfter.slice(lineEnd) }]
531992
- };
531993
- } else return {
531994
- preCursor: [
531995
- { value: formatText(textBefore.slice(0, highlight.start)) },
531996
- {
531997
- value: formatText(textBefore.slice(highlight.start, Math.min(highlight.end, cursorIndex))),
531998
- type: "highlight"
531999
- },
532000
- { value: formatText(textBefore.slice(highlight.end)) },
532001
- {
532002
- value: " ",
532003
- type: "cursor"
532004
- }
532005
- ],
532006
- postCursor: [
532007
- { value: formatText(textAfter.slice(0, Math.max(highlight.start - cursorIndex, 0))) },
532008
- {
532009
- value: formatText(textAfter.slice(Math.max(highlight.start - cursorIndex, 0), Math.max(highlight.end - cursorIndex, 0))),
532010
- type: "highlight"
532011
- },
532012
- { value: formatText(textAfter.slice(Math.max(highlight.end - cursorIndex, 0))) }
532013
- ]
532014
- };
532015
- }, [
532016
- cursorIndex,
532017
- showCursor,
532018
- focus,
532019
- value,
532020
- placeholder,
532021
- mask,
532022
- highlight,
532023
- formatText,
532024
- refreshKey
532025
- ]);
532026
- const visibleRows = (0, import_react.useMemo)(() => {
532027
- if (contentHeight !== void 0) return Math.max(rows ?? maxRows ?? 1, Math.min(maxRows ?? rows ?? 1, contentHeight));
532028
- return 1;
532029
- }, [
532030
- rows,
532031
- maxRows,
532032
- contentHeight
532033
- ]);
532034
- (0, import_react.useEffect)(() => {
532035
- if (markerHeight !== void 0 && visibleRows !== void 0) {
532036
- const cursorLineEnd = markerHeight;
532037
- setScrollOffset((prevOffset) => {
532038
- const viewportStart = prevOffset;
532039
- const viewportEnd = prevOffset + visibleRows;
532040
- if (cursorLineEnd <= viewportStart) return Math.max(0, cursorLineEnd - 1);
532041
- else if (cursorLineEnd > viewportEnd) return cursorLineEnd - visibleRows;
532042
- else if (contentHeight) {
532043
- if (contentHeight < visibleRows) return 0;
532044
- else if (contentHeight < viewportEnd) return contentHeight - visibleRows;
532045
- }
532046
- return prevOffset;
532047
- });
532032
+ if (input.includes("[<") && /\d+;\d+;\d+[Mm]/.test(input)) return;
532033
+ if (key.tab && key.shift) return;
532034
+ if (key.tab && !isMenuActive) {
532035
+ onTab?.();
532036
+ return;
532048
532037
  }
532049
- }, [
532050
- markerHeight,
532051
- visibleRows,
532052
- contentHeight
532053
- ]);
532054
- const getStyle = (0, import_react.useCallback)((type) => {
532055
- switch (type) {
532056
- case "placeholder": return {
532057
- ...textStyle,
532058
- dimColor: true
532059
- };
532060
- case "highlight": return highlightStyle ?? textStyle;
532061
- case "cursor": return {
532062
- ...highlightStyle ?? textStyle,
532063
- inverse: showCursor && focus
532064
- };
532065
- default: return textStyle;
532038
+ if (isMenuActive && (key.upArrow || key.downArrow || key.return || key.escape)) return;
532039
+ if (key.return && !key.ctrl && !key.shift && !key.meta && !isMenuActive) {
532040
+ if (submitDisabled) return;
532041
+ if (val_1.trim()) setHistory((h) => [...h, val_1]);
532042
+ setHistoryIndex(-1);
532043
+ setHistoryDraft("");
532044
+ onSubmit?.(val_1);
532045
+ setValueState("");
532046
+ setCursorIndex(0);
532047
+ setPasteLength(0);
532048
+ onChange?.("");
532049
+ return;
532066
532050
  }
532067
- }, [
532068
- textStyle,
532069
- highlightStyle,
532070
- showCursor,
532071
- focus
532072
- ]);
532073
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
532074
- height: visibleRows,
532075
- overflow: "hidden",
532076
- flexDirection: "column",
532077
- flexGrow: 0,
532078
- flexShrink: 0,
532079
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
532080
- flexDirection: "column",
532081
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
532082
- height: visibleRows,
532083
- overflowY: "hidden",
532084
- flexShrink: 0,
532085
- flexDirection: "column",
532086
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
532087
- marginTop: -scrollOffset,
532088
- flexDirection: "column",
532089
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MeasureBox, {
532090
- onHeightChange: setContentHeight,
532091
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [preCursor?.map((segment, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
532092
- ...getStyle(segment.type),
532093
- children: segment.value
532094
- }, idx)), postCursor?.map((segment, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
532095
- ...getStyle(segment.type),
532096
- children: segment.value
532097
- }, idx))] })
532098
- })
532099
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spacer, {})]
532100
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MeasureBox, {
532101
- onHeightChange: setMarkerHeight,
532102
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: preCursor?.map((segment, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
532103
- ...getStyle(segment.type),
532104
- children: segment.value
532105
- }, idx)) })
532106
- })]
532107
- })
532108
- });
532109
- };
532110
- var MultilineInput = ({ value, onChange, onSubmit, keyBindings, showCursor = true, highlightPastedText = false, focus = true, useCustomInput = (inputHandler, isActive) => useInput(inputHandler, { isActive }), ...controlledProps }) => {
532111
- const [cursorIndex, setCursorIndex] = (0, import_react.useState)(value.length);
532112
- const [pasteLength, setPasteLength] = (0, import_react.useState)(0);
532113
- (0, import_react.useEffect)(() => {
532114
- if (cursorIndex > value.length) setCursorIndex(value.length);
532115
- }, [value, cursorIndex]);
532116
- useCustomInput((input, key) => {
532117
- const submitKey = keyBindings?.submit ?? ((key2) => key2.return && key2.ctrl);
532118
- const newlineKey = keyBindings?.newline ?? ((key2) => key2.return);
532119
- if (submitKey(key)) {
532120
- onSubmit?.(value);
532051
+ if (key.return && (key.ctrl || key.shift || key.meta)) {
532052
+ const next = val_1.slice(0, cursor_0) + "\n" + val_1.slice(cursor_0);
532053
+ setValueState(next);
532054
+ setCursorIndex(cursor_0 + 1);
532055
+ setPasteLength(0);
532056
+ onChange?.(next);
532057
+ return;
532058
+ }
532059
+ if (key.ctrl && input === "c") return;
532060
+ if (key.ctrl && input === "a") {
532061
+ setCursorIndex(getLineStart(val_1, cursor_0));
532121
532062
  return;
532122
- } else if (newlineKey(key)) {
532123
- onChange(value.slice(0, cursorIndex) + "\n" + value.slice(cursorIndex));
532124
- setCursorIndex(cursorIndex + 1);
532063
+ }
532064
+ if (key.ctrl && input === "e") {
532065
+ setCursorIndex(getLineEnd(val_1, cursor_0));
532066
+ return;
532067
+ }
532068
+ if (key.home) {
532069
+ setCursorIndex(getLineStart(val_1, cursor_0));
532070
+ return;
532071
+ }
532072
+ if (key.end) {
532073
+ setCursorIndex(getLineEnd(val_1, cursor_0));
532074
+ return;
532075
+ }
532076
+ if (key.meta && key.leftArrow || key.ctrl && key.leftArrow) {
532077
+ setCursorIndex(getPrevWordStart(val_1, cursor_0));
532078
+ return;
532079
+ }
532080
+ if (key.meta && key.rightArrow || key.ctrl && key.rightArrow) {
532081
+ setCursorIndex(getNextWordEnd(val_1, cursor_0));
532082
+ return;
532083
+ }
532084
+ if (key.ctrl && input === "k") {
532085
+ const next_0 = val_1.slice(0, cursor_0) + val_1.slice(getLineEnd(val_1, cursor_0));
532086
+ setValueState(next_0);
532087
+ setPasteLength(0);
532088
+ onChange?.(next_0);
532089
+ return;
532090
+ }
532091
+ if (key.ctrl && input === "u") {
532092
+ const lineStart = getLineStart(val_1, cursor_0);
532093
+ const next_1 = val_1.slice(0, lineStart) + val_1.slice(cursor_0);
532094
+ setValueState(next_1);
532095
+ setCursorIndex(lineStart);
532125
532096
  setPasteLength(0);
532097
+ onChange?.(next_1);
532126
532098
  return;
532127
532099
  }
532128
- if (key.tab || key.shift && key.tab || key.ctrl && input === "c") return;
532129
- if (keyBindings?.newline?.(key)) {
532130
- onChange(value.slice(0, cursorIndex) + "\n" + value.slice(cursorIndex));
532131
- setCursorIndex(cursorIndex + 1);
532100
+ if (key.ctrl && input === "w") {
532101
+ const wordStart = getPrevWordStart(val_1, cursor_0);
532102
+ const next_2 = val_1.slice(0, wordStart) + val_1.slice(cursor_0);
532103
+ setValueState(next_2);
532104
+ setCursorIndex(wordStart);
532132
532105
  setPasteLength(0);
532106
+ onChange?.(next_2);
532133
532107
  return;
532134
532108
  }
532135
- let nextPasteLength = 0;
532136
- if (input.length > 1) nextPasteLength = input.length;
532137
532109
  if (key.upArrow) {
532138
- if (showCursor) {
532139
- const lines = normalizeLineEndings(value).split("\n");
532140
- let currentLineIndex = 0;
532141
- let currentPos = 0;
532142
- let col = 0;
532143
- for (let i = 0; i < lines.length; i++) {
532144
- const line = lines[i];
532145
- if (line === void 0) continue;
532146
- const lineLen = line.length;
532147
- const lineEnd = currentPos + lineLen;
532148
- if (cursorIndex >= currentPos && cursorIndex <= lineEnd) {
532149
- currentLineIndex = i;
532150
- col = cursorIndex - currentPos;
532151
- break;
532152
- }
532153
- currentPos = lineEnd + 1;
532154
- }
532155
- if (currentLineIndex > 0) {
532156
- const targetLineIndex = currentLineIndex - 1;
532157
- const targetLine = lines[targetLineIndex];
532158
- if (targetLine !== void 0) {
532159
- const targetLineLen = targetLine.length;
532160
- const newCol = Math.min(col, targetLineLen);
532161
- let newIndex = 0;
532162
- for (let i = 0; i < targetLineIndex; i++) newIndex += lines[i].length + 1;
532163
- newIndex += newCol;
532164
- setCursorIndex(newIndex);
532165
- setPasteLength(0);
532166
- }
532167
- }
532168
- }
532169
- } else if (key.downArrow) {
532170
- if (showCursor) {
532171
- const lines = normalizeLineEndings(value).split("\n");
532172
- let currentLineIndex = 0;
532173
- let currentPos = 0;
532174
- let col = 0;
532175
- for (let i = 0; i < lines.length; i++) {
532176
- const line = lines[i];
532177
- if (line === void 0) continue;
532178
- const lineLen = line.length;
532179
- const lineEnd = currentPos + lineLen;
532180
- if (cursorIndex >= currentPos && cursorIndex <= lineEnd) {
532181
- currentLineIndex = i;
532182
- col = cursorIndex - currentPos;
532183
- break;
532184
- }
532185
- currentPos = lineEnd + 1;
532186
- }
532187
- if (currentLineIndex < lines.length - 1) {
532188
- const targetLineIndex = currentLineIndex + 1;
532189
- const targetLine = lines[targetLineIndex];
532190
- if (targetLine !== void 0) {
532191
- const targetLineLen = targetLine.length;
532192
- const newCol = Math.min(col, targetLineLen);
532193
- let newIndex = 0;
532194
- for (let i = 0; i < targetLineIndex; i++) newIndex += lines[i].length + 1;
532195
- newIndex += newCol;
532196
- setCursorIndex(newIndex);
532197
- setPasteLength(0);
532198
- }
532199
- }
532200
- }
532201
- } else if (key.leftArrow) {
532202
- if (showCursor) {
532203
- setCursorIndex(Math.max(0, cursorIndex - 1));
532204
- setPasteLength(0);
532205
- }
532206
- } else if (key.rightArrow) {
532207
- if (showCursor) {
532208
- setCursorIndex(Math.min(value.length, cursorIndex + 1));
532209
- setPasteLength(0);
532210
- }
532211
- } else if (key.return) {
532212
- onChange(value.slice(0, cursorIndex) + "\n" + value.slice(cursorIndex));
532213
- setCursorIndex(cursorIndex + 1);
532110
+ const isMultiLine = val_1.includes("\n");
532111
+ if (!disableHistory && isOnFirstLine(val_1, cursor_0) && !isMultiLine) {
532112
+ const h_0 = historyRef.current;
532113
+ const hi = historyIndexRef.current;
532114
+ const nextIndex = hi + 1;
532115
+ if (nextIndex < h_0.length) {
532116
+ if (hi === -1) setHistoryDraft(val_1);
532117
+ const historyValue = h_0[h_0.length - 1 - nextIndex];
532118
+ setHistoryIndex(nextIndex);
532119
+ setValueState(historyValue);
532120
+ setCursorIndex(historyValue.length);
532121
+ onChange?.(historyValue);
532122
+ }
532123
+ } else setCursorIndex(getPrevLineIndex(val_1, cursor_0));
532124
+ setPasteLength(0);
532125
+ return;
532126
+ }
532127
+ if (key.downArrow) {
532128
+ const isMultiLine_0 = val_1.includes("\n");
532129
+ if (!disableHistory && isOnLastLine(val_1, cursor_0) && !isMultiLine_0) {
532130
+ const h_1 = historyRef.current;
532131
+ const hi_0 = historyIndexRef.current;
532132
+ const hd = historyDraftRef.current;
532133
+ if (hi_0 > 0) {
532134
+ const nextIndex_0 = hi_0 - 1;
532135
+ const historyValue_0 = h_1[h_1.length - 1 - nextIndex_0];
532136
+ setHistoryIndex(nextIndex_0);
532137
+ setValueState(historyValue_0);
532138
+ setCursorIndex(historyValue_0.length);
532139
+ onChange?.(historyValue_0);
532140
+ } else if (hi_0 === 0) {
532141
+ setHistoryIndex(-1);
532142
+ setValueState(hd);
532143
+ setCursorIndex(hd.length);
532144
+ onChange?.(hd);
532145
+ }
532146
+ } else setCursorIndex(getNextLineIndex(val_1, cursor_0));
532214
532147
  setPasteLength(0);
532215
- } else if (key.backspace || key.delete) {
532216
- if (cursorIndex > 0) {
532217
- onChange(value.slice(0, cursorIndex - 1) + value.slice(cursorIndex));
532218
- setCursorIndex(cursorIndex - 1);
532148
+ return;
532149
+ }
532150
+ if (key.leftArrow) {
532151
+ setCursorIndex(Math.max(0, cursor_0 - 1));
532152
+ setPasteLength(0);
532153
+ return;
532154
+ }
532155
+ if (key.rightArrow) {
532156
+ setCursorIndex(Math.min(val_1.length, cursor_0 + 1));
532157
+ setPasteLength(0);
532158
+ return;
532159
+ }
532160
+ if (key.backspace || key.delete) {
532161
+ if (cursor_0 > 0) {
532162
+ const next_3 = val_1.slice(0, cursor_0 - 1) + val_1.slice(cursor_0);
532163
+ setValueState(next_3);
532164
+ setCursorIndex(cursor_0 - 1);
532219
532165
  setPasteLength(0);
532166
+ onChange?.(next_3);
532220
532167
  }
532221
- } else if (input) {
532222
- onChange(value.slice(0, cursorIndex) + input + value.slice(cursorIndex));
532223
- setCursorIndex(cursorIndex + input.length);
532224
- setPasteLength(nextPasteLength);
532168
+ return;
532225
532169
  }
532226
- }, focus);
532227
- const highlight = (0, import_react.useMemo)(() => {
532228
- if (highlightPastedText && pasteLength > 1) return {
532229
- start: Math.max(0, cursorIndex - pasteLength),
532230
- end: cursorIndex
532231
- };
532232
- }, [
532233
- cursorIndex,
532234
- pasteLength,
532235
- highlightPastedText
532236
- ]);
532237
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControlledMultilineInput, {
532238
- ...controlledProps,
532170
+ if (input) {
532171
+ if (historyIndexRef.current !== -1) {
532172
+ setHistoryIndex(-1);
532173
+ setHistoryDraft("");
532174
+ }
532175
+ const next_4 = val_1.slice(0, cursor_0) + input + val_1.slice(cursor_0);
532176
+ setValueState(next_4);
532177
+ setCursorIndex(cursor_0 + input.length);
532178
+ setPasteLength(input.length > 1 ? input.length : 0);
532179
+ onChange?.(next_4);
532180
+ }
532181
+ }, { isActive });
532182
+ return {
532239
532183
  value,
532240
532184
  cursorIndex,
532241
- highlight,
532242
- showCursor,
532243
- focus
532244
- });
532245
- };
532185
+ pasteLength,
532186
+ setValue,
532187
+ clear
532188
+ };
532189
+ }
532190
+ //#endregion
532191
+ //#region src/components/TextInput.tsx
532192
+ /**
532193
+ * TextInput / ControlledTextInput
532194
+ *
532195
+ * Drop-in replacements for `MultilineInput` / `ControlledMultilineInput` from
532196
+ * `ink-multiline-input`. Key improvements over the upstream library:
532197
+ *
532198
+ * 1. Cursor rendered as an *inverse* block on the character it sits on —
532199
+ * no extra space inserted, no text displacement.
532200
+ *
532201
+ * 2. Placeholder visible whenever `value` is empty, regardless of focus.
532202
+ *
532203
+ * 3. Height and cursor-line computed directly from the text (no async
532204
+ * MeasureBox cycle), so arrow-key navigation shows immediately.
532205
+ *
532206
+ * 4. `useTextInput` (backing `TextInput`) fixes ↑/↓ so multi-line text
532207
+ * always navigates lines instead of history.
532208
+ */
532209
+ const TAB_CACHE = /* @__PURE__ */ new Map();
532210
+ function getSpaces(n) {
532211
+ if (!TAB_CACHE.has(n)) TAB_CACHE.set(n, " ".repeat(n));
532212
+ return TAB_CACHE.get(n);
532213
+ }
532214
+ function expandTabs(text, tabSize) {
532215
+ return text.replace(/\t/g, getSpaces(tabSize));
532216
+ }
532217
+ function normalizeLineEndings(text) {
532218
+ if (!text) return "";
532219
+ return text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
532220
+ }
532221
+ function fmt(text, tabSize) {
532222
+ return expandTabs(normalizeLineEndings(text), tabSize);
532223
+ }
532224
+ function computeCursorPos(value, cursorIndex, tabSize) {
532225
+ const beforeLines = fmt(value.slice(0, cursorIndex), tabSize).split("\n");
532226
+ const lineIdx = beforeLines.length - 1;
532227
+ const colIdx = beforeLines[lineIdx].length;
532228
+ const rawCharAtCursor = value[cursorIndex];
532229
+ const isNewline = rawCharAtCursor === "\n";
532230
+ return {
532231
+ lineIdx,
532232
+ colIdx,
532233
+ char: !rawCharAtCursor || isNewline ? " " : fmt(rawCharAtCursor, tabSize),
532234
+ isNewline
532235
+ };
532236
+ }
532237
+ const ControlledTextInput = (0, import_react.memo)(function ControlledTextInput(t0) {
532238
+ const $ = (0, import_compiler_runtime.c)(44);
532239
+ const { value, cursorIndex: t1, placeholder: t2, showCursor: t3, focus: t4, rows, maxRows: t5, tabSize: t6 } = t0;
532240
+ const cursorIndex = t1 === void 0 ? 0 : t1;
532241
+ const placeholder = t2 === void 0 ? "" : t2;
532242
+ const showCursor = t3 === void 0 ? true : t3;
532243
+ const focus = t4 === void 0 ? true : t4;
532244
+ const maxRows = t5 === void 0 ? 10 : t5;
532245
+ const tabSize = t6 === void 0 ? 4 : t6;
532246
+ const minRows = rows ?? 1;
532247
+ let t7;
532248
+ if ($[0] !== cursorIndex || $[1] !== tabSize || $[2] !== value) {
532249
+ t7 = value ? computeCursorPos(value, cursorIndex, tabSize) : null;
532250
+ $[0] = cursorIndex;
532251
+ $[1] = tabSize;
532252
+ $[2] = value;
532253
+ $[3] = t7;
532254
+ } else t7 = $[3];
532255
+ const cursorInfo = t7;
532256
+ let t8;
532257
+ if ($[4] !== tabSize || $[5] !== value) {
532258
+ t8 = value ? fmt(value, tabSize).split("\n") : [];
532259
+ $[4] = tabSize;
532260
+ $[5] = value;
532261
+ $[6] = t8;
532262
+ } else t8 = $[6];
532263
+ const allLines = t8;
532264
+ const lineCount = allLines.length;
532265
+ const cursorLineIdx = cursorInfo?.lineIdx ?? 0;
532266
+ const cursorColIdx = cursorInfo?.colIdx ?? 0;
532267
+ const cursorDisplayChar = cursorInfo?.char ?? " ";
532268
+ const charIsNewline = cursorInfo?.isNewline ?? false;
532269
+ const visibleRows = value ? Math.max(minRows, Math.min(maxRows, lineCount)) : minRows;
532270
+ const scrollStart = value ? Math.max(0, Math.min(lineCount - visibleRows, cursorLineIdx - visibleRows + 1)) : 0;
532271
+ let t9;
532272
+ if ($[7] !== allLines || $[8] !== scrollStart || $[9] !== value || $[10] !== visibleRows) {
532273
+ t9 = value ? allLines.slice(scrollStart, scrollStart + visibleRows) : [];
532274
+ $[7] = allLines;
532275
+ $[8] = scrollStart;
532276
+ $[9] = value;
532277
+ $[10] = visibleRows;
532278
+ $[11] = t9;
532279
+ } else t9 = $[11];
532280
+ const visibleLines = t9;
532281
+ if (!value) {
532282
+ let t10;
532283
+ if ($[12] !== focus || $[13] !== showCursor) {
532284
+ t10 = showCursor && focus && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
532285
+ inverse: true,
532286
+ children: " "
532287
+ });
532288
+ $[12] = focus;
532289
+ $[13] = showCursor;
532290
+ $[14] = t10;
532291
+ } else t10 = $[14];
532292
+ let t11;
532293
+ if ($[15] !== placeholder) {
532294
+ t11 = placeholder ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
532295
+ dimColor: true,
532296
+ children: placeholder
532297
+ }) : null;
532298
+ $[15] = placeholder;
532299
+ $[16] = t11;
532300
+ } else t11 = $[16];
532301
+ let t12;
532302
+ if ($[17] !== t10 || $[18] !== t11) {
532303
+ t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [t10, t11] });
532304
+ $[17] = t10;
532305
+ $[18] = t11;
532306
+ $[19] = t12;
532307
+ } else t12 = $[19];
532308
+ let t13;
532309
+ if ($[20] !== minRows || $[21] !== t12) {
532310
+ t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
532311
+ height: minRows,
532312
+ overflow: "hidden",
532313
+ flexDirection: "column",
532314
+ flexShrink: 0,
532315
+ flexGrow: 0,
532316
+ children: t12
532317
+ });
532318
+ $[20] = minRows;
532319
+ $[21] = t12;
532320
+ $[22] = t13;
532321
+ } else t13 = $[22];
532322
+ return t13;
532323
+ }
532324
+ if (!focus) {
532325
+ let t10;
532326
+ if ($[23] !== visibleLines) {
532327
+ t10 = visibleLines.map(_temp$7);
532328
+ $[23] = visibleLines;
532329
+ $[24] = t10;
532330
+ } else t10 = $[24];
532331
+ let t11;
532332
+ if ($[25] !== t10) {
532333
+ t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
532334
+ flexDirection: "column",
532335
+ flexShrink: 0,
532336
+ flexGrow: 0,
532337
+ children: t10
532338
+ });
532339
+ $[25] = t10;
532340
+ $[26] = t11;
532341
+ } else t11 = $[26];
532342
+ return t11;
532343
+ }
532344
+ let t10;
532345
+ if ($[27] !== charIsNewline || $[28] !== cursorColIdx || $[29] !== cursorDisplayChar || $[30] !== cursorLineIdx || $[31] !== scrollStart || $[32] !== showCursor || $[33] !== visibleLines) {
532346
+ let t11;
532347
+ if ($[35] !== charIsNewline || $[36] !== cursorColIdx || $[37] !== cursorDisplayChar || $[38] !== cursorLineIdx || $[39] !== scrollStart || $[40] !== showCursor) {
532348
+ t11 = (line_0, i_0) => {
532349
+ const absLine = i_0 + scrollStart;
532350
+ if (absLine !== cursorLineIdx) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: line_0 || " " }, absLine);
532351
+ const beforeCursor = line_0.slice(0, cursorColIdx);
532352
+ const afterCursor = charIsNewline ? "" : line_0.slice(cursorColIdx + cursorDisplayChar.length);
532353
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
532354
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: beforeCursor }),
532355
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
532356
+ inverse: showCursor,
532357
+ children: cursorDisplayChar
532358
+ }),
532359
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: afterCursor })
532360
+ ] }, absLine);
532361
+ };
532362
+ $[35] = charIsNewline;
532363
+ $[36] = cursorColIdx;
532364
+ $[37] = cursorDisplayChar;
532365
+ $[38] = cursorLineIdx;
532366
+ $[39] = scrollStart;
532367
+ $[40] = showCursor;
532368
+ $[41] = t11;
532369
+ } else t11 = $[41];
532370
+ t10 = visibleLines.map(t11);
532371
+ $[27] = charIsNewline;
532372
+ $[28] = cursorColIdx;
532373
+ $[29] = cursorDisplayChar;
532374
+ $[30] = cursorLineIdx;
532375
+ $[31] = scrollStart;
532376
+ $[32] = showCursor;
532377
+ $[33] = visibleLines;
532378
+ $[34] = t10;
532379
+ } else t10 = $[34];
532380
+ let t11;
532381
+ if ($[42] !== t10) {
532382
+ t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
532383
+ flexDirection: "column",
532384
+ flexShrink: 0,
532385
+ flexGrow: 0,
532386
+ children: t10
532387
+ });
532388
+ $[42] = t10;
532389
+ $[43] = t11;
532390
+ } else t11 = $[43];
532391
+ return t11;
532392
+ });
532393
+ /**
532394
+ * `TextInput` manages its own value state (via `useTextInput`) and delegates
532395
+ * rendering to `ControlledTextInput`. Use this when you don't need external
532396
+ * control over the value.
532397
+ */
532398
+ function TextInput(t0) {
532399
+ const $ = (0, import_compiler_runtime.c)(17);
532400
+ const { onSubmit, onChange, onScrollUp, onScrollDown, onTab, isActive, getIsMenuActive, submitDisabled, disableHistory, placeholder, rows, maxRows, tabSize } = t0;
532401
+ let t1;
532402
+ if ($[0] !== disableHistory || $[1] !== getIsMenuActive || $[2] !== isActive || $[3] !== onChange || $[4] !== onScrollDown || $[5] !== onScrollUp || $[6] !== onSubmit || $[7] !== onTab || $[8] !== submitDisabled) {
532403
+ t1 = {
532404
+ onSubmit,
532405
+ onChange,
532406
+ onScrollUp,
532407
+ onScrollDown,
532408
+ onTab,
532409
+ isActive,
532410
+ getIsMenuActive,
532411
+ submitDisabled,
532412
+ disableHistory
532413
+ };
532414
+ $[0] = disableHistory;
532415
+ $[1] = getIsMenuActive;
532416
+ $[2] = isActive;
532417
+ $[3] = onChange;
532418
+ $[4] = onScrollDown;
532419
+ $[5] = onScrollUp;
532420
+ $[6] = onSubmit;
532421
+ $[7] = onTab;
532422
+ $[8] = submitDisabled;
532423
+ $[9] = t1;
532424
+ } else t1 = $[9];
532425
+ const { value, cursorIndex } = useTextInput(t1);
532426
+ let t2;
532427
+ if ($[10] !== cursorIndex || $[11] !== maxRows || $[12] !== placeholder || $[13] !== rows || $[14] !== tabSize || $[15] !== value) {
532428
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControlledTextInput, {
532429
+ value,
532430
+ cursorIndex,
532431
+ placeholder,
532432
+ showCursor: true,
532433
+ rows,
532434
+ maxRows,
532435
+ tabSize
532436
+ });
532437
+ $[10] = cursorIndex;
532438
+ $[11] = maxRows;
532439
+ $[12] = placeholder;
532440
+ $[13] = rows;
532441
+ $[14] = tabSize;
532442
+ $[15] = value;
532443
+ $[16] = t2;
532444
+ } else t2 = $[16];
532445
+ return t2;
532446
+ }
532447
+ function _temp$7(line, i) {
532448
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: line || " " }, i);
532449
+ }
532246
532450
  //#endregion
532247
532451
  //#region ../../node_modules/jsonrepair/lib/esm/utils/JSONRepairError.js
532248
532452
  var JSONRepairError = class extends Error {
@@ -533524,7 +533728,7 @@ function useCodeGenStateHandler() {
533524
533728
  else if (step.name === "tool") state.messages.push({
533525
533729
  id: step.id ?? "unknown",
533526
533730
  type: "tool",
533527
- state: "generating",
533731
+ state: state.state === "generating" ? "generating" : "success",
533528
533732
  toolName: step.filePath ?? "",
533529
533733
  input: processToolInput(step.content),
533530
533734
  content: step.content,
@@ -533535,8 +533739,13 @@ function useCodeGenStateHandler() {
533535
533739
  else if (step.name === "thinking") state.messages.push({
533536
533740
  id: step.name,
533537
533741
  type: "thinking",
533538
- content: step.content ?? ""
533742
+ content: step.content ?? "",
533743
+ streaming: true
533539
533744
  });
533745
+ else {
533746
+ const prevThinking = state.messages.findLast((m_0) => m_0.type === "thinking");
533747
+ if (prevThinking) prevThinking.streaming = false;
533748
+ }
533540
533749
  break;
533541
533750
  case "delta": {
533542
533751
  const stepName = step.name;
@@ -533578,7 +533787,7 @@ function useCodeGenStateHandler() {
533578
533787
  existingTool_0.content = toolResult.tool_input;
533579
533788
  existingTool_0.input = processToolInput(existingTool_0.content);
533580
533789
  }
533581
- toolResult.content = toolResult.content;
533790
+ existingTool_0.toolResult = toolResult.content;
533582
533791
  if (isTool(existingTool_0, "TodoWrite")) {
533583
533792
  const todos = existingTool_0.structuredResult?.todos;
533584
533793
  if (Array.isArray(todos)) state.todoItems = todos;
@@ -533609,16 +533818,26 @@ function useCodeGenStateHandler() {
533609
533818
  }
533610
533819
  break;
533611
533820
  }
533612
- case "done":
533821
+ case "done": {
533613
533822
  state.contextWindow = step.contextWindow;
533614
533823
  state.usage = step.usage;
533615
533824
  state.lastCompletionId = step.id;
533616
533825
  state.model = step.model;
533617
533826
  state.creditsUsed = step.creditsUsed;
533618
533827
  state.activeUserQuestions = void 0;
533619
- if (step.applyResults?.length) turnApplyResults.push(...step.applyResults);
533828
+ const doneThinking = state.messages.findLast((m) => m.type === "thinking");
533829
+ if (doneThinking) doneThinking.streaming = false;
533830
+ if (step.applyResults?.length) for (const result of step.applyResults) {
533831
+ const existing = turnApplyResults.find((r) => r.filePath === result.filePath);
533832
+ if (existing) {
533833
+ existing.addedLines += result.addedLines;
533834
+ existing.removedLines += result.removedLines;
533835
+ existing.action = result.action;
533836
+ } else turnApplyResults.push({ ...result });
533837
+ }
533620
533838
  turnCreditsUsed += step.creditsUsed ?? 0;
533621
533839
  break;
533840
+ }
533622
533841
  case "error":
533623
533842
  state.lastError = step;
533624
533843
  break;
@@ -533633,7 +533852,8 @@ function useCodeGenStateHandler() {
533633
533852
  type: "idle",
533634
533853
  applyResults: turnApplyResults,
533635
533854
  creditsUsed: turnCreditsUsed,
533636
- durationMs: Date.now() - turnStartTime
533855
+ durationMs: Date.now() - turnStartTime,
533856
+ state: step.state
533637
533857
  });
533638
533858
  turnApplyResults = [];
533639
533859
  turnCreditsUsed = 0;
@@ -533657,7 +533877,6 @@ function useCodeGenStateHandler() {
533657
533877
  case "user-abort":
533658
533878
  case "continue":
533659
533879
  case "update_setup_value":
533660
- case "planning":
533661
533880
  case "text": break;
533662
533881
  default: break;
533663
533882
  }
@@ -533830,7 +534049,7 @@ function SlashCommandMenu(t0) {
533830
534049
  const [state] = useCodeGenState();
533831
534050
  let t1;
533832
534051
  if ($[0] !== state.customInstructions) {
533833
- const agents = (state.customInstructions ?? []).filter(_temp$5).map(_temp2$3);
534052
+ const agents = (state.customInstructions ?? []).filter(_temp$6).map(_temp2$3);
533834
534053
  let t2;
533835
534054
  if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
533836
534055
  t2 = {
@@ -534044,7 +534263,7 @@ function _temp2$3(i_0) {
534044
534263
  description: i_0.description
534045
534264
  };
534046
534265
  }
534047
- function _temp$5(i) {
534266
+ function _temp$6(i) {
534048
534267
  return i.type === "agent-mode";
534049
534268
  }
534050
534269
  //#endregion
@@ -534241,9 +534460,19 @@ function FilePicker(t0) {
534241
534460
  }
534242
534461
  //#endregion
534243
534462
  //#region src/components/InputPrompt.tsx
534244
- const MOUSE_RE$1 = /^\[<(\d+);\d+;\d+[Mm]/;
534245
- function shouldSubmitPrompt({ hasText, submitDisabled }) {
534246
- return hasText && !submitDisabled;
534463
+ /**
534464
+ * Returns a short, provider-agnostic display name for a model ID.
534465
+ *
534466
+ * Examples:
534467
+ * "vertexai-claude-4-6-sonnet" → "Sonnet 4.6"
534468
+ * "claude-opus-4-6" → "Opus 4.6"
534469
+ * "claude-haiku-4-5-20251001" → "Haiku 4.5"
534470
+ */
534471
+ function formatModelName(model) {
534472
+ const stripped = model.replace(/^vertexai-/i, "").replace(/^bedrock-/i, "").replace(/^anthropic\./i, "");
534473
+ const m = stripped.match(/claude-([a-z]+)-(\d+)-(\d+)/i);
534474
+ if (m) return `${m[1].charAt(0).toUpperCase() + m[1].slice(1)} ${m[2]}.${m[3]}`;
534475
+ return stripped;
534247
534476
  }
534248
534477
  function isSlashCommandInput(value) {
534249
534478
  return value === "/" || value.startsWith("/") && value.length <= 10;
@@ -534255,14 +534484,46 @@ function getAtQuery(value) {
534255
534484
  }
534256
534485
  const InputPrompt = (0, import_react.memo)(({ onSubmit, onChange, onSlashCommand, onToggleSessionMode, onSlashMenuActiveChange, onScrollUp, onScrollDown, onImplementPlan, isTabActive = true }) => {
534257
534486
  const [state] = useCodeGenState();
534258
- const [value, setValue] = (0, import_react.useState)("");
534259
534487
  const [dismissedSlashValue, setDismissedSlashValue] = (0, import_react.useState)(null);
534260
534488
  const [dismissedAtValue, setDismissedAtValue] = (0, import_react.useState)(null);
534261
- const [inputKey, setInputKey] = (0, import_react.useState)(0);
534262
534489
  const hasPlan = state.hasPlanToApply && !!onImplementPlan;
534263
- const planIsActive = hasPlan && !value;
534264
534490
  const isPlanning = state.sessionMode === "planning" || state.sessionMode === "auto-planning";
534265
534491
  const hint = hasPlan ? "Type to refine the plan..." : isPlanning ? "Describe what you want to plan..." : "Describe what you want to build...";
534492
+ const slashMenuActiveRef = (0, import_react.useRef)(false);
534493
+ const atMenuActiveRef = (0, import_react.useRef)(false);
534494
+ const getIsMenuActive = (0, import_react.useCallback)(() => slashMenuActiveRef.current || atMenuActiveRef.current, []);
534495
+ const handleChange = (0, import_react.useCallback)((val) => {
534496
+ if (dismissedSlashValue && val !== dismissedSlashValue) setDismissedSlashValue(null);
534497
+ if (dismissedAtValue && val !== dismissedAtValue) setDismissedAtValue(null);
534498
+ onChange?.(val);
534499
+ }, [
534500
+ dismissedSlashValue,
534501
+ dismissedAtValue,
534502
+ onChange
534503
+ ]);
534504
+ const { value, cursorIndex, setValue, clear } = useTextInput({
534505
+ onSubmit: (0, import_react.useCallback)((val_0) => {
534506
+ if (hasPlan && !val_0.trim() && onImplementPlan) {
534507
+ onImplementPlan();
534508
+ return;
534509
+ }
534510
+ if (val_0.trim()) onSubmit(val_0);
534511
+ setDismissedSlashValue(null);
534512
+ onChange?.("");
534513
+ }, [
534514
+ hasPlan,
534515
+ onChange,
534516
+ onImplementPlan,
534517
+ onSubmit
534518
+ ]),
534519
+ onChange: handleChange,
534520
+ onScrollUp,
534521
+ onScrollDown,
534522
+ onTab: onToggleSessionMode,
534523
+ isActive: isTabActive,
534524
+ getIsMenuActive,
534525
+ submitDisabled: false
534526
+ });
534266
534527
  const slashMenuActive = (0, import_react.useMemo)(() => !!onSlashCommand && isSlashCommandInput(value) && value.trim().length > 0 && value !== dismissedSlashValue, [
534267
534528
  dismissedSlashValue,
534268
534529
  onSlashCommand,
@@ -534275,59 +534536,32 @@ const InputPrompt = (0, import_react.memo)(({ onSubmit, onChange, onSlashCommand
534275
534536
  dismissedAtValue,
534276
534537
  slashMenuActive
534277
534538
  ]);
534539
+ slashMenuActiveRef.current = slashMenuActive;
534540
+ atMenuActiveRef.current = atMenuActive;
534541
+ const planIsActive = hasPlan && !value;
534278
534542
  (0, import_react.useEffect)(() => {
534279
534543
  onSlashMenuActiveChange?.(slashMenuActive);
534280
534544
  return () => {
534281
534545
  onSlashMenuActiveChange?.(false);
534282
534546
  };
534283
534547
  }, [onSlashMenuActiveChange, slashMenuActive]);
534284
- const handleSubmit = (0, import_react.useCallback)((val) => {
534285
- if (hasPlan && !val.trim() && onImplementPlan) {
534286
- onImplementPlan();
534287
- return;
534288
- }
534289
- if (shouldSubmitPrompt({
534290
- hasText: !!val.trim(),
534291
- submitDisabled: slashMenuActive
534292
- })) {
534293
- onSubmit(val);
534294
- setValue("");
534295
- setDismissedSlashValue(null);
534296
- onChange?.("");
534297
- }
534298
- }, [
534299
- hasPlan,
534300
- onChange,
534301
- onImplementPlan,
534302
- onSubmit,
534303
- slashMenuActive
534304
- ]);
534305
- const handleChange = (0, import_react.useCallback)((val_0) => {
534306
- setValue(val_0);
534307
- if (dismissedSlashValue && val_0 !== dismissedSlashValue) setDismissedSlashValue(null);
534308
- if (dismissedAtValue && val_0 !== dismissedAtValue) setDismissedAtValue(null);
534309
- onChange?.(val_0);
534310
- }, [
534311
- dismissedSlashValue,
534312
- dismissedAtValue,
534313
- onChange
534314
- ]);
534315
534548
  const handleSlashSelect = (0, import_react.useCallback)((selection) => {
534316
534549
  onSlashCommand?.(selection);
534317
- setValue("");
534318
- setDismissedSlashValue(null);
534319
- onChange?.("");
534320
- }, [onChange, onSlashCommand]);
534550
+ clear();
534551
+ }, [clear, onSlashCommand]);
534321
534552
  const handleSlashCancel = (0, import_react.useCallback)(() => {
534322
534553
  setDismissedSlashValue(value);
534323
534554
  }, [value]);
534324
534555
  const handleAtSelect = (0, import_react.useCallback)((filePath) => {
534325
534556
  const newValue = value.replace(/@[^\s]*$/, `@${filePath} `);
534326
534557
  setValue(newValue);
534327
- setInputKey((k) => k + 1);
534328
534558
  setDismissedAtValue(null);
534329
534559
  onChange?.(newValue);
534330
- }, [value, onChange]);
534560
+ }, [
534561
+ value,
534562
+ onChange,
534563
+ setValue
534564
+ ]);
534331
534565
  const handleAtCancel = (0, import_react.useCallback)(() => {
534332
534566
  setDismissedAtValue(value);
534333
534567
  }, [value]);
@@ -534402,62 +534636,30 @@ const InputPrompt = (0, import_react.memo)(({ onSubmit, onChange, onSlashCommand
534402
534636
  })
534403
534637
  ]
534404
534638
  }) }),
534405
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(MultilineInput, {
534639
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControlledTextInput, {
534406
534640
  value,
534407
- onChange: handleChange,
534408
- onSubmit: handleSubmit,
534641
+ cursorIndex,
534409
534642
  rows: 1,
534410
- maxRows: 10,
534411
- keyBindings: {
534412
- submit: (key) => key.return && !key.ctrl && !slashMenuActive && !atMenuActive,
534413
- newline: (key_0) => key_0.return && key_0.ctrl
534414
- },
534415
- useCustomInput: (handler, isActive) => {
534416
- useInput((input, key_1) => {
534417
- const match = input.match(MOUSE_RE$1);
534418
- if (match) {
534419
- const button = parseInt(match[1], 10);
534420
- if (button === 64) onScrollUp?.();
534421
- else if (button === 65) onScrollDown?.();
534422
- return;
534423
- }
534424
- if (input.includes("[<") && /\d+;\d+;\d+[Mm]/.test(input)) return;
534425
- if (key_1.tab && key_1.shift) return;
534426
- if (key_1.tab && !slashMenuActive) {
534427
- onToggleSessionMode?.();
534428
- return;
534429
- }
534430
- if ((slashMenuActive || atMenuActive) && (key_1.upArrow || key_1.downArrow || key_1.return || key_1.escape)) return;
534431
- handler(input, key_1);
534432
- }, { isActive: isActive && isTabActive });
534433
- }
534434
- }, inputKey), !value && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
534435
- dimColor: true,
534436
- children: hint
534437
- })] }),
534643
+ placeholder: hint,
534644
+ showCursor: true,
534645
+ maxRows: 10
534646
+ }) }),
534438
534647
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
534439
- gap: 1,
534648
+ columnGap: 1,
534649
+ flexWrap: "wrap",
534440
534650
  children: [
534441
534651
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
534442
534652
  color: accentColor,
534443
534653
  bold: true,
534444
534654
  children: state.sessionMode === "planning" ? "Plan" : state.sessionMode === "auto-planning" ? "Auto-Plan" : "Build"
534445
534655
  }),
534446
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
534656
+ (state.modelOverride || state.model) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
534447
534657
  dimColor: true,
534448
534658
  children: "·"
534449
- }),
534450
- state.model && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
534451
- dimColor: true,
534452
- children: state.model
534453
534659
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
534454
534660
  dimColor: true,
534455
- children: "·"
534661
+ children: formatModelName(state.modelOverride ?? state.model)
534456
534662
  })] }),
534457
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
534458
- dimColor: true,
534459
- children: "Fusion"
534460
- }),
534461
534663
  planIsActive && !slashMenuActive && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
534462
534664
  dimColor: true,
534463
534665
  children: "·"
@@ -534654,7 +534856,7 @@ const AskUserQuestionDisplay = (0, import_react.memo)((t0) => {
534654
534856
  else if (key.escape) {
534655
534857
  setCustomMode(false);
534656
534858
  setCustomText("");
534657
- } else if (key.backspace || key.delete) setCustomText(_temp$4);
534859
+ } else if (key.backspace || key.delete) setCustomText(_temp$5);
534658
534860
  else if (input && !key.ctrl && !key.meta) setCustomText((text_0) => text_0 + input);
534659
534861
  return;
534660
534862
  }
@@ -534991,7 +535193,7 @@ const AskUserQuestionDisplay = (0, import_react.memo)((t0) => {
534991
535193
  } else t30 = $[86];
534992
535194
  return t30;
534993
535195
  });
534994
- function _temp$4(text) {
535196
+ function _temp$5(text) {
534995
535197
  return text.slice(0, -1);
534996
535198
  }
534997
535199
  //#endregion
@@ -536681,7 +536883,7 @@ const WelcomeScreen = (0, import_react.memo)((t0) => {
536681
536883
  });
536682
536884
  //#endregion
536683
536885
  //#region src/components/StatusBar.tsx
536684
- function ProgressBar() {
536886
+ const ProgressBar = (0, import_react.memo)(() => {
536685
536887
  const $ = (0, import_compiler_runtime.c)(6);
536686
536888
  const [frame, setFrame] = (0, import_react.useState)(0);
536687
536889
  const frameRef = (0, import_react.useRef)(0);
@@ -536724,9 +536926,9 @@ function ProgressBar() {
536724
536926
  $[5] = t3;
536725
536927
  } else t3 = $[5];
536726
536928
  return t3;
536727
- }
536929
+ });
536728
536930
  const StatusBar = (0, import_react.memo)((t0) => {
536729
- const $ = (0, import_compiler_runtime.c)(8);
536931
+ const $ = (0, import_compiler_runtime.c)(4);
536730
536932
  const { ctrlCPending } = t0;
536731
536933
  const [state] = useCodeGenState();
536732
536934
  if (ctrlCPending) {
@@ -536744,79 +536946,62 @@ const StatusBar = (0, import_react.memo)((t0) => {
536744
536946
  return t1;
536745
536947
  }
536746
536948
  let t1;
536747
- if ($[1] !== state.state) {
536748
- t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
536749
- gap: 1,
536750
- children: state.state === "generating" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProgressBar, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
536751
- dimColor: true,
536752
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
536753
- bold: true,
536754
- children: "esc"
536755
- }), " interrupt"]
536756
- })] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: " " })
536757
- });
536758
- $[1] = state.state;
536759
- $[2] = t1;
536760
- } else t1 = $[2];
536949
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
536950
+ t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spacer, {});
536951
+ $[1] = t1;
536952
+ } else t1 = $[1];
536761
536953
  let t2;
536762
- if ($[3] !== state.activeUserQuestions) {
536763
- t2 = state.activeUserQuestions ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
536764
- gap: 3,
536765
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
536766
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
536954
+ if ($[2] !== state.activeUserQuestions) {
536955
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
536956
+ justifyContent: "space-between",
536957
+ paddingY: 0,
536958
+ children: [t1, state.activeUserQuestions ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
536959
+ gap: 3,
536960
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
536961
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
536962
+ bold: true,
536963
+ dimColor: true,
536964
+ children: "enter"
536965
+ }),
536966
+ " ",
536967
+ "or",
536968
+ " ",
536969
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
536970
+ bold: true,
536971
+ dimColor: true,
536972
+ children: "space"
536973
+ }),
536974
+ " ",
536975
+ "select"
536976
+ ] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
536767
536977
  bold: true,
536768
536978
  dimColor: true,
536769
- children: "enter"
536770
- }),
536771
- " ",
536772
- "or",
536773
- " ",
536774
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
536775
- bold: true,
536979
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
536980
+ bold: true,
536981
+ children: "esc"
536982
+ }), " abort"]
536983
+ })]
536984
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
536985
+ gap: 3,
536986
+ children: [process.env.TERM_PROGRAM !== "vscode" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
536776
536987
  dimColor: true,
536777
- children: "space"
536778
- }),
536779
- " ",
536780
- "select"
536781
- ] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
536782
- bold: true,
536783
- dimColor: true,
536784
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
536785
- bold: true,
536786
- children: "esc"
536787
- }), " abort"]
536788
- })]
536789
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
536790
- gap: 3,
536791
- children: [process.env.TERM_PROGRAM !== "vscode" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
536792
- dimColor: true,
536793
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
536794
- bold: true,
536795
- children: "shift+click"
536796
- }), " select text"]
536797
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
536798
- dimColor: true,
536799
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
536800
- bold: true,
536801
- children: "tab"
536802
- }), " agents"]
536988
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
536989
+ bold: true,
536990
+ children: "shift+click"
536991
+ }), " select text"]
536992
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
536993
+ dimColor: true,
536994
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
536995
+ bold: true,
536996
+ children: "tab"
536997
+ }), " agents"]
536998
+ })]
536803
536999
  })]
536804
537000
  });
536805
- $[3] = state.activeUserQuestions;
536806
- $[4] = t2;
536807
- } else t2 = $[4];
536808
- let t3;
536809
- if ($[5] !== t1 || $[6] !== t2) {
536810
- t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
536811
- justifyContent: "space-between",
536812
- paddingY: 0,
536813
- children: [t1, t2]
536814
- });
536815
- $[5] = t1;
536816
- $[6] = t2;
536817
- $[7] = t3;
536818
- } else t3 = $[7];
536819
- return t3;
537001
+ $[2] = state.activeUserQuestions;
537002
+ $[3] = t2;
537003
+ } else t2 = $[3];
537004
+ return t2;
536820
537005
  });
536821
537006
  //#endregion
536822
537007
  //#region src/utils/hyperlink.ts
@@ -537685,7 +537870,7 @@ const TipsSection = (0, import_react.memo)(() => {
537685
537870
  bb0: {
537686
537871
  let t1;
537687
537872
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
537688
- t1 = TIPS.filter(_temp$3);
537873
+ t1 = TIPS.filter(_temp$4);
537689
537874
  $[0] = t1;
537690
537875
  } else t1 = $[0];
537691
537876
  const availableTips = t1;
@@ -537887,71 +538072,95 @@ const TodoSection = (0, import_react.memo)(() => {
537887
538072
  return t4;
537888
538073
  });
537889
538074
  const FooterSection = (0, import_react.memo)(() => {
537890
- const $ = (0, import_compiler_runtime.c)(10);
538075
+ const $ = (0, import_compiler_runtime.c)(15);
537891
538076
  const [state] = useCodeGenState();
538077
+ const { stdout } = useStdout();
538078
+ const [rows, setRows] = (0, import_react.useState)(stdout?.rows ?? 24);
537892
538079
  let t0;
537893
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
537894
- t0 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TipsSection, {});
537895
- $[0] = t0;
537896
- } else t0 = $[0];
537897
538080
  let t1;
537898
- if ($[1] !== state.sessionId) {
537899
- t1 = state.sessionId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
538081
+ if ($[0] !== stdout) {
538082
+ t0 = () => {
538083
+ if (!stdout) return;
538084
+ const onResize = () => setRows(stdout.rows ?? 24);
538085
+ stdout.on("resize", onResize);
538086
+ return () => {
538087
+ stdout.off("resize", onResize);
538088
+ };
538089
+ };
538090
+ t1 = [stdout];
538091
+ $[0] = stdout;
538092
+ $[1] = t0;
538093
+ $[2] = t1;
538094
+ } else {
538095
+ t0 = $[1];
538096
+ t1 = $[2];
538097
+ }
538098
+ (0, import_react.useEffect)(t0, t1);
538099
+ let t2;
538100
+ if ($[3] !== rows) {
538101
+ t2 = rows >= 300 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TipsSection, {});
538102
+ $[3] = rows;
538103
+ $[4] = t2;
538104
+ } else t2 = $[4];
538105
+ let t3;
538106
+ if ($[5] !== state.sessionId) {
538107
+ t3 = state.sessionId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
537900
538108
  marginTop: 1,
537901
538109
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
537902
538110
  dimColor: true,
537903
538111
  children: ["--resume ", state.sessionId]
537904
538112
  })
537905
538113
  });
537906
- $[1] = state.sessionId;
537907
- $[2] = t1;
537908
- } else t1 = $[2];
537909
- let t2;
537910
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
537911
- t2 = process.cwd().replace(process.env.HOME ?? "", "~");
537912
- $[3] = t2;
537913
- } else t2 = $[3];
537914
- const t3 = state.gitState?.currentBranch;
538114
+ $[5] = state.sessionId;
538115
+ $[6] = t3;
538116
+ } else t3 = $[6];
537915
538117
  let t4;
537916
- if ($[4] !== t3) {
537917
- t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
538118
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
538119
+ t4 = process.cwd().replace(process.env.HOME ?? "", "~");
538120
+ $[7] = t4;
538121
+ } else t4 = $[7];
538122
+ const t5 = state.gitState?.currentBranch;
538123
+ let t6;
538124
+ if ($[8] !== t5) {
538125
+ t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
537918
538126
  marginTop: 1,
537919
538127
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
537920
538128
  dimColor: true,
537921
- children: [t2, t3]
538129
+ children: [t4, t5]
537922
538130
  })
537923
538131
  });
537924
- $[4] = t3;
537925
- $[5] = t4;
537926
- } else t4 = $[5];
537927
- let t5;
537928
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
537929
- t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
538132
+ $[8] = t5;
538133
+ $[9] = t6;
538134
+ } else t6 = $[9];
538135
+ let t7;
538136
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
538137
+ t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
537930
538138
  dimColor: true,
537931
538139
  children: [
537932
538140
  "•",
537933
538141
  " Fusion ",
537934
- "0.3.5"
538142
+ "0.3.8"
537935
538143
  ]
537936
538144
  });
537937
- $[6] = t5;
537938
- } else t5 = $[6];
537939
- let t6;
537940
- if ($[7] !== t1 || $[8] !== t4) {
537941
- t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
538145
+ $[10] = t7;
538146
+ } else t7 = $[10];
538147
+ let t8;
538148
+ if ($[11] !== t2 || $[12] !== t3 || $[13] !== t6) {
538149
+ t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
537942
538150
  flexDirection: "column",
537943
538151
  children: [
537944
- t0,
537945
- t1,
537946
- t4,
537947
- t5
538152
+ t2,
538153
+ t3,
538154
+ t6,
538155
+ t7
537948
538156
  ]
537949
538157
  });
537950
- $[7] = t1;
537951
- $[8] = t4;
537952
- $[9] = t6;
537953
- } else t6 = $[9];
537954
- return t6;
538158
+ $[11] = t2;
538159
+ $[12] = t3;
538160
+ $[13] = t6;
538161
+ $[14] = t8;
538162
+ } else t8 = $[14];
538163
+ return t8;
537955
538164
  });
537956
538165
  const Sidebar = (0, import_react.memo)(() => {
537957
538166
  const $ = (0, import_compiler_runtime.c)(10);
@@ -538016,7 +538225,7 @@ const Sidebar = (0, import_react.memo)(() => {
538016
538225
  } else t8 = $[9];
538017
538226
  return t8;
538018
538227
  });
538019
- function _temp$3(item) {
538228
+ function _temp$4(item) {
538020
538229
  return item.text;
538021
538230
  }
538022
538231
  function _temp2$2(t) {
@@ -597271,16 +597480,21 @@ function ToolHeader(t0) {
597271
597480
  const { state } = tool;
597272
597481
  const color = state === "error" ? "red" : "gray";
597273
597482
  const icon = state === "error" ? "✗" : "✓";
597483
+ const isRunning = state === "generating" || state === "running";
597274
597484
  let t1;
597275
- if ($[0] !== color || $[1] !== icon || $[2] !== state) {
597276
- t1 = state === "generating" || state === "running" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, { label: "" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597485
+ if ($[0] !== color || $[1] !== icon || $[2] !== isRunning) {
597486
+ t1 = isRunning ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597487
+ bold: true,
597488
+ color: "cyan",
597489
+ children: "●"
597490
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597277
597491
  color,
597278
597492
  dimColor: true,
597279
597493
  children: icon
597280
597494
  });
597281
597495
  $[0] = color;
597282
597496
  $[1] = icon;
597283
- $[2] = state;
597497
+ $[2] = isRunning;
597284
597498
  $[3] = t1;
597285
597499
  } else t1 = $[3];
597286
597500
  let t2;
@@ -597296,7 +597510,8 @@ function ToolHeader(t0) {
597296
597510
  let t3;
597297
597511
  if ($[6] !== extra || $[7] !== t1 || $[8] !== t2) {
597298
597512
  t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
597299
- gap: 1,
597513
+ columnGap: 1,
597514
+ flexWrap: "wrap",
597300
597515
  children: [
597301
597516
  t1,
597302
597517
  t2,
@@ -597324,6 +597539,7 @@ function FilePath(t0) {
597324
597539
  t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597325
597540
  color: "cyan",
597326
597541
  dimColor: true,
597542
+ wrap: "truncate-start",
597327
597543
  children: t1
597328
597544
  });
597329
597545
  $[2] = t1;
@@ -597339,6 +597555,7 @@ function CmdText(t0) {
597339
597555
  t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597340
597556
  color: "yellow",
597341
597557
  dimColor: true,
597558
+ wrap: "truncate",
597342
597559
  children: cmd
597343
597560
  });
597344
597561
  $[0] = cmd;
@@ -597363,7 +597580,7 @@ function OutputPreview(t0) {
597363
597580
  T0 = Box;
597364
597581
  t2 = "column";
597365
597582
  t3 = 2;
597366
- t4 = lines.map(_temp$2);
597583
+ t4 = lines.map(_temp$3);
597367
597584
  $[0] = maxLines;
597368
597585
  $[1] = text;
597369
597586
  $[2] = T0;
@@ -597382,13 +597599,19 @@ function OutputPreview(t0) {
597382
597599
  }
597383
597600
  let t5;
597384
597601
  if ($[8] !== allLines || $[9] !== maxLines || $[10] !== truncated) {
597385
- t5 = truncated && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
597386
- dimColor: true,
597387
- children: [
597388
- "... +",
597389
- allLines.length - maxLines,
597390
- " more lines"
597391
- ]
597602
+ t5 = truncated && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
597603
+ flexDirection: "row",
597604
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597605
+ dimColor: true,
597606
+ children: " "
597607
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
597608
+ dimColor: true,
597609
+ children: [
597610
+ "+",
597611
+ allLines.length - maxLines,
597612
+ " more lines"
597613
+ ]
597614
+ })]
597392
597615
  });
597393
597616
  $[8] = allLines;
597394
597617
  $[9] = maxLines;
@@ -597411,10 +597634,17 @@ function OutputPreview(t0) {
597411
597634
  } else t6 = $[17];
597412
597635
  return t6;
597413
597636
  }
597414
- function _temp$2(line, i) {
597415
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597416
- dimColor: true,
597417
- children: line || " "
597637
+ function _temp$3(line, i) {
597638
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
597639
+ flexDirection: "row",
597640
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597641
+ dimColor: true,
597642
+ children: i === 0 ? "└ " : " "
597643
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597644
+ dimColor: true,
597645
+ wrap: "wrap",
597646
+ children: line || " "
597647
+ })]
597418
597648
  }, i);
597419
597649
  }
597420
597650
  function buildDiffLines(oldStr, newStr) {
@@ -597480,6 +597710,7 @@ function _temp2$1(line, i) {
597480
597710
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597481
597711
  color: line.kind === "added" ? "green" : line.kind === "removed" ? "red" : void 0,
597482
597712
  dimColor: line.kind === "context",
597713
+ wrap: "wrap",
597483
597714
  children: prefix + " " + (line.text || " ")
597484
597715
  }, i);
597485
597716
  }
@@ -597494,7 +597725,7 @@ function ToolCallRead(t0) {
597494
597725
  } else t1 = $[1];
597495
597726
  const { file_path, offset, limit, view_range } = t1;
597496
597727
  let rangeInfo;
597497
- if (view_range) rangeInfo = `:${view_range[0]} ${view_range[1] - view_range[0]}L`;
597728
+ if (view_range) rangeInfo = `:${view_range[0]} ${view_range[1] - view_range[0] + 1}L`;
597498
597729
  else if (offset != null || limit != null) {
597499
597730
  const t2 = `${offset != null ? `:${offset}` : ""}${limit != null ? ` ${limit}L` : ""}`;
597500
597731
  let t3;
@@ -597690,7 +597921,7 @@ function ToolCallBash(t0) {
597690
597921
  const displayTitle = restart ? "[restart]" : description;
597691
597922
  let t2;
597692
597923
  if ($[2] !== command || $[3] !== restart) {
597693
- t2 = !restart && command ? command.includes("\n") ? command.split("\n")[0] + " ..." : command.slice(0, 80) : void 0;
597924
+ t2 = !restart && command ? command.includes("\n") ? command.split("\n")[0] + " ..." : command.slice(0, 90) : void 0;
597694
597925
  $[2] = command;
597695
597926
  $[3] = restart;
597696
597927
  $[4] = t2;
@@ -597723,12 +597954,16 @@ function ToolCallBash(t0) {
597723
597954
  } else t5 = $[12];
597724
597955
  let t6;
597725
597956
  if ($[13] !== displayCmd) {
597726
- t6 = displayCmd && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
597727
- paddingLeft: 3,
597728
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
597957
+ t6 = displayCmd && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
597958
+ paddingLeft: 2,
597959
+ flexDirection: "row",
597960
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597729
597961
  dimColor: true,
597730
- children: ["$ ", displayCmd]
597731
- })
597962
+ children: " "
597963
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597964
+ dimColor: true,
597965
+ children: displayCmd
597966
+ })]
597732
597967
  });
597733
597968
  $[13] = displayCmd;
597734
597969
  $[14] = t6;
@@ -597760,8 +597995,9 @@ function ToolCallBash(t0) {
597760
597995
  } else t8 = $[20];
597761
597996
  return t8;
597762
597997
  }
597998
+ const RESULT_PREVIEW_LINES = 5;
597763
597999
  function ToolCallGrep(t0) {
597764
- const $ = (0, import_compiler_runtime.c)(23);
598000
+ const $ = (0, import_compiler_runtime.c)(36);
597765
598001
  const { tool } = t0;
597766
598002
  let t1;
597767
598003
  if ($[0] !== tool.input) {
@@ -597770,93 +598006,158 @@ function ToolCallGrep(t0) {
597770
598006
  $[1] = t1;
597771
598007
  } else t1 = $[1];
597772
598008
  const { query, include_glob, case_sensitive } = t1;
598009
+ let T0;
598010
+ let matchCount;
597773
598011
  let t2;
597774
- if ($[2] !== tool.state || $[3] !== tool.toolResult) {
597775
- const resultText = tool.state === "success" ? getResultText(tool.toolResult) : void 0;
597776
- t2 = resultText ? resultText.trim().split("\n").filter(Boolean).length : void 0;
597777
- $[2] = tool.state;
597778
- $[3] = tool.toolResult;
597779
- $[4] = t2;
597780
- } else t2 = $[4];
597781
- const matchCount = t2;
597782
598012
  let t3;
597783
- if ($[5] !== query) {
597784
- t3 = query && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CmdText, { cmd: `"${query}"` });
597785
- $[5] = query;
597786
- $[6] = t3;
597787
- } else t3 = $[6];
597788
598013
  let t4;
597789
- if ($[7] !== include_glob) {
597790
- t4 = include_glob && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597791
- dimColor: true,
597792
- children: include_glob
597793
- });
597794
- $[7] = include_glob;
597795
- $[8] = t4;
597796
- } else t4 = $[8];
597797
598014
  let t5;
597798
- if ($[9] !== case_sensitive) {
597799
- t5 = case_sensitive === false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597800
- dimColor: true,
597801
- children: "-i"
598015
+ if ($[2] !== case_sensitive || $[3] !== include_glob || $[4] !== query || $[5] !== tool) {
598016
+ const resultText = tool.state === "success" ? getResultText(tool.toolResult) : void 0;
598017
+ const allFiles = resultText ? resultText.trim().split("\n").filter(Boolean) : void 0;
598018
+ matchCount = allFiles?.length;
598019
+ const previewFiles = allFiles?.slice(0, RESULT_PREVIEW_LINES);
598020
+ const hiddenCount = matchCount != null && matchCount > RESULT_PREVIEW_LINES ? matchCount - RESULT_PREVIEW_LINES : 0;
598021
+ let t6;
598022
+ if ($[12] !== query) {
598023
+ t6 = query ? query.length > 60 ? `"${query.slice(0, 57)}…"` : `"${query}"` : void 0;
598024
+ $[12] = query;
598025
+ $[13] = t6;
598026
+ } else t6 = $[13];
598027
+ const displayQuery = t6;
598028
+ T0 = Box;
598029
+ t2 = "column";
598030
+ t3 = 1;
598031
+ let t7;
598032
+ if ($[14] !== displayQuery) {
598033
+ t7 = displayQuery && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CmdText, { cmd: displayQuery });
598034
+ $[14] = displayQuery;
598035
+ $[15] = t7;
598036
+ } else t7 = $[15];
598037
+ let t8;
598038
+ if ($[16] !== include_glob) {
598039
+ t8 = include_glob && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598040
+ dimColor: true,
598041
+ children: include_glob
598042
+ });
598043
+ $[16] = include_glob;
598044
+ $[17] = t8;
598045
+ } else t8 = $[17];
598046
+ let t9;
598047
+ if ($[18] !== case_sensitive) {
598048
+ t9 = case_sensitive === false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598049
+ dimColor: true,
598050
+ children: "-i"
598051
+ });
598052
+ $[18] = case_sensitive;
598053
+ $[19] = t9;
598054
+ } else t9 = $[19];
598055
+ let t10;
598056
+ if ($[20] !== t7 || $[21] !== t8 || $[22] !== t9) {
598057
+ t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
598058
+ t7,
598059
+ t8,
598060
+ t9
598061
+ ] });
598062
+ $[20] = t7;
598063
+ $[21] = t8;
598064
+ $[22] = t9;
598065
+ $[23] = t10;
598066
+ } else t10 = $[23];
598067
+ if ($[24] !== t10 || $[25] !== tool) {
598068
+ t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolHeader, {
598069
+ tool,
598070
+ label: TOOL_LABELS.Grep,
598071
+ extra: t10
598072
+ });
598073
+ $[24] = t10;
598074
+ $[25] = tool;
598075
+ $[26] = t4;
598076
+ } else t4 = $[26];
598077
+ t5 = previewFiles && previewFiles.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
598078
+ flexDirection: "column",
598079
+ paddingLeft: 2,
598080
+ children: [previewFiles.map(_temp3$1), hiddenCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
598081
+ flexDirection: "row",
598082
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598083
+ dimColor: true,
598084
+ children: " "
598085
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
598086
+ dimColor: true,
598087
+ children: [
598088
+ "+",
598089
+ hiddenCount,
598090
+ " more"
598091
+ ]
598092
+ })]
598093
+ })]
597802
598094
  });
597803
- $[9] = case_sensitive;
597804
- $[10] = t5;
597805
- } else t5 = $[10];
598095
+ $[2] = case_sensitive;
598096
+ $[3] = include_glob;
598097
+ $[4] = query;
598098
+ $[5] = tool;
598099
+ $[6] = T0;
598100
+ $[7] = matchCount;
598101
+ $[8] = t2;
598102
+ $[9] = t3;
598103
+ $[10] = t4;
598104
+ $[11] = t5;
598105
+ } else {
598106
+ T0 = $[6];
598107
+ matchCount = $[7];
598108
+ t2 = $[8];
598109
+ t3 = $[9];
598110
+ t4 = $[10];
598111
+ t5 = $[11];
598112
+ }
597806
598113
  let t6;
597807
- if ($[11] !== t3 || $[12] !== t4 || $[13] !== t5) {
597808
- t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
597809
- t3,
597810
- t4,
597811
- t5
597812
- ] });
597813
- $[11] = t3;
597814
- $[12] = t4;
597815
- $[13] = t5;
597816
- $[14] = t6;
597817
- } else t6 = $[14];
597818
- let t7;
597819
- if ($[15] !== t6 || $[16] !== tool) {
597820
- t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolHeader, {
597821
- tool,
597822
- label: TOOL_LABELS.Grep,
597823
- extra: t6
597824
- });
597825
- $[15] = t6;
597826
- $[16] = tool;
597827
- $[17] = t7;
597828
- } else t7 = $[17];
597829
- let t8;
597830
- if ($[18] !== matchCount) {
597831
- t8 = matchCount != null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
598114
+ if ($[27] !== matchCount) {
598115
+ t6 = matchCount === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
597832
598116
  paddingLeft: 2,
597833
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
598117
+ flexDirection: "row",
598118
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597834
598119
  dimColor: true,
597835
- children: [
597836
- matchCount,
597837
- " match",
597838
- matchCount !== 1 ? "es" : ""
597839
- ]
597840
- })
598120
+ children: "└ "
598121
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598122
+ dimColor: true,
598123
+ children: "no matches"
598124
+ })]
597841
598125
  });
597842
- $[18] = matchCount;
597843
- $[19] = t8;
597844
- } else t8 = $[19];
597845
- let t9;
597846
- if ($[20] !== t7 || $[21] !== t8) {
597847
- t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
597848
- flexDirection: "column",
597849
- paddingX: 1,
597850
- children: [t7, t8]
598126
+ $[27] = matchCount;
598127
+ $[28] = t6;
598128
+ } else t6 = $[28];
598129
+ let t7;
598130
+ if ($[29] !== T0 || $[30] !== t2 || $[31] !== t3 || $[32] !== t4 || $[33] !== t5 || $[34] !== t6) {
598131
+ t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(T0, {
598132
+ flexDirection: t2,
598133
+ paddingX: t3,
598134
+ children: [
598135
+ t4,
598136
+ t5,
598137
+ t6
598138
+ ]
597851
598139
  });
597852
- $[20] = t7;
597853
- $[21] = t8;
597854
- $[22] = t9;
597855
- } else t9 = $[22];
597856
- return t9;
598140
+ $[29] = T0;
598141
+ $[30] = t2;
598142
+ $[31] = t3;
598143
+ $[32] = t4;
598144
+ $[33] = t5;
598145
+ $[34] = t6;
598146
+ $[35] = t7;
598147
+ } else t7 = $[35];
598148
+ return t7;
598149
+ }
598150
+ function _temp3$1(file, i) {
598151
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
598152
+ flexDirection: "row",
598153
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598154
+ dimColor: true,
598155
+ children: i === 0 ? "└ " : " "
598156
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilePath, { path: file })]
598157
+ }, i);
597857
598158
  }
597858
598159
  function ToolCallGlob(t0) {
597859
- const $ = (0, import_compiler_runtime.c)(15);
598160
+ const $ = (0, import_compiler_runtime.c)(24);
597860
598161
  const { tool } = t0;
597861
598162
  let t1;
597862
598163
  if ($[0] !== tool.input) {
@@ -597865,60 +598166,116 @@ function ToolCallGlob(t0) {
597865
598166
  $[1] = t1;
597866
598167
  } else t1 = $[1];
597867
598168
  const { pattern } = t1;
598169
+ let T0;
598170
+ let fileCount;
597868
598171
  let t2;
597869
- if ($[2] !== tool.state || $[3] !== tool.toolResult) {
597870
- const resultText = tool.state === "success" ? getResultText(tool.toolResult) : void 0;
597871
- t2 = resultText ? resultText.trim().split("\n").filter(Boolean).length : void 0;
597872
- $[2] = tool.state;
597873
- $[3] = tool.toolResult;
597874
- $[4] = t2;
597875
- } else t2 = $[4];
597876
- const fileCount = t2;
597877
598172
  let t3;
597878
- if ($[5] !== pattern) {
597879
- t3 = pattern ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CmdText, { cmd: pattern }) : void 0;
597880
- $[5] = pattern;
597881
- $[6] = t3;
597882
- } else t3 = $[6];
597883
598173
  let t4;
597884
- if ($[7] !== t3 || $[8] !== tool) {
597885
- t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolHeader, {
597886
- tool,
597887
- label: TOOL_LABELS.Glob,
597888
- extra: t3
598174
+ let t5;
598175
+ if ($[2] !== pattern || $[3] !== tool) {
598176
+ const resultText = tool.state === "success" ? getResultText(tool.toolResult) : void 0;
598177
+ const allFiles = resultText ? resultText.trim().split("\n").filter(Boolean) : void 0;
598178
+ fileCount = allFiles?.length;
598179
+ const previewFiles = allFiles?.slice(0, RESULT_PREVIEW_LINES);
598180
+ const hiddenCount = fileCount != null && fileCount > RESULT_PREVIEW_LINES ? fileCount - RESULT_PREVIEW_LINES : 0;
598181
+ T0 = Box;
598182
+ t2 = "column";
598183
+ t3 = 1;
598184
+ let t6;
598185
+ if ($[10] !== pattern) {
598186
+ t6 = pattern ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CmdText, { cmd: pattern }) : void 0;
598187
+ $[10] = pattern;
598188
+ $[11] = t6;
598189
+ } else t6 = $[11];
598190
+ if ($[12] !== t6 || $[13] !== tool) {
598191
+ t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolHeader, {
598192
+ tool,
598193
+ label: TOOL_LABELS.Glob,
598194
+ extra: t6
598195
+ });
598196
+ $[12] = t6;
598197
+ $[13] = tool;
598198
+ $[14] = t4;
598199
+ } else t4 = $[14];
598200
+ t5 = previewFiles && previewFiles.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
598201
+ flexDirection: "column",
598202
+ paddingLeft: 2,
598203
+ children: [previewFiles.map(_temp4), hiddenCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
598204
+ flexDirection: "row",
598205
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598206
+ dimColor: true,
598207
+ children: " "
598208
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
598209
+ dimColor: true,
598210
+ children: [
598211
+ "+",
598212
+ hiddenCount,
598213
+ " more"
598214
+ ]
598215
+ })]
598216
+ })]
597889
598217
  });
598218
+ $[2] = pattern;
598219
+ $[3] = tool;
598220
+ $[4] = T0;
598221
+ $[5] = fileCount;
598222
+ $[6] = t2;
597890
598223
  $[7] = t3;
597891
- $[8] = tool;
597892
- $[9] = t4;
597893
- } else t4 = $[9];
597894
- let t5;
597895
- if ($[10] !== fileCount) {
597896
- t5 = fileCount != null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
598224
+ $[8] = t4;
598225
+ $[9] = t5;
598226
+ } else {
598227
+ T0 = $[4];
598228
+ fileCount = $[5];
598229
+ t2 = $[6];
598230
+ t3 = $[7];
598231
+ t4 = $[8];
598232
+ t5 = $[9];
598233
+ }
598234
+ let t6;
598235
+ if ($[15] !== fileCount) {
598236
+ t6 = fileCount === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
597897
598237
  paddingLeft: 2,
597898
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
598238
+ flexDirection: "row",
598239
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
597899
598240
  dimColor: true,
597900
- children: [
597901
- fileCount,
597902
- " file",
597903
- fileCount !== 1 ? "s" : ""
597904
- ]
597905
- })
598241
+ children: "└ "
598242
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598243
+ dimColor: true,
598244
+ children: "no files found"
598245
+ })]
597906
598246
  });
597907
- $[10] = fileCount;
597908
- $[11] = t5;
597909
- } else t5 = $[11];
597910
- let t6;
597911
- if ($[12] !== t4 || $[13] !== t5) {
597912
- t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
597913
- flexDirection: "column",
597914
- paddingX: 1,
597915
- children: [t4, t5]
598247
+ $[15] = fileCount;
598248
+ $[16] = t6;
598249
+ } else t6 = $[16];
598250
+ let t7;
598251
+ if ($[17] !== T0 || $[18] !== t2 || $[19] !== t3 || $[20] !== t4 || $[21] !== t5 || $[22] !== t6) {
598252
+ t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(T0, {
598253
+ flexDirection: t2,
598254
+ paddingX: t3,
598255
+ children: [
598256
+ t4,
598257
+ t5,
598258
+ t6
598259
+ ]
597916
598260
  });
597917
- $[12] = t4;
597918
- $[13] = t5;
597919
- $[14] = t6;
597920
- } else t6 = $[14];
597921
- return t6;
598261
+ $[17] = T0;
598262
+ $[18] = t2;
598263
+ $[19] = t3;
598264
+ $[20] = t4;
598265
+ $[21] = t5;
598266
+ $[22] = t6;
598267
+ $[23] = t7;
598268
+ } else t7 = $[23];
598269
+ return t7;
598270
+ }
598271
+ function _temp4(file, i) {
598272
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
598273
+ flexDirection: "row",
598274
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598275
+ dimColor: true,
598276
+ children: i === 0 ? "└ " : " "
598277
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilePath, { path: file })]
598278
+ }, i);
597922
598279
  }
597923
598280
  function ToolCallReadRule(t0) {
597924
598281
  const $ = (0, import_compiler_runtime.c)(7);
@@ -598085,7 +598442,7 @@ function ToolCallGetScreenshot(t0) {
598085
598442
  return t5;
598086
598443
  }
598087
598444
  function ToolCallAgent(t0) {
598088
- const $ = (0, import_compiler_runtime.c)(16);
598445
+ const $ = (0, import_compiler_runtime.c)(17);
598089
598446
  const { tool } = t0;
598090
598447
  let t1;
598091
598448
  if ($[0] !== tool.input) {
@@ -598107,13 +598464,14 @@ function ToolCallAgent(t0) {
598107
598464
  }
598108
598465
  let t3;
598109
598466
  if ($[3] !== tool.agentContext) {
598110
- t3 = tool.agentContext.split("\n").map(_temp3$1).filter(_temp4).slice(-8);
598467
+ t3 = tool.agentContext.split("\n").map(_temp5).filter(_temp6).slice(-8);
598111
598468
  $[3] = tool.agentContext;
598112
598469
  $[4] = t3;
598113
598470
  } else t3 = $[4];
598114
598471
  t2 = t3;
598115
598472
  }
598116
598473
  const lines = t2;
598474
+ const isRunning = tool.state === "generating" || tool.state === "running";
598117
598475
  const t3 = `Agent(${subagent_type ?? "explorer"})`;
598118
598476
  let t4;
598119
598477
  if ($[5] !== description) {
@@ -598137,8 +598495,8 @@ function ToolCallAgent(t0) {
598137
598495
  $[10] = t5;
598138
598496
  } else t5 = $[10];
598139
598497
  let t6;
598140
- if ($[11] !== lines) {
598141
- t6 = lines.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
598498
+ if ($[11] !== isRunning || $[12] !== lines) {
598499
+ t6 = isRunning && lines.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
598142
598500
  flexDirection: "column",
598143
598501
  marginLeft: 3,
598144
598502
  paddingX: 1,
@@ -598147,36 +598505,75 @@ function ToolCallAgent(t0) {
598147
598505
  borderStyle: "round",
598148
598506
  borderColor: "grey",
598149
598507
  borderDimColor: true,
598150
- children: lines.map(_temp5)
598508
+ children: lines.map(_temp7)
598151
598509
  });
598152
- $[11] = lines;
598153
- $[12] = t6;
598154
- } else t6 = $[12];
598510
+ $[11] = isRunning;
598511
+ $[12] = lines;
598512
+ $[13] = t6;
598513
+ } else t6 = $[13];
598155
598514
  let t7;
598156
- if ($[13] !== t5 || $[14] !== t6) {
598515
+ if ($[14] !== t5 || $[15] !== t6) {
598157
598516
  t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
598158
598517
  flexDirection: "column",
598159
598518
  paddingX: 1,
598160
598519
  children: [t5, t6]
598161
598520
  });
598162
- $[13] = t5;
598163
- $[14] = t6;
598164
- $[15] = t7;
598165
- } else t7 = $[15];
598521
+ $[14] = t5;
598522
+ $[15] = t6;
598523
+ $[16] = t7;
598524
+ } else t7 = $[16];
598166
598525
  return t7;
598167
598526
  }
598168
- function _temp5(line, i) {
598527
+ function _temp7(line, i) {
598169
598528
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598170
598529
  dimColor: true,
598171
598530
  children: line
598172
598531
  }, i);
598173
598532
  }
598174
- function _temp4(l_0) {
598533
+ function _temp6(l_0) {
598175
598534
  return l_0.length > 0;
598176
598535
  }
598177
- function _temp3$1(l) {
598536
+ function _temp5(l) {
598178
598537
  return l.trimEnd();
598179
598538
  }
598539
+ function ToolCallExitPlanMode(t0) {
598540
+ const $ = (0, import_compiler_runtime.c)(8);
598541
+ const { tool } = t0;
598542
+ const plan = tool.structuredResult?.plan ?? tool.input?.plan;
598543
+ let t1;
598544
+ if ($[0] !== tool) {
598545
+ t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolHeader, {
598546
+ tool,
598547
+ label: TOOL_LABELS.ExitPlanMode
598548
+ });
598549
+ $[0] = tool;
598550
+ $[1] = t1;
598551
+ } else t1 = $[1];
598552
+ let t2;
598553
+ if ($[2] !== plan || $[3] !== tool.state) {
598554
+ t2 = plan && tool.state === "success" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
598555
+ flexDirection: "column",
598556
+ paddingLeft: 2,
598557
+ marginTop: 1,
598558
+ children: renderMarkdownBlocks(plan)
598559
+ });
598560
+ $[2] = plan;
598561
+ $[3] = tool.state;
598562
+ $[4] = t2;
598563
+ } else t2 = $[4];
598564
+ let t3;
598565
+ if ($[5] !== t1 || $[6] !== t2) {
598566
+ t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
598567
+ flexDirection: "column",
598568
+ paddingX: 1,
598569
+ children: [t1, t2]
598570
+ });
598571
+ $[5] = t1;
598572
+ $[6] = t2;
598573
+ $[7] = t3;
598574
+ } else t3 = $[7];
598575
+ return t3;
598576
+ }
598180
598577
  function ToolCallGeneric(t0) {
598181
598578
  const $ = (0, import_compiler_runtime.c)(11);
598182
598579
  const { tool } = t0;
@@ -598223,8 +598620,9 @@ function ToolCallGeneric(t0) {
598223
598620
  } else t4 = $[10];
598224
598621
  return t4;
598225
598622
  }
598623
+ const WRITE_PREVIEW_MAX_LINES = 60;
598226
598624
  function ToolCallWrite(t0) {
598227
- const $ = (0, import_compiler_runtime.c)(14);
598625
+ const $ = (0, import_compiler_runtime.c)(17);
598228
598626
  const { tool } = t0;
598229
598627
  let t1;
598230
598628
  if ($[0] !== tool.input) {
@@ -598234,54 +598632,63 @@ function ToolCallWrite(t0) {
598234
598632
  } else t1 = $[1];
598235
598633
  const { file_path, title, content } = t1;
598236
598634
  let t2;
598237
- if ($[2] !== title) {
598238
- t2 = title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598239
- dimColor: true,
598240
- children: title
598241
- }) : void 0;
598242
- $[2] = title;
598635
+ if ($[2] !== file_path) {
598636
+ t2 = file_path?.startsWith(".builder/plans/");
598637
+ $[2] = file_path;
598243
598638
  $[3] = t2;
598244
598639
  } else t2 = $[3];
598640
+ const isPlanFile = t2;
598245
598641
  let t3;
598246
- if ($[4] !== t2 || $[5] !== tool) {
598247
- t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolHeader, {
598642
+ if ($[4] !== title) {
598643
+ t3 = title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598644
+ dimColor: true,
598645
+ children: title
598646
+ }) : void 0;
598647
+ $[4] = title;
598648
+ $[5] = t3;
598649
+ } else t3 = $[5];
598650
+ let t4;
598651
+ if ($[6] !== t3 || $[7] !== tool) {
598652
+ t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolHeader, {
598248
598653
  tool,
598249
598654
  label: TOOL_LABELS.Write,
598250
- extra: t2
598655
+ extra: t3
598251
598656
  });
598252
- $[4] = t2;
598253
- $[5] = tool;
598254
598657
  $[6] = t3;
598255
- } else t3 = $[6];
598256
- let t4;
598257
- if ($[7] !== content || $[8] !== file_path || $[9] !== tool.state) {
598258
- t4 = tool.state === "success" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodePreview, {
598658
+ $[7] = tool;
598659
+ $[8] = t4;
598660
+ } else t4 = $[8];
598661
+ let t5;
598662
+ if ($[9] !== content || $[10] !== file_path || $[11] !== isPlanFile || $[12] !== tool.state) {
598663
+ t5 = tool.state === "success" && !isPlanFile && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodePreview, {
598259
598664
  code: content ?? "",
598260
598665
  filePath: file_path,
598261
598666
  paddingLeft: 2,
598262
- highlight: true
598667
+ highlight: true,
598668
+ maxLines: WRITE_PREVIEW_MAX_LINES
598263
598669
  });
598264
- $[7] = content;
598265
- $[8] = file_path;
598266
- $[9] = tool.state;
598267
- $[10] = t4;
598268
- } else t4 = $[10];
598269
- let t5;
598270
- if ($[11] !== t3 || $[12] !== t4) {
598271
- t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
598670
+ $[9] = content;
598671
+ $[10] = file_path;
598672
+ $[11] = isPlanFile;
598673
+ $[12] = tool.state;
598674
+ $[13] = t5;
598675
+ } else t5 = $[13];
598676
+ let t6;
598677
+ if ($[14] !== t4 || $[15] !== t5) {
598678
+ t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
598272
598679
  flexDirection: "column",
598273
598680
  paddingX: 1,
598274
- children: [t3, t4]
598681
+ children: [t4, t5]
598275
598682
  });
598276
- $[11] = t3;
598277
- $[12] = t4;
598278
- $[13] = t5;
598279
- } else t5 = $[13];
598280
- return t5;
598683
+ $[14] = t4;
598684
+ $[15] = t5;
598685
+ $[16] = t6;
598686
+ } else t6 = $[16];
598687
+ return t6;
598281
598688
  }
598282
598689
  function CodePreview(t0) {
598283
- const $ = (0, import_compiler_runtime.c)(18);
598284
- const { code, filePath, paddingLeft, highlight } = t0;
598690
+ const $ = (0, import_compiler_runtime.c)(28);
598691
+ const { code, filePath, paddingLeft, highlight, maxLines } = t0;
598285
598692
  const theme = useTheme();
598286
598693
  let t1;
598287
598694
  if ($[0] !== filePath) {
@@ -598299,12 +598706,22 @@ function CodePreview(t0) {
598299
598706
  $[4] = highlight;
598300
598707
  $[5] = t2;
598301
598708
  } else t2 = $[5];
598302
- const highlightedLines = t2;
598303
- const lineNumberWidth = String(highlightedLines.length).length;
598304
- const t3 = theme.inputBackground;
598305
- let t4;
598306
- if ($[6] !== filePath) {
598307
- t4 = filePath && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
598709
+ const allHighlightedLines = t2;
598710
+ const truncated = maxLines != null && allHighlightedLines.length > maxLines;
598711
+ let t3;
598712
+ if ($[6] !== allHighlightedLines || $[7] !== maxLines || $[8] !== truncated) {
598713
+ t3 = truncated ? allHighlightedLines.slice(0, maxLines) : allHighlightedLines;
598714
+ $[6] = allHighlightedLines;
598715
+ $[7] = maxLines;
598716
+ $[8] = truncated;
598717
+ $[9] = t3;
598718
+ } else t3 = $[9];
598719
+ const highlightedLines = t3;
598720
+ const lineNumberWidth = String(allHighlightedLines.length).length;
598721
+ const t4 = theme.inputBackground;
598722
+ let t5;
598723
+ if ($[10] !== filePath) {
598724
+ t5 = filePath && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
598308
598725
  marginBottom: 1,
598309
598726
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598310
598727
  color: "cyan",
@@ -598312,14 +598729,14 @@ function CodePreview(t0) {
598312
598729
  children: fileHyperlink(filePath)
598313
598730
  })
598314
598731
  });
598315
- $[6] = filePath;
598316
- $[7] = t4;
598317
- } else t4 = $[7];
598318
- let t5;
598319
- if ($[8] !== highlightedLines || $[9] !== lineNumberWidth) {
598320
- let t6;
598321
- if ($[11] !== lineNumberWidth) {
598322
- t6 = (line, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, { children: [
598732
+ $[10] = filePath;
598733
+ $[11] = t5;
598734
+ } else t5 = $[11];
598735
+ let t6;
598736
+ if ($[12] !== highlightedLines || $[13] !== lineNumberWidth) {
598737
+ let t7;
598738
+ if ($[15] !== lineNumberWidth) {
598739
+ t7 = (line, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, { children: [
598323
598740
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598324
598741
  dimColor: true,
598325
598742
  children: String(index + 1).padStart(lineNumberWidth, " ")
@@ -598330,36 +598747,58 @@ function CodePreview(t0) {
598330
598747
  }),
598331
598748
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: line || " " })
598332
598749
  ] }, index);
598333
- $[11] = lineNumberWidth;
598334
- $[12] = t6;
598335
- } else t6 = $[12];
598336
- t5 = highlightedLines.map(t6);
598337
- $[8] = highlightedLines;
598338
- $[9] = lineNumberWidth;
598339
- $[10] = t5;
598340
- } else t5 = $[10];
598341
- let t6;
598342
- if ($[13] !== paddingLeft || $[14] !== t4 || $[15] !== t5 || $[16] !== theme.inputBackground) {
598343
- t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
598750
+ $[15] = lineNumberWidth;
598751
+ $[16] = t7;
598752
+ } else t7 = $[16];
598753
+ t6 = highlightedLines.map(t7);
598754
+ $[12] = highlightedLines;
598755
+ $[13] = lineNumberWidth;
598756
+ $[14] = t6;
598757
+ } else t6 = $[14];
598758
+ let t7;
598759
+ if ($[17] !== allHighlightedLines.length || $[18] !== lineNumberWidth || $[19] !== maxLines || $[20] !== truncated) {
598760
+ t7 = truncated && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
598761
+ dimColor: true,
598762
+ children: [
598763
+ " ".repeat(lineNumberWidth + 3),
598764
+ "+",
598765
+ allHighlightedLines.length - maxLines,
598766
+ " more lines"
598767
+ ]
598768
+ });
598769
+ $[17] = allHighlightedLines.length;
598770
+ $[18] = lineNumberWidth;
598771
+ $[19] = maxLines;
598772
+ $[20] = truncated;
598773
+ $[21] = t7;
598774
+ } else t7 = $[21];
598775
+ let t8;
598776
+ if ($[22] !== paddingLeft || $[23] !== t5 || $[24] !== t6 || $[25] !== t7 || $[26] !== theme.inputBackground) {
598777
+ t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
598344
598778
  flexDirection: "column",
598345
598779
  paddingLeft,
598346
598780
  marginTop: 0,
598347
598781
  paddingX: 1,
598348
598782
  paddingY: 1,
598349
598783
  marginBottom: 1,
598350
- backgroundColor: t3,
598351
- children: [t4, t5]
598784
+ backgroundColor: t4,
598785
+ children: [
598786
+ t5,
598787
+ t6,
598788
+ t7
598789
+ ]
598352
598790
  });
598353
- $[13] = paddingLeft;
598354
- $[14] = t4;
598355
- $[15] = t5;
598356
- $[16] = theme.inputBackground;
598357
- $[17] = t6;
598358
- } else t6 = $[17];
598359
- return t6;
598791
+ $[22] = paddingLeft;
598792
+ $[23] = t5;
598793
+ $[24] = t6;
598794
+ $[25] = t7;
598795
+ $[26] = theme.inputBackground;
598796
+ $[27] = t8;
598797
+ } else t8 = $[27];
598798
+ return t8;
598360
598799
  }
598361
598800
  function ToolCallCompleted(t0) {
598362
- const $ = (0, import_compiler_runtime.c)(24);
598801
+ const $ = (0, import_compiler_runtime.c)(26);
598363
598802
  const { tool } = t0;
598364
598803
  switch (tool.toolName) {
598365
598804
  case "Read": {
@@ -598462,23 +598901,33 @@ function ToolCallCompleted(t0) {
598462
598901
  } else t2 = $[19];
598463
598902
  return t2;
598464
598903
  }
598465
- case "Agent": {
598904
+ case "ExitPlanMode": {
598466
598905
  const t1 = tool;
598467
598906
  let t2;
598468
598907
  if ($[20] !== t1) {
598469
- t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolCallAgent, { tool: t1 });
598908
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolCallExitPlanMode, { tool: t1 });
598470
598909
  $[20] = t1;
598471
598910
  $[21] = t2;
598472
598911
  } else t2 = $[21];
598473
598912
  return t2;
598474
598913
  }
598914
+ case "Agent": {
598915
+ const t1 = tool;
598916
+ let t2;
598917
+ if ($[22] !== t1) {
598918
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolCallAgent, { tool: t1 });
598919
+ $[22] = t1;
598920
+ $[23] = t2;
598921
+ } else t2 = $[23];
598922
+ return t2;
598923
+ }
598475
598924
  default: {
598476
598925
  let t1;
598477
- if ($[22] !== tool) {
598926
+ if ($[24] !== tool) {
598478
598927
  t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolCallGeneric, { tool });
598479
- $[22] = tool;
598480
- $[23] = t1;
598481
- } else t1 = $[23];
598928
+ $[24] = tool;
598929
+ $[25] = t1;
598930
+ } else t1 = $[25];
598482
598931
  return t1;
598483
598932
  }
598484
598933
  }
@@ -598486,14 +598935,17 @@ function ToolCallCompleted(t0) {
598486
598935
  //#endregion
598487
598936
  //#region src/components/MessageBlockView.tsx
598488
598937
  const MessageBlockView = (0, import_react.memo)((props) => {
598489
- const $ = (0, import_compiler_runtime.c)(19);
598938
+ const $ = (0, import_compiler_runtime.c)(20);
598490
598939
  const message = useSnapshot(props.message);
598491
598940
  const theme = useTheme();
598492
598941
  switch (message.type) {
598493
598942
  case "user": {
598494
598943
  let t0;
598495
598944
  if ($[0] !== message.displayPrompt) {
598496
- t0 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: message.displayPrompt });
598945
+ t0 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598946
+ wrap: "wrap",
598947
+ children: message.displayPrompt
598948
+ });
598497
598949
  $[0] = message.displayPrompt;
598498
598950
  $[1] = t0;
598499
598951
  } else t0 = $[1];
@@ -598543,32 +598995,37 @@ const MessageBlockView = (0, import_react.memo)((props) => {
598543
598995
  return t1;
598544
598996
  }
598545
598997
  case "thinking": {
598546
- let t0;
598547
- if ($[12] !== message.content || $[13] !== message.id) {
598548
- t0 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThinkingBlock, { text: message.content }, message.id);
598998
+ const t0 = message;
598999
+ let t1;
599000
+ if ($[12] !== message.content || $[13] !== message.id || $[14] !== t0.streaming) {
599001
+ t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThinkingBlock, {
599002
+ text: message.content,
599003
+ streaming: t0.streaming
599004
+ }, message.id);
598549
599005
  $[12] = message.content;
598550
599006
  $[13] = message.id;
598551
- $[14] = t0;
598552
- } else t0 = $[14];
598553
- return t0;
599007
+ $[14] = t0.streaming;
599008
+ $[15] = t1;
599009
+ } else t1 = $[15];
599010
+ return t1;
598554
599011
  }
598555
599012
  case "idle": {
598556
599013
  const t0 = message;
598557
599014
  let t1;
598558
- if ($[15] !== message.id || $[16] !== t0) {
599015
+ if ($[16] !== message.id || $[17] !== t0) {
598559
599016
  t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IdleBlock, { message: t0 }, message.id);
598560
- $[15] = message.id;
598561
- $[16] = t0;
598562
- $[17] = t1;
598563
- } else t1 = $[17];
599017
+ $[16] = message.id;
599018
+ $[17] = t0;
599019
+ $[18] = t1;
599020
+ } else t1 = $[18];
598564
599021
  return t1;
598565
599022
  }
598566
599023
  default: {
598567
599024
  let t0;
598568
- if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
599025
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
598569
599026
  t0 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
598570
- $[18] = t0;
598571
- } else t0 = $[18];
599027
+ $[19] = t0;
599028
+ } else t0 = $[19];
598572
599029
  return t0;
598573
599030
  }
598574
599031
  }
@@ -598587,7 +599044,7 @@ function CompletedTextBlock(t0) {
598587
599044
  t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
598588
599045
  flexDirection: "column",
598589
599046
  paddingX: 2,
598590
- marginBottom: 1,
599047
+ marginY: 1,
598591
599048
  children: t1
598592
599049
  });
598593
599050
  $[2] = t1;
@@ -598595,24 +599052,75 @@ function CompletedTextBlock(t0) {
598595
599052
  } else t2 = $[3];
598596
599053
  return t2;
598597
599054
  }
599055
+ const THINKING_MAX_CHARS = 400;
598598
599056
  function ThinkingBlock(t0) {
598599
- const $ = (0, import_compiler_runtime.c)(2);
598600
- const { text } = t0;
598601
- let t1;
599057
+ const $ = (0, import_compiler_runtime.c)(12);
599058
+ const { text, streaming: t1 } = t0;
599059
+ const streaming = t1 === void 0 ? false : t1;
599060
+ let t2;
598602
599061
  if ($[0] !== text) {
598603
- t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
598604
- flexDirection: "column",
598605
- paddingX: 2,
598606
- marginBottom: 1,
599062
+ t2 = text.length > THINKING_MAX_CHARS ? text.slice(0, THINKING_MAX_CHARS).trimEnd() + "…" : text.trim();
599063
+ $[0] = text;
599064
+ $[1] = t2;
599065
+ } else t2 = $[1];
599066
+ const preview = t2;
599067
+ let t3;
599068
+ if ($[2] !== streaming) {
599069
+ t3 = streaming ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599070
+ bold: true,
599071
+ color: "cyan",
599072
+ children: "●"
599073
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599074
+ dimColor: true,
599075
+ children: "◆"
599076
+ });
599077
+ $[2] = streaming;
599078
+ $[3] = t3;
599079
+ } else t3 = $[3];
599080
+ let t4;
599081
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
599082
+ t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599083
+ bold: true,
599084
+ dimColor: true,
599085
+ children: "Thinking"
599086
+ });
599087
+ $[4] = t4;
599088
+ } else t4 = $[4];
599089
+ let t5;
599090
+ if ($[5] !== t3) {
599091
+ t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
599092
+ gap: 1,
599093
+ children: [t3, t4]
599094
+ });
599095
+ $[5] = t3;
599096
+ $[6] = t5;
599097
+ } else t5 = $[6];
599098
+ let t6;
599099
+ if ($[7] !== preview) {
599100
+ t6 = preview.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
599101
+ paddingLeft: 2,
598607
599102
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598608
599103
  dimColor: true,
598609
- children: text
599104
+ wrap: "wrap",
599105
+ children: preview
598610
599106
  })
598611
599107
  });
598612
- $[0] = text;
598613
- $[1] = t1;
598614
- } else t1 = $[1];
598615
- return t1;
599108
+ $[7] = preview;
599109
+ $[8] = t6;
599110
+ } else t6 = $[8];
599111
+ let t7;
599112
+ if ($[9] !== t5 || $[10] !== t6) {
599113
+ t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
599114
+ flexDirection: "column",
599115
+ paddingX: 1,
599116
+ marginY: 1,
599117
+ children: [t5, t6]
599118
+ });
599119
+ $[9] = t5;
599120
+ $[10] = t6;
599121
+ $[11] = t7;
599122
+ } else t7 = $[11];
599123
+ return t7;
598616
599124
  }
598617
599125
  function formatDuration(ms) {
598618
599126
  if (ms < 1e3) return `${ms}ms`;
@@ -598667,7 +599175,7 @@ function pickVerb(seed) {
598667
599175
  return IDLE_VERBS[hash % IDLE_VERBS.length];
598668
599176
  }
598669
599177
  function IdleBlock(t0) {
598670
- const $ = (0, import_compiler_runtime.c)(20);
599178
+ const $ = (0, import_compiler_runtime.c)(24);
598671
599179
  const { message } = t0;
598672
599180
  let t1;
598673
599181
  if ($[0] !== message.durationMs) {
@@ -598691,73 +599199,79 @@ function IdleBlock(t0) {
598691
599199
  $[5] = t4;
598692
599200
  } else t4 = $[5];
598693
599201
  const credits = t4;
599202
+ const isAbort = message.state === "abort";
599203
+ const isError = message.state === "error";
599204
+ const summaryIcon = isError ? "✗" : isAbort ? "◆" : "✦";
599205
+ const summaryColor = isError ? "red" : isAbort ? "yellow" : "magenta";
599206
+ const summaryText = isError ? `Failed after ${duration}` : isAbort ? `Interrupted after ${duration}` : `${verb} for ${duration}`;
598694
599207
  let t5;
598695
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
598696
- t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
598697
- color: "magenta",
598698
- bold: true,
598699
- children: "✦"
598700
- });
598701
- $[6] = t5;
598702
- } else t5 = $[6];
599208
+ if ($[6] !== message.applyResults) {
599209
+ t5 = message.applyResults.map(_temp$2);
599210
+ $[6] = message.applyResults;
599211
+ $[7] = t5;
599212
+ } else t5 = $[7];
598703
599213
  let t6;
598704
- if ($[7] !== duration || $[8] !== verb) {
598705
- t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
599214
+ if ($[8] !== summaryColor || $[9] !== summaryIcon) {
599215
+ t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599216
+ color: summaryColor,
598706
599217
  bold: true,
598707
- children: [
598708
- verb,
598709
- " for ",
598710
- duration
598711
- ]
599218
+ children: summaryIcon
598712
599219
  });
598713
- $[7] = duration;
598714
- $[8] = verb;
598715
- $[9] = t6;
598716
- } else t6 = $[9];
599220
+ $[8] = summaryColor;
599221
+ $[9] = summaryIcon;
599222
+ $[10] = t6;
599223
+ } else t6 = $[10];
598717
599224
  let t7;
598718
- if ($[10] !== credits) {
598719
- t7 = credits && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
599225
+ if ($[11] !== summaryText) {
599226
+ t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599227
+ bold: true,
599228
+ children: summaryText
599229
+ });
599230
+ $[11] = summaryText;
599231
+ $[12] = t7;
599232
+ } else t7 = $[12];
599233
+ let t8;
599234
+ if ($[13] !== credits || $[14] !== isAbort || $[15] !== isError) {
599235
+ t8 = credits && !isAbort && !isError && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
598720
599236
  dimColor: true,
598721
599237
  children: ["· ", credits]
598722
599238
  });
598723
- $[10] = credits;
598724
- $[11] = t7;
598725
- } else t7 = $[11];
598726
- let t8;
598727
- if ($[12] !== t6 || $[13] !== t7) {
598728
- t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
599239
+ $[13] = credits;
599240
+ $[14] = isAbort;
599241
+ $[15] = isError;
599242
+ $[16] = t8;
599243
+ } else t8 = $[16];
599244
+ let t9;
599245
+ if ($[17] !== t6 || $[18] !== t7 || $[19] !== t8) {
599246
+ t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
598729
599247
  gap: 1,
599248
+ marginTop: 1,
598730
599249
  children: [
598731
- t5,
598732
599250
  t6,
598733
- t7
599251
+ t7,
599252
+ t8
598734
599253
  ]
598735
599254
  });
598736
- $[12] = t6;
598737
- $[13] = t7;
598738
- $[14] = t8;
598739
- } else t8 = $[14];
598740
- let t9;
598741
- if ($[15] !== message.applyResults) {
598742
- t9 = message.applyResults.map(_temp$1);
598743
- $[15] = message.applyResults;
598744
- $[16] = t9;
598745
- } else t9 = $[16];
599255
+ $[17] = t6;
599256
+ $[18] = t7;
599257
+ $[19] = t8;
599258
+ $[20] = t9;
599259
+ } else t9 = $[20];
598746
599260
  let t10;
598747
- if ($[17] !== t8 || $[18] !== t9) {
599261
+ if ($[21] !== t5 || $[22] !== t9) {
598748
599262
  t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
598749
599263
  flexDirection: "column",
598750
599264
  paddingX: 0,
598751
599265
  marginY: 1,
598752
- children: [t8, t9]
599266
+ children: [t5, t9]
598753
599267
  });
598754
- $[17] = t8;
598755
- $[18] = t9;
598756
- $[19] = t10;
598757
- } else t10 = $[19];
599268
+ $[21] = t5;
599269
+ $[22] = t9;
599270
+ $[23] = t10;
599271
+ } else t10 = $[23];
598758
599272
  return t10;
598759
599273
  }
598760
- function _temp$1(result) {
599274
+ function _temp$2(result) {
598761
599275
  const { green, red } = buildDots(result.addedLines, result.removedLines);
598762
599276
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
598763
599277
  flexDirection: "row",
@@ -598934,14 +599448,6 @@ const CodeSession = (0, import_react.memo)(({ onExit, isTabActive = true }) => {
598934
599448
  api.abort().catch(() => {});
598935
599449
  return;
598936
599450
  }
598937
- if (key.upArrow) {
598938
- scrollByClamped(-1);
598939
- return;
598940
- }
598941
- if (key.downArrow) {
598942
- scrollByClamped(1);
598943
- return;
598944
- }
598945
599451
  if (key.pageUp) {
598946
599452
  scrollByClamped(-(scrollRef.current?.getViewportHeight() || 10));
598947
599453
  return;
@@ -599032,8 +599538,9 @@ const CodeSession = (0, import_react.memo)(({ onExit, isTabActive = true }) => {
599032
599538
  userScrolledUp.current = false;
599033
599539
  scrollRef.current?.scrollToBottom();
599034
599540
  }, [api]);
599035
- const startIndex = Math.max(0, state.messages.length - 200);
599036
- const visibleMessages = state.messages.slice(startIndex);
599541
+ const MAX_VISIBLE_MESSAGES = 200;
599542
+ const messageCount = state.messages.length;
599543
+ const startIndex = Math.max(0, messageCount - MAX_VISIBLE_MESSAGES);
599037
599544
  const hiddenCount = startIndex;
599038
599545
  const showInput = !!!state.activeUserQuestions;
599039
599546
  if (!isTabActive) return null;
@@ -599079,30 +599586,58 @@ const CodeSession = (0, import_react.memo)(({ onExit, isTabActive = true }) => {
599079
599586
  ref: scrollRef,
599080
599587
  flexGrow: 1,
599081
599588
  flexDirection: "column",
599082
- children: [hiddenCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
599083
- paddingX: 2,
599084
- paddingY: 1,
599085
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
599086
- dimColor: true,
599087
- children: [
599088
- "─── ",
599089
- hiddenCount,
599090
- " older message",
599091
- hiddenCount === 1 ? "" : "s",
599092
- " not shown ───"
599093
- ]
599094
- })
599095
- }), visibleMessages.map((msg, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBoundary, {
599096
- fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
599589
+ children: [
599590
+ messageCount === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
599097
599591
  paddingX: 2,
599592
+ paddingY: 1,
599098
599593
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599099
- color: "red",
599100
599594
  dimColor: true,
599101
- children: "[failed to render message]"
599595
+ children: "No messages yet. Type a prompt below to get started."
599102
599596
  })
599103
599597
  }),
599104
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MessageBlockView, { message: proxy.messages[startIndex + i] }, `msg-${msg.id}-${startIndex + i}`)
599105
- }, `err-${msg.id}-${startIndex + i}`))]
599598
+ hiddenCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
599599
+ paddingX: 2,
599600
+ paddingY: 1,
599601
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
599602
+ dimColor: true,
599603
+ children: [
599604
+ "─── ",
599605
+ hiddenCount,
599606
+ " older message",
599607
+ hiddenCount === 1 ? "" : "s",
599608
+ " not shown ───"
599609
+ ]
599610
+ })
599611
+ }),
599612
+ Array.from({ length: messageCount - startIndex }, (_, i) => {
599613
+ const idx = startIndex + i;
599614
+ const msgProxy = proxy.messages[idx];
599615
+ const msgId = msgProxy.id;
599616
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBoundary, {
599617
+ fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
599618
+ paddingX: 2,
599619
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599620
+ color: "red",
599621
+ dimColor: true,
599622
+ children: "[failed to render message]"
599623
+ })
599624
+ }),
599625
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MessageBlockView, { message: msgProxy }, `msg-${msgId}-${idx}`)
599626
+ }, `err-${msgId}-${idx}`);
599627
+ }),
599628
+ state.state === "generating" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
599629
+ gap: 1,
599630
+ marginTop: 2,
599631
+ marginBottom: 1,
599632
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProgressBar, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
599633
+ dimColor: true,
599634
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599635
+ bold: true,
599636
+ children: "esc"
599637
+ }), " interrupt"]
599638
+ })]
599639
+ }, "generating-progress-bar")
599640
+ ]
599106
599641
  })
599107
599642
  })
599108
599643
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
@@ -599288,7 +599823,6 @@ function useClawSession(credentials, onNewMessages) {
599288
599823
  }
599289
599824
  //#endregion
599290
599825
  //#region src/components/ClawSession.tsx
599291
- const MOUSE_RE = /^\[<(\d+);\d+;\d+[Mm]/;
599292
599826
  const SIDEBAR_WIDTH = 55;
599293
599827
  function formatMessageTime(ts) {
599294
599828
  const diffMs = Date.now() - ts;
@@ -599440,259 +599974,424 @@ const ClawSidebar = (0, import_react.memo)(() => {
599440
599974
  } else t2 = $[5];
599441
599975
  return t2;
599442
599976
  });
599443
- const ClawSession = (0, import_react.memo)(({ credentials, isActive, onNewMessages, onExit }) => {
599977
+ const ClawSession = (0, import_react.memo)((t0) => {
599978
+ const $ = (0, import_compiler_runtime.c)(60);
599979
+ const { credentials, isActive, onNewMessages, onExit } = t0;
599444
599980
  const { stdout } = useStdout();
599445
599981
  const [cols, setCols] = (0, import_react.useState)(stdout?.columns ?? 80);
599446
599982
  const [rows, setRows] = (0, import_react.useState)(stdout?.rows ?? 24);
599447
599983
  const theme = useTheme();
599448
- const [inputValue, setInputValue] = (0, import_react.useState)("");
599449
599984
  const [ctrlCPending, setCtrlCPending] = (0, import_react.useState)(false);
599450
599985
  const ctrlCTimer = (0, import_react.useRef)(null);
599451
599986
  const scrollRef = (0, import_react.useRef)(null);
599452
599987
  const userScrolledUp = (0, import_react.useRef)(false);
599453
- const scrollByClamped = (0, import_react.useCallback)((delta) => {
599454
- const scrollView = scrollRef.current;
599455
- if (!scrollView) return;
599456
- const currentOffset = scrollView.getScrollOffset();
599457
- const bottomOffset = Math.max(0, scrollView.getBottomOffset());
599458
- const nextOffset = Math.max(0, Math.min(bottomOffset, currentOffset + delta));
599459
- userScrolledUp.current = nextOffset < bottomOffset;
599460
- scrollView.scrollTo(nextOffset);
599461
- }, []);
599988
+ let t1;
599989
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
599990
+ t1 = (delta) => {
599991
+ const scrollView = scrollRef.current;
599992
+ if (!scrollView) return;
599993
+ const currentOffset = scrollView.getScrollOffset();
599994
+ const bottomOffset = Math.max(0, scrollView.getBottomOffset());
599995
+ const nextOffset = Math.max(0, Math.min(bottomOffset, currentOffset + delta));
599996
+ userScrolledUp.current = nextOffset < bottomOffset;
599997
+ scrollView.scrollTo(nextOffset);
599998
+ };
599999
+ $[0] = t1;
600000
+ } else t1 = $[0];
600001
+ const scrollByClamped = t1;
599462
600002
  const { messages, isSending, isWaitingForReply, error, sendMessage } = useClawSession(credentials, onNewMessages);
599463
- (0, import_react.useEffect)(() => {
599464
- if (!isActive) return;
599465
- userScrolledUp.current = false;
599466
- setTimeout(() => {
599467
- scrollRef.current?.remeasure();
599468
- scrollRef.current?.scrollToBottom();
599469
- }, 0);
599470
- }, [messages.length, isWaitingForReply]);
599471
- (0, import_react.useEffect)(() => {
599472
- if (isActive) {
600003
+ let t2;
600004
+ if ($[1] !== isActive) {
600005
+ t2 = () => {
600006
+ if (!isActive) return;
599473
600007
  userScrolledUp.current = false;
599474
600008
  setTimeout(() => {
599475
600009
  scrollRef.current?.remeasure();
599476
600010
  scrollRef.current?.scrollToBottom();
599477
600011
  }, 0);
599478
- }
599479
- }, [isActive]);
599480
- (0, import_react.useEffect)(() => {
599481
- return () => {
599482
- if (ctrlCTimer.current) clearTimeout(ctrlCTimer.current);
599483
600012
  };
599484
- }, []);
599485
- (0, import_react.useEffect)(() => {
599486
- const handleResize = () => {
599487
- scrollRef.current?.remeasure();
599488
- setCols(stdout?.columns ?? 80);
599489
- setRows(stdout?.rows ?? 24);
600013
+ $[1] = isActive;
600014
+ $[2] = t2;
600015
+ } else t2 = $[2];
600016
+ let t3;
600017
+ if ($[3] !== isWaitingForReply || $[4] !== messages.length) {
600018
+ t3 = [messages.length, isWaitingForReply];
600019
+ $[3] = isWaitingForReply;
600020
+ $[4] = messages.length;
600021
+ $[5] = t3;
600022
+ } else t3 = $[5];
600023
+ (0, import_react.useEffect)(t2, t3);
600024
+ let t4;
600025
+ let t5;
600026
+ if ($[6] !== isActive) {
600027
+ t4 = () => {
600028
+ if (isActive) {
600029
+ userScrolledUp.current = false;
600030
+ setTimeout(() => {
600031
+ scrollRef.current?.remeasure();
600032
+ scrollRef.current?.scrollToBottom();
600033
+ }, 0);
600034
+ }
599490
600035
  };
599491
- stdout?.on("resize", handleResize);
599492
- return () => {
599493
- stdout?.off("resize", handleResize);
600036
+ t5 = [isActive];
600037
+ $[6] = isActive;
600038
+ $[7] = t4;
600039
+ $[8] = t5;
600040
+ } else {
600041
+ t4 = $[7];
600042
+ t5 = $[8];
600043
+ }
600044
+ (0, import_react.useEffect)(t4, t5);
600045
+ let t6;
600046
+ let t7;
600047
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
600048
+ t6 = () => () => {
600049
+ if (ctrlCTimer.current) clearTimeout(ctrlCTimer.current);
599494
600050
  };
599495
- }, [stdout]);
600051
+ t7 = [];
600052
+ $[9] = t6;
600053
+ $[10] = t7;
600054
+ } else {
600055
+ t6 = $[9];
600056
+ t7 = $[10];
600057
+ }
600058
+ (0, import_react.useEffect)(t6, t7);
600059
+ let t8;
600060
+ let t9;
600061
+ if ($[11] !== stdout) {
600062
+ t8 = () => {
600063
+ const handleResize = () => {
600064
+ scrollRef.current?.remeasure();
600065
+ setCols(stdout?.columns ?? 80);
600066
+ setRows(stdout?.rows ?? 24);
600067
+ };
600068
+ stdout?.on("resize", handleResize);
600069
+ return () => {
600070
+ stdout?.off("resize", handleResize);
600071
+ };
600072
+ };
600073
+ t9 = [stdout];
600074
+ $[11] = stdout;
600075
+ $[12] = t8;
600076
+ $[13] = t9;
600077
+ } else {
600078
+ t8 = $[12];
600079
+ t9 = $[13];
600080
+ }
600081
+ (0, import_react.useEffect)(t8, t9);
599496
600082
  const showSidebar = cols >= 100 && rows >= 24;
599497
- const handleSubmit = (0, import_react.useCallback)(async (val) => {
599498
- if (!val.trim() || isSending) return;
599499
- setInputValue("");
599500
- await sendMessage(val.trim());
599501
- userScrolledUp.current = false;
599502
- scrollRef.current?.scrollToBottom();
599503
- }, [isSending, sendMessage]);
599504
- useInput((input, key) => {
599505
- if (input === "c" && key.ctrl) {
599506
- if (ctrlCPending) {
599507
- if (ctrlCTimer.current) clearTimeout(ctrlCTimer.current);
599508
- onExit?.();
599509
- } else {
599510
- setCtrlCPending(true);
599511
- ctrlCTimer.current = setTimeout(() => {
599512
- setCtrlCPending(false);
599513
- ctrlCTimer.current = null;
599514
- }, 1e3);
600083
+ let t10;
600084
+ if ($[14] !== sendMessage) {
600085
+ t10 = async (val) => {
600086
+ if (!val.trim()) return;
600087
+ await sendMessage(val.trim());
600088
+ userScrolledUp.current = false;
600089
+ scrollRef.current?.scrollToBottom();
600090
+ };
600091
+ $[14] = sendMessage;
600092
+ $[15] = t10;
600093
+ } else t10 = $[15];
600094
+ const handleSubmit = t10;
600095
+ let t11;
600096
+ if ($[16] !== ctrlCPending || $[17] !== onExit) {
600097
+ t11 = (input, key) => {
600098
+ if (input === "c" && key.ctrl) {
600099
+ if (ctrlCPending) {
600100
+ if (ctrlCTimer.current) clearTimeout(ctrlCTimer.current);
600101
+ onExit?.();
600102
+ } else {
600103
+ setCtrlCPending(true);
600104
+ ctrlCTimer.current = setTimeout(() => {
600105
+ setCtrlCPending(false);
600106
+ ctrlCTimer.current = null;
600107
+ }, 1e3);
600108
+ }
600109
+ return;
599515
600110
  }
599516
- return;
599517
- }
599518
- if (key.upArrow) {
599519
- scrollByClamped(-1);
599520
- return;
599521
- }
599522
- if (key.downArrow) {
599523
- scrollByClamped(1);
599524
- return;
599525
- }
599526
- if (key.pageUp) {
599527
- scrollByClamped(-(scrollRef.current?.getViewportHeight() || 10));
599528
- return;
599529
- }
599530
- if (key.pageDown) {
599531
- scrollByClamped(scrollRef.current?.getViewportHeight() || 10);
599532
- return;
599533
- }
599534
- }, { isActive });
599535
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
599536
- flexDirection: "row",
599537
- flexGrow: 1,
599538
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
600111
+ if (key.upArrow) {
600112
+ scrollByClamped(-1);
600113
+ return;
600114
+ }
600115
+ if (key.downArrow) {
600116
+ scrollByClamped(1);
600117
+ return;
600118
+ }
600119
+ if (key.pageUp) {
600120
+ scrollByClamped(-(scrollRef.current?.getViewportHeight() || 10));
600121
+ return;
600122
+ }
600123
+ if (key.pageDown) {
600124
+ scrollByClamped(scrollRef.current?.getViewportHeight() || 10);
600125
+ return;
600126
+ }
600127
+ };
600128
+ $[16] = ctrlCPending;
600129
+ $[17] = onExit;
600130
+ $[18] = t11;
600131
+ } else t11 = $[18];
600132
+ let t12;
600133
+ if ($[19] !== isActive) {
600134
+ t12 = { isActive };
600135
+ $[19] = isActive;
600136
+ $[20] = t12;
600137
+ } else t12 = $[20];
600138
+ useInput(t11, t12);
600139
+ let t13;
600140
+ if ($[21] !== messages) {
600141
+ t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
599539
600142
  flexDirection: "column",
599540
600143
  flexGrow: 1,
599541
- paddingRight: 2,
599542
- children: [
599543
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
599544
- flexDirection: "column",
599545
- flexGrow: 1,
599546
- flexBasis: 0,
599547
- overflow: "hidden",
599548
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ScrollView, {
599549
- ref: scrollRef,
599550
- flexGrow: 1,
599551
- flexDirection: "column",
599552
- children: messages.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
599553
- paddingX: 2,
599554
- paddingY: 1,
599555
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599556
- dimColor: true,
599557
- children: "No messages yet. Send a message to start a conversation with Claw."
599558
- })
599559
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: (() => {
599560
- const startIndex = Math.max(0, messages.length - 100);
599561
- const visibleMessages = messages.slice(startIndex);
599562
- const hiddenCount = startIndex;
599563
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [hiddenCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
599564
- paddingX: 2,
599565
- paddingY: 1,
599566
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
599567
- dimColor: true,
599568
- children: [
599569
- "─── ",
599570
- hiddenCount,
599571
- " older message",
599572
- hiddenCount === 1 ? "" : "s",
599573
- " not shown ───"
599574
- ]
599575
- })
599576
- }), visibleMessages.map((msg) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBoundary, {
599577
- fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
599578
- paddingX: 2,
599579
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599580
- color: "red",
599581
- dimColor: true,
599582
- children: "[failed to render message]"
599583
- })
599584
- }),
599585
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClawMessageView, { message: msg })
599586
- }, msg.id))] });
599587
- })() })
599588
- })
599589
- }),
599590
- isWaitingForReply && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
599591
- paddingX: 2,
599592
- paddingY: 0,
599593
- gap: 1,
599594
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599595
- dimColor: true,
599596
- children: "Claw is thinking"
599597
- })]
599598
- }),
599599
- error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
600144
+ flexBasis: 0,
600145
+ overflow: "hidden",
600146
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ScrollView, {
600147
+ ref: scrollRef,
600148
+ flexGrow: 1,
600149
+ flexDirection: "column",
600150
+ children: messages.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
599600
600151
  paddingX: 2,
599601
- marginBottom: 1,
600152
+ paddingY: 1,
599602
600153
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599603
- color: "red",
599604
- children: error
599605
- })
599606
- }),
599607
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBoundary, {
599608
- fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599609
- color: "red",
599610
600154
  dimColor: true,
599611
- children: "Input unavailable · Ctrl+C to exit"
599612
- }),
599613
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
599614
- flexDirection: "column",
599615
- marginY: 1,
599616
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
599617
- borderStyle: "bold",
599618
- borderColor: "blue",
599619
- borderLeft: true,
599620
- borderRight: false,
599621
- borderTop: false,
599622
- borderBottom: false,
599623
- flexDirection: "column",
599624
- paddingLeft: 2,
599625
- paddingRight: 2,
599626
- paddingY: 1,
599627
- marginBottom: 1,
599628
- backgroundColor: theme.panelBackground,
599629
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(MultilineInput, {
599630
- value: inputValue,
599631
- onChange: setInputValue,
599632
- onSubmit: handleSubmit,
599633
- rows: 1,
599634
- maxRows: 10,
599635
- keyBindings: {
599636
- submit: (key_0) => key_0.return && !key_0.ctrl,
599637
- newline: (key_1) => key_1.return && key_1.ctrl
599638
- },
599639
- useCustomInput: (handler, active) => {
599640
- useInput((input_0, key_2) => {
599641
- const match = input_0.match(MOUSE_RE);
599642
- if (match) {
599643
- const button = parseInt(match[1], 10);
599644
- if (button === 64) scrollByClamped(-1);
599645
- else if (button === 65) scrollByClamped(1);
599646
- return;
599647
- }
599648
- if (input_0.includes("[<") && /\d+;\d+;\d+[Mm]/.test(input_0)) return;
599649
- if (key_2.tab && key_2.shift) return;
599650
- handler(input_0, key_2);
599651
- }, { isActive: active && isActive });
599652
- }
599653
- }), !inputValue && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599654
- dimColor: true,
599655
- children: "Message Claw..."
599656
- })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599657
- color: "blue",
599658
- bold: true,
599659
- children: isSending ? "Sending" : "Claw"
599660
- }) })]
599661
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
599662
- justifyContent: "space-between",
599663
- paddingY: 0,
599664
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
599665
- gap: 1,
599666
- children: ctrlCPending ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599667
- color: "yellow",
599668
- children: "Press Ctrl+C again to exit"
599669
- }) : isSending ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599670
- dimColor: true,
599671
- children: "waiting for response..."
599672
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: " " })
599673
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
599674
- gap: 3,
599675
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
599676
- dimColor: true,
599677
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599678
- bold: true,
599679
- children: "ctrl+enter"
599680
- }), " newline"]
599681
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
599682
- dimColor: true,
599683
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
599684
- bold: true,
599685
- children: "enter"
599686
- }), " send"]
599687
- })]
599688
- })]
599689
- })]
600155
+ children: "No messages yet. Send a message to start a conversation with Claw."
599690
600156
  })
599691
- })
600157
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: (() => {
600158
+ const startIndex = Math.max(0, messages.length - 100);
600159
+ const visibleMessages = messages.slice(startIndex);
600160
+ const hiddenCount = startIndex;
600161
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [hiddenCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
600162
+ paddingX: 2,
600163
+ paddingY: 1,
600164
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
600165
+ dimColor: true,
600166
+ children: [
600167
+ "─── ",
600168
+ hiddenCount,
600169
+ " older message",
600170
+ hiddenCount === 1 ? "" : "s",
600171
+ " not shown ───"
600172
+ ]
600173
+ })
600174
+ }), visibleMessages.map(_temp$1)] });
600175
+ })() })
600176
+ })
600177
+ });
600178
+ $[21] = messages;
600179
+ $[22] = t13;
600180
+ } else t13 = $[22];
600181
+ let t14;
600182
+ if ($[23] !== isWaitingForReply) {
600183
+ t14 = isWaitingForReply && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
600184
+ paddingX: 2,
600185
+ paddingY: 0,
600186
+ gap: 1,
600187
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
600188
+ dimColor: true,
600189
+ children: "Claw is thinking"
600190
+ })]
600191
+ });
600192
+ $[23] = isWaitingForReply;
600193
+ $[24] = t14;
600194
+ } else t14 = $[24];
600195
+ let t15;
600196
+ if ($[25] !== error) {
600197
+ t15 = error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
600198
+ paddingX: 2,
600199
+ marginBottom: 1,
600200
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
600201
+ color: "red",
600202
+ children: error
600203
+ })
600204
+ });
600205
+ $[25] = error;
600206
+ $[26] = t15;
600207
+ } else t15 = $[26];
600208
+ let t16;
600209
+ if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
600210
+ t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
600211
+ color: "red",
600212
+ dimColor: true,
600213
+ children: "Input unavailable · Ctrl+C to exit"
600214
+ });
600215
+ $[27] = t16;
600216
+ } else t16 = $[27];
600217
+ let t17;
600218
+ let t18;
600219
+ if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
600220
+ t17 = () => scrollByClamped(-1);
600221
+ t18 = () => scrollByClamped(1);
600222
+ $[28] = t17;
600223
+ $[29] = t18;
600224
+ } else {
600225
+ t17 = $[28];
600226
+ t18 = $[29];
600227
+ }
600228
+ let t19;
600229
+ if ($[30] !== handleSubmit || $[31] !== isActive || $[32] !== isSending) {
600230
+ t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextInput, {
600231
+ placeholder: "Message Claw...",
600232
+ rows: 1,
600233
+ maxRows: 10,
600234
+ onSubmit: handleSubmit,
600235
+ onScrollUp: t17,
600236
+ onScrollDown: t18,
600237
+ isActive,
600238
+ submitDisabled: isSending,
600239
+ disableHistory: true
600240
+ }) });
600241
+ $[30] = handleSubmit;
600242
+ $[31] = isActive;
600243
+ $[32] = isSending;
600244
+ $[33] = t19;
600245
+ } else t19 = $[33];
600246
+ const t20 = isSending ? "Sending" : "Claw";
600247
+ let t21;
600248
+ if ($[34] !== t20) {
600249
+ t21 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
600250
+ color: "blue",
600251
+ bold: true,
600252
+ children: t20
600253
+ }) });
600254
+ $[34] = t20;
600255
+ $[35] = t21;
600256
+ } else t21 = $[35];
600257
+ let t22;
600258
+ if ($[36] !== t19 || $[37] !== t21 || $[38] !== theme.panelBackground) {
600259
+ t22 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
600260
+ borderStyle: "bold",
600261
+ borderColor: "blue",
600262
+ borderLeft: true,
600263
+ borderRight: false,
600264
+ borderTop: false,
600265
+ borderBottom: false,
600266
+ flexDirection: "column",
600267
+ paddingLeft: 2,
600268
+ paddingRight: 2,
600269
+ paddingY: 1,
600270
+ marginBottom: 1,
600271
+ backgroundColor: theme.panelBackground,
600272
+ children: [t19, t21]
600273
+ });
600274
+ $[36] = t19;
600275
+ $[37] = t21;
600276
+ $[38] = theme.panelBackground;
600277
+ $[39] = t22;
600278
+ } else t22 = $[39];
600279
+ let t23;
600280
+ if ($[40] !== ctrlCPending || $[41] !== isSending) {
600281
+ t23 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
600282
+ gap: 1,
600283
+ children: ctrlCPending ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
600284
+ color: "yellow",
600285
+ children: "Press Ctrl+C again to exit"
600286
+ }) : isSending ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
600287
+ dimColor: true,
600288
+ children: "waiting for response..."
600289
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: " " })
600290
+ });
600291
+ $[40] = ctrlCPending;
600292
+ $[41] = isSending;
600293
+ $[42] = t23;
600294
+ } else t23 = $[42];
600295
+ let t24;
600296
+ if ($[43] === Symbol.for("react.memo_cache_sentinel")) {
600297
+ t24 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
600298
+ dimColor: true,
600299
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
600300
+ bold: true,
600301
+ children: "ctrl+enter"
600302
+ }), " newline"]
600303
+ });
600304
+ $[43] = t24;
600305
+ } else t24 = $[43];
600306
+ let t25;
600307
+ if ($[44] === Symbol.for("react.memo_cache_sentinel")) {
600308
+ t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
600309
+ gap: 3,
600310
+ children: [t24, /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
600311
+ dimColor: true,
600312
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
600313
+ bold: true,
600314
+ children: "enter"
600315
+ }), " send"]
600316
+ })]
600317
+ });
600318
+ $[44] = t25;
600319
+ } else t25 = $[44];
600320
+ let t26;
600321
+ if ($[45] !== t23) {
600322
+ t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
600323
+ justifyContent: "space-between",
600324
+ paddingY: 0,
600325
+ children: [t23, t25]
600326
+ });
600327
+ $[45] = t23;
600328
+ $[46] = t26;
600329
+ } else t26 = $[46];
600330
+ let t27;
600331
+ if ($[47] !== t22 || $[48] !== t26) {
600332
+ t27 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBoundary, {
600333
+ fallback: t16,
600334
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
600335
+ flexDirection: "column",
600336
+ marginY: 1,
600337
+ children: [t22, t26]
600338
+ })
600339
+ });
600340
+ $[47] = t22;
600341
+ $[48] = t26;
600342
+ $[49] = t27;
600343
+ } else t27 = $[49];
600344
+ let t28;
600345
+ if ($[50] !== t13 || $[51] !== t14 || $[52] !== t15 || $[53] !== t27) {
600346
+ t28 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
600347
+ flexDirection: "column",
600348
+ flexGrow: 1,
600349
+ paddingRight: 2,
600350
+ children: [
600351
+ t13,
600352
+ t14,
600353
+ t15,
600354
+ t27
599692
600355
  ]
599693
- }), showSidebar && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClawSidebar, {})]
599694
- });
600356
+ });
600357
+ $[50] = t13;
600358
+ $[51] = t14;
600359
+ $[52] = t15;
600360
+ $[53] = t27;
600361
+ $[54] = t28;
600362
+ } else t28 = $[54];
600363
+ let t29;
600364
+ if ($[55] !== showSidebar) {
600365
+ t29 = showSidebar && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClawSidebar, {});
600366
+ $[55] = showSidebar;
600367
+ $[56] = t29;
600368
+ } else t29 = $[56];
600369
+ let t30;
600370
+ if ($[57] !== t28 || $[58] !== t29) {
600371
+ t30 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
600372
+ flexDirection: "row",
600373
+ flexGrow: 1,
600374
+ children: [t28, t29]
600375
+ });
600376
+ $[57] = t28;
600377
+ $[58] = t29;
600378
+ $[59] = t30;
600379
+ } else t30 = $[59];
600380
+ return t30;
599695
600381
  });
600382
+ function _temp$1(msg) {
600383
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBoundary, {
600384
+ fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
600385
+ paddingX: 2,
600386
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
600387
+ color: "red",
600388
+ dimColor: true,
600389
+ children: "[failed to render message]"
600390
+ })
600391
+ }),
600392
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClawMessageView, { message: msg })
600393
+ }, msg.id);
600394
+ }
599696
600395
  //#endregion
599697
600396
  //#region src/components/CodeCommand.tsx
599698
600397
  const TabBar = (0, import_react.memo)((t0) => {
@@ -600081,7 +600780,7 @@ function initSentry() {
600081
600780
  init({
600082
600781
  dsn: "https://1c5033d697e0271ebe53773bff826de0@o117565.ingest.us.sentry.io/4511107776905216",
600083
600782
  tracesSampleRate: 0,
600084
- release: "0.3.5",
600783
+ release: "0.3.8",
600085
600784
  environment: process.env.NODE_ENV ?? "development",
600086
600785
  enabled: false,
600087
600786
  registerEsmLoaderHooks: false,
@@ -600105,7 +600804,7 @@ function isStandaloneBinary() {
600105
600804
  return !path$6.basename(process.execPath, ".exe").startsWith("node");
600106
600805
  }
600107
600806
  function getCurrentVersion() {
600108
- return "0.3.5";
600807
+ return "0.3.8";
600109
600808
  }
600110
600809
  async function fetchLatestVersion() {
600111
600810
  return new Promise((resolve, reject) => {
@@ -600195,28 +600894,59 @@ async function selfUpdate(onProgress) {
600195
600894
  const tarballUrl = `https://registry.npmjs.org/@builder.io/${pkgName}/-/${pkgName}-${latestVersion}.tgz`;
600196
600895
  const tmpDir = createTempDir(path$6.dirname(process.execPath));
600197
600896
  const tarballPath = path$6.join(tmpDir, "builder.tgz");
600897
+ let activeRequest = null;
600898
+ let activeChild = null;
600899
+ const onSigint = () => {
600900
+ activeRequest?.destroy();
600901
+ activeChild?.kill();
600902
+ try {
600903
+ fs$20.rmSync(tmpDir, {
600904
+ recursive: true,
600905
+ force: true
600906
+ });
600907
+ } catch {}
600908
+ onProgress("\nUpdate cancelled.");
600909
+ process.exit(130);
600910
+ };
600911
+ process.on("SIGINT", onSigint);
600198
600912
  try {
600199
- await downloadFile(tarballUrl, tarballPath);
600913
+ await downloadFile(tarballUrl, tarballPath, (req) => {
600914
+ activeRequest = req;
600915
+ });
600916
+ activeRequest = null;
600200
600917
  onProgress("Installing...");
600201
600918
  await new Promise((resolve, reject) => {
600202
- spawn("tar", [
600919
+ const tar = spawn("tar", [
600203
600920
  "-xzf",
600204
600921
  tarballPath,
600205
600922
  "-C",
600206
600923
  tmpDir
600207
- ], { stdio: "inherit" }).on("close", (code) => code === 0 ? resolve() : reject(/* @__PURE__ */ new Error(`tar exited with ${code}`)));
600924
+ ], { stdio: "inherit" });
600925
+ activeChild = tar;
600926
+ tar.on("close", (code) => {
600927
+ activeChild = null;
600928
+ code === 0 ? resolve() : reject(/* @__PURE__ */ new Error(`tar exited with ${code}`));
600929
+ });
600208
600930
  });
600209
600931
  const binaryName = process.platform === "win32" ? "builder.exe" : "builder";
600210
600932
  const extractedBinary = path$6.join(tmpDir, "package", binaryName);
600211
600933
  if (!fs$20.existsSync(extractedBinary)) throw new Error(`Binary not found in tarball at ${extractedBinary}`);
600212
600934
  fs$20.chmodSync(extractedBinary, 493);
600213
600935
  atomicReplace(extractedBinary, process.execPath);
600936
+ const rgName = process.platform === "win32" ? "rg.exe" : "rg";
600937
+ const extractedRg = path$6.join(tmpDir, "package", rgName);
600938
+ if (fs$20.existsSync(extractedRg)) {
600939
+ const destRg = path$6.join(path$6.dirname(process.execPath), rgName);
600940
+ fs$20.chmodSync(extractedRg, 493);
600941
+ atomicReplace(extractedRg, destRg);
600942
+ }
600214
600943
  writeUpdateCheck({
600215
600944
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
600216
600945
  latestVersion
600217
600946
  });
600218
600947
  onProgress(`Updated to ${latestVersion}. Restart builder to apply.`);
600219
600948
  } finally {
600949
+ process.off("SIGINT", onSigint);
600220
600950
  fs$20.rmSync(tmpDir, {
600221
600951
  recursive: true,
600222
600952
  force: true
@@ -600245,11 +600975,11 @@ function atomicReplace(source, dest) {
600245
600975
  } else throw err;
600246
600976
  }
600247
600977
  }
600248
- async function downloadFile(url, dest) {
600978
+ async function downloadFile(url, dest, onRequest) {
600249
600979
  return new Promise((resolve, reject) => {
600250
600980
  const file = fs$20.createWriteStream(dest);
600251
600981
  const request = (targetUrl) => {
600252
- https$4.get(targetUrl, (res) => {
600982
+ const req = https$4.get(targetUrl, (res) => {
600253
600983
  if (res.statusCode === 301 || res.statusCode === 302) {
600254
600984
  const location = res.headers.location;
600255
600985
  if (!location) {
@@ -600259,10 +600989,11 @@ async function downloadFile(url, dest) {
600259
600989
  res.resume();
600260
600990
  file.close();
600261
600991
  const newFile = fs$20.createWriteStream(dest);
600262
- https$4.get(location, (r) => {
600992
+ const redirectReq = https$4.get(location, (r) => {
600263
600993
  r.pipe(newFile);
600264
600994
  newFile.on("finish", () => newFile.close(() => resolve()));
600265
600995
  }).on("error", reject);
600996
+ onRequest?.(redirectReq);
600266
600997
  return;
600267
600998
  }
600268
600999
  if (res.statusCode !== 200) {
@@ -600275,13 +601006,14 @@ async function downloadFile(url, dest) {
600275
601006
  fs$20.unlink(dest, () => {});
600276
601007
  reject(err);
600277
601008
  });
601009
+ onRequest?.(req);
600278
601010
  };
600279
601011
  request(url);
600280
601012
  });
600281
601013
  }
600282
601014
  //#endregion
600283
601015
  //#region src/cli.tsx
600284
- const VERSION = "0.3.5";
601016
+ const VERSION = "0.3.8";
600285
601017
  async function startInk(command, options) {
600286
601018
  await render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
600287
601019
  command,
@@ -600294,8 +601026,9 @@ async function startInk(command, options) {
600294
601026
  }), {
600295
601027
  exitOnCtrlC: false,
600296
601028
  incrementalRendering: true,
600297
- maxFps: 15,
600298
- patchConsole: true
601029
+ maxFps: 30,
601030
+ patchConsole: true,
601031
+ concurrent: true
600299
601032
  }).waitUntilExit();
600300
601033
  await flush(2e3);
600301
601034
  }