@ywldan/kiro 0.2.5 → 0.2.7
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 +9 -5
- package/dist/ui/App.js +58 -12
- package/dist/ui/ModelPicker.js +20 -8
- package/dist/ui/StatusBar.js +20 -12
- package/dist/ui/model-picker.js +66 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -268,7 +268,7 @@ Exit codes: `0` success, `1` model/tool/session error, `2` usage error (includin
|
|
|
268
268
|
| Key | Action |
|
|
269
269
|
| --- | --- |
|
|
270
270
|
| `Enter` | Send the prompt, or run the highlighted `/` command |
|
|
271
|
-
| `Ctrl+C` |
|
|
271
|
+
| `Ctrl+C` | Press twice to exit; while a turn runs, the first press cancels it |
|
|
272
272
|
| `PgUp` / `PgDn` | Scroll the history (the wheel works too, unless you pass `--no-mouse`) |
|
|
273
273
|
| `Ctrl+O` | Expand or collapse the full output of the most recent tool call |
|
|
274
274
|
| `↑` / `↓` | Move through the `/` command menu; with an empty input, recall prompt history |
|
|
@@ -280,10 +280,12 @@ Exit codes: `0` success, `1` model/tool/session error, `2` usage error (includin
|
|
|
280
280
|
| `Ctrl+W` | Delete the previous word |
|
|
281
281
|
| Left / Right / Home / End | Move the cursor |
|
|
282
282
|
|
|
283
|
-
The status bar shows the active profile and model, the working directory, the context meter (`ctx 42k/128k`), the number of queued messages, and the current state (`ready`, `thinking…`, `replying…`, `running <tool>…`, `approval needed`, `cancelling
|
|
283
|
+
The status bar shows the active profile and model, the working directory, the context meter (`ctx 42k/128k`), the number of queued messages, and the current state (`ready`, `thinking…`, `replying…`, `running <tool>…`, `approval needed`, `cancelling…`, `Ctrl+C again to quit`) with a spinner and the elapsed seconds for the current turn (`replying… · 12s`). A long profile name is shortened in the middle, so the model and directory stay readable. On a wide terminal the context meter moves into the Usage card described below, leaving more room for the profile and path.
|
|
284
284
|
|
|
285
285
|
The input stays enabled while the agent works: type the next prompt and press Enter to queue it, and it runs as soon as the current turn ends. Queued prompts appear in the transcript right away, the status bar shows `N queued`, and Ctrl+C clears the queue together with the running turn. Slash commands typed while busy are queued the same way.
|
|
286
286
|
|
|
287
|
+
Pressing Ctrl+C while idle does not exit immediately: the status bar shows `Ctrl+C again to quit` for two seconds, and a second press within that window leaves. This makes an accidental Ctrl+C harmless. `/exit` still quits right away, and a running turn is cancelled by the first press.
|
|
288
|
+
|
|
287
289
|
Prompt history is stored per working directory in `~/.kiro/history/` (mode `0600`, up to 200 entries). With an empty input, `↑` recalls the most recent prompt, `↓` walks forward again, and editing the recalled text leaves history mode. Registered API-key values are redacted before a prompt is written. Set `KIRO_HISTORY_DIR` to store the files elsewhere.
|
|
288
290
|
|
|
289
291
|
Reasoning models stream their thinking traces live as a dim `thinking…` block. Once the visible answer starts, the trace collapses to a single `reasoning (done, not saved)` line: traces are display-only and are never written to sessions or `/export`. While the model is producing text the status bar switches from `thinking…` to `replying…`; tool execution shows `running <tool>…`.
|
|
@@ -296,7 +298,9 @@ Assistant replies are rendered as Markdown: headings, bold/italic, inline code,
|
|
|
296
298
|
|
|
297
299
|
Typing `/` opens a command palette. It is drawn over the bottom of the transcript instead of resizing it, so the conversation does not jump when the menu opens or closes. It filters as you type, `↑`/`↓` select a command, `Enter` runs it, and `Tab` completes it. `Esc` clears the input.
|
|
298
300
|
|
|
299
|
-
|
|
301
|
+
`/model` opens its picker as a centered overlay: the transcript, Usage card, and input row keep their places, and the input stays visible but disabled while the picker has focus. The list uses the frame's full height and reports hidden entries (`↑ 5 more · 6-15 of 30 · ↓ 15 more`) so long model lists are never silently cut off. On terminals narrower than 60 columns or shorter than 18 rows it falls back to the inline panel, which temporarily gives up transcript rows.
|
|
302
|
+
|
|
303
|
+
On a real TTY, `kiro` switches to the terminal's alternate screen: you get a clean page instead of the TUI drawing underneath the command you just ran. When Kiro exits — `/exit`, `Ctrl+C` twice, or an error — the terminal restores the previous shell contents and prompt. Redirected output (pipes, CI logs) is left untouched. Pass `--no-alt-screen` to stay on the normal screen instead.
|
|
300
304
|
|
|
301
305
|
Mouse reporting is **on by default**, so the wheel scrolls the transcript. The cost is that the terminal hands clicks to Kiro instead of starting a text selection: to copy text, hold Shift while dragging (or your terminal's equivalent), or run `/mouse` — or start with `--no-mouse` — to get plain click-drag selection back, scrolling with `PgUp`/`PgDn` instead. `/mouse` toggles it at any time.
|
|
302
306
|
|
|
@@ -307,7 +311,7 @@ Slash commands:
|
|
|
307
311
|
| Command | Action |
|
|
308
312
|
| --- | --- |
|
|
309
313
|
| `/help` | Show commands and keys |
|
|
310
|
-
| `/model` | Open the model picker: profile first, then searchable stored models |
|
|
314
|
+
| `/model` | Open the centered model picker: profile first, then searchable stored models |
|
|
311
315
|
| `/model <name>` | Switch profile without restarting |
|
|
312
316
|
| `/model add` | Guided setup; prompts appear in the input box and the key is masked |
|
|
313
317
|
| `/model edit [name]` | Edit fields, replace the key, re-test, and save |
|
|
@@ -434,7 +438,7 @@ pnpm mock # start the mock server on port 8787 for manual TUI testing
|
|
|
434
438
|
|
|
435
439
|
The mock server is scripted: it streams a text response with `write_file` and `list_dir` calls, then a `run_command` call, then a final answer, followed by multi-write and slow-streaming turns for approval and cancellation testing. It can also serve `GET /models` (with a configurable list or a forced `401`/`404`), return HTTP errors with custom headers such as `Retry-After`, drop the connection mid-stream, and records model-discovery and chat requests, including auth headers. Point a test profile at `http://localhost:8787/v1` and any model name; no key is needed.
|
|
436
440
|
|
|
437
|
-
The suite covers streaming, multiple tool calls per response, approvals and denials, malformed tool JSON, the round cap, HTTP errors, malformed SSE, unreachable endpoints, retries for 429/5xx and connection drops, no retry after partial output or a 401, the retry limit, read-only batching and ordered results, the global result cap, abort, workspace escapes, read paging, edit uniqueness, command exit codes and timeouts, output truncation, config validation, missing keys, system-prompt/`AGENTS.md` injection, and session persistence. Search tests cover glob matching, `.gitignore` handling, heavy-directory skips, result caps, ripgrep and the built-in grep fallback, binary/large-file skipping, and invalid regexes. Editing tests cover `replace_all`, near-miss hints, atomic multi-edits, and patch validation for updates, new files, conflicts, and rejected deletions. Context tests cover `stream_options` and usage parsing, token estimates and formatting, the 80% threshold, compaction boundaries, kept tool-call rounds, the old-result placeholder pass, empty-summary rejection, loop-level compaction (once per turn, non-fatal failures), persistence of compacted sessions, the `ctx` status-bar meter, and `contextWindow` config/wizard handling. Session tests cover atomic save/load, usage totals, file permissions, per-directory isolation, sorting, corrupt-file skipping, id validation, and reconstruction of resumed tool blocks and statuses. TUI unit tests cover Markdown styles, wrapping, and table alignment, slash-command filtering/shared help text, the Usage card and its width collapse, and SGR mouse-wheel parsing; pty runs exercise the command palette, mouse and PgUp/PgDn scrolling, Markdown rendering, approvals, cancellation, and the `/usage` toggle.
|
|
441
|
+
The suite covers streaming, multiple tool calls per response, approvals and denials, malformed tool JSON, the round cap, HTTP errors, malformed SSE, unreachable endpoints, retries for 429/5xx and connection drops, no retry after partial output or a 401, the retry limit, read-only batching and ordered results, the global result cap, abort, workspace escapes, read paging, edit uniqueness, command exit codes and timeouts, output truncation, config validation, missing keys, system-prompt/`AGENTS.md` injection, and session persistence. Search tests cover glob matching, `.gitignore` handling, heavy-directory skips, result caps, ripgrep and the built-in grep fallback, binary/large-file skipping, and invalid regexes. Editing tests cover `replace_all`, near-miss hints, atomic multi-edits, and patch validation for updates, new files, conflicts, and rejected deletions. Context tests cover `stream_options` and usage parsing, token estimates and formatting, the 80% threshold, compaction boundaries, kept tool-call rounds, the old-result placeholder pass, empty-summary rejection, loop-level compaction (once per turn, non-fatal failures), persistence of compacted sessions, the `ctx` status-bar meter, and `contextWindow` config/wizard handling. Session tests cover atomic save/load, usage totals, file permissions, per-directory isolation, sorting, corrupt-file skipping, id validation, and reconstruction of resumed tool blocks and statuses. TUI unit tests cover Markdown styles, wrapping, and table alignment, slash-command filtering/shared help text, the Usage card and its width collapse, the centered model-picker overlay with its frame and hidden-entry counts, and SGR mouse-wheel parsing; pty runs exercise the command palette, mouse and PgUp/PgDn scrolling, Markdown rendering, approvals, cancellation, and the `/usage` toggle.
|
|
438
442
|
|
|
439
443
|
Model workflow tests use a temp `$HOME` so the real `~/.kiro` is never touched. They cover atomic config saves that preserve unknown fields, profile-name and URL validation, corrupt-config backup/recovery, `.env` parsing and real-environment precedence, `0600` writes, masking, the exact preset list, discovery success/401/missing-`/models`/timeout, the connection test, and wizard add/edit/select/remove/last-profile refusal/cancel/manual-model fallback. Scripted `kiro model add`, `list`, `use`, `test`, and `remove` run through the real CLI against the in-process mock; a failed test saves nothing, keys never appear in `config.json`, and generated keys land in `.env`. The wizard screen renderer is unit-tested against a fake stream: alternate-screen enter/leave, a new menu replacing the previous one, the breadcrumb of answered prompts (menu title instead of `Choose`, the value kept by pressing Enter, confirmation of a `Y/n` default, and the reset on Escape or a return to the root menu), stale errors dropped at a step change, log trimming to the terminal height with the prompt always visible, keyboard scrolling of an over-long list (page, top, bottom, clamping, reset on new output), and replaying results after the screen is restored. `/model` groups profiles by endpoint so several models behind one base URL are listed as siblings.
|
|
440
444
|
|
package/dist/ui/App.js
CHANGED
|
@@ -21,7 +21,7 @@ import { Input } from './Input.js';
|
|
|
21
21
|
import { MessageList } from './MessageList.js';
|
|
22
22
|
import { MOUSE_OFF, MOUSE_ON } from './mouse.js';
|
|
23
23
|
import { ModelPicker } from './ModelPicker.js';
|
|
24
|
-
import { withProfileModel, withProfileModels } from './model-picker.js';
|
|
24
|
+
import { PICKER_INLINE_ROWS, pickerPopupRect, withProfileModel, withProfileModels, } from './model-picker.js';
|
|
25
25
|
import { formatProfileList } from './profile-list.js';
|
|
26
26
|
import { loadPromptHistory, recordPrompt } from './prompt-history.js';
|
|
27
27
|
import { StatusBar } from './StatusBar.js';
|
|
@@ -30,6 +30,8 @@ import { UsageCard, USAGE_CARD_GAP, USAGE_CARD_WIDTH, shouldShowUsageCard, } fro
|
|
|
30
30
|
import { addUsage, EMPTY_USAGE } from '../usage.js';
|
|
31
31
|
import { undoLastCheckpoint } from '../tools/checkpoint.js';
|
|
32
32
|
import { MAX_EXPANDED_TOOL_CHARS, MAX_REASONING_CHARS, } from './types.js';
|
|
33
|
+
/** Idle Ctrl+C must be pressed again within this window to exit. */
|
|
34
|
+
const QUIT_CONFIRM_MS = 2_000;
|
|
33
35
|
function useTerminalSize() {
|
|
34
36
|
const { stdout } = useStdout();
|
|
35
37
|
const read = useCallback(() => ({
|
|
@@ -80,6 +82,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
80
82
|
const [cancelling, setCancelling] = useState(false);
|
|
81
83
|
const [pendingApproval, setPendingApproval] = useState(null);
|
|
82
84
|
const [pickerOpen, setPickerOpen] = useState(false);
|
|
85
|
+
const [quitArmed, setQuitArmed] = useState(false);
|
|
83
86
|
const [palette, setPalette] = useState(null);
|
|
84
87
|
const [usageCardEnabled, setUsageCardEnabled] = useState(true);
|
|
85
88
|
const [mouseOn, setMouseOn] = useState(mouseEnabled);
|
|
@@ -118,6 +121,8 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
118
121
|
const busyRef = useRef(false);
|
|
119
122
|
const abortRef = useRef(null);
|
|
120
123
|
const cancelRequestedRef = useRef(false);
|
|
124
|
+
const quitArmedRef = useRef(false);
|
|
125
|
+
const quitTimerRef = useRef(null);
|
|
121
126
|
const [approvalPolicy] = useState(() => new ApprovalPolicy(yolo));
|
|
122
127
|
const [autoAllowed, setAutoAllowed] = useState([]);
|
|
123
128
|
const pendingApprovalRef = useRef(null);
|
|
@@ -357,6 +362,35 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
357
362
|
exit();
|
|
358
363
|
})();
|
|
359
364
|
}, [exit, persistSession]);
|
|
365
|
+
const disarmQuit = useCallback(() => {
|
|
366
|
+
if (quitTimerRef.current !== null) {
|
|
367
|
+
clearTimeout(quitTimerRef.current);
|
|
368
|
+
quitTimerRef.current = null;
|
|
369
|
+
}
|
|
370
|
+
quitArmedRef.current = false;
|
|
371
|
+
setQuitArmed(false);
|
|
372
|
+
}, []);
|
|
373
|
+
const armQuit = useCallback(() => {
|
|
374
|
+
if (quitTimerRef.current !== null)
|
|
375
|
+
clearTimeout(quitTimerRef.current);
|
|
376
|
+
quitArmedRef.current = true;
|
|
377
|
+
setQuitArmed(true);
|
|
378
|
+
quitTimerRef.current = setTimeout(() => {
|
|
379
|
+
quitTimerRef.current = null;
|
|
380
|
+
quitArmedRef.current = false;
|
|
381
|
+
setQuitArmed(false);
|
|
382
|
+
}, QUIT_CONFIRM_MS);
|
|
383
|
+
}, []);
|
|
384
|
+
useEffect(() => {
|
|
385
|
+
return () => {
|
|
386
|
+
if (quitTimerRef.current !== null)
|
|
387
|
+
clearTimeout(quitTimerRef.current);
|
|
388
|
+
};
|
|
389
|
+
}, []);
|
|
390
|
+
useEffect(() => {
|
|
391
|
+
if (busy)
|
|
392
|
+
disarmQuit();
|
|
393
|
+
}, [busy, disarmQuit]);
|
|
360
394
|
const flushText = useCallback(() => {
|
|
361
395
|
if (flushTimerRef.current) {
|
|
362
396
|
clearTimeout(flushTimerRef.current);
|
|
@@ -1202,14 +1236,17 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1202
1236
|
if (!(key.ctrl && input === 'c'))
|
|
1203
1237
|
return;
|
|
1204
1238
|
if (pickerOpen) {
|
|
1239
|
+
disarmQuit();
|
|
1205
1240
|
setPickerOpen(false);
|
|
1206
1241
|
return;
|
|
1207
1242
|
}
|
|
1208
1243
|
if (wizardActiveRef.current) {
|
|
1244
|
+
disarmQuit();
|
|
1209
1245
|
cancelWizard();
|
|
1210
1246
|
return;
|
|
1211
1247
|
}
|
|
1212
1248
|
if (pendingApprovalRef.current) {
|
|
1249
|
+
disarmQuit();
|
|
1213
1250
|
cancelRequestedRef.current = true;
|
|
1214
1251
|
setCancelling(true);
|
|
1215
1252
|
resolveApproval('deny');
|
|
@@ -1226,7 +1263,12 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1226
1263
|
abortRef.current?.abort();
|
|
1227
1264
|
return;
|
|
1228
1265
|
}
|
|
1229
|
-
|
|
1266
|
+
if (quitArmedRef.current) {
|
|
1267
|
+
disarmQuit();
|
|
1268
|
+
quit();
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1271
|
+
armQuit();
|
|
1230
1272
|
});
|
|
1231
1273
|
const activity = pendingApproval
|
|
1232
1274
|
? 'approval'
|
|
@@ -1241,17 +1283,21 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1241
1283
|
: null;
|
|
1242
1284
|
const activeProfile = runtimeConfig.profiles[profileName];
|
|
1243
1285
|
const contextWindow = contextWindowFor(activeProfile);
|
|
1244
|
-
const
|
|
1286
|
+
const pickerPopup = pickerOpen && !pendingApproval ? pickerPopupRect(columns, rows) : null;
|
|
1287
|
+
const pickerInline = pickerOpen && !pendingApproval && pickerPopup === null;
|
|
1288
|
+
const viewportHeight = Math.max(3, rows - 5 - (pendingApproval ? 12 : 0) - (pickerInline ? PICKER_INLINE_ROWS : 0));
|
|
1245
1289
|
const showUsageCard = usageCardEnabled && shouldShowUsageCard(columns, viewportHeight);
|
|
1246
1290
|
const chatWidth = showUsageCard ? Math.max(40, width - USAGE_CARD_WIDTH - USAGE_CARD_GAP) : width;
|
|
1247
|
-
return (_jsxs(Box, { flexDirection: "column", width: columns, paddingX: 1, children: [_jsxs(Box, { flexDirection: "row", alignItems: "flex-end", width: width, children: [_jsx(MessageList, { items: items, width: chatWidth, height: viewportHeight, resetSignal: resetSignal, expandedToolId: expandedToolId, palette: palette, interactive: !pendingApproval && !pickerOpen && !wizardActive && wizardPrompt === null }), showUsageCard ? (_jsx(Box, { marginLeft: USAGE_CARD_GAP, flexShrink: 0, children: _jsx(UsageCard, { usage: sessionUsage, contextTokens: contextTokens, contextWindow: contextWindow, contextEstimated: usageRef.current === null, lastReply: lastReply, busy: busy }) })) : null] }), pendingApproval ? (_jsx(ApprovalPrompt, { request: pendingApproval, width: width, onDecision: resolveApproval })) :
|
|
1248
|
-
?
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
:
|
|
1254
|
-
? '
|
|
1255
|
-
:
|
|
1291
|
+
return (_jsxs(Box, { flexDirection: "column", width: columns, paddingX: 1, children: [_jsxs(Box, { flexDirection: "row", alignItems: "flex-end", width: width, children: [_jsx(MessageList, { items: items, width: chatWidth, height: viewportHeight, resetSignal: resetSignal, expandedToolId: expandedToolId, palette: palette, interactive: !pendingApproval && !pickerOpen && !wizardActive && wizardPrompt === null }), showUsageCard ? (_jsx(Box, { marginLeft: USAGE_CARD_GAP, flexShrink: 0, children: _jsx(UsageCard, { usage: sessionUsage, contextTokens: contextTokens, contextWindow: contextWindow, contextEstimated: usageRef.current === null, lastReply: lastReply, busy: busy }) })) : null] }), pendingApproval ? (_jsx(ApprovalPrompt, { request: pendingApproval, width: width, onDecision: resolveApproval })) : pickerInline ? (_jsx(ModelPicker, { config: runtimeConfig, activeProfile: profileName, width: width, onSelect: (name, model) => void selectModel(name, model), onRefresh: refreshProfileModels, onCancel: () => setPickerOpen(false) })) : (_jsx(Input, { disabled: pickerOpen, width: width, mask: wizardPrompt?.mask, allowEmpty: wizardPrompt?.allowEmpty, history: wizardPrompt || wizardActive ? undefined : promptHistory, onPaletteChange: setPalette, placeholder: pickerOpen
|
|
1292
|
+
? 'Model picker open · Esc to close'
|
|
1293
|
+
: wizardPrompt
|
|
1294
|
+
? wizardPrompt.defaultValue && !wizardPrompt.mask
|
|
1295
|
+
? `${wizardPrompt.label} [${wizardPrompt.defaultValue}]`
|
|
1296
|
+
: wizardPrompt.label
|
|
1297
|
+
: busy
|
|
1298
|
+
? 'Kiro is working… type ahead, or Ctrl+C to cancel'
|
|
1299
|
+
: wizardActive
|
|
1300
|
+
? 'Working… Esc to cancel'
|
|
1301
|
+
: 'Ask Kiro to build or change something…', slashMenu: !wizardActive && !wizardPrompt, onSubmit: handleSubmit, onCancel: wizardActive ? cancelWizard : undefined }, wizardPrompt?.id ?? 0)), _jsx(StatusBar, { width: width, profile: profileName, model: activeProfile?.model ?? 'unknown', cwd: cwd, activity: activity, toolName: activeTool ?? undefined, busySince: busySince ?? undefined, queued: queuedCount > 0 ? queuedCount : undefined, yolo: yolo, autoAllowed: autoAllowed, quitHint: quitArmed, contextTokens: showUsageCard ? undefined : contextTokens, contextWindow: showUsageCard ? undefined : contextWindow }), pickerOpen && pickerPopup ? (_jsx(Box, { position: "absolute", marginTop: pickerPopup.top, marginLeft: pickerPopup.left, children: _jsx(ModelPicker, { config: runtimeConfig, activeProfile: profileName, width: pickerPopup.width, height: pickerPopup.height, onSelect: (name, model) => void selectModel(name, model), onRefresh: refreshProfileModels, onCancel: () => setPickerOpen(false) }) })) : null] }));
|
|
1256
1302
|
}
|
|
1257
1303
|
//# sourceMappingURL=App.js.map
|
package/dist/ui/ModelPicker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { Box, Text, useInput } from 'ink';
|
|
4
|
-
import { filterModelIds, modelIds, pickerWindow, profileRows, selectableLines, selectableNames, } from './model-picker.js';
|
|
4
|
+
import { filterModelIds, modelIds, pickerPopupRows, pickerRange, pickerRangeLabel, pickerWindow, profileRange, profileRows, selectableLines, selectableNames, } from './model-picker.js';
|
|
5
5
|
/** Keys are highlighted so the hint reads at a glance; the rest stays dim. */
|
|
6
6
|
const KEY_COLOR = '#ff9e64';
|
|
7
7
|
function Key({ children }) {
|
|
@@ -14,7 +14,7 @@ function Said({ children }) {
|
|
|
14
14
|
* Two-step picker: profiles (grouped by endpoint) first, then the models stored
|
|
15
15
|
* for that profile. It only reads config; the owner persists the choice.
|
|
16
16
|
*/
|
|
17
|
-
export function ModelPicker({ config, activeProfile, width, maxRows = 8, onSelect, onRefresh, onCancel, }) {
|
|
17
|
+
export function ModelPicker({ config, activeProfile, width, maxRows = 8, height, onSelect, onRefresh, onCancel, }) {
|
|
18
18
|
const [step, setStep] = useState({ kind: 'profile' });
|
|
19
19
|
const [index, setIndex] = useState(0);
|
|
20
20
|
const [refreshing, setRefreshing] = useState(false);
|
|
@@ -30,7 +30,19 @@ export function ModelPicker({ config, activeProfile, width, maxRows = 8, onSelec
|
|
|
30
30
|
const selected = Math.min(index, Math.max(0, count - 1));
|
|
31
31
|
const selectedLine = step.kind === 'profile' ? (lines[selected] ?? 0) : selected;
|
|
32
32
|
const total = step.kind === 'profile' ? rows.length : models.length;
|
|
33
|
-
const
|
|
33
|
+
const popup = height !== undefined;
|
|
34
|
+
const hintRows = (step.kind === 'model' && models.length === 0 ? 1 : 0) +
|
|
35
|
+
(step.kind === 'model' && profile !== undefined && !profile.models?.length ? 1 : 0) +
|
|
36
|
+
(error ? 1 : 0);
|
|
37
|
+
const listRows = popup ? pickerPopupRows(height, hintRows) : maxRows;
|
|
38
|
+
const { start, end } = pickerWindow(selectedLine, total, listRows);
|
|
39
|
+
const range = popup
|
|
40
|
+
? step.kind === 'model'
|
|
41
|
+
? pickerRange(start, end, total)
|
|
42
|
+
: profileRange(rows, start, end)
|
|
43
|
+
: null;
|
|
44
|
+
// The opaque frame needs an explicit foreground even on light terminal themes.
|
|
45
|
+
const base = popup ? 'white' : undefined;
|
|
34
46
|
const refresh = async (name) => {
|
|
35
47
|
setRefreshing(true);
|
|
36
48
|
setError(null);
|
|
@@ -111,19 +123,19 @@ export function ModelPicker({ config, activeProfile, width, maxRows = 8, onSelec
|
|
|
111
123
|
: query.trim()
|
|
112
124
|
? `Models · ${step.profile} (${models.length}/${allModels.length} match)`
|
|
113
125
|
: `Models · ${step.profile} (${models.length})`;
|
|
114
|
-
return (_jsxs(Box, { flexDirection: "column", width: width, borderStyle: "round", borderColor: "cyan", paddingX: 1, flexShrink: 0, children: [_jsx(Text, { bold: true, color: "cyan", wrap: "truncate-end", children: title }), step.kind === 'model' ? (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Said, { children: "Search: " }), query || _jsx(Said, { children: "type to filter" })] })) : null, step.kind === 'profile'
|
|
126
|
+
return (_jsxs(Box, { flexDirection: "column", width: width, height: height, borderStyle: "round", borderColor: "cyan", paddingX: 1, flexShrink: 0, backgroundColor: popup ? 'black' : undefined, overflow: height === undefined ? undefined : 'hidden', children: [_jsx(Text, { bold: true, color: "cyan", wrap: "truncate-end", children: title }), step.kind === 'model' ? (_jsxs(Text, { color: base, wrap: "truncate-end", children: [_jsx(Said, { children: "Search: " }), query || _jsx(Said, { children: "type to filter" })] })) : null, step.kind === 'profile'
|
|
115
127
|
? rows.slice(start, end).map((row, offset) => {
|
|
116
128
|
const line = start + offset;
|
|
117
129
|
if (row.kind === 'header') {
|
|
118
|
-
return (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: row.text }, `h${line}`));
|
|
130
|
+
return (_jsx(Text, { dimColor: true, color: base, wrap: "truncate-end", children: row.text }, `h${line}`));
|
|
119
131
|
}
|
|
120
132
|
const focused = line === selectedLine;
|
|
121
|
-
return (_jsx(Text, { color: focused ? 'cyan' :
|
|
133
|
+
return (_jsx(Text, { color: focused ? 'cyan' : base, bold: focused, wrap: "truncate-end", children: ` ${row.active ? '*' : ' '} ${row.name} ${row.model}` }, `p${line}`));
|
|
122
134
|
})
|
|
123
135
|
: models.slice(start, end).map((id, offset) => {
|
|
124
136
|
const line = start + offset;
|
|
125
137
|
const focused = line === selectedLine;
|
|
126
|
-
return (_jsx(Text, { color: focused ? 'cyan' :
|
|
127
|
-
}), step.kind === 'model' && models.length === 0 ? (_jsxs(Text, { dimColor: true, wrap: "truncate-end", children: ["No models match \"", query, "\". Backspace to edit, Esc to clear."] })) : null, step.kind === 'model' && profile && !profile.models?.length ? (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Said, { children: "Only the active model is stored; press " }), _jsx(Key, { children: "Ctrl+R" }), _jsx(Said, { children: " to fetch this endpoint." })] })) : null, error ? (_jsx(Text, { color: "red", wrap: "truncate-end", children: error })) : null, step.kind === 'profile' ? (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Key, { children: "\u2191/\u2193" }), _jsx(Said, { children: " move \u00B7 " }), _jsx(Key, { children: "Enter" }), _jsx(Said, { children: " choose profile \u00B7 " }), _jsx(Key, { children: "Esc" }), _jsx(Said, { children: " close" })] })) : refreshing ? (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: "Fetching models\u2026" })) : (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Key, { children: "\u2191/\u2193" }), _jsx(Said, { children: " move \u00B7 " }), _jsx(Key, { children: "Enter" }), _jsx(Said, { children: " use \u00B7 type to filter \u00B7 " }), _jsx(Key, { children: "Ctrl+R" }), _jsx(Said, { children: " refetch \u00B7 " }), _jsx(Key, { children: "Esc" }), _jsx(Said, { children: query ? ' clear search' : ' back' })] }))] }));
|
|
138
|
+
return (_jsx(Text, { color: focused ? 'cyan' : base, bold: focused, wrap: "truncate-end", children: ` ${id === profile?.model ? '*' : ' '} ${id}` }, `m${line}`));
|
|
139
|
+
}), step.kind === 'model' && models.length === 0 ? (_jsxs(Text, { dimColor: true, color: base, wrap: "truncate-end", children: ["No models match \"", query, "\". Backspace to edit, Esc to clear."] })) : null, step.kind === 'model' && profile && !profile.models?.length ? (_jsxs(Text, { color: base, wrap: "truncate-end", children: [_jsx(Said, { children: "Only the active model is stored; press " }), _jsx(Key, { children: "Ctrl+R" }), _jsx(Said, { children: " to fetch this endpoint." })] })) : null, error ? (_jsx(Text, { color: "red", wrap: "truncate-end", children: error })) : null, range ? (_jsx(Text, { dimColor: true, color: base, wrap: "truncate-end", children: pickerRangeLabel(range) })) : null, height === undefined ? null : _jsx(Box, { flexGrow: 1 }), step.kind === 'profile' ? (_jsxs(Text, { color: base, wrap: "truncate-end", children: [_jsx(Key, { children: "\u2191/\u2193" }), _jsx(Said, { children: " move \u00B7 " }), _jsx(Key, { children: "Enter" }), _jsx(Said, { children: " choose profile \u00B7 " }), _jsx(Key, { children: "Esc" }), _jsx(Said, { children: " close" })] })) : refreshing ? (_jsx(Text, { dimColor: true, color: base, wrap: "truncate-end", children: "Fetching models\u2026" })) : (_jsxs(Text, { color: base, wrap: "truncate-end", children: [_jsx(Key, { children: "\u2191/\u2193" }), _jsx(Said, { children: " move \u00B7 " }), _jsx(Key, { children: "Enter" }), _jsx(Said, { children: " use \u00B7 type to filter \u00B7 " }), _jsx(Key, { children: "Ctrl+R" }), _jsx(Said, { children: " refetch \u00B7 " }), _jsx(Key, { children: "Esc" }), _jsx(Said, { children: query ? ' clear search' : ' back' })] }))] }));
|
|
128
140
|
}
|
|
129
141
|
//# sourceMappingURL=ModelPicker.js.map
|
package/dist/ui/StatusBar.js
CHANGED
|
@@ -14,7 +14,7 @@ function prettyCwd(cwd) {
|
|
|
14
14
|
}
|
|
15
15
|
return cwd;
|
|
16
16
|
}
|
|
17
|
-
export function StatusBar({ width, profile, model, cwd, activity, toolName, busySince, queued, yolo = false, autoAllowed = [], contextTokens, contextWindow, }) {
|
|
17
|
+
export function StatusBar({ width, profile, model, cwd, activity, toolName, busySince, queued, yolo = false, autoAllowed = [], quitHint = false, contextTokens, contextWindow, }) {
|
|
18
18
|
const busy = activity !== null;
|
|
19
19
|
const [frame, setFrame] = useState(0);
|
|
20
20
|
useEffect(() => {
|
|
@@ -23,18 +23,26 @@ export function StatusBar({ width, profile, model, cwd, activity, toolName, busy
|
|
|
23
23
|
const interval = setInterval(() => setFrame((current) => (current + 1) % SPINNER.length), 100);
|
|
24
24
|
return () => clearInterval(interval);
|
|
25
25
|
}, [busy]);
|
|
26
|
-
const stateText =
|
|
27
|
-
? '
|
|
26
|
+
const stateText = quitHint
|
|
27
|
+
? 'Ctrl+C again to quit'
|
|
28
|
+
: activity === 'approval'
|
|
29
|
+
? 'approval needed'
|
|
30
|
+
: activity === 'cancelling'
|
|
31
|
+
? 'cancelling…'
|
|
32
|
+
: activity === 'running'
|
|
33
|
+
? `running ${toolName ?? 'tool'}…`
|
|
34
|
+
: activity === 'replying'
|
|
35
|
+
? 'replying…'
|
|
36
|
+
: activity === 'thinking'
|
|
37
|
+
? 'thinking…'
|
|
38
|
+
: 'ready';
|
|
39
|
+
const stateColor = quitHint
|
|
40
|
+
? 'red'
|
|
28
41
|
: activity === 'cancelling'
|
|
29
|
-
? '
|
|
30
|
-
: activity ===
|
|
31
|
-
?
|
|
32
|
-
:
|
|
33
|
-
? 'replying…'
|
|
34
|
-
: activity === 'thinking'
|
|
35
|
-
? 'thinking…'
|
|
36
|
-
: 'ready';
|
|
37
|
-
const stateColor = activity === 'cancelling' ? 'red' : activity === null ? 'green' : 'yellow';
|
|
42
|
+
? 'red'
|
|
43
|
+
: activity === null
|
|
44
|
+
? 'green'
|
|
45
|
+
: 'yellow';
|
|
38
46
|
const spinner = busy ? `${SPINNER[frame] ?? '⠋'} ` : '';
|
|
39
47
|
const elapsedMs = busy && busySince !== undefined ? Math.max(0, Date.now() - busySince) : 0;
|
|
40
48
|
// Whole seconds keep the re-rendering spinner from making the timer flicker.
|
package/dist/ui/model-picker.js
CHANGED
|
@@ -36,6 +36,72 @@ export function filterModelIds(ids, query) {
|
|
|
36
36
|
return terms.every((term) => haystack.includes(term));
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
+
export const PICKER_POPUP_MIN_COLUMNS = 60;
|
|
40
|
+
export const PICKER_POPUP_MIN_ROWS = 18;
|
|
41
|
+
export const PICKER_POPUP_MAX_WIDTH = 76;
|
|
42
|
+
export const PICKER_POPUP_MAX_HEIGHT = 16;
|
|
43
|
+
/** Rows the inline picker reserves below the transcript. */
|
|
44
|
+
export const PICKER_INLINE_ROWS = 13;
|
|
45
|
+
/**
|
|
46
|
+
* Centers a fixed picker frame over the app's content area, keeping the input
|
|
47
|
+
* and status rows clear. Returns null when the terminal is too small to overlay.
|
|
48
|
+
*/
|
|
49
|
+
export function pickerPopupRect(columns, rows) {
|
|
50
|
+
if (columns < PICKER_POPUP_MIN_COLUMNS || rows < PICKER_POPUP_MIN_ROWS)
|
|
51
|
+
return null;
|
|
52
|
+
const width = Math.min(PICKER_POPUP_MAX_WIDTH, columns - 8);
|
|
53
|
+
const height = Math.min(PICKER_POPUP_MAX_HEIGHT, rows - 6);
|
|
54
|
+
// The transcript takes rows - 5, then the input and status rows.
|
|
55
|
+
const contentRows = rows - 3;
|
|
56
|
+
return {
|
|
57
|
+
top: Math.max(0, Math.floor((contentRows - height) / 2)),
|
|
58
|
+
// The app root adds one column of horizontal padding.
|
|
59
|
+
left: Math.max(0, Math.floor((columns - width) / 2) - 1),
|
|
60
|
+
width,
|
|
61
|
+
height,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** Room for the list once the frame chrome and any hint/error rows are drawn. */
|
|
65
|
+
export function pickerPopupRows(height, extraRows = 0) {
|
|
66
|
+
return Math.max(2, height - 6 - Math.max(0, extraRows));
|
|
67
|
+
}
|
|
68
|
+
/** Visible selectable window plus how many entries are hidden on each side. */
|
|
69
|
+
export function pickerRange(start, end, total) {
|
|
70
|
+
const from = Math.max(0, Math.min(start, total));
|
|
71
|
+
const to = Math.max(from, Math.min(end, total));
|
|
72
|
+
return {
|
|
73
|
+
above: from,
|
|
74
|
+
below: total - to,
|
|
75
|
+
first: total === 0 ? 0 : from + 1,
|
|
76
|
+
last: to,
|
|
77
|
+
total,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** Same range, counting profiles while skipping endpoint headers. */
|
|
81
|
+
export function profileRange(rows, start, end) {
|
|
82
|
+
const lines = selectableLines(rows);
|
|
83
|
+
const above = lines.filter((line) => line < start).length;
|
|
84
|
+
const visible = lines.filter((line) => line >= start && line < end).length;
|
|
85
|
+
return {
|
|
86
|
+
above,
|
|
87
|
+
below: lines.length - above - visible,
|
|
88
|
+
first: visible === 0 ? 0 : above + 1,
|
|
89
|
+
last: above + visible,
|
|
90
|
+
total: lines.length,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export function pickerRangeLabel(range) {
|
|
94
|
+
const window = range.first === 0 || range.total === 0
|
|
95
|
+
? `0 of ${range.total}`
|
|
96
|
+
: `${range.first}-${range.last} of ${range.total}`;
|
|
97
|
+
const parts = [];
|
|
98
|
+
if (range.above > 0)
|
|
99
|
+
parts.push(`↑ ${range.above} more`);
|
|
100
|
+
parts.push(window);
|
|
101
|
+
if (range.below > 0)
|
|
102
|
+
parts.push(`↓ ${range.below} more`);
|
|
103
|
+
return parts.join(' · ');
|
|
104
|
+
}
|
|
39
105
|
/** Keeps the highlighted line inside a window of `maxRows` entries. */
|
|
40
106
|
export function pickerWindow(index, count, maxRows) {
|
|
41
107
|
if (count <= 0)
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.2.
|
|
1
|
+
export const VERSION = '0.2.7';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|