@wrongstack/tui 0.257.0 → 0.257.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
@@ -1,4 +1,4 @@
1
- import { writeErr, resolveProjectDir, wstackGlobalRoot, GlobalMailbox, resolveWstackPaths, loadGoal, InputBuilder, DefaultSessionRewinder, writeOut, formatTodosList, buildGoalPreamble, expectDefined as expectDefined$1, shouldEnhance, enhanceUserPrompt, recentTextTurns, normalizedEqual, buildChildEnv } from '@wrongstack/core';
1
+ import { writeErr, resolveProjectDir, wstackGlobalRoot, GlobalMailbox, resolveWstackPaths, loadGoal, InputBuilder, DefaultSessionRewinder, writeOut, formatTodosList, buildGoalPreamble, expectDefined as expectDefined$1, shouldEnhance, enhanceUserPrompt, recentTextTurns, normalizedEqual, truncate, buildChildEnv } from '@wrongstack/core';
2
2
  export { buildGoalPreamble } from '@wrongstack/core';
3
3
  import { Box as Box$1, useInput, useStdin, useStdout, Text as Text$1, render, useApp, measureElement, Static } from 'ink';
4
4
  import { randomUUID } from 'crypto';
@@ -126,6 +126,10 @@ function modeIcon(label) {
126
126
  const icon = MODE_ICONS[label] ?? "\u25AA";
127
127
  return `${icon} ${label}`;
128
128
  }
129
+ function truncateLabel(label, maxWidth) {
130
+ const stripped = label.replace(/^\/next\s+[\d\s]+\s*/, "");
131
+ return truncate(stripped, maxWidth);
132
+ }
129
133
  var COMPACT_THRESHOLD = 50;
130
134
  var COMFORTABLE_THRESHOLD = 90;
131
135
  var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
@@ -161,6 +165,7 @@ function StatusBar({
161
165
  debugStreamStats,
162
166
  enhanceCountdown,
163
167
  nextStepsAutoSubmitCountdown,
168
+ nextStepsAutoSubmitLabel,
164
169
  autoProceedCountdown,
165
170
  sessionCount,
166
171
  mailbox,
@@ -578,7 +583,9 @@ function StatusBar({
578
583
  hasNextStepsAutoSubmit && nextStepsAutoSubmitCountdown != null ? /* @__PURE__ */ jsxs(Fragment, { children: [
579
584
  todos && (todos.pending > 0 || todos.inProgress > 0 || todos.completed > 0) || plan && (plan.open > 0 || plan.inProgress > 0 || plan.done > 0) || fleetHasActivity || hasBrainActivity || hasDebugStream || hasEnhanceCountdown ? /* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2502" }) : null,
580
585
  /* @__PURE__ */ jsxs(Text, { color: nextStepsAutoSubmitCountdown <= 3 ? "yellow" : "cyan", children: [
581
- "\u23F3 next step in ",
586
+ "\u23F3 ",
587
+ nextStepsAutoSubmitLabel ? truncateLabel(nextStepsAutoSubmitLabel, 30) : "next step",
588
+ " in ",
582
589
  nextStepsAutoSubmitCountdown,
583
590
  "s"
584
591
  ] })
@@ -1557,9 +1564,9 @@ function buttonLabels(suggestedPattern) {
1557
1564
  function stringifyInput(input) {
1558
1565
  if (!input || typeof input !== "object") return "";
1559
1566
  const obj = input;
1560
- return Object.entries(obj).filter(([k]) => k !== "content" && k !== "new_string").map(([k, v]) => `${k}: ${truncate(JSON.stringify(v), 80)}`).join(" ");
1567
+ return Object.entries(obj).filter(([k]) => k !== "content" && k !== "new_string").map(([k, v]) => `${k}: ${truncate2(JSON.stringify(v), 80)}`).join(" ");
1561
1568
  }
1562
- function truncate(s2, max) {
1569
+ function truncate2(s2, max) {
1563
1570
  return s2.length <= max ? s2 : `${s2.slice(0, max - 1)}\u2026`;
1564
1571
  }
1565
1572
  function hasDiff(input) {
@@ -2851,8 +2858,7 @@ function MarkdownView({
2851
2858
  text,
2852
2859
  termWidth,
2853
2860
  contentWidth,
2854
- tableWidth,
2855
- panelBackground
2861
+ tableWidth
2856
2862
  }) {
2857
2863
  const lines = text.split("\n");
2858
2864
  const rows = [];
@@ -2863,23 +2869,9 @@ function MarkdownView({
2863
2869
  const tableEnd = detectTable(lines, i);
2864
2870
  if (tableEnd > i) {
2865
2871
  const tableText = renderTable(lines.slice(i, tableEnd), tableBudget);
2866
- if (panelBackground) {
2867
- const tableLines = tableText.split("\n");
2868
- rows.push(
2869
- /* @__PURE__ */ jsx(Box, { width: tableBudget, children: tableLines.map((line2, li) => {
2870
- const lineW = strWidth(line2);
2871
- const padding = tableBudget - lineW;
2872
- return /* @__PURE__ */ jsxs(Text, { children: [
2873
- /* @__PURE__ */ jsx(Text, { children: line2 }),
2874
- padding > 0 && /* @__PURE__ */ jsx(Text, { backgroundColor: panelBackground, children: " ".repeat(padding) })
2875
- ] }, li);
2876
- }) }, `t${key++}`)
2877
- );
2878
- } else {
2879
- rows.push(
2880
- /* @__PURE__ */ jsx(Box, { width: tableBudget, backgroundColor: "transparent", children: /* @__PURE__ */ jsx(Text, { children: tableText }) }, `t${key++}`)
2881
- );
2882
- }
2872
+ rows.push(
2873
+ /* @__PURE__ */ jsx(Box, { width: tableBudget, backgroundColor: "transparent", children: /* @__PURE__ */ jsx(Text, { children: tableText }) }, `t${key++}`)
2874
+ );
2883
2875
  i = tableEnd;
2884
2876
  continue;
2885
2877
  }
@@ -2943,7 +2935,7 @@ function MarkdownView({
2943
2935
  }
2944
2936
  rows.push(/* @__PURE__ */ jsx(InlineLine, { tokens: parseInline(line) }, `p${key++}`));
2945
2937
  }
2946
- return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: rows });
2938
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", width: Math.max(20, tableBudget), children: rows });
2947
2939
  }
2948
2940
  function shortenPath(p, max) {
2949
2941
  if (p.length <= max) return p;
@@ -3699,9 +3691,7 @@ function extractDiffPreview(toolName, output) {
3699
3691
  if (!diff || !diff.trim() || diff.startsWith("(no-op")) return void 0;
3700
3692
  return parseUnifiedDiff(diff, DIFF_MAX_LINES);
3701
3693
  }
3702
- var MESSAGE_PANEL_BORDER_WIDTH = 1;
3703
3694
  var MESSAGE_PANEL_CHROME_WIDTH = 2;
3704
- var ASSISTANT_BG = "#1e1e2e";
3705
3695
  function assistantContentWidth(termWidth) {
3706
3696
  return Math.max(20, termWidth - MESSAGE_PANEL_CHROME_WIDTH);
3707
3697
  }
@@ -3741,8 +3731,7 @@ function splitFencedBlocks(text) {
3741
3731
  function AssistantBody({
3742
3732
  text,
3743
3733
  termWidth,
3744
- contentWidth,
3745
- panelBackground
3734
+ contentWidth
3746
3735
  }) {
3747
3736
  const segments = splitFencedBlocks(text);
3748
3737
  const inner = contentWidth ?? termWidth;
@@ -3757,8 +3746,7 @@ function AssistantBody({
3757
3746
  {
3758
3747
  text: seg.text,
3759
3748
  termWidth: inner,
3760
- panelBackground,
3761
- tableWidth: termWidth - MESSAGE_PANEL_BORDER_WIDTH
3749
+ tableWidth: termWidth - MESSAGE_PANEL_CHROME_WIDTH
3762
3750
  },
3763
3751
  i
3764
3752
  )
@@ -4012,7 +4000,6 @@ var Entry = React5.memo(function Entry2({
4012
4000
  borderRight: false,
4013
4001
  borderBottom: false,
4014
4002
  borderColor: theme.user,
4015
- backgroundColor: "#1e1e2e",
4016
4003
  paddingLeft: 1,
4017
4004
  children: /* @__PURE__ */ jsxs(Text, { children: [
4018
4005
  /* @__PURE__ */ jsx(Text, { bold: true, color: theme.user, children: "USER " }),
@@ -4044,19 +4031,10 @@ var Entry = React5.memo(function Entry2({
4044
4031
  borderRight: false,
4045
4032
  borderBottom: false,
4046
4033
  borderColor: theme.assistant,
4047
- backgroundColor: "#1e1e2e",
4048
4034
  paddingLeft: 1,
4049
4035
  children: [
4050
4036
  /* @__PURE__ */ jsx(Box, { flexDirection: "row", children: /* @__PURE__ */ jsx(Text, { bold: true, color: theme.assistant, children: "ASSISTANT" }) }),
4051
- /* @__PURE__ */ jsx(
4052
- AssistantBody,
4053
- {
4054
- text: stripped,
4055
- termWidth,
4056
- contentWidth,
4057
- panelBackground: ASSISTANT_BG
4058
- }
4059
- )
4037
+ /* @__PURE__ */ jsx(AssistantBody, { text: stripped, termWidth, contentWidth })
4060
4038
  ]
4061
4039
  }
4062
4040
  ),
@@ -4079,7 +4057,8 @@ var Entry = React5.memo(function Entry2({
4079
4057
  ] }),
4080
4058
  steps.map((s2) => /* @__PURE__ */ jsx(Box, { flexDirection: "row", marginTop: 0, children: /* @__PURE__ */ jsxs(Text, { children: [
4081
4059
  /* @__PURE__ */ jsx(Text, { bold: true, color: theme.accent, children: ` ${s2.index}. ` }),
4082
- /* @__PURE__ */ jsx(Text, { children: s2.text })
4060
+ /* @__PURE__ */ jsx(Text, { children: s2.text }),
4061
+ s2.auto ? /* @__PURE__ */ jsx(Text, { color: "cyan", dimColor: true, children: " auto" }) : null
4083
4062
  ] }) }, s2.index))
4084
4063
  ]
4085
4064
  }
@@ -10109,12 +10088,14 @@ function App({
10109
10088
  nextStepsAutoSubmitSuggestionRef.current = promptToSubmit;
10110
10089
  const start = Date.now();
10111
10090
  setNextStepsAutoSubmitCountdown(Math.ceil(delay / 1e3));
10091
+ setNextStepsAutoSubmitLabel(promptToSubmit);
10112
10092
  nextStepsAutoSubmitTimerRef.current = setInterval(() => {
10113
10093
  const remaining = Math.max(0, Math.ceil((delay - (Date.now() - start)) / 1e3));
10114
10094
  if (remaining <= 0) {
10115
10095
  clearInterval(nextStepsAutoSubmitTimerRef.current);
10116
10096
  nextStepsAutoSubmitTimerRef.current = void 0;
10117
10097
  setNextStepsAutoSubmitCountdown(null);
10098
+ setNextStepsAutoSubmitLabel(null);
10118
10099
  const suggestion = nextStepsAutoSubmitSuggestionRef.current;
10119
10100
  nextStepsAutoSubmitSuggestionRef.current = null;
10120
10101
  if (suggestion) {
@@ -10122,10 +10103,17 @@ function App({
10122
10103
  setDraft(suggestion, suggestion.length);
10123
10104
  void (async () => {
10124
10105
  const trimmed = suggestion.trim();
10125
- if (!trimmed) return;
10106
+ if (!trimmed) {
10107
+ clearDraft();
10108
+ return;
10109
+ }
10126
10110
  const blocks = [{ type: "text", text: trimmed }];
10127
10111
  dispatch({ type: "addEntry", entry: { kind: "user", text: trimmed } });
10128
- await runBlocksRef.current(blocks);
10112
+ try {
10113
+ await runBlocksRef.current(blocks);
10114
+ } finally {
10115
+ clearDraft();
10116
+ }
10129
10117
  })();
10130
10118
  }
10131
10119
  } else {
@@ -10135,6 +10123,8 @@ function App({
10135
10123
  return () => {
10136
10124
  clearInterval(nextStepsAutoSubmitTimerRef.current);
10137
10125
  nextStepsAutoSubmitTimerRef.current = void 0;
10126
+ setNextStepsAutoSubmitCountdown(null);
10127
+ setNextStepsAutoSubmitLabel(null);
10138
10128
  };
10139
10129
  }, [state.status, autonomyLive, state.enhance, state.enhanceBusy, nextStepsRecheck, getSettings, getSuggestions, dispatch]);
10140
10130
  const settingsAutoSaveGateRef = useRef(true);
@@ -10500,6 +10490,7 @@ function App({
10500
10490
  const enhanceAbortRef = useRef(null);
10501
10491
  const [enhanceCountdown, setEnhanceCountdown] = useState(null);
10502
10492
  const [nextStepsAutoSubmitCountdown, setNextStepsAutoSubmitCountdown] = useState(null);
10493
+ const [nextStepsAutoSubmitLabel, setNextStepsAutoSubmitLabel] = useState(null);
10503
10494
  const nextStepsAutoSubmitSuggestionRef = useRef(null);
10504
10495
  const nextStepsAutoSubmitTimerRef = useRef(void 0);
10505
10496
  useTuiEventBridge({
@@ -11479,6 +11470,7 @@ function App({
11479
11470
  clearInterval(nextStepsAutoSubmitTimerRef.current);
11480
11471
  nextStepsAutoSubmitTimerRef.current = void 0;
11481
11472
  setNextStepsAutoSubmitCountdown(null);
11473
+ setNextStepsAutoSubmitLabel(null);
11482
11474
  nextStepsAutoSubmitSuggestionRef.current = null;
11483
11475
  }
11484
11476
  setDraft(next2, cursor - 1);
@@ -11507,6 +11499,7 @@ function App({
11507
11499
  clearInterval(nextStepsAutoSubmitTimerRef.current);
11508
11500
  nextStepsAutoSubmitTimerRef.current = void 0;
11509
11501
  setNextStepsAutoSubmitCountdown(null);
11502
+ setNextStepsAutoSubmitLabel(null);
11510
11503
  nextStepsAutoSubmitSuggestionRef.current = null;
11511
11504
  }
11512
11505
  setDraft(next2, cursor);
@@ -11640,6 +11633,7 @@ function App({
11640
11633
  clearInterval(nextStepsAutoSubmitTimerRef.current);
11641
11634
  nextStepsAutoSubmitTimerRef.current = void 0;
11642
11635
  setNextStepsAutoSubmitCountdown(null);
11636
+ setNextStepsAutoSubmitLabel(null);
11643
11637
  nextStepsAutoSubmitSuggestionRef.current = null;
11644
11638
  }
11645
11639
  setDraft("", 0);
@@ -11653,6 +11647,7 @@ function App({
11653
11647
  clearInterval(nextStepsAutoSubmitTimerRef.current);
11654
11648
  nextStepsAutoSubmitTimerRef.current = void 0;
11655
11649
  setNextStepsAutoSubmitCountdown(null);
11650
+ setNextStepsAutoSubmitLabel(null);
11656
11651
  nextStepsAutoSubmitSuggestionRef.current = null;
11657
11652
  }
11658
11653
  setDraft(next2, cursor);
@@ -11665,6 +11660,7 @@ function App({
11665
11660
  clearInterval(nextStepsAutoSubmitTimerRef.current);
11666
11661
  nextStepsAutoSubmitTimerRef.current = void 0;
11667
11662
  setNextStepsAutoSubmitCountdown(null);
11663
+ setNextStepsAutoSubmitLabel(null);
11668
11664
  nextStepsAutoSubmitSuggestionRef.current = null;
11669
11665
  }
11670
11666
  setDraft(next2, cursor);
@@ -11688,6 +11684,7 @@ function App({
11688
11684
  clearInterval(nextStepsAutoSubmitTimerRef.current);
11689
11685
  nextStepsAutoSubmitTimerRef.current = void 0;
11690
11686
  setNextStepsAutoSubmitCountdown(null);
11687
+ setNextStepsAutoSubmitLabel(null);
11691
11688
  nextStepsAutoSubmitSuggestionRef.current = null;
11692
11689
  }
11693
11690
  const next = buffer.slice(0, cursor) + input + buffer.slice(cursor);
@@ -12017,7 +12014,12 @@ ${content}
12017
12014
  while (stateRef.current.status !== "idle" && Date.now() - start < 1500) {
12018
12015
  await new Promise((r) => setTimeout(r, 25));
12019
12016
  }
12020
- await runBlocks(blocks2);
12017
+ setDraft(res.runText, res.runText.length);
12018
+ try {
12019
+ await runBlocks(blocks2);
12020
+ } finally {
12021
+ clearDraft();
12022
+ }
12021
12023
  }
12022
12024
  }
12023
12025
  const cmd = trimmed.slice(1).split(/\s+/, 1)[0];
@@ -12482,6 +12484,7 @@ User message:
12482
12484
  debugStreamStats: state.debugStreamStats,
12483
12485
  enhanceCountdown,
12484
12486
  nextStepsAutoSubmitCountdown,
12487
+ nextStepsAutoSubmitLabel,
12485
12488
  autoProceedCountdown: state.countdown?.remainingSeconds ?? null,
12486
12489
  sessionCount,
12487
12490
  mailbox: mailboxStatus,