@aednzxy/smith-tui 0.0.0-stage → 0.1.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.
- 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 +46 -4
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
// Centered modal overlays:
|
|
2
|
+
// Chats Picker (Ctrl+T / s), Full-Focus Inspector (i / Ctrl+\),
|
|
3
|
+
// Command Palette (Ctrl+K + live global search), Model/Thinking/Speed Picker,
|
|
4
|
+
// Rewind Picker, Branch Dialog, Wake Editor, People Dialog, Help Cheat Sheet (?),
|
|
5
|
+
// Theme Picker, Create Agent Wizard, Prompt Input, Confirm Dialog, and Full-Screen Text Editor.
|
|
6
|
+
import { stringWidth, truncateWidth, wrapParagraph } from '../engine/screen.js';
|
|
7
|
+
import { buildNavigatorRows, mergeConversations, } from '../format/sessions.js';
|
|
8
|
+
import { formatDateTime, formatRelativeAge, resolveTimeZone } from '../format/time.js';
|
|
9
|
+
import { TUI_PALETTES, TUI_PALETTE_LABELS } from '../theme/palettes.js';
|
|
10
|
+
import { renderInspectorPane } from './inspector-view.js';
|
|
11
|
+
export function getChatsOverlayRows(state, slice, filter, query) {
|
|
12
|
+
if (!slice)
|
|
13
|
+
return [];
|
|
14
|
+
const merged = mergeConversations(slice.wsSessions, slice.httpSessions, slice.readState);
|
|
15
|
+
return buildNavigatorRows(merged, {
|
|
16
|
+
filter,
|
|
17
|
+
query,
|
|
18
|
+
collapsedParents: state.collapsedParents,
|
|
19
|
+
timeZone: resolveTimeZone(state.account?.user.timezone),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function centerRect(buf, maxW, maxH) {
|
|
23
|
+
const w = Math.min(maxW, Math.max(32, buf.width - 4));
|
|
24
|
+
const h = Math.min(maxH, Math.max(10, buf.height - 4));
|
|
25
|
+
return {
|
|
26
|
+
x: Math.floor((buf.width - w) / 2),
|
|
27
|
+
y: Math.floor((buf.height - h) / 2),
|
|
28
|
+
w,
|
|
29
|
+
h,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function renderModal(buf, state, slice, sec, theme, cb) {
|
|
33
|
+
const modal = state.modal;
|
|
34
|
+
if (!modal)
|
|
35
|
+
return;
|
|
36
|
+
const bg = theme.overlay ?? theme.panel;
|
|
37
|
+
switch (modal.kind) {
|
|
38
|
+
case 'chats': {
|
|
39
|
+
const rect = centerRect(buf, Math.min(132, Math.max(56, buf.width - 6)), Math.min(34, Math.max(14, buf.height - 4)));
|
|
40
|
+
const agentName = slice?.agentName ?? state.activeAgentDir ?? 'Agent';
|
|
41
|
+
const rows = getChatsOverlayRows(state, slice, modal.filter, modal.editor.value);
|
|
42
|
+
const convIndices = [];
|
|
43
|
+
rows.forEach((r, idx) => {
|
|
44
|
+
if (r.kind === 'conversation')
|
|
45
|
+
convIndices.push(idx);
|
|
46
|
+
});
|
|
47
|
+
const clamped = convIndices.length > 0 ? Math.max(0, Math.min(convIndices.length - 1, modal.cursor)) : 0;
|
|
48
|
+
modal.cursor = clamped;
|
|
49
|
+
const countTag = convIndices.length > 0 ? ` (${clamped + 1}/${convIndices.length})` : '';
|
|
50
|
+
buf.drawBox(rect, { fg: theme.accent, bg }, {
|
|
51
|
+
fillStyle: { fg: theme.paper, bg },
|
|
52
|
+
title: `Conversations · ${agentName}${countTag}`,
|
|
53
|
+
titleStyle: { fg: theme.accent, bg, bold: true },
|
|
54
|
+
rightLabel: '^N new · Esc close',
|
|
55
|
+
});
|
|
56
|
+
const ix = rect.x + 2;
|
|
57
|
+
const iw = rect.w - 4;
|
|
58
|
+
let y = rect.y + 1;
|
|
59
|
+
// Filter chips row
|
|
60
|
+
const filters = [
|
|
61
|
+
{ id: 'all', label: 'All' },
|
|
62
|
+
{ id: 'needs_you', label: 'Needs you' },
|
|
63
|
+
{ id: 'working', label: 'Working' },
|
|
64
|
+
{ id: 'pinned', label: 'Pinned' },
|
|
65
|
+
{ id: 'archived', label: 'Archived' },
|
|
66
|
+
];
|
|
67
|
+
let fx = ix;
|
|
68
|
+
for (const f of filters) {
|
|
69
|
+
const active = modal.filter === f.id;
|
|
70
|
+
const lbl = ` ${f.label} `;
|
|
71
|
+
const w = stringWidth(lbl);
|
|
72
|
+
if (fx + w > ix + iw - 12)
|
|
73
|
+
break;
|
|
74
|
+
buf.drawText(fx, y, lbl, {
|
|
75
|
+
fg: active ? theme.accent : theme.muted,
|
|
76
|
+
bg: active ? theme.accentTint ?? theme.sunken : bg,
|
|
77
|
+
bold: active,
|
|
78
|
+
});
|
|
79
|
+
state.hitRegions.push({
|
|
80
|
+
rect: { x: fx, y, w, h: 1 },
|
|
81
|
+
action: () => {
|
|
82
|
+
modal.filter = f.id;
|
|
83
|
+
modal.cursor = 0;
|
|
84
|
+
modal.scroll = 0;
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
fx += w + 1;
|
|
88
|
+
}
|
|
89
|
+
const newBtn = ' + New ';
|
|
90
|
+
const newX = ix + iw - newBtn.length;
|
|
91
|
+
buf.drawText(newX, y, newBtn, { fg: theme.onAccent, bg: theme.accent, bold: true });
|
|
92
|
+
state.hitRegions.push({
|
|
93
|
+
rect: { x: newX, y, w: newBtn.length, h: 1 },
|
|
94
|
+
action: () => {
|
|
95
|
+
cb.closeModal();
|
|
96
|
+
cb.startDraftChat();
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
y += 1;
|
|
100
|
+
// Fuzzy search input
|
|
101
|
+
const inBg = theme.sunken ?? theme.field;
|
|
102
|
+
buf.fill({ x: ix, y, w: iw, h: 1 }, { fg: theme.paper, bg: inBg });
|
|
103
|
+
const win = modal.editor.singleLineWindow(iw - 4);
|
|
104
|
+
if (modal.editor.value.length === 0) {
|
|
105
|
+
buf.drawTruncated(ix + 1, y, 'Type to filter… (↑/↓ or wheel scroll · PgUp/Dn · Tab filter)', iw - 2, { fg: theme.muted, bg: inBg, dim: true });
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
buf.drawText(ix + 1, y, win.text, { fg: theme.paper, bg: inBg }, iw - 2);
|
|
109
|
+
}
|
|
110
|
+
buf.cursor = { x: ix + 1 + win.cursorCol, y, visible: true };
|
|
111
|
+
y += 1;
|
|
112
|
+
buf.drawHLine(rect.x + 1, y, rect.w - 2, { fg: theme.hairline, bg });
|
|
113
|
+
y += 1;
|
|
114
|
+
const listH = Math.max(2, rect.y + rect.h - y - 1);
|
|
115
|
+
const listW = Math.max(12, iw - 2); // leave 1 space + 1 col scrollbar
|
|
116
|
+
state.hitRegions.push({
|
|
117
|
+
rect: { x: ix, y, w: iw, h: listH },
|
|
118
|
+
action: () => { },
|
|
119
|
+
onWheel: cb.scrollChatsOverlay,
|
|
120
|
+
});
|
|
121
|
+
if (convIndices.length === 0) {
|
|
122
|
+
buf.drawTruncated(ix, y + 1, 'No conversations match this filter.', listW, { fg: theme.muted, bg });
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
const focusedRowIdx = convIndices[clamped] ?? 0;
|
|
126
|
+
if (focusedRowIdx < modal.scroll)
|
|
127
|
+
modal.scroll = focusedRowIdx;
|
|
128
|
+
if (focusedRowIdx >= modal.scroll + listH)
|
|
129
|
+
modal.scroll = focusedRowIdx - listH + 1;
|
|
130
|
+
modal.scroll = Math.max(0, Math.min(modal.scroll, Math.max(0, rows.length - listH)));
|
|
131
|
+
const agentColor = theme.agentColor(state.agents.find((a) => a.dirName === slice?.dir)?.color ?? slice?.dir ?? 'smith');
|
|
132
|
+
for (let i = 0; i < listH && modal.scroll + i < rows.length; i++) {
|
|
133
|
+
const rIdx = modal.scroll + i;
|
|
134
|
+
const row = rows[rIdx];
|
|
135
|
+
const ry = y + i;
|
|
136
|
+
if (row.kind === 'header') {
|
|
137
|
+
buf.drawTruncated(ix, ry, `${row.label} (${row.count})`, listW, { fg: theme.muted, bg, bold: true });
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const conv = row.conv;
|
|
141
|
+
const isCursor = rIdx === focusedRowIdx;
|
|
142
|
+
const isActive = slice && conv.sessionId === slice.selectedSessionId && !slice.draftMode;
|
|
143
|
+
const rowBg = isCursor
|
|
144
|
+
? theme.accentTint ?? theme.sunken
|
|
145
|
+
: conv.needsYou
|
|
146
|
+
? theme.amberTint ?? bg
|
|
147
|
+
: bg;
|
|
148
|
+
buf.fill({ x: ix, y: ry, w: listW, h: 1 }, { fg: theme.paper, bg: rowBg });
|
|
149
|
+
const lead = conv.needsYou ? '┃' : conv.inFlight ? '▎' : isActive ? '●' : ' ';
|
|
150
|
+
const leadColor = conv.needsYou ? theme.amber : conv.inFlight ? agentColor : isActive ? theme.accent : theme.muted;
|
|
151
|
+
buf.drawText(ix, ry, `${lead} `, { fg: leadColor, bg: rowBg, bold: true });
|
|
152
|
+
const indent = row.depth > 0 ? ' '.repeat(row.depth * 2 - 1) + '└ ' : '';
|
|
153
|
+
const fold = row.hasChildren ? (row.collapsed ? '▸ ' : '▾ ') : '';
|
|
154
|
+
const prefix = indent + fold;
|
|
155
|
+
let badge = '';
|
|
156
|
+
let badgeColor = theme.muted;
|
|
157
|
+
if (conv.needsYou) {
|
|
158
|
+
badge = 'Needs you';
|
|
159
|
+
badgeColor = theme.amber;
|
|
160
|
+
}
|
|
161
|
+
else if (conv.inFlight) {
|
|
162
|
+
badge = 'Working';
|
|
163
|
+
badgeColor = agentColor;
|
|
164
|
+
}
|
|
165
|
+
else if (conv.descendantNeedsYou > 0) {
|
|
166
|
+
badge = `↳ ${conv.descendantNeedsYou} needs`;
|
|
167
|
+
badgeColor = theme.amber;
|
|
168
|
+
}
|
|
169
|
+
else if (conv.stuck) {
|
|
170
|
+
badge = 'Stuck';
|
|
171
|
+
badgeColor = theme.red;
|
|
172
|
+
}
|
|
173
|
+
else if (conv.unread) {
|
|
174
|
+
badge = `● ${formatRelativeAge(conv.lastActivity)}`;
|
|
175
|
+
badgeColor = theme.red;
|
|
176
|
+
}
|
|
177
|
+
else if (conv.nextWakeAt) {
|
|
178
|
+
badge = `◷ ${formatRelativeAge(conv.lastActivity)}`;
|
|
179
|
+
badgeColor = theme.cyan;
|
|
180
|
+
}
|
|
181
|
+
else if (conv.tasks) {
|
|
182
|
+
badge = `${conv.tasks.done}/${conv.tasks.total} · ${formatRelativeAge(conv.lastActivity)}`;
|
|
183
|
+
badgeColor = theme.muted;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
badge = formatRelativeAge(conv.lastActivity);
|
|
187
|
+
badgeColor = theme.muted;
|
|
188
|
+
}
|
|
189
|
+
const pinMark = conv.pinned ? '★ ' : '';
|
|
190
|
+
const badgeW = stringWidth(badge) + 1;
|
|
191
|
+
const prefW = stringWidth(prefix + pinMark);
|
|
192
|
+
const titleW = Math.max(8, listW - 2 - prefW - badgeW);
|
|
193
|
+
if (prefix)
|
|
194
|
+
buf.drawText(ix + 2, ry, prefix, { fg: theme.muted, bg: rowBg }, listW - 2);
|
|
195
|
+
if (pinMark)
|
|
196
|
+
buf.drawText(ix + 2 + stringWidth(prefix), ry, pinMark, { fg: theme.amber, bg: rowBg });
|
|
197
|
+
buf.drawTruncated(ix + 2 + prefW, ry, conv.title, titleW, {
|
|
198
|
+
fg: isCursor ? theme.accent : conv.system ? theme.muted : theme.paper,
|
|
199
|
+
bg: rowBg,
|
|
200
|
+
bold: isCursor || isActive || conv.needsYou || conv.unread,
|
|
201
|
+
});
|
|
202
|
+
buf.drawText(ix + listW - badgeW + 1, ry, badge, { fg: badgeColor, bg: rowBg, bold: conv.needsYou || conv.inFlight });
|
|
203
|
+
state.hitRegions.push({
|
|
204
|
+
rect: { x: ix, y: ry, w: listW, h: 1 },
|
|
205
|
+
action: () => {
|
|
206
|
+
cb.closeModal();
|
|
207
|
+
cb.selectSession(conv.sessionId);
|
|
208
|
+
},
|
|
209
|
+
onWheel: cb.scrollChatsOverlay,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
buf.drawScrollbar({ x: ix, y, w: iw, h: listH }, rows.length, listH, modal.scroll, { fg: theme.hairline, bg }, { fg: theme.accent, bg });
|
|
213
|
+
}
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
case 'inspector': {
|
|
217
|
+
const w = Math.max(52, Math.min(buf.width - 4, Math.floor(buf.width * 0.92)));
|
|
218
|
+
const h = Math.max(14, Math.min(buf.height - 2, Math.floor(buf.height * 0.86)));
|
|
219
|
+
const rect = {
|
|
220
|
+
x: Math.floor((buf.width - w) / 2),
|
|
221
|
+
y: Math.floor((buf.height - h) / 2),
|
|
222
|
+
w,
|
|
223
|
+
h,
|
|
224
|
+
};
|
|
225
|
+
const title = slice?.sessionName
|
|
226
|
+
? `Inspector · ${truncateWidth(slice.sessionName, 44)}`
|
|
227
|
+
: 'Inspector';
|
|
228
|
+
buf.drawBox(rect, { fg: theme.cyan, bg }, {
|
|
229
|
+
fillStyle: { fg: theme.paper, bg },
|
|
230
|
+
title,
|
|
231
|
+
titleStyle: { fg: theme.cyan, bg, bold: true },
|
|
232
|
+
rightLabel: '1-9/0/b tab · Esc close',
|
|
233
|
+
});
|
|
234
|
+
if (slice && sec) {
|
|
235
|
+
renderInspectorPane(buf, { x: rect.x + 1, y: rect.y + 1, w: rect.w - 2, h: rect.h - 2 }, state, slice, sec, theme, cb.inspectorCallbacks, { asOverlay: true });
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
buf.drawText(rect.x + 3, rect.y + 2, 'Select an agent conversation to inspect.', { fg: theme.muted, bg });
|
|
239
|
+
}
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
case 'palette': {
|
|
243
|
+
const rect = centerRect(buf, 78, 22);
|
|
244
|
+
buf.drawBox(rect, { fg: theme.accent, bg }, { fillStyle: { fg: theme.paper, bg }, title: 'Search or Jump (Ctrl+K)', titleStyle: { fg: theme.accent, bg, bold: true }, rightLabel: 'Esc close' });
|
|
245
|
+
const ix = rect.x + 2;
|
|
246
|
+
const iw = rect.w - 4;
|
|
247
|
+
const inBg = theme.sunken ?? theme.field;
|
|
248
|
+
buf.fill({ x: ix, y: rect.y + 1, w: iw, h: 1 }, { fg: theme.paper, bg: inBg });
|
|
249
|
+
const win = modal.editor.singleLineWindow(iw - 4);
|
|
250
|
+
if (modal.editor.value.length === 0) {
|
|
251
|
+
buf.drawTruncated(ix + 1, rect.y + 1, 'Type to search chats, files, agents, or commands…', iw - 2, { fg: theme.muted, bg: inBg, dim: true });
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
buf.drawText(ix + 1, rect.y + 1, win.text, { fg: theme.paper, bg: inBg }, iw - 2);
|
|
255
|
+
}
|
|
256
|
+
buf.cursor = { x: ix + 1 + win.cursorCol, y: rect.y + 1, visible: true };
|
|
257
|
+
buf.drawHLine(rect.x + 1, rect.y + 2, rect.w - 2, { fg: theme.hairline, bg });
|
|
258
|
+
const items = cb.getPaletteActions();
|
|
259
|
+
const listH = rect.h - 4;
|
|
260
|
+
const cur = Math.max(0, Math.min(items.length - 1, modal.cursor));
|
|
261
|
+
const start = Math.max(0, Math.min(cur - Math.floor(listH / 2), Math.max(0, items.length - listH)));
|
|
262
|
+
if (items.length === 0) {
|
|
263
|
+
buf.drawTruncated(ix, rect.y + 3, modal.searching ? 'Searching across fleet…' : 'No matching commands, chats, or files.', iw, { fg: theme.muted, bg });
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
for (let i = 0; i < listH && start + i < items.length; i++) {
|
|
267
|
+
const idx = start + i;
|
|
268
|
+
const it = items[idx];
|
|
269
|
+
const sel = idx === cur;
|
|
270
|
+
const rowBg = sel ? theme.accentTint ?? theme.sunken : bg;
|
|
271
|
+
const ry = rect.y + 3 + i;
|
|
272
|
+
buf.fill({ x: ix, y: ry, w: iw, h: 1 }, { fg: theme.paper, bg: rowBg });
|
|
273
|
+
const catTag = `[${it.category}] `;
|
|
274
|
+
buf.drawText(ix, ry, catTag, { fg: theme.cyan, bg: rowBg }, 10);
|
|
275
|
+
buf.drawTruncated(ix + 10, ry, it.label, Math.max(10, Math.floor(iw * 0.45)), { fg: sel ? theme.accent : theme.paper, bg: rowBg, bold: sel });
|
|
276
|
+
const detX = ix + 10 + Math.floor(iw * 0.45) + 1;
|
|
277
|
+
const detW = ix + iw - detX;
|
|
278
|
+
if (detW > 6) {
|
|
279
|
+
buf.drawTruncated(detX, ry, it.shortcut ? `${it.detail} ${it.shortcut}` : it.detail, detW, { fg: theme.muted, bg: rowBg, dim: true });
|
|
280
|
+
}
|
|
281
|
+
state.hitRegions.push({
|
|
282
|
+
rect: { x: ix, y: ry, w: iw, h: 1 },
|
|
283
|
+
action: () => {
|
|
284
|
+
cb.closeModal();
|
|
285
|
+
it.run();
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
case 'model': {
|
|
293
|
+
const rect = centerRect(buf, 68, 22);
|
|
294
|
+
buf.drawBox(rect, { fg: theme.accent, bg }, { fillStyle: { fg: theme.paper, bg }, title: 'Model, Thinking Effort & Speed', titleStyle: { fg: theme.accent, bg, bold: true }, rightLabel: 'Tab section · Enter apply' });
|
|
295
|
+
const ix = rect.x + 2;
|
|
296
|
+
const iw = rect.w - 4;
|
|
297
|
+
let y = rect.y + 1;
|
|
298
|
+
const models = slice?.models ?? [];
|
|
299
|
+
const options = [
|
|
300
|
+
{ id: null, label: `Agent default (${slice?.defaultModel || 'auto'})`, hint: 'Follow agent config' },
|
|
301
|
+
...models.map((m) => ({ id: m.id, label: m.label || m.id, hint: m.hint })),
|
|
302
|
+
];
|
|
303
|
+
const listH = Math.max(3, rect.h - 9);
|
|
304
|
+
const cur = Math.max(0, Math.min(options.length - 1, modal.cursor));
|
|
305
|
+
const start = Math.max(0, Math.min(cur - Math.floor(listH / 2), Math.max(0, options.length - listH)));
|
|
306
|
+
const scrollNote = options.length > listH ? ` (${cur + 1}/${options.length} · ↑/↓ scroll)` : ` (${options.length})`;
|
|
307
|
+
buf.drawText(ix, y, `1. Model${scrollNote}`, { fg: modal.section === 'model' ? theme.accent : theme.muted, bg, bold: modal.section === 'model' });
|
|
308
|
+
y += 1;
|
|
309
|
+
for (let i = 0; i < listH && start + i < options.length; i++) {
|
|
310
|
+
const idx = start + i;
|
|
311
|
+
const opt = options[idx];
|
|
312
|
+
const sel = modal.section === 'model' && modal.cursor === idx;
|
|
313
|
+
const active = modal.selectedModel === opt.id;
|
|
314
|
+
const rowBg = sel ? theme.accentTint ?? theme.sunken : bg;
|
|
315
|
+
buf.fill({ x: ix, y, w: iw, h: 1 }, { fg: theme.paper, bg: rowBg });
|
|
316
|
+
buf.drawTruncated(ix + 1, y, `${active ? '● ' : '○ '}${opt.label}${opt.hint ? ` — ${opt.hint}` : ''}`, iw - 2, {
|
|
317
|
+
fg: active ? theme.accent : theme.paper,
|
|
318
|
+
bg: rowBg,
|
|
319
|
+
bold: sel || active,
|
|
320
|
+
});
|
|
321
|
+
state.hitRegions.push({
|
|
322
|
+
rect: { x: ix, y, w: iw, h: 1 },
|
|
323
|
+
action: () => {
|
|
324
|
+
modal.selectedModel = opt.id;
|
|
325
|
+
modal.cursor = idx;
|
|
326
|
+
},
|
|
327
|
+
});
|
|
328
|
+
y += 1;
|
|
329
|
+
}
|
|
330
|
+
// Thinking effort row
|
|
331
|
+
y = rect.y + rect.h - 6;
|
|
332
|
+
buf.drawHLine(rect.x + 1, y, rect.w - 2, { fg: theme.hairline, bg });
|
|
333
|
+
y += 1;
|
|
334
|
+
buf.drawText(ix, y, '2. Thinking effort: ', { fg: modal.section === 'thinking' ? theme.accent : theme.muted, bg, bold: modal.section === 'thinking' });
|
|
335
|
+
const efforts = [null, 'off', 'low', 'medium', 'high', 'xhigh', 'max'];
|
|
336
|
+
let ex = ix + 20;
|
|
337
|
+
for (const eff of efforts) {
|
|
338
|
+
const lbl = ` ${eff ?? 'default'} `;
|
|
339
|
+
const active = modal.selectedThinking === eff;
|
|
340
|
+
if (ex + lbl.length > ix + iw)
|
|
341
|
+
break;
|
|
342
|
+
buf.drawText(ex, y, lbl, { fg: active ? theme.onAccent : theme.paper, bg: active ? theme.accent : theme.sunken ?? bg, bold: active });
|
|
343
|
+
state.hitRegions.push({ rect: { x: ex, y, w: lbl.length, h: 1 }, action: () => { modal.selectedThinking = eff; } });
|
|
344
|
+
ex += lbl.length + 1;
|
|
345
|
+
}
|
|
346
|
+
// Speed row
|
|
347
|
+
y += 2;
|
|
348
|
+
buf.drawText(ix, y, '3. Speed mode: ', { fg: modal.section === 'speed' ? theme.accent : theme.muted, bg, bold: modal.section === 'speed' });
|
|
349
|
+
const speeds = [null, 'standard', 'fast'];
|
|
350
|
+
let sx = ix + 20;
|
|
351
|
+
for (const sp of speeds) {
|
|
352
|
+
const lbl = ` ${sp ?? 'default'} `;
|
|
353
|
+
const active = modal.selectedSpeed === sp;
|
|
354
|
+
buf.drawText(sx, y, lbl, { fg: active ? theme.onAccent : theme.paper, bg: active ? theme.accent : theme.sunken ?? bg, bold: active });
|
|
355
|
+
state.hitRegions.push({ rect: { x: sx, y, w: lbl.length, h: 1 }, action: () => { modal.selectedSpeed = sp; } });
|
|
356
|
+
sx += lbl.length + 1;
|
|
357
|
+
}
|
|
358
|
+
// Apply button
|
|
359
|
+
const applyLbl = ' Apply (Enter) ';
|
|
360
|
+
const ax = rect.x + rect.w - applyLbl.length - 2;
|
|
361
|
+
buf.drawText(ax, rect.y + rect.h - 2, applyLbl, { fg: theme.onAccent, bg: theme.accent, bold: true });
|
|
362
|
+
state.hitRegions.push({
|
|
363
|
+
rect: { x: ax, y: rect.y + rect.h - 2, w: applyLbl.length, h: 1 },
|
|
364
|
+
action: () => cb.applyModelSelection(modal.selectedModel, modal.selectedThinking, modal.selectedSpeed),
|
|
365
|
+
});
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
case 'rewind': {
|
|
369
|
+
const rect = centerRect(buf, 74, 20);
|
|
370
|
+
const items = slice?.rewindItems ?? [];
|
|
371
|
+
buf.drawBox(rect, { fg: theme.amber, bg }, { fillStyle: { fg: theme.paper, bg }, title: 'Rewind Conversation', titleStyle: { fg: theme.amber, bg, bold: true }, rightLabel: 'Enter rewind · Esc cancel' });
|
|
372
|
+
const ix = rect.x + 2;
|
|
373
|
+
const iw = rect.w - 4;
|
|
374
|
+
const tz = resolveTimeZone(state.account?.user.timezone);
|
|
375
|
+
if (items.length === 0) {
|
|
376
|
+
buf.drawText(ix, rect.y + 2, 'No user messages available to rewind to.', { fg: theme.muted, bg });
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
const cur = Math.max(0, Math.min(items.length - 1, modal.cursor));
|
|
380
|
+
for (let i = 0; i < items.length && rect.y + 2 + i * 2 < rect.y + rect.h - 1; i++) {
|
|
381
|
+
const item = items[i];
|
|
382
|
+
const sel = i === cur;
|
|
383
|
+
const rbg = sel ? theme.accentTint ?? theme.sunken : bg;
|
|
384
|
+
const ry = rect.y + 2 + i * 2;
|
|
385
|
+
buf.fill({ x: ix, y: ry, w: iw, h: 2 }, { fg: theme.paper, bg: rbg });
|
|
386
|
+
buf.drawTruncated(ix + 1, ry, item.text.replace(/\s+/g, ' '), iw - 2, { fg: theme.paper, bg: rbg, bold: sel });
|
|
387
|
+
buf.drawTruncated(ix + 1, ry + 1, `${formatDateTime(item.createdAt, tz)} · removes ${item.messageCount} msgs${item.childSessionCount > 0 ? ` & ${item.childSessionCount} subagents` : ''}`, iw - 2, { fg: theme.muted, bg: rbg });
|
|
388
|
+
state.hitRegions.push({
|
|
389
|
+
rect: { x: ix, y: ry, w: iw, h: 2 },
|
|
390
|
+
action: () => cb.rewindTo(item.id),
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
case 'branch': {
|
|
397
|
+
const rect = centerRect(buf, 64, 12);
|
|
398
|
+
buf.drawBox(rect, { fg: theme.accent, bg }, { fillStyle: { fg: theme.paper, bg }, title: 'Branch Conversation', titleStyle: { fg: theme.accent, bg, bold: true } });
|
|
399
|
+
const ix = rect.x + 2;
|
|
400
|
+
const iw = rect.w - 4;
|
|
401
|
+
buf.drawTruncated(ix, rect.y + 2, `Anchor: "${modal.preview}"`, iw, { fg: theme.muted, bg });
|
|
402
|
+
const choices = [
|
|
403
|
+
{ mode: 'with-context', title: 'Branch with full context', desc: 'Copies conversation history up to this message' },
|
|
404
|
+
{ mode: 'seed-only', title: 'Branch seed only', desc: 'Starts a clean branch carrying only this message' },
|
|
405
|
+
];
|
|
406
|
+
for (let i = 0; i < choices.length; i++) {
|
|
407
|
+
const c = choices[i];
|
|
408
|
+
const sel = modal.cursor === i;
|
|
409
|
+
const rbg = sel ? theme.accentTint ?? theme.sunken : bg;
|
|
410
|
+
const ry = rect.y + 4 + i * 3;
|
|
411
|
+
buf.fill({ x: ix, y: ry, w: iw, h: 2 }, { fg: theme.paper, bg: rbg });
|
|
412
|
+
buf.drawTruncated(ix + 1, ry, `${sel ? '▸ ' : ' '}${c.title}`, iw - 2, { fg: sel ? theme.accent : theme.paper, bg: rbg, bold: sel });
|
|
413
|
+
buf.drawTruncated(ix + 3, ry + 1, c.desc, iw - 4, { fg: theme.muted, bg: rbg });
|
|
414
|
+
state.hitRegions.push({ rect: { x: ix, y: ry, w: iw, h: 2 }, action: () => cb.branchConversation(modal.messageId, c.mode) });
|
|
415
|
+
}
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
case 'wake': {
|
|
419
|
+
const rect = centerRect(buf, 64, 16);
|
|
420
|
+
buf.drawBox(rect, { fg: theme.cyan, bg }, { fillStyle: { fg: theme.paper, bg }, title: 'Schedule Session Wake', titleStyle: { fg: theme.cyan, bg, bold: true }, rightLabel: 'Tab field · Enter save' });
|
|
421
|
+
const ix = rect.x + 2;
|
|
422
|
+
const iw = rect.w - 4;
|
|
423
|
+
let y = rect.y + 2;
|
|
424
|
+
buf.drawText(ix, y, `Mode: [${modal.mode === 'once' ? '●' : ' '}] One-shot ISO/offset [${modal.mode === 'cron' ? '●' : ' '}] Cron expression`, { fg: modal.field === 'mode' ? theme.accent : theme.paper, bg });
|
|
425
|
+
state.hitRegions.push({
|
|
426
|
+
rect: { x: ix, y, w: iw, h: 1 },
|
|
427
|
+
action: () => {
|
|
428
|
+
modal.mode = modal.mode === 'once' ? 'cron' : 'once';
|
|
429
|
+
},
|
|
430
|
+
});
|
|
431
|
+
y += 2;
|
|
432
|
+
const fBg = theme.sunken ?? theme.field;
|
|
433
|
+
buf.drawText(ix, y, modal.mode === 'once' ? 'When (ISO timestamp or +30m / +2h):' : 'Cron schedule (e.g. 0 9 * * 1-5):', { fg: modal.field === 'when' ? theme.accent : theme.muted, bg });
|
|
434
|
+
y += 1;
|
|
435
|
+
buf.fill({ x: ix, y, w: iw, h: 1 }, { fg: theme.paper, bg: fBg });
|
|
436
|
+
const wWin = modal.whenEditor.singleLineWindow(iw - 2);
|
|
437
|
+
buf.drawText(ix + 1, y, wWin.text, { fg: theme.paper, bg: fBg }, iw - 2);
|
|
438
|
+
if (modal.field === 'when')
|
|
439
|
+
buf.cursor = { x: ix + 1 + wWin.cursorCol, y, visible: true };
|
|
440
|
+
state.hitRegions.push({ rect: { x: ix, y, w: iw, h: 1 }, action: () => { modal.field = 'when'; } });
|
|
441
|
+
y += 2;
|
|
442
|
+
buf.drawText(ix, y, 'Wake note / prompt (optional):', { fg: modal.field === 'note' ? theme.accent : theme.muted, bg });
|
|
443
|
+
y += 1;
|
|
444
|
+
buf.fill({ x: ix, y, w: iw, h: 1 }, { fg: theme.paper, bg: fBg });
|
|
445
|
+
const nWin = modal.noteEditor.singleLineWindow(iw - 2);
|
|
446
|
+
buf.drawText(ix + 1, y, nWin.text, { fg: theme.paper, bg: fBg }, iw - 2);
|
|
447
|
+
if (modal.field === 'note')
|
|
448
|
+
buf.cursor = { x: ix + 1 + nWin.cursorCol, y, visible: true };
|
|
449
|
+
state.hitRegions.push({ rect: { x: ix, y, w: iw, h: 1 }, action: () => { modal.field = 'note'; } });
|
|
450
|
+
y += 2;
|
|
451
|
+
if (modal.error) {
|
|
452
|
+
buf.drawTruncated(ix, y, `✗ ${modal.error}`, iw, { fg: theme.red, bg });
|
|
453
|
+
y += 1;
|
|
454
|
+
}
|
|
455
|
+
const btnY = rect.y + rect.h - 2;
|
|
456
|
+
const saveLbl = ' Save wake ';
|
|
457
|
+
const nowLbl = ' Wake now ';
|
|
458
|
+
const delLbl = ' Cancel wake ';
|
|
459
|
+
buf.drawText(ix, btnY, saveLbl, { fg: theme.onAccent, bg: theme.accent, bold: true });
|
|
460
|
+
state.hitRegions.push({ rect: { x: ix, y: btnY, w: saveLbl.length, h: 1 }, action: cb.saveWake });
|
|
461
|
+
buf.drawText(ix + saveLbl.length + 2, btnY, nowLbl, { fg: theme.green, bg: theme.panel });
|
|
462
|
+
state.hitRegions.push({ rect: { x: ix + saveLbl.length + 2, y: btnY, w: nowLbl.length, h: 1 }, action: cb.fireWakeNow });
|
|
463
|
+
buf.drawText(ix + saveLbl.length + nowLbl.length + 4, btnY, delLbl, { fg: theme.red, bg: theme.panel });
|
|
464
|
+
state.hitRegions.push({ rect: { x: ix + saveLbl.length + nowLbl.length + 4, y: btnY, w: delLbl.length, h: 1 }, action: cb.cancelWake });
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
case 'people': {
|
|
468
|
+
const rect = centerRect(buf, 62, 18);
|
|
469
|
+
buf.drawBox(rect, { fg: theme.accent, bg }, { fillStyle: { fg: theme.paper, bg }, title: 'Shared Conversation People', titleStyle: { fg: theme.accent, bg, bold: true }, rightLabel: 'Enter toggle · Esc close' });
|
|
470
|
+
const ix = rect.x + 2;
|
|
471
|
+
const iw = rect.w - 4;
|
|
472
|
+
if (modal.loading) {
|
|
473
|
+
buf.drawText(ix, rect.y + 2, 'Loading participants…', { fg: theme.muted, bg });
|
|
474
|
+
}
|
|
475
|
+
else if (modal.error) {
|
|
476
|
+
buf.drawTruncated(ix, rect.y + 2, `✗ ${modal.error}`, iw, { fg: theme.red, bg });
|
|
477
|
+
}
|
|
478
|
+
else if (modal.data) {
|
|
479
|
+
buf.drawTruncated(ix, rect.y + 2, 'Owners of this agent are always included. Adding a member reveals full history.', iw, { fg: theme.muted, bg });
|
|
480
|
+
const members = modal.data.members;
|
|
481
|
+
for (let i = 0; i < members.length && rect.y + 4 + i < rect.y + rect.h - 1; i++) {
|
|
482
|
+
const m = members[i];
|
|
483
|
+
const sel = modal.cursor === i;
|
|
484
|
+
const rbg = sel ? theme.accentTint ?? theme.sunken : bg;
|
|
485
|
+
buf.fill({ x: ix, y: rect.y + 4 + i, w: iw, h: 1 }, { fg: theme.paper, bg: rbg });
|
|
486
|
+
buf.drawTruncated(ix + 1, rect.y + 4 + i, `${m.participating ? '[✓]' : '[ ]'} ${m.displayName}`, iw - 2, {
|
|
487
|
+
fg: m.participating ? theme.green : theme.paper,
|
|
488
|
+
bg: rbg,
|
|
489
|
+
bold: sel,
|
|
490
|
+
});
|
|
491
|
+
state.hitRegions.push({
|
|
492
|
+
rect: { x: ix, y: rect.y + 4 + i, w: iw, h: 1 },
|
|
493
|
+
action: () => cb.toggleParticipant(m.userId, !m.participating),
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
break;
|
|
498
|
+
}
|
|
499
|
+
case 'theme': {
|
|
500
|
+
const rect = centerRect(buf, 58, 24);
|
|
501
|
+
buf.drawBox(rect, { fg: theme.accent, bg }, { fillStyle: { fg: theme.paper, bg }, title: 'Select Smith Palette (m toggles dark/light)', titleStyle: { fg: theme.accent, bg, bold: true }, rightLabel: 'Enter select' });
|
|
502
|
+
const ix = rect.x + 2;
|
|
503
|
+
const iw = rect.w - 4;
|
|
504
|
+
const listH = rect.h - 3;
|
|
505
|
+
const cur = Math.max(0, Math.min(TUI_PALETTES.length - 1, modal.cursor));
|
|
506
|
+
const start = Math.max(0, Math.min(cur - Math.floor(listH / 2), Math.max(0, TUI_PALETTES.length - listH)));
|
|
507
|
+
for (let i = 0; i < listH && start + i < TUI_PALETTES.length; i++) {
|
|
508
|
+
const idx = start + i;
|
|
509
|
+
const pal = TUI_PALETTES[idx];
|
|
510
|
+
const sel = idx === cur;
|
|
511
|
+
const active = state.palette === pal;
|
|
512
|
+
const rbg = sel ? theme.accentTint ?? theme.sunken : bg;
|
|
513
|
+
buf.fill({ x: ix, y: rect.y + 1 + i, w: iw, h: 1 }, { fg: theme.paper, bg: rbg });
|
|
514
|
+
buf.drawTruncated(ix + 1, rect.y + 1 + i, `${active ? '● ' : '○ '}${TUI_PALETTE_LABELS[pal]}`, iw - 2, {
|
|
515
|
+
fg: sel || active ? theme.accent : theme.paper,
|
|
516
|
+
bg: rbg,
|
|
517
|
+
bold: sel || active,
|
|
518
|
+
});
|
|
519
|
+
state.hitRegions.push({ rect: { x: ix, y: rect.y + 1 + i, w: iw, h: 1 }, action: () => cb.applyTheme(pal) });
|
|
520
|
+
}
|
|
521
|
+
break;
|
|
522
|
+
}
|
|
523
|
+
case 'help': {
|
|
524
|
+
const rect = centerRect(buf, 78, 26);
|
|
525
|
+
buf.drawBox(rect, { fg: theme.accent, bg }, { fillStyle: { fg: theme.paper, bg }, title: 'Keyboard Shortcuts & Slash Commands', titleStyle: { fg: theme.accent, bg, bold: true }, rightLabel: '↑/↓ scroll · Esc close' });
|
|
526
|
+
const lines = [
|
|
527
|
+
'HYBRID KEYBOARD WORKFLOW (Calm Single-Pane TUI)',
|
|
528
|
+
' Pick an agent on launch (or pass smith-tui <agent> / --agent <dir>).',
|
|
529
|
+
' Chats start in INSERT mode ready to type. Press Esc to enter BROWSE mode',
|
|
530
|
+
' for single-key navigation, or use Ctrl/Alt chords straight from INSERT.',
|
|
531
|
+
'',
|
|
532
|
+
'CHORDS (work anywhere, even while typing in INSERT mode)',
|
|
533
|
+
' Ctrl+T Open Conversations Picker (↑/↓, PgUp/Dn, wheel, Tab filter, pin, archive)',
|
|
534
|
+
' Ctrl+\\ / Alt+I Open Full-Focus Inspector (Tasks, Plan, Diffs, Subagents, Notes)',
|
|
535
|
+
' Ctrl+K / Ctrl+P Command Palette & Search',
|
|
536
|
+
' Ctrl+O Open Model / Thinking Effort / Speed Picker',
|
|
537
|
+
' Ctrl+N Start a new deferred conversation',
|
|
538
|
+
' Ctrl+X Stop running agent turn (or /stop)',
|
|
539
|
+
' Ctrl+` / Alt+J Toggle bottom Logs / Shell / Background drawer',
|
|
540
|
+
' Ctrl+G Attach full-screen raw Container PTY Shell (Ctrl+] detaches)',
|
|
541
|
+
' Ctrl+, Global Preferences & Platform Settings',
|
|
542
|
+
' Alt+[ / Alt+] Go back / forward in navigation history',
|
|
543
|
+
' PgUp / PgDn Scroll chat transcript without leaving INSERT mode',
|
|
544
|
+
' Ctrl+C Quit Smith TUI cleanly',
|
|
545
|
+
'',
|
|
546
|
+
'BROWSE MODE (press Esc in Chat)',
|
|
547
|
+
' c or Enter Return to INSERT mode (compose message)',
|
|
548
|
+
' j / k or ↑ / ↓ Scroll transcript (u/d half-page · G/End bottom · Home top)',
|
|
549
|
+
' s or / Open Conversations Picker',
|
|
550
|
+
' i Open Full-Focus Inspector overlay',
|
|
551
|
+
' g Open Helix-style Go-To menu (next key jumps immediately)',
|
|
552
|
+
' m Model / Thinking / Speed Picker',
|
|
553
|
+
' o / r Toggle tool call details / reasoning blocks',
|
|
554
|
+
' w / R / B / P Wake schedule / Rewind / Branch / Shared People',
|
|
555
|
+
' n / y / L / X New chat / Copy last reply / Load older / Stop turn',
|
|
556
|
+
' t / ? Theme palette picker / This help overlay',
|
|
557
|
+
'',
|
|
558
|
+
'GO-TO MENU (press g, then one key)',
|
|
559
|
+
' c Chats b Boards n Notes d Files s Skills m Memory v Activity',
|
|
560
|
+
' . Agent cfg f Fleet i Inspector w Compute t Shell , Settings',
|
|
561
|
+
'',
|
|
562
|
+
'SLASH COMMANDS (in chat composer)',
|
|
563
|
+
' /chats /new /rename /model /rewind /branch /redo /stop /steer /queue',
|
|
564
|
+
' /wake /people /pin /archive /kill /copy /tools /thinking',
|
|
565
|
+
' /inspect /shell /fleet /compute /boards /notes /files /skills',
|
|
566
|
+
' /memory /activity /settings /theme /dark /light /search /help /logout /quit',
|
|
567
|
+
];
|
|
568
|
+
const ix = rect.x + 2;
|
|
569
|
+
const iw = rect.w - 4;
|
|
570
|
+
const viewH = rect.h - 2;
|
|
571
|
+
const start = Math.max(0, Math.min(modal.scroll, Math.max(0, lines.length - viewH)));
|
|
572
|
+
for (let i = 0; i < viewH && start + i < lines.length; i++) {
|
|
573
|
+
const l = lines[start + i];
|
|
574
|
+
const isHead = l.length > 0 && !l.startsWith(' ');
|
|
575
|
+
buf.drawTruncated(ix, rect.y + 1 + i, l, iw, {
|
|
576
|
+
fg: isHead ? theme.accent : theme.paper,
|
|
577
|
+
bg,
|
|
578
|
+
bold: isHead,
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
case 'prompt': {
|
|
584
|
+
const rect = centerRect(buf, 64, 10);
|
|
585
|
+
buf.drawBox(rect, { fg: theme.accent, bg }, { fillStyle: { fg: theme.paper, bg }, title: modal.title, titleStyle: { fg: theme.accent, bg, bold: true }, rightLabel: 'Enter submit · Esc cancel' });
|
|
586
|
+
const ix = rect.x + 2;
|
|
587
|
+
const iw = rect.w - 4;
|
|
588
|
+
let y = rect.y + 2;
|
|
589
|
+
if (modal.subtitle) {
|
|
590
|
+
buf.drawTruncated(ix, y, modal.subtitle, iw, { fg: theme.muted, bg });
|
|
591
|
+
y += 2;
|
|
592
|
+
}
|
|
593
|
+
const fBg = theme.sunken ?? theme.field;
|
|
594
|
+
buf.fill({ x: ix, y, w: iw, h: 1 }, { fg: theme.paper, bg: fBg });
|
|
595
|
+
const win = modal.editor.singleLineWindow(iw - 2, modal.masked);
|
|
596
|
+
buf.drawText(ix + 1, y, win.text, { fg: theme.paper, bg: fBg }, iw - 2);
|
|
597
|
+
buf.cursor = { x: ix + 1 + win.cursorCol, y, visible: true };
|
|
598
|
+
y += 2;
|
|
599
|
+
if (modal.error) {
|
|
600
|
+
buf.drawTruncated(ix, y, `✗ ${modal.error}`, iw, { fg: theme.red, bg });
|
|
601
|
+
}
|
|
602
|
+
else if (modal.busy) {
|
|
603
|
+
buf.drawText(ix, y, 'Working…', { fg: theme.amber, bg });
|
|
604
|
+
}
|
|
605
|
+
break;
|
|
606
|
+
}
|
|
607
|
+
case 'confirm': {
|
|
608
|
+
const rect = centerRect(buf, 60, 11);
|
|
609
|
+
const tone = modal.destructive ? theme.red : theme.amber;
|
|
610
|
+
buf.drawBox(rect, { fg: tone, bg }, { fillStyle: { fg: theme.paper, bg }, title: modal.title, titleStyle: { fg: tone, bg, bold: true } });
|
|
611
|
+
const ix = rect.x + 2;
|
|
612
|
+
const iw = rect.w - 4;
|
|
613
|
+
let y = rect.y + 2;
|
|
614
|
+
for (const line of wrapParagraph(modal.body, iw).slice(0, 4)) {
|
|
615
|
+
buf.drawText(ix, y, line, { fg: theme.paper, bg }, iw);
|
|
616
|
+
y += 1;
|
|
617
|
+
}
|
|
618
|
+
const btnY = rect.y + rect.h - 2;
|
|
619
|
+
const cLbl = ' Cancel ';
|
|
620
|
+
const okLbl = ` ${modal.confirmLabel} `;
|
|
621
|
+
buf.drawText(ix, btnY, cLbl, { fg: modal.cursor === 0 ? theme.onAccent : theme.muted, bg: modal.cursor === 0 ? theme.accent : theme.panel, bold: modal.cursor === 0 });
|
|
622
|
+
state.hitRegions.push({ rect: { x: ix, y: btnY, w: cLbl.length, h: 1 }, action: cb.closeModal });
|
|
623
|
+
buf.drawText(ix + cLbl.length + 2, btnY, okLbl, { fg: modal.cursor === 1 ? theme.onAccent : tone, bg: modal.cursor === 1 ? tone : theme.panel, bold: modal.cursor === 1 });
|
|
624
|
+
state.hitRegions.push({ rect: { x: ix + cLbl.length + 2, y: btnY, w: okLbl.length, h: 1 }, action: () => void modal.onConfirm() });
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
case 'editor': {
|
|
628
|
+
const rect = centerRect(buf, Math.min(110, buf.width - 4), Math.min(36, buf.height - 2));
|
|
629
|
+
buf.drawBox(rect, { fg: theme.accent, bg }, {
|
|
630
|
+
fillStyle: { fg: theme.paper, bg },
|
|
631
|
+
title: `${modal.title}${modal.dirty ? ' *' : ''}`,
|
|
632
|
+
titleStyle: { fg: theme.accent, bg, bold: true },
|
|
633
|
+
rightLabel: modal.saving ? 'Saving…' : 'Ctrl+S save · Esc close',
|
|
634
|
+
});
|
|
635
|
+
const ix = rect.x + 2;
|
|
636
|
+
const iw = rect.w - 4;
|
|
637
|
+
buf.drawTruncated(ix, rect.y + 1, modal.subtitle, iw, { fg: theme.muted, bg });
|
|
638
|
+
buf.drawHLine(rect.x + 1, rect.y + 2, rect.w - 2, { fg: theme.hairline, bg });
|
|
639
|
+
const editY = rect.y + 3;
|
|
640
|
+
const editH = Math.max(3, rect.h - 5);
|
|
641
|
+
const layout = modal.editor.layout(iw);
|
|
642
|
+
if (layout.cursorRow < modal.scroll)
|
|
643
|
+
modal.scroll = layout.cursorRow;
|
|
644
|
+
if (layout.cursorRow >= modal.scroll + editH)
|
|
645
|
+
modal.scroll = layout.cursorRow - editH + 1;
|
|
646
|
+
for (let i = 0; i < editH && modal.scroll + i < layout.lines.length; i++) {
|
|
647
|
+
buf.drawText(ix, editY + i, layout.lines[modal.scroll + i], { fg: theme.paper, bg }, iw);
|
|
648
|
+
}
|
|
649
|
+
buf.cursor = {
|
|
650
|
+
x: ix + Math.min(iw - 1, layout.cursorCol),
|
|
651
|
+
y: editY + Math.max(0, Math.min(editH - 1, layout.cursorRow - modal.scroll)),
|
|
652
|
+
visible: true,
|
|
653
|
+
};
|
|
654
|
+
if (modal.error) {
|
|
655
|
+
buf.drawTruncated(ix, rect.y + rect.h - 2, `✗ ${modal.error}`, iw - 14, { fg: theme.red, bg });
|
|
656
|
+
}
|
|
657
|
+
const svBtn = ' Save (Ctrl+S) ';
|
|
658
|
+
const sx = rect.x + rect.w - svBtn.length - 2;
|
|
659
|
+
buf.drawText(sx, rect.y + rect.h - 2, svBtn, { fg: theme.onAccent, bg: theme.accent, bold: true });
|
|
660
|
+
state.hitRegions.push({ rect: { x: sx, y: rect.y + rect.h - 2, w: svBtn.length, h: 1 }, action: cb.saveEditorModal });
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
case 'create_agent': {
|
|
664
|
+
const rect = centerRect(buf, 66, 17);
|
|
665
|
+
buf.drawBox(rect, { fg: theme.accent, bg }, { fillStyle: { fg: theme.paper, bg }, title: 'Create New Agent', titleStyle: { fg: theme.accent, bg, bold: true }, rightLabel: 'Tab field · Enter create' });
|
|
666
|
+
const ix = rect.x + 2;
|
|
667
|
+
const iw = rect.w - 4;
|
|
668
|
+
const fBg = theme.sunken ?? theme.field;
|
|
669
|
+
let y = rect.y + 2;
|
|
670
|
+
buf.drawText(ix, y, 'Name:', { fg: modal.field === 0 ? theme.accent : theme.muted, bg });
|
|
671
|
+
y += 1;
|
|
672
|
+
buf.fill({ x: ix, y, w: iw, h: 1 }, { fg: theme.paper, bg: fBg });
|
|
673
|
+
const nWin = modal.nameEditor.singleLineWindow(iw - 2);
|
|
674
|
+
buf.drawText(ix + 1, y, nWin.text, { fg: theme.paper, bg: fBg }, iw - 2);
|
|
675
|
+
if (modal.field === 0)
|
|
676
|
+
buf.cursor = { x: ix + 1 + nWin.cursorCol, y, visible: true };
|
|
677
|
+
y += 2;
|
|
678
|
+
buf.drawText(ix, y, 'Description:', { fg: modal.field === 1 ? theme.accent : theme.muted, bg });
|
|
679
|
+
y += 1;
|
|
680
|
+
buf.fill({ x: ix, y, w: iw, h: 1 }, { fg: theme.paper, bg: fBg });
|
|
681
|
+
const dWin = modal.descEditor.singleLineWindow(iw - 2);
|
|
682
|
+
buf.drawText(ix + 1, y, dWin.text, { fg: theme.paper, bg: fBg }, iw - 2);
|
|
683
|
+
if (modal.field === 1)
|
|
684
|
+
buf.cursor = { x: ix + 1 + dWin.cursorCol, y, visible: true };
|
|
685
|
+
y += 2;
|
|
686
|
+
const chosenModel = modal.models[modal.modelIdx];
|
|
687
|
+
buf.drawTruncated(ix, y, `Model (←/→): ${chosenModel ? `${chosenModel.label} (${chosenModel.id})` : 'default'}`, iw, {
|
|
688
|
+
fg: modal.field === 2 ? theme.accent : theme.paper,
|
|
689
|
+
bg,
|
|
690
|
+
bold: modal.field === 2,
|
|
691
|
+
});
|
|
692
|
+
y += 2;
|
|
693
|
+
buf.drawText(ix, y, `${modal.startNow ? '[✓]' : '[ ]'} Start container immediately (Space)`, {
|
|
694
|
+
fg: modal.field === 3 ? theme.accent : theme.paper,
|
|
695
|
+
bg,
|
|
696
|
+
});
|
|
697
|
+
y += 2;
|
|
698
|
+
if (modal.error) {
|
|
699
|
+
buf.drawTruncated(ix, y, `✗ ${modal.error}`, iw, { fg: theme.red, bg });
|
|
700
|
+
}
|
|
701
|
+
const crBtn = modal.busy ? ' Creating… ' : ' Create Agent ';
|
|
702
|
+
const cx = rect.x + rect.w - crBtn.length - 2;
|
|
703
|
+
buf.drawText(cx, rect.y + rect.h - 2, crBtn, { fg: theme.onAccent, bg: theme.accent, bold: true });
|
|
704
|
+
state.hitRegions.push({ rect: { x: cx, y: rect.y + rect.h - 2, w: crBtn.length, h: 1 }, action: cb.submitCreateAgent });
|
|
705
|
+
break;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
//# sourceMappingURL=modals-view.js.map
|