@builder.io/buildercode 0.4.1 → 0.4.2

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 +759 -425
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -24577,6 +24577,14 @@ const setTextNodeValue = (node, text) => {
24577
24577
  node.nodeValue = text;
24578
24578
  markNodeAsDirty(node);
24579
24579
  };
24580
+ const addLayoutListener = (rootNode, listener) => {
24581
+ if (rootNode.nodeName !== "ink-root") return () => {};
24582
+ rootNode.internal_layoutListeners ??= /* @__PURE__ */ new Set();
24583
+ rootNode.internal_layoutListeners.add(listener);
24584
+ return () => {
24585
+ rootNode.internal_layoutListeners?.delete(listener);
24586
+ };
24587
+ };
24580
24588
  const emitLayoutListeners = (rootNode) => {
24581
24589
  if (rootNode.nodeName !== "ink-root" || !rootNode.internal_layoutListeners) return;
24582
24590
  for (const listener of rootNode.internal_layoutListeners) listener();
@@ -46020,6 +46028,73 @@ const useWindowSize = () => {
46020
46028
  return size;
46021
46029
  };
46022
46030
  //#endregion
46031
+ //#region ../../node_modules/ink/build/hooks/use-box-metrics.js
46032
+ const emptyMetrics = {
46033
+ width: 0,
46034
+ height: 0,
46035
+ left: 0,
46036
+ top: 0
46037
+ };
46038
+ const findRootNode = (node) => {
46039
+ if (!node) return;
46040
+ if (!node.parentNode) return node.nodeName === "ink-root" ? node : void 0;
46041
+ return findRootNode(node.parentNode);
46042
+ };
46043
+ /**
46044
+ A React hook that returns the current layout metrics for a tracked box element.
46045
+ It updates when layout changes (for example terminal resize, sibling/content changes, or position changes).
46046
+
46047
+ The hook returns `{width: 0, height: 0, left: 0, top: 0}` until the first layout pass completes. It also returns zeros when the tracked ref is detached.
46048
+
46049
+ Use `hasMeasured` to detect when the currently tracked element has been measured.
46050
+
46051
+ @example
46052
+ ```tsx
46053
+ import {useRef} from 'react';
46054
+ import {Box, Text, useBoxMetrics} from 'ink';
46055
+
46056
+ const Example = () => {
46057
+ const ref = useRef(null);
46058
+ const {width, height, left, top, hasMeasured} = useBoxMetrics(ref);
46059
+ return (
46060
+ <Box ref={ref}>
46061
+ <Text>
46062
+ {hasMeasured ? `${width}x${height} at ${left},${top}` : 'Measuring...'}
46063
+ </Text>
46064
+ </Box>
46065
+ );
46066
+ };
46067
+ ```
46068
+ */
46069
+ const useBoxMetrics = (ref) => {
46070
+ const [metrics, setMetrics] = (0, import_react.useState)(emptyMetrics);
46071
+ const [hasMeasured, setHasMeasured] = (0, import_react.useState)(false);
46072
+ const { stdout } = useStdout();
46073
+ const updateMetrics = (0, import_react.useCallback)(() => {
46074
+ const layout = ref.current?.yogaNode?.getComputedLayout() ?? emptyMetrics;
46075
+ setMetrics((previousMetrics) => {
46076
+ return previousMetrics.width !== layout.width || previousMetrics.height !== layout.height || previousMetrics.left !== layout.left || previousMetrics.top !== layout.top ? layout : previousMetrics;
46077
+ });
46078
+ setHasMeasured(Boolean(ref.current));
46079
+ }, [ref]);
46080
+ (0, import_react.useEffect)(updateMetrics);
46081
+ (0, import_react.useEffect)(() => {
46082
+ const rootNode = findRootNode(ref.current);
46083
+ if (!rootNode) return;
46084
+ return addLayoutListener(rootNode, updateMetrics);
46085
+ });
46086
+ (0, import_react.useEffect)(() => {
46087
+ stdout.on("resize", updateMetrics);
46088
+ return () => {
46089
+ stdout.off("resize", updateMetrics);
46090
+ };
46091
+ }, [stdout, updateMetrics]);
46092
+ return (0, import_react.useMemo)(() => ({
46093
+ ...metrics,
46094
+ hasMeasured
46095
+ }), [metrics, hasMeasured]);
46096
+ };
46097
+ //#endregion
46023
46098
  //#region ../../node_modules/ink/build/measure-element.js
46024
46099
  /**
46025
46100
  Measure the dimensions of a particular `<Box>` element.
@@ -245033,7 +245108,7 @@ const LIB_CACHE = /* @__PURE__ */ new Map();
245033
245108
  const PENDING_LIB_CACHE = /* @__PURE__ */ new Map();
245034
245109
  const NODE_MODULE_CACHE = /* @__PURE__ */ new Map();
245035
245110
  const TSCONFIG_CACHE = /* @__PURE__ */ new Map();
245036
- const pkgVersion = process.env.OVERRIDE_VERSION ?? "0.4.1";
245111
+ const pkgVersion = process.env.OVERRIDE_VERSION ?? "0.4.2";
245037
245112
  //#endregion
245038
245113
  //#region ../dev-tools/core/detect-frameworks.ts
245039
245114
  async function detectFrameworks$1(sys) {
@@ -290975,7 +291050,7 @@ function wc$1({ parent: e }) {
290975
291050
  default: return !1;
290976
291051
  }
290977
291052
  }
290978
- function _c$25({ parent: e, grandparent: t }) {
291053
+ function _c$26({ parent: e, grandparent: t }) {
290979
291054
  return t?.type === "JSXAttribute" && e.type === "JSXExpressionContainer" && t.name.type === "JSXIdentifier" && t.name.name === "css";
290980
291055
  }
290981
291056
  async function co(e, t, r) {
@@ -295991,7 +296066,7 @@ var init_estree = __esmMin((() => {
295991
296066
  (e, t) => e.type === "CallExpression" && e.callee.type === "Identifier" && e.callee.name === "Component" && t === "arguments",
295992
296067
  (e, t) => e.type === "Decorator" && t === "expression"
295993
296068
  ];
295994
- po$1 = (e) => Oc$1(e) || wc$1(e) || _c$25(e) || oo$2(e);
296069
+ po$1 = (e) => Oc$1(e) || wc$1(e) || _c$26(e) || oo$2(e);
295995
296070
  Es$6 = 0;
295996
296071
  fo = mo.bind(void 0, "html"), yo = mo.bind(void 0, "angular");
295997
296072
  jc = [
@@ -400168,7 +400243,7 @@ function xc(t, e, s = {}) {
400168
400243
  let r = It(t, s.backwards ? e - 1 : e, s);
400169
400244
  return r !== Gt(t, r, s);
400170
400245
  }
400171
- function _c$24(t, e) {
400246
+ function _c$25(t, e) {
400172
400247
  if (e === !1) return !1;
400173
400248
  if (t.charAt(e) === "/" && t.charAt(e + 1) === "*") {
400174
400249
  for (let s = e + 2; s < t.length; ++s) if (t.charAt(s) === "*" && t.charAt(s + 1) === "/") return s + 2;
@@ -405993,7 +406068,7 @@ https://evilmartians.com/chronicles/postcss-8-plugin-migration`));
405993
406068
  ` || t === "\r" || t === "\u2028" || t === "\u2029";
405994
406069
  Gt = vc;
405995
406070
  Yt = xc;
405996
- xi$1 = _c$24;
406071
+ xi$1 = _c$25;
405997
406072
  _i = bc;
405998
406073
  Vt$1 = Ec;
405999
406074
  De = Oc;
@@ -531515,6 +531590,7 @@ async function getAgent(url) {
531515
531590
  }
531516
531591
  return _agent || new import_undici.Agent({ connect: { rejectUnauthorized } });
531517
531592
  }
531593
+ let lastGetSetCookie = void 0;
531518
531594
  const safeFetch = async (input, init, debug) => {
531519
531595
  const urlObj = new URL(input);
531520
531596
  const hostname = urlObj.hostname;
@@ -531532,9 +531608,11 @@ const safeFetch = async (input, init, debug) => {
531532
531608
  headers: {
531533
531609
  ...init?.headers,
531534
531610
  ...getUserAgent(),
531535
- ...traceData
531611
+ ...traceData,
531612
+ ...lastGetSetCookie ? { Cookie: lastGetSetCookie.join("; ") } : {}
531536
531613
  }
531537
531614
  });
531615
+ lastGetSetCookie = response.headers.getSetCookie();
531538
531616
  outcome = `status: ${response.status}`;
531539
531617
  if (!response.ok) {
531540
531618
  if (response.status === 402) {
@@ -534467,6 +534545,80 @@ function getNextLineIndex(text, cursor) {
534467
534545
  for (let i = 0; i <= lineIdx; i++) newIdx += lines[i].length + 1;
534468
534546
  return newIdx + Math.min(col, targetLine.length);
534469
534547
  }
534548
+ /**
534549
+ * Split `text` into visual lines of at most `width` characters each,
534550
+ * returning the character-index range [start, end) for each visual row.
534551
+ * Hard newlines (\n) always create a new visual line.
534552
+ */
534553
+ function getVisualLines(text, width) {
534554
+ if (width <= 0) return [{
534555
+ start: 0,
534556
+ end: text.length
534557
+ }];
534558
+ const result = [];
534559
+ const logicalLines = text.split("\n");
534560
+ let pos = 0;
534561
+ for (let li = 0; li < logicalLines.length; li++) {
534562
+ const line = logicalLines[li];
534563
+ const isLast = li === logicalLines.length - 1;
534564
+ if (line.length === 0) result.push({
534565
+ start: pos,
534566
+ end: pos
534567
+ });
534568
+ else for (let col = 0; col < line.length; col += width) {
534569
+ const segEnd = Math.min(col + width, line.length);
534570
+ result.push({
534571
+ start: pos + col,
534572
+ end: pos + segEnd
534573
+ });
534574
+ }
534575
+ pos += line.length + (isLast ? 0 : 1);
534576
+ }
534577
+ return result;
534578
+ }
534579
+ /**
534580
+ * Find which visual line the cursor is on, searching from the end.
534581
+ *
534582
+ * Searching in reverse means that when a cursor position falls on a
534583
+ * soft-wrap boundary (where segment_i.end === segment_{i+1}.start),
534584
+ * the LATER segment wins — which is visually correct: the cursor at
534585
+ * the first column of a wrapped row belongs to that row, not the one
534586
+ * above. For hard-newline gaps there is no overlap, so the unique
534587
+ * containing segment is always found.
534588
+ */
534589
+ function findVisualLineIndex(lines, cursor) {
534590
+ for (let i = lines.length - 1; i >= 0; i--) {
534591
+ const vl = lines[i];
534592
+ if (cursor >= vl.start && cursor <= vl.end) return i;
534593
+ }
534594
+ return 0;
534595
+ }
534596
+ function isOnFirstVisualLine(text, cursor, width) {
534597
+ const lines = getVisualLines(text, width);
534598
+ if (lines.length <= 1) return true;
534599
+ return findVisualLineIndex(lines, cursor) === 0;
534600
+ }
534601
+ function isOnLastVisualLine(text, cursor, width) {
534602
+ const lines = getVisualLines(text, width);
534603
+ if (!lines.length) return true;
534604
+ return findVisualLineIndex(lines, cursor) === lines.length - 1;
534605
+ }
534606
+ function getPrevVisualLineIndex(text, cursor, width) {
534607
+ const lines = getVisualLines(text, width);
534608
+ const idx = findVisualLineIndex(lines, cursor);
534609
+ if (idx <= 0) return cursor;
534610
+ const col = cursor - lines[idx].start;
534611
+ const prev = lines[idx - 1];
534612
+ return prev.start + Math.min(col, prev.end - prev.start);
534613
+ }
534614
+ function getNextVisualLineIndex(text, cursor, width) {
534615
+ const lines = getVisualLines(text, width);
534616
+ const idx = findVisualLineIndex(lines, cursor);
534617
+ if (idx >= lines.length - 1) return cursor;
534618
+ const col = cursor - lines[idx].start;
534619
+ const next = lines[idx + 1];
534620
+ return next.start + Math.min(col, next.end - next.start);
534621
+ }
534470
534622
  const inputHistory = {
534471
534623
  history: [],
534472
534624
  historyIndex: -1,
@@ -534482,7 +534634,7 @@ function useInputHistory() {
534482
534634
  let t0;
534483
534635
  if ($[0] !== forceUpdate) {
534484
534636
  t0 = () => {
534485
- const listener = () => forceUpdate(_temp$8);
534637
+ const listener = () => forceUpdate(_temp$9);
534486
534638
  inputHistory.listeners.add(listener);
534487
534639
  return () => {
534488
534640
  inputHistory.listeners.delete(listener);
@@ -534504,7 +534656,7 @@ function useInputHistory() {
534504
534656
  * characters — either case benefits from a compact inline placeholder rather
534505
534657
  * than flooding the input with raw content.
534506
534658
  */
534507
- function _temp$8(n) {
534659
+ function _temp$9(n) {
534508
534660
  return n + 1;
534509
534661
  }
534510
534662
  function isBigPaste(text) {
@@ -534514,24 +534666,16 @@ function makePasteToken(id, lineCount) {
534514
534666
  return `[Pasted text #${id} +${lineCount} line${lineCount === 1 ? "" : "s"}]`;
534515
534667
  }
534516
534668
  function useTextInput(options = {}) {
534517
- const { onSubmit, onChange, onTab, onShiftTab, onPaste, onBackspaceEmpty, isActive = true, getIsMenuActive, submitDisabled = false, disableHistory = false, initialValue = "" } = options;
534669
+ const { onSubmit, onChange, onTab, onShiftTab, onPaste, onBackspaceEmpty, isActive = true, getIsMenuActive, submitDisabled = false, disableHistory = false, initialValue = "", inputWidth = 0 } = options;
534518
534670
  const [value, setValueState] = (0, import_react.useState)(initialValue);
534519
534671
  const [cursorIndex, setCursorIndex] = (0, import_react.useState)(initialValue.length);
534520
534672
  useInputHistory();
534521
- const fnDeleteRef = (0, import_react.useRef)(false);
534522
- (0, import_react.useEffect)(() => {
534523
- const onData = (data) => {
534524
- if (data.toString("utf8").includes("\x1B[3~")) fnDeleteRef.current = true;
534525
- };
534526
- process.stdin.on("data", onData);
534527
- return () => {
534528
- process.stdin.off("data", onData);
534529
- };
534530
- }, []);
534531
534673
  const valueRef = (0, import_react.useRef)(value);
534532
534674
  const cursorRef = (0, import_react.useRef)(cursorIndex);
534675
+ const inputWidthRef = (0, import_react.useRef)(inputWidth);
534533
534676
  valueRef.current = value;
534534
534677
  cursorRef.current = cursorIndex;
534678
+ inputWidthRef.current = inputWidth;
534535
534679
  const pasteMapRef = (0, import_react.useRef)(/* @__PURE__ */ new Map());
534536
534680
  const pasteCounterRef = (0, import_react.useRef)(0);
534537
534681
  const resolvePaste = (0, import_react.useCallback)((val) => {
@@ -534579,6 +534723,7 @@ function useTextInput(options = {}) {
534579
534723
  onChange?.("");
534580
534724
  }, [onChange]);
534581
534725
  useInput((input, key) => {
534726
+ input = input.replaceAll("\\\r", "\n");
534582
534727
  const val_3 = valueRef.current;
534583
534728
  const cursor_1 = cursorRef.current;
534584
534729
  const { active: isMenuActive, captureSpace } = getIsMenuActive?.() ?? {
@@ -534609,9 +534754,12 @@ function useTextInput(options = {}) {
534609
534754
  return;
534610
534755
  }
534611
534756
  if (key.return && (key.ctrl || key.shift || key.meta)) {
534612
- const next_1 = val_3.slice(0, cursor_1) + "\n" + val_3.slice(cursor_1);
534757
+ const hasStrayBackslash = cursor_1 > 0 && val_3[cursor_1 - 1] === "\\";
534758
+ const baseVal = hasStrayBackslash ? val_3.slice(0, cursor_1 - 1) + val_3.slice(cursor_1) : val_3;
534759
+ const baseCursor = hasStrayBackslash ? cursor_1 - 1 : cursor_1;
534760
+ const next_1 = baseVal.slice(0, baseCursor) + "\n" + baseVal.slice(baseCursor);
534613
534761
  setValueState(next_1);
534614
- setCursorIndex(cursor_1 + 1);
534762
+ setCursorIndex(baseCursor + 1);
534615
534763
  onChange?.(next_1);
534616
534764
  return;
534617
534765
  }
@@ -534667,11 +534815,12 @@ function useTextInput(options = {}) {
534667
534815
  return;
534668
534816
  }
534669
534817
  if (key.upArrow) {
534670
- if (!isOnFirstLine(val_3, cursor_1)) {
534671
- setCursorIndex(getPrevLineIndex(val_3, cursor_1));
534818
+ const iw = inputWidthRef.current;
534819
+ if (!(iw > 0 ? isOnFirstVisualLine(val_3, cursor_1, iw) : isOnFirstLine(val_3, cursor_1))) {
534820
+ setCursorIndex(iw > 0 ? getPrevVisualLineIndex(val_3, cursor_1, iw) : getPrevLineIndex(val_3, cursor_1));
534672
534821
  return;
534673
534822
  }
534674
- if (!disableHistory) {
534823
+ if (!disableHistory && !val_3.includes("\n")) {
534675
534824
  const { history: h, historyIndex: hi } = inputHistory;
534676
534825
  const nextIndex = hi + 1;
534677
534826
  if (nextIndex < h.length) {
@@ -534688,11 +534837,12 @@ function useTextInput(options = {}) {
534688
534837
  return;
534689
534838
  }
534690
534839
  if (key.downArrow) {
534691
- if (!isOnLastLine(val_3, cursor_1)) {
534692
- setCursorIndex(getNextLineIndex(val_3, cursor_1));
534840
+ const iw_0 = inputWidthRef.current;
534841
+ if (!(iw_0 > 0 ? isOnLastVisualLine(val_3, cursor_1, iw_0) : isOnLastLine(val_3, cursor_1))) {
534842
+ setCursorIndex(iw_0 > 0 ? getNextVisualLineIndex(val_3, cursor_1, iw_0) : getNextLineIndex(val_3, cursor_1));
534693
534843
  return;
534694
534844
  }
534695
- if (!disableHistory) {
534845
+ if (!disableHistory && !val_3.includes("\n")) {
534696
534846
  const { history: h_0, historyIndex: hi_0, historyDraft: hd } = inputHistory;
534697
534847
  if (hi_0 > 0) {
534698
534848
  const nextIndex_0 = hi_0 - 1;
@@ -534722,16 +534872,14 @@ function useTextInput(options = {}) {
534722
534872
  setCursorIndex(Math.min(val_3.length, cursor_1 + 1));
534723
534873
  return;
534724
534874
  }
534725
- if (key.delete || key.backspace) {
534726
- const isFnDelete = fnDeleteRef.current;
534727
- fnDeleteRef.current = false;
534728
- if (isFnDelete) {
534729
- if (cursor_1 < val_3.length) {
534730
- const next_5 = val_3.slice(0, cursor_1) + val_3.slice(cursor_1 + 1);
534731
- setValueState(next_5);
534732
- onChange?.(next_5);
534733
- }
534734
- } else if (cursor_1 > 0) {
534875
+ if (key.delete && cursor_1 < val_3.length) {
534876
+ const next_5 = val_3.slice(0, cursor_1) + val_3.slice(cursor_1 + 1);
534877
+ setValueState(next_5);
534878
+ onChange?.(next_5);
534879
+ return;
534880
+ }
534881
+ if (key.backspace) {
534882
+ if (cursor_1 > 0) {
534735
534883
  const next_6 = val_3.slice(0, cursor_1 - 1) + val_3.slice(cursor_1);
534736
534884
  setValueState(next_6);
534737
534885
  setCursorIndex(cursor_1 - 1);
@@ -534739,7 +534887,8 @@ function useTextInput(options = {}) {
534739
534887
  } else if (val_3.length === 0) onBackspaceEmpty?.();
534740
534888
  return;
534741
534889
  }
534742
- if (input.length === 1 && input.charCodeAt(0) < 32) return;
534890
+ const code = input.charCodeAt(0);
534891
+ if (input.length === 1 && code < 32 && code !== 10) return;
534743
534892
  if (input) {
534744
534893
  if (inputHistory.historyIndex !== -1) {
534745
534894
  inputHistory.historyIndex = -1;
@@ -536248,7 +536397,8 @@ function useCodeGenStateHandler() {
536248
536397
  id: `thinking-${_msgIdCounter++}`,
536249
536398
  type: "thinking",
536250
536399
  content: step.content ?? "",
536251
- streaming: true
536400
+ streaming: true,
536401
+ startedAt: Date.now()
536252
536402
  });
536253
536403
  break;
536254
536404
  case "delta": {
@@ -536695,7 +536845,7 @@ function SlashCommandMenu(t0) {
536695
536845
  const contextPct = t2;
536696
536846
  let t3;
536697
536847
  if ($[3] !== state.customInstructions) {
536698
- t3 = (state.customInstructions ?? []).filter(_temp$7).map(_temp2$4);
536848
+ t3 = (state.customInstructions ?? []).filter(_temp$8).map(_temp2$5);
536699
536849
  $[3] = state.customInstructions;
536700
536850
  $[4] = t3;
536701
536851
  } else t3 = $[4];
@@ -537155,14 +537305,14 @@ function _temp4$1(cmd_1) {
537155
537305
  function _temp3$4(c) {
537156
537306
  return c.label.length;
537157
537307
  }
537158
- function _temp2$4(i_0) {
537308
+ function _temp2$5(i_0) {
537159
537309
  return {
537160
537310
  id: i_0.name,
537161
537311
  label: `/${i_0.name}`,
537162
537312
  description: i_0.description
537163
537313
  };
537164
537314
  }
537165
- function _temp$7(i) {
537315
+ function _temp$8(i) {
537166
537316
  return i.isSkill && i.userInvocable !== false && !BUILTIN_COMMAND_IDS.has(i.name);
537167
537317
  }
537168
537318
  //#endregion
@@ -537520,6 +537670,8 @@ const InputPrompt = (0, import_react.memo)(({ onSubmit, onChange, onSlashCommand
537520
537670
  setDismissedSlashValue(null);
537521
537671
  onChange?.("");
537522
537672
  }, [onChange, onSubmit]);
537673
+ const inputBoxRef = (0, import_react.useRef)(null);
537674
+ const { width: inputWidth } = useBoxMetrics(inputBoxRef);
537523
537675
  const pasteHandlerRef = (0, import_react.useRef)(() => {});
537524
537676
  const { value, cursorIndex, setValue, clear } = useTextInput({
537525
537677
  onSubmit: handleSubmitFromHook,
@@ -537530,6 +537682,7 @@ const InputPrompt = (0, import_react.memo)(({ onSubmit, onChange, onSlashCommand
537530
537682
  getIsMenuActive,
537531
537683
  submitDisabled: false,
537532
537684
  initialValue,
537685
+ inputWidth,
537533
537686
  onPaste: () => void Promise.resolve(pasteHandlerRef.current()).catch(() => {}),
537534
537687
  onBackspaceEmpty: pendingAttachments.length > 0 && onRemoveAttachment ? () => {
537535
537688
  const last = pendingAttachments[pendingAttachments.length - 1];
@@ -537640,7 +537793,8 @@ const InputPrompt = (0, import_react.memo)(({ onSubmit, onChange, onSlashCommand
537640
537793
  children: "queued:"
537641
537794
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
537642
537795
  color: "yellow",
537643
- children: msg.displayPrompt.length > 60 ? msg.displayPrompt.slice(0, 57) + "..." : msg.displayPrompt
537796
+ wrap: "truncate-end",
537797
+ children: msg.displayPrompt
537644
537798
  })]
537645
537799
  }, msg.idempotencyKey || i);
537646
537800
  })
@@ -537700,14 +537854,17 @@ const InputPrompt = (0, import_react.memo)(({ onSubmit, onChange, onSlashCommand
537700
537854
  children: "(backspace on empty input to remove)"
537701
537855
  })]
537702
537856
  }),
537703
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControlledTextInput, {
537704
- value,
537705
- cursorIndex,
537706
- rows: 1,
537707
- placeholder: hint,
537708
- showCursor: true,
537709
- maxRows: 10
537710
- }) }),
537857
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
537858
+ ref: inputBoxRef,
537859
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControlledTextInput, {
537860
+ value,
537861
+ cursorIndex,
537862
+ rows: 1,
537863
+ placeholder: hint,
537864
+ showCursor: true,
537865
+ maxRows: 10
537866
+ })
537867
+ }),
537711
537868
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
537712
537869
  columnGap: 1,
537713
537870
  flexWrap: "wrap",
@@ -537776,7 +537933,7 @@ function RewindMode(t0) {
537776
537933
  if ($[0] !== onCancel || $[1] !== onSelect || $[2] !== selectedIndex || $[3] !== turns) {
537777
537934
  t1 = (input, key) => {
537778
537935
  if (key.upArrow) {
537779
- setSelectedIndex(_temp$6);
537936
+ setSelectedIndex(_temp$7);
537780
537937
  return;
537781
537938
  }
537782
537939
  if (key.downArrow) {
@@ -537910,7 +538067,7 @@ function RewindMode(t0) {
537910
538067
  } else t7 = $[16];
537911
538068
  return t7;
537912
538069
  }
537913
- function _temp$6(i) {
538070
+ function _temp$7(i) {
537914
538071
  return Math.max(0, i - 1);
537915
538072
  }
537916
538073
  //#endregion
@@ -540157,8 +540314,8 @@ function useToast() {
540157
540314
  //#endregion
540158
540315
  //#region src/components/StatusBar.tsx
540159
540316
  const StatusBar = (0, import_react.memo)((t0) => {
540160
- const $ = (0, import_compiler_runtime.c)(31);
540161
- const { ctrlCPending, showSidebar } = t0;
540317
+ const $ = (0, import_compiler_runtime.c)(39);
540318
+ const { ctrlCPending, showSidebar, updateCheck } = t0;
540162
540319
  const [state] = useCodeGenState();
540163
540320
  const toast = useToast();
540164
540321
  if (ctrlCPending) {
@@ -540192,22 +540349,82 @@ const StatusBar = (0, import_react.memo)((t0) => {
540192
540349
  } else t2 = $[3];
540193
540350
  return t2;
540194
540351
  }
540352
+ if (updateCheck?.status === "upgrade") {
540353
+ let t1;
540354
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
540355
+ t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
540356
+ color: "yellow",
540357
+ children: "⬆"
540358
+ });
540359
+ $[4] = t1;
540360
+ } else t1 = $[4];
540361
+ let t2;
540362
+ if ($[5] !== updateCheck.currentVersion || $[6] !== updateCheck.newVersion) {
540363
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
540364
+ color: "yellow",
540365
+ children: [
540366
+ "Update available: ",
540367
+ updateCheck.currentVersion,
540368
+ " →",
540369
+ " ",
540370
+ updateCheck.newVersion
540371
+ ]
540372
+ });
540373
+ $[5] = updateCheck.currentVersion;
540374
+ $[6] = updateCheck.newVersion;
540375
+ $[7] = t2;
540376
+ } else t2 = $[7];
540377
+ let t3;
540378
+ let t4;
540379
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
540380
+ t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
540381
+ dimColor: true,
540382
+ children: "· run"
540383
+ });
540384
+ t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
540385
+ bold: true,
540386
+ color: "yellow",
540387
+ children: "builder update"
540388
+ });
540389
+ $[8] = t3;
540390
+ $[9] = t4;
540391
+ } else {
540392
+ t3 = $[8];
540393
+ t4 = $[9];
540394
+ }
540395
+ let t5;
540396
+ if ($[10] !== t2) {
540397
+ t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
540398
+ paddingY: 0,
540399
+ gap: 1,
540400
+ children: [
540401
+ t1,
540402
+ t2,
540403
+ t3,
540404
+ t4
540405
+ ]
540406
+ });
540407
+ $[10] = t2;
540408
+ $[11] = t5;
540409
+ } else t5 = $[11];
540410
+ return t5;
540411
+ }
540195
540412
  const ctx = state.contextWindow;
540196
540413
  const showContext = !showSidebar && ctx != null;
540197
540414
  let t1;
540198
- if ($[4] !== ctx || $[5] !== showContext) {
540415
+ if ($[12] !== ctx || $[13] !== showContext) {
540199
540416
  t1 = showContext ? Math.round(Math.min(ctx.usage, 1) * 100) : 0;
540200
- $[4] = ctx;
540201
- $[5] = showContext;
540202
- $[6] = t1;
540203
- } else t1 = $[6];
540417
+ $[12] = ctx;
540418
+ $[13] = showContext;
540419
+ $[14] = t1;
540420
+ } else t1 = $[14];
540204
540421
  const pct = t1;
540205
540422
  const tokens = showContext ? ctx.usedTokens : 0;
540206
- const fmtTokens = _temp$5;
540423
+ const fmtTokens = _temp$6;
540207
540424
  const ctxColor = pct > 80 ? "red" : pct > 50 ? "yellow" : "green";
540208
540425
  if (ctx != null && pct >= 75 && !state.activeUserQuestions) {
540209
540426
  let t2;
540210
- if ($[7] !== ctxColor || $[8] !== pct || $[9] !== showContext || $[10] !== tokens) {
540427
+ if ($[15] !== ctxColor || $[16] !== pct || $[17] !== showContext || $[18] !== tokens) {
540211
540428
  t2 = showContext && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
540212
540429
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
540213
540430
  color: ctxColor,
@@ -540220,24 +540437,24 @@ const StatusBar = (0, import_react.memo)((t0) => {
540220
540437
  }),
540221
540438
  ") · "
540222
540439
  ] });
540223
- $[7] = ctxColor;
540224
- $[8] = pct;
540225
- $[9] = showContext;
540226
- $[10] = tokens;
540227
- $[11] = t2;
540228
- } else t2 = $[11];
540440
+ $[15] = ctxColor;
540441
+ $[16] = pct;
540442
+ $[17] = showContext;
540443
+ $[18] = tokens;
540444
+ $[19] = t2;
540445
+ } else t2 = $[19];
540229
540446
  let t3;
540230
- if ($[12] !== ctxColor) {
540447
+ if ($[20] !== ctxColor) {
540231
540448
  t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
540232
540449
  bold: true,
540233
540450
  color: ctxColor,
540234
540451
  children: "/compact"
540235
540452
  });
540236
- $[12] = ctxColor;
540237
- $[13] = t3;
540238
- } else t3 = $[13];
540453
+ $[20] = ctxColor;
540454
+ $[21] = t3;
540455
+ } else t3 = $[21];
540239
540456
  let t4;
540240
- if ($[14] !== ctxColor || $[15] !== t2 || $[16] !== t3) {
540457
+ if ($[22] !== ctxColor || $[23] !== t2 || $[24] !== t3) {
540241
540458
  t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
540242
540459
  color: ctxColor,
540243
540460
  dimColor: true,
@@ -540250,13 +540467,13 @@ const StatusBar = (0, import_react.memo)((t0) => {
540250
540467
  "to summarize the conversation before hitting the limit"
540251
540468
  ]
540252
540469
  });
540253
- $[14] = ctxColor;
540254
- $[15] = t2;
540255
- $[16] = t3;
540256
- $[17] = t4;
540257
- } else t4 = $[17];
540470
+ $[22] = ctxColor;
540471
+ $[23] = t2;
540472
+ $[24] = t3;
540473
+ $[25] = t4;
540474
+ } else t4 = $[25];
540258
540475
  let t5;
540259
- if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
540476
+ if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
540260
540477
  t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
540261
540478
  gap: 3,
540262
540479
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
@@ -540267,22 +540484,22 @@ const StatusBar = (0, import_react.memo)((t0) => {
540267
540484
  }), " mode"]
540268
540485
  })
540269
540486
  });
540270
- $[18] = t5;
540271
- } else t5 = $[18];
540487
+ $[26] = t5;
540488
+ } else t5 = $[26];
540272
540489
  let t6;
540273
- if ($[19] !== t4) {
540490
+ if ($[27] !== t4) {
540274
540491
  t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
540275
540492
  justifyContent: "space-between",
540276
540493
  paddingY: 0,
540277
540494
  children: [t4, t5]
540278
540495
  });
540279
- $[19] = t4;
540280
- $[20] = t6;
540281
- } else t6 = $[20];
540496
+ $[27] = t4;
540497
+ $[28] = t6;
540498
+ } else t6 = $[28];
540282
540499
  return t6;
540283
540500
  }
540284
540501
  let t2;
540285
- if ($[21] !== ctxColor || $[22] !== pct || $[23] !== showContext || $[24] !== tokens) {
540502
+ if ($[29] !== ctxColor || $[30] !== pct || $[31] !== showContext || $[32] !== tokens) {
540286
540503
  t2 = showContext ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
540287
540504
  dimColor: true,
540288
540505
  children: [
@@ -540298,14 +540515,14 @@ const StatusBar = (0, import_react.memo)((t0) => {
540298
540515
  ")"
540299
540516
  ]
540300
540517
  }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spacer, {});
540301
- $[21] = ctxColor;
540302
- $[22] = pct;
540303
- $[23] = showContext;
540304
- $[24] = tokens;
540305
- $[25] = t2;
540306
- } else t2 = $[25];
540518
+ $[29] = ctxColor;
540519
+ $[30] = pct;
540520
+ $[31] = showContext;
540521
+ $[32] = tokens;
540522
+ $[33] = t2;
540523
+ } else t2 = $[33];
540307
540524
  let t3;
540308
- if ($[26] !== state.activeUserQuestions) {
540525
+ if ($[34] !== state.activeUserQuestions) {
540309
540526
  t3 = state.activeUserQuestions ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
540310
540527
  gap: 3,
540311
540528
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
@@ -540342,23 +540559,23 @@ const StatusBar = (0, import_react.memo)((t0) => {
540342
540559
  }), " mode"]
540343
540560
  })
540344
540561
  });
540345
- $[26] = state.activeUserQuestions;
540346
- $[27] = t3;
540347
- } else t3 = $[27];
540562
+ $[34] = state.activeUserQuestions;
540563
+ $[35] = t3;
540564
+ } else t3 = $[35];
540348
540565
  let t4;
540349
- if ($[28] !== t2 || $[29] !== t3) {
540566
+ if ($[36] !== t2 || $[37] !== t3) {
540350
540567
  t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
540351
540568
  justifyContent: "space-between",
540352
540569
  paddingY: 0,
540353
540570
  children: [t2, t3]
540354
540571
  });
540355
- $[28] = t2;
540356
- $[29] = t3;
540357
- $[30] = t4;
540358
- } else t4 = $[30];
540572
+ $[36] = t2;
540573
+ $[37] = t3;
540574
+ $[38] = t4;
540575
+ } else t4 = $[38];
540359
540576
  return t4;
540360
540577
  });
540361
- function _temp$5(n) {
540578
+ function _temp$6(n) {
540362
540579
  return n >= 1e6 ? `${(n / 1e6).toFixed(1)}M` : n >= 1e3 ? `${(n / 1e3).toFixed(0)}k` : String(n);
540363
540580
  }
540364
540581
  //#endregion
@@ -540401,8 +540618,8 @@ const GeneratingProgress = (0, import_react.memo)(() => {
540401
540618
  const theme = useTheme();
540402
540619
  const isGenerating = state.state === "generating";
540403
540620
  const todos = state.todoItems ?? [];
540404
- const completed = todos.filter(_temp$4);
540405
- const inProgress = todos.find(_temp2$3);
540621
+ const completed = todos.filter(_temp$5);
540622
+ const inProgress = todos.find(_temp2$4);
540406
540623
  const pending = todos.filter(_temp3$3);
540407
540624
  const lastCompleted = completed[completed.length - 1];
540408
540625
  const openCount = pending.length + (inProgress ? 1 : 0);
@@ -540439,7 +540656,6 @@ const GeneratingProgress = (0, import_react.memo)(() => {
540439
540656
  if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
540440
540657
  t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
540441
540658
  gap: 1,
540442
- marginBottom: 1,
540443
540659
  children: [t0, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
540444
540660
  flexShrink: 0,
540445
540661
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
@@ -540456,10 +540672,12 @@ const GeneratingProgress = (0, import_react.memo)(() => {
540456
540672
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
540457
540673
  flexDirection: "column",
540458
540674
  marginTop: 2,
540675
+ marginBottom: 1,
540459
540676
  children: [
540460
540677
  t1,
540461
540678
  inProgress && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
540462
540679
  gap: 1,
540680
+ marginTop: 1,
540463
540681
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
540464
540682
  flexShrink: 0,
540465
540683
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
@@ -540648,10 +540866,10 @@ const ProgressBar = (0, import_react.memo)(() => {
540648
540866
  } else t2 = $[4];
540649
540867
  return t2;
540650
540868
  });
540651
- function _temp$4(t) {
540869
+ function _temp$5(t) {
540652
540870
  return t.status === "completed";
540653
540871
  }
540654
- function _temp2$3(t_0) {
540872
+ function _temp2$4(t_0) {
540655
540873
  return t_0.status === "in_progress";
540656
540874
  }
540657
540875
  function _temp3$3(t_1) {
@@ -541505,7 +541723,7 @@ const TipsSection = (0, import_react.memo)(() => {
541505
541723
  bb0: {
541506
541724
  let t1;
541507
541725
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
541508
- t1 = TIPS.filter(_temp$3);
541726
+ t1 = TIPS.filter(_temp$4);
541509
541727
  $[0] = t1;
541510
541728
  } else t1 = $[0];
541511
541729
  const availableTips = t1;
@@ -541656,7 +541874,7 @@ const TodoSection = (0, import_react.memo)(() => {
541656
541874
  if (!state.todoItems?.length) return null;
541657
541875
  let t0;
541658
541876
  if ($[0] !== state.todoItems) {
541659
- t0 = state.todoItems.filter(_temp2$2);
541877
+ t0 = state.todoItems.filter(_temp2$3);
541660
541878
  $[0] = state.todoItems;
541661
541879
  $[1] = t0;
541662
541880
  } else t0 = $[1];
@@ -541774,7 +541992,7 @@ const FooterSection = (0, import_react.memo)(() => {
541774
541992
  children: [
541775
541993
  "•",
541776
541994
  " Fusion ",
541777
- "0.4.1"
541995
+ "0.4.2"
541778
541996
  ]
541779
541997
  });
541780
541998
  $[10] = t7;
@@ -541860,10 +542078,10 @@ const Sidebar = (0, import_react.memo)(() => {
541860
542078
  } else t8 = $[9];
541861
542079
  return t8;
541862
542080
  });
541863
- function _temp$3(item) {
542081
+ function _temp$4(item) {
541864
542082
  return item.text;
541865
542083
  }
541866
- function _temp2$2(t) {
542084
+ function _temp2$3(t) {
541867
542085
  return t.status === "completed";
541868
542086
  }
541869
542087
  function _temp3$2(item) {
@@ -601253,7 +601471,7 @@ function OutputPreview(t0) {
601253
601471
  T0 = Box;
601254
601472
  t2 = "column";
601255
601473
  t3 = 2;
601256
- t4 = lines.map(_temp$2);
601474
+ t4 = lines.map(_temp$3);
601257
601475
  $[0] = maxLines;
601258
601476
  $[1] = text;
601259
601477
  $[2] = T0;
@@ -601307,7 +601525,7 @@ function OutputPreview(t0) {
601307
601525
  } else t6 = $[17];
601308
601526
  return t6;
601309
601527
  }
601310
- function _temp$2(line, i) {
601528
+ function _temp$3(line, i) {
601311
601529
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
601312
601530
  flexDirection: "row",
601313
601531
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
@@ -601372,7 +601590,7 @@ function DiffView(t0) {
601372
601590
  const lines = t1;
601373
601591
  let t2;
601374
601592
  if ($[3] !== lines) {
601375
- t2 = lines.map(_temp2$1);
601593
+ t2 = lines.map(_temp2$2);
601376
601594
  $[3] = lines;
601377
601595
  $[4] = t2;
601378
601596
  } else t2 = $[4];
@@ -601388,7 +601606,7 @@ function DiffView(t0) {
601388
601606
  } else t3 = $[6];
601389
601607
  return t3;
601390
601608
  }
601391
- function _temp2$1(line, i) {
601609
+ function _temp2$2(line, i) {
601392
601610
  if (line.kind === "ellipsis") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
601393
601611
  dimColor: true,
601394
601612
  children: " ···"
@@ -602834,6 +603052,7 @@ const MessageBlockView = (0, import_react.memo)((props) => {
602834
603052
  if ($[15] !== message.content || $[16] !== message.id || $[17] !== props.onRender) {
602835
603053
  t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompletedTextBlock, {
602836
603054
  text: message.content,
603055
+ streaming: false,
602837
603056
  onRender: props.onRender
602838
603057
  }, message.id);
602839
603058
  $[15] = message.content;
@@ -602899,52 +603118,54 @@ const MessageBlockView = (0, import_react.memo)((props) => {
602899
603118
  }
602900
603119
  case "thinking": {
602901
603120
  let t2;
602902
- if ($[34] !== message.content || $[35] !== message.id || $[36] !== message.streaming || $[37] !== props.onRender) {
603121
+ if ($[34] !== message.content || $[35] !== message.id || $[36] !== message.startedAt || $[37] !== message.streaming || $[38] !== props.onRender) {
602903
603122
  t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThinkingBlock, {
602904
603123
  text: message.content,
602905
603124
  streaming: message.streaming,
603125
+ startedAt: message.startedAt,
602906
603126
  onRender: props.onRender
602907
603127
  }, message.id);
602908
603128
  $[34] = message.content;
602909
603129
  $[35] = message.id;
602910
- $[36] = message.streaming;
602911
- $[37] = props.onRender;
602912
- $[38] = t2;
602913
- } else t2 = $[38];
603130
+ $[36] = message.startedAt;
603131
+ $[37] = message.streaming;
603132
+ $[38] = props.onRender;
603133
+ $[39] = t2;
603134
+ } else t2 = $[39];
602914
603135
  let t3;
602915
- if ($[39] !== flashBg || $[40] !== t2) {
603136
+ if ($[40] !== flashBg || $[41] !== t2) {
602916
603137
  t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
602917
603138
  flexDirection: "column",
602918
603139
  backgroundColor: flashBg,
602919
603140
  "aria-hidden": true,
602920
603141
  children: t2
602921
603142
  });
602922
- $[39] = flashBg;
602923
- $[40] = t2;
602924
- $[41] = t3;
602925
- } else t3 = $[41];
603143
+ $[40] = flashBg;
603144
+ $[41] = t2;
603145
+ $[42] = t3;
603146
+ } else t3 = $[42];
602926
603147
  inner = t3;
602927
603148
  break bb0;
602928
603149
  }
602929
603150
  case "idle": {
602930
603151
  const idleMsg = message;
602931
603152
  let t2;
602932
- if ($[42] !== idleMsg.durationMs) {
603153
+ if ($[43] !== idleMsg.durationMs) {
602933
603154
  t2 = formatDuration(idleMsg.durationMs);
602934
- $[42] = idleMsg.durationMs;
602935
- $[43] = t2;
602936
- } else t2 = $[43];
603155
+ $[43] = idleMsg.durationMs;
603156
+ $[44] = t2;
603157
+ } else t2 = $[44];
602937
603158
  const idleDuration = t2;
602938
603159
  const idleAriaLabel = idleMsg.state === "error" ? `Failed after ${idleDuration}` : idleMsg.state === "abort" ? `Interrupted after ${idleDuration}` : `Worked for ${idleDuration}`;
602939
603160
  let t3;
602940
- if ($[44] !== idleMsg || $[45] !== message.id) {
603161
+ if ($[45] !== idleMsg || $[46] !== message.id) {
602941
603162
  t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IdleBlock, { message: idleMsg }, message.id);
602942
- $[44] = idleMsg;
602943
- $[45] = message.id;
602944
- $[46] = t3;
602945
- } else t3 = $[46];
603163
+ $[45] = idleMsg;
603164
+ $[46] = message.id;
603165
+ $[47] = t3;
603166
+ } else t3 = $[47];
602946
603167
  let t4;
602947
- if ($[47] !== flashBg || $[48] !== idleAriaLabel || $[49] !== t3) {
603168
+ if ($[48] !== flashBg || $[49] !== idleAriaLabel || $[50] !== t3) {
602948
603169
  t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
602949
603170
  flexDirection: "column",
602950
603171
  backgroundColor: flashBg,
@@ -602952,22 +603173,15 @@ const MessageBlockView = (0, import_react.memo)((props) => {
602952
603173
  "aria-label": idleAriaLabel,
602953
603174
  children: t3
602954
603175
  });
602955
- $[47] = flashBg;
602956
- $[48] = idleAriaLabel;
602957
- $[49] = t3;
602958
- $[50] = t4;
602959
- } else t4 = $[50];
603176
+ $[48] = flashBg;
603177
+ $[49] = idleAriaLabel;
603178
+ $[50] = t3;
603179
+ $[51] = t4;
603180
+ } else t4 = $[51];
602960
603181
  inner = t4;
602961
603182
  break bb0;
602962
603183
  }
602963
- default: {
602964
- let t2;
602965
- if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
602966
- t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
602967
- $[51] = t2;
602968
- } else t2 = $[51];
602969
- return t2;
602970
- }
603184
+ default: throw new Error(`Unknown message type: ${message}`);
602971
603185
  }
602972
603186
  let t2;
602973
603187
  if ($[52] !== flash || $[53] !== theme) {
@@ -603040,36 +603254,62 @@ function CompletedTextBlock(t0) {
603040
603254
  } else t4 = $[7];
603041
603255
  return t4;
603042
603256
  }
603043
- const THINKING_MAX_CHARS = 400;
603044
603257
  function ThinkingBlock(t0) {
603045
- const $ = (0, import_compiler_runtime.c)(16);
603046
- const { text, streaming: t1, onRender } = t0;
603258
+ const $ = (0, import_compiler_runtime.c)(25);
603259
+ const { text, streaming: t1, onRender, startedAt } = t0;
603047
603260
  const streaming = t1 === void 0 ? false : t1;
603048
603261
  let t2;
603049
603262
  if ($[0] !== text) {
603050
- t2 = text.length > THINKING_MAX_CHARS ? "" + text.slice(-THINKING_MAX_CHARS).trimStart() : text;
603263
+ t2 = text.trimEnd().split("\n").pop() ?? "";
603051
603264
  $[0] = text;
603052
603265
  $[1] = t2;
603053
603266
  } else t2 = $[1];
603054
- const preview = t2;
603267
+ const lastParagraph = t2;
603055
603268
  let t3;
603056
- if ($[2] !== onRender) {
603057
- t3 = () => {
603058
- onRender();
603269
+ if ($[2] !== streaming) {
603270
+ t3 = {
603271
+ isActive: streaming,
603272
+ interval: 1e3
603059
603273
  };
603060
- $[2] = onRender;
603274
+ $[2] = streaming;
603061
603275
  $[3] = t3;
603062
603276
  } else t3 = $[3];
603277
+ const { frame } = useAnimation(t3);
603063
603278
  let t4;
603064
- if ($[4] !== preview) {
603065
- t4 = [preview];
603066
- $[4] = preview;
603279
+ if ($[4] !== onRender) {
603280
+ t4 = () => {
603281
+ onRender();
603282
+ };
603283
+ $[4] = onRender;
603067
603284
  $[5] = t4;
603068
603285
  } else t4 = $[5];
603069
- (0, import_react.useEffect)(t3, t4);
603070
603286
  let t5;
603071
- if ($[6] !== streaming) {
603072
- t5 = streaming ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
603287
+ if ($[6] !== lastParagraph) {
603288
+ t5 = [lastParagraph];
603289
+ $[6] = lastParagraph;
603290
+ $[7] = t5;
603291
+ } else t5 = $[7];
603292
+ (0, import_react.useEffect)(t4, t5);
603293
+ let t6;
603294
+ bb0: {
603295
+ if (startedAt == null) {
603296
+ t6 = void 0;
603297
+ break bb0;
603298
+ }
603299
+ const t7 = Math.floor((Date.now() - startedAt) / 1e3) * 1e3;
603300
+ let t8;
603301
+ if ($[8] !== t7) {
603302
+ t8 = formatDuration(t7);
603303
+ $[8] = t7;
603304
+ $[9] = t8;
603305
+ } else t8 = $[9];
603306
+ t6 = `for ${t8}`;
603307
+ }
603308
+ const durationText = t6;
603309
+ let t7;
603310
+ let t8;
603311
+ if ($[10] !== streaming) {
603312
+ t7 = streaming ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
603073
603313
  bold: true,
603074
603314
  color: "cyan",
603075
603315
  "aria-hidden": true,
@@ -603079,53 +603319,73 @@ function ThinkingBlock(t0) {
603079
603319
  "aria-hidden": true,
603080
603320
  children: "◆"
603081
603321
  });
603082
- $[6] = streaming;
603083
- $[7] = t5;
603084
- } else t5 = $[7];
603085
- let t6;
603086
- if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
603087
- t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
603322
+ t8 = streaming ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
603088
603323
  bold: true,
603089
603324
  dimColor: true,
603090
603325
  children: "Thinking"
603326
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
603327
+ bold: true,
603328
+ children: "Thought"
603091
603329
  });
603092
- $[8] = t6;
603093
- } else t6 = $[8];
603094
- let t7;
603095
- if ($[9] !== t5) {
603096
- t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
603330
+ $[10] = streaming;
603331
+ $[11] = t7;
603332
+ $[12] = t8;
603333
+ } else {
603334
+ t7 = $[11];
603335
+ t8 = $[12];
603336
+ }
603337
+ let t9;
603338
+ if ($[13] !== durationText) {
603339
+ t9 = durationText && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
603340
+ dimColor: true,
603341
+ children: durationText
603342
+ });
603343
+ $[13] = durationText;
603344
+ $[14] = t9;
603345
+ } else t9 = $[14];
603346
+ let t10;
603347
+ if ($[15] !== t7 || $[16] !== t8 || $[17] !== t9) {
603348
+ t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
603097
603349
  gap: 1,
603098
- children: [t5, t6]
603350
+ children: [
603351
+ t7,
603352
+ t8,
603353
+ t9
603354
+ ]
603099
603355
  });
603100
- $[9] = t5;
603101
- $[10] = t7;
603102
- } else t7 = $[10];
603103
- let t8;
603104
- if ($[11] !== preview) {
603105
- t8 = preview.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
603356
+ $[15] = t7;
603357
+ $[16] = t8;
603358
+ $[17] = t9;
603359
+ $[18] = t10;
603360
+ } else t10 = $[18];
603361
+ let t11;
603362
+ if ($[19] !== lastParagraph || $[20] !== text.length) {
603363
+ t11 = text.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
603106
603364
  paddingLeft: 2,
603365
+ flexWrap: "wrap",
603107
603366
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
603108
603367
  dimColor: true,
603109
603368
  wrap: "wrap",
603110
- children: preview
603369
+ children: lastParagraph
603111
603370
  })
603112
603371
  });
603113
- $[11] = preview;
603114
- $[12] = t8;
603115
- } else t8 = $[12];
603116
- let t9;
603117
- if ($[13] !== t7 || $[14] !== t8) {
603118
- t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
603372
+ $[19] = lastParagraph;
603373
+ $[20] = text.length;
603374
+ $[21] = t11;
603375
+ } else t11 = $[21];
603376
+ let t12;
603377
+ if ($[22] !== t10 || $[23] !== t11) {
603378
+ t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
603119
603379
  flexDirection: "column",
603120
603380
  paddingX: 1,
603121
603381
  marginY: 1,
603122
- children: [t7, t8]
603382
+ children: [t10, t11]
603123
603383
  });
603124
- $[13] = t7;
603125
- $[14] = t8;
603126
- $[15] = t9;
603127
- } else t9 = $[15];
603128
- return t9;
603384
+ $[22] = t10;
603385
+ $[23] = t11;
603386
+ $[24] = t12;
603387
+ } else t12 = $[24];
603388
+ return t12;
603129
603389
  }
603130
603390
  function formatDuration(ms) {
603131
603391
  if (ms < 1e3) return `${ms}ms`;
@@ -603211,7 +603471,7 @@ function IdleBlock(t0) {
603211
603471
  const summaryText = isError ? `Failed after ${duration}` : isAbort ? `Interrupted after ${duration}` : `${verb} for ${duration}`;
603212
603472
  let t5;
603213
603473
  if ($[6] !== message.applyResults) {
603214
- t5 = message.applyResults.map(_temp$1);
603474
+ t5 = message.applyResults.map(_temp$2);
603215
603475
  $[6] = message.applyResults;
603216
603476
  $[7] = t5;
603217
603477
  } else t5 = $[7];
@@ -603276,7 +603536,7 @@ function IdleBlock(t0) {
603276
603536
  } else t10 = $[23];
603277
603537
  return t10;
603278
603538
  }
603279
- function _temp$1(result) {
603539
+ function _temp$2(result) {
603280
603540
  const { green, red } = buildDots(result.addedLines, result.removedLines);
603281
603541
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
603282
603542
  flexDirection: "row",
@@ -603347,8 +603607,8 @@ var ErrorBoundary = class extends import_react.Component {
603347
603607
  //#endregion
603348
603608
  //#region src/components/CodeSession.tsx
603349
603609
  const CodeSessionWrapper = (0, import_react.memo)((t0) => {
603350
- const $ = (0, import_compiler_runtime.c)(9);
603351
- const { session, onExit, isTabActive: t1 } = t0;
603610
+ const $ = (0, import_compiler_runtime.c)(11);
603611
+ const { session, onExit, isTabActive: t1, updateCheck, credentials } = t0;
603352
603612
  const isTabActive = t1 === void 0 ? true : t1;
603353
603613
  const [proxy, api] = useCodeGenFromSession(session);
603354
603614
  let t2;
@@ -603359,28 +603619,32 @@ const CodeSessionWrapper = (0, import_react.memo)((t0) => {
603359
603619
  $[2] = t2;
603360
603620
  } else t2 = $[2];
603361
603621
  let t3;
603362
- if ($[3] !== isTabActive || $[4] !== onExit) {
603622
+ if ($[3] !== credentials || $[4] !== isTabActive || $[5] !== onExit || $[6] !== updateCheck) {
603363
603623
  t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodeSession, {
603364
603624
  onExit,
603365
- isTabActive
603366
- });
603367
- $[3] = isTabActive;
603368
- $[4] = onExit;
603369
- $[5] = t3;
603370
- } else t3 = $[5];
603625
+ isTabActive,
603626
+ updateCheck,
603627
+ credentials
603628
+ });
603629
+ $[3] = credentials;
603630
+ $[4] = isTabActive;
603631
+ $[5] = onExit;
603632
+ $[6] = updateCheck;
603633
+ $[7] = t3;
603634
+ } else t3 = $[7];
603371
603635
  let t4;
603372
- if ($[6] !== t2 || $[7] !== t3) {
603636
+ if ($[8] !== t2 || $[9] !== t3) {
603373
603637
  t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodeGenStateContext.Provider, {
603374
603638
  value: t2,
603375
603639
  children: t3
603376
603640
  });
603377
- $[6] = t2;
603378
- $[7] = t3;
603379
- $[8] = t4;
603380
- } else t4 = $[8];
603641
+ $[8] = t2;
603642
+ $[9] = t3;
603643
+ $[10] = t4;
603644
+ } else t4 = $[10];
603381
603645
  return t4;
603382
603646
  });
603383
- const CodeSession = (0, import_react.memo)(({ onExit, isTabActive = true }) => {
603647
+ const CodeSession = (0, import_react.memo)(({ onExit, isTabActive = true, updateCheck, credentials }) => {
603384
603648
  const { stdout } = useStdout();
603385
603649
  const { rows, columns } = useWindowSize();
603386
603650
  const [slashMenuActive, setSlashMenuActive] = (0, import_react.useState)(false);
@@ -603527,7 +603791,8 @@ const CodeSession = (0, import_react.memo)(({ onExit, isTabActive = true }) => {
603527
603791
  queue: true,
603528
603792
  user: {
603529
603793
  role: "user",
603530
- source: "builder.io"
603794
+ source: "builder.io",
603795
+ userId: credentials.userId
603531
603796
  }
603532
603797
  }).catch(() => {});
603533
603798
  break;
@@ -603568,7 +603833,8 @@ const CodeSession = (0, import_react.memo)(({ onExit, isTabActive = true }) => {
603568
603833
  queue: true,
603569
603834
  user: {
603570
603835
  role: "user",
603571
- source: "builder.io"
603836
+ source: "builder.io",
603837
+ userId: credentials.userId
603572
603838
  }
603573
603839
  }).catch(() => {});
603574
603840
  break;
@@ -603607,7 +603873,8 @@ const CodeSession = (0, import_react.memo)(({ onExit, isTabActive = true }) => {
603607
603873
  reasoning: prefs.reasoning,
603608
603874
  user: {
603609
603875
  role: "user",
603610
- source: "builder.io"
603876
+ source: "builder.io",
603877
+ userId: credentials.userId
603611
603878
  },
603612
603879
  ...attachments ? { attachments } : {}
603613
603880
  });
@@ -603627,7 +603894,8 @@ const CodeSession = (0, import_react.memo)(({ onExit, isTabActive = true }) => {
603627
603894
  reasoning: prefs.reasoning,
603628
603895
  user: {
603629
603896
  role: "user",
603630
- source: "builder.io"
603897
+ source: "builder.io",
603898
+ userId: credentials.userId
603631
603899
  }
603632
603900
  });
603633
603901
  userScrolledUp.current = false;
@@ -603640,7 +603908,14 @@ const CodeSession = (0, import_react.memo)(({ onExit, isTabActive = true }) => {
603640
603908
  const getOnRenderCallback = (0, import_react.useCallback)((i_0) => {
603641
603909
  let cb = onRenderCallbacksRef.current.get(i_0);
603642
603910
  if (!cb) {
603643
- cb = () => scrollRef.current?.remeasureItem(i_0);
603911
+ cb = () => {
603912
+ if (isTabActive) {
603913
+ scrollRef.current?.remeasureItem(i_0);
603914
+ if (!userScrolledUp.current) setTimeout(() => {
603915
+ scrollRef.current?.scrollToBottom();
603916
+ }, 0);
603917
+ }
603918
+ };
603644
603919
  onRenderCallbacksRef.current.set(i_0, cb);
603645
603920
  }
603646
603921
  return cb;
@@ -603653,9 +603928,9 @@ const CodeSession = (0, import_react.memo)(({ onExit, isTabActive = true }) => {
603653
603928
  const termRow = row_0 - 1 - terminalTop;
603654
603929
  if (termRow < 0 || termRow >= viewportHeight) return;
603655
603930
  const contentRow = sv.getScrollOffset() + termRow;
603656
- const visibleCount = messageCount - startIndex + 1;
603931
+ const visibleCount = messageCount - startIndex;
603657
603932
  for (let i_1 = 0; i_1 < visibleCount; i_1++) {
603658
- const pos = sv.getItemPosition(i_1 + 1);
603933
+ const pos = sv.getItemPosition(i_1);
603659
603934
  if (!pos || contentRow < pos.top || contentRow >= pos.top + pos.height) continue;
603660
603935
  const msg = proxy.messages[startIndex + i_1];
603661
603936
  if (!msg) break;
@@ -603707,7 +603982,8 @@ const CodeSession = (0, import_react.memo)(({ onExit, isTabActive = true }) => {
603707
603982
  isTabActive
603708
603983
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusBar, {
603709
603984
  ctrlCPending,
603710
- showSidebar: false
603985
+ showSidebar: false,
603986
+ updateCheck
603711
603987
  })]
603712
603988
  });
603713
603989
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
@@ -603736,38 +604012,21 @@ const CodeSession = (0, import_react.memo)(({ onExit, isTabActive = true }) => {
603736
604012
  children: "You can still type below. Use /clear to reset the session."
603737
604013
  })]
603738
604014
  }),
603739
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ScrollView$1, {
604015
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ScrollView$1, {
603740
604016
  ref: scrollRef,
603741
604017
  flexGrow: 1,
603742
604018
  flexDirection: "column",
603743
604019
  width: "100%",
603744
- children: [messageCount === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
603745
- paddingX: 2,
603746
- paddingY: 1,
603747
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
603748
- dimColor: true,
603749
- children: "No messages yet. Type a prompt below to get started."
603750
- })
603751
- }), Array.from({ length: messageCount - startIndex }, (__0, i_2) => {
604020
+ children: Array.from({ length: messageCount - startIndex }, (__0, i_2) => {
603752
604021
  const idx = startIndex + i_2;
603753
604022
  const msgProxy = proxy.messages[idx];
603754
604023
  const msgId = msgProxy.id;
603755
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBoundary, {
603756
- fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
603757
- paddingX: 2,
603758
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
603759
- color: "red",
603760
- dimColor: true,
603761
- children: "[failed to render message]"
603762
- })
603763
- }),
603764
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MessageBlockView, {
603765
- message: msgProxy,
603766
- highlighted: msgId === highlightedMessageId,
603767
- onRender: getOnRenderCallback(i_2)
603768
- })
603769
- }, `err-${msgId}-${idx}`);
603770
- })]
604024
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MessageBlockView, {
604025
+ message: msgProxy,
604026
+ highlighted: msgId === highlightedMessageId,
604027
+ onRender: getOnRenderCallback(i_2)
604028
+ }, `${msgId}-${idx}`);
604029
+ })
603771
604030
  })
603772
604031
  })
603773
604032
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
@@ -603814,7 +604073,8 @@ const CodeSession = (0, import_react.memo)(({ onExit, isTabActive = true }) => {
603814
604073
  })] }),
603815
604074
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusBar, {
603816
604075
  ctrlCPending,
603817
- showSidebar
604076
+ showSidebar,
604077
+ updateCheck
603818
604078
  })
603819
604079
  ]
603820
604080
  })]
@@ -605458,6 +605718,7 @@ const KanbanSession = (0, import_react.memo)(({ credentials, isActive, onExit, c
605458
605718
  };
605459
605719
  }, []);
605460
605720
  useInput((input, key) => {
605721
+ if (MOUSE_RE.test(input)) return;
605461
605722
  if (input === "c" && key.ctrl) {
605462
605723
  if (ctrlCPendingRef.current) {
605463
605724
  if (ctrlCTimer.current) clearTimeout(ctrlCTimer.current);
@@ -605793,7 +606054,7 @@ function InitErrorScreen(t0) {
605793
606054
  } else t5 = $[7];
605794
606055
  return t5;
605795
606056
  }
605796
- function CodeCommand({ onExit, sys, options }) {
606057
+ function CodeCommand({ onExit, sys, options, updateCheck }) {
605797
606058
  const { exit } = useApp();
605798
606059
  const [initPhase, setInitPhase] = (0, import_react.useState)("loading");
605799
606060
  const [initError, setInitError] = (0, import_react.useState)("");
@@ -605942,9 +606203,11 @@ function CodeCommand({ onExit, sys, options }) {
605942
606203
  flexGrow: 1,
605943
606204
  display: onCodegen ? "flex" : "none",
605944
606205
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodeSessionWrapper, {
606206
+ credentials: credentialsRef.current,
605945
606207
  session: sessionRef.current,
605946
606208
  onExit: cleanup,
605947
- isTabActive: onCodegen
606209
+ isTabActive: onCodegen,
606210
+ updateCheck
605948
606211
  })
605949
606212
  }),
605950
606213
  clawEnabled === true && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
@@ -605976,167 +606239,6 @@ function CodeCommand({ onExit, sys, options }) {
605976
606239
  }
605977
606240
  }
605978
606241
  //#endregion
605979
- //#region src/app.tsx
605980
- function FatalErrorScreen(t0) {
605981
- const $ = (0, import_compiler_runtime.c)(8);
605982
- const { error } = t0;
605983
- const { exit } = useApp();
605984
- let t1;
605985
- if ($[0] !== exit) {
605986
- t1 = (input, key) => {
605987
- if (input === "c" && key.ctrl) {
605988
- exit();
605989
- process.exit(0);
605990
- }
605991
- };
605992
- $[0] = exit;
605993
- $[1] = t1;
605994
- } else t1 = $[1];
605995
- useInput(t1);
605996
- let t2;
605997
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
605998
- t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
605999
- color: "red",
606000
- bold: true,
606001
- children: "Fatal render error"
606002
- });
606003
- $[2] = t2;
606004
- } else t2 = $[2];
606005
- let t3;
606006
- if ($[3] !== error.message) {
606007
- t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
606008
- color: "red",
606009
- children: error.message
606010
- });
606011
- $[3] = error.message;
606012
- $[4] = t3;
606013
- } else t3 = $[4];
606014
- let t4;
606015
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
606016
- t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
606017
- dimColor: true,
606018
- children: "Press Ctrl+C to exit"
606019
- });
606020
- $[5] = t4;
606021
- } else t4 = $[5];
606022
- let t5;
606023
- if ($[6] !== t3) {
606024
- t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
606025
- flexDirection: "column",
606026
- padding: 1,
606027
- gap: 1,
606028
- children: [
606029
- t2,
606030
- t3,
606031
- t4
606032
- ]
606033
- });
606034
- $[6] = t3;
606035
- $[7] = t5;
606036
- } else t5 = $[7];
606037
- return t5;
606038
- }
606039
- function App(t0) {
606040
- const $ = (0, import_compiler_runtime.c)(12);
606041
- const { command, options, sys, theme } = t0;
606042
- const { exit } = useApp();
606043
- const { rows } = useWindowSize();
606044
- let t1;
606045
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
606046
- t1 = [];
606047
- $[0] = t1;
606048
- } else t1 = $[0];
606049
- (0, import_react.useEffect)(_temp2, t1);
606050
- let t2;
606051
- if ($[1] !== command || $[2] !== exit || $[3] !== options || $[4] !== sys) {
606052
- t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBoundary, {
606053
- fallback: _temp3,
606054
- children: command === "code" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodeCommand, {
606055
- onExit: exit,
606056
- sys,
606057
- options
606058
- }) : command === "launch" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
606059
- flexDirection: "column",
606060
- paddingX: 1,
606061
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
606062
- color: "yellow",
606063
- children: "Launch command coming soon. Use: npx builder.io@latest launch"
606064
- })
606065
- }) : command === "index-repo" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
606066
- flexDirection: "column",
606067
- paddingX: 1,
606068
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
606069
- color: "yellow",
606070
- children: "Repo indexing coming soon. Use: npx builder.io@latest index-repo"
606071
- })
606072
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
606073
- flexDirection: "column",
606074
- paddingX: 1,
606075
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
606076
- color: "red",
606077
- children: ["Unknown command: ", command]
606078
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
606079
- dimColor: true,
606080
- children: "Run builder --help for usage information"
606081
- })]
606082
- })
606083
- });
606084
- $[1] = command;
606085
- $[2] = exit;
606086
- $[3] = options;
606087
- $[4] = sys;
606088
- $[5] = t2;
606089
- } else t2 = $[5];
606090
- let t3;
606091
- if ($[6] !== rows || $[7] !== t2) {
606092
- t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
606093
- flexDirection: "column",
606094
- height: rows,
606095
- children: t2
606096
- });
606097
- $[6] = rows;
606098
- $[7] = t2;
606099
- $[8] = t3;
606100
- } else t3 = $[8];
606101
- let t4;
606102
- if ($[9] !== t3 || $[10] !== theme) {
606103
- t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext$1.Provider, {
606104
- value: theme,
606105
- children: t3
606106
- });
606107
- $[9] = t3;
606108
- $[10] = theme;
606109
- $[11] = t4;
606110
- } else t4 = $[11];
606111
- return t4;
606112
- }
606113
- function _temp3(error) {
606114
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FatalErrorScreen, { error });
606115
- }
606116
- function _temp2() {
606117
- enableSgrMouse();
606118
- return _temp;
606119
- }
606120
- function _temp() {
606121
- resetTerminal();
606122
- }
606123
- //#endregion
606124
- //#region src/sentry.ts
606125
- function initSentry() {
606126
- init({
606127
- dsn: "https://1c5033d697e0271ebe53773bff826de0@o117565.ingest.us.sentry.io/4511107776905216",
606128
- tracesSampleRate: 0,
606129
- release: "0.4.1",
606130
- environment: process.env.NODE_ENV ?? "development",
606131
- enabled: false,
606132
- registerEsmLoaderHooks: false,
606133
- normalizeDepth: 5,
606134
- maxValueLength: 1500,
606135
- integrations: [extraErrorDataIntegration()],
606136
- tracePropagationTargets: []
606137
- });
606138
- }
606139
- //#endregion
606140
606242
  //#region src/updater.ts
606141
606243
  const REGISTRY_BASE = "https://registry.npmjs.org/@builder.io";
606142
606244
  const CHECK_INTERVAL_MS = 1440 * 60 * 1e3;
@@ -606150,7 +606252,7 @@ function isStandaloneBinary() {
606150
606252
  return !path$6.basename(process.execPath, ".exe").startsWith("node");
606151
606253
  }
606152
606254
  function getCurrentVersion() {
606153
- return "0.4.1";
606255
+ return "0.4.2";
606154
606256
  }
606155
606257
  async function fetchLatestVersion() {
606156
606258
  return new Promise((resolve, reject) => {
@@ -606197,8 +606299,8 @@ function isNewerVersion(a, b) {
606197
606299
  }
606198
606300
  /**
606199
606301
  * Checks npm registry for a newer version of fusion (at most once per 24h).
606200
- * Returns a notification string if an update is available, null otherwise.
606201
- * Never throws — update checks should never interrupt normal usage.
606302
+ * Returns the current and latest versions when an update is available, null
606303
+ * otherwise. Never throws — update checks should never interrupt normal usage.
606202
606304
  */
606203
606305
  async function runUpdateCheck() {
606204
606306
  if (!isStandaloneBinary()) return null;
@@ -606215,7 +606317,10 @@ async function runUpdateCheck() {
606215
606317
  });
606216
606318
  }
606217
606319
  const current = getCurrentVersion();
606218
- if (isNewerVersion(latestVersion, current)) return `Update available: ${current} → ${latestVersion}\nRun \`builder update\` to install.`;
606320
+ if (isNewerVersion(latestVersion, current)) return {
606321
+ currentVersion: current,
606322
+ latestVersion
606323
+ };
606219
606324
  } catch {}
606220
606325
  return null;
606221
606326
  }
@@ -606358,26 +606463,258 @@ async function downloadFile(url, dest, onRequest) {
606358
606463
  });
606359
606464
  }
606360
606465
  //#endregion
606466
+ //#region src/hooks/useUpdateCheck.ts
606467
+ /**
606468
+ * Runs the update check once on mount and returns a structured state object
606469
+ * describing whether a newer version of the CLI is available.
606470
+ *
606471
+ * - `checking` — the async check is still in progress
606472
+ * - `up-to-date` — the CLI is already on the latest version (or the check
606473
+ * doesn't apply, e.g. running via npx)
606474
+ * - `upgrade` — a newer version is available; `newVersion` holds the latest
606475
+ */
606476
+ function useUpdateCheck() {
606477
+ const $ = (0, import_compiler_runtime.c)(3);
606478
+ let t0;
606479
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
606480
+ t0 = {
606481
+ status: "checking",
606482
+ currentVersion: getCurrentVersion(),
606483
+ newVersion: ""
606484
+ };
606485
+ $[0] = t0;
606486
+ } else t0 = $[0];
606487
+ const [state, setState] = (0, import_react.useState)(t0);
606488
+ let t1;
606489
+ let t2;
606490
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
606491
+ t1 = () => {
606492
+ runUpdateCheck().then((result) => {
606493
+ if (result) setState({
606494
+ status: "upgrade",
606495
+ currentVersion: result.currentVersion,
606496
+ newVersion: result.latestVersion
606497
+ });
606498
+ else setState(_temp$1);
606499
+ }).catch(() => {
606500
+ setState(_temp2$1);
606501
+ });
606502
+ };
606503
+ t2 = [];
606504
+ $[1] = t1;
606505
+ $[2] = t2;
606506
+ } else {
606507
+ t1 = $[1];
606508
+ t2 = $[2];
606509
+ }
606510
+ (0, import_react.useEffect)(t1, t2);
606511
+ return state;
606512
+ }
606513
+ function _temp2$1(prev_0) {
606514
+ return {
606515
+ ...prev_0,
606516
+ status: "up-to-date"
606517
+ };
606518
+ }
606519
+ function _temp$1(prev) {
606520
+ return {
606521
+ ...prev,
606522
+ status: "up-to-date"
606523
+ };
606524
+ }
606525
+ //#endregion
606526
+ //#region src/app.tsx
606527
+ function FatalErrorScreen(t0) {
606528
+ const $ = (0, import_compiler_runtime.c)(8);
606529
+ const { error } = t0;
606530
+ const { exit } = useApp();
606531
+ let t1;
606532
+ if ($[0] !== exit) {
606533
+ t1 = (input, key) => {
606534
+ if (input === "c" && key.ctrl) {
606535
+ exit();
606536
+ process.exit(0);
606537
+ }
606538
+ };
606539
+ $[0] = exit;
606540
+ $[1] = t1;
606541
+ } else t1 = $[1];
606542
+ useInput(t1);
606543
+ let t2;
606544
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
606545
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
606546
+ color: "red",
606547
+ bold: true,
606548
+ children: "Fatal render error"
606549
+ });
606550
+ $[2] = t2;
606551
+ } else t2 = $[2];
606552
+ let t3;
606553
+ if ($[3] !== error.message) {
606554
+ t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
606555
+ color: "red",
606556
+ children: error.message
606557
+ });
606558
+ $[3] = error.message;
606559
+ $[4] = t3;
606560
+ } else t3 = $[4];
606561
+ let t4;
606562
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
606563
+ t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
606564
+ dimColor: true,
606565
+ children: "Press Ctrl+C to exit"
606566
+ });
606567
+ $[5] = t4;
606568
+ } else t4 = $[5];
606569
+ let t5;
606570
+ if ($[6] !== t3) {
606571
+ t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
606572
+ flexDirection: "column",
606573
+ padding: 1,
606574
+ gap: 1,
606575
+ children: [
606576
+ t2,
606577
+ t3,
606578
+ t4
606579
+ ]
606580
+ });
606581
+ $[6] = t3;
606582
+ $[7] = t5;
606583
+ } else t5 = $[7];
606584
+ return t5;
606585
+ }
606586
+ function App(t0) {
606587
+ const $ = (0, import_compiler_runtime.c)(13);
606588
+ const { command, options, sys, theme } = t0;
606589
+ const { exit } = useApp();
606590
+ const { rows } = useWindowSize();
606591
+ const updateCheck = useUpdateCheck();
606592
+ let t1;
606593
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
606594
+ t1 = [];
606595
+ $[0] = t1;
606596
+ } else t1 = $[0];
606597
+ (0, import_react.useEffect)(_temp2, t1);
606598
+ let t2;
606599
+ if ($[1] !== command || $[2] !== exit || $[3] !== options || $[4] !== sys || $[5] !== updateCheck) {
606600
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBoundary, {
606601
+ fallback: _temp3,
606602
+ children: command === "code" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodeCommand, {
606603
+ onExit: exit,
606604
+ sys,
606605
+ options,
606606
+ updateCheck
606607
+ }) : command === "launch" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
606608
+ flexDirection: "column",
606609
+ paddingX: 1,
606610
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
606611
+ color: "yellow",
606612
+ children: "Launch command coming soon. Use: npx builder.io@latest launch"
606613
+ })
606614
+ }) : command === "index-repo" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
606615
+ flexDirection: "column",
606616
+ paddingX: 1,
606617
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
606618
+ color: "yellow",
606619
+ children: "Repo indexing coming soon. Use: npx builder.io@latest index-repo"
606620
+ })
606621
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
606622
+ flexDirection: "column",
606623
+ paddingX: 1,
606624
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
606625
+ color: "red",
606626
+ children: ["Unknown command: ", command]
606627
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
606628
+ dimColor: true,
606629
+ children: "Run builder --help for usage information"
606630
+ })]
606631
+ })
606632
+ });
606633
+ $[1] = command;
606634
+ $[2] = exit;
606635
+ $[3] = options;
606636
+ $[4] = sys;
606637
+ $[5] = updateCheck;
606638
+ $[6] = t2;
606639
+ } else t2 = $[6];
606640
+ let t3;
606641
+ if ($[7] !== rows || $[8] !== t2) {
606642
+ t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
606643
+ flexDirection: "column",
606644
+ height: rows,
606645
+ children: t2
606646
+ });
606647
+ $[7] = rows;
606648
+ $[8] = t2;
606649
+ $[9] = t3;
606650
+ } else t3 = $[9];
606651
+ let t4;
606652
+ if ($[10] !== t3 || $[11] !== theme) {
606653
+ t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext$1.Provider, {
606654
+ value: theme,
606655
+ children: t3
606656
+ });
606657
+ $[10] = t3;
606658
+ $[11] = theme;
606659
+ $[12] = t4;
606660
+ } else t4 = $[12];
606661
+ return t4;
606662
+ }
606663
+ function _temp3(error) {
606664
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FatalErrorScreen, { error });
606665
+ }
606666
+ function _temp2() {
606667
+ enableSgrMouse();
606668
+ return _temp;
606669
+ }
606670
+ function _temp() {
606671
+ resetTerminal();
606672
+ }
606673
+ //#endregion
606674
+ //#region src/sentry.ts
606675
+ function initSentry() {
606676
+ init({
606677
+ dsn: "https://1c5033d697e0271ebe53773bff826de0@o117565.ingest.us.sentry.io/4511107776905216",
606678
+ tracesSampleRate: 0,
606679
+ release: "0.4.2",
606680
+ environment: process.env.NODE_ENV ?? "development",
606681
+ enabled: false,
606682
+ registerEsmLoaderHooks: false,
606683
+ normalizeDepth: 5,
606684
+ maxValueLength: 1500,
606685
+ integrations: [extraErrorDataIntegration()],
606686
+ tracePropagationTargets: []
606687
+ });
606688
+ }
606689
+ //#endregion
606361
606690
  //#region src/cli.tsx
606362
- const VERSION = "0.4.1";
606691
+ const VERSION = "0.4.2";
606363
606692
  async function startInk(command, options) {
606693
+ const sys = await createDevToolsNodeSys({
606694
+ cwd: process.cwd(),
606695
+ ignoreMissingConfig: true
606696
+ });
606697
+ const logFile = process.env.FUSION_LOG_FILE;
606698
+ const theme = detectTheme(await queryOsc11());
606699
+ const file = typeof logFile === "string" ? fs.createWriteStream(logFile) : void 0;
606700
+ const restore = patchConsole((_, data) => {
606701
+ file?.write(data);
606702
+ });
606364
606703
  await render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
606365
606704
  command,
606366
606705
  options,
606367
- sys: await createDevToolsNodeSys({
606368
- cwd: process.cwd(),
606369
- ignoreMissingConfig: true
606370
- }),
606371
- theme: detectTheme(await queryOsc11())
606706
+ sys,
606707
+ theme
606372
606708
  }), {
606373
606709
  exitOnCtrlC: false,
606374
606710
  incrementalRendering: true,
606375
606711
  maxFps: 30,
606376
- patchConsole: true,
606712
+ patchConsole: false,
606377
606713
  concurrent: false,
606378
- alternateScreen: true,
606379
- isScreenReaderEnabled: process.env["INK_SCREEN_READER"] === "true"
606714
+ alternateScreen: true
606380
606715
  }).waitUntilExit();
606716
+ file?.end();
606717
+ restore();
606381
606718
  await flush(2e3);
606382
606719
  }
606383
606720
  const program = new Command().name("fusion").version(VERSION, "-v, --version").description("Builder.io Fusion CLI — AI-powered code generation");
@@ -606404,9 +606741,6 @@ process.on("uncaughtException", (error) => {
606404
606741
  captureException(error);
606405
606742
  throw error;
606406
606743
  });
606407
- runUpdateCheck().then((msg) => {
606408
- if (msg) process.stderr.write(`\n${msg}\n\n`);
606409
- }).catch(() => {});
606410
606744
  await program.parseAsync();
606411
606745
  //#endregion
606412
606746
  export {};