@orion-agents/orion-code 0.4.8 → 0.4.9
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/CHANGELOG.md +8 -0
- package/README.md +5 -5
- package/README.zh-CN.md +5 -5
- package/dist/cli.js +42 -3
- package/dist/commands/session-command-handlers.js +8 -3
- package/dist/commands/system-commands.js +3 -3
- package/dist/commands/types.d.ts +3 -0
- package/dist/framework/loop-progress.js +3 -1
- package/dist/framework/query.d.ts +3 -1
- package/dist/framework/query.js +18 -3
- package/dist/framework/tool-serializer.d.ts +12 -0
- package/dist/framework/tool-serializer.js +35 -0
- package/dist/framework/tool.d.ts +2 -0
- package/dist/harness/ledger.js +2 -1
- package/dist/print-ui/delivery.d.ts +15 -0
- package/dist/print-ui/delivery.js +131 -0
- package/dist/print-ui/event-stream.d.ts +6 -1
- package/dist/print-ui/event-stream.js +56 -10
- package/dist/print-ui/launch.d.ts +5 -0
- package/dist/print-ui/launch.js +66 -9
- package/dist/runtime/agent-loop.d.ts +3 -1
- package/dist/runtime/agent-loop.js +20 -8
- package/dist/runtime/agent-runtime-controller.d.ts +4 -1
- package/dist/runtime/agent-runtime-controller.js +36 -22
- package/dist/runtime/agent-runtime-runner.d.ts +4 -0
- package/dist/runtime/agent-runtime-runner.js +9 -0
- package/dist/runtime/builtin-tool-provider.js +6 -5
- package/dist/runtime/composer/layout.d.ts +1 -1
- package/dist/runtime/composer/layout.js +5 -5
- package/dist/runtime/core-tools/descriptors.d.ts +1 -1
- package/dist/runtime/core-tools/descriptors.js +39 -1
- package/dist/runtime/first-party-core-provider.js +1 -0
- package/dist/runtime/first-party-tool-services.js +10 -0
- package/dist/runtime/goals/evidence.js +2 -0
- package/dist/runtime/legacy-thread-materializer.d.ts +7 -0
- package/dist/runtime/legacy-thread-materializer.js +32 -6
- package/dist/runtime/orion-runtime-v1.d.ts +2 -1
- package/dist/runtime/orion-runtime-v1.js +1 -0
- package/dist/runtime/product-bootstrap.d.ts +2 -0
- package/dist/runtime/product-bootstrap.js +1 -0
- package/dist/runtime/product-orion-runtime.d.ts +2 -1
- package/dist/runtime/product-orion-runtime.js +1 -0
- package/dist/runtime/rich-text/layout.d.ts +3 -1
- package/dist/runtime/rich-text/layout.js +37 -22
- package/dist/runtime/shell-process-sessions.d.ts +41 -0
- package/dist/runtime/shell-process-sessions.js +258 -0
- package/dist/runtime/step-snapshot.js +4 -1
- package/dist/runtime/subagents/presets.d.ts +1 -1
- package/dist/runtime/subagents/presets.js +1 -0
- package/dist/runtime/task-context-recovery.js +7 -0
- package/dist/runtime/thread-event-store.d.ts +3 -0
- package/dist/runtime/thread-event-store.js +35 -22
- package/dist/runtime/thread-session-index.d.ts +15 -3
- package/dist/runtime/thread-session-index.js +152 -45
- package/dist/runtime/thread-session-view.js +1 -1
- package/dist/runtime/thread-ui-adapter.d.ts +1 -1
- package/dist/runtime/thread-ui-adapter.js +14 -8
- package/dist/runtime/tool-gateway.d.ts +1 -0
- package/dist/runtime/tool-gateway.js +1 -0
- package/dist/runtime/tool-transcript-entry.d.ts +8 -1
- package/dist/runtime/tool-transcript-entry.js +35 -7
- package/dist/runtime/ui-events.d.ts +7 -0
- package/dist/services/global-config.d.ts +1 -1
- package/dist/services/global-config.js +2 -0
- package/dist/services/llm.d.ts +3 -0
- package/dist/services/llm.js +48 -4
- package/dist/terminal-ui/raw-editor.js +2 -1
- package/dist/tools/core/exec-command.js +51 -42
- package/dist/tools/core/index.d.ts +2 -1
- package/dist/tools/core/index.js +4 -1
- package/dist/tools/core/process-session.d.ts +2 -0
- package/dist/tools/core/process-session.js +54 -0
- package/dist/tui-core/frame.d.ts +2 -0
- package/dist/tui-core/frame.js +19 -0
- package/dist/tui-core/input-parser.d.ts +4 -1
- package/dist/tui-core/input-parser.js +22 -0
- package/dist/tui-ui/chrome-view-model.d.ts +0 -2
- package/dist/tui-ui/chrome-view-model.js +54 -56
- package/dist/tui-ui/launch.js +133 -202
- package/dist/tui-ui/layout.d.ts +16 -41
- package/dist/tui-ui/layout.js +408 -295
- package/dist/tui-ui/render-scheduler.d.ts +2 -5
- package/dist/tui-ui/render-scheduler.js +10 -10
- package/dist/tui-ui/response-clipboard.d.ts +17 -0
- package/dist/tui-ui/response-clipboard.js +201 -0
- package/dist/tui-ui/runner.d.ts +65 -80
- package/dist/tui-ui/runner.js +545 -738
- package/dist/tui-ui/session-picker-preview.d.ts +8 -0
- package/dist/tui-ui/session-picker-preview.js +119 -0
- package/dist/tui-ui/session-picker.d.ts +20 -0
- package/dist/tui-ui/session-picker.js +42 -0
- package/dist/tui-ui/state.d.ts +34 -81
- package/dist/tui-ui/state.js +155 -288
- package/dist/tui-ui/terminal-image.d.ts +3 -7
- package/dist/tui-ui/terminal-image.js +18 -47
- package/dist/tui-ui/terminal-viewport.d.ts +55 -0
- package/dist/tui-ui/terminal-viewport.js +221 -0
- package/dist/tui-ui/transcript-layout.d.ts +5 -0
- package/dist/tui-ui/transcript-layout.js +43 -28
- package/dist/tui-ui/transcript-pager.d.ts +39 -0
- package/dist/tui-ui/transcript-pager.js +278 -0
- package/dist/tui-ui/transcript-tool-output.d.ts +16 -0
- package/dist/tui-ui/transcript-tool-output.js +102 -0
- package/dist/utils/bounded-file.d.ts +4 -0
- package/dist/utils/bounded-file.js +30 -0
- package/dist/utils/command-process.d.ts +4 -0
- package/dist/utils/command-process.js +23 -0
- package/docs/cli-guide.md +50 -6
- package/npm-shrinkwrap.json +115 -15
- package/package.json +4 -1
- package/dist/tui-ui/inline-surface.d.ts +0 -191
- package/dist/tui-ui/inline-surface.js +0 -644
- package/dist/tui-ui/input-ownership.d.ts +0 -46
- package/dist/tui-ui/input-ownership.js +0 -74
- package/dist/tui-ui/transcript-inspector-layout.d.ts +0 -9
- package/dist/tui-ui/transcript-inspector-layout.js +0 -107
- package/dist/tui-ui/transcript-inspector-surface.d.ts +0 -18
- package/dist/tui-ui/transcript-inspector-surface.js +0 -91
- package/dist/tui-ui/transcript-inspector.d.ts +0 -36
- package/dist/tui-ui/transcript-inspector.js +0 -129
package/dist/tui-ui/layout.js
CHANGED
|
@@ -3,185 +3,227 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.measureTuiLiveFrameHeight = measureTuiLiveFrameHeight;
|
|
7
6
|
exports.renderTuiUiFrame = renderTuiUiFrame;
|
|
8
|
-
exports.
|
|
7
|
+
exports.renderTranscriptPagerFrame = renderTranscriptPagerFrame;
|
|
8
|
+
exports.moveTuiPromptVisualCursor = moveTuiPromptVisualCursor;
|
|
9
9
|
const string_width_1 = __importDefault(require("string-width"));
|
|
10
10
|
const frame_1 = require("../tui-core/frame");
|
|
11
11
|
const style_1 = require("../tui-core/style");
|
|
12
12
|
const grapheme_1 = require("../runtime/composer/grapheme");
|
|
13
|
+
const layout_1 = require("../runtime/composer/layout");
|
|
13
14
|
const ui_view_model_1 = require("../runtime/ui-view-model");
|
|
14
15
|
const format_1 = require("../services/format");
|
|
15
|
-
const state_1 = require("./state");
|
|
16
16
|
const transcript_layout_1 = require("./transcript-layout");
|
|
17
|
+
const transcript_pager_1 = require("./transcript-pager");
|
|
17
18
|
const chrome_view_model_1 = require("./chrome-view-model");
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const MIN_HEIGHT = 8;
|
|
21
|
-
const PROMPT_BORDER_ROWS = 2;
|
|
22
|
-
const MAX_TIMELINE_ROWS = 6;
|
|
19
|
+
const PROMPT_PREFIX = '› ';
|
|
20
|
+
const MAX_PROMPT_ROWS = 6;
|
|
23
21
|
const MAX_COMPOSER_PICKER_ROWS = 6;
|
|
24
|
-
const STATUS_ROWS = 1;
|
|
25
22
|
const ACTIVITY_SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧'];
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return activeSubtaskTimelineEntries(state).length + activeToolStarts(state).length;
|
|
23
|
+
/** Keep the editable row and activity visible, then allocate the popup or passive footer. */
|
|
24
|
+
function computeBudget(height, state, visualPromptRows, picker) {
|
|
25
|
+
const activityRows = Number(state.processing && height > 1);
|
|
26
|
+
const available = height - activityRows;
|
|
27
|
+
const minHistory = picker
|
|
28
|
+
? Number(available > 2 && state.transcript.length > 0)
|
|
29
|
+
: Number(available > 1 && (state.transcript.length > 0 || !!state.overlay));
|
|
30
|
+
const bottomRows = available - minHistory;
|
|
31
|
+
const footerRows = picker
|
|
32
|
+
? Math.min(bottomRows - 1, MAX_COMPOSER_PICKER_ROWS, Math.max(1, Math.floor(height / 2)), Math.max(1, picker.items.length + Number(picker.type === 'files')))
|
|
33
|
+
: Number(bottomRows > 1);
|
|
34
|
+
const promptRows = Math.min(visualPromptRows, MAX_PROMPT_ROWS, Math.max(1, Math.floor(height / 2)), bottomRows - footerRows);
|
|
35
|
+
const queueRows = picker
|
|
36
|
+
? 0
|
|
37
|
+
: Math.max(0, Math.min(2, state.followupQueue.items.length, bottomRows - promptRows - footerRows));
|
|
38
|
+
return {
|
|
39
|
+
promptRows,
|
|
40
|
+
activityRows,
|
|
41
|
+
queueRows,
|
|
42
|
+
footerRows,
|
|
43
|
+
transcriptRows: available - promptRows - footerRows - queueRows,
|
|
44
|
+
};
|
|
49
45
|
}
|
|
50
46
|
function activeToolStarts(state) {
|
|
51
47
|
const finishedCallIds = new Set(state.runtimeToolEvents.filter(event => event.type === 'finished').map(event => event.callId));
|
|
52
48
|
return state.runtimeToolEvents.filter(event => event.type === 'started' && !finishedCallIds.has(event.callId));
|
|
53
49
|
}
|
|
54
|
-
function activeSubtaskTimelineEntries(state) {
|
|
55
|
-
return state.subtaskTimeline.filter(entry => entry.state === 'queued' || entry.state === 'running');
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Measure the cursor-owned live block. Idle TUI state stays compact like an
|
|
59
|
-
* ordinary shell prompt. Composer pickers draw into this same block, so opening
|
|
60
|
-
* one does not allocate terminal rows or advance native scrollback.
|
|
61
|
-
*/
|
|
62
|
-
function measureTuiLiveFrameHeight(state, width, maxHeight, options = {}) {
|
|
63
|
-
const safeWidth = Math.max(MIN_WIDTH, Math.floor(width));
|
|
64
|
-
const transcriptWidth = resolveTranscriptWidth(safeWidth, options.transcriptWidth);
|
|
65
|
-
const safeMaxHeight = Math.max(MIN_HEIGHT, Math.floor(maxHeight));
|
|
66
|
-
if (state.overlay && state.overlay.type !== 'commands' && state.overlay.type !== 'files') {
|
|
67
|
-
return safeMaxHeight;
|
|
68
|
-
}
|
|
69
|
-
const budget = computeBudget(safeMaxHeight, state);
|
|
70
|
-
const fixedRows = safeMaxHeight - budget.transcriptRows;
|
|
71
|
-
const transcriptRows = state.transcript
|
|
72
|
-
.slice(state.queuedTranscriptCount)
|
|
73
|
-
.reduce((count, entry) => count + layoutRecord(entry, transcriptWidth, options).length, 0);
|
|
74
|
-
return Math.min(safeMaxHeight, Math.max(MIN_HEIGHT, fixedRows + transcriptRows));
|
|
75
|
-
}
|
|
76
50
|
function renderTuiUiFrame(state, options) {
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
51
|
+
const frame = (0, frame_1.createTuiFrame)(options.width, options.height);
|
|
52
|
+
const theme = options.theme ?? style_1.DEFAULT_THEME;
|
|
53
|
+
const overlay = state.overlay;
|
|
54
|
+
if (overlay?.type === 'permission') {
|
|
55
|
+
renderPermissionPicker(frame, overlay, theme);
|
|
56
|
+
(0, frame_1.setFrameCursor)(frame, 0, 0, false);
|
|
57
|
+
return frame;
|
|
58
|
+
}
|
|
59
|
+
if (overlay?.type === 'sessions') {
|
|
60
|
+
renderSessionPicker(frame, state, overlay, theme);
|
|
61
|
+
return frame;
|
|
62
|
+
}
|
|
63
|
+
if (overlay?.type === 'queue') {
|
|
64
|
+
renderFollowupQueue(frame, state, overlay, theme);
|
|
65
|
+
return frame;
|
|
66
|
+
}
|
|
67
|
+
const picker = overlay?.type === 'commands' || overlay?.type === 'files' ? overlay : null;
|
|
68
|
+
const prompt = layoutPrompt(state.prompt.value, state.prompt.cursor, frame.width);
|
|
69
|
+
const budget = computeBudget(frame.height, state, prompt.lines.length, picker);
|
|
83
70
|
const transcriptRows = Math.max(0, Math.min(options.maxTranscriptRows ?? budget.transcriptRows, budget.transcriptRows));
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
71
|
+
const footerTop = frame.height - budget.footerRows;
|
|
72
|
+
const promptTop = footerTop - budget.promptRows;
|
|
73
|
+
const pager = options.transcriptPager ?? new transcript_pager_1.TranscriptPager();
|
|
74
|
+
const fullPicker = overlay && !picker;
|
|
75
|
+
if (fullPicker) {
|
|
76
|
+
renderOverlay(frame, overlay, budget.transcriptRows);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
if (!state.transcript.length && options.startupRows) {
|
|
80
|
+
options.startupRows.slice(0, transcriptRows).forEach((row, index) => {
|
|
81
|
+
let available = frame.width;
|
|
82
|
+
const clipped = [];
|
|
83
|
+
for (const span of row) {
|
|
84
|
+
const text = truncateCells(span.text, available);
|
|
85
|
+
if (text.length === 0)
|
|
86
|
+
break;
|
|
87
|
+
clipped.push({ ...span, text });
|
|
88
|
+
available -= (0, string_width_1.default)(text);
|
|
89
|
+
}
|
|
90
|
+
(0, transcript_layout_1.writeStyledRowToFrame)(frame, index, clipped);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
const toolOutputMode = options.toolOutputMode ?? state.toolOutputViewMode;
|
|
95
|
+
renderTranscript(frame, state, 0, transcriptRows, { ...options, toolOutputMode }, pager, {
|
|
96
|
+
layoutExploration: toolOutputMode === 'full'
|
|
97
|
+
? undefined
|
|
98
|
+
: (counts, width) => layoutExplorationGroup(counts, width, theme),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (budget.queueRows) {
|
|
103
|
+
renderFollowupPreview(frame, state, budget.transcriptRows, budget.queueRows, theme);
|
|
104
|
+
}
|
|
105
|
+
if (budget.activityRows) {
|
|
106
|
+
renderActivity(frame, state, budget.transcriptRows + budget.queueRows, options);
|
|
107
|
+
}
|
|
108
|
+
renderPrompt(frame, state, prompt, promptTop, budget.promptRows, theme);
|
|
109
|
+
if (budget.footerRows) {
|
|
110
|
+
if (picker)
|
|
111
|
+
renderComposerPicker(frame, picker, footerTop, budget.footerRows, theme);
|
|
112
|
+
else
|
|
113
|
+
renderStatus(frame, state, footerTop, options, !pager.isFollowing, budget.queueRows > 0);
|
|
114
|
+
}
|
|
96
115
|
return frame;
|
|
97
116
|
}
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
117
|
+
/** The full transcript view reads the same records as the chat viewport. */
|
|
118
|
+
function renderTranscriptPagerFrame(state, options) {
|
|
119
|
+
const frame = (0, frame_1.createTuiFrame)(options.width, options.height);
|
|
120
|
+
const theme = options.theme ?? style_1.DEFAULT_THEME;
|
|
121
|
+
const tail = activeToolStarts(state).map(event => ({
|
|
122
|
+
id: `running-tool:${event.callId}`,
|
|
123
|
+
role: 'tool',
|
|
124
|
+
content: '',
|
|
125
|
+
finalized: false,
|
|
126
|
+
revision: 1,
|
|
127
|
+
toolActivity: {
|
|
128
|
+
state: 'running',
|
|
129
|
+
name: event.name,
|
|
130
|
+
detail: '',
|
|
131
|
+
command: event.command,
|
|
132
|
+
body: '',
|
|
133
|
+
callId: event.callId,
|
|
134
|
+
seq: event.sequence,
|
|
135
|
+
},
|
|
136
|
+
}));
|
|
137
|
+
const pageOptions = {
|
|
138
|
+
head: options.olderRecords,
|
|
139
|
+
tail,
|
|
140
|
+
hasEarlier: options.hasEarlierRecords,
|
|
141
|
+
onVisibleRecord: options.onVisibleRecord,
|
|
142
|
+
};
|
|
143
|
+
const historyLayout = {
|
|
144
|
+
...options,
|
|
145
|
+
layoutTranscriptRecord: options.layoutTranscriptRecord ??
|
|
146
|
+
((entry, width) => (0, transcript_layout_1.layoutTranscriptEntry)(entry, { width, theme, history: true })),
|
|
147
|
+
};
|
|
148
|
+
if (frame.height > 2) {
|
|
149
|
+
(0, frame_1.writeFrameText)(frame, 0, 0, ellipsizeCells('Transcript', frame.width), theme.brand);
|
|
150
|
+
renderTranscript(frame, state, 1, frame.height - 2, historyLayout, options.transcriptPager, pageOptions);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
renderTranscript(frame, state, 0, frame.height, historyLayout, options.transcriptPager, pageOptions);
|
|
154
|
+
}
|
|
155
|
+
if (frame.height > 2) {
|
|
156
|
+
let navigation = 'PgUp/PgDn scroll';
|
|
157
|
+
if (options.loadingEarlierRecords)
|
|
158
|
+
navigation = 'Loading earlier messages…';
|
|
159
|
+
else if (options.transcriptPager.nearStart)
|
|
160
|
+
navigation = 'PgUp load earlier';
|
|
161
|
+
(0, frame_1.writeFrameText)(frame, frame.height - 1, 0, ellipsizeCells(`${navigation} · Ctrl+T close`, frame.width), theme.statusText);
|
|
162
|
+
}
|
|
163
|
+
(0, frame_1.setFrameCursor)(frame, 0, 0, false);
|
|
125
164
|
return frame;
|
|
126
165
|
}
|
|
127
|
-
|
|
128
|
-
function renderLiveTranscript(frame, state, startRow, maxRows, options) {
|
|
166
|
+
function renderTranscript(frame, state, startRow, maxRows, options, pager, pageOptions) {
|
|
129
167
|
const width = resolveTranscriptWidth(frame.width, options.transcriptWidth);
|
|
130
|
-
const rows = state.transcript
|
|
131
|
-
|
|
132
|
-
.flatMap(entry => layoutRecord(entry, width, options));
|
|
133
|
-
const visible = rows.slice(Math.max(0, rows.length - maxRows));
|
|
134
|
-
visible.forEach((row, index) => {
|
|
135
|
-
(0, transcript_layout_1.writeStyledRowToFrame)(frame, startRow + index, row);
|
|
136
|
-
});
|
|
168
|
+
const rows = pager.rows(state.transcript, width, maxRows, (entry, columns) => layoutRecord(entry, columns, options), pageOptions);
|
|
169
|
+
rows.forEach((row, index) => (0, transcript_layout_1.writeStyledRowToFrame)(frame, startRow + index, row));
|
|
137
170
|
}
|
|
138
|
-
function
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
171
|
+
function layoutExplorationGroup({ reads, searches, listings }, width, theme) {
|
|
172
|
+
const calls = reads + searches + listings;
|
|
173
|
+
const label = `• Explored ${calls} calls`;
|
|
174
|
+
const labelWidth = (0, string_width_1.default)(label);
|
|
175
|
+
const labelStyle = theme.toolName ?? theme.assistantText;
|
|
176
|
+
if (width < labelWidth) {
|
|
177
|
+
const compact = `Explored ${calls}`;
|
|
178
|
+
const text = ellipsizeCells((0, string_width_1.default)(compact) <= width ? compact : `${calls} calls`, width);
|
|
179
|
+
return [[{ text, style: labelStyle }]];
|
|
180
|
+
}
|
|
181
|
+
const details = [
|
|
182
|
+
reads && `${reads} ${reads === 1 ? 'read' : 'reads'}`,
|
|
183
|
+
searches && `${searches} ${searches === 1 ? 'search' : 'searches'}`,
|
|
184
|
+
listings && `${listings} ${listings === 1 ? 'listing' : 'listings'}`,
|
|
185
|
+
].filter(Boolean);
|
|
186
|
+
return [
|
|
187
|
+
[
|
|
188
|
+
{ text: label, style: labelStyle },
|
|
189
|
+
{
|
|
190
|
+
text: ellipsizeCells(` · ${details.join(' · ')}`, width - labelWidth),
|
|
191
|
+
style: theme.toolMeta ?? theme.muted,
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
];
|
|
146
195
|
}
|
|
147
196
|
/** Render the activity timeline (subtasks + running tools) just above status. */
|
|
148
|
-
function
|
|
149
|
-
const items = [];
|
|
150
|
-
for (const t of activeSubtaskTimelineEntries(state)) {
|
|
151
|
-
const mark = t.state === 'running' ? '▶' : '◦';
|
|
152
|
-
const label = t.summary ?? t.objective ?? t.role;
|
|
153
|
-
const sequence = state.subtaskTimeline.findIndex(entry => entry.taskId === t.taskId) + 1;
|
|
154
|
-
items.push(`${mark} #${sequence} ${t.role} · ${truncateCells(label, 34)} · ${t.state}`);
|
|
155
|
-
}
|
|
156
|
-
for (const e of activeToolStarts(state)) {
|
|
157
|
-
items.push(`⚙ #${e.sequence} ${e.command ?? e.name} running`);
|
|
158
|
-
}
|
|
159
|
-
const visible = items.slice(-maxRows);
|
|
160
|
-
visible.forEach((line, index) => {
|
|
161
|
-
(0, frame_1.writeFrameText)(frame, top + index, 0, truncateCells(line, frame.width), theme?.activityRunning);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
function renderStatus(frame, state, row, options) {
|
|
197
|
+
function renderStatus(frame, state, row, options, readingHistory, queuePreviewVisible) {
|
|
165
198
|
if (row < 0)
|
|
166
199
|
return;
|
|
167
200
|
const chrome = (0, chrome_view_model_1.createTuiChromeViewModel)(state, options.statusLine);
|
|
168
201
|
const mode = chrome.segments.find(segment => segment.id === 'mode');
|
|
169
202
|
const secondary = chrome.segments
|
|
170
|
-
.filter(segment => segment.id !== 'mode')
|
|
203
|
+
.filter(segment => segment.id !== 'mode' && (!queuePreviewVisible || segment.id !== 'queue'))
|
|
171
204
|
.sort((a, b) => b.priority - a.priority);
|
|
172
205
|
const theme = options.theme ?? style_1.DEFAULT_THEME;
|
|
173
|
-
const separator = '
|
|
206
|
+
const separator = ' · ';
|
|
174
207
|
const separatorWidth = (0, string_width_1.default)(separator);
|
|
208
|
+
const width = frame.width;
|
|
175
209
|
let column = 0;
|
|
176
210
|
const write = (text, style) => {
|
|
177
211
|
(0, frame_1.writeFrameText)(frame, row, column, text, style);
|
|
178
212
|
column += (0, string_width_1.default)(text);
|
|
179
213
|
};
|
|
180
214
|
if (mode)
|
|
181
|
-
write(ellipsizeCells(mode.label,
|
|
215
|
+
write(ellipsizeCells(mode.label, width), segmentStyle(mode, theme, state));
|
|
216
|
+
if (readingHistory) {
|
|
217
|
+
const hint = width >= 30 ? 'History · PgDn' : 'History';
|
|
218
|
+
if (column + separatorWidth + (0, string_width_1.default)(hint) <= width) {
|
|
219
|
+
if (column > 0)
|
|
220
|
+
write(separator, theme.statusText);
|
|
221
|
+
write(hint, theme.statusText);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
182
224
|
// Claim space for compact labels before letting any single long label expand.
|
|
183
225
|
// A model name or Goal objective must not crowd out the current phase or queue.
|
|
184
|
-
let remaining =
|
|
226
|
+
let remaining = width - column;
|
|
185
227
|
const visible = secondary.flatMap(segment => {
|
|
186
228
|
const label = singleLine(segment.label);
|
|
187
229
|
const compact = segment.compactLabel
|
|
@@ -208,71 +250,101 @@ function renderStatus(frame, state, row, options) {
|
|
|
208
250
|
write(separator, theme.statusText);
|
|
209
251
|
write(text, segmentStyle(segment, theme, state));
|
|
210
252
|
}
|
|
211
|
-
if (!state.processing && options.mascot !== false && frame.width >= 48) {
|
|
212
|
-
const badge = `${separator}${(0, pixel_mascot_1.pixelHunterBadge)(chrome.pose, options.animationFrame)}`;
|
|
213
|
-
if (column + (0, string_width_1.default)(badge) <= frame.width)
|
|
214
|
-
write(badge, theme.mascot);
|
|
215
|
-
}
|
|
216
253
|
}
|
|
217
254
|
function renderActivity(frame, state, row, options) {
|
|
218
255
|
const theme = options.theme ?? style_1.DEFAULT_THEME;
|
|
219
|
-
if (state.overlay?.type === 'permission') {
|
|
220
|
-
(0, frame_1.writeFrameText)(frame, row, 0, '◇ Waiting for approval', theme.warning);
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
256
|
const spinner = ACTIVITY_SPINNER[(options.animationFrame ?? 0) % ACTIVITY_SPINNER.length];
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
257
|
+
const tools = activeToolStarts(state);
|
|
258
|
+
const currentTool = tools.at(-1);
|
|
259
|
+
const currentAgent = state.subtaskTimeline.find(entry => entry.state === 'running');
|
|
260
|
+
const phase = tools.length > 0
|
|
261
|
+
? `Running tools${tools.length > 1 ? ` ${tools.length}` : ''}`
|
|
262
|
+
: currentAgent
|
|
227
263
|
? 'Running agents'
|
|
228
264
|
: 'Working';
|
|
229
|
-
const
|
|
230
|
-
|
|
265
|
+
const heading = `${spinner} ${phase}`;
|
|
266
|
+
const elapsed = options.activityElapsedSeconds;
|
|
267
|
+
const full = `${heading} · ${elapsed === undefined ? '' : `${formatElapsed(elapsed)} · `}Esc to interrupt`;
|
|
268
|
+
const shortcut = ' · Esc';
|
|
269
|
+
if ((0, string_width_1.default)(full) > frame.width) {
|
|
270
|
+
const compact = frame.width > (0, string_width_1.default)(shortcut)
|
|
271
|
+
? `${ellipsizeCells(heading, frame.width - (0, string_width_1.default)(shortcut))}${shortcut}`
|
|
272
|
+
: truncateCells(heading, frame.width);
|
|
273
|
+
(0, frame_1.writeFrameText)(frame, row, 0, compact, theme.activityRunning);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
(0, frame_1.writeFrameText)(frame, row, 0, full, theme.activityRunning);
|
|
277
|
+
const label = currentTool
|
|
278
|
+
? [currentTool.name, currentTool.command].filter(Boolean).join(' · ')
|
|
279
|
+
: (currentAgent?.summary ?? currentAgent?.objective ?? currentAgent?.role);
|
|
280
|
+
const column = (0, string_width_1.default)(full);
|
|
281
|
+
const detailWidth = frame.width - column - 3;
|
|
282
|
+
if (label && detailWidth >= 8) {
|
|
283
|
+
(0, frame_1.writeFrameText)(frame, row, column, ` · ${ellipsizeCells(singleLine(label), detailWidth)}`, theme.statusText);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
function formatElapsed(seconds) {
|
|
287
|
+
if (seconds < 60)
|
|
288
|
+
return `${seconds}s`;
|
|
289
|
+
if (seconds < 3600)
|
|
290
|
+
return `${Math.floor(seconds / 60)}m ${seconds % 60}s`;
|
|
291
|
+
return `${Math.floor(seconds / 3600)}h ${Math.floor((seconds % 3600) / 60)}m`;
|
|
231
292
|
}
|
|
232
293
|
function singleLine(value) {
|
|
233
294
|
return (0, style_1.sanitizeTerminalText)(value).replace(/\s+/gu, ' ').trim();
|
|
234
295
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
296
|
+
function layoutPrompt(value, cursor, width) {
|
|
297
|
+
const textStart = width >= 5 ? (0, string_width_1.default)(PROMPT_PREFIX) : 0;
|
|
298
|
+
// Leave a cell for the caret at the end of a full line when the viewport allows it.
|
|
299
|
+
const reservedColumns = textStart + Number(textStart > 0);
|
|
300
|
+
const lines = (0, layout_1.getPromptVisualLines)(value.replace(/\t/gu, ' '), width, reservedColumns);
|
|
301
|
+
const offset = (0, grapheme_1.floorGraphemeBoundary)(value, cursor);
|
|
302
|
+
let cursorRow = lines.length - 1;
|
|
303
|
+
while (cursorRow > 0 && lines[cursorRow].start > offset)
|
|
304
|
+
cursorRow -= 1;
|
|
305
|
+
const line = lines[cursorRow];
|
|
306
|
+
const cursorColumn = (0, string_width_1.default)(line.content.slice(0, offset - line.start));
|
|
307
|
+
return { lines, cursorRow, cursorColumn, textStart };
|
|
308
|
+
}
|
|
309
|
+
/** Move within the displayed draft before Up/Down hands off to input history. */
|
|
310
|
+
function moveTuiPromptVisualCursor(value, cursor, width, direction) {
|
|
311
|
+
const { lines, cursorRow, cursorColumn } = layoutPrompt(value, cursor, width);
|
|
312
|
+
const targetRow = cursorRow + direction;
|
|
313
|
+
const target = lines[targetRow];
|
|
314
|
+
if (!target)
|
|
315
|
+
return undefined;
|
|
316
|
+
const hasSoftBoundary = lines[targetRow + 1]?.start === target.end;
|
|
317
|
+
let column = 0;
|
|
318
|
+
let offset = target.start;
|
|
319
|
+
for (const part of (0, grapheme_1.segmentGraphemes)(target.content)) {
|
|
320
|
+
const end = part.index + part.segment.length;
|
|
321
|
+
const nextColumn = column + (0, string_width_1.default)(part.segment);
|
|
322
|
+
// One offset at a soft wrap belongs to the next row. Walking up onto
|
|
323
|
+
// that offset would leave the cursor in the current row.
|
|
324
|
+
if (nextColumn > cursorColumn || (hasSoftBoundary && end === target.content.length))
|
|
325
|
+
break;
|
|
326
|
+
column = nextColumn;
|
|
327
|
+
offset = target.start + end;
|
|
328
|
+
}
|
|
329
|
+
return (0, grapheme_1.floorGraphemeBoundary)(value, offset);
|
|
330
|
+
}
|
|
331
|
+
/** Draw a caret-bearing window of the visual rows without changing the draft. */
|
|
332
|
+
function renderPrompt(frame, state, prompt, top, visibleCount, theme) {
|
|
333
|
+
const { lines, cursorRow, cursorColumn, textStart } = prompt;
|
|
334
|
+
const first = Math.max(0, Math.min(cursorRow - Math.floor((visibleCount - 1) / 2), lines.length - visibleCount));
|
|
335
|
+
const background = theme.userBackground?.background;
|
|
336
|
+
const markerStyle = { ...promptModeStyle(state, theme), background };
|
|
337
|
+
const inputStyle = { ...theme.userText, background };
|
|
338
|
+
const fillStyle = { background };
|
|
339
|
+
lines.slice(first, first + visibleCount).forEach((line, index) => {
|
|
340
|
+
const row = top + index;
|
|
341
|
+
for (const cell of frame.rows[row])
|
|
342
|
+
cell.style = fillStyle;
|
|
343
|
+
if (index === 0 && textStart > 0)
|
|
344
|
+
(0, frame_1.writeFrameText)(frame, row, 0, PROMPT_PREFIX, markerStyle);
|
|
345
|
+
(0, frame_1.writeFrameText)(frame, row, textStart, truncateCells(line.content, frame.width - textStart), inputStyle);
|
|
346
|
+
});
|
|
347
|
+
(0, frame_1.setFrameCursor)(frame, top + cursorRow - first, textStart + cursorColumn, true);
|
|
276
348
|
}
|
|
277
349
|
function promptModeStyle(state, theme) {
|
|
278
350
|
if (state.goal)
|
|
@@ -305,67 +377,9 @@ function segmentStyle(segment, theme, state) {
|
|
|
305
377
|
return theme?.statusText;
|
|
306
378
|
}
|
|
307
379
|
}
|
|
308
|
-
function
|
|
309
|
-
if (width <= 0)
|
|
310
|
-
return { text: '', cursorCells: 0 };
|
|
311
|
-
const graphemes = (0, grapheme_1.segmentGraphemes)(value);
|
|
312
|
-
const rightIndex = graphemes.findIndex(part => part.index + part.segment.length > cursor);
|
|
313
|
-
const boundary = rightIndex < 0 ? value.length : graphemes[rightIndex].index;
|
|
314
|
-
const after = value.slice(boundary);
|
|
315
|
-
const rightBudget = Math.min((0, string_width_1.default)(after), Math.ceil(width / 3));
|
|
316
|
-
const beforeBudget = width - rightBudget;
|
|
317
|
-
let left = value.slice(0, boundary);
|
|
318
|
-
let cursorCells = (0, string_width_1.default)(left);
|
|
319
|
-
if (cursorCells > beforeBudget) {
|
|
320
|
-
cursorCells = 1;
|
|
321
|
-
let start = rightIndex < 0 ? graphemes.length : rightIndex;
|
|
322
|
-
while (start > 0) {
|
|
323
|
-
const cells = (0, string_width_1.default)(graphemes[start - 1].segment);
|
|
324
|
-
if (cursorCells + cells > beforeBudget)
|
|
325
|
-
break;
|
|
326
|
-
cursorCells += cells;
|
|
327
|
-
start--;
|
|
328
|
-
}
|
|
329
|
-
left = `…${value.slice(graphemes[start]?.index ?? boundary, boundary)}`;
|
|
330
|
-
}
|
|
331
|
-
return {
|
|
332
|
-
text: `${left}${ellipsizeCells(after, width - cursorCells)}`,
|
|
333
|
-
cursorCells,
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
function renderOverlay(frame, overlay, maxRows, transcriptRows, theme) {
|
|
380
|
+
function renderOverlay(frame, overlay, maxRows) {
|
|
337
381
|
if (!overlay || maxRows <= 0)
|
|
338
382
|
return;
|
|
339
|
-
if (overlay.type === 'commands' || overlay.type === 'files') {
|
|
340
|
-
renderComposerPicker(frame, overlay, transcriptRows, theme);
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
if (overlay.type === 'sessions') {
|
|
344
|
-
const request = overlay.request;
|
|
345
|
-
const visibleCount = Math.max(0, Math.min(maxRows - 1, request.maxVisibleItems ?? maxRows - 1, request.sessions.length));
|
|
346
|
-
const start = sessionPickerStartIndex(overlay.selectedIndex, visibleCount, request.sessions.length);
|
|
347
|
-
const visibleSessions = request.sessions.slice(start, start + visibleCount);
|
|
348
|
-
const rows = [
|
|
349
|
-
`Sessions: ${request.title} (${overlay.selectedIndex + 1}/${request.sessions.length})`,
|
|
350
|
-
...visibleSessions.map((session, offset) => {
|
|
351
|
-
const index = start + offset;
|
|
352
|
-
const marker = index === overlay.selectedIndex ? '›' : ' ';
|
|
353
|
-
const label = session.name || session.taskSummary || session.id.slice(0, 8);
|
|
354
|
-
const size = (0, format_1.formatBytes)(session.historySizeBytes ?? 0);
|
|
355
|
-
const messages = `${session.messageCount ?? 0} msgs`;
|
|
356
|
-
const project = request.showProject ? ` ${session.projectPath}` : '';
|
|
357
|
-
return `${marker} ${String(index + 1).padStart(2, ' ')} ${session.id.slice(0, 8)} ${label} ${messages} ${size} ${session.model}${project}`;
|
|
358
|
-
}),
|
|
359
|
-
].map(row => truncateCells(row, frame.width));
|
|
360
|
-
rows.slice(0, maxRows).forEach((line, index) => {
|
|
361
|
-
(0, frame_1.writeFrameText)(frame, index, 0, line);
|
|
362
|
-
});
|
|
363
|
-
// Clear any remaining transcript rows below overlay content
|
|
364
|
-
for (let i = rows.length; i < maxRows; i++) {
|
|
365
|
-
(0, frame_1.writeFrameText)(frame, i, 0, '');
|
|
366
|
-
}
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
383
|
if (overlay.type === 'model') {
|
|
370
384
|
const request = overlay.request;
|
|
371
385
|
const pickerState = (0, ui_view_model_1.createModelPickerState)({ ...request, visibleStart: 0 });
|
|
@@ -422,43 +436,157 @@ function renderOverlay(frame, overlay, maxRows, transcriptRows, theme) {
|
|
|
422
436
|
}
|
|
423
437
|
return;
|
|
424
438
|
}
|
|
425
|
-
if (overlay.type === 'permission') {
|
|
426
|
-
const picker = (0, ui_view_model_1.createPermissionDecisionPickerState)(overlay.request);
|
|
427
|
-
const rows = [
|
|
428
|
-
`Tool Permission: ${overlay.request.name}`,
|
|
429
|
-
...picker.visibleItems.map((item, index) => {
|
|
430
|
-
const marker = index === overlay.selectedIndex ? '›' : ' ';
|
|
431
|
-
return `${marker} ${item.label}${item.description ? ` — ${item.description}` : ''}`;
|
|
432
|
-
}),
|
|
433
|
-
'Enter select y allow once n/Esc deny',
|
|
434
|
-
].map(row => truncateCells(row, frame.width));
|
|
435
|
-
rows.slice(0, maxRows).forEach((line, index) => {
|
|
436
|
-
(0, frame_1.writeFrameText)(frame, index, 0, line);
|
|
437
|
-
});
|
|
438
|
-
// Clear any remaining transcript rows below overlay content
|
|
439
|
-
for (let i = rows.length; i < maxRows; i++) {
|
|
440
|
-
(0, frame_1.writeFrameText)(frame, i, 0, '');
|
|
441
|
-
}
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
439
|
if (overlay.type === 'shortcuts') {
|
|
445
440
|
const rows = [
|
|
446
441
|
'Orion Pixel · Shortcuts',
|
|
447
|
-
'/ commands @ files ? help Ctrl+O
|
|
442
|
+
'/ commands @ files ? help Ctrl+O copy reply',
|
|
448
443
|
'Enter send/steer Tab complete/queue Shift+Tab cycle mode',
|
|
449
|
-
'
|
|
450
|
-
'Ctrl+R history Ctrl+E editor Ctrl+L redraw
|
|
451
|
-
'
|
|
444
|
+
'Ctrl+T transcript PgUp/PgDn scroll',
|
|
445
|
+
'Esc stop Ctrl+R history Ctrl+E editor Ctrl+L redraw',
|
|
446
|
+
'/resume find sessions /queue manage Alt+↑ edit last queued',
|
|
447
|
+
'Ctrl+C interrupt / twice exits Ctrl+D exit',
|
|
452
448
|
].map(row => truncateCells(row, frame.width));
|
|
453
449
|
rows.slice(0, maxRows).forEach((line, index) => {
|
|
454
450
|
(0, frame_1.writeFrameText)(frame, index, 0, line);
|
|
455
451
|
});
|
|
456
452
|
}
|
|
457
453
|
}
|
|
458
|
-
function
|
|
459
|
-
const
|
|
460
|
-
|
|
454
|
+
function renderSessionPicker(frame, state, { query, matches, preview, request, selectedIndex }, theme) {
|
|
455
|
+
const headingRows = Number(frame.height >= 3);
|
|
456
|
+
const hintRows = Number(frame.height >= 5);
|
|
457
|
+
const bodyStart = headingRows + 1;
|
|
458
|
+
const bodyRows = frame.height - bodyStart - hintRows;
|
|
459
|
+
const active = matches[selectedIndex];
|
|
460
|
+
if (headingRows) {
|
|
461
|
+
const position = active ? selectedIndex + 1 : 0;
|
|
462
|
+
writeModalLine(frame, 0, `Sessions: ${request.title} (${position}/${matches.length})`, theme.brand);
|
|
463
|
+
}
|
|
464
|
+
if (hintRows) {
|
|
465
|
+
writeModalLine(frame, frame.height - 1, '↑↓ select · Enter resume · Esc close', theme.statusText);
|
|
466
|
+
}
|
|
467
|
+
const visualQuery = layoutPrompt(query.value, query.cursor, frame.width);
|
|
468
|
+
renderPrompt(frame, state, visualQuery, headingRows, 1, theme);
|
|
469
|
+
if (!query.value && frame.width > visualQuery.textStart) {
|
|
470
|
+
(0, frame_1.writeFrameText)(frame, headingRows, visualQuery.textStart, ellipsizeCells('Search sessions', frame.width - visualQuery.textStart), { ...theme.statusText, background: theme.userBackground?.background });
|
|
471
|
+
}
|
|
472
|
+
if (!active) {
|
|
473
|
+
if (bodyRows)
|
|
474
|
+
writeModalLine(frame, bodyStart, 'No matching sessions.', theme.statusText);
|
|
461
475
|
return;
|
|
476
|
+
}
|
|
477
|
+
const previewRows = bodyRows >= 3 ? Math.min(4, Math.floor(bodyRows / 2)) : 0;
|
|
478
|
+
const count = Math.min(matches.length, request.maxVisibleItems ?? 10, bodyRows - previewRows);
|
|
479
|
+
const start = pickerStartIndex(selectedIndex, count, matches.length);
|
|
480
|
+
matches.slice(start, start + count).forEach((session, offset) => {
|
|
481
|
+
const index = start + offset;
|
|
482
|
+
const selected = index === selectedIndex;
|
|
483
|
+
const marker = selected ? '›' : ' ';
|
|
484
|
+
const label = session.name || session.taskSummary || session.id.slice(0, 8);
|
|
485
|
+
const project = request.showProject ? ` ${session.projectPath}` : '';
|
|
486
|
+
const metadata = `${session.messageCount ?? 0} msgs ${(0, format_1.formatBytes)(session.historySizeBytes ?? 0)} ${session.model}${project}`;
|
|
487
|
+
const text = frame.width < 36
|
|
488
|
+
? `${marker} ${label}`
|
|
489
|
+
: `${marker} ${String(index + 1).padStart(2, ' ')} ${session.id.slice(0, 8)} ${label} ${metadata}`;
|
|
490
|
+
writeModalLine(frame, bodyStart + offset, text, selected ? theme.brand : theme.statusText);
|
|
491
|
+
});
|
|
492
|
+
if (!previewRows)
|
|
493
|
+
return;
|
|
494
|
+
const previewStart = bodyStart + count;
|
|
495
|
+
const heading = preview?.length
|
|
496
|
+
? 'Preview'
|
|
497
|
+
: preview === undefined
|
|
498
|
+
? 'Preview · loading…'
|
|
499
|
+
: 'Preview · no recent messages';
|
|
500
|
+
writeModalLine(frame, previewStart, heading, theme.brand);
|
|
501
|
+
if (preview?.length) {
|
|
502
|
+
preview.slice(Math.max(0, preview.length - previewRows + 1)).forEach((message, index) => {
|
|
503
|
+
const role = message.role === 'user' ? 'You' : 'Orion';
|
|
504
|
+
writeModalLine(frame, previewStart + index + 1, `${role} · ${message.text}`, theme.statusText);
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
else if (active.taskSummary && active.taskSummary !== active.name && previewRows >= 2) {
|
|
508
|
+
writeModalLine(frame, previewStart + 1, active.taskSummary, theme.statusText);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
function renderFollowupPreview(frame, state, top, rows, theme) {
|
|
512
|
+
const { items, limit } = state.followupQueue;
|
|
513
|
+
items.slice(0, rows).forEach((item, index) => {
|
|
514
|
+
const label = index === 0 ? `Next turn ${items.length}/${limit} · ` : ' 2. ';
|
|
515
|
+
writeModalLine(frame, top + index, label + item.text, theme.queueBadge ?? theme.statusText);
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
function renderFollowupQueue(frame, state, { editor, selectedIndex, notice }, theme) {
|
|
519
|
+
const { items, limit } = state.followupQueue;
|
|
520
|
+
if (editor) {
|
|
521
|
+
const headingRows = Number(frame.height >= 2);
|
|
522
|
+
const hintRows = Number(frame.height >= 3);
|
|
523
|
+
const { value, cursor } = editor.draft;
|
|
524
|
+
const prompt = layoutPrompt(value, cursor, frame.width);
|
|
525
|
+
const inputRows = Math.min(prompt.lines.length, MAX_PROMPT_ROWS, frame.height - headingRows - hintRows);
|
|
526
|
+
if (headingRows)
|
|
527
|
+
writeModalLine(frame, 0, 'Edit queued message', theme.brand);
|
|
528
|
+
renderPrompt(frame, state, prompt, headingRows, inputRows, theme);
|
|
529
|
+
if (hintRows) {
|
|
530
|
+
const current = items.find(item => item.id === editor.itemId);
|
|
531
|
+
const status = notice ??
|
|
532
|
+
(current?.revision !== editor.revision ? 'Message already sent or changed.' : undefined);
|
|
533
|
+
const hint = status ?? 'Enter save · Ctrl+J newline · Esc back';
|
|
534
|
+
writeModalLine(frame, headingRows + inputRows, hint, status ? theme.warning : theme.statusText);
|
|
535
|
+
}
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
const headingRows = Number(frame.height >= 2);
|
|
539
|
+
const hintRows = Number(frame.height >= 4);
|
|
540
|
+
const count = Math.min(8, items.length, frame.height - headingRows - hintRows);
|
|
541
|
+
const start = pickerStartIndex(selectedIndex, count, items.length);
|
|
542
|
+
if (headingRows)
|
|
543
|
+
writeModalLine(frame, 0, `Queue · Next turn (${items.length}/${limit})`, theme.brand);
|
|
544
|
+
items.slice(start, start + count).forEach((item, offset) => {
|
|
545
|
+
const index = start + offset;
|
|
546
|
+
const selected = index === selectedIndex;
|
|
547
|
+
const marker = selected ? '›' : ' ';
|
|
548
|
+
writeModalLine(frame, headingRows + offset, `${marker} ${index + 1}. ${item.text}`, selected ? theme.brand : theme.statusText);
|
|
549
|
+
});
|
|
550
|
+
if (!items.length && headingRows < frame.height) {
|
|
551
|
+
writeModalLine(frame, headingRows, 'No messages queued.', theme.statusText);
|
|
552
|
+
}
|
|
553
|
+
if (hintRows) {
|
|
554
|
+
const hint = notice || 'Enter edit · [ ] move · Del remove · Esc close';
|
|
555
|
+
writeModalLine(frame, frame.height - 1, hint, notice ? theme.warning : theme.statusText);
|
|
556
|
+
}
|
|
557
|
+
(0, frame_1.setFrameCursor)(frame, 0, 0, false);
|
|
558
|
+
}
|
|
559
|
+
function writeModalLine(frame, row, text, style) {
|
|
560
|
+
const line = (0, style_1.sanitizeTerminalText)(text)
|
|
561
|
+
.replace(/[\r\n\t]+/gu, ' ')
|
|
562
|
+
.trimEnd();
|
|
563
|
+
(0, frame_1.writeFrameText)(frame, row, 0, ellipsizeCells(line, frame.width), style);
|
|
564
|
+
}
|
|
565
|
+
function renderPermissionPicker(frame, overlay, theme) {
|
|
566
|
+
const picker = (0, ui_view_model_1.createPermissionDecisionPickerState)(overlay.request);
|
|
567
|
+
const headingRows = Number(frame.height > 1);
|
|
568
|
+
const hintRows = Number(frame.height >= picker.visibleItems.length + 2);
|
|
569
|
+
const visibleCount = Math.min(picker.visibleItems.length, frame.height - headingRows - hintRows);
|
|
570
|
+
const start = pickerStartIndex(overlay.selectedIndex, visibleCount, picker.visibleItems.length);
|
|
571
|
+
if (headingRows) {
|
|
572
|
+
const heading = `Tool Permission: ${singleLine(overlay.request.name)}`;
|
|
573
|
+
(0, frame_1.writeFrameText)(frame, 0, 0, ellipsizeCells(heading, frame.width), theme.modePermission);
|
|
574
|
+
}
|
|
575
|
+
picker.visibleItems.slice(start, start + visibleCount).forEach((item, index) => {
|
|
576
|
+
const selected = start + index === overlay.selectedIndex;
|
|
577
|
+
const marker = selected ? '›' : ' ';
|
|
578
|
+
const label = `${marker} ${item.label}${item.description ? ` — ${item.description}` : ''}`;
|
|
579
|
+
const row = headingRows + index;
|
|
580
|
+
const style = selected ? theme.pickerSelected : undefined;
|
|
581
|
+
if (selected)
|
|
582
|
+
(0, frame_1.writeFrameText)(frame, row, 0, ' '.repeat(frame.width), style);
|
|
583
|
+
(0, frame_1.writeFrameText)(frame, row, 0, ellipsizeCells(label, frame.width), style);
|
|
584
|
+
});
|
|
585
|
+
if (hintRows) {
|
|
586
|
+
(0, frame_1.writeFrameText)(frame, headingRows + visibleCount, 0, ellipsizeCells('Enter select · y allow once · Esc deny', frame.width), theme.statusText);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
function renderComposerPicker(frame, overlay, top, availableRows, theme) {
|
|
462
590
|
const rows = [];
|
|
463
591
|
if (overlay.type === 'files' && availableRows > 1) {
|
|
464
592
|
const query = singleLine(overlay.query);
|
|
@@ -487,10 +615,10 @@ function renderComposerPicker(frame, overlay, endRow, theme) {
|
|
|
487
615
|
});
|
|
488
616
|
}
|
|
489
617
|
rows.forEach(({ text, selected }, index) => {
|
|
490
|
-
const row =
|
|
618
|
+
const row = top + index;
|
|
491
619
|
const style = selected ? theme.pickerSelected : undefined;
|
|
492
|
-
|
|
493
|
-
|
|
620
|
+
if (selected)
|
|
621
|
+
(0, frame_1.writeFrameText)(frame, row, 0, ' '.repeat(frame.width), style);
|
|
494
622
|
(0, frame_1.writeFrameText)(frame, row, 0, ellipsizeCells(text, frame.width), style);
|
|
495
623
|
});
|
|
496
624
|
}
|
|
@@ -542,19 +670,4 @@ function ellipsizeCells(value, width) {
|
|
|
542
670
|
return '';
|
|
543
671
|
return (0, string_width_1.default)(value) <= width ? value : `${truncateCells(value, width - 1)}…`;
|
|
544
672
|
}
|
|
545
|
-
/** Map an absolute character cursor to {line, col} within a multi-line value. */
|
|
546
|
-
function lineColOfCursor(value, cursor) {
|
|
547
|
-
const lines = value.split('\n');
|
|
548
|
-
const safeCursor = Math.max(0, Math.min(cursor, value.length));
|
|
549
|
-
let offset = 0;
|
|
550
|
-
for (let i = 0; i < lines.length; i++) {
|
|
551
|
-
const lineLen = lines[i].length;
|
|
552
|
-
if (safeCursor <= offset + lineLen) {
|
|
553
|
-
return { line: i, col: safeCursor - offset };
|
|
554
|
-
}
|
|
555
|
-
offset += lineLen + 1; // +1 for the newline separator
|
|
556
|
-
}
|
|
557
|
-
const last = lines.length - 1;
|
|
558
|
-
return { line: last, col: lines[last].length };
|
|
559
|
-
}
|
|
560
673
|
//# sourceMappingURL=layout.js.map
|