omp-fabric 1.27.2 → 1.28.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 (104) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +1 -1
  3. package/dist/chunks/{chunk-KIH3KLZU.js → chunk-C2YMZNT5.js} +5 -5
  4. package/dist/chunks/chunk-C2YMZNT5.js.map +7 -0
  5. package/dist/chunks/{chunk-OJZNMROB.js → chunk-DKXNUCM2.js} +36 -50
  6. package/dist/chunks/chunk-DKXNUCM2.js.map +7 -0
  7. package/dist/chunks/chunk-K3OSK6AX.js +132 -0
  8. package/dist/chunks/chunk-K3OSK6AX.js.map +7 -0
  9. package/dist/chunks/{chunk-2BOZMRT5.js → chunk-LK66YHVL.js} +32 -49
  10. package/dist/chunks/chunk-LK66YHVL.js.map +7 -0
  11. package/dist/chunks/chunk-MIGBZN2K.js +81 -0
  12. package/dist/chunks/chunk-MIGBZN2K.js.map +7 -0
  13. package/dist/chunks/chunk-O337ZL5J.js +277 -0
  14. package/dist/chunks/chunk-O337ZL5J.js.map +7 -0
  15. package/dist/chunks/chunk-T76MXSP4.js +32 -0
  16. package/dist/chunks/chunk-T76MXSP4.js.map +7 -0
  17. package/dist/chunks/{chunk-NOZBB266.js → chunk-XZIQGFF7.js} +9 -13
  18. package/dist/chunks/chunk-XZIQGFF7.js.map +7 -0
  19. package/dist/chunks/{chunk-4XLJPEI4.js → chunk-ZJ7HHWW4.js} +20 -41
  20. package/dist/chunks/chunk-ZJ7HHWW4.js.map +7 -0
  21. package/dist/core/approval-controller.d.ts.map +1 -1
  22. package/dist/fabric-exec-tool.d.ts.map +1 -1
  23. package/dist/fabric-runtime-state.js +3 -1
  24. package/dist/fabric-runtime-state.js.map +1 -1
  25. package/dist/host-compatibility.d.ts +1 -1
  26. package/dist/index.js +169 -164
  27. package/dist/index.js.map +3 -3
  28. package/dist/ui/arc-group.d.ts +1 -1
  29. package/dist/ui/arc-group.d.ts.map +1 -1
  30. package/dist/ui/code-preview-shell.d.ts +2 -2
  31. package/dist/ui/code-preview-shell.d.ts.map +1 -1
  32. package/dist/ui/controller.d.ts.map +1 -1
  33. package/dist/ui/conversation-chrome.d.ts +1 -5
  34. package/dist/ui/conversation-chrome.d.ts.map +1 -1
  35. package/dist/ui/conversation-chrome.js +2 -2
  36. package/dist/ui/conversation-queue.d.ts +3 -2
  37. package/dist/ui/conversation-queue.d.ts.map +1 -1
  38. package/dist/ui/conversation-render.d.ts +19 -23
  39. package/dist/ui/conversation-render.d.ts.map +1 -1
  40. package/dist/ui/conversation.d.ts +7 -17
  41. package/dist/ui/conversation.d.ts.map +1 -1
  42. package/dist/ui/conversation.js +317 -318
  43. package/dist/ui/conversation.js.map +3 -3
  44. package/dist/ui/core-tool-render.d.ts +1 -1
  45. package/dist/ui/core-tool-render.d.ts.map +1 -1
  46. package/dist/ui/dashboard-detail.d.ts +4 -4
  47. package/dist/ui/dashboard-detail.d.ts.map +1 -1
  48. package/dist/ui/dashboard-fabric-graph.d.ts +1 -1
  49. package/dist/ui/dashboard-fabric-graph.d.ts.map +1 -1
  50. package/dist/ui/dashboard-presentation.d.ts +1 -1
  51. package/dist/ui/dashboard-presentation.d.ts.map +1 -1
  52. package/dist/ui/dashboard.d.ts +8 -8
  53. package/dist/ui/dashboard.d.ts.map +1 -1
  54. package/dist/ui/dashboard.js +207 -343
  55. package/dist/ui/dashboard.js.map +3 -3
  56. package/dist/ui/diff-background.d.ts +1 -1
  57. package/dist/ui/diff-background.d.ts.map +1 -1
  58. package/dist/ui/fabric-actor-delivery-selector.d.ts +4 -4
  59. package/dist/ui/fabric-actor-delivery-selector.d.ts.map +1 -1
  60. package/dist/ui/fabric-actor-tool-selector.d.ts +5 -6
  61. package/dist/ui/fabric-actor-tool-selector.d.ts.map +1 -1
  62. package/dist/ui/fabric-host-event-selector.d.ts +4 -4
  63. package/dist/ui/fabric-host-event-selector.d.ts.map +1 -1
  64. package/dist/ui/fabric-model-selector.d.ts +4 -6
  65. package/dist/ui/fabric-model-selector.d.ts.map +1 -1
  66. package/dist/ui/fabric-render.d.ts +6 -6
  67. package/dist/ui/fabric-render.d.ts.map +1 -1
  68. package/dist/ui/fabric-thinking-selector.d.ts +4 -7
  69. package/dist/ui/fabric-thinking-selector.d.ts.map +1 -1
  70. package/dist/ui/highlight.d.ts +2 -13
  71. package/dist/ui/highlight.d.ts.map +1 -1
  72. package/dist/ui/row-balance.d.ts +6 -6
  73. package/dist/ui/row-balance.d.ts.map +1 -1
  74. package/dist/ui/settings.d.ts +6 -3
  75. package/dist/ui/settings.d.ts.map +1 -1
  76. package/dist/ui/settings.js +234 -112
  77. package/dist/ui/settings.js.map +3 -3
  78. package/dist/ui/state-file-preview.d.ts +1 -1
  79. package/dist/ui/state-file-preview.d.ts.map +1 -1
  80. package/dist/ui/tui/input.d.ts +16 -0
  81. package/dist/ui/tui/input.d.ts.map +1 -0
  82. package/dist/ui/tui/rows.d.ts +24 -0
  83. package/dist/ui/tui/rows.d.ts.map +1 -0
  84. package/dist/ui/tui/select-list.d.ts +28 -0
  85. package/dist/ui/tui/select-list.d.ts.map +1 -0
  86. package/dist/ui/tui/settings-list.d.ts +38 -0
  87. package/dist/ui/tui/settings-list.d.ts.map +1 -0
  88. package/dist/ui/tui/text-field.d.ts +40 -0
  89. package/dist/ui/tui/text-field.d.ts.map +1 -0
  90. package/dist/ui/tui/view.d.ts +26 -0
  91. package/dist/ui/tui/view.d.ts.map +1 -0
  92. package/dist/ui/widget.d.ts +3 -3
  93. package/dist/ui/widget.d.ts.map +1 -1
  94. package/docs/interface.md +3 -3
  95. package/package.json +11 -11
  96. package/dist/chunks/chunk-2BOZMRT5.js.map +0 -7
  97. package/dist/chunks/chunk-4XLJPEI4.js.map +0 -7
  98. package/dist/chunks/chunk-G2IBGGBM.js +0 -42
  99. package/dist/chunks/chunk-G2IBGGBM.js.map +0 -7
  100. package/dist/chunks/chunk-KIH3KLZU.js.map +0 -7
  101. package/dist/chunks/chunk-NOZBB266.js.map +0 -7
  102. package/dist/chunks/chunk-OJZNMROB.js.map +0 -7
  103. package/dist/ui/symbol-theme.d.ts +0 -3
  104. package/dist/ui/symbol-theme.d.ts.map +0 -1
@@ -3,195 +3,281 @@ import {
3
3
  } from "../chunks/chunk-XU5Z4JCQ.js";
4
4
  import {
5
5
  conversationFooter
6
- } from "../chunks/chunk-NOZBB266.js";
6
+ } from "../chunks/chunk-XZIQGFF7.js";
7
7
  import {
8
- ompSymbolTheme
9
- } from "../chunks/chunk-G2IBGGBM.js";
8
+ TextField
9
+ } from "../chunks/chunk-O337ZL5J.js";
10
+ import {
11
+ asRows
12
+ } from "../chunks/chunk-MIGBZN2K.js";
10
13
  import {
11
14
  isActiveStatus
12
15
  } from "../chunks/chunk-QPXSCMTG.js";
13
16
  import {
14
17
  safeText
15
- } from "../chunks/chunk-KIH3KLZU.js";
18
+ } from "../chunks/chunk-C2YMZNT5.js";
16
19
  import {
20
+ compactRedactedValue,
21
+ redact,
17
22
  terminalSafe,
18
23
  unwrapActorEnvelopeText
19
24
  } from "../chunks/chunk-DLXPTBPL.js";
25
+ import {
26
+ isKey,
27
+ keyOf
28
+ } from "../chunks/chunk-T76MXSP4.js";
20
29
 
21
30
  // src/ui/conversation.ts
22
- import {
23
- CURSOR_MARKER,
24
- Editor,
25
- fuzzyFilter,
26
- getKeybindings as getKeybindings2,
27
- Input,
28
- Key as Key2,
29
- matchesKey as matchesKey2,
30
- truncateToWidth as truncateToWidth2,
31
- visibleWidth
32
- } from "@oh-my-pi/pi-tui";
31
+ import { getKeybindings as getKeybindings2 } from "@oh-my-pi/pi-coding-agent/config/keybindings/keybindings";
32
+ import { fuzzyFilter } from "@oh-my-pi/pi-coding-agent/utils/fuzzy";
33
+ import { truncate as truncate3, visibleWidth } from "@oh-my-pi/pi-tui/text/width";
33
34
 
34
35
  // src/ui/conversation-render.ts
35
- import {
36
- AssistantMessageComponent,
37
- BashExecutionComponent,
38
- BranchSummaryMessageComponent,
39
- CompactionSummaryMessageComponent,
40
- ToolExecutionComponent,
41
- UserMessageComponent
42
- } from "@oh-my-pi/pi-coding-agent";
43
- import { wrapTextWithAnsi } from "@oh-my-pi/pi-tui";
36
+ import { renderMarkdown } from "@oh-my-pi/pi-tui/text/markdown/render";
37
+ import { padTo, truncate, wrap } from "@oh-my-pi/pi-tui/text/width";
38
+ var COLLAPSED_RESULT_LINES = 6;
39
+ var EXPANDED_RESULT_LINES = 200;
44
40
  var textOf = (content) => {
45
41
  if (typeof content === "string") return content;
46
42
  if (!Array.isArray(content)) return "";
47
- return content.filter(
48
- (part) => typeof part === "object" && part !== null && part.type === "text" && typeof part.text === "string"
49
- ).map((part) => part.text).join("\n");
50
- };
51
- var safeRender = (component, width, fallback) => {
52
- try {
53
- return [...component.render(width)];
54
- } catch {
55
- return fallback();
43
+ const parts = [];
44
+ for (const part of content) {
45
+ if (typeof part === "object" && part !== null && "type" in part && part.type === "text" && "text" in part && typeof part.text === "string") {
46
+ parts.push(part.text);
47
+ }
56
48
  }
49
+ return parts.join("\n");
50
+ };
51
+ var resultContent = (raw) => typeof raw === "object" && raw !== null && "content" in raw ? raw.content : void 0;
52
+ var resultIsError = (raw) => typeof raw === "object" && raw !== null && "isError" in raw && raw.isError === true;
53
+ var normalizeResult = (raw) => {
54
+ const content = resultContent(raw);
55
+ const details = typeof raw === "object" && raw !== null && "details" in raw ? raw.details : void 0;
56
+ return {
57
+ content: Array.isArray(content) ? content : [],
58
+ ...details !== void 0 ? { details } : {},
59
+ ...resultIsError(raw) ? { isError: true } : {}
60
+ };
57
61
  };
58
62
  var FabricConversationTranscriptRenderer = class {
59
- constructor(tui, theme, rendererOptions = {}) {
60
- this.tui = tui;
63
+ constructor(host, theme, rendererOptions = {}) {
64
+ this.host = host;
61
65
  this.theme = theme;
62
66
  this.rendererOptions = rendererOptions;
63
67
  }
64
68
  disposed = false;
65
- toolComponents = /* @__PURE__ */ new Map();
66
- assistantComponents = /* @__PURE__ */ new Map();
67
- messageComponents = /* @__PURE__ */ new Map();
69
+ prompts = [];
70
+ cache = /* @__PURE__ */ new Map();
71
+ seen = /* @__PURE__ */ new Set();
68
72
  invalidate() {
69
73
  if (this.disposed) return;
70
- this.toolComponents.clear();
71
- this.assistantComponents.clear();
72
- this.messageComponents.clear();
73
- this.tui.requestRender();
74
+ this.cache.clear();
75
+ this.host.requestRender();
74
76
  }
75
77
  dispose() {
76
78
  this.disposed = true;
77
- this.invalidate();
79
+ this.cache.clear();
80
+ }
81
+ get promptRows() {
82
+ return this.prompts;
78
83
  }
79
84
  render(transcript, width, options) {
80
85
  if (this.disposed || width <= 0) return [];
81
- const lines = [];
82
86
  if (transcript.messages.length === 0 && !transcript.streaming.partialAssistant && transcript.streaming.tools.length === 0) {
87
+ this.cache.clear();
83
88
  return [this.theme.fg("dim", "No retained transcript yet; new agent activity will appear here.")];
84
89
  }
90
+ const lines = [];
91
+ this.prompts = [];
92
+ this.seen = /* @__PURE__ */ new Set();
85
93
  if (transcript.hasMore) lines.push(this.theme.fg("dim", "\u2191 older activity available"));
86
94
  const renderedTools = /* @__PURE__ */ new Set();
87
- for (const message of transcript.messages) this.renderMessage(message, width, options, lines, renderedTools);
88
- if (transcript.streaming.partialAssistant) {
89
- this.renderAssistant(transcript.streaming.partialAssistant, width, options, lines, renderedTools, true);
95
+ const results = /* @__PURE__ */ new Map();
96
+ for (const message of transcript.messages) {
97
+ if (message.role === "toolResult" && typeof message.toolCallId === "string") results.set(message.toolCallId, message);
90
98
  }
99
+ const streamingTools = new Map(transcript.streaming.tools.map((tool) => [tool.toolCallId, tool]));
100
+ const pushTool = (input) => {
101
+ if (renderedTools.has(input.id)) return;
102
+ renderedTools.add(input.id);
103
+ this.block(lines, `tool:${options.target.id}:${input.id}`, [input.name, input.args, input.result, input.partial, input.isError, options.toolsExpanded], width, () => this.toolRows(input, width, options.toolsExpanded));
104
+ };
105
+ const pushAssistant = (message) => {
106
+ this.block(lines, `assistant:${options.target.id}:${message.timestamp}`, [...message.content, message.stopReason, message.errorMessage, options.hideThinking === true], width, () => this.assistantRows(message, width, options.hideThinking === true));
107
+ for (const block of message.content) {
108
+ if (block.type !== "toolCall") continue;
109
+ const result = results.get(block.id);
110
+ const live = streamingTools.get(block.id);
111
+ pushTool({
112
+ id: block.id,
113
+ name: block.name,
114
+ args: block.arguments,
115
+ result: result ?? live?.result ?? live?.partial,
116
+ partial: result === void 0 && live?.result === void 0,
117
+ isError: result?.isError === true || live?.isError === true || resultIsError(live?.result)
118
+ });
119
+ }
120
+ };
121
+ for (const message of transcript.messages) {
122
+ switch (message.role) {
123
+ case "user": {
124
+ const text = unwrapActorEnvelopeText(textOf(message.content)) ?? textOf(message.content);
125
+ if (text) {
126
+ this.prompts.push(lines.length + 1);
127
+ lines.push(...this.userRows(text, width, false));
128
+ }
129
+ break;
130
+ }
131
+ case "assistant":
132
+ pushAssistant(message);
133
+ break;
134
+ case "toolResult":
135
+ if (typeof message.toolCallId === "string") {
136
+ pushTool({
137
+ id: message.toolCallId,
138
+ name: message.toolName ?? "tool",
139
+ args: void 0,
140
+ result: message,
141
+ partial: false,
142
+ isError: message.isError === true
143
+ });
144
+ }
145
+ break;
146
+ case "bashExecution":
147
+ lines.push(...this.bashRows(message, width, options.toolsExpanded));
148
+ break;
149
+ case "custom":
150
+ lines.push(...this.customRows(message, width, options.toolsExpanded));
151
+ break;
152
+ case "compactionSummary":
153
+ lines.push(...this.summaryRows("Compaction summary", message.summary, width, options.toolsExpanded));
154
+ break;
155
+ case "branchSummary":
156
+ lines.push(...this.summaryRows("Branch summary", message.summary, width, options.toolsExpanded));
157
+ break;
158
+ default:
159
+ break;
160
+ }
161
+ }
162
+ if (transcript.streaming.partialAssistant) pushAssistant(transcript.streaming.partialAssistant);
91
163
  for (const tool of transcript.streaming.tools) {
92
- if (renderedTools.has(tool.toolCallId)) continue;
93
- renderedTools.add(tool.toolCallId);
94
- this.renderTool(tool.toolCallId, tool.toolName, tool.args, tool.result, tool.partial, tool.isError, width, options, lines, true);
164
+ pushTool({
165
+ id: tool.toolCallId,
166
+ name: tool.toolName,
167
+ args: tool.args,
168
+ result: tool.result ?? tool.partial,
169
+ partial: tool.result === void 0,
170
+ isError: tool.isError === true || tool.status === "failed"
171
+ });
95
172
  }
96
173
  if (transcript.hasNewer) lines.push(this.theme.fg("dim", "\u2193 newer activity available"));
174
+ for (const key of this.cache.keys()) {
175
+ if (!this.seen.has(key)) this.cache.delete(key);
176
+ }
97
177
  return lines;
98
178
  }
99
- renderMessage(message, width, options, lines, renderedTools) {
100
- switch (message.role) {
101
- case "user": {
102
- const text = unwrapActorEnvelopeText(textOf(message.content)) ?? textOf(message.content);
103
- if (text) this.push(lines, safeRender(new UserMessageComponent(terminalSafe(text, false)), width, () => this.fallback(text, width)));
104
- return;
105
- }
106
- case "assistant":
107
- this.renderAssistant(message, width, options, lines, renderedTools, false);
108
- return;
109
- case "toolResult":
110
- if (typeof message.toolCallId === "string") {
111
- this.renderTool(message.toolCallId, message.toolName ?? "tool", void 0, message, void 0, message.isError, width, options, lines, false);
112
- }
113
- return;
114
- case "bashExecution":
115
- this.renderBash(message, width, options, lines);
116
- return;
117
- case "custom":
118
- this.renderCustom(message, width, options, lines);
119
- return;
120
- case "compactionSummary":
121
- this.renderSummary(message, width, options, lines, CompactionSummaryMessageComponent);
122
- return;
123
- case "branchSummary":
124
- this.renderSummary(message, width, options, lines, BranchSummaryMessageComponent);
125
- return;
126
- default:
127
- return;
179
+ block(lines, key, inputs, width, build) {
180
+ this.seen.add(key);
181
+ const cached = this.cache.get(key);
182
+ if (cached && cached.width === width && cached.inputs.length === inputs.length && cached.inputs.every((value, index) => Object.is(value, inputs[index]))) {
183
+ lines.push(...cached.rows);
184
+ return;
128
185
  }
186
+ let rows;
187
+ try {
188
+ rows = build();
189
+ } catch (error) {
190
+ rows = [this.theme.fg("error", truncate(`render failed: ${error instanceof Error ? error.message : String(error)}`, width))];
191
+ }
192
+ this.cache.set(key, { inputs, width, rows });
193
+ lines.push(...rows);
194
+ }
195
+ markdown(text, width, textStyle) {
196
+ const source = terminalSafe(text, false);
197
+ if (source.trim() === "") return [];
198
+ return renderMarkdown(source, width, { theme: this.theme, ...textStyle ? { textStyle } : {} });
199
+ }
200
+ userRows(text, width, synthetic) {
201
+ const body = terminalSafe(text, false);
202
+ const rows = body.split("\n").flatMap((line) => line === "" ? [""] : wrap(line, Math.max(1, width - 2)));
203
+ const style = (row) => {
204
+ const padded = padTo(` ${row}`, width);
205
+ return synthetic ? this.theme.fg("dim", padded) : this.theme.bg("userMessageBg", padded);
206
+ };
207
+ return ["", ...rows.map(style)];
129
208
  }
130
- renderAssistant(message, width, options, lines, renderedTools, transient) {
131
- const key = `${message.timestamp}:${options.target.id}:${options.hideThinking === true}`;
132
- let component = this.assistantComponents.get(key);
133
- if (!component) {
134
- component = new AssistantMessageComponent(message, options.hideThinking ?? false);
135
- this.assistantComponents.set(key, component);
136
- } else {
137
- component.updateContent(message, { transient });
138
- }
139
- this.push(lines, safeRender(component, width, () => this.fallback(textOf(message.content), width)));
209
+ assistantRows(message, width, hideThinking) {
210
+ const rows = [];
140
211
  for (const block of message.content) {
141
- if (block.type !== "toolCall" || renderedTools.has(block.id)) continue;
142
- renderedTools.add(block.id);
143
- this.renderTool(block.id, block.name, block.arguments, void 0, void 0, message.stopReason === "error", width, options, lines, transient);
144
- }
145
- }
146
- renderTool(id, name, args, result, partial, isError, width, options, lines, transient) {
147
- let component = this.toolComponents.get(`${options.target.id}:${id}`);
148
- if (!component) {
149
- const tool = this.rendererOptions.getToolDefinition?.(name);
150
- component = new ToolExecutionComponent(name, args, { showImages: options.showImages ?? true }, tool, {
151
- requestRender: () => this.tui.requestRender(),
152
- requestComponentRender: () => this.tui.requestRender(),
153
- resetDisplay: () => void 0,
154
- imageBudget: this.tui.imageBudget
155
- }, options.target.cwd ?? process.cwd(), id);
156
- this.toolComponents.set(`${options.target.id}:${id}`, component);
157
- }
158
- component.setExpanded(options.toolsExpanded);
159
- const normalizeResult = (raw) => {
160
- const record = raw ?? {};
161
- return {
162
- content: Array.isArray(record.content) ? record.content : [],
163
- ...record.details !== void 0 ? { details: record.details } : {},
164
- ...record.isError !== void 0 ? { isError: record.isError } : {}
165
- };
166
- };
167
- if (args !== void 0) component.updateArgs(args, id);
168
- if (result !== void 0) component.updateResult(normalizeResult(result), false, id);
169
- else if (partial !== void 0) component.updateResult(normalizeResult(partial), true, id);
170
- if (isError) component.seal();
171
- lines.push(...safeRender(component, width, () => this.fallback(name, width)));
172
- }
173
- renderBash(message, width, options, lines) {
174
- const component = new BashExecutionComponent(message.command, this.tui, message.excludeFromContext);
175
- component.appendOutput(terminalSafe(message.output ?? "", false));
176
- component.setComplete(message.exitCode, message.cancelled, { output: message.output ?? "" });
177
- component.setExpanded(options.toolsExpanded);
178
- this.push(lines, safeRender(component, width, () => this.fallback(message.command, width)));
179
- }
180
- renderCustom(message, width, options, lines) {
212
+ if (block.type === "thinking") {
213
+ if (hideThinking) continue;
214
+ const thinking = this.markdown(block.thinking, width, "muted em");
215
+ if (thinking.length > 0) rows.push("", ...thinking);
216
+ } else if (block.type === "text") {
217
+ const text = this.markdown(block.text, width);
218
+ if (text.length > 0) rows.push("", ...text);
219
+ }
220
+ }
221
+ if (message.stopReason === "error" && message.errorMessage) {
222
+ rows.push("", ...wrap(this.theme.fg("error", terminalSafe(`Error: ${message.errorMessage}`)), width));
223
+ }
224
+ return rows;
225
+ }
226
+ toolRows(input, width, expanded) {
227
+ const definition = this.rendererOptions.getToolDefinition?.(input.name);
228
+ const renderOptions = { expanded, isPartial: input.partial };
229
+ const call = definition?.renderCall ? asRows(definition.renderCall(input.args ?? {}, renderOptions, this.theme), this.theme).render(width) : this.genericCallRows(input, width);
230
+ const result = input.result === void 0 ? [] : definition?.renderResult ? asRows(definition.renderResult(normalizeResult(input.result), renderOptions, this.theme, input.args), this.theme).render(width) : this.genericResultRows(input, width, expanded);
231
+ return ["", ...call, ...result];
232
+ }
233
+ genericCallRows(input, width) {
234
+ const status = input.partial ? this.theme.fg("warning", "\u25C6") : input.isError ? this.theme.fg("error", "\u2717") : this.theme.fg("success", "\u2713");
235
+ const args = input.args === void 0 ? "" : ` ${this.theme.fg("muted", compactRedactedValue(redact(input.args)))}`;
236
+ return [truncate(`${status} ${this.theme.fg("toolTitle", this.theme.style("strong", terminalSafe(input.name)))}${args}`, width)];
237
+ }
238
+ genericResultRows(input, width, expanded) {
239
+ const text = terminalSafe(textOf(resultContent(input.result)), false).replace(/\n+$/, "");
240
+ if (text === "") return [];
241
+ const lines = text.split("\n");
242
+ const limit = expanded ? EXPANDED_RESULT_LINES : COLLAPSED_RESULT_LINES;
243
+ const color = input.isError ? "error" : "toolOutput";
244
+ const rows = lines.slice(0, limit).map((line) => truncate(this.theme.fg(color, ` ${line}`), width));
245
+ if (lines.length > limit) {
246
+ rows.push(this.theme.fg("dim", truncate(` \u2026 ${lines.length - limit} more lines`, width)));
247
+ }
248
+ return rows;
249
+ }
250
+ bashRows(message, width, expanded) {
251
+ const header = truncate(`${this.theme.fg("toolTitle", this.theme.style("strong", "$"))} ${terminalSafe(message.command)}`, width);
252
+ const output = terminalSafe(message.output ?? "", false).replace(/\n+$/, "");
253
+ const lines = output === "" ? [] : output.split("\n");
254
+ const limit = expanded ? EXPANDED_RESULT_LINES : COLLAPSED_RESULT_LINES;
255
+ const rows = ["", header, ...lines.slice(0, limit).map((line) => truncate(this.theme.fg("toolOutput", ` ${line}`), width))];
256
+ if (lines.length > limit) rows.push(this.theme.fg("dim", truncate(` \u2026 ${lines.length - limit} more lines`, width)));
257
+ if (message.cancelled) rows.push(this.theme.fg("warning", " cancelled"));
258
+ else if (message.exitCode !== void 0 && message.exitCode !== 0) {
259
+ rows.push(this.theme.fg("error", ` exit ${message.exitCode}`));
260
+ }
261
+ return rows;
262
+ }
263
+ customRows(message, width, expanded) {
264
+ if (!message.display) return [];
265
+ const renderer = this.rendererOptions.getMessageRenderer?.(message.customType);
266
+ if (renderer) {
267
+ try {
268
+ const rendered = asRows(renderer(message, { expanded }, this.theme), this.theme).render(width);
269
+ if (rendered.length > 0) return ["", ...rendered];
270
+ } catch {
271
+ return [];
272
+ }
273
+ }
181
274
  const text = textOf(message.content);
182
- if (!message.display || !text) return;
183
- this.push(lines, safeRender(new UserMessageComponent(terminalSafe(text, false), { synthetic: true }), width, () => this.fallback(text, width)));
184
- }
185
- renderSummary(message, width, options, lines, ComponentClass) {
186
- const component = new ComponentClass(message);
187
- if ("setExpanded" in component && typeof component.setExpanded === "function") component.setExpanded(options.toolsExpanded);
188
- this.push(lines, safeRender(component, width, () => this.fallback(message.summary, width)));
189
- }
190
- push(lines, block) {
191
- lines.push(...block);
275
+ return text ? this.userRows(text, width, true) : [];
192
276
  }
193
- fallback(text, width) {
194
- return terminalSafe(text, false).split("\n").flatMap((line) => wrapTextWithAnsi(line, Math.max(1, width)).map((item) => this.theme.fg("text", item)));
277
+ summaryRows(label, summary, width, expanded) {
278
+ const header = this.theme.fg("dim", truncate(`\u25C7 ${label}`, width));
279
+ if (!expanded) return ["", header];
280
+ return ["", header, ...this.markdown(summary, width, "muted")];
195
281
  }
196
282
  };
197
283
 
@@ -199,13 +285,8 @@ var FabricConversationTranscriptRenderer = class {
199
285
  import { createHash } from "node:crypto";
200
286
 
201
287
  // src/ui/conversation-queue.ts
202
- import {
203
- Ellipsis,
204
- Key,
205
- getKeybindings,
206
- matchesKey,
207
- truncateToWidth
208
- } from "@oh-my-pi/pi-tui";
288
+ import { getKeybindings } from "@oh-my-pi/pi-coding-agent/config/keybindings/keybindings";
289
+ import { truncate as truncate2 } from "@oh-my-pi/pi-tui/text/width";
209
290
  var QUEUE_STEER_CONVERSATION_QUEUE_REQUEST_EVENT = "queue-steer:conversation-queue:request:v1";
210
291
  var DEQUEUE_FALLBACK = "alt+up";
211
292
  var REMOVE_ROW_KEY = "alt+x";
@@ -461,21 +542,16 @@ function createConversationQueue(options) {
461
542
  };
462
543
  const dequeueKeys = () => {
463
544
  const manager = options.keybindings ?? getKeybindings();
464
- const keys = manager.getKeys("app.message.dequeue");
545
+ const keys = manager.keysFor("app.message.dequeue");
465
546
  return keys.filter((key) => /up$/i.test(key)).map(
466
547
  (key) => key.endsWith("Up") ? `${key.slice(0, -2)}Down` : `${key.slice(0, -2)}down`
467
548
  );
468
549
  };
469
550
  const actionMatches = (data, action, fallback) => {
470
- const manager = options.keybindings;
471
- if (manager) {
472
- const keys = manager.getKeys(action);
473
- if (keys.length === 0) return false;
474
- return manager.matches(data, action);
475
- }
476
- const global = getKeybindings();
477
- if (global.getKeys(action).length > 0) return global.matches(data, action);
478
- return fallback(data);
551
+ const manager = options.keybindings ?? getKeybindings();
552
+ if (manager.keysFor(action).length === 0) return options.keybindings ? false : fallback(data);
553
+ const key = keyOf(data);
554
+ return key !== void 0 && manager.matches(key, action);
479
555
  };
480
556
  const startEditing = () => {
481
557
  if (!options.editor) {
@@ -516,7 +592,7 @@ function createConversationQueue(options) {
516
592
  const matchesOptionArrow = (data, direction) => {
517
593
  const arrow = direction === "left" ? OUTDENT_ROW_KEY : INDENT_ROW_KEY;
518
594
  const wordAlias = direction === "left" ? "alt+b" : "alt+f";
519
- return matchesKey(data, arrow) && !matchesKey(data, wordAlias);
595
+ return isKey(data, arrow) && !isKey(data, wordAlias);
520
596
  };
521
597
  const inlineEditorRenderer = () => {
522
598
  const editor = options.editor;
@@ -657,30 +733,30 @@ function createConversationQueue(options) {
657
733
  theme
658
734
  );
659
735
  const lines2 = [...widget.render(width)];
660
- if (dispatched.length > 0) lines2.push(theme.fg("dim", truncateToWidth("Sent rows await child delivery; they cannot be edited locally.", width, "")));
736
+ if (dispatched.length > 0) lines2.push(theme.fg("dim", truncate2("Sent rows await child delivery; they cannot be edited locally.", width, "")));
661
737
  return lines2;
662
738
  }
663
739
  const lines = [""];
664
740
  const innerWidth = Math.max(0, width - 2);
665
- const dequeueHint = (options.keybindings ?? getKeybindings()).getKeys("app.message.dequeue").join("/") || DEQUEUE_FALLBACK;
741
+ const dequeueHint = (options.keybindings ?? getKeybindings()).keysFor("app.message.dequeue").join("/") || DEQUEUE_FALLBACK;
666
742
  for (const row of rows) {
667
743
  const label = bridge ? bridge.laneLabel(row.lane) : NATIVE_LANE_LABEL[row.lane];
668
744
  const marker = row.selected ? "\u203A " : row.paused ? "\u23F8 " : "";
669
745
  const note = row.removed ? " \xB7 removed on save" : row.paused ? " \xB7 paused" : "";
670
746
  const color = row.state === "dispatched" ? "dim" : bridge ? bridge.laneColor(row.lane) : "dim";
671
747
  lines.push(
672
- ` ${theme.fg(color, truncateToWidth(`${marker}${label}: ${row.text.replace(/\n/g, " ")}${note}`, innerWidth, Ellipsis.Unicode))} `
748
+ ` ${theme.fg(color, truncate2(`${marker}${label}: ${row.text.replace(/\n/g, " ")}${note}`, innerWidth))} `
673
749
  );
674
750
  }
675
751
  const hint = queue.length > 0 ? `\u21B3 ${dequeueHint} to edit queued messages` : "\u21B3 Waiting for child delivery";
676
- lines.push(` ${theme.fg("dim", truncateToWidth(hint, innerWidth, Ellipsis.Unicode))} `);
752
+ lines.push(` ${theme.fg("dim", truncate2(hint, innerWidth))} `);
677
753
  return lines;
678
754
  },
679
755
  handleInput(data) {
680
756
  if (disposed) return false;
681
757
  if (!editSession) {
682
758
  if (queue.length === 0) return false;
683
- if (!options.editor?.getText().trim() && matchesKey(data, Key.enter)) {
759
+ if (!options.editor?.getText().trim() && isKey(data, "enter")) {
684
760
  const head = queue.peek();
685
761
  if (head) {
686
762
  queue.setPaused(head.id, false);
@@ -688,14 +764,14 @@ function createConversationQueue(options) {
688
764
  }
689
765
  return true;
690
766
  }
691
- if (actionMatches(data, "app.message.dequeue", (input) => matchesKey(input, DEQUEUE_FALLBACK))) {
767
+ if (actionMatches(data, "app.message.dequeue", (input) => isKey(input, DEQUEUE_FALLBACK))) {
692
768
  return startEditing();
693
769
  }
694
770
  return false;
695
771
  }
696
772
  const session = editSession;
697
773
  const editor = options.editor;
698
- if (actionMatches(data, "app.message.dequeue", (input) => matchesKey(input, DEQUEUE_FALLBACK)) && editor) {
774
+ if (actionMatches(data, "app.message.dequeue", (input) => isKey(input, DEQUEUE_FALLBACK)) && editor) {
699
775
  const ordered = queue.snapshot();
700
776
  const index = ordered.findIndex((item) => item.id === session.selectedId);
701
777
  const target = index <= 0 ? ordered.at(-1) : ordered[index - 1];
@@ -704,7 +780,7 @@ function createConversationQueue(options) {
704
780
  return true;
705
781
  }
706
782
  const nextKeys = dequeueKeys();
707
- if (nextKeys.length > 0 && nextKeys.some((key) => matchesKey(data, key)) && editor) {
783
+ if (nextKeys.length > 0 && nextKeys.some((key) => isKey(data, key)) && editor) {
708
784
  const ordered = queue.snapshot();
709
785
  const index = ordered.findIndex((item) => item.id === session.selectedId);
710
786
  const target = index === -1 || index === ordered.length - 1 ? ordered[0] : ordered[index + 1];
@@ -712,12 +788,12 @@ function createConversationQueue(options) {
712
788
  requestRender();
713
789
  return true;
714
790
  }
715
- if (matchesKey(data, REMOVE_ROW_KEY)) {
791
+ if (isKey(data, REMOVE_ROW_KEY)) {
716
792
  session.toggleRemoved(session.selectedId);
717
793
  requestRender();
718
794
  return true;
719
795
  }
720
- if (matchesKey(data, PAUSE_ROW_KEY)) {
796
+ if (isKey(data, PAUSE_ROW_KEY)) {
721
797
  session.togglePaused(session.selectedId);
722
798
  requestRender();
723
799
  return true;
@@ -732,16 +808,16 @@ function createConversationQueue(options) {
732
808
  requestRender();
733
809
  return true;
734
810
  }
735
- if (matchesKey(data, TOGGLE_LANE_KEY)) {
811
+ if (isKey(data, TOGGLE_LANE_KEY)) {
736
812
  const current = queue.get(session.selectedId)?.lane;
737
813
  if (current) session.setLane(session.selectedId, current === "steer" ? "followUp" : "steer");
738
814
  requestRender();
739
815
  return true;
740
816
  }
741
- if (actionMatches(data, "tui.input.submit", (input) => matchesKey(input, Key.enter)) || actionMatches(data, "app.message.followUp", () => false)) {
817
+ if (actionMatches(data, "tui.input.submit", (input) => isKey(input, "enter")) || actionMatches(data, "app.message.followUp", () => false)) {
742
818
  return finishEditing(true);
743
819
  }
744
- if (actionMatches(data, "app.interrupt", (input) => matchesKey(input, Key.escape))) {
820
+ if (actionMatches(data, "app.interrupt", (input) => isKey(input, "escape"))) {
745
821
  return finishEditing(false);
746
822
  }
747
823
  editor?.handleInput?.(data);
@@ -1004,30 +1080,14 @@ var FabricConversationState = class {
1004
1080
  var FEEDBACK_TTL_MS = 8e3;
1005
1081
  var FOLLOW_UP_FALLBACK = ["alt+enter", "ctrl+q"];
1006
1082
  var TOOLS_EXPAND_FALLBACK = ["ctrl+o"];
1007
- var conversationEditorTheme = (theme, thinking) => ({
1008
- symbols: ompSymbolTheme,
1009
- borderColor: (value) => {
1010
- const level = thinking();
1011
- const color = level === "minimal" ? "thinkingMinimal" : level === "low" ? "thinkingLow" : level === "medium" ? "thinkingMedium" : level === "high" ? "thinkingHigh" : level === "xhigh" ? "thinkingXhigh" : level === "max" ? "thinkingMax" : "borderMuted";
1012
- return theme.fg(color, value);
1013
- },
1014
- selectList: {
1015
- selectedPrefix: (text) => theme.fg("accent", text),
1016
- selectedText: (text) => theme.fg("accent", text),
1017
- description: (text) => theme.fg("muted", text),
1018
- scrollInfo: (text) => theme.fg("muted", text),
1019
- noMatch: (text) => theme.fg("muted", text),
1020
- symbols: ompSymbolTheme
1021
- }
1022
- });
1083
+ var editorBorderColor = (thinking) => thinking === "minimal" ? "thinkingMinimal" : thinking === "low" ? "thinkingLow" : thinking === "medium" ? "thinkingMedium" : thinking === "high" ? "thinkingHigh" : thinking === "xhigh" ? "thinkingXhigh" : thinking === "max" ? "thinkingMax" : "borderMuted";
1023
1084
  var errorText2 = (error) => {
1024
1085
  if (error instanceof Error) return error.message;
1025
1086
  return String(error ?? "");
1026
1087
  };
1027
1088
  var isMainTarget = (target) => target?.kind === "main";
1028
1089
  var FabricConversationView = class {
1029
- focusState = true;
1030
- tui;
1090
+ host;
1031
1091
  theme;
1032
1092
  options;
1033
1093
  state;
@@ -1042,22 +1102,14 @@ var FabricConversationView = class {
1042
1102
  stopConfirmId;
1043
1103
  disposed = false;
1044
1104
  lastBodyLength = 0;
1045
- lastBody = [];
1046
1105
  lastBodyBudget = 1;
1047
- editorTop = 0;
1048
- editorHeight = 0;
1049
- ownsMouseMode = false;
1050
- constructor(tui, theme, options) {
1051
- this.tui = tui;
1106
+ constructor(host, theme, options) {
1107
+ this.host = host;
1052
1108
  this.theme = theme;
1053
1109
  this.options = options;
1054
1110
  this.state = options.state;
1055
- this.renderer = new FabricConversationTranscriptRenderer(tui, theme, {
1056
- ...options.rendererOptions,
1057
- imageWidthCells: options.appearance?.imageWidthCells
1058
- });
1059
- this.editor = new Editor(conversationEditorTheme(theme, () => this.currentTarget()?.thinking));
1060
- this.editor.focused = true;
1111
+ this.renderer = new FabricConversationTranscriptRenderer(host, theme, options.rendererOptions);
1112
+ this.editor = new TextField({ multiline: true });
1061
1113
  this.editor.onChange = (text) => {
1062
1114
  if (this.currentId && !this.state.queues.get(this.currentId)?.editingActive) this.state.view(this.currentId).draft = text;
1063
1115
  };
@@ -1067,22 +1119,6 @@ var FabricConversationView = class {
1067
1119
  const resolved = requested && requestedTarget && !isMainTarget(requestedTarget) ? requested : nonMain[0]?.id;
1068
1120
  if (resolved) this.applySelection(resolved, false);
1069
1121
  if (!this.currentId) this.currentId = nonMain[0]?.id;
1070
- if (true) {
1071
- tui.terminal.write("\x1B[?1000h\x1B[?1006h");
1072
- this.ownsMouseMode = true;
1073
- }
1074
- }
1075
- get focused() {
1076
- return this.focusState;
1077
- }
1078
- set focused(value) {
1079
- this.focusState = value;
1080
- if (this.mode === "picker") {
1081
- if (this.pickerInput) this.pickerInput.focused = value;
1082
- if (this.editor) this.editor.focused = false;
1083
- return;
1084
- }
1085
- if (this.editor) this.editor.focused = value;
1086
1122
  }
1087
1123
  /** Re-focus a target while the view is open; selecting Main closes to the native session. */
1088
1124
  selectTarget(id) {
@@ -1090,33 +1126,22 @@ var FabricConversationView = class {
1090
1126
  }
1091
1127
  handleInput(data) {
1092
1128
  if (this.disposed) return;
1093
- const mouse = /^\x1b\[<(\d+);(\d+);(\d+)([Mm])$/.exec(data);
1094
- if (mouse) {
1095
- const button = Number(mouse[1]);
1096
- if ((button & 64) !== 0 && mouse[4] === "M") {
1097
- this.handleMouse({ button, col: Number(mouse[2]) - 1, row: Number(mouse[3]) - 1, release: false, wheel: (button & 1) === 0 ? -1 : 1, motion: false, leftClick: false });
1098
- }
1099
- return;
1100
- }
1101
1129
  if (this.mode === "picker") {
1102
1130
  this.handlePickerInput(data);
1103
- this.tui.requestRender();
1131
+ this.host.requestRender();
1104
1132
  return;
1105
1133
  }
1106
1134
  this.handleConversationInput(data);
1107
- this.tui.requestRender();
1135
+ this.host.requestRender();
1108
1136
  }
1109
- handleMouse(event) {
1137
+ handleWheel(rows) {
1110
1138
  if (this.disposed) return;
1111
- if (event.wheel !== null) {
1112
- if (this.mode === "picker") this.movePickerSelection(event.wheel);
1113
- else this.scrollBy(event.wheel * 3);
1114
- this.tui.requestRender();
1115
- }
1139
+ if (this.mode === "picker") this.movePickerSelection(rows < 0 ? -1 : 1);
1140
+ else this.scrollBy(rows);
1116
1141
  }
1117
1142
  render(width) {
1118
1143
  if (this.disposed || width <= 0) return [];
1119
- const rows = Math.max(1, this.terminalRows());
1144
+ const rows = Math.max(1, this.host.size().rows);
1120
1145
  this.markCurrentTargetSeen();
1121
1146
  this.reconcileEditor();
1122
1147
  const target = this.currentTarget();
@@ -1126,7 +1151,7 @@ var FabricConversationView = class {
1126
1151
  let editorLines = this.mode === "conversation" && !(queue?.editingActive && queue.mode === "extension") ? this.renderEditorLines(width) : [];
1127
1152
  const editorBudget = Math.min(editorLines.length, Math.max(1, rows - (rows >= 6 ? 3 : 0)));
1128
1153
  if (editorLines.length > editorBudget) {
1129
- const cursor = Math.max(0, editorLines.findIndex((line) => line.includes(CURSOR_MARKER)));
1154
+ const cursor = (this.editor?.cursorRow ?? 0) + 1;
1130
1155
  const start = Math.max(0, Math.min(cursor - Math.floor(editorBudget / 2), editorLines.length - editorBudget));
1131
1156
  editorLines = editorLines.slice(start, start + editorBudget);
1132
1157
  }
@@ -1150,22 +1175,14 @@ var FabricConversationView = class {
1150
1175
  const hints = this.mode === "conversation" && remaining > 2 ? [this.hintsLine(width)] : [];
1151
1176
  remaining -= hints.length;
1152
1177
  const queueBudget = Math.max(0, remaining - 1);
1153
- if (queueLines.length > queueBudget) {
1154
- const cursor = queueLines.findIndex((line) => line.includes(CURSOR_MARKER));
1155
- const start = Math.max(0, Math.min(cursor < 0 ? 0 : cursor - Math.floor(queueBudget / 2), queueLines.length - queueBudget));
1156
- queueLines = queueLines.slice(start, start + queueBudget);
1157
- }
1178
+ if (queueLines.length > queueBudget) queueLines = queueLines.slice(0, queueBudget);
1158
1179
  remaining -= queueLines.length;
1159
- this.editorTop = rows - editorLines.length - footer.length - hints.length;
1160
- this.editorHeight = editorLines.length;
1161
1180
  const body = remaining <= 0 ? [] : this.mode === "picker" ? this.pickerLines(width, remaining) : this.windowBody(transcriptLines, remaining);
1162
1181
  while (body.length < remaining) body.push("");
1163
- return [...head, ...body.slice(0, remaining), ...queueLines, ...editorLines, ...footer, ...hints].slice(0, rows).map((line) => visibleWidth(line) <= width ? line : truncateToWidth2(line, width, ""));
1182
+ return [...head, ...body.slice(0, remaining), ...queueLines, ...editorLines, ...footer, ...hints].slice(0, rows).map((line) => visibleWidth(line) <= width ? line : truncate3(line, width, ""));
1164
1183
  }
1165
1184
  invalidate() {
1166
1185
  this.renderer.invalidate();
1167
- this.editor?.invalidate();
1168
- this.pickerInput?.invalidate();
1169
1186
  }
1170
1187
  dispose() {
1171
1188
  if (this.currentId) this.state.queues.detach(this.currentId);
@@ -1173,10 +1190,6 @@ var FabricConversationView = class {
1173
1190
  this.editor = void 0;
1174
1191
  this.pickerInput = void 0;
1175
1192
  this.renderer.dispose();
1176
- if (this.ownsMouseMode) {
1177
- this.ownsMouseMode = false;
1178
- this.tui.terminal.write("\x1B[?1000l\x1B[?1006l");
1179
- }
1180
1193
  }
1181
1194
  /** Keep the editor in sync with the shared session draft (e.g. after an ack
1182
1195
  * that landed while a previous view instance was disposed). */
@@ -1196,7 +1209,7 @@ var FabricConversationView = class {
1196
1209
  kind: "error",
1197
1210
  at: Date.now()
1198
1211
  };
1199
- if (requestRender) this.tui.requestRender();
1212
+ if (requestRender) this.host.requestRender();
1200
1213
  return;
1201
1214
  }
1202
1215
  if (isMainTarget(target)) {
@@ -1211,7 +1224,7 @@ var FabricConversationView = class {
1211
1224
  this.closePicker();
1212
1225
  this.feedback = void 0;
1213
1226
  this.editor?.setText(entry.draft);
1214
- if (requestRender) this.tui.requestRender();
1227
+ if (requestRender) this.host.requestRender();
1215
1228
  }
1216
1229
  markCurrentTargetSeen() {
1217
1230
  if (!this.currentId) return;
@@ -1235,27 +1248,21 @@ var FabricConversationView = class {
1235
1248
  targetById(id) {
1236
1249
  return this.currentTargets().find((target) => target.id === id);
1237
1250
  }
1238
- terminalRows() {
1239
- return this.tui.terminal?.rows ?? process.stdout.rows ?? 28;
1240
- }
1241
1251
  /**
1242
1252
  * Respects a configured binding; when an injected manager reports no keys
1243
1253
  * the binding is unbound (never falls back), and only the default global
1244
1254
  * manager (no injection) falls back to hard-coded keys.
1245
1255
  */
1246
1256
  bindingMatches(data, binding, fallbackKeys) {
1247
- if (this.options.keybindings) {
1248
- const keys2 = this.options.keybindings.getKeys(binding);
1249
- return keys2.length > 0 && this.options.keybindings.matches(data, binding);
1250
- }
1251
- const global = getKeybindings2();
1252
- const keys = global.getKeys(binding);
1253
- if (keys.length > 0) return global.matches(data, binding);
1254
- return fallbackKeys.some((key) => matchesKey2(data, key));
1257
+ const key = keyOf(data);
1258
+ if (!key) return false;
1259
+ const manager = this.options.keybindings ?? getKeybindings2();
1260
+ if (manager.keysFor(binding).length > 0) return manager.matches(key, binding);
1261
+ return !this.options.keybindings && fallbackKeys.includes(key.id);
1255
1262
  }
1256
1263
  bindingHint(binding, fallbackLabel) {
1257
1264
  const manager = this.options.keybindings ?? getKeybindings2();
1258
- const keys = manager.getKeys(binding);
1265
+ const keys = manager.keysFor(binding);
1259
1266
  if (keys.length > 0) return keys.join("/");
1260
1267
  return this.options.keybindings ? "unbound" : fallbackLabel;
1261
1268
  }
@@ -1265,13 +1272,13 @@ var FabricConversationView = class {
1265
1272
  this.feedback = void 0;
1266
1273
  if (this.stopConfirmId === void 0 && this.currentQueue()?.handleInput(data)) return;
1267
1274
  if (this.stopConfirmId !== void 0) {
1268
- if (matchesKey2(data, Key2.enter)) {
1275
+ if (isKey(data, "enter")) {
1269
1276
  const target = this.targetById(this.stopConfirmId);
1270
1277
  this.stopConfirmId = void 0;
1271
1278
  if (target) this.dispatchStop(target);
1272
1279
  return;
1273
1280
  }
1274
- if (matchesKey2(data, Key2.escape)) {
1281
+ if (isKey(data, "escape")) {
1275
1282
  this.stopConfirmId = void 0;
1276
1283
  this.feedback = { text: "Stop cancelled", kind: "info", at: Date.now() };
1277
1284
  return;
@@ -1282,86 +1289,87 @@ var FabricConversationView = class {
1282
1289
  this.submit("followUp");
1283
1290
  return;
1284
1291
  }
1285
- if (matchesKey2(data, Key2.enter)) {
1292
+ if (isKey(data, "enter")) {
1286
1293
  this.submit("steer");
1287
1294
  return;
1288
1295
  }
1289
- if (matchesKey2(data, Key2.ctrl("c"))) {
1296
+ if (isKey(data, "ctrl+c")) {
1290
1297
  if (editor.getText().length > 0) editor.setText("");
1291
1298
  return;
1292
1299
  }
1293
- if (matchesKey2(data, Key2.escape)) {
1300
+ if (isKey(data, "escape")) {
1294
1301
  this.options.close();
1295
1302
  return;
1296
1303
  }
1297
- if (matchesKey2(data, Key2.ctrl("n"))) {
1304
+ if (isKey(data, "ctrl+n")) {
1298
1305
  this.openPicker();
1299
1306
  return;
1300
1307
  }
1301
- if (matchesKey2(data, "ctrl+tab")) {
1308
+ if (isKey(data, "ctrl+tab")) {
1302
1309
  this.cycleTarget(1);
1303
1310
  return;
1304
1311
  }
1305
- if (matchesKey2(data, "shift+ctrl+tab")) {
1312
+ if (isKey(data, "ctrl+shift+tab")) {
1306
1313
  this.cycleTarget(-1);
1307
1314
  return;
1308
1315
  }
1309
- if (matchesKey2(data, "ctrl+shift+left")) {
1316
+ if (isKey(data, "ctrl+shift+left")) {
1310
1317
  this.navigateParent();
1311
1318
  return;
1312
1319
  }
1313
- if (matchesKey2(data, "ctrl+shift+right")) {
1320
+ if (isKey(data, "ctrl+shift+right")) {
1314
1321
  this.navigateFirstChild();
1315
1322
  return;
1316
1323
  }
1317
- if (matchesKey2(data, "alt+left") && editor.getText().length === 0) {
1324
+ if (isKey(data, "alt+left") && editor.getText().length === 0) {
1318
1325
  this.navigateParent();
1319
1326
  return;
1320
1327
  }
1321
- if (matchesKey2(data, "alt+right") && editor.getText().length === 0) {
1328
+ if (isKey(data, "alt+right") && editor.getText().length === 0) {
1322
1329
  this.navigateFirstChild();
1323
1330
  return;
1324
1331
  }
1332
+ const key = keyOf(data);
1325
1333
  const injectedKeys = this.options.keybindings;
1326
1334
  const globalKeys = getKeybindings2();
1327
- const matchesViewport = (data2, action) => (injectedKeys ? injectedKeys.matches(data2, action) : false) || globalKeys.matches(data2, action);
1328
- if (matchesViewport(data, "tui.editor.jumpBackward")) {
1335
+ const matchesViewport = (action) => key !== void 0 && ((injectedKeys?.matches(key, action) ?? false) || globalKeys.matches(key, action));
1336
+ if (matchesViewport("tui.editor.jumpBackward")) {
1329
1337
  this.scrollPrompt(-1);
1330
1338
  return;
1331
1339
  }
1332
- if (matchesViewport(data, "tui.editor.jumpForward")) {
1340
+ if (matchesViewport("tui.editor.jumpForward")) {
1333
1341
  this.scrollPrompt(1);
1334
1342
  return;
1335
1343
  }
1336
- if (matchesViewport(data, "tui.editor.cursorUp")) {
1344
+ if (matchesViewport("tui.editor.cursorUp")) {
1337
1345
  this.scrollBy(-1);
1338
1346
  return;
1339
1347
  }
1340
- if (matchesViewport(data, "tui.editor.cursorDown")) {
1348
+ if (matchesViewport("tui.editor.cursorDown")) {
1341
1349
  this.scrollBy(1);
1342
1350
  return;
1343
1351
  }
1344
- if (matchesViewport(data, "tui.editor.pageUp")) {
1352
+ if (matchesViewport("tui.editor.pageUp")) {
1345
1353
  this.scrollBy(-Math.max(1, this.lastBodyBudget - 2));
1346
1354
  return;
1347
1355
  }
1348
- if (matchesViewport(data, "tui.editor.pageDown")) {
1356
+ if (matchesViewport("tui.editor.pageDown")) {
1349
1357
  this.scrollBy(Math.max(1, this.lastBodyBudget - 2));
1350
1358
  return;
1351
1359
  }
1352
- if (matchesViewport(data, "tui.editor.cursorWordLeft")) {
1360
+ if (matchesViewport("tui.editor.cursorWordLeft")) {
1353
1361
  this.scrollBy(-Math.max(1, Math.floor(this.lastBodyBudget / 2)));
1354
1362
  return;
1355
1363
  }
1356
- if (matchesViewport(data, "tui.editor.cursorWordRight")) {
1364
+ if (matchesViewport("tui.editor.cursorWordRight")) {
1357
1365
  this.scrollBy(Math.max(1, Math.floor(this.lastBodyBudget / 2)));
1358
1366
  return;
1359
1367
  }
1360
- if (matchesViewport(data, "tui.editor.cursorLineStart")) {
1368
+ if (matchesViewport("tui.editor.cursorLineStart")) {
1361
1369
  this.scrollToTop();
1362
1370
  return;
1363
1371
  }
1364
- if (matchesViewport(data, "tui.editor.cursorLineEnd")) {
1372
+ if (matchesViewport("tui.editor.cursorLineEnd")) {
1365
1373
  this.followLatest();
1366
1374
  return;
1367
1375
  }
@@ -1480,7 +1488,7 @@ var FabricConversationView = class {
1480
1488
  kind: "info",
1481
1489
  at: Date.now()
1482
1490
  };
1483
- this.tui.requestRender();
1491
+ this.host.requestRender();
1484
1492
  }).catch((error) => {
1485
1493
  if (this.state.epoch !== epoch) return;
1486
1494
  this.state.failPendingSend(target.id, raw);
@@ -1492,7 +1500,7 @@ var FabricConversationView = class {
1492
1500
  kind: "error",
1493
1501
  at: Date.now()
1494
1502
  };
1495
- this.tui.requestRender();
1503
+ this.host.requestRender();
1496
1504
  });
1497
1505
  }
1498
1506
  dispatchStop(target) {
@@ -1509,7 +1517,7 @@ var FabricConversationView = class {
1509
1517
  kind: "info",
1510
1518
  at: Date.now()
1511
1519
  };
1512
- this.tui.requestRender();
1520
+ this.host.requestRender();
1513
1521
  }).catch((error) => {
1514
1522
  if (this.disposed || epoch !== this.state.epoch) return;
1515
1523
  this.feedback = {
@@ -1517,7 +1525,7 @@ var FabricConversationView = class {
1517
1525
  kind: "error",
1518
1526
  at: Date.now()
1519
1527
  };
1520
- this.tui.requestRender();
1528
+ this.host.requestRender();
1521
1529
  });
1522
1530
  }
1523
1531
  navigateParent() {
@@ -1568,7 +1576,7 @@ var FabricConversationView = class {
1568
1576
  if (!this.currentId) return;
1569
1577
  const entry = this.state.view(this.currentId);
1570
1578
  const position = entry.following ? Math.max(0, this.lastBodyLength - this.lastBodyBudget) : entry.scroll;
1571
- const prompts = this.lastBody.flatMap((line, index) => line.includes("\x1B]133;A") ? [index] : []);
1579
+ const prompts = this.renderer.promptRows;
1572
1580
  const target = direction < 0 ? prompts.filter((row) => row < position).at(-1) : prompts.find((row) => row > position);
1573
1581
  this.scrollBy(target === void 0 ? direction * Math.max(1, this.lastBodyBudget) : target - position);
1574
1582
  }
@@ -1589,8 +1597,7 @@ var FabricConversationView = class {
1589
1597
  }
1590
1598
  openPicker() {
1591
1599
  this.mode = "picker";
1592
- this.pickerInput = new Input();
1593
- this.pickerInput.focused = this.focusState;
1600
+ this.pickerInput = new TextField();
1594
1601
  this.pickerInput.onSubmit = () => this.pickSelected();
1595
1602
  if (this.editor) this.editor.focused = false;
1596
1603
  this.pickerSelectedId = this.currentId ?? this.nonMainTargets()[0]?.id;
@@ -1601,10 +1608,10 @@ var FabricConversationView = class {
1601
1608
  this.pickerInput = void 0;
1602
1609
  this.pickerRows = [];
1603
1610
  this.pickerSelectedId = void 0;
1604
- if (this.editor) this.editor.focused = this.focusState;
1611
+ if (this.editor) this.editor.focused = true;
1605
1612
  }
1606
1613
  refreshPicker() {
1607
- const search = this.pickerInput?.getValue() ?? "";
1614
+ const search = this.pickerInput?.getText() ?? "";
1608
1615
  const rows = [];
1609
1616
  const targets = this.currentTargets();
1610
1617
  const byId = new Map(targets.map((target) => [target.id, target]));
@@ -1661,19 +1668,19 @@ var FabricConversationView = class {
1661
1668
  this.closePicker();
1662
1669
  return;
1663
1670
  }
1664
- if (matchesKey2(data, Key2.escape)) {
1671
+ if (isKey(data, "escape")) {
1665
1672
  this.closePicker();
1666
1673
  return;
1667
1674
  }
1668
- if (matchesKey2(data, Key2.up)) {
1675
+ if (isKey(data, "up")) {
1669
1676
  this.movePickerSelection(-1);
1670
1677
  return;
1671
1678
  }
1672
- if (matchesKey2(data, Key2.down)) {
1679
+ if (isKey(data, "down")) {
1673
1680
  this.movePickerSelection(1);
1674
1681
  return;
1675
1682
  }
1676
- if (matchesKey2(data, Key2.enter)) {
1683
+ if (isKey(data, "enter")) {
1677
1684
  this.pickSelected();
1678
1685
  return;
1679
1686
  }
@@ -1698,7 +1705,7 @@ var FabricConversationView = class {
1698
1705
  const main = this.mainTarget();
1699
1706
  if (main) chain.push(main);
1700
1707
  }
1701
- if (chain.length === 0) return truncateToWidth2(this.theme.fg("dim", "Fabric"), width, "");
1708
+ if (chain.length === 0) return truncate3(this.theme.fg("dim", "Fabric"), width, "");
1702
1709
  const last = chain[chain.length - 1];
1703
1710
  const parts = chain.map((target, index) => {
1704
1711
  const isCurrent = target.id === this.currentId;
@@ -1706,7 +1713,7 @@ var FabricConversationView = class {
1706
1713
  const styled = isCurrent ? this.theme.fg("accent", name) : this.theme.fg("muted", name);
1707
1714
  return last && index === chain.length - 1 && this.isUnread(last) ? `${styled} \u25CF` : styled;
1708
1715
  });
1709
- return truncateToWidth2(parts.join(this.theme.fg("dim", " > ")), width, "");
1716
+ return truncate3(parts.join(this.theme.fg("dim", " > ")), width, "");
1710
1717
  }
1711
1718
  statusLine(width) {
1712
1719
  const target = this.currentTarget();
@@ -1721,14 +1728,14 @@ var FabricConversationView = class {
1721
1728
  if (target.readOnlyReason) {
1722
1729
  parts.push(this.theme.fg("warning", safeText(`read-only: ${target.readOnlyReason}`)));
1723
1730
  }
1724
- return truncateToWidth2(parts.join(this.theme.fg("dim", " \xB7 ")), width, "");
1731
+ return truncate3(parts.join(this.theme.fg("dim", " \xB7 ")), width, "");
1725
1732
  }
1726
1733
  currentFeedbackLine(width) {
1727
1734
  if (this.mode === "picker") return void 0;
1728
1735
  if (!this.feedback) return void 0;
1729
1736
  if (Date.now() - this.feedback.at > FEEDBACK_TTL_MS) return void 0;
1730
1737
  const color = this.feedback.kind === "error" ? "error" : "accent";
1731
- return truncateToWidth2(this.theme.fg(color, this.feedback.text), width, "");
1738
+ return truncate3(this.theme.fg(color, this.feedback.text), width, "");
1732
1739
  }
1733
1740
  hintsLine(width) {
1734
1741
  const followUpKeys = this.bindingHint("app.message.followUp", "alt+enter");
@@ -1746,12 +1753,13 @@ var FabricConversationView = class {
1746
1753
  "close"
1747
1754
  ];
1748
1755
  const full = [...hints, this.theme.fg("dim", toolsKeys), "tools"].join(" ");
1749
- return truncateToWidth2(full, width, "");
1756
+ return truncate3(full, width, "");
1750
1757
  }
1751
1758
  renderEditorLines(innerWidth) {
1752
1759
  const editor = this.editor;
1753
1760
  if (!editor) return [];
1754
- return [...editor.render(innerWidth)];
1761
+ const rule = this.theme.fg(editorBorderColor(this.currentTarget()?.thinking), "\u2500".repeat(Math.max(1, innerWidth)));
1762
+ return [rule, ...editor.render(innerWidth), rule];
1755
1763
  }
1756
1764
  currentQueue() {
1757
1765
  const target = this.currentTarget();
@@ -1776,7 +1784,7 @@ var FabricConversationView = class {
1776
1784
  if (kind === "error" && !this.disposed && this.currentId === target.id) this.feedback = { text: safeText(text), kind, at: Date.now() };
1777
1785
  },
1778
1786
  requestRender: () => {
1779
- if (!this.disposed && this.currentId === target.id) this.tui.requestRender();
1787
+ if (!this.disposed && this.currentId === target.id) this.host.requestRender();
1780
1788
  }
1781
1789
  });
1782
1790
  }
@@ -1789,16 +1797,11 @@ var FabricConversationView = class {
1789
1797
  return this.renderer.render(transcript, innerWidth, {
1790
1798
  target,
1791
1799
  toolsExpanded: entry.toolsExpanded,
1792
- hideThinking: entry.hideThinking ?? this.options.appearance?.hideThinkingBlock ?? false,
1793
- showImages: this.options.appearance?.showImages ?? true,
1794
- outputPad: this.options.appearance?.outputPad ?? 1,
1795
- ...this.options.appearance?.codeBlockIndent !== void 0 ? { codeBlockIndent: this.options.appearance.codeBlockIndent } : {},
1796
- codePreviewSettings: this.options.codePreviewSettings
1800
+ hideThinking: entry.hideThinking ?? this.options.appearance?.hideThinkingBlock ?? false
1797
1801
  });
1798
1802
  }
1799
1803
  windowBody(body, budget) {
1800
1804
  this.lastBodyLength = body.length;
1801
- this.lastBody = body;
1802
1805
  this.lastBodyBudget = budget;
1803
1806
  const entry = this.currentId ? this.state.view(this.currentId) : void 0;
1804
1807
  if (!entry) return body.slice(0, Math.max(0, budget));
@@ -1838,11 +1841,7 @@ var FabricConversationView = class {
1838
1841
  const unread = this.isUnread(row.target) ? this.theme.fg("accent", " \u25CF") : "";
1839
1842
  const label = isMainTarget(row.target) ? "Main (native session)" : `${safeText(row.target.name)} ${this.theme.fg("muted", `(${row.target.kind} \xB7 ${row.target.status})`)}`;
1840
1843
  lines.push(
1841
- truncateToWidth2(
1842
- `${indent}${marker}${selected ? this.theme.fg("accent", label) : label}${unread}`,
1843
- innerWidth,
1844
- ""
1845
- )
1844
+ truncate3(`${indent}${marker}${selected ? this.theme.fg("accent", label) : label}${unread}`, innerWidth, "")
1846
1845
  );
1847
1846
  }
1848
1847
  if (rows.length > listBudget) {