ccmanager 2.0.0 → 2.1.0
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/Menu.js
CHANGED
|
@@ -24,6 +24,7 @@ const Menu = ({ sessionManager, worktreeService, onSelectWorktree, onSelectRecen
|
|
|
24
24
|
const [sessions, setSessions] = useState([]);
|
|
25
25
|
const [items, setItems] = useState([]);
|
|
26
26
|
const [recentProjects, setRecentProjects] = useState([]);
|
|
27
|
+
const limit = 10;
|
|
27
28
|
// Use the search mode hook
|
|
28
29
|
const { isSearchMode, searchQuery, selectedIndex, setSearchQuery } = useSearchMode(items.length, {
|
|
29
30
|
isDisabled: !!error,
|
|
@@ -374,9 +375,9 @@ const Menu = ({ sessionManager, worktreeService, onSelectWorktree, onSelectRecen
|
|
|
374
375
|
isSearchMode && items.length === 0 ? (React.createElement(Box, null,
|
|
375
376
|
React.createElement(Text, { color: "yellow" }, "No worktrees match your search"))) : isSearchMode ? (
|
|
376
377
|
// In search mode, show the items as a list without SelectInput
|
|
377
|
-
React.createElement(Box, { flexDirection: "column" }, items.map((item, index) => (React.createElement(Text, { key: item.value, color: index === selectedIndex ? 'green' : undefined },
|
|
378
|
+
React.createElement(Box, { flexDirection: "column" }, items.slice(0, limit).map((item, index) => (React.createElement(Text, { key: item.value, color: index === selectedIndex ? 'green' : undefined },
|
|
378
379
|
index === selectedIndex ? '❯ ' : ' ',
|
|
379
|
-
item.label))))) : (React.createElement(SelectInput, { items: items, onSelect: item => handleSelect(item), isFocused: !error, initialIndex: selectedIndex })),
|
|
380
|
+
item.label))))) : (React.createElement(SelectInput, { items: items, onSelect: item => handleSelect(item), isFocused: !error, initialIndex: selectedIndex, limit: limit })),
|
|
380
381
|
error && (React.createElement(Box, { marginTop: 1, paddingX: 1, borderStyle: "round", borderColor: "red" },
|
|
381
382
|
React.createElement(Box, { flexDirection: "column" },
|
|
382
383
|
React.createElement(Text, { color: "red", bold: true },
|
|
@@ -6,9 +6,11 @@ import { shortcutManager } from '../services/shortcutManager.js';
|
|
|
6
6
|
import { configurationManager } from '../services/configurationManager.js';
|
|
7
7
|
import { generateWorktreeDirectory } from '../utils/worktreeUtils.js';
|
|
8
8
|
import { WorktreeService } from '../services/worktreeService.js';
|
|
9
|
+
import { useSearchMode } from '../hooks/useSearchMode.js';
|
|
9
10
|
const NewWorktree = ({ onComplete, onCancel }) => {
|
|
10
11
|
const worktreeConfig = configurationManager.getWorktreeConfig();
|
|
11
12
|
const isAutoDirectory = worktreeConfig.autoDirectory;
|
|
13
|
+
const limit = 10;
|
|
12
14
|
// Adjust initial step based on auto directory mode
|
|
13
15
|
const [step, setStep] = useState(isAutoDirectory ? 'branch' : 'path');
|
|
14
16
|
const [path, setPath] = useState('');
|
|
@@ -27,16 +29,32 @@ const NewWorktree = ({ onComplete, onCancel }) => {
|
|
|
27
29
|
};
|
|
28
30
|
}, []); // Empty deps array - only initialize once
|
|
29
31
|
// Create branch items with default branch first (memoized)
|
|
30
|
-
const
|
|
32
|
+
const allBranchItems = useMemo(() => [
|
|
31
33
|
{ label: `${defaultBranch} (default)`, value: defaultBranch },
|
|
32
34
|
...branches
|
|
33
35
|
.filter(br => br !== defaultBranch)
|
|
34
36
|
.map(br => ({ label: br, value: br })),
|
|
35
37
|
], [branches, defaultBranch]);
|
|
38
|
+
// Use search mode for base branch selection
|
|
39
|
+
const { isSearchMode, searchQuery, selectedIndex, setSearchQuery } = useSearchMode(allBranchItems.length, {
|
|
40
|
+
isDisabled: step !== 'base-branch',
|
|
41
|
+
});
|
|
42
|
+
// Filter branch items based on search query
|
|
43
|
+
const branchItems = useMemo(() => {
|
|
44
|
+
if (!searchQuery)
|
|
45
|
+
return allBranchItems;
|
|
46
|
+
return allBranchItems.filter(item => item.value.toLowerCase().includes(searchQuery.toLowerCase()));
|
|
47
|
+
}, [allBranchItems, searchQuery]);
|
|
36
48
|
useInput((input, key) => {
|
|
37
49
|
if (shortcutManager.matchesShortcut('cancel', input, key)) {
|
|
38
50
|
onCancel();
|
|
39
51
|
}
|
|
52
|
+
// Handle arrow key navigation in search mode for base branch selection
|
|
53
|
+
if (step === 'base-branch' && isSearchMode) {
|
|
54
|
+
// Don't handle any keys here - let useSearchMode handle them
|
|
55
|
+
// The hook will handle arrow keys for navigation and Enter to exit search mode
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
40
58
|
});
|
|
41
59
|
const handlePathSubmit = (value) => {
|
|
42
60
|
if (value.trim()) {
|
|
@@ -109,7 +127,17 @@ const NewWorktree = ({ onComplete, onCancel }) => {
|
|
|
109
127
|
"Select base branch for ",
|
|
110
128
|
React.createElement(Text, { color: "cyan" }, branch),
|
|
111
129
|
":")),
|
|
112
|
-
React.createElement(
|
|
130
|
+
isSearchMode && (React.createElement(Box, { marginBottom: 1 },
|
|
131
|
+
React.createElement(Text, null, "Search: "),
|
|
132
|
+
React.createElement(TextInputWrapper, { value: searchQuery, onChange: setSearchQuery, focus: true, placeholder: "Type to filter branches..." }))),
|
|
133
|
+
isSearchMode && branchItems.length === 0 ? (React.createElement(Box, null,
|
|
134
|
+
React.createElement(Text, { color: "yellow" }, "No branches match your search"))) : isSearchMode ? (
|
|
135
|
+
// In search mode, show the items as a list without SelectInput
|
|
136
|
+
React.createElement(Box, { flexDirection: "column" }, branchItems.slice(0, limit).map((item, index) => (React.createElement(Text, { key: item.value, color: index === selectedIndex ? 'green' : undefined },
|
|
137
|
+
index === selectedIndex ? '❯ ' : ' ',
|
|
138
|
+
item.label))))) : (React.createElement(SelectInput, { items: branchItems, onSelect: handleBaseBranchSelect, initialIndex: selectedIndex, limit: limit, isFocused: !isSearchMode })),
|
|
139
|
+
!isSearchMode && (React.createElement(Box, { marginTop: 1 },
|
|
140
|
+
React.createElement(Text, { dimColor: true }, "Press / to search"))))),
|
|
113
141
|
step === 'copy-settings' && (React.createElement(Box, { flexDirection: "column" },
|
|
114
142
|
React.createElement(Box, { marginBottom: 1 },
|
|
115
143
|
React.createElement(Text, null,
|