ccmanager 0.1.6 → 0.1.8
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/NewWorktree.js +20 -16
- package/dist/components/Session.js +10 -3
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState,
|
|
1
|
+
import React, { useState, useMemo } from 'react';
|
|
2
2
|
import { Box, Text, useInput } from 'ink';
|
|
3
3
|
import TextInput from 'ink-text-input';
|
|
4
4
|
import SelectInput from 'ink-select-input';
|
|
@@ -13,18 +13,23 @@ const NewWorktree = ({ onComplete, onCancel }) => {
|
|
|
13
13
|
const [step, setStep] = useState(isAutoDirectory ? 'branch' : 'path');
|
|
14
14
|
const [path, setPath] = useState('');
|
|
15
15
|
const [branch, setBranch] = useState('');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
// Initialize worktree service and load branches (memoized to avoid re-initialization)
|
|
17
|
+
const { branches, defaultBranch } = useMemo(() => {
|
|
18
|
+
const service = new WorktreeService();
|
|
19
|
+
const allBranches = service.getAllBranches();
|
|
20
|
+
const defaultBr = service.getDefaultBranch();
|
|
21
|
+
return {
|
|
22
|
+
branches: allBranches,
|
|
23
|
+
defaultBranch: defaultBr,
|
|
24
|
+
};
|
|
25
|
+
}, []); // Empty deps array - only initialize once
|
|
26
|
+
// Create branch items with default branch first (memoized)
|
|
27
|
+
const branchItems = useMemo(() => [
|
|
23
28
|
{ label: `${defaultBranch} (default)`, value: defaultBranch },
|
|
24
29
|
...branches
|
|
25
30
|
.filter(br => br !== defaultBranch)
|
|
26
31
|
.map(br => ({ label: br, value: br })),
|
|
27
|
-
];
|
|
32
|
+
], [branches, defaultBranch]);
|
|
28
33
|
useInput((input, key) => {
|
|
29
34
|
if (shortcutManager.matchesShortcut('cancel', input, key)) {
|
|
30
35
|
onCancel();
|
|
@@ -52,13 +57,12 @@ const NewWorktree = ({ onComplete, onCancel }) => {
|
|
|
52
57
|
onComplete(path, branch, item.value);
|
|
53
58
|
}
|
|
54
59
|
};
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}, [branch, isAutoDirectory, worktreeConfig.autoDirectoryPattern]);
|
|
60
|
+
// Calculate generated path for preview (memoized to avoid expensive recalculations)
|
|
61
|
+
const generatedPath = useMemo(() => {
|
|
62
|
+
return isAutoDirectory && branch
|
|
63
|
+
? generateWorktreeDirectory(branch, worktreeConfig.autoDirectoryPattern)
|
|
64
|
+
: '';
|
|
65
|
+
}, [isAutoDirectory, branch, worktreeConfig.autoDirectoryPattern]);
|
|
62
66
|
return (React.createElement(Box, { flexDirection: "column" },
|
|
63
67
|
React.createElement(Box, { marginBottom: 1 },
|
|
64
68
|
React.createElement(Text, { bold: true, color: "green" }, "Create New Worktree")),
|
|
@@ -43,9 +43,16 @@ const Session = ({ session, sessionManager, onReturnToMenu, }) => {
|
|
|
43
43
|
// https://github.com/kbwo/ccmanager/issues/2
|
|
44
44
|
const currentCols = process.stdout.columns || 80;
|
|
45
45
|
const currentRows = process.stdout.rows || 24;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
// Do not delete try-catch
|
|
47
|
+
// Prevent ccmanager from exiting when claude process has already exited
|
|
48
|
+
try {
|
|
49
|
+
session.process.resize(currentCols, currentRows);
|
|
50
|
+
if (session.terminal) {
|
|
51
|
+
session.terminal.resize(currentCols, currentRows);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
/* empty */
|
|
49
56
|
}
|
|
50
57
|
// Listen for session data events
|
|
51
58
|
const handleSessionData = (activeSession, data) => {
|