@ywldan/kiro 0.2.5 → 0.2.6
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 +4 -2
- package/dist/ui/App.js +15 -11
- package/dist/ui/ModelPicker.js +20 -8
- package/dist/ui/model-picker.js +66 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -296,6 +296,8 @@ Assistant replies are rendered as Markdown: headings, bold/italic, inline code,
|
|
|
296
296
|
|
|
297
297
|
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
298
|
|
|
299
|
+
`/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.
|
|
300
|
+
|
|
299
301
|
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`, 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
302
|
|
|
301
303
|
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.
|
|
@@ -307,7 +309,7 @@ Slash commands:
|
|
|
307
309
|
| Command | Action |
|
|
308
310
|
| --- | --- |
|
|
309
311
|
| `/help` | Show commands and keys |
|
|
310
|
-
| `/model` | Open the model picker: profile first, then searchable stored models |
|
|
312
|
+
| `/model` | Open the centered model picker: profile first, then searchable stored models |
|
|
311
313
|
| `/model <name>` | Switch profile without restarting |
|
|
312
314
|
| `/model add` | Guided setup; prompts appear in the input box and the key is masked |
|
|
313
315
|
| `/model edit [name]` | Edit fields, replace the key, re-test, and save |
|
|
@@ -434,7 +436,7 @@ pnpm mock # start the mock server on port 8787 for manual TUI testing
|
|
|
434
436
|
|
|
435
437
|
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
438
|
|
|
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.
|
|
439
|
+
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
440
|
|
|
439
441
|
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
442
|
|
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';
|
|
@@ -1241,17 +1241,21 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1241
1241
|
: null;
|
|
1242
1242
|
const activeProfile = runtimeConfig.profiles[profileName];
|
|
1243
1243
|
const contextWindow = contextWindowFor(activeProfile);
|
|
1244
|
-
const
|
|
1244
|
+
const pickerPopup = pickerOpen && !pendingApproval ? pickerPopupRect(columns, rows) : null;
|
|
1245
|
+
const pickerInline = pickerOpen && !pendingApproval && pickerPopup === null;
|
|
1246
|
+
const viewportHeight = Math.max(3, rows - 5 - (pendingApproval ? 12 : 0) - (pickerInline ? PICKER_INLINE_ROWS : 0));
|
|
1245
1247
|
const showUsageCard = usageCardEnabled && shouldShowUsageCard(columns, viewportHeight);
|
|
1246
1248
|
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
|
-
:
|
|
1249
|
+
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
|
|
1250
|
+
? 'Model picker open · Esc to close'
|
|
1251
|
+
: wizardPrompt
|
|
1252
|
+
? wizardPrompt.defaultValue && !wizardPrompt.mask
|
|
1253
|
+
? `${wizardPrompt.label} [${wizardPrompt.defaultValue}]`
|
|
1254
|
+
: wizardPrompt.label
|
|
1255
|
+
: busy
|
|
1256
|
+
? 'Kiro is working… type ahead, or Ctrl+C to cancel'
|
|
1257
|
+
: wizardActive
|
|
1258
|
+
? 'Working… Esc to cancel'
|
|
1259
|
+
: '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, 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
1260
|
}
|
|
1257
1261
|
//# 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/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.6';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|