wave-code 0.18.3 → 0.18.4
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/dist/components/CommandSelector.d.ts.map +1 -1
- package/dist/components/CommandSelector.js +9 -13
- package/dist/components/ConfirmationSelector.d.ts.map +1 -1
- package/dist/components/ConfirmationSelector.js +0 -1
- package/dist/components/DiscoverView.d.ts.map +1 -1
- package/dist/components/DiscoverView.js +10 -6
- package/dist/components/FileSelector.js +8 -8
- package/dist/components/HistorySearch.d.ts.map +1 -1
- package/dist/components/HistorySearch.js +6 -13
- package/dist/components/InstalledView.d.ts.map +1 -1
- package/dist/components/InstalledView.js +10 -6
- package/dist/components/LoginCommand.d.ts.map +1 -1
- package/dist/components/LoginCommand.js +14 -11
- package/dist/components/MarketplaceDetail.d.ts.map +1 -1
- package/dist/components/MarketplaceDetail.js +11 -7
- package/dist/components/MarketplaceView.d.ts.map +1 -1
- package/dist/components/MarketplaceView.js +10 -6
- package/dist/components/ModelSelector.d.ts.map +1 -1
- package/dist/components/ModelSelector.js +9 -15
- package/dist/components/SessionSelector.d.ts +5 -3
- package/dist/components/SessionSelector.d.ts.map +1 -1
- package/dist/components/SessionSelector.js +11 -7
- package/dist/components/WorktreeExitPrompt.d.ts.map +1 -1
- package/dist/components/WorktreeExitPrompt.js +3 -3
- package/dist/reducers/questionReducer.d.ts +0 -7
- package/dist/reducers/questionReducer.d.ts.map +1 -1
- package/dist/reducers/questionReducer.js +2 -1
- package/dist/reducers/selectorReducer.d.ts +7 -5
- package/dist/reducers/selectorReducer.d.ts.map +1 -1
- package/dist/reducers/selectorReducer.js +4 -2
- package/package.json +2 -2
- package/src/components/CommandSelector.tsx +11 -15
- package/src/components/ConfirmationSelector.tsx +0 -1
- package/src/components/DiscoverView.tsx +22 -7
- package/src/components/FileSelector.tsx +9 -9
- package/src/components/HistorySearch.tsx +7 -14
- package/src/components/InstalledView.tsx +23 -9
- package/src/components/LoginCommand.tsx +33 -36
- package/src/components/MarketplaceDetail.tsx +25 -10
- package/src/components/MarketplaceView.tsx +16 -7
- package/src/components/ModelSelector.tsx +13 -16
- package/src/components/SessionSelector.tsx +19 -9
- package/src/components/WorktreeExitPrompt.tsx +7 -4
- package/src/reducers/questionReducer.ts +2 -6
- package/src/reducers/selectorReducer.ts +20 -10
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import React, { useReducer, useEffect } from "react";
|
|
2
2
|
import { Box, Text, useInput } from "ink";
|
|
3
3
|
import type { SessionMetadata } from "wave-agent-sdk";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
selectorReducer,
|
|
6
|
+
type SelectorState,
|
|
7
|
+
} from "../reducers/selectorReducer.js";
|
|
8
|
+
|
|
9
|
+
type SessionItem = SessionMetadata & { firstMessage?: string };
|
|
5
10
|
|
|
6
11
|
export interface SessionSelectorProps {
|
|
7
|
-
sessions:
|
|
12
|
+
sessions: SessionItem[];
|
|
8
13
|
onSelect: (sessionId: string) => void;
|
|
9
14
|
onCancel: () => void;
|
|
10
15
|
}
|
|
@@ -14,33 +19,38 @@ export const SessionSelector: React.FC<SessionSelectorProps> = ({
|
|
|
14
19
|
onSelect,
|
|
15
20
|
onCancel,
|
|
16
21
|
}) => {
|
|
17
|
-
const [state, dispatch] = useReducer(selectorReducer
|
|
22
|
+
const [state, dispatch] = useReducer(selectorReducer<SessionItem>, {
|
|
18
23
|
selectedIndex: 0,
|
|
19
24
|
pendingDecision: null,
|
|
20
|
-
|
|
25
|
+
items: [],
|
|
26
|
+
} as SelectorState<SessionItem>);
|
|
21
27
|
|
|
22
|
-
const { selectedIndex, pendingDecision } = state;
|
|
28
|
+
const { selectedIndex, pendingDecision, items } = state;
|
|
29
|
+
|
|
30
|
+
// Sync sessions into reducer state
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
dispatch({ type: "SET_ITEMS", items: sessions });
|
|
33
|
+
}, [sessions]);
|
|
23
34
|
|
|
24
35
|
useInput((_input, key) => {
|
|
25
36
|
dispatch({
|
|
26
37
|
type: "HANDLE_KEY",
|
|
27
38
|
key,
|
|
28
|
-
maxIndex: sessions.length - 1,
|
|
29
39
|
hasInsert: false,
|
|
30
40
|
});
|
|
31
41
|
});
|
|
32
42
|
|
|
33
43
|
useEffect(() => {
|
|
34
44
|
if (pendingDecision === "select") {
|
|
35
|
-
if (
|
|
36
|
-
onSelect(
|
|
45
|
+
if (items.length > 0 && selectedIndex < items.length) {
|
|
46
|
+
onSelect(items[selectedIndex].id);
|
|
37
47
|
}
|
|
38
48
|
dispatch({ type: "CLEAR_DECISION" });
|
|
39
49
|
} else if (pendingDecision === "cancel") {
|
|
40
50
|
onCancel();
|
|
41
51
|
dispatch({ type: "CLEAR_DECISION" });
|
|
42
52
|
}
|
|
43
|
-
}, [pendingDecision, selectedIndex,
|
|
53
|
+
}, [pendingDecision, selectedIndex, items, onSelect, onCancel]);
|
|
44
54
|
|
|
45
55
|
if (sessions.length === 0) {
|
|
46
56
|
return (
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React, { useReducer, useEffect } from "react";
|
|
2
2
|
import { Box, Text, useInput } from "ink";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
selectorReducer,
|
|
5
|
+
type SelectorState,
|
|
6
|
+
} from "../reducers/selectorReducer.js";
|
|
4
7
|
|
|
5
8
|
interface WorktreeExitPromptProps {
|
|
6
9
|
name: string;
|
|
@@ -21,10 +24,11 @@ export const WorktreeExitPrompt: React.FC<WorktreeExitPromptProps> = ({
|
|
|
21
24
|
onRemove,
|
|
22
25
|
onCancel,
|
|
23
26
|
}) => {
|
|
24
|
-
const [state, dispatch] = useReducer(selectorReducer
|
|
27
|
+
const [state, dispatch] = useReducer(selectorReducer<string>, {
|
|
25
28
|
selectedIndex: 0,
|
|
26
29
|
pendingDecision: null,
|
|
27
|
-
|
|
30
|
+
items: ["keep", "remove"],
|
|
31
|
+
} as SelectorState<string>);
|
|
28
32
|
|
|
29
33
|
const { selectedIndex, pendingDecision } = state;
|
|
30
34
|
|
|
@@ -32,7 +36,6 @@ export const WorktreeExitPrompt: React.FC<WorktreeExitPromptProps> = ({
|
|
|
32
36
|
dispatch({
|
|
33
37
|
type: "HANDLE_KEY",
|
|
34
38
|
key,
|
|
35
|
-
maxIndex: 1,
|
|
36
39
|
hasInsert: false,
|
|
37
40
|
});
|
|
38
41
|
});
|
|
@@ -52,11 +52,6 @@ export type QuestionAction =
|
|
|
52
52
|
type: "HANDLE_KEY";
|
|
53
53
|
input: string;
|
|
54
54
|
key: Key;
|
|
55
|
-
currentQuestion: {
|
|
56
|
-
question: string;
|
|
57
|
-
options: Array<{ label: string }>;
|
|
58
|
-
multiSelect?: boolean;
|
|
59
|
-
};
|
|
60
55
|
questions: Array<{
|
|
61
56
|
question: string;
|
|
62
57
|
options: Array<{ label: string }>;
|
|
@@ -265,7 +260,8 @@ export function questionReducer(
|
|
|
265
260
|
case "CLEAR_DECISION":
|
|
266
261
|
return { ...state, decision: null };
|
|
267
262
|
case "HANDLE_KEY": {
|
|
268
|
-
const { input, key,
|
|
263
|
+
const { input, key, questions } = action;
|
|
264
|
+
const currentQuestion = questions[state.currentQuestionIndex];
|
|
269
265
|
if (!currentQuestion) return state;
|
|
270
266
|
|
|
271
267
|
const options = [...currentQuestion.options, { label: "Other" }];
|
|
@@ -1,31 +1,38 @@
|
|
|
1
1
|
import { Key } from "ink";
|
|
2
2
|
|
|
3
|
-
export interface SelectorState {
|
|
3
|
+
export interface SelectorState<T = unknown> {
|
|
4
4
|
selectedIndex: number;
|
|
5
5
|
pendingDecision: "select" | "insert" | "cancel" | null;
|
|
6
|
+
items: T[];
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
export type SelectorAction =
|
|
9
|
+
export type SelectorAction<T = unknown> =
|
|
9
10
|
| { type: "MOVE_UP" }
|
|
10
|
-
| { type: "MOVE_DOWN"
|
|
11
|
+
| { type: "MOVE_DOWN" }
|
|
11
12
|
| { type: "RESET_INDEX" }
|
|
12
|
-
| { type: "
|
|
13
|
+
| { type: "SET_ITEMS"; items: T[] }
|
|
14
|
+
| { type: "HANDLE_KEY"; key: Key; hasInsert: boolean }
|
|
13
15
|
| { type: "CLEAR_DECISION" };
|
|
14
16
|
|
|
15
|
-
export function selectorReducer(
|
|
16
|
-
state: SelectorState
|
|
17
|
-
action: SelectorAction
|
|
18
|
-
): SelectorState {
|
|
17
|
+
export function selectorReducer<T = unknown>(
|
|
18
|
+
state: SelectorState<T>,
|
|
19
|
+
action: SelectorAction<T>,
|
|
20
|
+
): SelectorState<T> {
|
|
19
21
|
switch (action.type) {
|
|
20
22
|
case "MOVE_UP":
|
|
21
23
|
return { ...state, selectedIndex: Math.max(0, state.selectedIndex - 1) };
|
|
22
24
|
case "MOVE_DOWN":
|
|
23
25
|
return {
|
|
24
26
|
...state,
|
|
25
|
-
selectedIndex: Math.min(
|
|
27
|
+
selectedIndex: Math.min(
|
|
28
|
+
state.items.length - 1,
|
|
29
|
+
state.selectedIndex + 1,
|
|
30
|
+
),
|
|
26
31
|
};
|
|
27
32
|
case "RESET_INDEX":
|
|
28
33
|
return { ...state, selectedIndex: 0 };
|
|
34
|
+
case "SET_ITEMS":
|
|
35
|
+
return { ...state, items: action.items, selectedIndex: 0 };
|
|
29
36
|
case "HANDLE_KEY":
|
|
30
37
|
if (action.key.upArrow) {
|
|
31
38
|
return {
|
|
@@ -36,7 +43,10 @@ export function selectorReducer(
|
|
|
36
43
|
if (action.key.downArrow) {
|
|
37
44
|
return {
|
|
38
45
|
...state,
|
|
39
|
-
selectedIndex: Math.min(
|
|
46
|
+
selectedIndex: Math.min(
|
|
47
|
+
state.items.length - 1,
|
|
48
|
+
state.selectedIndex + 1,
|
|
49
|
+
),
|
|
40
50
|
};
|
|
41
51
|
}
|
|
42
52
|
if (action.key.return) {
|