opencode-account-manager 0.6.4 → 0.6.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 +235 -216
- package/README_VI.md +235 -216
- package/dist/cli.js +83 -0
- package/dist/cli.js.map +1 -1
- package/dist/core/config-store.d.ts +12 -0
- package/dist/core/config-store.d.ts.map +1 -1
- package/dist/core/config-store.js +98 -0
- package/dist/core/config-store.js.map +1 -1
- package/dist/core/health-log.d.ts +9 -0
- package/dist/core/health-log.d.ts.map +1 -0
- package/dist/core/health-log.js +154 -0
- package/dist/core/health-log.js.map +1 -0
- package/dist/core/health-oauth.d.ts +5 -0
- package/dist/core/health-oauth.d.ts.map +1 -0
- package/dist/core/health-oauth.js +147 -0
- package/dist/core/health-oauth.js.map +1 -0
- package/dist/core/health-orchestrator.d.ts +32 -0
- package/dist/core/health-orchestrator.d.ts.map +1 -0
- package/dist/core/health-orchestrator.js +148 -0
- package/dist/core/health-orchestrator.js.map +1 -0
- package/dist/core/health-utils.d.ts +15 -0
- package/dist/core/health-utils.d.ts.map +1 -0
- package/dist/core/health-utils.js +60 -0
- package/dist/core/health-utils.js.map +1 -0
- package/dist/core/paths.d.ts +1 -0
- package/dist/core/paths.d.ts.map +1 -1
- package/dist/core/paths.js +4 -0
- package/dist/core/paths.js.map +1 -1
- package/dist/core/types.d.ts +26 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/tui/Dashboard.d.ts.map +1 -1
- package/dist/tui/Dashboard.js +69 -2
- package/dist/tui/Dashboard.js.map +1 -1
- package/dist/tui/components/AccountList.d.ts +5 -3
- package/dist/tui/components/AccountList.d.ts.map +1 -1
- package/dist/tui/components/AccountList.js +9 -3
- package/dist/tui/components/AccountList.js.map +1 -1
- package/dist/tui/components/DashboardView.d.ts +3 -2
- package/dist/tui/components/DashboardView.d.ts.map +1 -1
- package/dist/tui/components/DashboardView.js +102 -17
- package/dist/tui/components/DashboardView.js.map +1 -1
- package/dist/tui/components/HealthBadge.d.ts +9 -0
- package/dist/tui/components/HealthBadge.d.ts.map +1 -0
- package/dist/tui/components/HealthBadge.js +56 -0
- package/dist/tui/components/HealthBadge.js.map +1 -0
- package/dist/tui/components/StatusBadge.d.ts +2 -1
- package/dist/tui/components/StatusBadge.d.ts.map +1 -1
- package/dist/tui/components/StatusBadge.js +30 -2
- package/dist/tui/components/StatusBadge.js.map +1 -1
- package/dist/tui/components/index.d.ts +1 -0
- package/dist/tui/components/index.d.ts.map +1 -1
- package/dist/tui/components/index.js +3 -1
- package/dist/tui/components/index.js.map +1 -1
- package/docs/BLUEPRINT.md +476 -476
- package/docs/ROADMAP.md +125 -107
- package/package.json +38 -38
- package/src/cli.ts +139 -38
- package/src/core/config-store.ts +278 -171
- package/src/core/crypto.ts +162 -162
- package/src/core/health-log.ts +173 -0
- package/src/core/health-oauth.ts +190 -0
- package/src/core/health-orchestrator.ts +224 -0
- package/src/core/importers/amExport.ts +177 -177
- package/src/core/opencode-config.ts +217 -217
- package/src/core/paths.ts +10 -6
- package/src/core/types.ts +193 -147
- package/src/tui/Dashboard.tsx +557 -478
- package/src/tui/components/AccountList.tsx +122 -104
- package/src/tui/components/ActionPalette.tsx +117 -117
- package/src/tui/components/Box.tsx +7 -7
- package/src/tui/components/DashboardView.tsx +324 -220
- package/src/tui/components/ExportModal.tsx +255 -255
- package/src/tui/components/FileBrowser.tsx +393 -393
- package/src/tui/components/Header.tsx +26 -26
- package/src/tui/components/HealthBadge.tsx +64 -0
- package/src/tui/components/ImportModal.tsx +334 -334
- package/src/tui/components/McpServerList.tsx +67 -67
- package/src/tui/components/Menu.tsx +61 -61
- package/src/tui/components/PasswordInput.tsx +159 -159
- package/src/tui/components/ProviderList.tsx +59 -59
- package/src/tui/components/SectionBox.tsx +35 -35
- package/src/tui/components/StatsRow.tsx +33 -33
- package/src/tui/components/StatusBadge.tsx +36 -3
- package/src/tui/components/index.ts +15 -14
- package/test-minimal.js +26 -26
- package/test-with-accounts.js +58 -58
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
|
-
import { StatusBadge } from "./StatusBadge";
|
|
4
|
-
import {
|
|
3
|
+
import { StatusBadge } from "./StatusBadge";
|
|
4
|
+
import { HealthBadge } from "./HealthBadge";
|
|
5
|
+
import { Account, AccountHealthResult } from "../../core/types";
|
|
6
|
+
import { normalizeHealthKey } from "../../core/config-store";
|
|
5
7
|
|
|
6
|
-
interface AccountRowProps {
|
|
7
|
-
account: Account;
|
|
8
|
-
isSelected?: boolean;
|
|
9
|
-
isChecked?: boolean;
|
|
10
|
-
showCheckbox?: boolean;
|
|
11
|
-
|
|
8
|
+
interface AccountRowProps {
|
|
9
|
+
account: Account;
|
|
10
|
+
isSelected?: boolean;
|
|
11
|
+
isChecked?: boolean;
|
|
12
|
+
showCheckbox?: boolean;
|
|
13
|
+
healthResult?: AccountHealthResult;
|
|
14
|
+
}
|
|
12
15
|
|
|
13
16
|
function formatDuration(ms: number): string {
|
|
14
17
|
if (ms <= 0) return "-";
|
|
@@ -20,98 +23,109 @@ function formatDuration(ms: number): string {
|
|
|
20
23
|
return `${minutes}m`;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
function getAccountStatus(account: Account): {
|
|
24
|
-
status: "available" | "limited" | "disabled";
|
|
25
|
-
resetIn: string;
|
|
26
|
-
limitDetails: string[];
|
|
27
|
-
} {
|
|
28
|
-
if (account.enabled === false) {
|
|
29
|
-
return { status: "disabled", resetIn: "-", limitDetails: [] };
|
|
30
|
-
}
|
|
31
|
-
const resets = account.rateLimitResetTimes || {};
|
|
32
|
-
const now = Date.now();
|
|
33
|
-
const limitDetails: string[] = [];
|
|
34
|
-
|
|
35
|
-
// Build detailed limit info for each model
|
|
36
|
-
for (const [model, resetTime] of Object.entries(resets)) {
|
|
37
|
-
if (resetTime > now) {
|
|
38
|
-
limitDetails.push(`${model}: ${formatDuration(resetTime - now)}`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (limitDetails.length === 0) {
|
|
43
|
-
return { status: "available", resetIn: "-", limitDetails: [] };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const nextReset = Math.min(...Object.values(resets).filter((v) => v > now));
|
|
47
|
-
return {
|
|
48
|
-
status: "limited",
|
|
49
|
-
resetIn: formatDuration(nextReset - now),
|
|
50
|
-
limitDetails,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
26
|
+
function getAccountStatus(account: Account): {
|
|
27
|
+
status: "available" | "limited" | "disabled";
|
|
28
|
+
resetIn: string;
|
|
29
|
+
limitDetails: string[];
|
|
30
|
+
} {
|
|
31
|
+
if (account.enabled === false) {
|
|
32
|
+
return { status: "disabled", resetIn: "-", limitDetails: [] };
|
|
33
|
+
}
|
|
34
|
+
const resets = account.rateLimitResetTimes || {};
|
|
35
|
+
const now = Date.now();
|
|
36
|
+
const limitDetails: string[] = [];
|
|
37
|
+
|
|
38
|
+
// Build detailed limit info for each model
|
|
39
|
+
for (const [model, resetTime] of Object.entries(resets)) {
|
|
40
|
+
if (resetTime > now) {
|
|
41
|
+
limitDetails.push(`${model}: ${formatDuration(resetTime - now)}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (limitDetails.length === 0) {
|
|
46
|
+
return { status: "available", resetIn: "-", limitDetails: [] };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const nextReset = Math.min(...Object.values(resets).filter((v) => v > now));
|
|
50
|
+
return {
|
|
51
|
+
status: "limited",
|
|
52
|
+
resetIn: formatDuration(nextReset - now),
|
|
53
|
+
limitDetails,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
53
56
|
|
|
54
|
-
export function AccountRow({
|
|
57
|
+
export function AccountRow({
|
|
58
|
+
account,
|
|
59
|
+
isSelected,
|
|
60
|
+
isChecked,
|
|
61
|
+
showCheckbox,
|
|
62
|
+
healthResult,
|
|
63
|
+
}: AccountRowProps) {
|
|
55
64
|
const { status, resetIn, limitDetails } = getAccountStatus(account);
|
|
56
65
|
const project = account.projectId || account.managedProjectId || "-";
|
|
57
|
-
|
|
58
|
-
const checkbox = showCheckbox
|
|
59
|
-
? (isChecked ? "[x]" : "[ ]")
|
|
60
|
-
: "";
|
|
61
|
-
|
|
62
|
-
const cursor = isSelected ? ">" : " ";
|
|
63
|
-
const emailColor = status === "disabled" ? "gray" : "white";
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<Box flexDirection="column">
|
|
67
|
-
<Box flexDirection="row" paddingX={1}>
|
|
68
|
-
<Box width={2}>
|
|
69
|
-
<Text color={isSelected ? "white" : "gray"}>{cursor}</Text>
|
|
70
|
-
</Box>
|
|
71
|
-
{showCheckbox && (
|
|
72
|
-
<Box width={4}>
|
|
73
|
-
<Text color={isChecked ? "white" : "gray"}>{checkbox}</Text>
|
|
74
|
-
</Box>
|
|
75
|
-
)}
|
|
76
|
-
<Box width={28}>
|
|
77
|
-
<Text color={emailColor} strikethrough={status === "disabled"}>
|
|
78
|
-
{account.email}
|
|
79
|
-
</Text>
|
|
80
|
-
</Box>
|
|
81
|
-
<Box width={18}>
|
|
82
|
-
<Text dimColor>{project.slice(0, 16)}</Text>
|
|
83
|
-
</Box>
|
|
66
|
+
|
|
67
|
+
const checkbox = showCheckbox
|
|
68
|
+
? (isChecked ? "[x]" : "[ ]")
|
|
69
|
+
: "";
|
|
70
|
+
|
|
71
|
+
const cursor = isSelected ? ">" : " ";
|
|
72
|
+
const emailColor = status === "disabled" ? "gray" : "white";
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<Box flexDirection="column">
|
|
76
|
+
<Box flexDirection="row" paddingX={1}>
|
|
77
|
+
<Box width={2}>
|
|
78
|
+
<Text color={isSelected ? "white" : "gray"}>{cursor}</Text>
|
|
79
|
+
</Box>
|
|
80
|
+
{showCheckbox && (
|
|
81
|
+
<Box width={4}>
|
|
82
|
+
<Text color={isChecked ? "white" : "gray"}>{checkbox}</Text>
|
|
83
|
+
</Box>
|
|
84
|
+
)}
|
|
85
|
+
<Box width={28}>
|
|
86
|
+
<Text color={emailColor} strikethrough={status === "disabled"}>
|
|
87
|
+
{account.email}
|
|
88
|
+
</Text>
|
|
89
|
+
</Box>
|
|
90
|
+
<Box width={18}>
|
|
91
|
+
<Text dimColor>{project.slice(0, 16)}</Text>
|
|
92
|
+
</Box>
|
|
84
93
|
<Box width={12}>
|
|
85
94
|
<StatusBadge status={status} />
|
|
86
95
|
</Box>
|
|
87
96
|
<Box width={10}>
|
|
88
|
-
<
|
|
97
|
+
<HealthBadge result={healthResult} />
|
|
89
98
|
</Box>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
<Box paddingLeft={showCheckbox ? 8 : 4}>
|
|
93
|
-
<Text dimColor>
|
|
94
|
-
└─ {limitDetails.join(" | ")}
|
|
95
|
-
</Text>
|
|
99
|
+
<Box width={10}>
|
|
100
|
+
<Text dimColor>{resetIn}</Text>
|
|
96
101
|
</Box>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
</Box>
|
|
103
|
+
{status === "limited" && limitDetails.length > 0 && (
|
|
104
|
+
<Box paddingLeft={showCheckbox ? 8 : 4}>
|
|
105
|
+
<Text dimColor>
|
|
106
|
+
└─ {limitDetails.join(" | ")}
|
|
107
|
+
</Text>
|
|
108
|
+
</Box>
|
|
109
|
+
)}
|
|
110
|
+
</Box>
|
|
111
|
+
);
|
|
107
112
|
}
|
|
108
113
|
|
|
109
|
-
|
|
110
|
-
accounts
|
|
111
|
-
selectedIndex
|
|
112
|
-
checkedEmails
|
|
113
|
-
showCheckbox
|
|
114
|
-
|
|
114
|
+
interface AccountListProps {
|
|
115
|
+
accounts: Account[];
|
|
116
|
+
selectedIndex?: number;
|
|
117
|
+
checkedEmails?: Set<string>;
|
|
118
|
+
showCheckbox?: boolean;
|
|
119
|
+
healthResults?: Record<string, AccountHealthResult>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function AccountList({
|
|
123
|
+
accounts,
|
|
124
|
+
selectedIndex = -1,
|
|
125
|
+
checkedEmails = new Set(),
|
|
126
|
+
showCheckbox = false,
|
|
127
|
+
healthResults
|
|
128
|
+
}: AccountListProps) {
|
|
115
129
|
return (
|
|
116
130
|
<Box flexDirection="column">
|
|
117
131
|
<Box flexDirection="row" paddingX={1} marginBottom={1}>
|
|
@@ -129,22 +143,26 @@ export function AccountList({
|
|
|
129
143
|
<Box width={18}>
|
|
130
144
|
<Text bold dimColor>PROJECT</Text>
|
|
131
145
|
</Box>
|
|
132
|
-
<Box width={12}>
|
|
133
|
-
<Text bold dimColor>STATUS</Text>
|
|
134
|
-
</Box>
|
|
135
|
-
<Box width={10}>
|
|
136
|
-
<Text bold dimColor>
|
|
137
|
-
</Box>
|
|
146
|
+
<Box width={12}>
|
|
147
|
+
<Text bold dimColor>STATUS</Text>
|
|
148
|
+
</Box>
|
|
149
|
+
<Box width={10}>
|
|
150
|
+
<Text bold dimColor>HEALTH</Text>
|
|
151
|
+
</Box>
|
|
152
|
+
<Box width={10}>
|
|
153
|
+
<Text bold dimColor>RESET IN</Text>
|
|
154
|
+
</Box>
|
|
138
155
|
</Box>
|
|
139
|
-
{accounts.map((account, index) => (
|
|
140
|
-
<AccountRow
|
|
141
|
-
key={account.email}
|
|
142
|
-
account={account}
|
|
143
|
-
isSelected={index === selectedIndex}
|
|
144
|
-
isChecked={checkedEmails.has(account.email)}
|
|
145
|
-
showCheckbox={showCheckbox}
|
|
146
|
-
|
|
147
|
-
|
|
156
|
+
{accounts.map((account, index) => (
|
|
157
|
+
<AccountRow
|
|
158
|
+
key={account.email}
|
|
159
|
+
account={account}
|
|
160
|
+
isSelected={index === selectedIndex}
|
|
161
|
+
isChecked={checkedEmails.has(account.email)}
|
|
162
|
+
showCheckbox={showCheckbox}
|
|
163
|
+
healthResult={healthResults?.[normalizeHealthKey(account.email)]}
|
|
164
|
+
/>
|
|
165
|
+
))}
|
|
148
166
|
{accounts.length === 0 && (
|
|
149
167
|
<Box paddingX={1}>
|
|
150
168
|
<Text dimColor>No accounts found</Text>
|
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { Box, Text, useInput } from "ink";
|
|
3
|
-
|
|
4
|
-
export interface PaletteAction {
|
|
5
|
-
id: string;
|
|
6
|
-
label: string;
|
|
7
|
-
shortcut?: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
category?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface ActionPaletteProps {
|
|
13
|
-
actions: PaletteAction[];
|
|
14
|
-
onSelect: (actionId: string) => void;
|
|
15
|
-
onClose: () => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function ActionPalette({ actions, onSelect, onClose }: ActionPaletteProps) {
|
|
19
|
-
const [search, setSearch] = useState("");
|
|
20
|
-
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
21
|
-
|
|
22
|
-
// Filter actions by search
|
|
23
|
-
const filteredActions = actions.filter(action => {
|
|
24
|
-
const searchLower = search.toLowerCase();
|
|
25
|
-
return (
|
|
26
|
-
action.label.toLowerCase().includes(searchLower) ||
|
|
27
|
-
action.id.toLowerCase().includes(searchLower) ||
|
|
28
|
-
(action.description?.toLowerCase().includes(searchLower))
|
|
29
|
-
);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
useInput((input, key) => {
|
|
33
|
-
// Close on Escape
|
|
34
|
-
if (key.escape) {
|
|
35
|
-
onClose();
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Navigate up
|
|
40
|
-
if (key.upArrow) {
|
|
41
|
-
setSelectedIndex(prev => Math.max(0, prev - 1));
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Navigate down
|
|
46
|
-
if (key.downArrow) {
|
|
47
|
-
setSelectedIndex(prev => Math.min(filteredActions.length - 1, prev + 1));
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Select on Enter
|
|
52
|
-
if (key.return) {
|
|
53
|
-
const action = filteredActions[selectedIndex];
|
|
54
|
-
if (action) {
|
|
55
|
-
onSelect(action.id);
|
|
56
|
-
}
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Backspace
|
|
61
|
-
if (key.backspace || key.delete) {
|
|
62
|
-
setSearch(prev => prev.slice(0, -1));
|
|
63
|
-
setSelectedIndex(0);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Type to search (printable characters)
|
|
68
|
-
if (input && input.length === 1 && !key.ctrl && !key.meta) {
|
|
69
|
-
setSearch(prev => prev + input);
|
|
70
|
-
setSelectedIndex(0);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<Box
|
|
76
|
-
flexDirection="column"
|
|
77
|
-
borderStyle="round"
|
|
78
|
-
borderColor="gray"
|
|
79
|
-
paddingX={1}
|
|
80
|
-
paddingY={0}
|
|
81
|
-
>
|
|
82
|
-
{/* Search input */}
|
|
83
|
-
<Box marginBottom={1}>
|
|
84
|
-
<Text bold>{">"} </Text>
|
|
85
|
-
<Text>{search || " "}</Text>
|
|
86
|
-
<Text color="gray">_</Text>
|
|
87
|
-
</Box>
|
|
88
|
-
|
|
89
|
-
{/* Actions list */}
|
|
90
|
-
<Box flexDirection="column" marginBottom={1}>
|
|
91
|
-
{filteredActions.length === 0 ? (
|
|
92
|
-
<Text dimColor>No matching actions</Text>
|
|
93
|
-
) : (
|
|
94
|
-
filteredActions.slice(0, 10).map((action, index) => {
|
|
95
|
-
const isSelected = index === selectedIndex;
|
|
96
|
-
return (
|
|
97
|
-
<Box key={action.id}>
|
|
98
|
-
<Text inverse={isSelected} dimColor={!isSelected}>
|
|
99
|
-
{isSelected ? "▸ " : " "}
|
|
100
|
-
{action.label}
|
|
101
|
-
</Text>
|
|
102
|
-
{action.shortcut && (
|
|
103
|
-
<Text dimColor> [{action.shortcut}]</Text>
|
|
104
|
-
)}
|
|
105
|
-
</Box>
|
|
106
|
-
);
|
|
107
|
-
})
|
|
108
|
-
)}
|
|
109
|
-
</Box>
|
|
110
|
-
|
|
111
|
-
{/* Help */}
|
|
112
|
-
<Box>
|
|
113
|
-
<Text dimColor>↑↓ navigate • Enter select • Esc close</Text>
|
|
114
|
-
</Box>
|
|
115
|
-
</Box>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Box, Text, useInput } from "ink";
|
|
3
|
+
|
|
4
|
+
export interface PaletteAction {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
shortcut?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
category?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface ActionPaletteProps {
|
|
13
|
+
actions: PaletteAction[];
|
|
14
|
+
onSelect: (actionId: string) => void;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function ActionPalette({ actions, onSelect, onClose }: ActionPaletteProps) {
|
|
19
|
+
const [search, setSearch] = useState("");
|
|
20
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
21
|
+
|
|
22
|
+
// Filter actions by search
|
|
23
|
+
const filteredActions = actions.filter(action => {
|
|
24
|
+
const searchLower = search.toLowerCase();
|
|
25
|
+
return (
|
|
26
|
+
action.label.toLowerCase().includes(searchLower) ||
|
|
27
|
+
action.id.toLowerCase().includes(searchLower) ||
|
|
28
|
+
(action.description?.toLowerCase().includes(searchLower))
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
useInput((input, key) => {
|
|
33
|
+
// Close on Escape
|
|
34
|
+
if (key.escape) {
|
|
35
|
+
onClose();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Navigate up
|
|
40
|
+
if (key.upArrow) {
|
|
41
|
+
setSelectedIndex(prev => Math.max(0, prev - 1));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Navigate down
|
|
46
|
+
if (key.downArrow) {
|
|
47
|
+
setSelectedIndex(prev => Math.min(filteredActions.length - 1, prev + 1));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Select on Enter
|
|
52
|
+
if (key.return) {
|
|
53
|
+
const action = filteredActions[selectedIndex];
|
|
54
|
+
if (action) {
|
|
55
|
+
onSelect(action.id);
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Backspace
|
|
61
|
+
if (key.backspace || key.delete) {
|
|
62
|
+
setSearch(prev => prev.slice(0, -1));
|
|
63
|
+
setSelectedIndex(0);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Type to search (printable characters)
|
|
68
|
+
if (input && input.length === 1 && !key.ctrl && !key.meta) {
|
|
69
|
+
setSearch(prev => prev + input);
|
|
70
|
+
setSelectedIndex(0);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<Box
|
|
76
|
+
flexDirection="column"
|
|
77
|
+
borderStyle="round"
|
|
78
|
+
borderColor="gray"
|
|
79
|
+
paddingX={1}
|
|
80
|
+
paddingY={0}
|
|
81
|
+
>
|
|
82
|
+
{/* Search input */}
|
|
83
|
+
<Box marginBottom={1}>
|
|
84
|
+
<Text bold>{">"} </Text>
|
|
85
|
+
<Text>{search || " "}</Text>
|
|
86
|
+
<Text color="gray">_</Text>
|
|
87
|
+
</Box>
|
|
88
|
+
|
|
89
|
+
{/* Actions list */}
|
|
90
|
+
<Box flexDirection="column" marginBottom={1}>
|
|
91
|
+
{filteredActions.length === 0 ? (
|
|
92
|
+
<Text dimColor>No matching actions</Text>
|
|
93
|
+
) : (
|
|
94
|
+
filteredActions.slice(0, 10).map((action, index) => {
|
|
95
|
+
const isSelected = index === selectedIndex;
|
|
96
|
+
return (
|
|
97
|
+
<Box key={action.id}>
|
|
98
|
+
<Text inverse={isSelected} dimColor={!isSelected}>
|
|
99
|
+
{isSelected ? "▸ " : " "}
|
|
100
|
+
{action.label}
|
|
101
|
+
</Text>
|
|
102
|
+
{action.shortcut && (
|
|
103
|
+
<Text dimColor> [{action.shortcut}]</Text>
|
|
104
|
+
)}
|
|
105
|
+
</Box>
|
|
106
|
+
);
|
|
107
|
+
})
|
|
108
|
+
)}
|
|
109
|
+
</Box>
|
|
110
|
+
|
|
111
|
+
{/* Help */}
|
|
112
|
+
<Box>
|
|
113
|
+
<Text dimColor>↑↓ navigate • Enter select • Esc close</Text>
|
|
114
|
+
</Box>
|
|
115
|
+
</Box>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
@@ -24,13 +24,13 @@ export function Box({
|
|
|
24
24
|
width={width}
|
|
25
25
|
paddingX={padding}
|
|
26
26
|
>
|
|
27
|
-
{title && (
|
|
28
|
-
<InkBox marginBottom={1}>
|
|
29
|
-
<Text bold>
|
|
30
|
-
{title}
|
|
31
|
-
</Text>
|
|
32
|
-
</InkBox>
|
|
33
|
-
)}
|
|
27
|
+
{title && (
|
|
28
|
+
<InkBox marginBottom={1}>
|
|
29
|
+
<Text bold>
|
|
30
|
+
{title}
|
|
31
|
+
</Text>
|
|
32
|
+
</InkBox>
|
|
33
|
+
)}
|
|
34
34
|
{children}
|
|
35
35
|
</InkBox>
|
|
36
36
|
);
|