@wrongstack/tui 0.5.3 → 0.5.6

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
@@ -497,9 +497,12 @@ function History({ entries, streamingText, toolStream }) {
497
497
  const toolTail = toolStream?.text ? tailForDisplay(toolStream.text, MAX_STREAM_DISPLAY_CHARS) : "";
498
498
  return /* @__PURE__ */ jsxs(Fragment, { children: [
499
499
  /* @__PURE__ */ jsx(Static, { items: entries, children: (entry) => /* @__PURE__ */ jsx(Box, { marginBottom: entry.kind === "turn-summary" ? 1 : 0, children: /* @__PURE__ */ jsx(Entry, { entry, termWidth }) }, entry.id) }),
500
- tail ? /* @__PURE__ */ jsxs(Box, { children: [
501
- /* @__PURE__ */ jsx(Text, { dimColor: true, children: "> " }),
502
- /* @__PURE__ */ jsx(Text, { children: tail })
500
+ tail ? /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginY: 1, children: [
501
+ /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
502
+ /* @__PURE__ */ jsx(Text, { bold: true, color: "cyan", children: "ASSISTANT: " }),
503
+ /* @__PURE__ */ jsx(Text, { dimColor: true, children: "(streaming...)" })
504
+ ] }),
505
+ /* @__PURE__ */ jsx(Text, { color: "white", children: tail })
503
506
  ] }) : null,
504
507
  toolTail ? /* @__PURE__ */ jsx(
505
508
  ToolStreamBox,
@@ -603,7 +606,10 @@ function Entry({
603
606
  entry.queued ? /* @__PURE__ */ jsx(Text, { dimColor: true, children: " (queued)" }) : null
604
607
  ] });
605
608
  case "assistant":
606
- return /* @__PURE__ */ jsx(Text, { children: renderMarkdownTables(entry.text, termWidth) });
609
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginY: 1, children: [
610
+ /* @__PURE__ */ jsx(Box, { flexDirection: "row", children: /* @__PURE__ */ jsx(Text, { bold: true, color: "cyan", children: "ASSISTANT: " }) }),
611
+ /* @__PURE__ */ jsx(Text, { color: "white", children: renderMarkdownTables(entry.text, termWidth) })
612
+ ] });
607
613
  case "tool": {
608
614
  const argSummary = formatToolArgs(entry.name, entry.input);
609
615
  const outLines = formatToolOutput(
@@ -2101,6 +2107,9 @@ function reducer(state, action) {
2101
2107
  return { ...state, buffer: action.buffer, cursor: action.cursor };
2102
2108
  case "addPlaceholder":
2103
2109
  return { ...state, placeholders: [...state.placeholders, action.ph] };
2110
+ case "removeLastPlaceholder":
2111
+ if (state.placeholders.length === 0) return state;
2112
+ return { ...state, placeholders: state.placeholders.slice(0, -1) };
2104
2113
  case "clearInput":
2105
2114
  return {
2106
2115
  ...state,
@@ -3880,7 +3889,7 @@ function App({
3880
3889
  if (cursor === 0) return;
3881
3890
  const beforeCursor = buffer.slice(0, cursor);
3882
3891
  const lastWordStart = beforeCursor.lastIndexOf(" ") + 1;
3883
- const next3 = buffer.slice(0, lastWordStart) + buffer.slice(cursor);
3892
+ const next3 = beforeCursor.slice(0, lastWordStart) + buffer.slice(cursor);
3884
3893
  setDraft(next3, lastWordStart);
3885
3894
  } else {
3886
3895
  if (cursor >= buffer.length) return;
@@ -3892,6 +3901,15 @@ function App({
3892
3901
  }
3893
3902
  return;
3894
3903
  }
3904
+ if (key.backspace && cursor === buffer.length && state.placeholders.length > 0) {
3905
+ const BLOCK_PH_RE = /\[pasted(?: #\d+)?\]$/;
3906
+ if (BLOCK_PH_RE.test(buffer)) {
3907
+ const newBuffer = buffer.replace(BLOCK_PH_RE, "").replace(/\s+$/, "");
3908
+ dispatch({ type: "removeLastPlaceholder" });
3909
+ setDraft(newBuffer, newBuffer.length);
3910
+ return;
3911
+ }
3912
+ }
3895
3913
  if (cursor === 0) return;
3896
3914
  const next2 = buffer.slice(0, cursor - 1) + buffer.slice(cursor);
3897
3915
  setDraft(next2, cursor - 1);
@@ -3968,19 +3986,28 @@ function App({
3968
3986
  cleanInput = input.replace(/\x1b\[200~/g, "").replace(/\x1b\[201~/g, "");
3969
3987
  bracketedPaste = true;
3970
3988
  }
3971
- if (bracketedPaste || cleanInput.length > PASTE_THRESHOLD_CHARS || cleanInput.includes("\n")) {
3989
+ if (bracketedPaste || cleanInput.length > PASTE_THRESHOLD_CHARS) {
3972
3990
  const builder = builderRef.current;
3973
3991
  if (!builder) return;
3974
3992
  const ph = await builder.appendPaste(cleanInput);
3975
3993
  if (ph) {
3976
3994
  const lineCount = cleanInput.split("\n").length;
3977
3995
  dispatch({ type: "addPlaceholder", ph: `${ph} (${lineCount} lines)` });
3996
+ } else if (cleanInput.includes("\n")) {
3997
+ const lineCount = cleanInput.split("\n").length;
3998
+ dispatch({ type: "addPlaceholder", ph: `[pasted] (${lineCount} lines)` });
3978
3999
  } else {
3979
4000
  const next2 = buffer.slice(0, cursor) + cleanInput + buffer.slice(cursor);
3980
4001
  setDraft(next2, cursor + cleanInput.length);
3981
4002
  }
3982
4003
  return;
3983
4004
  }
4005
+ if (cleanInput.includes("\n")) {
4006
+ const normalized = cleanInput.replace(/\r?\n/g, " ");
4007
+ const next2 = buffer.slice(0, cursor) + normalized + buffer.slice(cursor);
4008
+ setDraft(next2, cursor + normalized.length);
4009
+ return;
4010
+ }
3984
4011
  const next = buffer.slice(0, cursor) + cleanInput + buffer.slice(cursor);
3985
4012
  setDraft(next, cursor + cleanInput.length);
3986
4013
  };