@aednzxy/smith-tui 0.0.0-stage → 0.1.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/README.md +160 -2
- package/dist/app/commands.js +58 -0
- package/dist/app/commands.js.map +1 -0
- package/dist/app/controller.js +5129 -0
- package/dist/app/controller.js.map +1 -0
- package/dist/app/state.js +266 -0
- package/dist/app/state.js.map +1 -0
- package/dist/cli.js +154 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/config.js +110 -0
- package/dist/client/config.js.map +1 -0
- package/dist/client/http.js +796 -0
- package/dist/client/http.js.map +1 -0
- package/dist/client/reducer.js +623 -0
- package/dist/client/reducer.js.map +1 -0
- package/dist/client/session-start.js +39 -0
- package/dist/client/session-start.js.map +1 -0
- package/dist/client/shell-ws.js +126 -0
- package/dist/client/shell-ws.js.map +1 -0
- package/dist/client/types.js +22 -0
- package/dist/client/types.js.map +1 -0
- package/dist/client/ws.js +233 -0
- package/dist/client/ws.js.map +1 -0
- package/dist/engine/color.js +142 -0
- package/dist/engine/color.js.map +1 -0
- package/dist/engine/editor.js +350 -0
- package/dist/engine/editor.js.map +1 -0
- package/dist/engine/input.js +351 -0
- package/dist/engine/input.js.map +1 -0
- package/dist/engine/screen.js +513 -0
- package/dist/engine/screen.js.map +1 -0
- package/dist/engine/terminal.js +163 -0
- package/dist/engine/terminal.js.map +1 -0
- package/dist/format/diff.js +85 -0
- package/dist/format/diff.js.map +1 -0
- package/dist/format/markdown.js +438 -0
- package/dist/format/markdown.js.map +1 -0
- package/dist/format/questions.js +78 -0
- package/dist/format/questions.js.map +1 -0
- package/dist/format/sessions.js +310 -0
- package/dist/format/sessions.js.map +1 -0
- package/dist/format/time.js +217 -0
- package/dist/format/time.js.map +1 -0
- package/dist/format/tools.js +169 -0
- package/dist/format/tools.js.map +1 -0
- package/dist/format/vt.js +233 -0
- package/dist/format/vt.js.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/theme/palettes.js +1651 -0
- package/dist/theme/palettes.js.map +1 -0
- package/dist/views/activity-view.js +212 -0
- package/dist/views/activity-view.js.map +1 -0
- package/dist/views/auth-view.js +85 -0
- package/dist/views/auth-view.js.map +1 -0
- package/dist/views/boards-view.js +163 -0
- package/dist/views/boards-view.js.map +1 -0
- package/dist/views/chat-view.js +626 -0
- package/dist/views/chat-view.js.map +1 -0
- package/dist/views/compute-view.js +281 -0
- package/dist/views/compute-view.js.map +1 -0
- package/dist/views/files-skills-view.js +209 -0
- package/dist/views/files-skills-view.js.map +1 -0
- package/dist/views/fleet-view.js +282 -0
- package/dist/views/fleet-view.js.map +1 -0
- package/dist/views/inspector-view.js +612 -0
- package/dist/views/inspector-view.js.map +1 -0
- package/dist/views/memory-view.js +316 -0
- package/dist/views/memory-view.js.map +1 -0
- package/dist/views/modals-view.js +709 -0
- package/dist/views/modals-view.js.map +1 -0
- package/dist/views/notes-view.js +133 -0
- package/dist/views/notes-view.js.map +1 -0
- package/dist/views/select-agent-view.js +153 -0
- package/dist/views/select-agent-view.js.map +1 -0
- package/dist/views/settings-view.js +538 -0
- package/dist/views/settings-view.js.map +1 -0
- package/dist/views/shell-layout.js +802 -0
- package/dist/views/shell-layout.js.map +1 -0
- package/package.json +47 -4
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
// Following Inspector trailing pane (ADR 189 / ADR 193):
|
|
2
|
+
// Overview, Tasks, Plan, Status cards, Background processes, Worktree Changes + Diff viewer,
|
|
3
|
+
// Pull Requests & Tickets, Subagents (AgentSessions), Session Compute, Private Notes, Browser status.
|
|
4
|
+
import { INSPECTOR_TABS } from '../app/state.js';
|
|
5
|
+
import { stringWidth, wrapParagraph } from '../engine/screen.js';
|
|
6
|
+
import { parseUnifiedDiff, styleDiffLine } from '../format/diff.js';
|
|
7
|
+
import { renderMarkdown } from '../format/markdown.js';
|
|
8
|
+
import { mergeConversations } from '../format/sessions.js';
|
|
9
|
+
import { formatDateTime, formatDurationMs, formatUsd, resolveTimeZone } from '../format/time.js';
|
|
10
|
+
export function getInspectorOverviewActions(slice, cb) {
|
|
11
|
+
return [
|
|
12
|
+
{ key: 'm', label: 'Change model / thinking effort / speed', run: cb.openModelPicker },
|
|
13
|
+
{ key: 'w', label: 'Schedule or manage session wake', run: cb.openWakeModal },
|
|
14
|
+
{ key: 'R', label: 'Rewind conversation to an earlier message', run: cb.openRewindModal },
|
|
15
|
+
{ key: 'B', label: 'Branch conversation from latest message', run: cb.openBranchModal },
|
|
16
|
+
...(slice.capabilities.sessionParticipantManagement
|
|
17
|
+
? [{ key: 'P', label: 'Manage shared conversation people', run: cb.openPeopleModal }]
|
|
18
|
+
: []),
|
|
19
|
+
{ key: 'r', label: 'Refresh inspector data', run: cb.refreshInspector },
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
export function getInspectorChangeFiles(sec) {
|
|
23
|
+
const out = [];
|
|
24
|
+
for (const src of sec.changes?.sources ?? []) {
|
|
25
|
+
const sourceTitle = src.title ?? src.profile ?? src.agentSessionId;
|
|
26
|
+
for (const f of src.files) {
|
|
27
|
+
out.push({
|
|
28
|
+
agentSessionId: src.agentSessionId,
|
|
29
|
+
sourceTitle,
|
|
30
|
+
path: f.path,
|
|
31
|
+
status: f.status,
|
|
32
|
+
additions: f.additions,
|
|
33
|
+
deletions: f.deletions,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
export function renderInspectorPane(buf, rect, state, slice, sec, theme, cb, opts) {
|
|
40
|
+
const asOverlay = opts?.asOverlay !== false;
|
|
41
|
+
const focused = asOverlay;
|
|
42
|
+
const bg = asOverlay ? theme.overlay ?? theme.panel : theme.panel;
|
|
43
|
+
if (!asOverlay) {
|
|
44
|
+
buf.fill(rect, { fg: theme.paper, bg });
|
|
45
|
+
buf.drawVLine(rect.x, rect.y, rect.h, {
|
|
46
|
+
fg: focused ? theme.accent : theme.hairline,
|
|
47
|
+
bg,
|
|
48
|
+
});
|
|
49
|
+
buf.pushClip({ x: rect.x + 1, y: rect.y, w: Math.max(1, rect.w - 1), h: rect.h });
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
buf.pushClip(rect);
|
|
53
|
+
}
|
|
54
|
+
const innerX = asOverlay ? rect.x + 2 : rect.x + 2;
|
|
55
|
+
const innerW = Math.max(8, asOverlay ? rect.w - 4 : rect.w - 3);
|
|
56
|
+
let y = rect.y;
|
|
57
|
+
// Compute badge counts per tab
|
|
58
|
+
const tasksWidget = slice.widgets.find((w) => w.payload.kind === 'tasks');
|
|
59
|
+
const planWidget = slice.widgets.find((w) => w.payload.kind === 'plan');
|
|
60
|
+
const statusWidgets = slice.widgets.filter((w) => w.payload.kind === 'status');
|
|
61
|
+
const bgWidget = slice.widgets.find((w) => w.payload.kind === 'background');
|
|
62
|
+
const prWidget = slice.widgets.find((w) => w.payload.kind === 'pull_requests');
|
|
63
|
+
const ticketWidget = slice.widgets.find((w) => w.payload.kind === 'tickets');
|
|
64
|
+
const counts = {};
|
|
65
|
+
if (tasksWidget?.payload.kind === 'tasks') {
|
|
66
|
+
const done = tasksWidget.payload.items.filter((t) => t.status === 'done').length;
|
|
67
|
+
counts.tasks = `${done}/${tasksWidget.payload.items.length}`;
|
|
68
|
+
}
|
|
69
|
+
if (planWidget)
|
|
70
|
+
counts.plan = '•';
|
|
71
|
+
if (statusWidgets.length > 0)
|
|
72
|
+
counts.status = String(statusWidgets.length);
|
|
73
|
+
if (bgWidget?.payload.kind === 'background' && bgWidget.payload.processes.length > 0) {
|
|
74
|
+
counts.background = String(bgWidget.payload.processes.length);
|
|
75
|
+
}
|
|
76
|
+
if (sec.changes && sec.changes.sources.length > 0) {
|
|
77
|
+
const fileCount = sec.changes.sources.reduce((acc, s) => acc + s.files.length, 0);
|
|
78
|
+
if (fileCount > 0)
|
|
79
|
+
counts.changes = String(fileCount);
|
|
80
|
+
}
|
|
81
|
+
const prCount = (prWidget?.payload.kind === 'pull_requests' ? prWidget.payload.items.length : 0) +
|
|
82
|
+
(ticketWidget?.payload.kind === 'tickets' ? ticketWidget.payload.items.length : 0);
|
|
83
|
+
if (prCount > 0)
|
|
84
|
+
counts.prs = String(prCount);
|
|
85
|
+
if (sec.subagents.length > 0)
|
|
86
|
+
counts.subagents = String(sec.subagents.length);
|
|
87
|
+
if (sec.sessionCompute && sec.sessionCompute.workloads.length > 0)
|
|
88
|
+
counts.compute = String(sec.sessionCompute.workloads.length);
|
|
89
|
+
if (sec.sessionNote?.text.trim())
|
|
90
|
+
counts.notes = '•';
|
|
91
|
+
if (sec.browsers.length > 0)
|
|
92
|
+
counts.browser = String(sec.browsers.length);
|
|
93
|
+
if (!asOverlay) {
|
|
94
|
+
buf.drawTruncated(innerX, y, 'Inspector ([ / ] tabs · r refresh)', innerW, {
|
|
95
|
+
fg: focused ? theme.accent : theme.paper,
|
|
96
|
+
bg,
|
|
97
|
+
bold: true,
|
|
98
|
+
});
|
|
99
|
+
y += 1;
|
|
100
|
+
}
|
|
101
|
+
const tabShortcuts = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'b'];
|
|
102
|
+
let tx = innerX;
|
|
103
|
+
let tabRow = y;
|
|
104
|
+
for (let i = 0; i < INSPECTOR_TABS.length; i++) {
|
|
105
|
+
const t = INSPECTOR_TABS[i];
|
|
106
|
+
const key = tabShortcuts[i] ?? '';
|
|
107
|
+
const badge = counts[t.id] ? `:${counts[t.id]}` : '';
|
|
108
|
+
const lbl = `${key} ${t.label}${badge}`;
|
|
109
|
+
const w = stringWidth(lbl) + (activePad(state.inspectorTab === t.id) ? 2 : 0);
|
|
110
|
+
if (tx + w > innerX + innerW && tx > innerX) {
|
|
111
|
+
tabRow += 1;
|
|
112
|
+
tx = innerX;
|
|
113
|
+
}
|
|
114
|
+
if (tabRow > y + 2)
|
|
115
|
+
break;
|
|
116
|
+
const active = state.inspectorTab === t.id;
|
|
117
|
+
const drawStr = active ? ` ${lbl} ` : lbl;
|
|
118
|
+
buf.drawText(tx, tabRow, drawStr, {
|
|
119
|
+
fg: active ? theme.accent : counts[t.id] ? theme.paper : theme.muted,
|
|
120
|
+
bg: active ? theme.accentTint ?? theme.sunken : bg,
|
|
121
|
+
bold: active,
|
|
122
|
+
});
|
|
123
|
+
state.hitRegions.push({ rect: { x: tx, y: tabRow, w: stringWidth(drawStr), h: 1 }, action: () => cb.selectTab(t.id) });
|
|
124
|
+
tx += stringWidth(drawStr) + 1;
|
|
125
|
+
}
|
|
126
|
+
y = tabRow + 1;
|
|
127
|
+
buf.drawHLine(asOverlay ? rect.x + 1 : rect.x + 1, y, rect.w - (asOverlay ? 2 : 1), { fg: theme.hairline, bg });
|
|
128
|
+
y += 1;
|
|
129
|
+
const bodyRect = { x: innerX, y, w: innerW, h: Math.max(1, rect.y + rect.h - y) };
|
|
130
|
+
state.hitRegions.push({
|
|
131
|
+
rect: bodyRect,
|
|
132
|
+
action: cb.focusInspector,
|
|
133
|
+
onWheel: cb.scrollInspector,
|
|
134
|
+
});
|
|
135
|
+
const tz = resolveTimeZone(state.account?.user.timezone);
|
|
136
|
+
switch (state.inspectorTab) {
|
|
137
|
+
case 'overview':
|
|
138
|
+
renderInspectorOverview(buf, bodyRect, state, slice, theme, tz, bg, cb);
|
|
139
|
+
break;
|
|
140
|
+
case 'tasks':
|
|
141
|
+
renderInspectorTasks(buf, bodyRect, slice, state.inspectorScroll, theme, bg);
|
|
142
|
+
break;
|
|
143
|
+
case 'plan':
|
|
144
|
+
renderInspectorPlan(buf, bodyRect, slice, state.inspectorScroll, theme, bg);
|
|
145
|
+
break;
|
|
146
|
+
case 'status':
|
|
147
|
+
renderInspectorStatusCards(buf, bodyRect, slice, state.inspectorScroll, theme, bg);
|
|
148
|
+
break;
|
|
149
|
+
case 'background':
|
|
150
|
+
renderInspectorBackground(buf, bodyRect, state, slice, theme, bg, cb);
|
|
151
|
+
break;
|
|
152
|
+
case 'changes':
|
|
153
|
+
renderInspectorChanges(buf, bodyRect, state, sec, theme, bg, cb);
|
|
154
|
+
break;
|
|
155
|
+
case 'prs':
|
|
156
|
+
renderInspectorPrs(buf, bodyRect, slice, sec, theme, bg);
|
|
157
|
+
break;
|
|
158
|
+
case 'subagents':
|
|
159
|
+
renderInspectorSubagents(buf, bodyRect, state, sec, theme, bg, cb);
|
|
160
|
+
break;
|
|
161
|
+
case 'compute':
|
|
162
|
+
renderInspectorCompute(buf, bodyRect, sec, theme, bg);
|
|
163
|
+
break;
|
|
164
|
+
case 'notes':
|
|
165
|
+
renderInspectorNotes(buf, bodyRect, state, sec, theme, bg, cb);
|
|
166
|
+
break;
|
|
167
|
+
case 'browser':
|
|
168
|
+
renderInspectorBrowser(buf, bodyRect, sec, theme, bg);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
buf.popClip();
|
|
172
|
+
}
|
|
173
|
+
function activePad(active) {
|
|
174
|
+
return active;
|
|
175
|
+
}
|
|
176
|
+
function renderInspectorOverview(buf, rect, state, slice, theme, tz, bg, cb) {
|
|
177
|
+
const merged = mergeConversations(slice.wsSessions, slice.httpSessions, slice.readState);
|
|
178
|
+
const conv = slice.selectedSessionId ? merged.find((c) => c.sessionId === slice.selectedSessionId) ?? null : null;
|
|
179
|
+
let y = rect.y;
|
|
180
|
+
const maxY = rect.y + rect.h;
|
|
181
|
+
const putKv = (k, v, color = theme.paper) => {
|
|
182
|
+
if (y >= maxY)
|
|
183
|
+
return;
|
|
184
|
+
buf.drawTruncated(rect.x, y, k, 13, { fg: theme.muted, bg });
|
|
185
|
+
buf.drawTruncated(rect.x + 14, y, v, Math.max(4, rect.w - 14), { fg: color, bg });
|
|
186
|
+
y += 1;
|
|
187
|
+
};
|
|
188
|
+
putKv('Session', slice.draftMode ? '(draft)' : slice.selectedSessionId ?? '—', theme.paper);
|
|
189
|
+
putKv('Model', slice.sessionSelection === 'auto' ? `Auto (${slice.sessionModel})` : slice.sessionModel || slice.defaultModel || '—', theme.accent);
|
|
190
|
+
if (slice.effectiveReasoning) {
|
|
191
|
+
putKv('Reasoning', `${slice.effectiveReasoning.thinking} · ${slice.effectiveReasoning.speed}`, theme.cyan);
|
|
192
|
+
}
|
|
193
|
+
if (slice.modelFallback) {
|
|
194
|
+
putKv('Fallback', `${slice.modelFallback.fromModel} -> ${slice.modelFallback.toModel}`, theme.amber);
|
|
195
|
+
}
|
|
196
|
+
if (slice.contextLimit && slice.contextLimit > 0) {
|
|
197
|
+
const ratio = slice.contextTokens / slice.contextLimit;
|
|
198
|
+
const pct = Math.min(100, Math.round(ratio * 100));
|
|
199
|
+
putKv('Context', `${pct}% (${slice.contextTokens.toLocaleString()}/${slice.contextLimit.toLocaleString()})`, pct >= 85 ? theme.amber : theme.paper);
|
|
200
|
+
if (y < maxY) {
|
|
201
|
+
buf.drawProgressBar(rect.x, y, Math.min(rect.w, 32), ratio, { fg: pct >= 90 ? theme.red : pct >= 80 ? theme.amber : theme.accent, bg }, { fg: theme.hairline, bg });
|
|
202
|
+
y += 1;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
putKv('Compactions', String(slice.compactions));
|
|
206
|
+
putKv('Session cost', formatUsd(slice.totalCostUsd), theme.green);
|
|
207
|
+
if (conv?.nextWakeAt) {
|
|
208
|
+
putKv('Next wake', `${formatDateTime(conv.nextWakeAt, tz)}${conv.wakeCron ? ` (${conv.wakeCron})` : ''}`, theme.cyan);
|
|
209
|
+
if (conv.wakeNote)
|
|
210
|
+
putKv('Wake note', conv.wakeNote, theme.muted);
|
|
211
|
+
}
|
|
212
|
+
if (conv?.parentSessionId) {
|
|
213
|
+
putKv('Parent chat', conv.parentSessionId, theme.accent);
|
|
214
|
+
}
|
|
215
|
+
if (conv && conv.childCount > 0) {
|
|
216
|
+
putKv('Children', `${conv.childCount} chats · ${conv.doneChildCount} done`, theme.paper);
|
|
217
|
+
}
|
|
218
|
+
y += 1;
|
|
219
|
+
if (y < maxY) {
|
|
220
|
+
buf.drawText(rect.x, y, 'Quick actions (j/k + Enter, or press shortcut)', { fg: theme.muted, bg, bold: true });
|
|
221
|
+
y += 1;
|
|
222
|
+
}
|
|
223
|
+
const actions = getInspectorOverviewActions(slice, cb);
|
|
224
|
+
const cur = Math.max(0, Math.min(actions.length - 1, state.inspectorCursor));
|
|
225
|
+
for (let i = 0; i < actions.length; i++) {
|
|
226
|
+
const act = actions[i];
|
|
227
|
+
if (y >= maxY)
|
|
228
|
+
break;
|
|
229
|
+
const sel = i === cur;
|
|
230
|
+
const rowBg = sel ? theme.accentTint ?? theme.sunken : bg;
|
|
231
|
+
buf.fill({ x: rect.x, y, w: Math.min(rect.w, 60), h: 1 }, { fg: theme.paper, bg: rowBg });
|
|
232
|
+
buf.drawText(rect.x + 1, y, `${sel ? '▸ ' : ' '}[${act.key}] `, { fg: theme.accent, bg: rowBg, bold: true });
|
|
233
|
+
buf.drawTruncated(rect.x + 7, y, act.label, Math.max(8, Math.min(rect.w, 60) - 8), {
|
|
234
|
+
fg: sel ? theme.accent : theme.paper,
|
|
235
|
+
bg: rowBg,
|
|
236
|
+
bold: sel,
|
|
237
|
+
});
|
|
238
|
+
state.hitRegions.push({ rect: { x: rect.x, y, w: Math.min(rect.w, 60), h: 1 }, action: act.run });
|
|
239
|
+
y += 1;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function renderInspectorTasks(buf, rect, slice, scroll, theme, bg) {
|
|
243
|
+
const widget = slice.widgets.find((w) => w.payload.kind === 'tasks');
|
|
244
|
+
if (!widget || widget.payload.kind !== 'tasks' || widget.payload.items.length === 0) {
|
|
245
|
+
buf.drawTruncated(rect.x, rect.y, 'No task list in this conversation.', rect.w, { fg: theme.muted, bg });
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const items = widget.payload.items;
|
|
249
|
+
const done = items.filter((t) => t.status === 'done').length;
|
|
250
|
+
buf.drawTruncated(rect.x, rect.y, `Tasks (${done}/${items.length} done)`, rect.w, { fg: theme.paper, bg, bold: true });
|
|
251
|
+
buf.drawProgressBar(rect.x, rect.y + 1, Math.min(rect.w, 32), done / Math.max(1, items.length), { fg: theme.green, bg }, { fg: theme.hairline, bg });
|
|
252
|
+
let y = rect.y + 3;
|
|
253
|
+
const start = Math.max(0, Math.min(scroll, Math.max(0, items.length - 1)));
|
|
254
|
+
for (let i = start; i < items.length && y < rect.y + rect.h; i++) {
|
|
255
|
+
const t = items[i];
|
|
256
|
+
const icon = t.status === 'done' ? '✓' : t.status === 'in_progress' ? '◐' : '○';
|
|
257
|
+
const color = t.status === 'done' ? theme.green : t.status === 'in_progress' ? theme.amber : theme.muted;
|
|
258
|
+
buf.drawText(rect.x, y, `${icon} `, { fg: color, bg, bold: true });
|
|
259
|
+
buf.drawTruncated(rect.x + 2, y, t.text, rect.w - 2, {
|
|
260
|
+
fg: t.status === 'done' ? theme.muted : theme.paper,
|
|
261
|
+
bg,
|
|
262
|
+
});
|
|
263
|
+
y += 1;
|
|
264
|
+
if (t.note && y < rect.y + rect.h) {
|
|
265
|
+
buf.drawTruncated(rect.x + 3, y, t.note, rect.w - 3, { fg: theme.muted, bg, dim: true });
|
|
266
|
+
y += 1;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function renderInspectorPlan(buf, rect, slice, scroll, theme, bg) {
|
|
271
|
+
const widget = slice.widgets.find((w) => w.payload.kind === 'plan');
|
|
272
|
+
if (!widget || widget.payload.kind !== 'plan') {
|
|
273
|
+
buf.drawTruncated(rect.x, rect.y, 'No plan document in this conversation.', rect.w, { fg: theme.muted, bg });
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const lines = renderMarkdown(widget.payload.markdown, rect.w, theme, bg);
|
|
277
|
+
const start = Math.max(0, Math.min(scroll, Math.max(0, lines.length - rect.h)));
|
|
278
|
+
for (let i = 0; i < rect.h && start + i < lines.length; i++) {
|
|
279
|
+
buf.drawSegments(rect.x, rect.y + i, lines[start + i].segments, rect.w);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function renderInspectorStatusCards(buf, rect, slice, scroll, theme, bg) {
|
|
283
|
+
const cards = slice.widgets.filter((w) => w.payload.kind === 'status');
|
|
284
|
+
if (cards.length === 0) {
|
|
285
|
+
buf.drawTruncated(rect.x, rect.y, 'No script status cards.', rect.w, { fg: theme.muted, bg });
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
let y = rect.y - Math.max(0, scroll);
|
|
289
|
+
for (const card of cards) {
|
|
290
|
+
if (card.payload.kind !== 'status')
|
|
291
|
+
continue;
|
|
292
|
+
if (y >= rect.y && y < rect.y + rect.h) {
|
|
293
|
+
buf.drawTruncated(rect.x, y, card.title ?? card.widgetId, rect.w, { fg: theme.accent, bg, bold: true });
|
|
294
|
+
}
|
|
295
|
+
y += 1;
|
|
296
|
+
for (const row of card.payload.rows) {
|
|
297
|
+
if (y >= rect.y && y < rect.y + rect.h) {
|
|
298
|
+
const c = row.state === 'ok' ? theme.green : row.state === 'error' ? theme.red : row.state === 'attention' || row.state === 'waiting' ? theme.amber : theme.paper;
|
|
299
|
+
buf.drawTruncated(rect.x + 1, y, `${row.label}: `, 16, { fg: theme.muted, bg });
|
|
300
|
+
buf.drawTruncated(rect.x + 17, y, row.value, Math.max(4, rect.w - 17), { fg: c, bg, bold: row.state === 'error' });
|
|
301
|
+
}
|
|
302
|
+
y += 1;
|
|
303
|
+
}
|
|
304
|
+
if (card.payload.footer) {
|
|
305
|
+
if (y >= rect.y && y < rect.y + rect.h) {
|
|
306
|
+
buf.drawTruncated(rect.x + 1, y, card.payload.footer, rect.w - 1, { fg: theme.muted, bg, dim: true });
|
|
307
|
+
}
|
|
308
|
+
y += 1;
|
|
309
|
+
}
|
|
310
|
+
y += 1;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function renderInspectorBackground(buf, rect, state, slice, theme, bg, cb) {
|
|
314
|
+
const widget = slice.widgets.find((w) => w.payload.kind === 'background');
|
|
315
|
+
if (!widget || widget.payload.kind !== 'background' || widget.payload.processes.length === 0) {
|
|
316
|
+
buf.drawTruncated(rect.x, rect.y, 'No background processes.', rect.w, { fg: theme.muted, bg });
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const procs = widget.payload.processes;
|
|
320
|
+
const cur = Math.max(0, Math.min(procs.length - 1, state.inspectorCursor));
|
|
321
|
+
let y = rect.y;
|
|
322
|
+
for (let i = 0; i < procs.length; i++) {
|
|
323
|
+
const p = procs[i];
|
|
324
|
+
if (y >= rect.y + rect.h)
|
|
325
|
+
break;
|
|
326
|
+
const sel = i === cur;
|
|
327
|
+
const rowBg = sel ? theme.accentTint ?? theme.sunken : bg;
|
|
328
|
+
const color = p.state === 'running' ? theme.green : p.state === 'killed' ? theme.red : theme.muted;
|
|
329
|
+
buf.fill({ x: rect.x, y, w: rect.w, h: 1 }, { fg: theme.paper, bg: rowBg });
|
|
330
|
+
buf.drawTruncated(rect.x, y, `${sel ? '▸ ' : ' '}● ${p.state} · ${p.command}`, rect.w - 12, { fg: color, bg: rowBg, bold: true });
|
|
331
|
+
if (p.state === 'running') {
|
|
332
|
+
const sx = rect.x + rect.w - 11;
|
|
333
|
+
buf.drawText(sx, y, ' Stop (x) ', { fg: theme.onAccent, bg: theme.red, bold: true });
|
|
334
|
+
state.hitRegions.push({ rect: { x: sx, y, w: 10, h: 1 }, action: () => cb.stopBackground(p.id) });
|
|
335
|
+
}
|
|
336
|
+
y += 1;
|
|
337
|
+
for (const line of p.tailLines.slice(-6)) {
|
|
338
|
+
if (y >= rect.y + rect.h)
|
|
339
|
+
break;
|
|
340
|
+
buf.drawTruncated(rect.x + 3, y, line, rect.w - 3, { fg: theme.muted, bg });
|
|
341
|
+
y += 1;
|
|
342
|
+
}
|
|
343
|
+
y += 1;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
function renderInspectorChanges(buf, rect, state, sec, theme, bg, cb) {
|
|
347
|
+
const files = getInspectorChangeFiles(sec);
|
|
348
|
+
if (files.length === 0) {
|
|
349
|
+
buf.drawTruncated(rect.x, rect.y, 'No worktree changes recorded for this chat.', rect.w, { fg: theme.muted, bg });
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
let y = rect.y;
|
|
353
|
+
const maxY = rect.y + rect.h;
|
|
354
|
+
if (sec.selectedDiff && sec.selectedDiff.ok) {
|
|
355
|
+
const backLabel = ' ← Files (Bksp/Esc) ';
|
|
356
|
+
buf.drawText(rect.x, y, backLabel, { fg: theme.accent, bg: theme.accentTint ?? theme.sunken, bold: true });
|
|
357
|
+
state.hitRegions.push({
|
|
358
|
+
rect: { x: rect.x, y, w: backLabel.length, h: 1 },
|
|
359
|
+
action: () => {
|
|
360
|
+
sec.selectedDiff = null;
|
|
361
|
+
sec.selectedDiffKey = null;
|
|
362
|
+
state.inspectorScroll = 0;
|
|
363
|
+
},
|
|
364
|
+
});
|
|
365
|
+
buf.drawTruncated(rect.x + backLabel.length + 1, y, sec.selectedDiff.path, Math.max(8, rect.w - backLabel.length - 1), {
|
|
366
|
+
fg: theme.paper,
|
|
367
|
+
bg,
|
|
368
|
+
bold: true,
|
|
369
|
+
});
|
|
370
|
+
y += 2;
|
|
371
|
+
const diffLines = parseUnifiedDiff(sec.selectedDiff.diff);
|
|
372
|
+
const start = Math.max(0, Math.min(state.inspectorScroll, Math.max(0, diffLines.length - (maxY - y))));
|
|
373
|
+
for (let i = start; i < diffLines.length && y < maxY; i++) {
|
|
374
|
+
const styled = styleDiffLine(diffLines[i], theme);
|
|
375
|
+
if (styled.bg)
|
|
376
|
+
buf.fill({ x: rect.x, y, w: rect.w, h: 1 }, { fg: theme.paper, bg: styled.bg });
|
|
377
|
+
buf.drawSegments(rect.x, y, styled.segments, rect.w);
|
|
378
|
+
y += 1;
|
|
379
|
+
}
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
buf.drawTruncated(rect.x, y, `${files.length} changed files (j/k select · Enter view diff)`, rect.w, { fg: theme.muted, bg, dim: true });
|
|
383
|
+
y += 1;
|
|
384
|
+
const cur = Math.max(0, Math.min(files.length - 1, state.inspectorCursor));
|
|
385
|
+
let lastSource = '';
|
|
386
|
+
for (let i = 0; i < files.length && y < maxY; i++) {
|
|
387
|
+
const f = files[i];
|
|
388
|
+
if (f.sourceTitle !== lastSource) {
|
|
389
|
+
lastSource = f.sourceTitle;
|
|
390
|
+
buf.drawTruncated(rect.x, y, `▸ ${f.sourceTitle}`, rect.w, { fg: theme.accent, bg, bold: true });
|
|
391
|
+
y += 1;
|
|
392
|
+
if (y >= maxY)
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
const sel = i === cur;
|
|
396
|
+
const rowBg = sel ? theme.accentTint ?? theme.sunken : bg;
|
|
397
|
+
const sc = f.status === 'added' ? theme.green : f.status === 'deleted' ? theme.red : theme.amber;
|
|
398
|
+
const stats = f.additions !== undefined || f.deletions !== undefined ? ` +${f.additions ?? 0}/-${f.deletions ?? 0}` : '';
|
|
399
|
+
buf.fill({ x: rect.x, y, w: rect.w, h: 1 }, { fg: theme.paper, bg: rowBg });
|
|
400
|
+
buf.drawText(rect.x + 1, y, `${sel ? '▸ ' : ' '}${f.status[0].toUpperCase()} `, { fg: sc, bg: rowBg, bold: true });
|
|
401
|
+
buf.drawTruncated(rect.x + 5, y, f.path + stats, Math.max(8, rect.w - 5), { fg: sel ? theme.accent : theme.paper, bg: rowBg, bold: sel });
|
|
402
|
+
state.hitRegions.push({
|
|
403
|
+
rect: { x: rect.x, y, w: rect.w, h: 1 },
|
|
404
|
+
action: () => {
|
|
405
|
+
state.inspectorCursor = i;
|
|
406
|
+
cb.openWorktreeDiff(f.agentSessionId, f.path);
|
|
407
|
+
},
|
|
408
|
+
});
|
|
409
|
+
y += 1;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
function renderInspectorPrs(buf, rect, slice, sec, theme, bg) {
|
|
413
|
+
const prs = slice.widgets.find((w) => w.payload.kind === 'pull_requests');
|
|
414
|
+
const tickets = slice.widgets.find((w) => w.payload.kind === 'tickets');
|
|
415
|
+
let y = rect.y;
|
|
416
|
+
const maxY = rect.y + rect.h;
|
|
417
|
+
if (prs?.payload.kind === 'pull_requests' && prs.payload.items.length > 0) {
|
|
418
|
+
buf.drawText(rect.x, y, 'Pull Requests', { fg: theme.accent, bg, bold: true });
|
|
419
|
+
y += 1;
|
|
420
|
+
for (const item of prs.payload.items) {
|
|
421
|
+
if (y >= maxY)
|
|
422
|
+
break;
|
|
423
|
+
const status = sec.prStatuses.find((s) => s.url === item.url);
|
|
424
|
+
const badge = status && status.ok ? `[${status.status}] ` : '';
|
|
425
|
+
const badgeColor = status && status.ok
|
|
426
|
+
? status.status === 'merged'
|
|
427
|
+
? theme.magenta
|
|
428
|
+
: status.status === 'open'
|
|
429
|
+
? theme.green
|
|
430
|
+
: status.status === 'draft'
|
|
431
|
+
? theme.amber
|
|
432
|
+
: theme.red
|
|
433
|
+
: theme.muted;
|
|
434
|
+
buf.drawText(rect.x, y, badge, { fg: badgeColor, bg, bold: true });
|
|
435
|
+
buf.drawTruncated(rect.x + stringWidth(badge), y, item.title ?? item.url, rect.w - stringWidth(badge), { fg: theme.paper, bg });
|
|
436
|
+
y += 1;
|
|
437
|
+
if (y < maxY) {
|
|
438
|
+
buf.drawTruncated(rect.x + 2, y, item.url, rect.w - 2, { fg: theme.muted, bg, dim: true });
|
|
439
|
+
y += 1;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
y += 1;
|
|
443
|
+
}
|
|
444
|
+
if (tickets?.payload.kind === 'tickets' && tickets.payload.items.length > 0) {
|
|
445
|
+
buf.drawText(rect.x, y, 'Tickets', { fg: theme.cyan, bg, bold: true });
|
|
446
|
+
y += 1;
|
|
447
|
+
for (const item of tickets.payload.items) {
|
|
448
|
+
if (y >= maxY)
|
|
449
|
+
break;
|
|
450
|
+
buf.drawTruncated(rect.x, y, item.title ?? item.url, rect.w, { fg: theme.paper, bg });
|
|
451
|
+
y += 1;
|
|
452
|
+
if (y < maxY) {
|
|
453
|
+
buf.drawTruncated(rect.x + 2, y, item.url, rect.w - 2, { fg: theme.muted, bg, dim: true });
|
|
454
|
+
y += 1;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
if (y === rect.y) {
|
|
459
|
+
buf.drawTruncated(rect.x, rect.y, 'No pull requests or tickets linked yet.', rect.w, { fg: theme.muted, bg });
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
function renderInspectorSubagents(buf, rect, state, sec, theme, bg, cb) {
|
|
463
|
+
if (sec.subagents.length === 0) {
|
|
464
|
+
buf.drawTruncated(rect.x, rect.y, 'No subagents spawned in this chat.', rect.w, { fg: theme.muted, bg });
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
let y = rect.y;
|
|
468
|
+
const maxY = rect.y + rect.h;
|
|
469
|
+
if (sec.selectedSubagentId && sec.selectedSubagentDetail) {
|
|
470
|
+
const det = sec.selectedSubagentDetail;
|
|
471
|
+
const back = ' ← List (Bksp/Esc) ';
|
|
472
|
+
buf.drawText(rect.x, y, back, { fg: theme.accent, bg: theme.accentTint ?? theme.sunken, bold: true });
|
|
473
|
+
state.hitRegions.push({
|
|
474
|
+
rect: { x: rect.x, y, w: back.length, h: 1 },
|
|
475
|
+
action: () => {
|
|
476
|
+
sec.selectedSubagentId = null;
|
|
477
|
+
sec.selectedSubagentDetail = null;
|
|
478
|
+
sec.selectedSubagentTranscript = null;
|
|
479
|
+
state.inspectorScroll = 0;
|
|
480
|
+
},
|
|
481
|
+
});
|
|
482
|
+
buf.drawTruncated(rect.x + back.length + 1, y, det.taskPreview ?? det.profile ?? det.id, Math.max(8, rect.w - back.length - 1), { fg: theme.paper, bg, bold: true });
|
|
483
|
+
y += 1;
|
|
484
|
+
buf.drawTruncated(rect.x, y, `State: ${det.state} · Profile: ${det.profile ?? 'default'}`, rect.w, {
|
|
485
|
+
fg: det.state === 'running' ? theme.green : det.state === 'awaiting_input' ? theme.amber : theme.muted,
|
|
486
|
+
bg,
|
|
487
|
+
});
|
|
488
|
+
y += 1;
|
|
489
|
+
let ax = rect.x;
|
|
490
|
+
const acts = [
|
|
491
|
+
{ label: ' Steer (s) ', action: 'steer', show: det.state === 'running' || det.state === 'awaiting_input' },
|
|
492
|
+
{ label: ' Resume (R) ', action: 'resume', show: det.state === 'completed' || det.state === 'stopped' || det.state === 'failed' },
|
|
493
|
+
{ label: ' Stop (x) ', action: 'stop', show: det.state === 'running' || det.state === 'starting' },
|
|
494
|
+
];
|
|
495
|
+
for (const a of acts) {
|
|
496
|
+
if (!a.show)
|
|
497
|
+
continue;
|
|
498
|
+
buf.drawText(ax, y, a.label, { fg: a.action === 'stop' ? theme.onAccent : theme.accent, bg: a.action === 'stop' ? theme.red : theme.sunken ?? theme.field, bold: true });
|
|
499
|
+
state.hitRegions.push({ rect: { x: ax, y, w: a.label.length, h: 1 }, action: () => cb.mutateSubagent(det.id, a.action) });
|
|
500
|
+
ax += a.label.length + 1;
|
|
501
|
+
}
|
|
502
|
+
y += 2;
|
|
503
|
+
const msgs = sec.selectedSubagentTranscript?.messages ?? [];
|
|
504
|
+
for (const m of msgs.slice(-14)) {
|
|
505
|
+
if (y >= maxY)
|
|
506
|
+
break;
|
|
507
|
+
buf.drawTruncated(rect.x, y, `${m.role === 'user' ? 'Prompt' : 'Child'}: ${(m.text ?? '').replace(/\s+/g, ' ')}`, rect.w, {
|
|
508
|
+
fg: m.role === 'user' ? theme.accent : theme.paper,
|
|
509
|
+
bg,
|
|
510
|
+
});
|
|
511
|
+
y += 1;
|
|
512
|
+
}
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
buf.drawTruncated(rect.x, y, `${sec.subagents.length} subagents (j/k select · Enter inspect)`, rect.w, { fg: theme.muted, bg, dim: true });
|
|
516
|
+
y += 1;
|
|
517
|
+
const cur = Math.max(0, Math.min(sec.subagents.length - 1, state.inspectorCursor));
|
|
518
|
+
for (let i = 0; i < sec.subagents.length && y < maxY; i++) {
|
|
519
|
+
const sub = sec.subagents[i];
|
|
520
|
+
const sel = i === cur;
|
|
521
|
+
const rowBg = sel ? theme.accentTint ?? theme.sunken : bg;
|
|
522
|
+
const color = sub.state === 'running' || sub.state === 'starting'
|
|
523
|
+
? theme.green
|
|
524
|
+
: sub.state === 'awaiting_input'
|
|
525
|
+
? theme.amber
|
|
526
|
+
: sub.state === 'failed'
|
|
527
|
+
? theme.red
|
|
528
|
+
: theme.muted;
|
|
529
|
+
buf.fill({ x: rect.x, y, w: rect.w, h: 1 }, { fg: theme.paper, bg: rowBg });
|
|
530
|
+
buf.drawTruncated(rect.x, y, `${sel ? '▸ ' : ' '}● ${sub.state} ${sub.taskPreview ?? sub.profile ?? sub.id}`, rect.w, { fg: color, bg: rowBg, bold: true });
|
|
531
|
+
state.hitRegions.push({
|
|
532
|
+
rect: { x: rect.x, y, w: rect.w, h: 1 },
|
|
533
|
+
action: () => {
|
|
534
|
+
state.inspectorCursor = i;
|
|
535
|
+
cb.openSubagent(sub.id);
|
|
536
|
+
},
|
|
537
|
+
});
|
|
538
|
+
y += 1;
|
|
539
|
+
if (y < maxY) {
|
|
540
|
+
const durMs = sub.startedAt && sub.completedAt
|
|
541
|
+
? Math.max(0, Date.parse(sub.completedAt) - Date.parse(sub.startedAt))
|
|
542
|
+
: null;
|
|
543
|
+
const meta = [sub.profile || 'default', `${sub.numTurns}t`, durMs !== null ? formatDurationMs(durMs) : '']
|
|
544
|
+
.filter(Boolean)
|
|
545
|
+
.join(' · ');
|
|
546
|
+
buf.drawTruncated(rect.x + 4, y, meta, rect.w - 4, { fg: theme.muted, bg, dim: true });
|
|
547
|
+
y += 1;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
function renderInspectorCompute(buf, rect, sec, theme, bg) {
|
|
552
|
+
const list = sec.sessionCompute?.workloads ?? [];
|
|
553
|
+
if (list.length === 0) {
|
|
554
|
+
buf.drawTruncated(rect.x, rect.y, 'No Compute workloads linked to this chat.', rect.w, { fg: theme.muted, bg });
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
let y = rect.y;
|
|
558
|
+
for (const w of list) {
|
|
559
|
+
if (y >= rect.y + rect.h)
|
|
560
|
+
break;
|
|
561
|
+
const color = w.state === 'running' ? theme.green : w.state === 'failed' ? theme.red : w.state === 'queued' ? theme.amber : theme.muted;
|
|
562
|
+
buf.drawTruncated(rect.x, y, `#${w.id} [${w.state}] ${w.title ?? w.kind}`, rect.w, { fg: color, bg, bold: true });
|
|
563
|
+
y += 1;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
function renderInspectorNotes(buf, rect, state, sec, theme, bg, cb) {
|
|
567
|
+
let y = rect.y;
|
|
568
|
+
buf.drawText(rect.x, y, 'Private session note', { fg: theme.paper, bg, bold: true });
|
|
569
|
+
const editLbl = ' Edit (e) ';
|
|
570
|
+
const ex = rect.x + rect.w - editLbl.length;
|
|
571
|
+
buf.drawText(ex, y, editLbl, { fg: theme.onAccent, bg: theme.accent, bold: true });
|
|
572
|
+
state.hitRegions.push({ rect: { x: ex, y, w: editLbl.length, h: 1 }, action: cb.editSessionNote });
|
|
573
|
+
y += 2;
|
|
574
|
+
const text = sec.sessionNote?.text ?? '';
|
|
575
|
+
if (!text.trim()) {
|
|
576
|
+
buf.drawTruncated(rect.x, y, 'Your private scratchpad for this conversation. The agent never sees it. Press e or Enter to edit.', rect.w, { fg: theme.muted, bg });
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
for (const para of text.split('\n')) {
|
|
580
|
+
for (const wl of wrapParagraph(para, rect.w)) {
|
|
581
|
+
if (y >= rect.y + rect.h)
|
|
582
|
+
return;
|
|
583
|
+
buf.drawText(rect.x, y, wl, { fg: theme.paper, bg }, rect.w);
|
|
584
|
+
y += 1;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
function renderInspectorBrowser(buf, rect, sec, theme, bg) {
|
|
589
|
+
if (sec.browsers.length === 0) {
|
|
590
|
+
buf.drawTruncated(rect.x, rect.y, 'No active in-container browser session.', rect.w, { fg: theme.muted, bg });
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
let y = rect.y;
|
|
594
|
+
for (const b of sec.browsers) {
|
|
595
|
+
if (y >= rect.y + rect.h)
|
|
596
|
+
break;
|
|
597
|
+
buf.drawTruncated(rect.x, y, `● Browser ${b.id} (${b.tabs.length} tabs · ${b.state})`, rect.w, { fg: theme.green, bg, bold: true });
|
|
598
|
+
y += 1;
|
|
599
|
+
for (const t of b.tabs) {
|
|
600
|
+
if (y >= rect.y + rect.h)
|
|
601
|
+
break;
|
|
602
|
+
const isActive = t.id === b.activeTabId;
|
|
603
|
+
buf.drawTruncated(rect.x + 2, y, `${isActive ? '▸ ' : ' '}${t.title || t.url}`, rect.w - 2, { fg: isActive ? theme.accent : theme.paper, bg });
|
|
604
|
+
y += 1;
|
|
605
|
+
}
|
|
606
|
+
if (y < rect.y + rect.h) {
|
|
607
|
+
buf.drawTruncated(rect.x + 2, y, '(Live pixel viewer requires graphical app)', rect.w - 2, { fg: theme.muted, bg, dim: true });
|
|
608
|
+
y += 2;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
//# sourceMappingURL=inspector-view.js.map
|