@wrongstack/tui 0.107.2 → 0.109.1

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,7 +1,7 @@
1
- import { expectDefined, writeErr, InputBuilder, DefaultSessionRewinder, writeOut, formatTodosList, buildGoalPreamble, shouldEnhance, enhanceUserPrompt, recentTextTurns, normalizedEqual, buildChildEnv } from '@wrongstack/core';
1
+ import { expectDefined, writeErr, resolveWstackPaths, loadGoal, InputBuilder, DefaultSessionRewinder, writeOut, formatTodosList, buildGoalPreamble, shouldEnhance, enhanceUserPrompt, recentTextTurns, normalizedEqual, buildChildEnv } from '@wrongstack/core';
2
2
  export { buildGoalPreamble } from '@wrongstack/core';
3
3
  import { Box, Text, useInput, useStdin, useStdout, render, useApp, Static } from 'ink';
4
- import React6, { useState, useEffect, memo, useReducer, useRef, useMemo, useCallback } from 'react';
4
+ import React6, { useState, useEffect, memo, useCallback, useReducer, useRef, useMemo } from 'react';
5
5
  import * as fs2 from 'fs/promises';
6
6
  import * as path2 from 'path';
7
7
  import { routeImagesForModel } from '@wrongstack/runtime/vision';
@@ -913,10 +913,10 @@ function AgentsMonitor({
913
913
  const live = useMemo(() => selectLiveAgents(all, nowTick), [all, nowTick]);
914
914
  const [selectedIndex, setSelectedIndex] = useState(0);
915
915
  const safeIndex = Math.min(selectedIndex, Math.max(0, live.length - 1));
916
- useInput((input, key) => {
917
- if (key.upArrow || input === "k") {
916
+ useInput((_input, key) => {
917
+ if (key.upArrow) {
918
918
  setSelectedIndex((prev) => Math.max(0, prev - 1));
919
- } else if (key.downArrow || input === "j") {
919
+ } else if (key.downArrow) {
920
920
  setSelectedIndex((prev) => Math.min(live.length - 1, prev + 1));
921
921
  }
922
922
  });
@@ -3084,7 +3084,8 @@ function CodeBlock({
3084
3084
  const hidden = Math.max(0, lines.length - MAX_CODE_LINES);
3085
3085
  if (hidden > 0) lines = lines.slice(0, MAX_CODE_LINES);
3086
3086
  const gutterW = String(lines.length).length;
3087
- const maxW = Math.max(20, Math.min(contentWidth - 6 - gutterW - 1, 120));
3087
+ const boxWidth = Math.max(22, contentWidth - 2);
3088
+ const maxW = Math.max(20, Math.min(boxWidth - 4 - gutterW - 1, 120));
3088
3089
  let carry = {};
3089
3090
  const rows = lines.map((raw) => {
3090
3091
  const display = raw.length > maxW ? `${raw.slice(0, maxW - 1)}\u2026` : raw;
@@ -3096,6 +3097,8 @@ function CodeBlock({
3096
3097
  Box,
3097
3098
  {
3098
3099
  flexDirection: "column",
3100
+ width: boxWidth,
3101
+ flexShrink: 0,
3099
3102
  marginLeft: 2,
3100
3103
  marginY: 0,
3101
3104
  borderStyle: "round",
@@ -3800,6 +3803,8 @@ var Input = memo(function Input2({
3800
3803
  cursor,
3801
3804
  disabled,
3802
3805
  hint,
3806
+ hidden,
3807
+ placeholderHeight,
3803
3808
  onKey
3804
3809
  }) {
3805
3810
  useInput((input, key) => {
@@ -3855,6 +3860,9 @@ var Input = memo(function Input2({
3855
3860
  }, [stdout]);
3856
3861
  const promptColor = disabled ? "red" : "cyan";
3857
3862
  const rows = layoutInputRows(prompt, value, cursor, cols);
3863
+ if (hidden) {
3864
+ return /* @__PURE__ */ jsx(Box, { height: Math.max(1, placeholderHeight ?? rows.length) });
3865
+ }
3858
3866
  return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
3859
3867
  rows.map(
3860
3868
  (row, i) => row.length === 0 ? (
@@ -7331,32 +7339,33 @@ function App({
7331
7339
  setStatuslineHiddenItems(hiddenItems);
7332
7340
  }, [setStatuslineHiddenItems, hiddenItems]);
7333
7341
  const projectRoot = agent.ctx.projectRoot;
7334
- useEffect(() => {
7342
+ const refreshGoalSummary = useCallback(() => {
7335
7343
  if (!projectRoot) return;
7336
- const goalPath = path2.join(projectRoot, ".wrongstack", "goal.json");
7337
- fs2.readFile(goalPath, "utf8").then((raw) => {
7338
- const goal = JSON.parse(raw);
7339
- if (goal?.goal && typeof goal.iterations === "number") {
7340
- const lastEntry = goal.journal?.[goal.journal.length - 1];
7341
- dispatch({
7342
- type: "goalSummary",
7343
- summary: {
7344
- goal: goal.goal,
7345
- refinedGoal: goal.refinedGoal,
7346
- goalState: goal.goalState ?? "active",
7347
- iterations: goal.iterations,
7348
- progress: goal.progress,
7349
- progressNote: goal.progressNote,
7350
- progressTrend: goal.progressTrend,
7351
- deliverables: goal.deliverables,
7352
- lastTask: lastEntry?.task,
7353
- lastStatus: lastEntry?.status
7354
- }
7355
- });
7356
- }
7344
+ const goalPath = resolveWstackPaths({ projectRoot }).projectGoal;
7345
+ loadGoal(goalPath).then((goal) => {
7346
+ if (!goal) return;
7347
+ const lastEntry = goal.journal?.[goal.journal.length - 1];
7348
+ dispatch({
7349
+ type: "goalSummary",
7350
+ summary: {
7351
+ goal: goal.goal,
7352
+ refinedGoal: goal.refinedGoal,
7353
+ goalState: goal.goalState ?? "active",
7354
+ iterations: goal.iterations,
7355
+ progress: goal.progress,
7356
+ progressNote: goal.progressNote,
7357
+ progressTrend: goal.progressTrend,
7358
+ deliverables: goal.deliverables,
7359
+ lastTask: lastEntry?.task,
7360
+ lastStatus: lastEntry?.status
7361
+ }
7362
+ });
7357
7363
  }).catch(() => {
7358
7364
  });
7359
7365
  }, [projectRoot]);
7366
+ useEffect(() => {
7367
+ refreshGoalSummary();
7368
+ }, [refreshGoalSummary]);
7360
7369
  const restoredEntries = (() => {
7361
7370
  const msgs = agent.ctx.messages;
7362
7371
  if (!msgs || msgs.length === 0) return [];
@@ -7506,6 +7515,9 @@ function App({
7506
7515
  const t = setInterval(() => setNowTick(Date.now()), 1e4);
7507
7516
  return () => clearInterval(t);
7508
7517
  }, []);
7518
+ useEffect(() => {
7519
+ if (state.goalPanelOpen) refreshGoalSummary();
7520
+ }, [state.goalPanelOpen, nowTick, refreshGoalSummary]);
7509
7521
  const [enhanceDots, setEnhanceDots] = useState(0);
7510
7522
  useEffect(() => {
7511
7523
  if (!state.enhanceBusy) return;
@@ -8981,18 +8993,10 @@ function App({
8981
8993
  dispatch({ type: "toggleMonitor" });
8982
8994
  return;
8983
8995
  }
8984
- if (state.worktreeMonitorOpen) {
8985
- dispatch({ type: "worktreeMonitorToggle" });
8986
- return;
8987
- }
8988
8996
  if (state.todosMonitorOpen) {
8989
8997
  dispatch({ type: "toggleTodosMonitor" });
8990
8998
  return;
8991
8999
  }
8992
- if (state.autoPhase?.monitorOpen) {
8993
- dispatch({ type: "autoPhaseMonitorToggle" });
8994
- return;
8995
- }
8996
9000
  if (state.settingsPicker.open) {
8997
9001
  dispatch({ type: "settingsClose" });
8998
9002
  return;
@@ -9010,6 +9014,9 @@ function App({
9010
9014
  return;
9011
9015
  }
9012
9016
  }
9017
+ if (state.processListOpen) {
9018
+ return;
9019
+ }
9013
9020
  if (input === "?" && !key.ctrl && !key.meta && draftRef.current.buffer === "" && !state.slashPicker.open && !state.picker.open && !state.modelPicker.open && !state.autonomyPicker.open && !state.settingsPicker.open && !state.rewindOverlay && !state.monitorOpen && !state.agentsMonitorOpen && !state.worktreeMonitorOpen && !state.todosMonitorOpen && !state.autoPhase?.monitorOpen) {
9014
9021
  dispatch({ type: "toggleHelp" });
9015
9022
  return;
@@ -9610,8 +9617,7 @@ User message:
9610
9617
  stdout?.columns ?? 80
9611
9618
  );
9612
9619
  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;
9620
+ const hideInput = enhanceActive || state.helpOpen || state.processListOpen;
9615
9621
  return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", flexGrow: 1, flexShrink: 0, children: [
9616
9622
  /* @__PURE__ */ jsx(
9617
9623
  History,
@@ -9623,12 +9629,14 @@ User message:
9623
9629
  ),
9624
9630
  /* @__PURE__ */ jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [
9625
9631
  /* @__PURE__ */ jsx(LiveActivityStrip, { entries: state.fleet, nowTick }),
9626
- hideInput ? /* @__PURE__ */ jsx(Box, { height: inputHeight }) : /* @__PURE__ */ jsx(
9632
+ /* @__PURE__ */ jsx(
9627
9633
  Input,
9628
9634
  {
9629
9635
  prompt: INPUT_PROMPT,
9630
9636
  value: state.buffer,
9631
9637
  cursor: state.cursor,
9638
+ hidden: hideInput,
9639
+ placeholderHeight: inputHeight,
9632
9640
  disabled: state.status === "aborting" && !state.steeringPending || state.confirmQueue.length > 0,
9633
9641
  hint: inputHint,
9634
9642
  onKey: stableOnKey