dsh-oc-tui 0.1.4 → 0.2.0-pre.13
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 +179 -28
- package/bin/apply-update.cjs +187 -0
- package/bin/mcp-sse-bridge.mjs +499 -0
- package/cordis.patch.yml +46 -32
- package/docs//347/224/250/346/210/267/346/211/213/345/206/214.md +560 -424
- package/dsh-plugin.json +65 -65
- package/lib/caps.js +83 -0
- package/lib/i18n.js +283 -0
- package/lib/image.js +326 -0
- package/lib/index.js +980 -185
- package/lib/locales/ar.js +561 -0
- package/lib/locales/de.js +530 -0
- package/lib/locales/en.js +548 -0
- package/lib/locales/es.js +530 -0
- package/lib/locales/fr.js +530 -0
- package/lib/locales/id.js +532 -0
- package/lib/locales/it.js +530 -0
- package/lib/locales/ja.js +530 -0
- package/lib/locales/ko.js +530 -0
- package/lib/locales/nl.js +530 -0
- package/lib/locales/pl.js +544 -0
- package/lib/locales/pt-BR.js +530 -0
- package/lib/locales/ru.js +544 -0
- package/lib/locales/tr.js +530 -0
- package/lib/locales/vi.js +532 -0
- package/lib/locales/zh-CN.js +531 -0
- package/lib/locales/zh-TW.js +531 -0
- package/lib/markdown.js +560 -297
- package/lib/mcp-skill.js +93 -0
- package/lib/mcp.js +838 -0
- package/lib/mermaid-ascii.js +138 -0
- package/lib/mermaid.js +137 -0
- package/lib/rewind.js +15 -14
- package/lib/splash-opencode.js +108 -0
- package/lib/startup.js +16 -10
- package/lib/term.js +242 -10
- package/lib/ui.js +1265 -406
- package/lib/updates.js +1028 -697
- package/lib/util.js +85 -27
- package/lib/web-settings.js +846 -454
- package/package.json +145 -100
- package/skills/mcp-import/SKILL.md +216 -0
package/lib/ui.js
CHANGED
|
@@ -2,7 +2,20 @@
|
|
|
2
2
|
// theme, session sidebar, chat transcript, input row, and status bar.
|
|
3
3
|
import { Screen, makeStyle, mergeStyle, hexToAnsi } from './term.js'
|
|
4
4
|
import { renderMarkdown } from './markdown.js'
|
|
5
|
-
import {
|
|
5
|
+
import { sha16 } from './image.js'
|
|
6
|
+
import { displayWidth, truncateWidth, timeString, toolSummary, roughTokens, formatTokens, wrapText, shortenPath, decodeDataUrl } from './util.js'
|
|
7
|
+
import { paintSplashOpenCode } from './splash-opencode.js'
|
|
8
|
+
import { loadMermaidEngine, paintMermaidArt, renderMermaidArt } from './mermaid-ascii.js'
|
|
9
|
+
// `tr` on purpose: the paint methods below bind `t` to THEME, and a bare `t`
|
|
10
|
+
// import would be shadowed there.
|
|
11
|
+
import { t as tr, tn, getLocale } from './i18n.js'
|
|
12
|
+
|
|
13
|
+
// Mermaid art sits where a code-block body sits, and the pane keeps the same
|
|
14
|
+
// slack a markdown table keeps for gutters and message insets before an art
|
|
15
|
+
// wider than that is declared too wide for the viewport.
|
|
16
|
+
const MERMAID_INDENT = ' '
|
|
17
|
+
const MERMAID_INDENT_WIDTH = displayWidth(MERMAID_INDENT)
|
|
18
|
+
const MERMAID_MARGIN = 4
|
|
6
19
|
|
|
7
20
|
// DeepSeek brand palette: deep blue accents on a blue-tinted dark canvas.
|
|
8
21
|
export const THEME = {
|
|
@@ -18,7 +31,6 @@ export const THEME = {
|
|
|
18
31
|
textMuted: '8a93a8',
|
|
19
32
|
background: '0a0e18', // blue-tinted dark background
|
|
20
33
|
backgroundPanel: '111a2c',
|
|
21
|
-
workspaceBar: '16223a', // workspace strip under the header bar (between panel and element)
|
|
22
34
|
backgroundElement: '1b2740',
|
|
23
35
|
border: '3d4d73',
|
|
24
36
|
borderSubtle: '2b3a5c',
|
|
@@ -31,17 +43,13 @@ export const THEME = {
|
|
|
31
43
|
markdownHorizontalRule: '46547a',
|
|
32
44
|
codeBg: '1b2740',
|
|
33
45
|
thinking: '9aa6c2',
|
|
34
|
-
reminder: 'c5bdf7', // system-reminder
|
|
35
|
-
reminderBg: '3a2f66', // system-reminder box background (violet)
|
|
46
|
+
reminder: 'c5bdf7', // system-reminder row text (pale violet)
|
|
36
47
|
imageChipBg: 'd97706', // orange emphasis for pasted-image markers
|
|
37
48
|
imageChipText: '1a0d00', // text on the orange image chip
|
|
38
|
-
compaction: '95d8c0', // compaction
|
|
39
|
-
|
|
40
|
-
inbox: '9fd0e8', // pending-inbox box text (pale cyan)
|
|
41
|
-
inboxBg: '1d4152', // pending-inbox box background (cyan)
|
|
49
|
+
compaction: '95d8c0', // compaction row text (pale mint)
|
|
50
|
+
inbox: '9fd0e8', // pending-inbox row text (pale cyan)
|
|
42
51
|
steering: '9fd0e8', // inline badge on a user turn that arrived as steering
|
|
43
|
-
systemPrompt: 'b9c4dd', // system-prompt
|
|
44
|
-
systemPromptBg: '28324d', // system-prompt box background
|
|
52
|
+
systemPrompt: 'b9c4dd', // system-prompt row text (cool gray)
|
|
45
53
|
// Context-meter segments (web ContextMeter port): heuristic composition
|
|
46
54
|
// shares get distinct hues so the breakdown bar reads at a glance.
|
|
47
55
|
contextSystem: '7fd88f',
|
|
@@ -49,6 +57,20 @@ export const THEME = {
|
|
|
49
57
|
contextMessages: '56b6c2',
|
|
50
58
|
// Mouse text-selection highlight (left-drag select, right-click copy).
|
|
51
59
|
selection: '3153b8',
|
|
60
|
+
// Syntax highlighting palette (highlight.js token classes), tuned for the
|
|
61
|
+
// blue-tinted dark canvas and the code background.
|
|
62
|
+
syntaxKeyword: 'c792ea',
|
|
63
|
+
syntaxString: '9ece8f',
|
|
64
|
+
syntaxNumber: 'e5b567',
|
|
65
|
+
syntaxComment: '6b7490',
|
|
66
|
+
syntaxFunction: '82aaff',
|
|
67
|
+
syntaxType: 'e5c07b',
|
|
68
|
+
tableBorder: '41528a',
|
|
69
|
+
// Transcript markers: the pointer that opens a user turn carries the brand
|
|
70
|
+
// blue, the assistant's own label a quiet one, so a long transcript reads at
|
|
71
|
+
// a glance without any frame around either.
|
|
72
|
+
userPointer: '4d6bfe',
|
|
73
|
+
assistantLabel: '9aa6c2',
|
|
52
74
|
}
|
|
53
75
|
|
|
54
76
|
// Flowing activity indicator frames (clockwise Braille flow).
|
|
@@ -57,7 +79,7 @@ const SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇',
|
|
|
57
79
|
// Label of the header row that names the workspace a session is rooted in, and
|
|
58
80
|
// the fewest columns a path may occupy before the strip is dropped entirely (a
|
|
59
81
|
// six-cell fragment of a path helps nobody).
|
|
60
|
-
const
|
|
82
|
+
const WORKSPACE_LABEL_KEY = 'header.workspace'
|
|
61
83
|
const WORKSPACE_MIN_PATH = 8
|
|
62
84
|
|
|
63
85
|
// Cached styles for the composer's flowing (marching-ants) frame: a bright
|
|
@@ -65,14 +87,16 @@ const WORKSPACE_MIN_PATH = 8
|
|
|
65
87
|
// because the whole border re-resolves its tone on every animation frame.
|
|
66
88
|
let flowFramePalette = null
|
|
67
89
|
|
|
90
|
+
// Composer command palette: the command stays literal, the description is a
|
|
91
|
+
// catalog key resolved at paint time (so a language switch is live).
|
|
68
92
|
const COMMAND_HINTS = [
|
|
69
|
-
['/help', '
|
|
70
|
-
['/new', 'new
|
|
71
|
-
['/model', '
|
|
72
|
-
['/rewind', 'rewind
|
|
73
|
-
['/clear', 'clear
|
|
74
|
-
['/quit', '
|
|
75
|
-
['/compact', 'compact
|
|
93
|
+
['/help', 'hint.help'], ['/settings', 'hint.settings'],
|
|
94
|
+
['/new', 'hint.new'], ['/resume', 'hint.resume'],
|
|
95
|
+
['/model', 'hint.model'], ['/provider', 'hint.provider'],
|
|
96
|
+
['/rewind', 'hint.rewind'], ['/stats', 'hint.stats'],
|
|
97
|
+
['/clear', 'hint.clear'], ['/cancel', 'hint.cancel'],
|
|
98
|
+
['/quit', 'hint.quit'],
|
|
99
|
+
['/compact', 'hint.compact'], ['/goal', 'hint.goal'],
|
|
76
100
|
]
|
|
77
101
|
|
|
78
102
|
// The marker shown in place of an approval detail whose sensitivity is
|
|
@@ -80,16 +104,45 @@ const COMMAND_HINTS = [
|
|
|
80
104
|
// prompt's bullets) would leak how long the hidden value is.
|
|
81
105
|
const REDACTED_DETAIL = '••••••'
|
|
82
106
|
|
|
107
|
+
// The goal phases the catalog names; anything else renders as the raw id.
|
|
108
|
+
const GOAL_PHASE_KEYS = new Set(['goal.active', 'goal.paused', 'goal.blocked', 'goal.complete'])
|
|
109
|
+
|
|
110
|
+
// Right status rail (OpenCode-style right column): the expanded home of the
|
|
111
|
+
// status figures the bottom row compresses — model, thinking intensity,
|
|
112
|
+
// context — plus the session's goal and subagent activity. The threshold sits
|
|
113
|
+
// well above the 120-column default many terminals open at (the rail at that
|
|
114
|
+
// width read as "small window"), while any maximized desktop window clears it.
|
|
115
|
+
const RAIL_MIN_COLS = 140
|
|
116
|
+
const RAIL_WIDTH = 34
|
|
117
|
+
|
|
83
118
|
// Usable text width inside the composer box, derived from the same geometry
|
|
84
|
-
// render() uses (composerX = sidebarW + 2 or 1; the box spans to
|
|
85
|
-
// two columns of padding on each side). Shared so the
|
|
86
|
-
// count and its painting can never disagree.
|
|
87
|
-
function composerTextWidth(cols, sidebarW) {
|
|
119
|
+
// render() uses (composerX = sidebarW + 2 or 1; the box spans to the main
|
|
120
|
+
// area's right edge, with two columns of padding on each side). Shared so the
|
|
121
|
+
// approval prompt's line count and its painting can never disagree.
|
|
122
|
+
function composerTextWidth(cols, sidebarW, railW = 0) {
|
|
88
123
|
const composerX = sidebarW > 0 ? sidebarW + 2 : 1
|
|
89
|
-
const
|
|
124
|
+
const rightEdge = cols - (railW > 0 ? railW + 1 : 0)
|
|
125
|
+
const composerW = rightEdge - composerX - 1
|
|
90
126
|
return Math.max(1, composerW - 4)
|
|
91
127
|
}
|
|
92
128
|
|
|
129
|
+
// Width of the region an overlay may occupy: every column left of the rail's
|
|
130
|
+
// border. Rail mode shrinks the main area by that border column plus
|
|
131
|
+
// RAIL_WIDTH, so a modal centered on the full terminal width would sit half a
|
|
132
|
+
// rail's width right of the frame it covers — visibly off-center once the
|
|
133
|
+
// window is maximized. Without a rail the region is the whole screen, which
|
|
134
|
+
// keeps the narrow layout byte-identical.
|
|
135
|
+
function overlayRegion(cols, railW = 0) {
|
|
136
|
+
return railW > 0 ? cols - railW - 1 : cols
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Rows that carry no action (group headers, a server's transport target or
|
|
140
|
+
// tool names) are stepped over instead of being selectable dead ends; a row
|
|
141
|
+
// opts out with `selectable: false`.
|
|
142
|
+
function settingsRowSelectable(item) {
|
|
143
|
+
return item.kind !== 'header' && item.selectable !== false
|
|
144
|
+
}
|
|
145
|
+
|
|
93
146
|
export function inputRows(text, cursor, width) {
|
|
94
147
|
const rows = ['']
|
|
95
148
|
let row = 0
|
|
@@ -163,20 +216,10 @@ function formatMetric(value) {
|
|
|
163
216
|
return value >= 100 ? Math.round(value).toString() : value.toFixed(1)
|
|
164
217
|
}
|
|
165
218
|
|
|
166
|
-
// `1 turn` / `3 turns`: the
|
|
167
|
-
//
|
|
168
|
-
function count(n,
|
|
169
|
-
return n
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Pad a line's segments to the full transcript width with a background fill
|
|
173
|
-
// so a "boxed" region (e.g. thinking) keeps its emphasized background even in
|
|
174
|
-
// cells that carry no text.
|
|
175
|
-
function boxPad(segs, width, bg) {
|
|
176
|
-
let w = 0
|
|
177
|
-
for (const s of segs) w += displayWidth(s.text)
|
|
178
|
-
if (w >= width) return segs
|
|
179
|
-
return [...segs, { text: ' '.repeat(width - w), style: makeStyle({ bg }) }]
|
|
219
|
+
// `1 turn` / `3 turns`: the count comes from the active locale's plural rules
|
|
220
|
+
// through the catalog (`transcript.turns`, `transcript.steps`).
|
|
221
|
+
function count(n, key) {
|
|
222
|
+
return tn(key, n, { count: n })
|
|
180
223
|
}
|
|
181
224
|
|
|
182
225
|
// Truncate a segment list to a display width, preserving each segment's style.
|
|
@@ -200,6 +243,39 @@ function clipSegs(segs, width) {
|
|
|
200
243
|
return out
|
|
201
244
|
}
|
|
202
245
|
|
|
246
|
+
// A flat, unboxed block: the marker row comes first, body lines hang under it
|
|
247
|
+
// at `hang` columns in the block's own color, and every row is tagged so the
|
|
248
|
+
// whole block stays one click target. Transcript rows are plain segment lists
|
|
249
|
+
// that the render boundary clips, so a block computes no frame width — the
|
|
250
|
+
// boxed shapes did, and their borders drifted whenever a wide rune made the
|
|
251
|
+
// measured row differ from the painted one.
|
|
252
|
+
function flatRows(tag, block, markerSegs, body, hang = 4, width = Infinity) {
|
|
253
|
+
// The marker row is the one row a caller composes by hand, so it is the one
|
|
254
|
+
// that can outgrow the transcript: clip it here rather than trusting each
|
|
255
|
+
// caller's arithmetic.
|
|
256
|
+
const rows = [{ segs: clipSegs(markerSegs, width) }]
|
|
257
|
+
const pad = ' '.repeat(hang)
|
|
258
|
+
for (const line of body) rows.push({ segs: [{ text: pad, style: null }, ...line] })
|
|
259
|
+
for (const row of rows) row[tag] = { block }
|
|
260
|
+
return rows
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Per-tool accent for the activity rows: shell commands read as actions
|
|
264
|
+
// (gold), reads as lookups (cyan), edits as changes (light blue), todo writes
|
|
265
|
+
// as progress (mint); anything unmapped keeps the light-blue accent.
|
|
266
|
+
const TOOL_ACCENTS = {
|
|
267
|
+
run: 'warning', bash: 'warning', pwsh: 'warning', shell: 'warning', command: 'warning',
|
|
268
|
+
read: 'info', glob: 'info', grep: 'info', ls: 'info',
|
|
269
|
+
edit: 'secondary', write: 'secondary', 'str-replace-editor': 'secondary', multiedit: 'secondary', patch: 'secondary',
|
|
270
|
+
todo: 'success', todo_write: 'success',
|
|
271
|
+
task: 'primary', agent: 'primary', subagent: 'primary',
|
|
272
|
+
web_search: 'accent', webfetch: 'accent', fetch: 'accent',
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function toolAccent(name, t) {
|
|
276
|
+
return t[TOOL_ACCENTS[String(name ?? '').toLowerCase()]] ?? t.accent
|
|
277
|
+
}
|
|
278
|
+
|
|
203
279
|
// Interpolate between two hex colors; t in [0, 1].
|
|
204
280
|
function mixColor(a, b, t) {
|
|
205
281
|
const ca = hexToAnsi(a)
|
|
@@ -264,7 +340,7 @@ export function inboxMessageText(message) {
|
|
|
264
340
|
else if (block?.type === 'file') parts.push('[File]')
|
|
265
341
|
}
|
|
266
342
|
const text = parts.join(' ').trim()
|
|
267
|
-
return text === '' ? '
|
|
343
|
+
return text === '' ? tr('common.emptyMessage') : text
|
|
268
344
|
}
|
|
269
345
|
|
|
270
346
|
// One-line preview for a pending-inbox row: newlines collapse so a multi-line
|
|
@@ -277,8 +353,8 @@ function inboxPreview(text, width) {
|
|
|
277
353
|
// The application view state + layout + painting. It is dsh-agnostic: the
|
|
278
354
|
// plugin feeds it events and key presses.
|
|
279
355
|
export class App {
|
|
280
|
-
constructor(terminal, { sidebarWidth =
|
|
281
|
-
this.
|
|
356
|
+
constructor(terminal, { sidebarWidth = 18 } = {}) {
|
|
357
|
+
this.terminal = terminal
|
|
282
358
|
this.sidebarWidth = sidebarWidth
|
|
283
359
|
this.blocks = []
|
|
284
360
|
this.assistantHeaderPending = true
|
|
@@ -294,10 +370,19 @@ export class App {
|
|
|
294
370
|
this.metrics = {} // whole-log stats + billing (web stats strip / tokenUsage port)
|
|
295
371
|
this.contextMeter = null // { percent, usedTokens, contextWindow, breakdown } — web ContextMeter port
|
|
296
372
|
this.statsOpen = false // click-open session stats / token usage window
|
|
373
|
+
this.statsDetailVisible = false // fullscreen stats panel (replaces modal)
|
|
297
374
|
this.sidebarVisible = false
|
|
298
375
|
this.sidebarAgents = [] // [{ id, label }]
|
|
299
376
|
this.sidebarSessions = [] // [{ id, label, time }]
|
|
300
377
|
this.sidebarSelection = -1
|
|
378
|
+
// Right status rail state. `goal` is the current goal view (objective,
|
|
379
|
+
// phase, rounds) folded from the harness's `goal` projection; `subagents`
|
|
380
|
+
// are the delegation rows of `ctx.subagents.listDescendants()`; `versions`
|
|
381
|
+
// names the running dsh and TUI builds in the rail footer.
|
|
382
|
+
this.goal = null // { objective, phase, blockedReason?, roundsStarted, maxGoalRounds }
|
|
383
|
+
this.subagents = [] // [{ id, label, mode, activity, depth, readable }]
|
|
384
|
+
this.railScroll = 0 // lines scrolled up from the rail's bottom (0 = follow)
|
|
385
|
+
this.versions = { tui: '', dsh: '' }
|
|
301
386
|
this.rewind = null // rewind picker state, or null
|
|
302
387
|
this.inputText = ''
|
|
303
388
|
this.inputCursor = 0
|
|
@@ -312,7 +397,7 @@ export class App {
|
|
|
312
397
|
this.settingsSecret = false
|
|
313
398
|
this.settingsConfirm = null
|
|
314
399
|
this.settingsBusy = false // update checks / installs animate a subtitle spinner
|
|
315
|
-
this.settingsTitle = '
|
|
400
|
+
this.settingsTitle = tr('settings.title')
|
|
316
401
|
this.settingsSubtitle = ''
|
|
317
402
|
this.settingsItems = []
|
|
318
403
|
this.settingsMenu = [] // left menu of the settings dialog: [{ id, label }]
|
|
@@ -341,6 +426,34 @@ export class App {
|
|
|
341
426
|
this._streamingRenderAt = 0 // last time the live streaming block was re-rendered
|
|
342
427
|
this.textSelection = null // { startX, startY, endX, endY, text } for mouse text selection
|
|
343
428
|
this.textSelectionDragging = false // true while left button is held and dragging
|
|
429
|
+
// Image pipeline state. Blocks carry `images: ImageSource[]`; results land
|
|
430
|
+
// in _imageResults keyed by source key. Rendering (decode + encode) happens
|
|
431
|
+
// outside the view model: onImageRequest hands a source to the host, which
|
|
432
|
+
// calls setImageResult when the render lands. graphicsProtocol mirrors the
|
|
433
|
+
// probed terminal capability ('kitty' | 'iterm2' | 'sixel' | 'halfblock');
|
|
434
|
+
// halfblock results are plain styled lines, everything else reserves rows
|
|
435
|
+
// and lets the terminal draw pixels there.
|
|
436
|
+
this._imageGroupSeq = 0 // identifies one image's reserved rows inside a block
|
|
437
|
+
this._imageResults = new Map() // key -> { state: 'loading' | 'done' | 'error', protocol?, cellsW?, cellsH?, segLines?, error? }
|
|
438
|
+
this._imageBlocks = new Map() // key -> Set of blocks showing it (rev bump on arrival)
|
|
439
|
+
this._imageRequested = new Set()
|
|
440
|
+
this._imageSources = new Map() // key -> the source that produced it (cropped variants are re-renders of it)
|
|
441
|
+
this._imageCrops = new Map() // key -> Set of '<key>\u0000<crop>' variants still holding a payload
|
|
442
|
+
this._imageCropsPrev = new Set() // variants the previous render used (a crop outlives one idle frame)
|
|
443
|
+
this.onImageRequest = null // (source) => void
|
|
444
|
+
this._mermaidResults = new Map() // 'mermaid:<hash>' -> { state, imageKey? }
|
|
445
|
+
this._mermaidBlocks = new Map()
|
|
446
|
+
this._mermaidRequested = new Set()
|
|
447
|
+
this.onMermaidRequest = null // (code, key) => void
|
|
448
|
+
this._mermaidEngine = undefined // undefined: not asked yet, 'loading', engine, or null
|
|
449
|
+
this._needsRepaint = null // () => void, set by the host: repaint when a late art arrives
|
|
450
|
+
this.mermaidMode = 'auto' // 'auto' | 'local' | 'off' — off means a diagram is its source
|
|
451
|
+
this.graphicsProtocol = 'halfblock'
|
|
452
|
+
this.imagePixels = true // false = the settings chose chip placeholders over any pixels
|
|
453
|
+
this.imageMaxRows = 20
|
|
454
|
+
this.imageCellW = 8 // terminal cell size in pixels (from caps probing)
|
|
455
|
+
this.imageCellH = 16
|
|
456
|
+
this._lastTransWidth = 80
|
|
344
457
|
}
|
|
345
458
|
|
|
346
459
|
addHitRegion(kind, x, y, width, height = 1, data = {}) {
|
|
@@ -451,7 +564,9 @@ export class App {
|
|
|
451
564
|
|
|
452
565
|
// The plain text under the selection rect, taken from the last rendered
|
|
453
566
|
// screen so it matches what the user sees. Wide-rune continuation cells
|
|
454
|
-
// ('') are skipped; trailing fill spaces are trimmed per row.
|
|
567
|
+
// ('') are skipped; trailing fill spaces are trimmed per row. Bubble border
|
|
568
|
+
// glyphs (│) are dropped so copying a message body yields the message, not
|
|
569
|
+
// the frame; a space replaces each one to keep interior columns intact.
|
|
455
570
|
selectionText() {
|
|
456
571
|
const screen = this._lastScreen
|
|
457
572
|
const rect = this._selectionRect()
|
|
@@ -468,7 +583,7 @@ export class App {
|
|
|
468
583
|
for (let x = from; x <= to; x++) {
|
|
469
584
|
const ch = row[x]?.ch
|
|
470
585
|
if (!ch) continue
|
|
471
|
-
out += ch
|
|
586
|
+
out += ch === '│' ? ' ' : ch
|
|
472
587
|
}
|
|
473
588
|
lines.push(out.replace(/\s+$/, ''))
|
|
474
589
|
}
|
|
@@ -509,8 +624,11 @@ export class App {
|
|
|
509
624
|
this.gitBranch = gitBranch
|
|
510
625
|
this.sessionId = ''
|
|
511
626
|
// No active session: the top bar names the empty workspace instead of
|
|
512
|
-
// leaking the previous session's title.
|
|
513
|
-
|
|
627
|
+
// leaking the previous session's title. `untitled` is the sentinel the
|
|
628
|
+
// header resolves through the catalog at paint time, so a language switch
|
|
629
|
+
// renames the placeholder too.
|
|
630
|
+
this.untitled = true
|
|
631
|
+
this.title = ''
|
|
514
632
|
if (model !== undefined) this.model = model
|
|
515
633
|
if (provider !== undefined) this.provider = provider
|
|
516
634
|
}
|
|
@@ -528,7 +646,10 @@ export class App {
|
|
|
528
646
|
this.sessionId = id
|
|
529
647
|
if (id) this.titleScreen = false
|
|
530
648
|
}
|
|
531
|
-
if (title !== undefined)
|
|
649
|
+
if (title !== undefined) {
|
|
650
|
+
this.title = title
|
|
651
|
+
this.untitled = title === '' || title === undefined
|
|
652
|
+
}
|
|
532
653
|
if (model !== undefined) this.model = model
|
|
533
654
|
if (provider !== undefined) this.provider = provider
|
|
534
655
|
}
|
|
@@ -607,6 +728,45 @@ export class App {
|
|
|
607
728
|
}
|
|
608
729
|
}
|
|
609
730
|
|
|
731
|
+
// The rail's GOAL section data: one normalized view of the harness's current
|
|
732
|
+
// goal (the `goal` projection view, or `ctx.goals.get(agent)`), or null when
|
|
733
|
+
// no goal is current. The projection carries the rounds as a sibling of
|
|
734
|
+
// `goal`; the live service view spreads them flat — read both.
|
|
735
|
+
setGoal(view) {
|
|
736
|
+
const goal = view?.goal
|
|
737
|
+
if (!goal || typeof goal.objective !== 'string' || goal.objective.trim() === '') {
|
|
738
|
+
this.goal = null
|
|
739
|
+
return
|
|
740
|
+
}
|
|
741
|
+
this.goal = {
|
|
742
|
+
objective: goal.objective.trim(),
|
|
743
|
+
phase: String(goal.phase ?? 'active'),
|
|
744
|
+
blockedReason: goal.blockedReason && typeof goal.blockedReason.message === 'string' ? goal.blockedReason : null,
|
|
745
|
+
roundsStarted: Number.isFinite(view.roundsStarted) ? view.roundsStarted : 0,
|
|
746
|
+
maxGoalRounds: Number.isFinite(goal.maxGoalRounds) ? goal.maxGoalRounds : 0,
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
// The rail's SUBAGENTS section data: the delegation rows of
|
|
751
|
+
// `ctx.subagents.listDescendants()` (child rows plus diagnostic rows), or a
|
|
752
|
+
// host without the subagent service leaving the section empty.
|
|
753
|
+
setSubagents(rows) {
|
|
754
|
+
this.subagents = (Array.isArray(rows) ? rows : []).map((row) => ({
|
|
755
|
+
id: String(row?.id ?? ''),
|
|
756
|
+
label: typeof row?.label === 'string' && row.label !== '' ? row.label : String(row?.id ?? '').slice(0, 8),
|
|
757
|
+
mode: row?.mode === 'continuable' ? 'continuable' : 'one-shot',
|
|
758
|
+
activity: row?.activity === 'running' ? 'running' : 'idle',
|
|
759
|
+
depth: Number.isFinite(row?.depth) ? row.depth : 1,
|
|
760
|
+
readable: row?.kind !== 'diagnostic',
|
|
761
|
+
}))
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
// Shift+Up/Down and the wheel over the rail move the rail's own window.
|
|
765
|
+
// Render clamps the offset to the content, so this stays unbounded.
|
|
766
|
+
scrollRail(delta) {
|
|
767
|
+
this.railScroll = Math.max(0, this.railScroll + delta)
|
|
768
|
+
}
|
|
769
|
+
|
|
610
770
|
// The stats strip and the details window share one group vocabulary, ported
|
|
611
771
|
// from the web chat stats strip. Every group drops out whole when it has no
|
|
612
772
|
// data, and a session whose steps all settled without billing keeps its
|
|
@@ -615,19 +775,19 @@ export class App {
|
|
|
615
775
|
const m = this.metrics ?? {}
|
|
616
776
|
const groups = []
|
|
617
777
|
if ((m.steps ?? 0) > 0) {
|
|
618
|
-
groups.push(count(m.turns ?? 0, '
|
|
778
|
+
groups.push(count(m.turns ?? 0, 'transcript.turns') + ' · ' + count(m.steps, 'transcript.steps'))
|
|
619
779
|
const durations = []
|
|
620
|
-
if ((m.llmMs ?? 0) > 0) durations.push('
|
|
621
|
-
if ((m.toolMs ?? 0) > 0) durations.push('
|
|
780
|
+
if ((m.llmMs ?? 0) > 0) durations.push(tr('stats.llmTime', { value: formatDuration(m.llmMs) }))
|
|
781
|
+
if ((m.toolMs ?? 0) > 0) durations.push(tr('stats.toolTime', { value: formatDuration(m.toolMs) }))
|
|
622
782
|
if (durations.length > 0) groups.push(durations.join(' · '))
|
|
623
783
|
const speeds = []
|
|
624
|
-
if ((m.ttftSteps ?? 0) > 0) speeds.push('
|
|
625
|
-
if ((m.decodeMs ?? 0) > 0) speeds.push(formatMetric(m.decodeTokens / (m.decodeMs / 1000))
|
|
784
|
+
if ((m.ttftSteps ?? 0) > 0) speeds.push(tr('stats.ttft', { value: formatDuration(m.ttftMs / m.ttftSteps) }))
|
|
785
|
+
if ((m.decodeMs ?? 0) > 0) speeds.push(tr('stats.tokensPerSecond', { value: formatMetric(m.decodeTokens / (m.decodeMs / 1000)) }))
|
|
626
786
|
if (speeds.length > 0) groups.push(speeds.join(' · '))
|
|
627
787
|
}
|
|
628
788
|
if ((m.billedInputTokens ?? 0) > 0 || (m.outputTokens ?? 0) > 0) {
|
|
629
|
-
if (m.cacheHitRate !== undefined) groups.push('
|
|
630
|
-
groups.push('
|
|
789
|
+
if (m.cacheHitRate !== undefined) groups.push(tr('stats.cacheRate', { percent: m.cacheHitRate }))
|
|
790
|
+
groups.push(tr('stats.inOut', { input: formatTokens(m.billedInputTokens ?? 0), output: formatTokens(m.outputTokens ?? 0) }))
|
|
631
791
|
}
|
|
632
792
|
return groups
|
|
633
793
|
}
|
|
@@ -641,7 +801,7 @@ export class App {
|
|
|
641
801
|
// `menu` (optional) drives the settings dialog's left menu bar (Main / Model);
|
|
642
802
|
// views without a menu (choice lists, session manager, model picker) render
|
|
643
803
|
// the classic single-column layout.
|
|
644
|
-
openSettings(items, { title = '
|
|
804
|
+
openSettings(items, { title = tr('settings.title'), subtitle = '', menu = [], menuIndex = 0 } = {}) {
|
|
645
805
|
this.settingsItems = items
|
|
646
806
|
this.setSettingsSelection(0)
|
|
647
807
|
this.settingsEditing = null
|
|
@@ -705,8 +865,8 @@ export class App {
|
|
|
705
865
|
picker.scroll = Math.max(0, Math.min(picker.scroll, Math.max(0, n - visible)))
|
|
706
866
|
}
|
|
707
867
|
|
|
708
|
-
// Point the selection at an item index, skipping
|
|
709
|
-
// 'header' rows are never selectable): a landing on
|
|
868
|
+
// Point the selection at an item index, skipping rows that carry no action
|
|
869
|
+
// (kind 'header' rows are never selectable): a landing on one moves down to
|
|
710
870
|
// the next real item, or back to the first selectable one.
|
|
711
871
|
setSettingsSelection(index) {
|
|
712
872
|
const items = this.settingsItems
|
|
@@ -715,16 +875,16 @@ export class App {
|
|
|
715
875
|
return
|
|
716
876
|
}
|
|
717
877
|
let target = Math.max(0, Math.min(index, items.length - 1))
|
|
718
|
-
while (target < items.length && items[target]
|
|
878
|
+
while (target < items.length && !settingsRowSelectable(items[target])) target++
|
|
719
879
|
if (target >= items.length) {
|
|
720
|
-
const first = items.findIndex(
|
|
880
|
+
const first = items.findIndex(settingsRowSelectable)
|
|
721
881
|
target = first < 0 ? 0 : first
|
|
722
882
|
}
|
|
723
883
|
this.settingsSelection = target
|
|
724
884
|
}
|
|
725
885
|
|
|
726
886
|
// Move the selection by one row in either direction, wrapping around and
|
|
727
|
-
// stepping over
|
|
887
|
+
// stepping over rows with no action so it always rests on a selectable item.
|
|
728
888
|
moveSettingsSelection(delta) {
|
|
729
889
|
const count = this.settingsItems.length
|
|
730
890
|
if (count === 0) return
|
|
@@ -732,7 +892,7 @@ export class App {
|
|
|
732
892
|
let steps = count
|
|
733
893
|
while (steps-- > 0) {
|
|
734
894
|
index = (index + delta + count) % count
|
|
735
|
-
if (this.settingsItems[index]
|
|
895
|
+
if (settingsRowSelectable(this.settingsItems[index])) break
|
|
736
896
|
}
|
|
737
897
|
this.settingsSelection = index
|
|
738
898
|
}
|
|
@@ -749,13 +909,272 @@ export class App {
|
|
|
749
909
|
this.scroll = 0
|
|
750
910
|
}
|
|
751
911
|
|
|
752
|
-
addUser(text, { steering = false } = {}) {
|
|
912
|
+
addUser(text, { steering = false, images } = {}) {
|
|
753
913
|
this.detachInboxBlock()
|
|
754
|
-
|
|
914
|
+
const block = makeBlock('user', { text, steering })
|
|
915
|
+
if (images?.length) block.images = images
|
|
916
|
+
this.blocks.push(block)
|
|
755
917
|
this.assistantHeaderPending = true
|
|
756
918
|
this.scroll = 0
|
|
757
919
|
}
|
|
758
920
|
|
|
921
|
+
// Attach image sources to the most recent user block (an event-side image
|
|
922
|
+
// that the optimistic submit could not have shown, e.g. queued from Web UI).
|
|
923
|
+
attachImagesToLastUser(images) {
|
|
924
|
+
if (!images?.length) return false
|
|
925
|
+
for (let i = this.blocks.length - 1; i >= 0; i--) {
|
|
926
|
+
const b = this.blocks[i]
|
|
927
|
+
if (b.kind !== 'user') continue
|
|
928
|
+
if (b.images?.length) return false
|
|
929
|
+
b.images = images
|
|
930
|
+
b.rev = (b.rev ?? 0) + 1
|
|
931
|
+
return true
|
|
932
|
+
}
|
|
933
|
+
return false
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// Image render options for the host: the probed protocol, the size budget
|
|
937
|
+
// (cells), the probed cell pixel size, and the canvas background the
|
|
938
|
+
// renderer composes transparent pixels over.
|
|
939
|
+
imageRenderOptions() {
|
|
940
|
+
return {
|
|
941
|
+
protocol: this.graphicsProtocol,
|
|
942
|
+
maxCellsW: Math.max(8, Math.min(72, this._lastTransWidth - 6)),
|
|
943
|
+
maxCellsH: this.imageMaxRows,
|
|
944
|
+
cellW: this.imageCellW,
|
|
945
|
+
cellH: this.imageCellH,
|
|
946
|
+
bgHex: THEME.background,
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
// A render landed for an image key: cache it and refresh every block that
|
|
951
|
+
// shows the source so the next frame picks the finished render up. The block
|
|
952
|
+
// set survives the bump — a result can be replaced (protocol upgrade after
|
|
953
|
+
// caps probing, width re-render) and the replacement must reach the same
|
|
954
|
+
// blocks; the map is cleared with the line cache in resetView.
|
|
955
|
+
setImageResult(key, result) {
|
|
956
|
+
this._imageResults.set(key, result)
|
|
957
|
+
const blocks = this._imageBlocks.get(key)
|
|
958
|
+
if (blocks) {
|
|
959
|
+
for (const b of blocks) b.rev = (b.rev ?? 0) + 1
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// The payload for an image whose top rows scrolled above the window: the same
|
|
964
|
+
// source rendered with cropCells set, so the band left on screen is encoded
|
|
965
|
+
// at the height it occupies. The host treats it like any other image, and the
|
|
966
|
+
// result lands under the variant key — nothing in the layout reads it, the
|
|
967
|
+
// paint pass only needs the payload.
|
|
968
|
+
_requestImageCrop(key, clip) {
|
|
969
|
+
const cropKey = key + '\u0000' + clip
|
|
970
|
+
let live = this._imageCrops.get(key)
|
|
971
|
+
if (!live) {
|
|
972
|
+
live = new Set()
|
|
973
|
+
this._imageCrops.set(key, live)
|
|
974
|
+
}
|
|
975
|
+
if (live.has(cropKey)) return
|
|
976
|
+
const src = this._imageSources.get(key)
|
|
977
|
+
if (!src) return
|
|
978
|
+
live.add(cropKey)
|
|
979
|
+
this.onImageRequest?.({ ...src, key: cropKey, cropCells: clip })
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
// Lines for one image source: a loading placeholder while the host renders,
|
|
983
|
+
// styled halfblock rows for the text fallback, or reserved annotation rows
|
|
984
|
+
// for a graphics protocol (render() registers them on the Screen). Rows come
|
|
985
|
+
// back unprefixed — the surrounding block (transcript, tool row) supplies
|
|
986
|
+
// its own gutter.
|
|
987
|
+
_imageLines(src, block, width, out) {
|
|
988
|
+
const key = src.key
|
|
989
|
+
// Kept for the cropped variants below: an image whose top rows scrolled out
|
|
990
|
+
// of the window is re-rendered from the same source, and the host only
|
|
991
|
+
// ever sees sources, never the blocks that resolved them.
|
|
992
|
+
this._imageSources.set(key, src)
|
|
993
|
+
// Chip mode: the settings turned pixels off entirely — images stay
|
|
994
|
+
// placeholder chips and the pipeline never runs.
|
|
995
|
+
if (this.imagePixels === false) {
|
|
996
|
+
out.push({ segs: [{ text: tr('image.attachment'), style: makeStyle({ fg: THEME.textMuted, italic: true }) }] })
|
|
997
|
+
return
|
|
998
|
+
}
|
|
999
|
+
let result = this._imageResults.get(key)
|
|
1000
|
+
if (!result) {
|
|
1001
|
+
result = { state: 'loading' }
|
|
1002
|
+
this._imageResults.set(key, result)
|
|
1003
|
+
}
|
|
1004
|
+
// Remember which blocks show this key so setImageResult can bump their
|
|
1005
|
+
// rev — without a bump the per-block line cache would keep showing the
|
|
1006
|
+
// placeholder after the render landed.
|
|
1007
|
+
let blocks = this._imageBlocks.get(key)
|
|
1008
|
+
if (!blocks) {
|
|
1009
|
+
blocks = new Set()
|
|
1010
|
+
this._imageBlocks.set(key, blocks)
|
|
1011
|
+
}
|
|
1012
|
+
blocks.add(block)
|
|
1013
|
+
if (result.state === 'loading') {
|
|
1014
|
+
if (!this._imageRequested.has(key)) {
|
|
1015
|
+
this._imageRequested.add(key)
|
|
1016
|
+
this.onImageRequest?.(src)
|
|
1017
|
+
}
|
|
1018
|
+
out.push({ segs: [{ text: tr('image.rendering'), style: makeStyle({ fg: THEME.textMuted, italic: true }) }] })
|
|
1019
|
+
return
|
|
1020
|
+
}
|
|
1021
|
+
if (result.state === 'error') {
|
|
1022
|
+
out.push({ segs: [{ text: tr('image.renderFailed', { error: truncateWidth(result.error ?? tr('common.unknown'), Math.max(8, width - 28)) }), style: makeStyle({ fg: THEME.error }) }] })
|
|
1023
|
+
return
|
|
1024
|
+
}
|
|
1025
|
+
if (result.protocol === 'halfblock') {
|
|
1026
|
+
for (const row of result.segLines ?? []) {
|
|
1027
|
+
out.push({ segs: row })
|
|
1028
|
+
}
|
|
1029
|
+
return
|
|
1030
|
+
}
|
|
1031
|
+
// Every reserved row carries the whole placement so a row that is drawn
|
|
1032
|
+
// without the group's first row above it still knows the x, the width, the
|
|
1033
|
+
// height it belongs to and which group it belongs to; `start` is the group's
|
|
1034
|
+
// own first row, re-anchored to the block's lines by _ensureBlockLines.
|
|
1035
|
+
const gid = ++this._imageGroupSeq
|
|
1036
|
+
const start = out.length
|
|
1037
|
+
for (let i = 0; i < (result.cellsH ?? 1); i++) {
|
|
1038
|
+
out.push({ segs: [], image: { key, gid, x: 2, cellsW: result.cellsW ?? 1, cellsH: result.cellsH ?? 1, top: i === 0, start } })
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
// Markdown lines that may carry media: ```mermaid fences and standalone
|
|
1043
|
+
// images become mermaid/image pipeline lines when the result can render,
|
|
1044
|
+
// falling back to the inline renderings otherwise.
|
|
1045
|
+
_markdownLines(text, block, width, out) {
|
|
1046
|
+
const hooks = { mermaid: true, image: true }
|
|
1047
|
+
for (const line of renderMarkdown(text, THEME, width, hooks)) {
|
|
1048
|
+
if (line && line.mermaid !== undefined) this._mermaidLines(line.mermaid, block, width, out)
|
|
1049
|
+
else if (line && line.image !== undefined) this._markdownImageLines(line.image, block, width, out)
|
|
1050
|
+
else out.push({ segs: line })
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
// A ```mermaid fence: native box-drawing art first, then the image provider
|
|
1055
|
+
// chain (local mmdc, then mermaid.ink) for grammars the engine does not
|
|
1056
|
+
// draw, and the highlighted source when mermaid rendering is off or nothing
|
|
1057
|
+
// else answers.
|
|
1058
|
+
_mermaidLines(code, block, width, out) {
|
|
1059
|
+
const key = 'mermaid:' + sha16(Buffer.from(code, 'utf8'))
|
|
1060
|
+
const off = this.mermaidMode === 'off'
|
|
1061
|
+
|
|
1062
|
+
if (!off && this._mermaidEngine === undefined) {
|
|
1063
|
+
// The engine loads on the first fence and arrives after the paint that
|
|
1064
|
+
// shows the placeholder below. Until it settles there is no art to draw
|
|
1065
|
+
// and no image to ask for either: firing a network render for a diagram
|
|
1066
|
+
// the engine is about to draw natively would leak the diagram text to
|
|
1067
|
+
// mermaid.ink for nothing.
|
|
1068
|
+
this._mermaidEngine = 'loading'
|
|
1069
|
+
loadMermaidEngine().then((engine) => this._mermaidEngineSettled(engine))
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
const engine = this._mermaidEngine
|
|
1073
|
+
if (!off) {
|
|
1074
|
+
if (engine === 'loading') {
|
|
1075
|
+
out.push({ segs: [{ text: tr('image.mermaidRendering'), style: makeStyle({ fg: THEME.textMuted, italic: true }) }] })
|
|
1076
|
+
return
|
|
1077
|
+
}
|
|
1078
|
+
if (engine) {
|
|
1079
|
+
const art = renderMermaidArt(engine, code)
|
|
1080
|
+
if (art) {
|
|
1081
|
+
const budget = width - MERMAID_INDENT_WIDTH - MERMAID_MARGIN
|
|
1082
|
+
if (art.width <= budget) {
|
|
1083
|
+
for (const segs of paintMermaidArt(art, THEME, MERMAID_INDENT)) out.push({ segs })
|
|
1084
|
+
return
|
|
1085
|
+
}
|
|
1086
|
+
// Real art, wider than this pane: name what it needs and show the
|
|
1087
|
+
// source. A raster of the same diagram reads worse, and sending the
|
|
1088
|
+
// source to mermaid.ink to draw what the engine already drew leaks
|
|
1089
|
+
// it for nothing.
|
|
1090
|
+
out.push({ segs: [{ text: tr('image.mermaidTooWide', { width: art.width, budget: Math.max(0, budget) }), style: makeStyle({ fg: THEME.textMuted, italic: true }) }] })
|
|
1091
|
+
for (const line of renderMarkdown('```mermaid\n' + code + '\n```', THEME, width)) {
|
|
1092
|
+
out.push({ segs: line })
|
|
1093
|
+
}
|
|
1094
|
+
return
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
// Off, or a grammar the engine does not draw: the provider chain draws it
|
|
1100
|
+
// as an image unless the setting says a diagram stays its own source.
|
|
1101
|
+
if (off) {
|
|
1102
|
+
for (const line of renderMarkdown('```mermaid\n' + code + '\n```', THEME, width)) {
|
|
1103
|
+
out.push({ segs: line })
|
|
1104
|
+
}
|
|
1105
|
+
return
|
|
1106
|
+
}
|
|
1107
|
+
let result = this._mermaidResults.get(key)
|
|
1108
|
+
if (!result) {
|
|
1109
|
+
result = { state: 'loading' }
|
|
1110
|
+
this._mermaidResults.set(key, result)
|
|
1111
|
+
}
|
|
1112
|
+
this._trackMediaBlock(this._mermaidBlocks, key, block)
|
|
1113
|
+
if (result.state === 'loading') {
|
|
1114
|
+
if (!this._mermaidRequested.has(key)) {
|
|
1115
|
+
this._mermaidRequested.add(key)
|
|
1116
|
+
this.onMermaidRequest?.(code, key)
|
|
1117
|
+
}
|
|
1118
|
+
out.push({ segs: [{ text: tr('image.mermaidRendering'), style: makeStyle({ fg: THEME.textMuted, italic: true }) }] })
|
|
1119
|
+
return
|
|
1120
|
+
}
|
|
1121
|
+
if (result.state === 'done') {
|
|
1122
|
+
this._imageLines({ key: result.imageKey }, block, width, out)
|
|
1123
|
+
return
|
|
1124
|
+
}
|
|
1125
|
+
// fallback / error: the source, highlighted.
|
|
1126
|
+
for (const line of renderMarkdown('```mermaid\n' + code + '\n```', THEME, width)) {
|
|
1127
|
+
out.push({ segs: line })
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
// The lazy engine import resolved (engine, or null when missing/broken).
|
|
1132
|
+
// The first fence painted its placeholder into the per-block line cache
|
|
1133
|
+
// while the import was in flight, and nothing about that paint bumps the
|
|
1134
|
+
// cache key (rev + width) — a repaint alone would reuse the cached
|
|
1135
|
+
// "rendering…" rows forever, until a resize happened to change the width.
|
|
1136
|
+
// The settle therefore invalidates the cache before asking for a repaint.
|
|
1137
|
+
_mermaidEngineSettled(engine) {
|
|
1138
|
+
this._mermaidEngine = engine
|
|
1139
|
+
this._blockLineCache.clear()
|
|
1140
|
+
this._needsRepaint?.()
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
// A standalone markdown image: remote URLs go through the image pipeline,
|
|
1144
|
+
// data URLs decode to bytes locally; anything else keeps the alt text.
|
|
1145
|
+
_markdownImageLines({ url, alt }, block, width, out) {
|
|
1146
|
+
const text = String(url ?? '')
|
|
1147
|
+
if (/^data:image\//i.test(text)) {
|
|
1148
|
+
const decoded = decodeDataUrl(text)
|
|
1149
|
+
if (decoded) {
|
|
1150
|
+
this._imageLines({ kind: 'bytes', key: sha16(decoded.data), bytes: decoded.data }, block, width, out)
|
|
1151
|
+
return
|
|
1152
|
+
}
|
|
1153
|
+
} else if (/^https?:\/\//i.test(text)) {
|
|
1154
|
+
this._imageLines({ kind: 'url', key: 'url:' + sha16(Buffer.from(text, 'utf8')), url: text }, block, width, out)
|
|
1155
|
+
return
|
|
1156
|
+
}
|
|
1157
|
+
out.push({ segs: [{ text: '🖼 ' + (alt || tr('image.altFallback')), style: makeStyle({ fg: THEME.textMuted, italic: true }) }] })
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
_trackMediaBlock(map, key, block) {
|
|
1161
|
+
let blocks = map.get(key)
|
|
1162
|
+
if (!blocks) {
|
|
1163
|
+
blocks = new Set()
|
|
1164
|
+
map.set(key, blocks)
|
|
1165
|
+
}
|
|
1166
|
+
blocks.add(block)
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
// A mermaid provider result landed (done with an image key, or fallback).
|
|
1170
|
+
setMermaidResult(key, result) {
|
|
1171
|
+
this._mermaidResults.set(key, result)
|
|
1172
|
+
const blocks = this._mermaidBlocks.get(key)
|
|
1173
|
+
if (blocks) {
|
|
1174
|
+
for (const b of blocks) b.rev = (b.rev ?? 0) + 1
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
|
|
759
1178
|
startAssistant() {
|
|
760
1179
|
this.detachInboxBlock()
|
|
761
1180
|
const showHeader = this.assistantHeaderPending
|
|
@@ -979,7 +1398,19 @@ export class App {
|
|
|
979
1398
|
this.usage = { input: 0, output: 0 }
|
|
980
1399
|
this.metrics = {}
|
|
981
1400
|
this.scroll = 0
|
|
1401
|
+
this.goal = null
|
|
1402
|
+
this.subagents = []
|
|
1403
|
+
this.railScroll = 0
|
|
982
1404
|
this._blockLineCache.clear()
|
|
1405
|
+
this._imageResults.clear()
|
|
1406
|
+
this._imageBlocks.clear()
|
|
1407
|
+
this._imageRequested.clear()
|
|
1408
|
+
this._imageSources.clear()
|
|
1409
|
+
this._imageCrops.clear()
|
|
1410
|
+
this._imageCropsPrev = new Set()
|
|
1411
|
+
this._mermaidResults.clear()
|
|
1412
|
+
this._mermaidBlocks.clear()
|
|
1413
|
+
this._mermaidRequested.clear()
|
|
983
1414
|
this.resetInbox()
|
|
984
1415
|
}
|
|
985
1416
|
|
|
@@ -991,6 +1422,14 @@ export class App {
|
|
|
991
1422
|
block.rev++
|
|
992
1423
|
}
|
|
993
1424
|
|
|
1425
|
+
// Toggle a tool activity card between the one-line summary and the full
|
|
1426
|
+
// result. A running tool has no result to show yet and stays collapsed.
|
|
1427
|
+
toggleTool(block) {
|
|
1428
|
+
if (!block || block.kind !== 'tool' || block.status === 'running') return
|
|
1429
|
+
block.expanded = block.expanded !== true
|
|
1430
|
+
block.rev++
|
|
1431
|
+
}
|
|
1432
|
+
|
|
994
1433
|
// Toggle a collapsible context box (system-reminder / compaction / system
|
|
995
1434
|
// prompt / pending inbox) between collapsed and expanded. The pending-inbox
|
|
996
1435
|
// box keeps its expansion on the App (it is rebuilt as splices arrive), so
|
|
@@ -1050,7 +1489,7 @@ export class App {
|
|
|
1050
1489
|
|
|
1051
1490
|
scrollTranscript(delta) {
|
|
1052
1491
|
const layout = this._layout()
|
|
1053
|
-
const width = layout.
|
|
1492
|
+
const width = layout.borderX - layout.sidebarW - (layout.sidebarW > 0 ? 1 : 0)
|
|
1054
1493
|
const maxScroll = Math.max(0, this._transcriptTotal(width) - layout.transcriptH)
|
|
1055
1494
|
this.scroll = Math.max(0, Math.min(maxScroll, this.scroll + delta))
|
|
1056
1495
|
}
|
|
@@ -1074,12 +1513,12 @@ export class App {
|
|
|
1074
1513
|
// Auto-dismiss only makes sense when we can repaint to clear it; in
|
|
1075
1514
|
// headless/test use (no term.paint) the toast stays for the caller to
|
|
1076
1515
|
// inspect.
|
|
1077
|
-
if (!this.
|
|
1516
|
+
if (!this.terminal || typeof this.terminal.paint !== 'function') return
|
|
1078
1517
|
this._toastTimer = setTimeout(() => {
|
|
1079
1518
|
this._toastTimer = null
|
|
1080
1519
|
if (this.toast) {
|
|
1081
1520
|
this.toast = null
|
|
1082
|
-
if (this.
|
|
1521
|
+
if (this.terminal.started) this.terminal.paint(this.render())
|
|
1083
1522
|
}
|
|
1084
1523
|
}, 2000)
|
|
1085
1524
|
}
|
|
@@ -1087,21 +1526,29 @@ export class App {
|
|
|
1087
1526
|
// ---- layout ----------------------------------------------------------
|
|
1088
1527
|
|
|
1089
1528
|
_layout() {
|
|
1090
|
-
const cols = this.
|
|
1091
|
-
const rows = this.
|
|
1092
|
-
const headerH =
|
|
1529
|
+
const cols = this.terminal.cols
|
|
1530
|
+
const rows = this.terminal.rows
|
|
1531
|
+
const headerH = 1
|
|
1093
1532
|
const statusH = 1
|
|
1094
1533
|
const sliderH = this.effortSliderVisible && this.effortSlider ? 1 : 0
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1534
|
+
// OpenCode-style: very narrow sidebar (max 12 cols), auto-hide aggressively
|
|
1535
|
+
// Prioritize conversation view - sidebar only shows when explicitly toggled AND space allows
|
|
1536
|
+
let sidebarW = this.sidebarVisible && cols >= 110 ? Math.min(12, Math.floor(cols / 9)) : 0
|
|
1537
|
+
if (cols - sidebarW < 75) sidebarW = 0
|
|
1538
|
+
// The right status rail claims one border column plus RAIL_WIDTH content
|
|
1539
|
+
// columns; `borderX` is the main area's exclusive right edge (the border
|
|
1540
|
+
// glyph's own column). Narrow windows keep the single-column layout.
|
|
1541
|
+
const railW = cols >= RAIL_MIN_COLS ? RAIL_WIDTH : 0
|
|
1542
|
+
const borderX = railW > 0 ? cols - railW - 1 : cols
|
|
1543
|
+
const composerWidth = Math.max(20, borderX - sidebarW - 6)
|
|
1098
1544
|
const visual = inputRows(this.inputText, this.inputCursor, composerWidth)
|
|
1099
1545
|
const suggestions = this.inputText.startsWith('/') && !this.inputText.includes(' ') ? Math.min(COMMAND_HINTS.length, COMMAND_HINTS.filter(([command]) => command.startsWith(this.inputText)).length) : 0
|
|
1100
1546
|
const imageHintH = this.inputImages.length > 0 ? 1 : 0
|
|
1101
1547
|
// The stats strip takes one row directly above the composer, the seat the
|
|
1102
1548
|
// web chat stats line occupies in its composer dock. A session with nothing
|
|
1103
|
-
// to report keeps the row for the transcript
|
|
1104
|
-
|
|
1549
|
+
// to report keeps the row for the transcript, and the rail (which carries
|
|
1550
|
+
// the same figures expanded) drops it.
|
|
1551
|
+
const statsH = railW > 0 ? 0 : this._statsStripVisible() ? 1 : 0
|
|
1105
1552
|
// The composer's content rows. An approval prompt replaces the input text
|
|
1106
1553
|
// and needs more rows than it: the protocol requires the action, summary,
|
|
1107
1554
|
// origin and details to be shown. Its height comes from the same helper the
|
|
@@ -1110,7 +1557,7 @@ export class App {
|
|
|
1110
1557
|
const maxComposerRows = Math.max(1, rows - headerH - statusH - sliderH - imageHintH - statsH - suggestions - 2)
|
|
1111
1558
|
let inputRowsVisible
|
|
1112
1559
|
if (this.pendingApproval) {
|
|
1113
|
-
const approval = this._approvalLines(composerTextWidth(cols, sidebarW), maxComposerRows)
|
|
1560
|
+
const approval = this._approvalLines(composerTextWidth(cols, sidebarW, railW), maxComposerRows)
|
|
1114
1561
|
inputRowsVisible = Math.max(1, Math.min(approval.length, maxComposerRows))
|
|
1115
1562
|
} else {
|
|
1116
1563
|
inputRowsVisible = Math.min(Math.max(1, visual.rows.length), rows >= 28 ? 6 : 3)
|
|
@@ -1119,7 +1566,7 @@ export class App {
|
|
|
1119
1566
|
const transcriptTop = headerH
|
|
1120
1567
|
const transcriptBottom = rows - inputH - statusH - sliderH - imageHintH - statsH
|
|
1121
1568
|
const transcriptH = Math.max(1, transcriptBottom - transcriptTop)
|
|
1122
|
-
return { cols, rows, headerH, inputH, inputRowsVisible, suggestions, imageHintH, statsH, statusH, sliderH, transcriptTop, transcriptBottom, transcriptH, sidebarW, composerWidth, visual }
|
|
1569
|
+
return { cols, rows, headerH, inputH, inputRowsVisible, suggestions, imageHintH, statsH, statusH, sliderH, transcriptTop, transcriptBottom, transcriptH, sidebarW, railW, borderX, composerWidth, visual }
|
|
1123
1570
|
}
|
|
1124
1571
|
|
|
1125
1572
|
// ---- block -> lines --------------------------------------------------
|
|
@@ -1129,102 +1576,180 @@ export class App {
|
|
|
1129
1576
|
const out = []
|
|
1130
1577
|
switch (block.kind) {
|
|
1131
1578
|
case 'user': {
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1579
|
+
// A pointer marks your turn and the text hangs under it — no frame, no
|
|
1580
|
+
// fill, so a long prompt never has to be measured against a border.
|
|
1581
|
+
// The timestamp trails the last line (or its own row when the last line
|
|
1582
|
+
// is full) so a steering message still reads as its own event.
|
|
1583
|
+
const pointerW = 4
|
|
1584
|
+
const hang = ' '.repeat(pointerW)
|
|
1585
|
+
const pointer = { text: ' ❯ ', style: makeStyle({ fg: t.userPointer, bold: true }) }
|
|
1586
|
+
const lines = renderMarkdown(block.text, t, Math.max(8, width - pointerW))
|
|
1587
|
+
if (lines.length === 0) lines.push([])
|
|
1588
|
+
const tail = []
|
|
1589
|
+
if (block.steering) tail.push({ text: tr('transcript.steeringBadge'), style: makeStyle({ fg: t.steering, bold: true }) })
|
|
1590
|
+
tail.push({ text: ' · ' + timeString(block.time), style: makeStyle({ fg: t.textMuted }) })
|
|
1591
|
+
const last = lines[lines.length - 1]
|
|
1592
|
+
const tailW = tail.reduce((n, s) => n + displayWidth(s.text), 0)
|
|
1593
|
+
const lastW = last.reduce((n, s) => n + displayWidth(s.text), 0)
|
|
1594
|
+
// The text hangs at `pointerW`, so the tail only joins it when it fits
|
|
1595
|
+
// in what is left of the row *after* that indent.
|
|
1596
|
+
if (lastW + tailW <= width - pointerW) last.push(...tail)
|
|
1597
|
+
else lines.push([{ text: hang, style: null }, ...tail])
|
|
1598
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1599
|
+
out.push({ segs: i === 0 ? [pointer, ...lines[i]] : [{ text: hang, style: null }, ...lines[i]] })
|
|
1139
1600
|
}
|
|
1601
|
+
for (const src of block.images ?? []) this._imageLines(src, block, width, out)
|
|
1140
1602
|
out.push({ segs: [] })
|
|
1141
1603
|
break
|
|
1142
1604
|
}
|
|
1143
1605
|
case 'assistant': {
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1606
|
+
// A message that only issued tool calls has nothing to say on its own:
|
|
1607
|
+
// its activity lives in the tool rows below, and drawing an empty frame
|
|
1608
|
+
// anyway is what produced the empty bubbles in long tool turns. The
|
|
1609
|
+
// turn's `dsh · time` header must not be swallowed here — pass it to
|
|
1610
|
+
// the next assistant block if there is one.
|
|
1611
|
+
if (block.text === '' && !block.reasoning) {
|
|
1612
|
+
if (block.showHeader === true) {
|
|
1613
|
+
// The next assistant message can sit behind this one's tool rows —
|
|
1614
|
+
// scan past them.
|
|
1615
|
+
let j = this.blocks.indexOf(block) + 1
|
|
1616
|
+
while (j < this.blocks.length && this.blocks[j].kind === 'tool') j++
|
|
1617
|
+
const next = this.blocks[j]
|
|
1618
|
+
if (next?.kind === 'assistant' && next.showHeader === false) {
|
|
1619
|
+
next.showHeader = true
|
|
1620
|
+
next.rev = (next.rev ?? 0) + 1
|
|
1621
|
+
}
|
|
1622
|
+
block.showHeader = false
|
|
1623
|
+
}
|
|
1624
|
+
break
|
|
1148
1625
|
}
|
|
1149
|
-
// Thinking is
|
|
1150
|
-
//
|
|
1151
|
-
//
|
|
1152
|
-
//
|
|
1626
|
+
// Thinking is one flat row: collapsed it names itself, expanded the
|
|
1627
|
+
// body hangs under it in muted italics. No frame and no full-width
|
|
1628
|
+
// band — the boxed shapes measured their own borders and drifted on
|
|
1629
|
+
// wide runes, and the band read as a bar across the transcript.
|
|
1153
1630
|
if (block.reasoning) {
|
|
1154
|
-
const boxBg = t.backgroundElement
|
|
1155
1631
|
const streaming = block.streaming === true
|
|
1156
1632
|
const collapsed = block.thinkingCollapsed === true || streaming
|
|
1157
|
-
const hint = streaming ? '
|
|
1158
|
-
// While streaming, a flowing spinner leads the
|
|
1633
|
+
const hint = streaming ? tr('transcript.streaming') : (collapsed ? tr('common.clickExpand') : tr('common.clickCollapse'))
|
|
1634
|
+
// While streaming, a flowing spinner leads the marker (replaced at
|
|
1159
1635
|
// draw time so the cached lines can stay static between frames).
|
|
1160
1636
|
const marker = streaming
|
|
1161
|
-
? { text: '⠿', style: makeStyle({ fg: t.primary,
|
|
1162
|
-
: { text: collapsed ? '▸' : '▾', style: makeStyle({ fg: t.thinking,
|
|
1163
|
-
const
|
|
1164
|
-
{ text: ' ', style: makeStyle({ fg: t.thinking, bg: boxBg }) },
|
|
1165
|
-
marker,
|
|
1166
|
-
{ text: ' thinking' + hint, style: makeStyle({ fg: t.thinking, bg: boxBg, bold: true }) },
|
|
1167
|
-
]
|
|
1168
|
-
out.push({ segs: boxPad(headerSegs, width, boxBg), thinking: { block } })
|
|
1637
|
+
? { text: '⠿', style: makeStyle({ fg: t.primary, bold: true }), anim: 'spinner' }
|
|
1638
|
+
: { text: collapsed ? '▸' : '▾', style: makeStyle({ fg: t.thinking, bold: true }) }
|
|
1639
|
+
const body = []
|
|
1169
1640
|
if (!collapsed) {
|
|
1170
|
-
for (const line of renderMarkdown(block.reasoning, t, width -
|
|
1171
|
-
|
|
1172
|
-
{ text: ' ', style: makeStyle({ fg: t.thinking, bg: boxBg }) },
|
|
1173
|
-
...line.map((s) => ({
|
|
1174
|
-
...s,
|
|
1175
|
-
style: mergeStyle(s.style, { fg: t.thinking, italic: true, bg: boxBg }),
|
|
1176
|
-
})),
|
|
1177
|
-
], width, boxBg)
|
|
1178
|
-
out.push({ segs, thinking: { block } })
|
|
1641
|
+
for (const line of renderMarkdown(block.reasoning, t, Math.max(8, width - 6))) {
|
|
1642
|
+
body.push(line.map((s) => ({ ...s, style: mergeStyle(s.style, { fg: t.thinking, italic: true }) })))
|
|
1179
1643
|
}
|
|
1180
1644
|
}
|
|
1645
|
+
out.push(...flatRows('thinking', block, [
|
|
1646
|
+
{ text: ' ', style: null },
|
|
1647
|
+
marker,
|
|
1648
|
+
{ text: tr('transcript.thinking') + hint, style: makeStyle({ fg: t.thinking, bold: true }) },
|
|
1649
|
+
], body, 4, width))
|
|
1650
|
+
// A blank line separates the reasoning from the visible answer so
|
|
1651
|
+
// the two never run together.
|
|
1652
|
+
if (block.text) out.push({ segs: [] })
|
|
1181
1653
|
}
|
|
1182
1654
|
let text = block.text
|
|
1183
1655
|
if (block.streaming) text += '▍'
|
|
1184
|
-
//
|
|
1185
|
-
//
|
|
1186
|
-
|
|
1187
|
-
|
|
1656
|
+
// One header per request: a turn split by tool calls renders one
|
|
1657
|
+
// answer per block, and only the first announces `dsh · time`.
|
|
1658
|
+
if (block.showHeader !== false) {
|
|
1659
|
+
out.push({
|
|
1660
|
+
segs: [
|
|
1661
|
+
{ text: ' ', style: null },
|
|
1662
|
+
{ text: 'dsh', style: makeStyle({ fg: t.assistantLabel, bold: true }) },
|
|
1663
|
+
{ text: ' · ' + timeString(block.time), style: makeStyle({ fg: t.textMuted }) },
|
|
1664
|
+
],
|
|
1665
|
+
})
|
|
1666
|
+
}
|
|
1188
1667
|
if (text) {
|
|
1189
|
-
const
|
|
1190
|
-
|
|
1191
|
-
|
|
1668
|
+
const body = []
|
|
1669
|
+
this._markdownLines(text, block, Math.max(8, width - 2), body)
|
|
1670
|
+
// The answer hangs at the same two columns as its header; a media row
|
|
1671
|
+
// (mermaid art, a reserved image slab) already carries its own x
|
|
1672
|
+
// offset, so it passes through untouched.
|
|
1673
|
+
for (const line of body) {
|
|
1674
|
+
if (line.image) {
|
|
1675
|
+
out.push(line)
|
|
1676
|
+
continue
|
|
1677
|
+
}
|
|
1678
|
+
out.push({ segs: [{ text: ' ', style: null }, ...(line.segs ?? [])] })
|
|
1679
|
+
}
|
|
1192
1680
|
}
|
|
1681
|
+
for (const src of block.images ?? []) this._imageLines(src, block, width, out)
|
|
1193
1682
|
out.push({ segs: [] })
|
|
1194
1683
|
break
|
|
1195
1684
|
}
|
|
1196
1685
|
case 'tool': {
|
|
1686
|
+
// OpenCode-style activity row: a status marker, the action in its own
|
|
1687
|
+
// accent, and the target it acts on (the path read, the command run)
|
|
1688
|
+
// in muted text. Collapsed it is exactly that one row; expanded the
|
|
1689
|
+
// result hangs under a ⎿ gutter. The whole block is a click target —
|
|
1690
|
+
// a collapsed row hides its result precisely so a long turn of tool
|
|
1691
|
+
// calls stays scannable, and one click brings the details back.
|
|
1197
1692
|
const running = block.status === 'running'
|
|
1693
|
+
const expanded = block.expanded === true
|
|
1694
|
+
const accent = toolAccent(block.name, t)
|
|
1198
1695
|
const statusColor = running ? t.warning : block.status === 'error' ? t.error : t.success
|
|
1199
|
-
const
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1696
|
+
const marker = running
|
|
1697
|
+
? { text: '⠿', style: makeStyle({ fg: statusColor, bold: true }), anim: 'spinner' }
|
|
1698
|
+
: { text: block.status === 'error' ? '✗' : '✓', style: makeStyle({ fg: statusColor, bold: true }) }
|
|
1699
|
+
const summary = toolSummary(block.name, block.args)
|
|
1700
|
+
const cut = summary.indexOf(' ')
|
|
1701
|
+
const verb = cut < 0 ? summary : summary.slice(0, cut)
|
|
1702
|
+
const rawTarget = cut < 0 ? '' : summary.slice(cut + 1)
|
|
1703
|
+
// The tool row sets its hint one column further out than the notes do,
|
|
1704
|
+
// so the shared " · click to ..." text gets one more leading space.
|
|
1705
|
+
const hint = running ? '' : ' ' + (expanded ? tr('common.clickCollapse') : tr('common.clickExpand'))
|
|
1706
|
+
const budget = Math.max(6, width - 7 - displayWidth(verb) - displayWidth(hint))
|
|
1707
|
+
const target = truncateWidth(rawTarget, budget)
|
|
1708
|
+
out.push({
|
|
1709
|
+
segs: [
|
|
1710
|
+
{ text: ' ', style: null },
|
|
1711
|
+
marker,
|
|
1712
|
+
{ text: ' ', style: null },
|
|
1713
|
+
{ text: verb, style: makeStyle({ fg: accent, bold: true }) },
|
|
1714
|
+
...(target ? [{ text: ' ' + target, style: makeStyle({ fg: t.textMuted }) }] : []),
|
|
1715
|
+
...(hint ? [{ text: hint, style: makeStyle({ fg: t.textMuted, dim: true }) }] : []),
|
|
1716
|
+
],
|
|
1717
|
+
tool: { block },
|
|
1718
|
+
})
|
|
1719
|
+
// Tool-result images (screenshots, generated pictures) render in full
|
|
1720
|
+
// only while expanded — the collapse is a text-economy rule, not a
|
|
1721
|
+
// media one.
|
|
1722
|
+
if (expanded) {
|
|
1723
|
+
const cap = 400
|
|
1724
|
+
const resultLines = renderMarkdown(block.result ?? '', t, Math.max(8, width - 8))
|
|
1725
|
+
const shown = Math.min(resultLines.length, cap)
|
|
1726
|
+
for (let i = 0; i < shown; i++) {
|
|
1727
|
+
out.push({
|
|
1728
|
+
segs: [
|
|
1729
|
+
{ text: ' ', style: null },
|
|
1730
|
+
...(i === 0
|
|
1731
|
+
? [{ text: '⎿', style: makeStyle({ fg: t.textMuted }) }, { text: ' ', style: null }]
|
|
1732
|
+
: [{ text: ' ', style: null }]),
|
|
1733
|
+
...resultLines[i].map((s) => ({ ...s, style: makeStyle({ fg: t.text }) })),
|
|
1734
|
+
],
|
|
1735
|
+
tool: { block },
|
|
1736
|
+
})
|
|
1218
1737
|
}
|
|
1219
|
-
if (resultLines.length >
|
|
1220
|
-
out.push({
|
|
1738
|
+
if (resultLines.length > cap) {
|
|
1739
|
+
out.push({
|
|
1740
|
+
segs: [{ text: ' ' + tr('common.moreLines', { count: resultLines.length - cap }), style: makeStyle({ fg: t.textMuted, dim: true }) }],
|
|
1741
|
+
tool: { block },
|
|
1742
|
+
})
|
|
1221
1743
|
}
|
|
1744
|
+
const from = out.length
|
|
1745
|
+
for (const src of block.images ?? []) this._imageLines(src, block, width, out)
|
|
1746
|
+
for (let i = from; i < out.length; i++) out[i].tool = { block }
|
|
1222
1747
|
}
|
|
1223
1748
|
out.push({ segs: [] })
|
|
1224
1749
|
break
|
|
1225
1750
|
}
|
|
1226
1751
|
case 'todo': {
|
|
1227
|
-
out.push({ segs: [{ text: ' tasks', style: makeStyle({ fg: t.info, bold: true }) }] })
|
|
1752
|
+
out.push({ segs: [{ text: ' ' + tr('transcript.tasks'), style: makeStyle({ fg: t.info, bold: true }) }] })
|
|
1228
1753
|
for (const item of block.todos ?? []) {
|
|
1229
1754
|
const mark = item.status === 'completed' ? '☑' : item.status === 'in_progress' ? '◐' : '□'
|
|
1230
1755
|
const color = item.status === 'completed' ? t.success : item.status === 'in_progress' ? t.warning : t.textMuted
|
|
@@ -1240,29 +1765,23 @@ export class App {
|
|
|
1240
1765
|
break
|
|
1241
1766
|
}
|
|
1242
1767
|
case 'note': {
|
|
1243
|
-
// Context notes (system-reminder / compaction)
|
|
1244
|
-
//
|
|
1245
|
-
//
|
|
1246
|
-
const
|
|
1247
|
-
? { fg: t.compaction, bg: t.compactionBg }
|
|
1248
|
-
: { fg: t.reminder, bg: t.reminderBg }
|
|
1768
|
+
// Context notes (system-reminder / compaction): one flat marker row
|
|
1769
|
+
// naming the label, the body hanging under it in the label's own
|
|
1770
|
+
// color, collapsed by default. Whole block clickable to toggle.
|
|
1771
|
+
const fg = block.label === 'compaction' ? t.compaction : t.reminder
|
|
1249
1772
|
const collapsed = block.collapsed === true
|
|
1250
|
-
const hint = collapsed ? '
|
|
1251
|
-
const
|
|
1252
|
-
{ text: ' ', style: makeStyle({ fg: palette.fg, bg: palette.bg }) },
|
|
1253
|
-
{ text: collapsed ? '▸' : '▾', style: makeStyle({ fg: palette.fg, bg: palette.bg, bold: true }) },
|
|
1254
|
-
{ text: ' ' + block.label + hint, style: makeStyle({ fg: palette.fg, bg: palette.bg, bold: true }) },
|
|
1255
|
-
]
|
|
1256
|
-
out.push({ segs: boxPad(headerSegs, width, palette.bg), note: { block } })
|
|
1773
|
+
const hint = collapsed ? tr('common.clickExpand') : tr('common.clickCollapse')
|
|
1774
|
+
const body = []
|
|
1257
1775
|
if (!collapsed) {
|
|
1258
|
-
for (const line of renderMarkdown(block.text, t, width -
|
|
1259
|
-
|
|
1260
|
-
{ text: ' ', style: makeStyle({ fg: palette.fg, bg: palette.bg }) },
|
|
1261
|
-
...line.map((s) => ({ ...s, style: mergeStyle(s.style, { fg: palette.fg, bg: palette.bg }) })),
|
|
1262
|
-
], width, palette.bg)
|
|
1263
|
-
out.push({ segs, note: { block } })
|
|
1776
|
+
for (const line of renderMarkdown(block.text, t, Math.max(8, width - 6))) {
|
|
1777
|
+
body.push(line.map((s) => ({ ...s, style: mergeStyle(s.style, { fg }) })))
|
|
1264
1778
|
}
|
|
1265
1779
|
}
|
|
1780
|
+
out.push(...flatRows('note', block, [
|
|
1781
|
+
{ text: ' ', style: null },
|
|
1782
|
+
{ text: collapsed ? '▸' : '▾', style: makeStyle({ fg, bold: true }) },
|
|
1783
|
+
{ text: ' ' + tr(block.label === 'compaction' ? 'note.compaction' : 'note.systemReminder') + hint, style: makeStyle({ fg, bold: true }) },
|
|
1784
|
+
], body, 4, width))
|
|
1266
1785
|
out.push({ segs: [] })
|
|
1267
1786
|
break
|
|
1268
1787
|
}
|
|
@@ -1275,63 +1794,58 @@ export class App {
|
|
|
1275
1794
|
break
|
|
1276
1795
|
}
|
|
1277
1796
|
case 'sysnote': {
|
|
1278
|
-
// The session's system prompt (V3 `system/message`)
|
|
1279
|
-
//
|
|
1280
|
-
// never reads as a reminder or a compaction checkpoint.
|
|
1281
|
-
const
|
|
1797
|
+
// The session's system prompt (V3 `system/message`): the same flat
|
|
1798
|
+
// collapsible shape as the other notes, in its own neutral palette so
|
|
1799
|
+
// it never reads as a reminder or a compaction checkpoint.
|
|
1800
|
+
const fg = t.systemPrompt
|
|
1282
1801
|
const collapsed = block.collapsed === true
|
|
1283
|
-
const hint = collapsed ? '
|
|
1284
|
-
const
|
|
1285
|
-
{ text: ' ', style: makeStyle({ fg: palette.fg, bg: palette.bg }) },
|
|
1286
|
-
{ text: collapsed ? '▸' : '▾', style: makeStyle({ fg: palette.fg, bg: palette.bg, bold: true }) },
|
|
1287
|
-
{ text: ' system prompt' + hint, style: makeStyle({ fg: palette.fg, bg: palette.bg, bold: true }) },
|
|
1288
|
-
]
|
|
1289
|
-
out.push({ segs: boxPad(headerSegs, width, palette.bg), note: { block } })
|
|
1802
|
+
const hint = collapsed ? tr('common.clickExpand') : tr('common.clickCollapse')
|
|
1803
|
+
const body = []
|
|
1290
1804
|
if (!collapsed) {
|
|
1291
|
-
for (const line of renderMarkdown(block.text, t, width -
|
|
1292
|
-
|
|
1293
|
-
{ text: ' ', style: makeStyle({ fg: palette.fg, bg: palette.bg }) },
|
|
1294
|
-
...line.map((s) => ({ ...s, style: mergeStyle(s.style, { fg: palette.fg, bg: palette.bg }) })),
|
|
1295
|
-
], width, palette.bg)
|
|
1296
|
-
out.push({ segs, note: { block } })
|
|
1805
|
+
for (const line of renderMarkdown(block.text, t, Math.max(8, width - 6))) {
|
|
1806
|
+
body.push(line.map((s) => ({ ...s, style: mergeStyle(s.style, { fg }) })))
|
|
1297
1807
|
}
|
|
1298
1808
|
}
|
|
1809
|
+
out.push(...flatRows('note', block, [
|
|
1810
|
+
{ text: ' ', style: null },
|
|
1811
|
+
{ text: collapsed ? '▸' : '▾', style: makeStyle({ fg, bold: true }) },
|
|
1812
|
+
{ text: tr('transcript.systemPrompt') + hint, style: makeStyle({ fg, bold: true }) },
|
|
1813
|
+
], body, 4, width))
|
|
1299
1814
|
out.push({ segs: [] })
|
|
1300
1815
|
break
|
|
1301
1816
|
}
|
|
1302
1817
|
case 'inbox': {
|
|
1303
1818
|
// Admitted-but-unclaimed input. "steering" entries are injected at the
|
|
1304
1819
|
// next step boundary and are consumed first, so they lead; "queued"
|
|
1305
|
-
// entries wait for their own turn.
|
|
1306
|
-
|
|
1820
|
+
// entries wait for their own turn. A flat marker row plus one preview
|
|
1821
|
+
// line per entry, each kind labeled next to its marker.
|
|
1822
|
+
const fg = t.inbox
|
|
1307
1823
|
const nextStep = block.nextStep ?? []
|
|
1308
1824
|
const nextTurn = block.nextTurn ?? []
|
|
1309
1825
|
const expanded = block.expanded === true
|
|
1310
1826
|
const counts = []
|
|
1311
|
-
if (nextStep.length > 0) counts.push(nextStep.length + '
|
|
1312
|
-
if (nextTurn.length > 0) counts.push(nextTurn.length + '
|
|
1313
|
-
const hint = expanded ? '
|
|
1314
|
-
const
|
|
1315
|
-
{
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
]
|
|
1319
|
-
out.push({ segs: boxPad(headerSegs, width, palette.bg), note: { block } })
|
|
1827
|
+
if (nextStep.length > 0) counts.push(nextStep.length + tr('transcript.steering'))
|
|
1828
|
+
if (nextTurn.length > 0) counts.push(nextTurn.length + tr('transcript.queued'))
|
|
1829
|
+
const hint = expanded ? tr('common.clickCollapse') : tr('common.clickExpand')
|
|
1830
|
+
const rows = [
|
|
1831
|
+
...nextStep.map((message) => ({ marker: '⟲', kind: tr('transcript.steering').trim(), message })),
|
|
1832
|
+
...nextTurn.map((message) => ({ marker: '↳', kind: tr('transcript.queued').trim(), message })),
|
|
1833
|
+
]
|
|
1834
|
+
const body = []
|
|
1320
1835
|
if (expanded) {
|
|
1321
|
-
const rows = [
|
|
1322
|
-
...nextStep.map((message) => ({ marker: '⟲', kind: 'steering', message })),
|
|
1323
|
-
...nextTurn.map((message) => ({ marker: '↳', kind: 'queued', message })),
|
|
1324
|
-
]
|
|
1325
1836
|
for (const { marker, kind, message } of rows) {
|
|
1326
|
-
|
|
1327
|
-
{ text: '
|
|
1328
|
-
{ text:
|
|
1329
|
-
{ text:
|
|
1330
|
-
|
|
1331
|
-
], width, palette.bg)
|
|
1332
|
-
out.push({ segs, note: { block } })
|
|
1837
|
+
body.push([
|
|
1838
|
+
{ text: marker + ' ', style: makeStyle({ fg, bold: true }) },
|
|
1839
|
+
{ text: kind + ' ', style: makeStyle({ fg, dim: true }) },
|
|
1840
|
+
{ text: inboxPreview(message.text, Math.max(8, width - 16)), style: makeStyle({ fg: t.text }) },
|
|
1841
|
+
])
|
|
1333
1842
|
}
|
|
1334
1843
|
}
|
|
1844
|
+
out.push(...flatRows('note', block, [
|
|
1845
|
+
{ text: ' ', style: null },
|
|
1846
|
+
{ text: expanded ? '▾' : '▸', style: makeStyle({ fg, bold: true }) },
|
|
1847
|
+
{ text: tr('transcript.pendingInput') + counts.join(' · ') + hint, style: makeStyle({ fg, bold: true }) },
|
|
1848
|
+
], body, 6, width))
|
|
1335
1849
|
out.push({ segs: [] })
|
|
1336
1850
|
break
|
|
1337
1851
|
}
|
|
@@ -1353,6 +1867,17 @@ export class App {
|
|
|
1353
1867
|
return cached.lines
|
|
1354
1868
|
}
|
|
1355
1869
|
const rendered = this._blockLines(block, width)
|
|
1870
|
+
// `start` was captured while the image rows were still in whatever array the
|
|
1871
|
+
// block renderer was filling — a bubble builds its body first and wraps it
|
|
1872
|
+
// afterwards, so the index the rows were given is not the one they end up
|
|
1873
|
+
// at. Re-anchor it here, where the block's final lines are known: the draw
|
|
1874
|
+
// pass reads it as "how many rows of this group sit above the window".
|
|
1875
|
+
for (let i = 0; i < rendered.length; i++) {
|
|
1876
|
+
const img = rendered[i]?.image
|
|
1877
|
+
if (!img) continue
|
|
1878
|
+
const prev = rendered[i - 1]?.image
|
|
1879
|
+
img.start = prev && prev.gid === img.gid ? prev.start : i
|
|
1880
|
+
}
|
|
1356
1881
|
if (block.streaming) this._streamingRenderAt = Date.now()
|
|
1357
1882
|
this._blockLineCache.set(block, { key, lines: rendered })
|
|
1358
1883
|
return rendered
|
|
@@ -1368,54 +1893,87 @@ export class App {
|
|
|
1368
1893
|
// ---- paint -----------------------------------------------------------
|
|
1369
1894
|
|
|
1370
1895
|
render() {
|
|
1371
|
-
const { cols, rows, headerH, inputRowsVisible, suggestions, imageHintH, statsH, transcriptTop, transcriptBottom, transcriptH, sidebarW, visual } = this._layout()
|
|
1896
|
+
const { cols, rows, headerH, inputRowsVisible, suggestions, imageHintH, statsH, transcriptTop, transcriptBottom, transcriptH, sidebarW, railW, borderX, visual } = this._layout()
|
|
1372
1897
|
this.hitRegions = []
|
|
1373
1898
|
const screen = new Screen(cols, rows)
|
|
1374
1899
|
const t = THEME
|
|
1375
1900
|
screen.clear(makeStyle({ bg: t.background }))
|
|
1376
1901
|
|
|
1377
|
-
// Header: brand + session name
|
|
1902
|
+
// Header: brand + session name on the left. The right end carries the
|
|
1903
|
+
// workspace the open session is rooted in; the model is deliberately not
|
|
1904
|
+
// painted here — the status row (narrow) and the rail's MODEL section
|
|
1905
|
+
// (wide) already name it, and a second copy read as clutter. When the row
|
|
1906
|
+
// runs tight the label yields first, then the branch (truncated, not
|
|
1907
|
+
// dropped while it still fits); the path itself is shortened from the head
|
|
1908
|
+
// so the project folder stays readable at any width.
|
|
1378
1909
|
const headerStyle = makeStyle({ fg: t.textMuted, bg: t.backgroundPanel })
|
|
1379
1910
|
screen.fill(0, 0, cols, ' ', headerStyle)
|
|
1380
|
-
const
|
|
1381
|
-
const modelX = cols - displayWidth(modelInfo) - 2
|
|
1911
|
+
const branch = this.gitBranch ? 'git: ' + this.gitBranch : ''
|
|
1382
1912
|
let hx = 2
|
|
1383
1913
|
hx = screen.text(hx, 0, '◈ ', makeStyle({ fg: t.primary, bold: true, bg: t.backgroundPanel }))
|
|
1384
1914
|
hx = gradientText(screen, hx, 0, 'DeepSeek Harness TUI', t.primary, '#dce6ff', { bold: true, bg: t.backgroundPanel })
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
screen.fill(0, 1, cols, ' ', makeStyle({ bg: barBg }))
|
|
1412
|
-
if (path) {
|
|
1413
|
-
let wx = screen.text(2, 1, WORKSPACE_LABEL, makeStyle({ fg: t.textMuted, bold: true, bg: barBg }))
|
|
1414
|
-
wx = screen.text(wx + 1, 1, path, makeStyle({ fg: t.text, bg: barBg }))
|
|
1415
|
-
if (branch && wx + 3 + displayWidth(branch) <= cols - 2) {
|
|
1416
|
-
screen.text(wx + 3, 1, branch, makeStyle({ fg: t.success, bg: barBg }))
|
|
1915
|
+
let workspace = null
|
|
1916
|
+
// The placeholder a session with no title of its own shows: resolved here,
|
|
1917
|
+
// not when the session was opened, so a language switch renames it.
|
|
1918
|
+
const sessionTitle = this.untitled ? tr('session.newTitle') : this.title
|
|
1919
|
+
const hasTitle = Boolean(sessionTitle) && sessionTitle !== 'DeepSeek Harness'
|
|
1920
|
+
// The right block takes what is left of the row after the brand, the
|
|
1921
|
+
// session title and the margins. Within that budget the pieces yield in
|
|
1922
|
+
// order — the label first, then the branch (truncated, not dropped while
|
|
1923
|
+
// it still fits) — while the path is shortened from the head so the
|
|
1924
|
+
// project folder stays readable. The title itself gives ground only down
|
|
1925
|
+
// to 8 columns before the workspace gives up entirely.
|
|
1926
|
+
const workspaceLabel = tr(WORKSPACE_LABEL_KEY)
|
|
1927
|
+
const workspaceLabelW = displayWidth(workspaceLabel)
|
|
1928
|
+
const workspaceFor = (budget) => {
|
|
1929
|
+
if (!this.titleScreen && this.workingDirectory) {
|
|
1930
|
+
for (const [withLabel, withBranch] of [[true, true], [false, true], [false, false]]) {
|
|
1931
|
+
const branchW = withBranch && branch ? Math.min(displayWidth(branch), 20) + 3 : 0
|
|
1932
|
+
const labelW = withLabel ? workspaceLabelW + 1 : 0
|
|
1933
|
+
const pathRoom = budget - branchW - labelW
|
|
1934
|
+
if (pathRoom >= WORKSPACE_MIN_PATH) {
|
|
1935
|
+
return {
|
|
1936
|
+
label: withLabel,
|
|
1937
|
+
path: shortenPath(this.workingDirectory, pathRoom),
|
|
1938
|
+
branch: withBranch && branch ? truncateWidth(branch, 20) : '',
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1417
1941
|
}
|
|
1418
1942
|
}
|
|
1943
|
+
return null
|
|
1944
|
+
}
|
|
1945
|
+
let titleW = hasTitle ? displayWidth(sessionTitle) : 0
|
|
1946
|
+
const wsPossible = !this.titleScreen && this.workingDirectory
|
|
1947
|
+
const titleSeat = hx + (hasTitle ? displayWidth(' · ') + titleW + 2 : 0)
|
|
1948
|
+
workspace = workspaceFor(cols - 2 - titleSeat)
|
|
1949
|
+
if (!workspace && wsPossible && titleW > 8) {
|
|
1950
|
+
const retry = workspaceFor(cols - 2 - (hx + displayWidth(' · ') + 8 + 2))
|
|
1951
|
+
if (retry) {
|
|
1952
|
+
titleW = 8
|
|
1953
|
+
workspace = retry
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
if (hasTitle) {
|
|
1957
|
+
const rightW = workspace
|
|
1958
|
+
? (workspace.label ? workspaceLabelW + 1 : 0) + displayWidth(workspace.path)
|
|
1959
|
+
+ (workspace.branch ? displayWidth(workspace.branch) + 3 : 0)
|
|
1960
|
+
: 0
|
|
1961
|
+
hx = screen.text(hx, 0, ' · ', makeStyle({ fg: t.textMuted, bg: t.backgroundPanel }))
|
|
1962
|
+
// The title may grow back into whatever slack the shrunken allocation
|
|
1963
|
+
// left between it and the right block — the block is right-anchored, so
|
|
1964
|
+
// the extra columns are pure gap otherwise.
|
|
1965
|
+
const room = (workspace ? cols - 2 - rightW - 2 : cols - 2) - hx
|
|
1966
|
+
hx = screen.text(hx, 0, truncateWidth(sessionTitle, Math.max(1, room)), makeStyle({ fg: t.text, bold: true, bg: t.backgroundPanel }))
|
|
1967
|
+
}
|
|
1968
|
+
if (workspace) {
|
|
1969
|
+
const rightW = (workspace.label ? workspaceLabelW + 1 : 0) + displayWidth(workspace.path)
|
|
1970
|
+
+ (workspace.branch ? displayWidth(workspace.branch) + 3 : 0)
|
|
1971
|
+
let wx = cols - 2 - rightW
|
|
1972
|
+
if (workspace.label) {
|
|
1973
|
+
wx = screen.text(wx, 0, workspaceLabel, makeStyle({ fg: t.textMuted, bg: t.backgroundPanel })) + 1
|
|
1974
|
+
}
|
|
1975
|
+
wx = screen.text(wx, 0, workspace.path, makeStyle({ fg: t.text, bg: t.backgroundPanel }))
|
|
1976
|
+
if (workspace.branch) screen.text(wx + 3, 0, workspace.branch, makeStyle({ fg: t.success, bg: t.backgroundPanel }))
|
|
1419
1977
|
}
|
|
1420
1978
|
|
|
1421
1979
|
// Sidebar
|
|
@@ -1424,9 +1982,9 @@ export class App {
|
|
|
1424
1982
|
transcriptX = sidebarW + 1
|
|
1425
1983
|
const sideStyle = makeStyle({ fg: t.textMuted, bg: t.backgroundPanel })
|
|
1426
1984
|
for (let y = headerH; y < transcriptBottom; y++) screen.fill(0, y, sidebarW, ' ', sideStyle)
|
|
1427
|
-
screen.text(2, headerH, '
|
|
1985
|
+
screen.text(2, headerH, tr('sidebar.sessions'), makeStyle({ fg: t.textMuted, bold: true, bg: t.backgroundPanel }))
|
|
1428
1986
|
const newSessionStyle = makeStyle({ fg: t.primary, bold: true, bg: t.backgroundPanel })
|
|
1429
|
-
screen.text(1, headerH + 1, '
|
|
1987
|
+
screen.text(1, headerH + 1, tr('sidebar.newSession'), newSessionStyle)
|
|
1430
1988
|
this.addHitRegion('new-session', 0, headerH + 1, sidebarW)
|
|
1431
1989
|
let sy = headerH + 3
|
|
1432
1990
|
const active = this.sessionId
|
|
@@ -1442,7 +2000,7 @@ export class App {
|
|
|
1442
2000
|
}
|
|
1443
2001
|
if (this.sidebarSessions.length > 0) {
|
|
1444
2002
|
if (sy < transcriptTop + transcriptH - 1) {
|
|
1445
|
-
screen.text(2, sy, '
|
|
2003
|
+
screen.text(2, sy, tr('sidebar.recent'), makeStyle({ fg: t.textMuted, bold: true, bg: t.backgroundPanel }))
|
|
1446
2004
|
sy++
|
|
1447
2005
|
}
|
|
1448
2006
|
for (let i = 0; i < this.sidebarSessions.length; i++) {
|
|
@@ -1464,7 +2022,8 @@ export class App {
|
|
|
1464
2022
|
|
|
1465
2023
|
// Transcript. Only the visible window is materialised (never the whole
|
|
1466
2024
|
// history), so render cost stays bounded no matter how long the session is.
|
|
1467
|
-
const transWidth =
|
|
2025
|
+
const transWidth = borderX - transcriptX
|
|
2026
|
+
this._lastTransWidth = transWidth
|
|
1468
2027
|
this.addHitRegion('transcript', transcriptX, transcriptTop, transWidth, transcriptH)
|
|
1469
2028
|
const total = this._transcriptTotal(transWidth)
|
|
1470
2029
|
const maxScroll = Math.max(0, total - transcriptH)
|
|
@@ -1474,6 +2033,7 @@ export class App {
|
|
|
1474
2033
|
const endIndex = Math.min(total, offset + transcriptH)
|
|
1475
2034
|
let cursor = 0
|
|
1476
2035
|
let row = 0
|
|
2036
|
+
const usedCrops = new Set()
|
|
1477
2037
|
for (const block of this.blocks) {
|
|
1478
2038
|
const lines = this._ensureBlockLines(block, transWidth)
|
|
1479
2039
|
const blockEnd = cursor + lines.length
|
|
@@ -1490,14 +2050,44 @@ export class App {
|
|
|
1490
2050
|
// column) can be wider than the box even when the markdown renderer
|
|
1491
2051
|
// respected its own limit. Letting it through would paint past the
|
|
1492
2052
|
// terminal edge, wrap the row, and shift the rest of the frame.
|
|
1493
|
-
const budget =
|
|
2053
|
+
const budget = transWidth
|
|
1494
2054
|
for (const seg of clipSegs(line.segs, budget)) {
|
|
1495
2055
|
// Animated placeholders (spinners) are resolved at draw time so
|
|
1496
2056
|
// the cached lines stay static between animation frames.
|
|
1497
2057
|
x = screen.text(x, y, seg.anim ? this.animChar() : seg.text, seg.style)
|
|
1498
2058
|
}
|
|
1499
|
-
|
|
1500
|
-
//
|
|
2059
|
+
// The row tail fills to the main area's right edge; with the status
|
|
2060
|
+
// rail on screen the fill stops short of the rail's border column.
|
|
2061
|
+
if (borderX < cols) screen.fill(x, y, Math.max(0, borderX - x), ' ', makeStyle({ fg: t.text }))
|
|
2062
|
+
else screen.fillToEnd(x, y, makeStyle({ fg: t.text }))
|
|
2063
|
+
// A graphics-protocol image row: the cells stay blank (background
|
|
2064
|
+
// above), and the terminal draws pixels over them via the slab
|
|
2065
|
+
// registered here.
|
|
2066
|
+
if (line.image) {
|
|
2067
|
+
const img = line.image
|
|
2068
|
+
// The group's first row can be above the window: the transcript is
|
|
2069
|
+
// scrolled past the top of the image. Only the rows that are left
|
|
2070
|
+
// are reserved then, and the payload for them is a crop of the same
|
|
2071
|
+
// source — placing the whole image would draw its scrolled-away
|
|
2072
|
+
// rows back over the window.
|
|
2073
|
+
const clip = Math.max(0, Math.min(from - img.start, img.cellsH - 1))
|
|
2074
|
+
const cropKey = clip > 0 ? img.key + '\u0000' + clip : img.key
|
|
2075
|
+
// `i === from` because the group's own first row can be above the
|
|
2076
|
+
// window, and then every row in it is a continuation row.
|
|
2077
|
+
if (i === from || lines[i - 1]?.image?.gid !== img.gid) {
|
|
2078
|
+
if (clip > 0) this._requestImageCrop(img.key, clip)
|
|
2079
|
+
screen.setImageRow(y, {
|
|
2080
|
+
key: cropKey,
|
|
2081
|
+
x: transcriptX + img.x,
|
|
2082
|
+
cellsW: img.cellsW,
|
|
2083
|
+
cellsH: img.cellsH - clip,
|
|
2084
|
+
top: true,
|
|
2085
|
+
})
|
|
2086
|
+
}
|
|
2087
|
+
usedCrops.add(cropKey)
|
|
2088
|
+
}
|
|
2089
|
+
// The whole thinking card is a click target that toggles
|
|
2090
|
+
// expand/collapse; the region hugs the card, not the row.
|
|
1501
2091
|
if (line.thinking) {
|
|
1502
2092
|
this.addHitRegion('thinking', transcriptX, y, transWidth, 1, { thinkingBlock: line.thinking.block })
|
|
1503
2093
|
}
|
|
@@ -1505,6 +2095,10 @@ export class App {
|
|
|
1505
2095
|
if (line.note) {
|
|
1506
2096
|
this.addHitRegion('note', transcriptX, y, transWidth, 1, { noteBlock: line.note.block })
|
|
1507
2097
|
}
|
|
2098
|
+
// Tool activity cards expand to their full result on click.
|
|
2099
|
+
if (line.tool) {
|
|
2100
|
+
this.addHitRegion('tool', transcriptX, y, transWidth, 1, { toolBlock: line.tool.block })
|
|
2101
|
+
}
|
|
1508
2102
|
row++
|
|
1509
2103
|
}
|
|
1510
2104
|
}
|
|
@@ -1513,30 +2107,41 @@ export class App {
|
|
|
1513
2107
|
}
|
|
1514
2108
|
for (; row < transcriptH; row++) {
|
|
1515
2109
|
const y = transcriptTop + row
|
|
1516
|
-
screen.fill(transcriptX, y,
|
|
2110
|
+
screen.fill(transcriptX, y, borderX - transcriptX, ' ', makeStyle({ bg: t.background }))
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
// Release the cropped variants these last two frames did not show. Each one
|
|
2114
|
+
// holds an encoded payload, and scrolling a tall image steps through every
|
|
2115
|
+
// crop offset — without this the transcript would accumulate one payload
|
|
2116
|
+
// per row ever scrolled past. Two frames of grace so a payload queued for
|
|
2117
|
+
// the paint that follows this render is not dropped underneath it.
|
|
2118
|
+
for (const [key, live] of this._imageCrops) {
|
|
2119
|
+
for (const cropKey of live) {
|
|
2120
|
+
if (usedCrops.has(cropKey) || this._imageCropsPrev.has(cropKey)) continue
|
|
2121
|
+
live.delete(cropKey)
|
|
2122
|
+
this._imageResults.delete(cropKey)
|
|
2123
|
+
this.terminal.dropImagePayload?.(cropKey)
|
|
2124
|
+
}
|
|
2125
|
+
if (live.size === 0) this._imageCrops.delete(key)
|
|
1517
2126
|
}
|
|
2127
|
+
this._imageCropsPrev = usedCrops
|
|
1518
2128
|
|
|
1519
2129
|
if (this.titleScreen && this.blocks.length === 0) {
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
const branch = 'git: ' + this.gitBranch
|
|
1531
|
-
screen.text(centerX - Math.floor(displayWidth(branch) / 2), centerY + 3, branch, makeStyle({ fg: t.success, bg: t.background }))
|
|
1532
|
-
}
|
|
1533
|
-
const hint = 'Ctrl+P Settings · Tab thinking'
|
|
1534
|
-
screen.text(centerX - Math.floor(displayWidth(hint) / 2), centerY + 5, hint, makeStyle({ fg: t.textMuted, bg: t.background }))
|
|
2130
|
+
// OpenCode-style splash: DeepSeek brand mark with workspace/git context.
|
|
2131
|
+
// The composer claims the rows below `floor`, so the shortcut row has to
|
|
2132
|
+
// sit above it or it would be painted over. The mark centers in the main
|
|
2133
|
+
// area, never under the status rail.
|
|
2134
|
+
paintSplashOpenCode(screen, cols, rows, t, {
|
|
2135
|
+
workingDirectory: this.workingDirectory,
|
|
2136
|
+
gitBranch: this.gitBranch,
|
|
2137
|
+
model: this.model,
|
|
2138
|
+
provider: this.provider,
|
|
2139
|
+
}, transcriptBottom + statsH - 1, { x0: 0, width: borderX })
|
|
1535
2140
|
}
|
|
1536
2141
|
|
|
1537
2142
|
// Composer
|
|
1538
2143
|
const composerX = sidebarW > 0 ? sidebarW + 2 : 1
|
|
1539
|
-
const composerW =
|
|
2144
|
+
const composerW = borderX - composerX - 1
|
|
1540
2145
|
let composerTop = transcriptBottom + statsH
|
|
1541
2146
|
|
|
1542
2147
|
// Stats strip: the web chat's session stats line, one row between the
|
|
@@ -1572,12 +2177,12 @@ export class App {
|
|
|
1572
2177
|
for (const [command, description] of matches) {
|
|
1573
2178
|
screen.fill(composerX, composerTop, composerW, ' ', makeStyle({ bg: t.backgroundElement }))
|
|
1574
2179
|
screen.text(composerX + 2, composerTop, command, makeStyle({ fg: t.primary, bold: true, bg: t.backgroundElement }))
|
|
1575
|
-
screen.text(composerX + 18, composerTop, description, makeStyle({ fg: t.textMuted, bg: t.backgroundElement }))
|
|
2180
|
+
screen.text(composerX + 18, composerTop, tr(description), makeStyle({ fg: t.textMuted, bg: t.backgroundElement }))
|
|
1576
2181
|
composerTop++
|
|
1577
2182
|
}
|
|
1578
2183
|
}
|
|
1579
2184
|
if (imageHintH) {
|
|
1580
|
-
const hint = '
|
|
2185
|
+
const hint = tr('composer.imageHint')
|
|
1581
2186
|
screen.fill(composerX, composerTop, composerW, ' ', makeStyle({ bg: t.background }))
|
|
1582
2187
|
screen.text(composerX + 2, composerTop, truncateWidth(hint, composerW - 4), makeStyle({ fg: t.warning, bold: true, bg: t.background }))
|
|
1583
2188
|
composerTop++
|
|
@@ -1602,7 +2207,7 @@ export class App {
|
|
|
1602
2207
|
// The approval prompt replaces the composer's content. Computed once: the
|
|
1603
2208
|
// same helper _layout used to size the box, so the two agree by construction.
|
|
1604
2209
|
const approvalLines = this.pendingApproval
|
|
1605
|
-
? this._approvalLines(composerTextWidth(cols, sidebarW), inputRowsVisible)
|
|
2210
|
+
? this._approvalLines(composerTextWidth(cols, sidebarW, railW), inputRowsVisible)
|
|
1606
2211
|
: null
|
|
1607
2212
|
for (let i = 0; i < inputRowsVisible; i++) {
|
|
1608
2213
|
const y = composerTop + 1 + i
|
|
@@ -1655,12 +2260,19 @@ export class App {
|
|
|
1655
2260
|
} else {
|
|
1656
2261
|
screen.text(composerX, bottom, '╰' + '─'.repeat(Math.max(0, composerW - 2)) + '╯', borderStyle)
|
|
1657
2262
|
}
|
|
1658
|
-
|
|
1659
|
-
|
|
2263
|
+
// The composer's mode label names the model that will receive the message.
|
|
2264
|
+
// With the status rail on screen the rail's MODEL section owns that fact,
|
|
2265
|
+
// so the label only stays for the interrupt hint.
|
|
2266
|
+
const mode = this.status === 'running'
|
|
2267
|
+
? tr('status.interrupt')
|
|
2268
|
+
: railW > 0 ? '' : (this.provider ? this.provider + ' · ' : '') + (this.model || tr('status.model'))
|
|
2269
|
+
if (mode !== '') {
|
|
2270
|
+
screen.text(composerX + 2, bottom, ' ' + truncateWidth(mode, Math.max(0, composerW - 6)) + ' ', makeStyle({ fg: this.status === 'running' ? t.warning : t.textMuted, bg: t.background }))
|
|
2271
|
+
}
|
|
1660
2272
|
|
|
1661
2273
|
// Reasoning-effort slider: one row between the composer and the status
|
|
1662
2274
|
// row, driven by the current model's real selectable levels.
|
|
1663
|
-
if (this.effortSliderVisible) this._paintEffortSlider(screen, cols, rows)
|
|
2275
|
+
if (this.effortSliderVisible) this._paintEffortSlider(screen, cols, rows, borderX)
|
|
1664
2276
|
|
|
1665
2277
|
// Status row
|
|
1666
2278
|
const statusRow = rows - 1
|
|
@@ -1680,28 +2292,37 @@ export class App {
|
|
|
1680
2292
|
const dotColor = this.status === 'running' ? t.success : t.textMuted
|
|
1681
2293
|
screen.text(1, statusRow, statusDot, makeStyle({ fg: dotColor, bg: t.background }))
|
|
1682
2294
|
}
|
|
1683
|
-
// Left cluster: the
|
|
1684
|
-
//
|
|
1685
|
-
//
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
const
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
2295
|
+
// Left cluster: with the rail on screen the model, thinking and context
|
|
2296
|
+
// figures live expanded in the rail, so the row keeps the live indicator
|
|
2297
|
+
// and the draft-token estimate, plus a shortcut hint at the right end.
|
|
2298
|
+
// Without the rail the model name leads the row and the context meter owns
|
|
2299
|
+
// the right end, sized to whatever space remains — the model name survives
|
|
2300
|
+
// before the draft count does when the row is crowded.
|
|
2301
|
+
const tokText = this.usage.input > 0 ? '' : tr('status.draftTokens', { count: roughTokens(this.inputText) })
|
|
2302
|
+
if (railW > 0) {
|
|
2303
|
+
if (tokText) screen.text(leftX, statusRow, tokText, statusStyle)
|
|
2304
|
+
const hint = tr('status.ctrlP')
|
|
2305
|
+
const hintX = cols - displayWidth(hint) - 2
|
|
2306
|
+
if (hintX > leftX + displayWidth(tokText) + 2) {
|
|
2307
|
+
screen.text(hintX, statusRow, hint, makeStyle({ fg: t.textMuted, dim: true, bg: t.background }))
|
|
2308
|
+
}
|
|
2309
|
+
} else {
|
|
2310
|
+
const modelName = this.model || tr('status.model')
|
|
2311
|
+
const leftBase = ' ' + modelName
|
|
2312
|
+
const leftWithTokens = tokText ? leftBase + ' · ' + tokText : leftBase
|
|
2313
|
+
const metricRight = cols - 2
|
|
2314
|
+
const meterGeom = this._contextMeterGeometry(statusRow, leftX + 1, metricRight)
|
|
2315
|
+
const leftBudget = meterGeom
|
|
2316
|
+
? Math.max(0, meterGeom.x0 - leftX - 1)
|
|
2317
|
+
: Math.max(0, Math.floor(cols * 0.42))
|
|
2318
|
+
const leftClipped = displayWidth(leftWithTokens) <= leftBudget
|
|
2319
|
+
? leftWithTokens
|
|
2320
|
+
: displayWidth(leftBase) <= leftBudget
|
|
2321
|
+
? leftBase
|
|
2322
|
+
: truncateWidth(leftBase, leftBudget)
|
|
2323
|
+
screen.text(leftX, statusRow, leftClipped, statusStyle)
|
|
2324
|
+
if (meterGeom) this._paintContextMeter(screen, statusRow, meterGeom)
|
|
2325
|
+
}
|
|
1705
2326
|
|
|
1706
2327
|
// Toast: bottom-center, on the same status row as the model/meter
|
|
1707
2328
|
// readings; it auto-dismisses after 2 seconds.
|
|
@@ -1713,15 +2334,20 @@ export class App {
|
|
|
1713
2334
|
screen.text(toastX, statusRow, toastText, st)
|
|
1714
2335
|
}
|
|
1715
2336
|
|
|
2337
|
+
// Right status rail: painted after the main area (its border and panel
|
|
2338
|
+
// overwrite any transcript tail fill) and before the overlays, which must
|
|
2339
|
+
// be able to cover it.
|
|
2340
|
+
if (railW > 0) this._paintRail(screen, { cols, rows, headerH, railW, borderX })
|
|
2341
|
+
|
|
1716
2342
|
// Overlays
|
|
1717
|
-
if (this.overlay === 'help') this._paintHelp(screen, cols, rows)
|
|
1718
|
-
if (this.overlay === 'settings') this._paintSettings(screen, cols, rows)
|
|
1719
|
-
if (this.overlay === 'rewind') this._paintRewind(screen, cols, rows)
|
|
2343
|
+
if (this.overlay === 'help') this._paintHelp(screen, cols, rows, railW)
|
|
2344
|
+
if (this.overlay === 'settings') this._paintSettings(screen, cols, rows, railW)
|
|
2345
|
+
if (this.overlay === 'rewind') this._paintRewind(screen, cols, rows, railW)
|
|
1720
2346
|
// The question modal owns the screen while a request is pending.
|
|
1721
2347
|
this._questionCaret = null
|
|
1722
|
-
if (this.pendingQuestions) this._paintQuestions(screen, cols, rows)
|
|
1723
|
-
else if (this.statsOpen && !this.overlay) this._paintStats(screen, cols, rows)
|
|
1724
|
-
if (this.pendingSecret) this._paintSecret(screen, cols, rows)
|
|
2348
|
+
if (this.pendingQuestions) this._paintQuestions(screen, cols, rows, railW)
|
|
2349
|
+
else if (this.statsOpen && !this.overlay) this._paintStats(screen, cols, rows, railW)
|
|
2350
|
+
if (this.pendingSecret) this._paintSecret(screen, cols, rows, railW)
|
|
1725
2351
|
|
|
1726
2352
|
// Normalize backgrounds: transcript markdown segments, indents, and row
|
|
1727
2353
|
// tail fills carry fg-only styles, which would otherwise fall back to the
|
|
@@ -1767,7 +2393,7 @@ export class App {
|
|
|
1767
2393
|
const label = makeStyle({ fg: t.textMuted, bg })
|
|
1768
2394
|
const value = makeStyle({ fg: t.text, bg })
|
|
1769
2395
|
const action = String(state.toolName ?? '')
|
|
1770
|
-
const hint = '
|
|
2396
|
+
const hint = tr('composer.approvalHint')
|
|
1771
2397
|
const hintStyle = makeStyle({ fg: t.textMuted, dim: true, bg })
|
|
1772
2398
|
const lines = []
|
|
1773
2399
|
|
|
@@ -1796,7 +2422,7 @@ export class App {
|
|
|
1796
2422
|
// 1. The action. The key hints ride along on this row when they fit, so the
|
|
1797
2423
|
// two things a decision needs — what is being approved and how to answer
|
|
1798
2424
|
// — survive even a one-row composer.
|
|
1799
|
-
const actionHead = '
|
|
2425
|
+
const actionHead = tr('composer.approval')
|
|
1800
2426
|
const hintInline = displayWidth(actionHead) + displayWidth(action) + 2 + displayWidth(hint) <= width
|
|
1801
2427
|
const actionRow = [
|
|
1802
2428
|
{ text: actionHead, style: label },
|
|
@@ -1809,15 +2435,16 @@ export class App {
|
|
|
1809
2435
|
lines.push(actionRow)
|
|
1810
2436
|
|
|
1811
2437
|
// 2. The summary: the human explanation of what is being approved.
|
|
1812
|
-
if (state.summary) field('
|
|
2438
|
+
if (state.summary) field(tr('composer.summary'), state.summary, value)
|
|
1813
2439
|
// 3. The origin: which component asked.
|
|
1814
|
-
if (state.origin) field('
|
|
2440
|
+
if (state.origin) field(tr('composer.origin'), state.origin, value)
|
|
1815
2441
|
// 4. The risk, when the request carries one. Distinguishable by tone so it
|
|
1816
2442
|
// reads as a warning rather than another detail.
|
|
1817
2443
|
if (state.risk) {
|
|
1818
2444
|
const risk = String(state.risk)
|
|
1819
2445
|
const riskColor = risk === 'low' ? t.success : risk === 'high' ? t.error : t.warning
|
|
1820
|
-
|
|
2446
|
+
const riskText = ['low', 'medium', 'high'].includes(risk) ? tr('risk.' + risk) : risk
|
|
2447
|
+
field(tr('composer.risk'), riskText, makeStyle({ fg: riskColor, bold: true, bg }))
|
|
1821
2448
|
}
|
|
1822
2449
|
// 5. The details. A detail marked `private` shows its label but not its
|
|
1823
2450
|
// value: line 185's principle for CopyText.sensitivity ("private" means
|
|
@@ -1844,23 +2471,23 @@ export class App {
|
|
|
1844
2471
|
if (budget <= 1) return lines.slice(0, 1).concat(tail)
|
|
1845
2472
|
const keep = Math.max(1, budget - 1)
|
|
1846
2473
|
const clipped = lines.slice(0, keep)
|
|
1847
|
-
clipped.push([{ text: '
|
|
2474
|
+
clipped.push([{ text: tr('common.more', { count: lines.length - keep }), style: label }])
|
|
1848
2475
|
return clipped.concat(tail)
|
|
1849
2476
|
}
|
|
1850
2477
|
|
|
1851
|
-
_paintEffortSlider(screen, cols, rows) {
|
|
2478
|
+
_paintEffortSlider(screen, cols, rows, rightEdge = cols) {
|
|
1852
2479
|
const t = THEME
|
|
1853
2480
|
const slider = this.effortSlider
|
|
1854
2481
|
if (!slider || slider.levels.length === 0) return
|
|
1855
2482
|
const y = rows - 2
|
|
1856
2483
|
const bg = t.background
|
|
1857
|
-
screen.fill(0, y,
|
|
2484
|
+
screen.fill(0, y, rightEdge, ' ', makeStyle({ bg }))
|
|
1858
2485
|
const levels = slider.levels
|
|
1859
2486
|
const index = Math.min(this._effortIndex(), levels.length - 1)
|
|
1860
2487
|
const atMax = this._effortAtMax()
|
|
1861
2488
|
// The level name alone carries the meaning — no "effort" caption.
|
|
1862
2489
|
const left = 2
|
|
1863
|
-
const trackWidth = Math.max(10, Math.min(26,
|
|
2490
|
+
const trackWidth = Math.max(10, Math.min(26, rightEdge - left - 48))
|
|
1864
2491
|
const fill = levels.length <= 1 ? 1 : Math.max(1, Math.round((index / (levels.length - 1)) * trackWidth))
|
|
1865
2492
|
const phase = Math.floor(Date.now() / 60)
|
|
1866
2493
|
const head = atMax ? phase % fill : -1
|
|
@@ -1899,17 +2526,208 @@ export class App {
|
|
|
1899
2526
|
// exactly its two ends rather than a fake none..max scale.
|
|
1900
2527
|
if (levels.length > 1) {
|
|
1901
2528
|
const range = ' · ' + String(levels[0]?.name ?? levels[0]?.id) + ' → ' + String(levels[levels.length - 1]?.name ?? levels[levels.length - 1]?.id)
|
|
1902
|
-
const clipped = truncateWidth(range, Math.max(4,
|
|
2529
|
+
const clipped = truncateWidth(range, Math.max(4, rightEdge - x - 22))
|
|
1903
2530
|
if (displayWidth(clipped) > 4) {
|
|
1904
2531
|
screen.text(x, y, clipped, makeStyle({ fg: t.textMuted, bg }))
|
|
1905
2532
|
x += displayWidth(clipped)
|
|
1906
2533
|
}
|
|
1907
2534
|
}
|
|
1908
|
-
const hint = '
|
|
1909
|
-
const hintX =
|
|
2535
|
+
const hint = tr('composer.effortHint')
|
|
2536
|
+
const hintX = rightEdge - displayWidth(hint) - 1
|
|
1910
2537
|
if (hintX > x + 2) screen.text(hintX, y, hint, makeStyle({ fg: t.textMuted, dim: true, bg }))
|
|
1911
2538
|
}
|
|
1912
2539
|
|
|
2540
|
+
// ---- right status rail -------------------------------------------------
|
|
2541
|
+
// The wide-window column: session title on top, scrollable sections in the
|
|
2542
|
+
// middle (model, thinking, context, session figures, goal, subagents), and
|
|
2543
|
+
// the workspace path plus build versions pinned to the bottom. Sections with
|
|
2544
|
+
// no data drop out whole, and the whole rail scrolls so future sections can
|
|
2545
|
+
// outgrow the window without a redesign.
|
|
2546
|
+
|
|
2547
|
+
// The rail's scrollable content, one line per row, every style carrying the
|
|
2548
|
+
// panel background (the renderer's default-background pass would otherwise
|
|
2549
|
+
// repaint text cells with the page background over the rail's panel).
|
|
2550
|
+
_railLines(width) {
|
|
2551
|
+
const t = THEME
|
|
2552
|
+
const bg = t.backgroundPanel
|
|
2553
|
+
const lines = []
|
|
2554
|
+
const st = (extra = {}) => makeStyle({ bg, ...extra })
|
|
2555
|
+
const muted = st({ fg: t.textMuted })
|
|
2556
|
+
// A section header: one blank line before it (never leading) plus the
|
|
2557
|
+
// all-caps label, the same vocabulary the left sidebar's SESSIONS/RECENT
|
|
2558
|
+
// headers use.
|
|
2559
|
+
const section = (name) => {
|
|
2560
|
+
if (lines.length > 0) lines.push([])
|
|
2561
|
+
lines.push([{ text: name, style: st({ fg: t.textMuted, bold: true }) }])
|
|
2562
|
+
}
|
|
2563
|
+
const row = (text, style) => lines.push([{ text, style: style ?? st({ fg: t.text }) }])
|
|
2564
|
+
|
|
2565
|
+
section(tr('rail.model'))
|
|
2566
|
+
row(truncateWidth(this.model || '…', width), st({ fg: t.text, bold: true }))
|
|
2567
|
+
if (this.provider) row(truncateWidth(this.provider, width), muted)
|
|
2568
|
+
|
|
2569
|
+
section(tr('rail.thinking'))
|
|
2570
|
+
const level = this._effortLevel()
|
|
2571
|
+
if (level) {
|
|
2572
|
+
row(truncateWidth(String(level.name ?? level.id ?? '—'), width), st({ fg: t.secondary, bold: true }))
|
|
2573
|
+
const slider = this.effortSlider
|
|
2574
|
+
if (slider && slider.levels.length > 1) {
|
|
2575
|
+
const range = String(slider.levels[0]?.name ?? '') + ' → ' + String(slider.levels[slider.levels.length - 1]?.name ?? '')
|
|
2576
|
+
row(truncateWidth(range, width), muted)
|
|
2577
|
+
}
|
|
2578
|
+
} else {
|
|
2579
|
+
row(tr('rail.noData'), muted)
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
section(tr('rail.context'))
|
|
2583
|
+
const meter = this.contextMeter
|
|
2584
|
+
if (meter) {
|
|
2585
|
+
const barW = Math.max(3, width - 2)
|
|
2586
|
+
const fill = Math.min(barW, Math.max(0, Math.round(meter.percent / 100 * barW)))
|
|
2587
|
+
const fillColor = meter.percent >= 100 ? t.error : meter.percent >= 90 ? t.warning : t.primary
|
|
2588
|
+
lines.push([{ text: '█'.repeat(fill) + '░'.repeat(barW - fill), style: st({ fg: fillColor }) }])
|
|
2589
|
+
row(tr('rail.percentUsed', { percent: meter.percent }), meter.percent >= 90 ? st({ fg: fillColor }) : muted)
|
|
2590
|
+
row(tr('rail.tokens', { used: formatTokens(meter.usedTokens), window: formatTokens(meter.contextWindow) }), muted)
|
|
2591
|
+
const m = this.metrics ?? {}
|
|
2592
|
+
if ((m.billedInputTokens ?? 0) > 0 || (m.outputTokens ?? 0) > 0) {
|
|
2593
|
+
row(tr('stats.inOut', { input: formatTokens(m.billedInputTokens ?? 0), output: formatTokens(m.outputTokens ?? 0) }), muted)
|
|
2594
|
+
if (m.cacheHitRate !== undefined) row(tr('rail.cacheHit', { percent: m.cacheHitRate }), muted)
|
|
2595
|
+
}
|
|
2596
|
+
if (meter.breakdown) {
|
|
2597
|
+
for (const piece of wrapText(tr('rail.breakdown', {
|
|
2598
|
+
system: formatTokens(meter.breakdown.systemTokens),
|
|
2599
|
+
tools: formatTokens(meter.breakdown.toolsTokens),
|
|
2600
|
+
messages: formatTokens(meter.breakdown.messageTokens),
|
|
2601
|
+
}), width)) {
|
|
2602
|
+
row(piece, muted)
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
} else {
|
|
2606
|
+
row(tr('rail.contextPending'), st({ fg: t.textMuted, italic: true }))
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
// The figures the narrow window's stats strip carries; the strip drops out
|
|
2610
|
+
// while the rail is up, so this is their only home in the wide layout.
|
|
2611
|
+
if (this._statsStripVisible()) {
|
|
2612
|
+
section(tr('rail.session'))
|
|
2613
|
+
for (const group of this._statsGroups()) {
|
|
2614
|
+
for (const piece of wrapText(group, width)) row(piece, muted)
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
if (this.goal) {
|
|
2619
|
+
section(tr('rail.goal'))
|
|
2620
|
+
for (const piece of wrapText(this.goal.objective, width)) row(piece)
|
|
2621
|
+
const phaseColor = { active: t.success, paused: t.warning, blocked: t.error, complete: t.primary }[this.goal.phase] ?? t.textMuted
|
|
2622
|
+
// The phase is a protocol id: the four known ones are named by the
|
|
2623
|
+
// catalog, an unknown future phase still renders as itself.
|
|
2624
|
+
const phaseKey = 'goal.' + this.goal.phase
|
|
2625
|
+
let phaseLine = GOAL_PHASE_KEYS.has(phaseKey) ? tr(phaseKey) : this.goal.phase
|
|
2626
|
+
if (this.goal.maxGoalRounds > 0) phaseLine += tr('rail.round', { started: this.goal.roundsStarted, max: this.goal.maxGoalRounds })
|
|
2627
|
+
row(phaseLine, st({ fg: phaseColor }))
|
|
2628
|
+
if (this.goal.blockedReason?.message) {
|
|
2629
|
+
for (const piece of wrapText(this.goal.blockedReason.message, width)) {
|
|
2630
|
+
row(piece, st({ fg: t.error }))
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
|
|
2635
|
+
if (this.subagents.length > 0) {
|
|
2636
|
+
section(tr('rail.subagents'))
|
|
2637
|
+
const running = this.subagents.filter((sub) => sub.activity === 'running').length
|
|
2638
|
+
row(tr('rail.subagentCounts', { running, total: this.subagents.length }), muted)
|
|
2639
|
+
// The list caps at 10 rows so one runaway delegation cannot push
|
|
2640
|
+
// everything else off the rail; the count above still names every one.
|
|
2641
|
+
for (const sub of this.subagents.slice(0, 10)) {
|
|
2642
|
+
const mark = sub.activity === 'running' ? '●' : '○'
|
|
2643
|
+
const color = sub.activity === 'running' ? t.success : t.textMuted
|
|
2644
|
+
const depthTag = sub.depth > 1 ? ' L' + sub.depth : ''
|
|
2645
|
+
lines.push([
|
|
2646
|
+
{ text: mark + ' ', style: st({ fg: color }) },
|
|
2647
|
+
{ text: truncateWidth((sub.readable ? sub.label : tr('rail.unreadable', { label: sub.label })) + depthTag, Math.max(4, width - 2)), style: st({ fg: sub.activity === 'running' ? t.text : t.textMuted }) },
|
|
2648
|
+
])
|
|
2649
|
+
}
|
|
2650
|
+
if (this.subagents.length > 10) row(tr('rail.more', { count: this.subagents.length - 10 }), muted)
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
return lines
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
_paintRail(screen, { cols, rows, headerH, railW, borderX }) {
|
|
2657
|
+
const t = THEME
|
|
2658
|
+
const bg = t.backgroundPanel
|
|
2659
|
+
const sideStyle = makeStyle({ fg: t.textMuted, bg })
|
|
2660
|
+
const x0 = borderX + 1
|
|
2661
|
+
const railTop = headerH
|
|
2662
|
+
const railBottom = rows - 1 // the status row stays full-width below the rail
|
|
2663
|
+
if (railBottom - railTop < 4) return
|
|
2664
|
+
for (let y = railTop; y < railBottom; y++) screen.fill(x0, y, railW, ' ', sideStyle)
|
|
2665
|
+
for (let y = railTop; y < railBottom; y++) screen.set(borderX, y, '│', makeStyle({ fg: t.borderSubtle }))
|
|
2666
|
+
|
|
2667
|
+
const innerW = railW - 2
|
|
2668
|
+
// Session title, pinned above the scroll window (up to three rows).
|
|
2669
|
+
let contentTop = railTop
|
|
2670
|
+
const titleText = this.titleScreen ? '' : String(this.untitled ? tr('session.newTitle') : this.title ?? '')
|
|
2671
|
+
if (titleText !== '') {
|
|
2672
|
+
for (const line of wrapText(titleText, innerW).slice(0, 3)) {
|
|
2673
|
+
screen.text(x0 + 1, contentTop, truncateWidth(line, innerW), makeStyle({ fg: t.text, bold: true, bg }))
|
|
2674
|
+
contentTop++
|
|
2675
|
+
}
|
|
2676
|
+
contentTop++ // blank separator under the title
|
|
2677
|
+
}
|
|
2678
|
+
// One fixed footer row: the running builds. The workspace lives in the
|
|
2679
|
+
// header's right end now — repeating it here read as the same clutter the
|
|
2680
|
+
// duplicated model name did.
|
|
2681
|
+
const footerH = 1
|
|
2682
|
+
const contentBottom = railBottom - footerH
|
|
2683
|
+
const contentH = contentBottom - contentTop
|
|
2684
|
+
if (contentH <= 0) return
|
|
2685
|
+
|
|
2686
|
+
const lines = this._railLines(innerW)
|
|
2687
|
+
const maxRail = Math.max(0, lines.length - contentH)
|
|
2688
|
+
if (this.railScroll > maxRail) this.railScroll = maxRail
|
|
2689
|
+
const scroll = this.railScroll
|
|
2690
|
+
for (let i = 0; i < contentH && scroll + i < lines.length; i++) {
|
|
2691
|
+
const line = lines[scroll + i]
|
|
2692
|
+
const y = contentTop + i
|
|
2693
|
+
let lx = x0 + 1
|
|
2694
|
+
for (const seg of clipSegs(line, innerW)) lx = screen.text(lx, y, seg.text, seg.style)
|
|
2695
|
+
}
|
|
2696
|
+
// Scrollbar in the rail's rightmost column whenever the sections overflow.
|
|
2697
|
+
if (lines.length > contentH) {
|
|
2698
|
+
const thumbH = Math.max(1, Math.round(contentH * contentH / lines.length))
|
|
2699
|
+
const thumbY = contentTop + Math.round(scroll * (contentH - thumbH) / Math.max(1, lines.length - contentH))
|
|
2700
|
+
for (let i = 0; i < contentH; i++) {
|
|
2701
|
+
screen.set(x0 + railW - 1, contentTop + i, '│', makeStyle({ fg: t.borderSubtle, bg }))
|
|
2702
|
+
}
|
|
2703
|
+
for (let i = 0; i < thumbH && thumbY + i < contentBottom; i++) {
|
|
2704
|
+
screen.set(x0 + railW - 1, thumbY + i, '┃', makeStyle({ fg: t.border, bold: true, bg }))
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
const builds = [
|
|
2709
|
+
this.versions.dsh ? 'dsh ' + this.versions.dsh : '',
|
|
2710
|
+
this.versions.tui ? 'tui ' + this.versions.tui : '',
|
|
2711
|
+
].filter((part) => part !== '').join(' · ')
|
|
2712
|
+
if (builds) screen.text(x0 + 1, railBottom - 1, truncateWidth(builds, innerW), makeStyle({ fg: t.textMuted, dim: true, bg }))
|
|
2713
|
+
|
|
2714
|
+
// The whole rail is a wheel-scroll target; the context section doubles as
|
|
2715
|
+
// the stats window's opener (the seat the bottom-row meter vacates).
|
|
2716
|
+
this.addHitRegion('rail', x0, railTop, railW, railBottom - railTop)
|
|
2717
|
+
const contextHeader = tr('rail.context')
|
|
2718
|
+
for (let i = 0; i < lines.length; i++) {
|
|
2719
|
+
if (lines[i].length === 1 && lines[i][0].text === contextHeader) {
|
|
2720
|
+
const y = contentTop + (i - scroll)
|
|
2721
|
+
const end = lines.findIndex((line, j) => j > i && line.length === 1 && line[0].style?.bold && line[0].text !== contextHeader)
|
|
2722
|
+
const stop = (end < 0 ? lines.length : end) - scroll
|
|
2723
|
+
if (y >= contentTop && y < contentBottom) {
|
|
2724
|
+
this.addHitRegion('stats', x0, y, railW, Math.max(1, Math.min(stop, contentBottom) - y))
|
|
2725
|
+
}
|
|
2726
|
+
break
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
|
|
1913
2731
|
// The current effort value, pinned to the top-right corner of the composer
|
|
1914
2732
|
// box — diagonally opposite the `provider · model` label at bottom-left.
|
|
1915
2733
|
// `↑ max` gets a blinking text arrow and per-letter flowing gradient; any
|
|
@@ -1995,65 +2813,75 @@ export class App {
|
|
|
1995
2813
|
// prompt, tools, messages). The bar's overall length stays the provider-exact
|
|
1996
2814
|
// percent; a zero-width part is dropped. Opened by clicking the stats strip
|
|
1997
2815
|
// or the context meter, or with `/stats`.
|
|
1998
|
-
_paintStats(screen, cols, rows) {
|
|
2816
|
+
_paintStats(screen, cols, rows, railW = 0) {
|
|
1999
2817
|
const t = THEME
|
|
2000
2818
|
const m = this.metrics ?? {}
|
|
2001
2819
|
const meter = this.contextMeter
|
|
2002
2820
|
const body = []
|
|
2003
2821
|
if ((m.steps ?? 0) > 0) {
|
|
2004
|
-
body.push({ label: 'usage', value: count(m.turns ?? 0, '
|
|
2822
|
+
body.push({ label: tr('stats.usage'), value: count(m.turns ?? 0, 'transcript.turns') + ' · ' + count(m.steps, 'transcript.steps') })
|
|
2005
2823
|
const durations = []
|
|
2006
|
-
if ((m.llmMs ?? 0) > 0) durations.push('
|
|
2007
|
-
if ((m.toolMs ?? 0) > 0) durations.push('
|
|
2008
|
-
if (durations.length > 0) body.push({ label: 'duration', value: durations.join(' · ') })
|
|
2824
|
+
if ((m.llmMs ?? 0) > 0) durations.push(tr('stats.llmTime', { value: formatDuration(m.llmMs) }))
|
|
2825
|
+
if ((m.toolMs ?? 0) > 0) durations.push(tr('stats.toolTime', { value: formatDuration(m.toolMs) }))
|
|
2826
|
+
if (durations.length > 0) body.push({ label: tr('stats.duration'), value: durations.join(' · ') })
|
|
2009
2827
|
const speeds = []
|
|
2010
|
-
if ((m.ttftSteps ?? 0) > 0) speeds.push('
|
|
2011
|
-
if ((m.decodeMs ?? 0) > 0) speeds.push(formatMetric(m.decodeTokens / (m.decodeMs / 1000))
|
|
2012
|
-
if (speeds.length > 0) body.push({ label: 'speed', value: speeds.join(' · ') })
|
|
2828
|
+
if ((m.ttftSteps ?? 0) > 0) speeds.push(tr('stats.ttft', { value: formatDuration(m.ttftMs / m.ttftSteps) }))
|
|
2829
|
+
if ((m.decodeMs ?? 0) > 0) speeds.push(tr('stats.tokensPerSecond', { value: formatMetric(m.decodeTokens / (m.decodeMs / 1000)) }))
|
|
2830
|
+
if (speeds.length > 0) body.push({ label: tr('stats.speed'), value: speeds.join(' · ') })
|
|
2013
2831
|
} else {
|
|
2014
|
-
body.push({ label: 'usage', value: '
|
|
2832
|
+
body.push({ label: tr('stats.usage'), value: tr('stats.noSteps') })
|
|
2015
2833
|
}
|
|
2016
2834
|
body.push({
|
|
2017
|
-
label: 'tokens',
|
|
2018
|
-
value: '
|
|
2835
|
+
label: tr('stats.tokens'),
|
|
2836
|
+
value: tr('stats.inOut', { input: formatTokens(m.billedInputTokens ?? 0), output: formatTokens(m.outputTokens ?? 0) }),
|
|
2019
2837
|
})
|
|
2020
2838
|
if (m.cacheHitRate !== undefined) {
|
|
2021
2839
|
body.push({
|
|
2022
|
-
label: 'cache',
|
|
2023
|
-
value:
|
|
2024
|
-
|
|
2025
|
-
|
|
2840
|
+
label: tr('stats.cache'),
|
|
2841
|
+
value: tr('stats.cacheDetail', {
|
|
2842
|
+
percent: m.cacheHitRate,
|
|
2843
|
+
read: formatTokens(m.cacheReadTokens ?? 0),
|
|
2844
|
+
write: formatTokens(m.cacheWriteTokens ?? 0),
|
|
2845
|
+
miss: formatTokens(m.uncachedInputTokens ?? 0),
|
|
2846
|
+
}),
|
|
2026
2847
|
})
|
|
2027
2848
|
}
|
|
2028
2849
|
if (meter) {
|
|
2029
2850
|
body.push({ blank: true })
|
|
2030
2851
|
body.push({
|
|
2031
|
-
label: 'context',
|
|
2032
|
-
value: '
|
|
2852
|
+
label: tr('stats.context'),
|
|
2853
|
+
value: tr('stats.contextUsed', {
|
|
2854
|
+
percent: meter.percent,
|
|
2855
|
+
used: formatTokens(meter.usedTokens),
|
|
2856
|
+
window: formatTokens(meter.contextWindow),
|
|
2857
|
+
}),
|
|
2033
2858
|
})
|
|
2034
2859
|
const parts = meter.breakdown
|
|
2035
2860
|
? [
|
|
2036
|
-
{ tokens: meter.breakdown.systemTokens, color: t.contextSystem, label: '
|
|
2037
|
-
{ tokens: meter.breakdown.toolsTokens, color: t.contextTools, label: 'tools' },
|
|
2038
|
-
{ tokens: meter.breakdown.messageTokens, color: t.contextMessages, label: 'messages' },
|
|
2861
|
+
{ tokens: meter.breakdown.systemTokens, color: t.contextSystem, label: tr('stats.systemPrompt') },
|
|
2862
|
+
{ tokens: meter.breakdown.toolsTokens, color: t.contextTools, label: tr('stats.tools') },
|
|
2863
|
+
{ tokens: meter.breakdown.messageTokens, color: t.contextMessages, label: tr('stats.messages') },
|
|
2039
2864
|
].filter((p) => p.tokens > 0)
|
|
2040
2865
|
: null
|
|
2041
2866
|
body.push({ bar: true, parts })
|
|
2042
2867
|
if (parts && parts.length > 0) {
|
|
2043
2868
|
for (const part of parts) body.push({ legend: part })
|
|
2044
2869
|
} else {
|
|
2045
|
-
body.push({ note: '
|
|
2870
|
+
body.push({ note: tr('stats.compositionUnavailable') })
|
|
2046
2871
|
}
|
|
2047
2872
|
} else {
|
|
2048
2873
|
body.push({ blank: true })
|
|
2049
|
-
body.push({ note: '
|
|
2874
|
+
body.push({ note: tr('stats.contextPending') })
|
|
2050
2875
|
}
|
|
2051
2876
|
body.push({ blank: true })
|
|
2052
2877
|
|
|
2053
|
-
|
|
2054
|
-
//
|
|
2878
|
+
// One centered modal at every width. The maximized window used to swap
|
|
2879
|
+
// this for a right-hand panel, and the two shapes read as different
|
|
2880
|
+
// features; the modal is what the strip click always meant.
|
|
2881
|
+
const region = overlayRegion(cols, railW)
|
|
2882
|
+
const w = Math.min(64, region - 4)
|
|
2055
2883
|
const h = Math.min(body.length + 5, Math.max(7, rows - 2))
|
|
2056
|
-
const x0 = Math.max(0, Math.floor((
|
|
2884
|
+
const x0 = Math.max(0, Math.floor((region - w) / 2))
|
|
2057
2885
|
const y0 = Math.max(1, Math.floor((rows - h) / 2) - 1)
|
|
2058
2886
|
const box = makeStyle({ fg: t.text, bg: t.backgroundElement })
|
|
2059
2887
|
const border = makeStyle({ fg: t.border, bg: t.backgroundElement })
|
|
@@ -2066,17 +2894,18 @@ export class App {
|
|
|
2066
2894
|
screen.set(x0, y0 + y, '│', border)
|
|
2067
2895
|
screen.set(x0 + w - 1, y0 + y, '│', border)
|
|
2068
2896
|
}
|
|
2069
|
-
screen.set(x0, y0, '
|
|
2070
|
-
screen.set(x0, y0 + h - 1, '
|
|
2897
|
+
screen.set(x0, y0, '╭', border); screen.set(x0 + w - 1, y0, '╮', border)
|
|
2898
|
+
screen.set(x0, y0 + h - 1, '╰', border); screen.set(x0 + w - 1, y0 + h - 1, '╯', border)
|
|
2071
2899
|
|
|
2072
2900
|
const labelW = 9
|
|
2073
2901
|
const barX = x0 + 3
|
|
2074
2902
|
const barW = w - 8
|
|
2075
2903
|
let yy = y0 + 1
|
|
2076
|
-
screen.text(x0 + 3, yy, '
|
|
2077
|
-
|
|
2904
|
+
screen.text(x0 + 3, yy, tr('stats.title'), makeStyle({ fg: t.primary, bold: true, bg: t.backgroundElement }))
|
|
2905
|
+
const escLabel = tr('common.escClose')
|
|
2906
|
+
screen.text(x0 + w - displayWidth(escLabel) - 3, yy, escLabel, makeStyle({ fg: t.textMuted, bg: t.backgroundElement }))
|
|
2078
2907
|
yy++
|
|
2079
|
-
screen.text(x0 + 3, yy, '
|
|
2908
|
+
screen.text(x0 + 3, yy, tr('stats.hint'), makeStyle({ fg: t.textMuted, dim: true, bg: t.backgroundElement }))
|
|
2080
2909
|
yy += 2
|
|
2081
2910
|
for (const row of body) {
|
|
2082
2911
|
if (yy >= y0 + h - 1) break
|
|
@@ -2101,8 +2930,6 @@ export class App {
|
|
|
2101
2930
|
continue
|
|
2102
2931
|
}
|
|
2103
2932
|
if (row.legend) {
|
|
2104
|
-
// The legend label is longer than the stats label column, so its figure
|
|
2105
|
-
// is right-aligned against the box instead of sharing that column.
|
|
2106
2933
|
const figure = '~' + formatTokens(row.legend.tokens)
|
|
2107
2934
|
screen.text(x0 + 3, yy, '■', makeStyle({ fg: row.legend.color, bg: t.backgroundElement }))
|
|
2108
2935
|
screen.text(x0 + 6, yy, row.legend.label, makeStyle({ fg: t.text, bg: t.backgroundElement }))
|
|
@@ -2127,7 +2954,7 @@ export class App {
|
|
|
2127
2954
|
// the way the WebUI composer stages them. A question declaring the
|
|
2128
2955
|
// `plan-review` intent renders its `detail` — the plan under review — above
|
|
2129
2956
|
// the choices; the answer encoding is identical either way.
|
|
2130
|
-
_paintQuestions(screen, cols, rows) {
|
|
2957
|
+
_paintQuestions(screen, cols, rows, railW = 0) {
|
|
2131
2958
|
const t = THEME
|
|
2132
2959
|
const q = this.pendingQuestions
|
|
2133
2960
|
if (!q) return
|
|
@@ -2135,10 +2962,11 @@ export class App {
|
|
|
2135
2962
|
if (!question) return
|
|
2136
2963
|
this._questionCaret = null
|
|
2137
2964
|
|
|
2138
|
-
const
|
|
2965
|
+
const region = overlayRegion(cols, railW)
|
|
2966
|
+
const w = Math.max(34, Math.min(78, region - 8)) + 6
|
|
2139
2967
|
const maxH = Math.max(9, rows - 2)
|
|
2140
2968
|
const contentW = w - 6
|
|
2141
|
-
const x0 = Math.max(0, Math.floor((
|
|
2969
|
+
const x0 = Math.max(0, Math.floor((region - w) / 2))
|
|
2142
2970
|
const options = Array.isArray(question.options) ? question.options : []
|
|
2143
2971
|
const multi = question.multiSelect === true
|
|
2144
2972
|
const draft = q.drafts[q.index] ?? { selected: [], custom: '' }
|
|
@@ -2165,14 +2993,16 @@ export class App {
|
|
|
2165
2993
|
screen.set(x0, y0 + y, '│', border)
|
|
2166
2994
|
screen.set(x0 + w - 1, y0 + y, '│', border)
|
|
2167
2995
|
}
|
|
2168
|
-
screen.set(x0, y0, '
|
|
2169
|
-
screen.set(x0, y0 + h - 1, '
|
|
2996
|
+
screen.set(x0, y0, '╭', border); screen.set(x0 + w - 1, y0, '╮', border)
|
|
2997
|
+
screen.set(x0, y0 + h - 1, '╰', border); screen.set(x0 + w - 1, y0 + h - 1, '╯', border)
|
|
2170
2998
|
|
|
2171
2999
|
const cx = x0 + 3
|
|
2172
3000
|
const title = question.header
|
|
2173
3001
|
? String(question.header)
|
|
2174
|
-
: (q.questions.length > 1
|
|
2175
|
-
|
|
3002
|
+
: (q.questions.length > 1
|
|
3003
|
+
? tr('questions.titleOf', { index: q.index + 1, total: q.questions.length })
|
|
3004
|
+
: tr('questions.title'))
|
|
3005
|
+
const esc = tr('questions.defer')
|
|
2176
3006
|
screen.text(cx, y0 + 1, truncateWidth(title, contentW - displayWidth(esc) - 2), makeStyle({ fg: t.primary, bold: true, bg: t.backgroundElement }))
|
|
2177
3007
|
screen.text(x0 + w - 3 - displayWidth(esc), y0 + 1, esc, makeStyle({ fg: t.textMuted, bg: t.backgroundElement }))
|
|
2178
3008
|
|
|
@@ -2192,7 +3022,7 @@ export class App {
|
|
|
2192
3022
|
q.scroll = scroll
|
|
2193
3023
|
for (let x = 0; x < contentW; x++) screen.set(cx + x, y, '─', makeStyle({ fg: t.borderSubtle, bg: t.backgroundElement }))
|
|
2194
3024
|
if (detailLines.length > detailH) {
|
|
2195
|
-
const counter = (scroll + 1
|
|
3025
|
+
const counter = tr('questions.range', { from: scroll + 1, to: scroll + detailH, total: detailLines.length })
|
|
2196
3026
|
screen.text(x0 + w - 3 - displayWidth(counter), y, counter, makeStyle({ fg: t.textMuted, bg: t.backgroundElement }))
|
|
2197
3027
|
}
|
|
2198
3028
|
y++
|
|
@@ -2239,7 +3069,7 @@ export class App {
|
|
|
2239
3069
|
if (customActive) screen.fill(x0 + 1, y, w - 2, ' ', customStyle)
|
|
2240
3070
|
const filled = customText.trim() !== ''
|
|
2241
3071
|
const marker = multi ? (filled ? '[x] ' : '[ ] ') : (filled ? '(o) ' : '( ) ')
|
|
2242
|
-
const prefix = marker + (options.length > 0 ? '
|
|
3072
|
+
const prefix = marker + (options.length > 0 ? tr('questions.other') : tr('questions.answer'))
|
|
2243
3073
|
screen.text(cx, y, prefix, customStyle)
|
|
2244
3074
|
const textX = cx + displayWidth(prefix)
|
|
2245
3075
|
const room = Math.max(1, x0 + w - 3 - textX)
|
|
@@ -2252,17 +3082,17 @@ export class App {
|
|
|
2252
3082
|
} else if (filled) {
|
|
2253
3083
|
screen.text(textX, y, truncateWidth(customText, room), customStyle)
|
|
2254
3084
|
} else {
|
|
2255
|
-
screen.text(textX, y, truncateWidth('
|
|
3085
|
+
screen.text(textX, y, truncateWidth(tr('questions.placeholder'), room), makeStyle({ fg: t.textMuted, italic: true, bg: customStyle.bg }))
|
|
2256
3086
|
}
|
|
2257
3087
|
this.addHitRegion('question-custom', x0 + 1, y, w - 2, 1)
|
|
2258
3088
|
y++
|
|
2259
3089
|
|
|
2260
3090
|
y++
|
|
2261
3091
|
const hints = q.customMode
|
|
2262
|
-
? '
|
|
3092
|
+
? tr('questions.hintCustom')
|
|
2263
3093
|
: multi
|
|
2264
|
-
? '
|
|
2265
|
-
: '
|
|
3094
|
+
? tr('questions.hintMulti')
|
|
3095
|
+
: tr('questions.hintSingle')
|
|
2266
3096
|
screen.text(cx, y, truncateWidth(hints, contentW), makeStyle({ fg: t.textMuted, bg: t.backgroundElement }))
|
|
2267
3097
|
if (q.error) {
|
|
2268
3098
|
const errText = truncateWidth(String(q.error), Math.floor(contentW / 2))
|
|
@@ -2273,15 +3103,16 @@ export class App {
|
|
|
2273
3103
|
// A standalone masked prompt for secret-input requests. The Settings pages
|
|
2274
3104
|
// have their own inline masked field; this is the same masking applied to a
|
|
2275
3105
|
// one-field modal that a standard protocol request can drive.
|
|
2276
|
-
_paintSecret(screen, cols, rows) {
|
|
3106
|
+
_paintSecret(screen, cols, rows, railW = 0) {
|
|
2277
3107
|
const t = THEME
|
|
2278
3108
|
const state = this.pendingSecret
|
|
2279
3109
|
// Clamped to the available columns as well as the 64-column cap: a 30-column
|
|
2280
3110
|
// floor with a centred x would push the right edge past the frame on a very
|
|
2281
3111
|
// narrow terminal.
|
|
2282
|
-
const
|
|
3112
|
+
const region = overlayRegion(cols, railW)
|
|
3113
|
+
const width = Math.max(20, Math.min(region - 8, 64))
|
|
2283
3114
|
const height = state.description ? 7 : 6
|
|
2284
|
-
const x = Math.max(1, Math.floor((
|
|
3115
|
+
const x = Math.max(1, Math.floor((region - width) / 2))
|
|
2285
3116
|
const y = Math.max(1, Math.floor((rows - height) / 2))
|
|
2286
3117
|
const panel = makeStyle({ fg: t.text, bg: t.backgroundElement })
|
|
2287
3118
|
const border = makeStyle({ fg: t.border, bg: t.backgroundElement })
|
|
@@ -2296,8 +3127,8 @@ export class App {
|
|
|
2296
3127
|
screen.set(x, y + row, '│', border)
|
|
2297
3128
|
screen.set(x + width - 1, y + row, '│', border)
|
|
2298
3129
|
}
|
|
2299
|
-
screen.set(x, y, '
|
|
2300
|
-
screen.set(x, y + height - 1, '
|
|
3130
|
+
screen.set(x, y, '╭', border); screen.set(x + width - 1, y, '╮', border)
|
|
3131
|
+
screen.set(x, y + height - 1, '╰', border); screen.set(x + width - 1, y + height - 1, '╯', border)
|
|
2301
3132
|
|
|
2302
3133
|
let row = y + 1
|
|
2303
3134
|
screen.text(x + 2, row, truncateWidth(state.label, width - 4),
|
|
@@ -2312,7 +3143,7 @@ export class App {
|
|
|
2312
3143
|
screen.text(x + 2, row, truncateWidth(masked, width - 4), panel)
|
|
2313
3144
|
row += 1
|
|
2314
3145
|
screen.text(x + 2, row,
|
|
2315
|
-
truncateWidth(state.error ?? '
|
|
3146
|
+
truncateWidth(state.error ?? tr('secret.hint'), width - 4),
|
|
2316
3147
|
makeStyle({ fg: state.error ? t.error : t.textMuted, bg: t.backgroundElement }))
|
|
2317
3148
|
}
|
|
2318
3149
|
|
|
@@ -2320,12 +3151,15 @@ export class App {
|
|
|
2320
3151
|
// menu column on the left — Tab switches the active entry, clicking works
|
|
2321
3152
|
// too; views without a menu (choice lists, session manager, model picker)
|
|
2322
3153
|
// keep the classic single-column layout.
|
|
2323
|
-
_paintSettings(screen, cols, rows) {
|
|
3154
|
+
_paintSettings(screen, cols, rows, railW = 0) {
|
|
2324
3155
|
const t = THEME
|
|
2325
3156
|
const menu = Array.isArray(this.settingsMenu) ? this.settingsMenu : []
|
|
2326
3157
|
const hasMenu = menu.length > 0
|
|
2327
|
-
|
|
2328
|
-
|
|
3158
|
+
// The menu column is sized from its labels: "Aggiornamento" or "Обновление"
|
|
3159
|
+
// must not be cut to the English "Update" width. Capped so a runaway label
|
|
3160
|
+
// cannot eat the content pane.
|
|
3161
|
+
const menuW = hasMenu ? Math.min(20, Math.max(12, ...menu.map((entry) => displayWidth(entry.label))) + 5) : 0
|
|
3162
|
+
const w = Math.min(hasMenu ? 84 : 68, overlayRegion(cols, railW) - 4)
|
|
2329
3163
|
// Display rows: group headers (kind 'header') break the list into
|
|
2330
3164
|
// sections with a blank separator line; every selectable item is one
|
|
2331
3165
|
// compact row. Headers are never selectable and carry no hit region.
|
|
@@ -2341,7 +3175,7 @@ export class App {
|
|
|
2341
3175
|
}
|
|
2342
3176
|
const h = Math.max(9, Math.min(rows - 4, display.length + 6))
|
|
2343
3177
|
const contentH = h - 6
|
|
2344
|
-
const x0 = Math.max(0, Math.floor((cols - w) / 2))
|
|
3178
|
+
const x0 = Math.max(0, Math.floor((overlayRegion(cols, railW) - w) / 2))
|
|
2345
3179
|
const y0 = Math.max(0, Math.floor((rows - h) / 2))
|
|
2346
3180
|
const box = makeStyle({ fg: t.text, bg: t.backgroundElement })
|
|
2347
3181
|
const border = makeStyle({ fg: t.border, bg: t.backgroundElement })
|
|
@@ -2354,8 +3188,8 @@ export class App {
|
|
|
2354
3188
|
screen.set(x0, y0 + y, '│', border)
|
|
2355
3189
|
screen.set(x0 + w - 1, y0 + y, '│', border)
|
|
2356
3190
|
}
|
|
2357
|
-
screen.set(x0, y0, '
|
|
2358
|
-
screen.set(x0, y0 + h - 1, '
|
|
3191
|
+
screen.set(x0, y0, '╭', border); screen.set(x0 + w - 1, y0, '╮', border)
|
|
3192
|
+
screen.set(x0, y0 + h - 1, '╰', border); screen.set(x0 + w - 1, y0 + h - 1, '╯', border)
|
|
2359
3193
|
// Content area: everything right of the menu column.
|
|
2360
3194
|
const cx = x0 + menuW
|
|
2361
3195
|
const cw = w - menuW
|
|
@@ -2365,7 +3199,7 @@ export class App {
|
|
|
2365
3199
|
screen.set(x0 + menuW, y0, '┬', border)
|
|
2366
3200
|
for (let yy = y0 + 1; yy < y0 + h - 1; yy++) screen.set(x0 + menuW, yy, '│', border)
|
|
2367
3201
|
screen.set(x0 + menuW, y0 + h - 1, '┴', border)
|
|
2368
|
-
screen.text(x0 + 2, y0 + 1, '
|
|
3202
|
+
screen.text(x0 + 2, y0 + 1, tr('settings.menu'), makeStyle({ fg: t.textMuted, bold: true, bg: t.backgroundElement }))
|
|
2369
3203
|
for (let i = 0; i < menu.length; i++) {
|
|
2370
3204
|
const my = y0 + 3 + i
|
|
2371
3205
|
if (my >= y0 + h - 1) break
|
|
@@ -2376,13 +3210,13 @@ export class App {
|
|
|
2376
3210
|
bg: active ? t.backgroundPanel : t.backgroundElement,
|
|
2377
3211
|
})
|
|
2378
3212
|
if (active) screen.fill(x0 + 1, my, menuW - 1, ' ', menuStyle)
|
|
2379
|
-
screen.text(x0 + 2, my, (active ? '▸ ' : ' ') + truncateWidth(menu[i].label, menuW -
|
|
3213
|
+
screen.text(x0 + 2, my, (active ? '▸ ' : ' ') + truncateWidth(menu[i].label, menuW - 3), menuStyle)
|
|
2380
3214
|
this.addHitRegion('settings-menu', x0 + 1, my, menuW - 1, 1, { menuIndex: i })
|
|
2381
3215
|
}
|
|
2382
3216
|
}
|
|
2383
3217
|
screen.text(cx + 3, y0 + 1, truncateWidth(this.settingsTitle, cw - 6), makeStyle({ fg: t.primary, bold: true, bg: t.backgroundElement }))
|
|
2384
3218
|
|
|
2385
|
-
const subtitleText = (this.settingsBusy ? this.animChar() + ' ' : '') + (this.settingsSubtitle || '
|
|
3219
|
+
const subtitleText = (this.settingsBusy ? this.animChar() + ' ' : '') + (this.settingsSubtitle || tr('settings.shared'))
|
|
2386
3220
|
screen.text(cx + 3, y0 + 2, truncateWidth(subtitleText, cw - 6), makeStyle({ fg: t.textMuted, bg: t.backgroundElement }))
|
|
2387
3221
|
// Scroll window with explicit scroll offset (wheel scrolling support).
|
|
2388
3222
|
// The scroll offset is clamped to ensure the window always shows content.
|
|
@@ -2418,10 +3252,14 @@ export class App {
|
|
|
2418
3252
|
const confirming = this.settingsConfirm?.item === item
|
|
2419
3253
|
const confirmHint = confirming
|
|
2420
3254
|
? this.settingsConfirm.item.kind === 'session'
|
|
2421
|
-
? '
|
|
2422
|
-
: (this.settingsConfirm.text ?? '
|
|
3255
|
+
? tr('settings.confirmDeleteSession')
|
|
3256
|
+
: tr('settings.confirmHint', { text: this.settingsConfirm.text ?? tr('settings.confirmDefault') })
|
|
2423
3257
|
: ''
|
|
2424
|
-
|
|
3258
|
+
// A row whose stored id differs from what the user should read (a
|
|
3259
|
+
// locale id, a `queue`/`steer` choice) carries `valueLabel`; the id is
|
|
3260
|
+
// still what gets committed.
|
|
3261
|
+
const stored = item.valueLabel ?? item.value
|
|
3262
|
+
const value = confirming ? confirmHint : this.settingsEditing === i ? draft + '█' : stored
|
|
2425
3263
|
const valueTone = item.tone === 'warning' ? t.warning : item.tone === 'success' ? t.success : undefined
|
|
2426
3264
|
const valueStyle = makeStyle({ fg: confirming ? t.warning : valueTone ? valueTone : selected && !item.disabled ? t.secondary : t.textMuted, bg: style.bg })
|
|
2427
3265
|
// Nested rows (e.g. a provider's models) indent one step per level.
|
|
@@ -2451,9 +3289,22 @@ export class App {
|
|
|
2451
3289
|
})
|
|
2452
3290
|
let vx = cx + 6 + indent
|
|
2453
3291
|
vx = screen.text(vx, y, item.version, item.installed ? installedStyle : baseStyle)
|
|
2454
|
-
if (item.installed) vx = screen.text(vx, y, ' (installed)
|
|
3292
|
+
if (item.installed) vx = screen.text(vx, y, ' ' + tr('common.installed'), installedStyle)
|
|
2455
3293
|
for (const tag of item.tags ?? []) vx = screen.text(vx, y, ' [' + tag + ']', tagStyle(tag))
|
|
2456
3294
|
}
|
|
3295
|
+
} else if (item.kind === 'update-progress') {
|
|
3296
|
+
// Live download bar: label, ten cells of █/░, then the byte progress
|
|
3297
|
+
// the value column normally carries. An unknown total (no
|
|
3298
|
+
// content-length) shows an entirely empty bar instead of a fake one.
|
|
3299
|
+
const barW = 10
|
|
3300
|
+
const percent = typeof item.percent === 'number' && Number.isFinite(item.percent)
|
|
3301
|
+
? Math.max(0, Math.min(100, item.percent))
|
|
3302
|
+
: null
|
|
3303
|
+
const done = percent === null ? 0 : Math.round((barW * percent) / 100)
|
|
3304
|
+
const barStyle = makeStyle({ fg: percent === null ? t.textMuted : percent >= 100 ? t.success : t.primary, bg: style.bg })
|
|
3305
|
+
screen.text(cx + 6 + indent, y, truncateWidth(item.label, Math.max(6, 22 - indent)), style)
|
|
3306
|
+
screen.text(cx + 30, y, '\u2588'.repeat(done) + '\u2591'.repeat(barW - done), barStyle)
|
|
3307
|
+
screen.text(cx + 30 + barW + 1, y, truncateWidth(value, Math.max(4, cw - 41 - 5)), valueStyle)
|
|
2457
3308
|
} else {
|
|
2458
3309
|
screen.text(cx + 6 + indent, y, truncateWidth(item.label, Math.max(6, 29 - indent)), style)
|
|
2459
3310
|
screen.text(cx + 36, y, truncateWidth(value, cw - 41), valueStyle)
|
|
@@ -2462,18 +3313,19 @@ export class App {
|
|
|
2462
3313
|
y++
|
|
2463
3314
|
}
|
|
2464
3315
|
const footer = this.settingsEditing !== null
|
|
2465
|
-
? '
|
|
3316
|
+
? tr('settings.footerEdit')
|
|
2466
3317
|
: hasMenu
|
|
2467
|
-
? '
|
|
2468
|
-
: '
|
|
3318
|
+
? tr('settings.footerMenu')
|
|
3319
|
+
: tr('settings.footerPlain')
|
|
2469
3320
|
screen.text(cx + 3, y0 + h - 2, footer, makeStyle({ fg: this.settingsConfirm ? t.warning : t.textMuted, bg: t.backgroundElement }))
|
|
2470
3321
|
}
|
|
2471
3322
|
|
|
2472
|
-
_paintHelp(screen, cols, rows) {
|
|
3323
|
+
_paintHelp(screen, cols, rows, railW = 0) {
|
|
2473
3324
|
const t = THEME
|
|
2474
|
-
const
|
|
2475
|
-
const
|
|
2476
|
-
const
|
|
3325
|
+
const region = overlayRegion(cols, railW)
|
|
3326
|
+
const w = Math.min(64, region - 4)
|
|
3327
|
+
const h = 25
|
|
3328
|
+
const x0 = Math.max(0, Math.floor((region - w) / 2))
|
|
2477
3329
|
const y0 = Math.max(0, Math.floor((rows - h) / 2))
|
|
2478
3330
|
const box = makeStyle({ fg: t.text, bg: t.backgroundElement })
|
|
2479
3331
|
const border = makeStyle({ fg: t.border, bg: t.backgroundElement })
|
|
@@ -2486,33 +3338,39 @@ export class App {
|
|
|
2486
3338
|
screen.set(x0, y0 + i, '│', border)
|
|
2487
3339
|
screen.set(x0 + w - 1, y0 + i, '│', border)
|
|
2488
3340
|
}
|
|
2489
|
-
screen.set(x0, y0, '
|
|
2490
|
-
screen.set(x0, y0 + h - 1, '
|
|
2491
|
-
screen.text(x0 + 2, y0 + 1, '
|
|
3341
|
+
screen.set(x0, y0, '╭', border); screen.set(x0 + w - 1, y0, '╮', border)
|
|
3342
|
+
screen.set(x0, y0 + h - 1, '╰', border); screen.set(x0 + w - 1, y0 + h - 1, '╯', border)
|
|
3343
|
+
screen.text(x0 + 2, y0 + 1, tr('help.title'), makeStyle({ fg: t.primary, bold: true, bg: t.backgroundElement }))
|
|
2492
3344
|
const rows2 = [
|
|
2493
|
-
['
|
|
2494
|
-
['
|
|
2495
|
-
['
|
|
2496
|
-
['
|
|
2497
|
-
['
|
|
2498
|
-
['
|
|
2499
|
-
['
|
|
2500
|
-
['
|
|
2501
|
-
['
|
|
2502
|
-
['
|
|
2503
|
-
['
|
|
2504
|
-
['
|
|
2505
|
-
['
|
|
2506
|
-
['
|
|
3345
|
+
[tr('help.enter'), tr('help.enterDesc')],
|
|
3346
|
+
[tr('help.ctrlEnter'), tr('help.ctrlEnterDesc')],
|
|
3347
|
+
[tr('help.ctrlC'), tr('help.ctrlCDesc')],
|
|
3348
|
+
[tr('help.ctrlP'), tr('help.ctrlPDesc')],
|
|
3349
|
+
[tr('help.ctrlE'), tr('help.ctrlEDesc')],
|
|
3350
|
+
[tr('help.tab'), tr('help.tabDesc')],
|
|
3351
|
+
[tr('help.ctrlN'), tr('help.ctrlNDesc')],
|
|
3352
|
+
[tr('help.ctrlD'), tr('help.ctrlDDesc')],
|
|
3353
|
+
[tr('help.pg'), tr('help.pgDesc')],
|
|
3354
|
+
[tr('help.shiftArrows'), tr('help.shiftArrowsDesc')],
|
|
3355
|
+
[tr('help.upDown'), tr('help.upDownDesc')],
|
|
3356
|
+
[tr('help.mouse'), tr('help.mouseDesc')],
|
|
3357
|
+
[tr('help.wheel'), tr('help.wheelDesc')],
|
|
3358
|
+
[tr('help.escEsc'), tr('help.escEscDesc')],
|
|
3359
|
+
[tr('help.esc'), tr('help.escDesc')],
|
|
2507
3360
|
]
|
|
3361
|
+
// The key column is measured, not assumed: a translated key label ("Hoch /
|
|
3362
|
+
// Runter") must not push its description off the box, and every description
|
|
3363
|
+
// is truncated to what is left of the row.
|
|
3364
|
+
const keyCol = Math.max(14, ...rows2.map(([key]) => displayWidth(key))) + 2
|
|
3365
|
+
const descRoom = Math.max(8, w - 3 - keyCol - 2)
|
|
2508
3366
|
let yy = y0 + 3
|
|
2509
3367
|
for (const [key, desc] of rows2) {
|
|
2510
3368
|
screen.text(x0 + 3, yy, key, makeStyle({ fg: t.success, bg: t.backgroundElement }))
|
|
2511
|
-
screen.text(x0 + 3 +
|
|
3369
|
+
screen.text(x0 + 3 + keyCol, yy, truncateWidth(desc, descRoom), makeStyle({ fg: t.text, bg: t.backgroundElement }))
|
|
2512
3370
|
yy++
|
|
2513
3371
|
}
|
|
2514
3372
|
yy++
|
|
2515
|
-
screen.text(x0 + 3, yy, '
|
|
3373
|
+
screen.text(x0 + 3, yy, tr('help.commands'), makeStyle({ fg: t.accent, bold: true, bg: t.backgroundElement }))
|
|
2516
3374
|
yy++
|
|
2517
3375
|
for (const cmd of ['/help /settings /new /resume <id>', '/model <id> /provider <route> /rewind', '/stats /clear /cancel /quit']) {
|
|
2518
3376
|
screen.text(x0 + 3, yy, cmd, makeStyle({ fg: t.text, bg: t.backgroundElement }))
|
|
@@ -2520,15 +3378,16 @@ export class App {
|
|
|
2520
3378
|
}
|
|
2521
3379
|
}
|
|
2522
3380
|
|
|
2523
|
-
_paintRewind(screen, cols, rows) {
|
|
3381
|
+
_paintRewind(screen, cols, rows, railW = 0) {
|
|
2524
3382
|
const picker = this.rewind
|
|
2525
3383
|
if (!picker) return
|
|
2526
3384
|
const t = THEME
|
|
2527
3385
|
const listing = picker.step === 'restore' ? picker.restoreOptions : picker.items
|
|
2528
3386
|
const sel = picker.step === 'restore' ? picker.modeIndex : picker.selected
|
|
2529
|
-
const
|
|
3387
|
+
const region = overlayRegion(cols, railW)
|
|
3388
|
+
const w = Math.min(72, region - 4)
|
|
2530
3389
|
const h = Math.min(rows - 2, 8 + Math.min(7, Math.max(1, listing.length)))
|
|
2531
|
-
const x0 = Math.max(0, Math.floor((
|
|
3390
|
+
const x0 = Math.max(0, Math.floor((region - w) / 2))
|
|
2532
3391
|
const y0 = Math.max(0, Math.floor((rows - h) / 2))
|
|
2533
3392
|
const box = makeStyle({ fg: t.text, bg: t.backgroundElement })
|
|
2534
3393
|
const border = makeStyle({ fg: t.border, bg: t.backgroundElement })
|
|
@@ -2541,18 +3400,18 @@ export class App {
|
|
|
2541
3400
|
screen.set(x0, y0 + i, '│', border)
|
|
2542
3401
|
screen.set(x0 + w - 1, y0 + i, '│', border)
|
|
2543
3402
|
}
|
|
2544
|
-
screen.set(x0, y0, '
|
|
2545
|
-
screen.set(x0, y0 + h - 1, '
|
|
2546
|
-
screen.text(x0 + 2, y0 + 1, '
|
|
3403
|
+
screen.set(x0, y0, '╭', border); screen.set(x0 + w - 1, y0, '╮', border)
|
|
3404
|
+
screen.set(x0, y0 + h - 1, '╰', border); screen.set(x0 + w - 1, y0 + h - 1, '╯', border)
|
|
3405
|
+
screen.text(x0 + 2, y0 + 1, tr('rewind.title'), makeStyle({ fg: t.primary, bold: true, bg: t.backgroundElement }))
|
|
2547
3406
|
const innerW = w - 4
|
|
2548
3407
|
let subtitle
|
|
2549
|
-
if (picker.busy) subtitle = '
|
|
3408
|
+
if (picker.busy) subtitle = tr('common.working')
|
|
2550
3409
|
else if (picker.error) subtitle = picker.error
|
|
2551
3410
|
else if (picker.step === 'restore') {
|
|
2552
3411
|
const item = picker.items[picker.selected]
|
|
2553
|
-
subtitle = '
|
|
3412
|
+
subtitle = tr('rewind.restoreTo', { label: item?.label ?? '' })
|
|
2554
3413
|
} else {
|
|
2555
|
-
subtitle = '
|
|
3414
|
+
subtitle = tr('rewind.restorePrompt')
|
|
2556
3415
|
}
|
|
2557
3416
|
screen.text(x0 + 2, y0 + 2, truncateWidth(subtitle, innerW), makeStyle({
|
|
2558
3417
|
fg: picker.error ? t.error : t.textMuted,
|
|
@@ -2563,7 +3422,7 @@ export class App {
|
|
|
2563
3422
|
const start = picker.scroll
|
|
2564
3423
|
const end = Math.min(listing.length, start + listH)
|
|
2565
3424
|
if (listing.length === 0) {
|
|
2566
|
-
screen.text(x0 + 3, listTop, '
|
|
3425
|
+
screen.text(x0 + 3, listTop, tr('rewind.empty'), makeStyle({ fg: t.textMuted, italic: true, bg: t.backgroundElement }))
|
|
2567
3426
|
}
|
|
2568
3427
|
for (let i = start; i < end; i++) {
|
|
2569
3428
|
const y = listTop + (i - start)
|
|
@@ -2591,10 +3450,10 @@ export class App {
|
|
|
2591
3450
|
this.addHitRegion(picker.step === 'restore' ? 'rewind-option' : 'rewind-item', x0 + 1, y, w - 2, 1, { rewindIndex: i })
|
|
2592
3451
|
}
|
|
2593
3452
|
const footer = picker.busy
|
|
2594
|
-
? '
|
|
3453
|
+
? tr('common.pleaseWait')
|
|
2595
3454
|
: picker.step === 'restore'
|
|
2596
|
-
? '
|
|
2597
|
-
: '
|
|
3455
|
+
? tr('common.selectConfirmBack')
|
|
3456
|
+
: tr('common.selectContinueExit')
|
|
2598
3457
|
screen.text(x0 + 2, y0 + h - 2, truncateWidth(footer, innerW), makeStyle({ fg: t.textMuted, bg: t.backgroundElement }))
|
|
2599
3458
|
}
|
|
2600
3459
|
}
|