@oh-my-pi/pi-tui 18.10.3 → 18.11.0

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +39 -142
  2. package/dist/types/app-keybindings.d.ts +5 -0
  3. package/dist/types/chat/figure-markdown.d.ts +7 -2
  4. package/dist/types/chat/read-tool-group.d.ts +2 -2
  5. package/dist/types/components/markdown.d.ts +8 -0
  6. package/dist/types/components/text.d.ts +2 -0
  7. package/dist/types/keybinding-matchers.d.ts +6 -0
  8. package/dist/types/multiplexers/tmux.d.ts +1 -0
  9. package/dist/types/multiplexers/types.d.ts +6 -0
  10. package/dist/types/overlays/approval-dialog.d.ts +69 -0
  11. package/dist/types/overlays/plan-review-overlay.d.ts +4 -0
  12. package/dist/types/prompt/custom-editor.d.ts +18 -10
  13. package/dist/types/render/hanging-wrap.d.ts +5 -0
  14. package/dist/types/terminal-capabilities.d.ts +8 -0
  15. package/dist/types/terminal-multiplexer.d.ts +1 -0
  16. package/dist/types/tmux.d.ts +30 -4
  17. package/dist/types/tools/read.d.ts +7 -0
  18. package/package.json +9 -9
  19. package/src/app-keybindings.ts +7 -0
  20. package/src/apps/debug/raw-sse.ts +2 -2
  21. package/src/chat/assistant-message.ts +19 -4
  22. package/src/chat/figure-markdown.ts +10 -3
  23. package/src/chat/read-tool-group.ts +78 -32
  24. package/src/chat/svg-figure.ts +3 -1
  25. package/src/chat/svg-source.ts +6 -3
  26. package/src/components/markdown.ts +12 -0
  27. package/src/components/text.ts +11 -1
  28. package/src/hotkeys-markdown.ts +1 -0
  29. package/src/keybinding-matchers.ts +19 -0
  30. package/src/multiplexers/tmux.ts +3 -0
  31. package/src/multiplexers/types.ts +6 -0
  32. package/src/overlays/approval-dialog.ts +321 -0
  33. package/src/overlays/btw-history-panel.ts +2 -2
  34. package/src/overlays/model-browser.ts +9 -6
  35. package/src/overlays/plan-review-overlay.ts +16 -0
  36. package/src/prompt/custom-editor.ts +149 -64
  37. package/src/render/code-cell.ts +10 -4
  38. package/src/render/hanging-wrap.ts +31 -0
  39. package/src/terminal-capabilities.ts +25 -7
  40. package/src/terminal.ts +14 -3
  41. package/src/tmux.ts +74 -16
  42. package/src/tools/ask.ts +20 -9
  43. package/src/tools/edit.ts +4 -1
  44. package/src/tools/lsp.ts +9 -2
  45. package/src/tools/read.ts +21 -14
  46. package/src/tools/todo.ts +3 -2
  47. package/src/tools/write.ts +14 -4
  48. package/src/tui.ts +16 -2
  49. package/dist/types/tools/eval-format/code-mode-declarations.d.ts +0 -5
  50. package/src/tools/eval-format/code-mode-declarations.ts +0 -61
@@ -7,6 +7,7 @@ import {
7
7
  Markdown,
8
8
  type MarkdownTheme,
9
9
  rewriteMarkdownLinkDestinations,
10
+ streamingMarkdownSource,
10
11
  } from "../components/markdown";
11
12
  import { Spacer } from "../components/spacer";
12
13
  import { Text } from "../components/text";
@@ -111,6 +112,14 @@ interface StableRenderInputs {
111
112
  readonly color: ((text: string) => string) | undefined;
112
113
  }
113
114
 
115
+ /**
116
+ * A partial last thinking line the prose fold may still drop: the start of a
117
+ * fence marker (`` ` ``, `~`) or of an empty `<!-- -->` sentinel. Once it turns
118
+ * into either, the fold's ellipsis lands back on the line above it
119
+ * (`formatThinkingForDisplay`), so that line is not yet settled.
120
+ */
121
+ const UNSETTLED_THINKING_TAIL = /(?:^|\n)[^\S\n]*(?:`{1,2}|~{1,2}|<(?:!(?:-(?:-[^\S\n]*-{0,2})?)?)?)[^\S\n]*$/;
122
+
114
123
  function isSnapshotExtension(previous: readonly StablePart[], current: readonly StablePart[]): boolean {
115
124
  if (previous.length > current.length) return false;
116
125
  for (let index = 0; index < previous.length; index++) {
@@ -1240,17 +1249,23 @@ export class AssistantMessageComponent extends Container {
1240
1249
  // Streaming child: publish Markdown's frozen prefix, and only
1241
1250
  // once non-blank content exists past it — the block's last
1242
1251
  // non-blank line is still being written (thinking's prose fold
1243
- // may rewrite it) and must stay out of published bytes.
1252
+ // may rewrite it) and must stay out of published bytes. A
1253
+ // partial thinking line the fold may still drop does not count.
1254
+ // The frozen prefix is in streamingMarkdownSource form, so
1255
+ // offsets into the block use that form too.
1244
1256
  const raw = md.getLastRenderStableText();
1245
1257
  const frozen = raw.trim();
1246
- if (frozen.length > 0 && /\S/.test(item.lastText.slice(raw.length))) {
1258
+ let past = streamingMarkdownSource(item.lastText).slice(raw.length);
1259
+ if (item.blockType === "thinking") past = past.replace(UNSETTLED_THINKING_TAIL, "");
1260
+ if (frozen.length > 0 && /\S/.test(past)) {
1247
1261
  parts.push({ kind: item.blockType, text: frozen });
1248
1262
  }
1249
1263
  break;
1250
1264
  }
1251
1265
  // Closed child: only the streaming tail may mutate in place, so
1252
- // everything before it is final.
1253
- parts.push({ kind: item.blockType, text: item.lastText });
1266
+ // everything before it is final. Same form as the frozen prefix it
1267
+ // published while streaming, so the snapshot still extends.
1268
+ parts.push({ kind: item.blockType, text: streamingMarkdownSource(item.lastText) });
1254
1269
  itemIndex++;
1255
1270
  continue;
1256
1271
  }
@@ -1,6 +1,6 @@
1
1
  import type { Tokens } from "@oh-my-pi/pi-utils/marked";
2
2
  import type { ImageBudget } from "../components/image";
3
- import type { Markdown } from "../components/markdown";
3
+ import { type Markdown, streamingMarkdownSource } from "../components/markdown";
4
4
  import { Spacer } from "../components/spacer";
5
5
  import { Container } from "../tui";
6
6
  import { SvgFigure, svgFigureRendering } from "./svg-figure";
@@ -68,11 +68,18 @@ export class FigureMarkdown extends Container {
68
68
  /**
69
69
  * The trimmed prose ahead of the first figure, or "" when the block opens
70
70
  * with one. These are the only rows plain Markdown reproduces byte for
71
- * byte, so they are all a transcript may publish ahead of the figure.
71
+ * byte, so they are all a transcript may publish ahead of the figure. While
72
+ * that prose is still the streaming tail (no figure follows it yet), only
73
+ * its settled prefix ({@link Markdown.getLastRenderStableText}) qualifies:
74
+ * the rest is still being written. Both forms are in
75
+ * {@link streamingMarkdownSource} form, so the settled prefix stays a byte
76
+ * prefix of the whole run once a figure splits it off.
72
77
  */
73
78
  get leadingProse(): string {
74
79
  const first = this.#parts[0];
75
- return first?.kind === "markdown" ? first.text : "";
80
+ if (first?.kind !== "markdown") return "";
81
+ if (this.#transient && this.#parts.length === 1) return first.md.getLastRenderStableText().trim();
82
+ return streamingMarkdownSource(first.text);
76
83
  }
77
84
 
78
85
  /** Whether a figure's final source still waits for its raster, or a chart for its pick or raster. */
@@ -10,11 +10,14 @@ import {
10
10
  type ReadRenderArgs,
11
11
  type ReadToolDetails,
12
12
  readContentCode,
13
+ readResultIsMarkdown,
13
14
  readSourceFsPath,
14
15
  splitPathAndSel,
15
16
  } from "../tools/read";
16
17
  import { PREVIEW_LIMITS, shortenPath } from "../render/render-utils";
17
- import { fileHyperlink, renderCodeCell } from "../render";
18
+ import { fileHyperlink, renderCodeCell, renderMarkdownCell } from "../render";
19
+ import { wrapTreeLine } from "../render/hanging-wrap";
20
+ import { wrapTextWithAnsi } from "../utils";
18
21
  import { canonicalizeMessage } from "./thinking-display";
19
22
  import { internalUrlSchemeSpec, splitUrlScheme } from "../tools/url-scheme-host";
20
23
  import type { ToolExecutionHandle } from "./tool-execution";
@@ -22,7 +25,7 @@ import { formatUsageRow } from "../overlays/usage-row";
22
25
  import { formatCount } from "@oh-my-pi/pi-utils";
23
26
  import type { TspCardStatus, TspSpan, TspText } from "@oh-my-pi/pi-wire";
24
27
  import type { NativeToolHead } from "../tools/renderer";
25
- import { card, code, keyed, node, span, text, withHidden } from "../native/describe";
28
+ import { card, code, keyed, md, node, span, text, withHidden } from "../native/describe";
26
29
  import {
27
30
  type DescribeContext,
28
31
  type NativeChild,
@@ -121,11 +124,23 @@ type ReadEntry = {
121
124
  status: "pending" | "success" | "warning" | "error";
122
125
  correctedFrom?: string;
123
126
  contentText?: string;
127
+ /** The result's `details.contentType`; see {@link previewsMarkdown}. */
128
+ contentType?: string;
129
+ /** The call's `raw` arg, which keeps Markdown previews as source. */
130
+ raw?: boolean;
124
131
  conflictCount?: number;
125
132
  codeStartLine?: number;
126
133
  codeLineNumbers?: Array<number | null>;
127
134
  };
128
135
 
136
+ /**
137
+ * Whether an entry previews as rendered Markdown instead of numbered source.
138
+ * Derived on each render so `raw`/path args that land after the result still apply.
139
+ */
140
+ function previewsMarkdown(entry: ReadEntry): boolean {
141
+ return readResultIsMarkdown({ contentType: entry.contentType }, { path: entry.path, raw: entry.raw });
142
+ }
143
+
129
144
  type ReadUsageRow = {
130
145
  toolCallIds: readonly string[];
131
146
  usage: Usage;
@@ -135,13 +150,12 @@ type ReadUsageRow = {
135
150
  turnElapsedMs?: number;
136
151
  };
137
152
 
138
- /** Number of code lines to show in collapsed preview mode */
153
+ /** Number of preview rows to show per read while collapsed. */
139
154
  const COLLAPSED_PREVIEW_LINES = PREVIEW_LIMITS.OUTPUT_COLLAPSED;
140
155
 
141
156
  /**
142
- * Collapsed clamp for a data-first group whose previews are already trimmed
143
- * to {@link COLLAPSED_PREVIEW_LINES}: large enough never to cut the trimmed
144
- * body, so collapsed shows every file and the head of each preview.
157
+ * The outer data-first group must not cut off later files: code is trimmed by
158
+ * source line and Markdown is clamped by each file's native card after rendering.
145
159
  */
146
160
  const TRIMMED_BODY_PREVIEW = { lines: 1000 } as const;
147
161
 
@@ -429,6 +443,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
429
443
  status: "pending",
430
444
  };
431
445
  entry.path = rawPath;
446
+ entry.raw = args.raw === true;
432
447
  this.#entries.set(toolCallId, entry);
433
448
  this.#updateDisplay();
434
449
  }
@@ -485,6 +500,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
485
500
  typeof details?.conflictCount === "number" && details.conflictCount > 0 ? details.conflictCount : undefined;
486
501
  entry.conflictCount = conflictCount;
487
502
  entry.status = result.isError ? "error" : suffixResolution ? "warning" : "success";
503
+ entry.contentType = details?.contentType;
488
504
  // Store clean display content for preview/expanded display when the read
489
505
  // tool provides it; fall back to model-facing text for legacy results.
490
506
  const displayContent = details?.displayContent;
@@ -578,8 +594,8 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
578
594
  * The read run as one inline `tool` on terminals that list the kind, else
579
595
  * the fallback: a bare `card` (role `omp.tool.read`) with `Read <path>` or
580
596
  * `Read (N)` in the head, a `list` of path items (status tone, link,
581
- * correction and conflict detail, nested usage) and, with content previews
582
- * on, a `code` block per read clamped by the card's preview while collapsed.
597
+ * correction and conflict detail, nested usage) and a clamped preview per
598
+ * read when content previews are on.
583
599
  */
584
600
  override describe(cx?: DescribeContext): NativeNode {
585
601
  const dataFirst = cx?.supports("tool") === true;
@@ -593,8 +609,8 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
593
609
  * The data-first read (§7.3 read, read group, read error): one inline
594
610
  * `tool` (role `omp.tool.read`). One file: `Read path:13-36`, a failure's
595
611
  * message in the head. Several: `Read 3 files` over one 22px row per file
596
- * (glyph, dim dir, strong name, range). Content previews are numbered
597
- * `code` (a section per file in a group), trimmed while collapsed.
612
+ * (glyph, dim dir, strong name, range). Each content preview is numbered
613
+ * code or rendered Markdown, clamped per file while collapsed.
598
614
  */
599
615
  #describeTool(): NativeNode {
600
616
  const entries = [...this.#entries.values()];
@@ -715,8 +731,21 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
715
731
  );
716
732
  }
717
733
 
718
- /** One read's content as numbered `code`, trimmed to its first lines (plus a count) while collapsed. */
734
+ /** One read's content, clamped per file while the group is collapsed. */
719
735
  #nativePreview(entry: ReadEntry): NativeChild[] {
736
+ if (previewsMarkdown(entry)) {
737
+ return [
738
+ card(
739
+ {
740
+ variant: "bare",
741
+ collapsible: true,
742
+ collapsed: !this.#expanded,
743
+ preview: { lines: COLLAPSED_PREVIEW_LINES },
744
+ },
745
+ [md(entry.contentText ?? "")],
746
+ ),
747
+ ];
748
+ }
720
749
  const split = splitPathAndSel(entry.path);
721
750
  const lines = (entry.contentText ?? "").split("\n");
722
751
  const shown = this.#expanded ? lines.length : Math.min(lines.length, COLLAPSED_PREVIEW_LINES);
@@ -796,11 +825,13 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
796
825
  preview: { lines: COLLAPSED_PREVIEW_LINES },
797
826
  },
798
827
  [
799
- code(entry.contentText ?? "", {
800
- lang: getLanguageFromPath(split.path),
801
- start: entry.codeStartLine,
802
- numbers: true,
803
- }),
828
+ previewsMarkdown(entry)
829
+ ? md(entry.contentText ?? "")
830
+ : code(entry.contentText ?? "", {
831
+ lang: getLanguageFromPath(split.path),
832
+ start: entry.codeStartLine,
833
+ numbers: true,
834
+ }),
804
835
  ],
805
836
  `p${entry.toolCallId}`,
806
837
  ),
@@ -862,7 +893,9 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
862
893
 
863
894
  // Clear previous children and rebuild the summary and preview blocks.
864
895
  this.clear();
865
- this.#text = new Text("", 0, 0);
896
+ this.#text = new Text("", 0, 0).setWrapLine(
897
+ (line, width) => wrapTreeLine(line, width, theme) ?? wrapTextWithAnsi(line, width),
898
+ );
866
899
 
867
900
  if (displayRows.length === 0) {
868
901
  this.#text.setText(` ${theme.format.bullet} ${theme.fg("toolTitle", theme.bold("Read"))}`);
@@ -1124,7 +1157,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
1124
1157
  }
1125
1158
 
1126
1159
  /**
1127
- * Add a code-cell content preview below the entry summary.
1160
+ * Add a code-cell (or Markdown-cell) content preview below the entry summary.
1128
1161
  * When collapsed: shows first COLLAPSED_PREVIEW_LINES lines with a "… N more lines ⟨<key>: Expand⟩" hint.
1129
1162
  * When expanded: shows full content.
1130
1163
  */
@@ -1151,20 +1184,33 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
1151
1184
  const component: Component = {
1152
1185
  render: (width: number) => {
1153
1186
  if (cachedLines && cachedWidth === width) return cachedLines;
1154
- cachedLines = renderCodeCell(
1155
- {
1156
- code: entry.contentText ?? "",
1157
- language: lang,
1158
- title,
1159
- status: entry.status === "success" ? "complete" : entry.status,
1160
- expanded,
1161
- codeMaxLines: expanded ? undefined : COLLAPSED_PREVIEW_LINES,
1162
- codeStartLine: entry.codeStartLine,
1163
- codeLineNumbers: entry.codeLineNumbers,
1164
- width,
1165
- },
1166
- theme,
1167
- );
1187
+ const status = entry.status === "success" ? "complete" : entry.status;
1188
+ cachedLines = previewsMarkdown(entry)
1189
+ ? renderMarkdownCell(
1190
+ {
1191
+ content: entry.contentText ?? "",
1192
+ title,
1193
+ status,
1194
+ expanded,
1195
+ contentMaxLines: COLLAPSED_PREVIEW_LINES,
1196
+ width,
1197
+ },
1198
+ theme,
1199
+ )
1200
+ : renderCodeCell(
1201
+ {
1202
+ code: entry.contentText ?? "",
1203
+ language: lang,
1204
+ title,
1205
+ status,
1206
+ expanded,
1207
+ codeMaxLines: expanded ? undefined : COLLAPSED_PREVIEW_LINES,
1208
+ codeStartLine: entry.codeStartLine,
1209
+ codeLineNumbers: entry.codeLineNumbers,
1210
+ width,
1211
+ },
1212
+ theme,
1213
+ );
1168
1214
  cachedWidth = width;
1169
1215
  return cachedLines;
1170
1216
  },
@@ -17,7 +17,7 @@ import { hexToOklch, hueDistance, logger, oklchCusp, oklchToHex } from "@oh-my-p
17
17
  import { Image, type ImageBudget, imageMaxColumns } from "../components/image";
18
18
  import { fencedCode, type Markdown } from "../components/markdown";
19
19
  import { type CellDimensions, getCellDimensions, getImageDimensions } from "../terminal-capabilities";
20
- import { getThemeEpoch, type ThemeColor, theme } from "../theme";
20
+ import { ensureThemeSync, getThemeEpoch, type ThemeColor, theme } from "../theme";
21
21
  import type { Component } from "../tui";
22
22
  import { closePartialSvg, prepareSvg } from "./svg-source";
23
23
 
@@ -59,6 +59,7 @@ const SERIES_CHROMA = 0.19;
59
59
 
60
60
  /** The active theme's color per figure token, for resolving a figure with `prepareSvg`. */
61
61
  export function svgFigurePalette(): Record<string, string> {
62
+ ensureThemeSync();
62
63
  const palette: Record<string, string> = { surface: theme.getBgHex("selectedBg") };
63
64
  for (const token in PALETTE) palette[token] = theme.getColorHex(PALETTE[token]!);
64
65
  seriesColors(palette.accent!, theme.isLight).forEach((color, at) => {
@@ -181,6 +182,7 @@ export class SvgFigure implements Component {
181
182
  #placeholder: readonly string[] | undefined;
182
183
 
183
184
  constructor(options: SvgFigureOptions) {
185
+ ensureThemeSync();
184
186
  this.#options = options;
185
187
  }
186
188
 
@@ -35,9 +35,12 @@ export function splitSvgFences(markdown: string): FigureSegment[] {
35
35
  let proseStart = 0;
36
36
  let lineStart = 0;
37
37
  while (lineStart <= markdown.length) {
38
- const newline = markdown.indexOf("\n", lineStart);
39
- const lineEnd = newline < 0 ? markdown.length : newline;
40
- const next = newline < 0 ? markdown.length + 1 : newline + 1;
38
+ let lineEnd = lineStart;
39
+ while (lineEnd < markdown.length && markdown[lineEnd] !== "\n" && markdown[lineEnd] !== "\r") lineEnd++;
40
+ const next =
41
+ lineEnd === markdown.length
42
+ ? markdown.length + 1
43
+ : lineEnd + (markdown[lineEnd] === "\r" && markdown[lineEnd + 1] === "\n" ? 2 : 1);
41
44
  const line = markdown.slice(lineStart, lineEnd);
42
45
  if (fence) {
43
46
  if (closesFence(line, fence.marker)) {
@@ -52,6 +52,18 @@ function normalizeOsc8Terminators(text: string): string {
52
52
  return text.replace(OSC8_ST_PREFIX_REGEX, "$1\x07");
53
53
  }
54
54
 
55
+ /**
56
+ * `text` as the streaming renderer lexes it: OSC 8 terminators unified and
57
+ * tabs expanded. {@link Markdown.getLastRenderStableText} is a prefix of this
58
+ * form, not of the raw source, so append-only publishers that mix settled
59
+ * prefixes with whole blocks must compare both in this form. Rendering it is
60
+ * byte-identical to rendering `text`.
61
+ */
62
+ export function streamingMarkdownSource(text: string): string {
63
+ if (!text.includes("\t") && !text.includes("\x1b")) return text;
64
+ return replaceTabs(normalizeOsc8Terminators(text));
65
+ }
66
+
55
67
  /** The longest suffix of `text` a future append could still complete into a
56
68
  * full `\x1b]8;[^\x07\x1b]*\x1b\\` match: the last `\x1b]8;` plus clean
57
69
  * body (or that plus the pending ST-ESC `\x1b`), or a strict prefix of the
@@ -30,6 +30,7 @@ export class Text implements Component {
30
30
  #customBgFn?: (text: string) => string;
31
31
  #styleFn?: (text: string) => string;
32
32
  #ignoreTight = false;
33
+ #wrapLine?: (line: string, width: number) => string[];
33
34
 
34
35
  setIgnoreTight(ignore: boolean): this {
35
36
  if (this.#ignoreTight === ignore) return this;
@@ -37,6 +38,12 @@ export class Text implements Component {
37
38
  this.invalidate();
38
39
  return this;
39
40
  }
41
+ /** Override row wrapping when the source carries structural prefixes. */
42
+ setWrapLine(wrapLine: (line: string, width: number) => string[]): this {
43
+ this.#wrapLine = wrapLine;
44
+ this.invalidate();
45
+ return this;
46
+ }
40
47
 
41
48
  // Cache for rendered output
42
49
  #cachedText?: string;
@@ -162,7 +169,10 @@ export class Text implements Component {
162
169
  const paddingX = this.#ignoreTight ? this.#paddingX : getPaddingX(this.#paddingX);
163
170
  const contentWidth = Math.max(1, width - paddingX * 2);
164
171
  // Wrap text (this preserves ANSI codes but does NOT pad)
165
- const wrappedLines = wrapTextWithAnsi(normalizedText, contentWidth);
172
+ const wrapLine = this.#wrapLine;
173
+ const wrappedLines = wrapLine
174
+ ? normalizedText.split("\n").flatMap(line => wrapLine(line, contentWidth))
175
+ : wrapTextWithAnsi(normalizedText, contentWidth);
166
176
 
167
177
  // Add margins and background to each line
168
178
  const leftMargin = padding(paddingX);
@@ -136,6 +136,7 @@ function hotkeyGroups(bindings: HotkeysMarkdownBindings): HotkeyGroup[] {
136
136
  { keys: [act("app.tools.expand")], action: "Toggle tool output expansion" },
137
137
  { keys: [act("app.tools.toggleVisibility")], action: "Toggle tool activity visibility" },
138
138
  { keys: [act("app.ask.hide")], action: "Hide/show a pending ask question" },
139
+ { keys: [act("app.approval.approve")], action: "Approve a pending tool call" },
139
140
  { keys: [act("app.thinking.toggle")], action: "Toggle thinking block visibility" },
140
141
  { keys: [act("app.editor.external")], action: "Edit message in external editor" },
141
142
  { keys: [act("app.retry")], action: "Retry last failed assistant turn" },
@@ -28,6 +28,11 @@ export function matchesAppToolsExpand(data: string): boolean {
28
28
  return matchesKey(data, "ctrl+o");
29
29
  }
30
30
 
31
+ /** Effective tools-expand key: the first bound key, or Ctrl+O when unbound. */
32
+ export function appToolsExpandKey(): KeyId {
33
+ return getKeybindings().getKeys("app.tools.expand")[0] ?? "ctrl+o";
34
+ }
35
+
31
36
  /** Match the generic selector cancel keybinding. */
32
37
  export function matchesSelectCancel(data: string): boolean {
33
38
  return getKeybindings().matches(data, "tui.select.cancel");
@@ -101,3 +106,17 @@ export function matchesAppFollowUp(data: string): boolean {
101
106
  }
102
107
  return matchesEffectiveKeys(data, ["ctrl+enter", "ctrl+q"]);
103
108
  }
109
+
110
+ /** Approve-key defaults when `app.approval.approve` is unbound: approval must stay reachable by keyboard. */
111
+ const APPROVE_DEFAULT_KEYS: readonly KeyId[] = ["ctrl+enter", "ctrl+q"];
112
+
113
+ /** Effective tool-approval keys: the `app.approval.approve` bindings, or Ctrl+Enter/Ctrl+Q when unbound. */
114
+ export function appApproveKeys(): readonly KeyId[] {
115
+ const keys = getKeybindings().getKeys("app.approval.approve");
116
+ return keys.length > 0 ? keys : APPROVE_DEFAULT_KEYS;
117
+ }
118
+
119
+ /** Match the tool-approval key, recognizing modifier-tagged LF as Ctrl+Enter like {@link matchesAppFollowUp}. */
120
+ export function matchesAppApprove(data: string): boolean {
121
+ return matchesEffectiveKeys(data, appApproveKeys());
122
+ }
@@ -32,6 +32,9 @@ export const tmuxMultiplexer = {
32
32
  // An explicit appearance refresh passes OSC 11 to the outer terminal, then
33
33
  // re-reads tmux's cache once it has consumed the reply.
34
34
  backgroundColorCache: { passthrough: wrapTmuxPassthrough, settleMs: 100 },
35
+ // tmux drops paste markers for a pane whose own DEC 2004 flag another
36
+ // writer cleared, and only answers DECRQM 2004 since 3.6.
37
+ gatesBracketedPaste: true,
35
38
  expandsRepPadding: true,
36
39
  // tmux expires synchronized output after one second.
37
40
  expiresSynchronizedOutput: true,
@@ -83,6 +83,12 @@ export interface TerminalMultiplexerModule<Id extends string = string> {
83
83
  * session, and an unrecognized report does not turn it off.
84
84
  */
85
85
  readonly honorsSynchronizedOutput?: boolean;
86
+ /**
87
+ * Tracks DEC 2004 per pane and forwards paste markers only while it is set,
88
+ * yet may leave DECRQM 2004 unanswered, so bracketed paste is reasserted
89
+ * without waiting for a DECRPM confirmation.
90
+ */
91
+ readonly gatesBracketedPaste?: boolean;
86
92
  /**
87
93
  * The session does not reveal whether its client renders graphics while
88
94
  * outer-terminal identity variables leak in, so images and Kitty