@wrongstack/tui 0.8.2 → 0.8.4

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
@@ -1180,7 +1180,17 @@ function padCell(text, width, align) {
1180
1180
  }
1181
1181
  function History({ entries, streamingText, toolStream }) {
1182
1182
  const { stdout } = useStdout();
1183
- const termWidth = stdout?.columns ?? 80;
1183
+ const [termSize, setTermSize] = useState({ columns: stdout?.columns ?? 80, rows: stdout?.rows ?? 24 });
1184
+ useEffect(() => {
1185
+ const handleResize = () => {
1186
+ setTermSize({ columns: stdout?.columns ?? 80, rows: stdout?.rows ?? 24 });
1187
+ };
1188
+ process.stdout.on("resize", handleResize);
1189
+ return () => {
1190
+ process.stdout.off("resize", handleResize);
1191
+ };
1192
+ }, [stdout]);
1193
+ const termWidth = termSize.columns;
1184
1194
  const tail = streamingText ? tailForDisplay(streamingText, MAX_STREAM_DISPLAY_CHARS) : "";
1185
1195
  const toolTail = toolStream?.text ? tailForDisplay(toolStream.text, MAX_STREAM_DISPLAY_CHARS) : "";
1186
1196
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -4193,16 +4203,26 @@ function App({
4193
4203
  }, [events, onClearHistory]);
4194
4204
  useEffect(() => {
4195
4205
  const offFired = events.on("compaction.fired", (e) => {
4196
- const { level, tokens, load, maxContext: maxContext2, report, aggressive } = e;
4206
+ const { level, tokens, load, maxContext: maxContext2, report } = e;
4197
4207
  const pct = (load * 100).toFixed(0);
4198
4208
  const before = report.before;
4199
4209
  const after = report.after;
4200
4210
  const saved = before - after;
4211
+ if (saved <= 0) {
4212
+ dispatch({
4213
+ type: "addEntry",
4214
+ entry: {
4215
+ kind: "info",
4216
+ text: `\u25B8 compaction skipped at ${level} \u2014 load ${pct}% (${tokens.toLocaleString()} of ${maxContext2.toLocaleString()} tok). preserveK protects recent turns; nothing to elide.`
4217
+ }
4218
+ });
4219
+ return;
4220
+ }
4201
4221
  const table = [
4202
- `\u25B8 context compacted at ${level} (${pct}% of ${maxContext2.toLocaleString()} tok)`,
4203
- ` tokens before ${before.toLocaleString().padStart(8)}`,
4204
- ` tokens after ${after.toLocaleString().padStart(8)}`,
4205
- ` saved ${saved.toLocaleString().padStart(8)} (${(saved / before * 100).toFixed(1)}%)`
4222
+ `\u25B8 context compacted at ${level} \u2014 load ${pct}% (${tokens.toLocaleString()} of ${maxContext2.toLocaleString()} tok, full request)`,
4223
+ ` msg tokens before ${before.toLocaleString().padStart(8)}`,
4224
+ ` msg tokens after ${after.toLocaleString().padStart(8)}`,
4225
+ ` saved ${saved.toLocaleString().padStart(8)} (${(saved / before * 100).toFixed(1)}%)`
4206
4226
  ];
4207
4227
  for (const line of table) {
4208
4228
  dispatch({ type: "addEntry", entry: { kind: "info", text: line } });
@@ -4211,7 +4231,7 @@ function App({
4211
4231
  const offFailed = events.on("compaction.failed", (e) => {
4212
4232
  const { level, load, maxContext: maxContext2, fatal } = e;
4213
4233
  const pct = (load * 100).toFixed(0);
4214
- const text = fatal ? `\u2717 compaction failed at ${level} (${pct}% of ${maxContext2.toLocaleString()} tok) \u2014 FATAL` : `\u26A0 compaction failed at ${level} (${pct}% of ${maxContext2.toLocaleString()} tok) \u2014 continuing`;
4234
+ const text = fatal ? `\u2717 compaction failed at ${level} \u2014 load ${pct}% of ${maxContext2.toLocaleString()} tok \u2014 FATAL` : `\u26A0 compaction failed at ${level} \u2014 load ${pct}% of ${maxContext2.toLocaleString()} tok \u2014 continuing`;
4215
4235
  dispatch({ type: "addEntry", entry: { kind: fatal ? "error" : "warn", text } });
4216
4236
  });
4217
4237
  return () => {
@@ -5413,8 +5433,7 @@ User message:
5413
5433
  totalTokens: state.fleetTokens,
5414
5434
  nowTick
5415
5435
  }
5416
- ) : null,
5417
- state.monitorOpen ? /* @__PURE__ */ jsx(
5436
+ ) : state.monitorOpen ? /* @__PURE__ */ jsx(
5418
5437
  FleetMonitor,
5419
5438
  {
5420
5439
  entries: state.fleet,