@wrongstack/tui 0.104.0 → 0.107.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.
package/dist/index.js CHANGED
@@ -2065,9 +2065,8 @@ function computeWidths(allRows, cols, maxWidth, sepWidths) {
2065
2065
  for (let c = 0; c < cols; c++) {
2066
2066
  const cell = row[c] ?? "";
2067
2067
  const stripped = stripInlineMarkers(cell);
2068
- const w = longestWord(stripped);
2069
2068
  const total = strWidth(stripped);
2070
- natural[c] = Math.max(expectDefined$1(natural[c]), w, total);
2069
+ natural[c] = Math.max(expectDefined$1(natural[c]), total);
2071
2070
  }
2072
2071
  }
2073
2072
  if (sepWidths) {
@@ -2200,19 +2199,16 @@ function strWidth(s2) {
2200
2199
  i += cpLen;
2201
2200
  continue;
2202
2201
  }
2202
+ if (code >= 9472 && code <= 9599) {
2203
+ width += 1;
2204
+ i += cpLen;
2205
+ continue;
2206
+ }
2203
2207
  width += 1;
2204
2208
  i += cpLen;
2205
2209
  }
2206
2210
  return width;
2207
2211
  }
2208
- function longestWord(s2) {
2209
- let max = 0;
2210
- for (const w of s2.split(/\s+/)) {
2211
- const visualWidth = strWidth(w);
2212
- if (visualWidth > max) max = visualWidth;
2213
- }
2214
- return max;
2215
- }
2216
2212
  function border(left, mid, right, widths) {
2217
2213
  return left + widths.map((w) => "\u2500".repeat(w + 2)).join(mid) + right;
2218
2214
  }
@@ -2220,13 +2216,12 @@ function stripInlineMarkers(text) {
2220
2216
  return text.replace(/\*\*(.+?)\*\*/g, "$1").replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g, "$1").replace(/`(.+?)`/g, "$1").replace(/~~(.+?)~~/g, "$1");
2221
2217
  }
2222
2218
  var ANSI_BOLD = "\x1B[1m";
2223
- var ANSI_RESET = "\x1B[22m";
2224
2219
  var ANSI_DIM = "\x1B[2m";
2225
2220
  var ANSI_CYAN = "\x1B[36m";
2226
2221
  var ANSI_STRIKE = "\x1B[9m";
2227
2222
  var ANSI_RESET_ALL = "\x1B[0m";
2228
2223
  function applyInlineAnsi(text) {
2229
- return text.replace(/\*\*(.+?)\*\*/g, `${ANSI_BOLD}$1${ANSI_RESET}`).replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g, `${ANSI_DIM}$1${ANSI_RESET_ALL}`).replace(/`(.+?)`/g, `${ANSI_CYAN}$1${ANSI_RESET_ALL}`).replace(/~~(.+?)~~/g, `${ANSI_STRIKE}$1${ANSI_RESET_ALL}`);
2224
+ return text.replace(/\*\*(.+?)\*\*/g, `${ANSI_BOLD}$1${ANSI_RESET_ALL}`).replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g, `${ANSI_DIM}$1${ANSI_RESET_ALL}`).replace(/`(.+?)`/g, `${ANSI_CYAN}$1${ANSI_RESET_ALL}`).replace(/~~(.+?)~~/g, `${ANSI_STRIKE}$1${ANSI_RESET_ALL}`);
2230
2225
  }
2231
2226
  function renderRow(cells, widths, aligns) {
2232
2227
  const styled = cells.map((c) => applyInlineAnsi(c));
@@ -2239,7 +2234,7 @@ function renderRow(cells, widths, aligns) {
2239
2234
  for (let c = 0; c < widths.length; c++) {
2240
2235
  const w = widths[c] ?? MIN_COL_WIDTH;
2241
2236
  const text = wrapped[c]?.[line] ?? "";
2242
- parts.push(padCell(text, w, aligns[c] ?? "left"));
2237
+ parts.push(padCell(text, w, aligns[c] ?? "left") + ANSI_RESET_ALL);
2243
2238
  }
2244
2239
  out.push("\u2502 " + parts.join(" \u2502 ") + " \u2502");
2245
2240
  }
@@ -3224,6 +3219,10 @@ function extractDiffPreview(toolName, output) {
3224
3219
  return parseUnifiedDiff(diff, DIFF_MAX_LINES);
3225
3220
  }
3226
3221
  var MESSAGE_PANEL_CHROME_WIDTH = 2;
3222
+ var MESSAGE_PANEL_MARGIN = 2;
3223
+ function assistantContentWidth(termWidth) {
3224
+ return Math.max(20, termWidth - MESSAGE_PANEL_CHROME_WIDTH - MESSAGE_PANEL_MARGIN * 2);
3225
+ }
3227
3226
  function splitFencedBlocks(text) {
3228
3227
  const lines = text.split("\n");
3229
3228
  const segs = [];
@@ -3377,9 +3376,6 @@ function brainRiskColor(risk) {
3377
3376
  return "red";
3378
3377
  }
3379
3378
  }
3380
- function assistantContentWidth(termWidth) {
3381
- return Math.max(20, termWidth - MESSAGE_PANEL_CHROME_WIDTH);
3382
- }
3383
3379
  var Entry = React6.memo(function Entry2({
3384
3380
  entry,
3385
3381
  termWidth
@@ -3389,6 +3385,7 @@ var Entry = React6.memo(function Entry2({
3389
3385
  return /* @__PURE__ */ jsx(
3390
3386
  Box,
3391
3387
  {
3388
+ marginX: MESSAGE_PANEL_MARGIN,
3392
3389
  borderStyle: "single",
3393
3390
  borderTop: false,
3394
3391
  borderRight: false,
@@ -3415,6 +3412,7 @@ var Entry = React6.memo(function Entry2({
3415
3412
  Box,
3416
3413
  {
3417
3414
  flexDirection: "column",
3415
+ marginX: MESSAGE_PANEL_MARGIN,
3418
3416
  marginY: 1,
3419
3417
  borderStyle: "single",
3420
3418
  borderTop: false,
@@ -3488,6 +3486,7 @@ var Entry = React6.memo(function Entry2({
3488
3486
  return /* @__PURE__ */ jsx(
3489
3487
  Box,
3490
3488
  {
3489
+ marginX: MESSAGE_PANEL_MARGIN,
3491
3490
  borderStyle: "single",
3492
3491
  borderTop: false,
3493
3492
  borderRight: false,
@@ -3501,6 +3500,7 @@ var Entry = React6.memo(function Entry2({
3501
3500
  return /* @__PURE__ */ jsx(
3502
3501
  Box,
3503
3502
  {
3503
+ marginX: MESSAGE_PANEL_MARGIN,
3504
3504
  borderStyle: "single",
3505
3505
  borderTop: false,
3506
3506
  borderRight: false,
@@ -3519,6 +3519,7 @@ var Entry = React6.memo(function Entry2({
3519
3519
  Box,
3520
3520
  {
3521
3521
  flexDirection: "column",
3522
+ marginX: MESSAGE_PANEL_MARGIN,
3522
3523
  marginY: 1,
3523
3524
  borderStyle: "single",
3524
3525
  borderTop: false,
@@ -3922,8 +3923,8 @@ var LiveActivityStrip = React6.memo(function LiveActivityStrip2({
3922
3923
  }) {
3923
3924
  const { stdout } = useStdout();
3924
3925
  const width = Math.max(10, (stdout?.columns ?? 80) - 2);
3925
- if (Object.keys(entries).length === 0) return null;
3926
- const rows = activityStripRows(entries, Date.now(), maxRows, width);
3926
+ const hasEntries = Object.keys(entries).length > 0;
3927
+ const rows = hasEntries ? activityStripRows(entries, Date.now(), maxRows, width) : new Array(maxRows).fill("");
3927
3928
  return /* @__PURE__ */ jsx(Box, { flexDirection: "column", paddingX: 1, children: rows.map((text, slot) => (
3928
3929
  // biome-ignore lint/suspicious/noArrayIndexKey: fixed-height slots, index IS the identity
3929
3930
  /* @__PURE__ */ jsx(Box, { height: 1, children: text === "" ? /* @__PURE__ */ jsx(Text, { children: " " }) : /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -7310,6 +7311,7 @@ function App({
7310
7311
  getModeLabel
7311
7312
  }) {
7312
7313
  const { exit } = useApp();
7314
+ const { stdout } = useStdout();
7313
7315
  const [liveModel, setLiveModel] = useState(model);
7314
7316
  const [liveProvider, setLiveProvider] = useState(provider ?? "agent");
7315
7317
  const [activeMaxContext, setActiveMaxContext] = useState(effectiveMaxContext);
@@ -9601,6 +9603,15 @@ User message:
9601
9603
  return "";
9602
9604
  }, [state.buffer, state.status, state.picker.open]);
9603
9605
  const enhanceActive = state.enhanceBusy || state.enhance != null;
9606
+ const inputCellRows = layoutInputRows(
9607
+ INPUT_PROMPT,
9608
+ state.buffer,
9609
+ state.cursor,
9610
+ stdout?.columns ?? 80
9611
+ );
9612
+ const inputHeight = Math.max(1, inputCellRows.length);
9613
+ const monitorOpen = state.monitorOpen || state.agentsMonitorOpen || state.worktreeMonitorOpen || state.todosMonitorOpen || state.queuePanelOpen || state.processListOpen || state.goalPanelOpen || state.helpOpen;
9614
+ const hideInput = enhanceActive || monitorOpen;
9604
9615
  return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", flexGrow: 1, flexShrink: 0, children: [
9605
9616
  /* @__PURE__ */ jsx(
9606
9617
  History,
@@ -9612,7 +9623,7 @@ User message:
9612
9623
  ),
9613
9624
  /* @__PURE__ */ jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [
9614
9625
  /* @__PURE__ */ jsx(LiveActivityStrip, { entries: state.fleet, nowTick }),
9615
- enhanceActive ? /* @__PURE__ */ jsx(Box, { height: 1 }) : /* @__PURE__ */ jsx(
9626
+ hideInput ? /* @__PURE__ */ jsx(Box, { height: inputHeight }) : /* @__PURE__ */ jsx(
9616
9627
  Input,
9617
9628
  {
9618
9629
  prompt: INPUT_PROMPT,