@akiojin/gwt 2.10.0 → 2.11.1
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/cli/ui/components/App.d.ts.map +1 -1
- package/dist/cli/ui/components/App.js +5 -47
- package/dist/cli/ui/components/App.js.map +1 -1
- package/dist/cli/ui/components/common/Input.d.ts +1 -1
- package/dist/cli/ui/components/screens/BranchListScreen.d.ts +1 -2
- package/dist/cli/ui/components/screens/BranchListScreen.d.ts.map +1 -1
- package/dist/cli/ui/components/screens/BranchListScreen.js +19 -14
- package/dist/cli/ui/components/screens/BranchListScreen.js.map +1 -1
- package/dist/cli/ui/components/screens/ModelSelectorScreen.d.ts.map +1 -1
- package/dist/cli/ui/components/screens/ModelSelectorScreen.js +6 -6
- package/dist/cli/ui/components/screens/ModelSelectorScreen.js.map +1 -1
- package/dist/cli/ui/components/screens/PRCleanupScreen.d.ts.map +1 -1
- package/dist/cli/ui/components/screens/PRCleanupScreen.js +0 -3
- package/dist/cli/ui/components/screens/PRCleanupScreen.js.map +1 -1
- package/dist/cli/ui/hooks/useGitData.d.ts.map +1 -1
- package/dist/cli/ui/hooks/useGitData.js +43 -2
- package/dist/cli/ui/hooks/useGitData.js.map +1 -1
- package/dist/cli/ui/types.d.ts +16 -4
- package/dist/cli/ui/types.d.ts.map +1 -1
- package/dist/cli/ui/utils/branchFormatter.d.ts.map +1 -1
- package/dist/cli/ui/utils/branchFormatter.js +124 -28
- package/dist/cli/ui/utils/branchFormatter.js.map +1 -1
- package/dist/cli/ui/utils/modelOptions.d.ts.map +1 -1
- package/dist/cli/ui/utils/modelOptions.js.map +1 -1
- package/dist/client/assets/{index-CNWntAlF.js → index-Dl798X5w.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/git.d.ts +6 -0
- package/dist/git.d.ts.map +1 -1
- package/dist/git.js +40 -5
- package/dist/git.js.map +1 -1
- package/dist/web/client/src/components/BranchGraph.js +1 -1
- package/dist/web/client/src/components/BranchGraph.js.map +1 -1
- package/dist/web/client/src/pages/BranchDetailPage.d.ts.map +1 -1
- package/dist/web/client/src/pages/BranchDetailPage.js +8 -3
- package/dist/web/client/src/pages/BranchDetailPage.js.map +1 -1
- package/dist/web/server/routes/sessions.d.ts.map +1 -1
- package/dist/web/server/routes/sessions.js +4 -2
- package/dist/web/server/routes/sessions.js.map +1 -1
- package/dist/worktree.d.ts.map +1 -1
- package/dist/worktree.js +31 -44
- package/dist/worktree.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/ui/__tests__/acceptance/navigation.acceptance.test.tsx +9 -17
- package/src/cli/ui/__tests__/components/App.protected-branch.test.tsx +14 -20
- package/src/cli/ui/__tests__/components/App.shortcuts.test.tsx +14 -44
- package/src/cli/ui/__tests__/components/App.test.tsx +8 -15
- package/src/cli/ui/__tests__/components/ModelSelectorScreen.initial.test.tsx +12 -5
- package/src/cli/ui/__tests__/components/common/Confirm.test.tsx +3 -2
- package/src/cli/ui/__tests__/components/common/ErrorBoundary.test.tsx +3 -2
- package/src/cli/ui/__tests__/components/common/Input.test.tsx +3 -2
- package/src/cli/ui/__tests__/components/common/LoadingIndicator.test.tsx +15 -14
- package/src/cli/ui/__tests__/components/common/Select.memo.test.tsx +3 -3
- package/src/cli/ui/__tests__/components/common/Select.test.tsx +1 -4
- package/src/cli/ui/__tests__/components/parts/Footer.test.tsx +3 -2
- package/src/cli/ui/__tests__/components/parts/Header.test.tsx +3 -2
- package/src/cli/ui/__tests__/components/parts/ScrollableList.test.tsx +3 -2
- package/src/cli/ui/__tests__/components/parts/Stats.test.tsx +3 -2
- package/src/cli/ui/__tests__/components/screens/AIToolSelectorScreen.test.tsx +3 -2
- package/src/cli/ui/__tests__/components/screens/BranchCreatorScreen.test.tsx +3 -2
- package/src/cli/ui/__tests__/components/screens/BranchListScreen.test.tsx +33 -43
- package/src/cli/ui/__tests__/components/screens/ExecutionModeSelectorScreen.test.tsx +3 -2
- package/src/cli/ui/__tests__/components/screens/PRCleanupScreen.test.tsx +3 -2
- package/src/cli/ui/__tests__/components/screens/SessionSelectorScreen.test.tsx +3 -2
- package/src/cli/ui/__tests__/hooks/useScreenState.test.ts +18 -17
- package/src/cli/ui/__tests__/hooks/useTerminalSize.test.ts +3 -2
- package/src/cli/ui/__tests__/integration/edgeCases.test.tsx +5 -12
- package/src/cli/ui/__tests__/integration/navigation.test.tsx +15 -10
- package/src/cli/ui/__tests__/integration/realtimeUpdate.test.tsx +3 -2
- package/src/cli/ui/__tests__/performance/branchList.performance.test.tsx +0 -4
- package/src/cli/ui/__tests__/performance/useMemoOptimization.test.tsx +3 -5
- package/src/cli/ui/__tests__/utils/branchFormatter.test.ts +24 -23
- package/src/cli/ui/components/App.tsx +3 -74
- package/src/cli/ui/components/common/Input.tsx +1 -1
- package/src/cli/ui/components/screens/BranchListScreen.tsx +32 -22
- package/src/cli/ui/components/screens/ModelSelectorScreen.tsx +46 -49
- package/src/cli/ui/components/screens/PRCleanupScreen.tsx +0 -3
- package/src/cli/ui/hooks/useGitData.ts +59 -1
- package/src/cli/ui/screens/__tests__/BranchActionSelectorScreen.test.tsx +3 -2
- package/src/cli/ui/types.ts +24 -5
- package/src/cli/ui/utils/branchFormatter.ts +123 -28
- package/src/cli/ui/utils/modelOptions.test.ts +4 -6
- package/src/cli/ui/utils/modelOptions.ts +1 -2
- package/src/config/index.ts +2 -1
- package/src/git.ts +56 -16
- package/src/web/client/src/components/BranchGraph.tsx +1 -1
- package/src/web/client/src/pages/BranchDetailPage.tsx +8 -3
- package/src/web/server/routes/sessions.ts +12 -5
- package/src/worktree.ts +31 -59
- package/dist/cli/ui/components/screens/WorktreeManagerScreen.d.ts +0 -20
- package/dist/cli/ui/components/screens/WorktreeManagerScreen.d.ts.map +0 -1
- package/dist/cli/ui/components/screens/WorktreeManagerScreen.js +0 -65
- package/dist/cli/ui/components/screens/WorktreeManagerScreen.js.map +0 -1
- package/src/cli/ui/__tests__/components/screens/WorktreeManagerScreen.test.tsx +0 -151
- package/src/cli/ui/components/screens/WorktreeManagerScreen.tsx +0 -117
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
hasUnpushedCommitsInRepo,
|
|
5
5
|
getRepositoryRoot,
|
|
6
6
|
fetchAllRemotes,
|
|
7
|
+
collectUpstreamMap,
|
|
8
|
+
getBranchDivergenceStatuses,
|
|
7
9
|
} from "../../../git.js";
|
|
8
10
|
import { listAdditionalWorktrees } from "../../../worktree.js";
|
|
9
11
|
import { getPullRequestByBranch } from "../../../github.js";
|
|
@@ -65,6 +67,36 @@ export function useGitData(options?: UseGitDataOptions): UseGitDataResult {
|
|
|
65
67
|
}
|
|
66
68
|
const lastToolUsageMap = await getLastToolUsageMap(repoRoot);
|
|
67
69
|
|
|
70
|
+
// upstream情報とdivergence情報を取得
|
|
71
|
+
const [upstreamMap, divergenceStatuses] = await Promise.all([
|
|
72
|
+
collectUpstreamMap(repoRoot),
|
|
73
|
+
getBranchDivergenceStatuses({ cwd: repoRoot }).catch(() => []),
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
// divergenceをMapに変換
|
|
77
|
+
const divergenceMap = new Map(
|
|
78
|
+
divergenceStatuses.map((s) => [
|
|
79
|
+
s.branch,
|
|
80
|
+
{
|
|
81
|
+
ahead: s.localAhead,
|
|
82
|
+
behind: s.remoteAhead,
|
|
83
|
+
upToDate: s.localAhead === 0 && s.remoteAhead === 0,
|
|
84
|
+
},
|
|
85
|
+
]),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// ローカルブランチ名のSet(重複除去用)
|
|
89
|
+
const localBranchNames = new Set(
|
|
90
|
+
branchesData.filter((b) => b.type === "local").map((b) => b.name),
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
// リモートブランチ名のSet(hasRemoteCounterpart判定用)
|
|
94
|
+
const remoteBranchNames = new Set(
|
|
95
|
+
branchesData
|
|
96
|
+
.filter((b) => b.type === "remote")
|
|
97
|
+
.map((b) => b.name.replace(/^origin\//, "")),
|
|
98
|
+
);
|
|
99
|
+
|
|
68
100
|
// Store worktrees separately
|
|
69
101
|
setWorktrees(worktreesData);
|
|
70
102
|
|
|
@@ -81,9 +113,18 @@ export function useGitData(options?: UseGitDataOptions): UseGitDataResult {
|
|
|
81
113
|
worktreeMap.set(worktree.branch, uiWorktreeInfo);
|
|
82
114
|
}
|
|
83
115
|
|
|
116
|
+
// リモートブランチの重複除去(ローカルに同名がある場合は除外)
|
|
117
|
+
const filteredBranches = branchesData.filter((branch) => {
|
|
118
|
+
if (branch.type === "remote") {
|
|
119
|
+
const remoteBranchBaseName = branch.name.replace(/^origin\//, "");
|
|
120
|
+
return !localBranchNames.has(remoteBranchBaseName);
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
});
|
|
124
|
+
|
|
84
125
|
// Attach worktree info and check unpushed/PR status for local branches
|
|
85
126
|
const enrichedBranches = await Promise.all(
|
|
86
|
-
|
|
127
|
+
filteredBranches.map(async (branch) => {
|
|
87
128
|
const worktreeInfo = worktreeMap.get(branch.name);
|
|
88
129
|
let hasUnpushed = false;
|
|
89
130
|
let prInfo = null;
|
|
@@ -110,6 +151,20 @@ export function useGitData(options?: UseGitDataOptions): UseGitDataResult {
|
|
|
110
151
|
}
|
|
111
152
|
}
|
|
112
153
|
|
|
154
|
+
// upstream/divergence/hasRemoteCounterpart情報を付加
|
|
155
|
+
const upstream =
|
|
156
|
+
branch.type === "local"
|
|
157
|
+
? (upstreamMap.get(branch.name) ?? null)
|
|
158
|
+
: null;
|
|
159
|
+
const divergence =
|
|
160
|
+
branch.type === "local"
|
|
161
|
+
? (divergenceMap.get(branch.name) ?? null)
|
|
162
|
+
: null;
|
|
163
|
+
const hasRemoteCounterpart =
|
|
164
|
+
branch.type === "local"
|
|
165
|
+
? remoteBranchNames.has(branch.name)
|
|
166
|
+
: false;
|
|
167
|
+
|
|
113
168
|
return {
|
|
114
169
|
...branch,
|
|
115
170
|
...(worktreeInfo ? { worktree: worktreeInfo } : {}),
|
|
@@ -128,6 +183,9 @@ export function useGitData(options?: UseGitDataOptions): UseGitDataResult {
|
|
|
128
183
|
...(lastToolUsageMap.get(branch.name)
|
|
129
184
|
? { lastToolUsage: lastToolUsageMap.get(branch.name) ?? null }
|
|
130
185
|
: {}),
|
|
186
|
+
...(upstream !== null ? { upstream } : {}),
|
|
187
|
+
...(divergence !== null ? { divergence } : {}),
|
|
188
|
+
...(hasRemoteCounterpart ? { hasRemoteCounterpart } : {}),
|
|
131
189
|
};
|
|
132
190
|
}),
|
|
133
191
|
);
|
|
@@ -11,8 +11,9 @@ describe("BranchActionSelectorScreen", () => {
|
|
|
11
11
|
beforeEach(() => {
|
|
12
12
|
// Setup happy-dom
|
|
13
13
|
const window = new Window();
|
|
14
|
-
globalThis.window = window as
|
|
15
|
-
globalThis.document =
|
|
14
|
+
globalThis.window = window as unknown as typeof globalThis.window;
|
|
15
|
+
globalThis.document =
|
|
16
|
+
window.document as unknown as typeof globalThis.document;
|
|
16
17
|
});
|
|
17
18
|
|
|
18
19
|
it("should render the screen", () => {
|
package/src/cli/ui/types.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { LastToolUsage } from "../../types/api.js";
|
|
2
|
+
export type { LastToolUsage } from "../../types/api.js";
|
|
3
|
+
|
|
1
4
|
export interface WorktreeInfo {
|
|
2
5
|
path: string;
|
|
3
6
|
locked: boolean;
|
|
@@ -5,11 +8,8 @@ export interface WorktreeInfo {
|
|
|
5
8
|
isAccessible?: boolean;
|
|
6
9
|
}
|
|
7
10
|
|
|
8
|
-
import type { LastToolUsage } from "../../types/api.js";
|
|
9
|
-
|
|
10
11
|
export type AITool = string;
|
|
11
12
|
export type InferenceLevel = "low" | "medium" | "high" | "xhigh";
|
|
12
|
-
export type { LastToolUsage } from "../../types/api.js";
|
|
13
13
|
|
|
14
14
|
export interface ModelOption {
|
|
15
15
|
id: string;
|
|
@@ -20,6 +20,12 @@ export interface ModelOption {
|
|
|
20
20
|
isDefault?: boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export interface BranchDivergence {
|
|
24
|
+
ahead: number;
|
|
25
|
+
behind: number;
|
|
26
|
+
upToDate: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
export interface BranchInfo {
|
|
24
30
|
name: string;
|
|
25
31
|
type: "local" | "remote";
|
|
@@ -39,6 +45,9 @@ export interface BranchInfo {
|
|
|
39
45
|
mergedPR?: { number: number; mergedAt: string };
|
|
40
46
|
latestCommitTimestamp?: number;
|
|
41
47
|
lastToolUsage?: LastToolUsage | null;
|
|
48
|
+
upstream?: string | null;
|
|
49
|
+
divergence?: BranchDivergence | null;
|
|
50
|
+
hasRemoteCounterpart?: boolean;
|
|
42
51
|
}
|
|
43
52
|
|
|
44
53
|
export interface BranchChoice {
|
|
@@ -132,7 +141,7 @@ export interface WorktreeWithPR {
|
|
|
132
141
|
pullRequest: PullRequest | null;
|
|
133
142
|
}
|
|
134
143
|
|
|
135
|
-
export type CleanupReason = "
|
|
144
|
+
export type CleanupReason = "no-diff-with-base" | "remote-synced";
|
|
136
145
|
|
|
137
146
|
export interface CleanupTarget {
|
|
138
147
|
worktreePath: string | null; // null for local branch only cleanup
|
|
@@ -173,7 +182,6 @@ export interface GitHubPRResponse {
|
|
|
173
182
|
*/
|
|
174
183
|
export type ScreenType =
|
|
175
184
|
| "branch-list"
|
|
176
|
-
| "worktree-manager"
|
|
177
185
|
| "branch-creator"
|
|
178
186
|
| "branch-action-selector"
|
|
179
187
|
| "ai-tool-selector"
|
|
@@ -201,6 +209,14 @@ export interface Screen {
|
|
|
201
209
|
*/
|
|
202
210
|
export type WorktreeStatus = "active" | "inaccessible" | undefined;
|
|
203
211
|
|
|
212
|
+
export type SyncStatus =
|
|
213
|
+
| "up-to-date"
|
|
214
|
+
| "ahead"
|
|
215
|
+
| "behind"
|
|
216
|
+
| "diverged"
|
|
217
|
+
| "no-upstream"
|
|
218
|
+
| "remote-only";
|
|
219
|
+
|
|
204
220
|
export interface BranchItem extends BranchInfo {
|
|
205
221
|
// Display properties
|
|
206
222
|
icons: string[];
|
|
@@ -209,6 +225,9 @@ export interface BranchItem extends BranchInfo {
|
|
|
209
225
|
label: string;
|
|
210
226
|
value: string;
|
|
211
227
|
lastToolUsageLabel?: string | null;
|
|
228
|
+
syncStatus?: SyncStatus;
|
|
229
|
+
syncInfo?: string | undefined;
|
|
230
|
+
remoteName?: string | undefined;
|
|
212
231
|
}
|
|
213
232
|
|
|
214
233
|
/**
|
|
@@ -25,23 +25,38 @@ const worktreeIcons: Record<Exclude<WorktreeStatus, undefined>, string> = {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
const changeIcons = {
|
|
28
|
-
current: "
|
|
29
|
-
hasChanges: "
|
|
30
|
-
unpushed: "
|
|
31
|
-
openPR: "
|
|
28
|
+
current: "👉",
|
|
29
|
+
hasChanges: "💾",
|
|
30
|
+
unpushed: "📤",
|
|
31
|
+
openPR: "🔃",
|
|
32
32
|
mergedPR: "✅",
|
|
33
33
|
warning: "⚠️",
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
const remoteIcon = "☁";
|
|
37
37
|
|
|
38
|
+
// Sync status icons
|
|
39
|
+
const syncIcons = {
|
|
40
|
+
upToDate: "✓",
|
|
41
|
+
ahead: "↑",
|
|
42
|
+
behind: "↓",
|
|
43
|
+
diverged: "↕",
|
|
44
|
+
none: "-",
|
|
45
|
+
remoteOnly: "☁",
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Remote column markers
|
|
49
|
+
const remoteMarkers = {
|
|
50
|
+
tracked: "🔗", // ローカル+同名リモートあり
|
|
51
|
+
localOnly: "💻", // ローカルのみ(リモートなし)
|
|
52
|
+
remoteOnly: "☁️", // リモートのみ(ローカルなし)
|
|
53
|
+
};
|
|
54
|
+
|
|
38
55
|
// Emoji width varies by terminal. Provide explicit minimum widths so we never
|
|
39
56
|
// underestimate and accidentally push the row past the terminal columns.
|
|
40
57
|
const iconWidthOverrides: Record<string, number> = {
|
|
41
58
|
// Remote icon
|
|
42
59
|
[remoteIcon]: 1,
|
|
43
|
-
// Unpushed icon
|
|
44
|
-
"⬆": 1,
|
|
45
60
|
// Branch type icons
|
|
46
61
|
"⚡": 1,
|
|
47
62
|
"✨": 1,
|
|
@@ -53,11 +68,16 @@ const iconWidthOverrides: Record<string, number> = {
|
|
|
53
68
|
"🟢": 1,
|
|
54
69
|
"🟠": 1,
|
|
55
70
|
// Change status icons
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
71
|
+
"👉": 1,
|
|
72
|
+
"💾": 1,
|
|
73
|
+
"📤": 1,
|
|
74
|
+
"🔃": 1,
|
|
59
75
|
"✅": 1,
|
|
60
76
|
"⚠️": 1,
|
|
77
|
+
// Remote markers
|
|
78
|
+
"🔗": 1,
|
|
79
|
+
"💻": 1,
|
|
80
|
+
"☁️": 1,
|
|
61
81
|
};
|
|
62
82
|
|
|
63
83
|
const getIconWidth = (icon: string): number => {
|
|
@@ -79,15 +99,6 @@ function mapToolLabel(toolId: string, toolLabel?: string): string {
|
|
|
79
99
|
return "Custom";
|
|
80
100
|
}
|
|
81
101
|
|
|
82
|
-
function mapModeLabel(
|
|
83
|
-
mode?: "normal" | "continue" | "resume" | null,
|
|
84
|
-
): string | null {
|
|
85
|
-
if (mode === "normal") return "New";
|
|
86
|
-
if (mode === "continue") return "Continue";
|
|
87
|
-
if (mode === "resume") return "Resume";
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
102
|
function formatTimestamp(ts: number): string {
|
|
92
103
|
const date = new Date(ts);
|
|
93
104
|
const year = date.getFullYear();
|
|
@@ -103,12 +114,8 @@ function buildLastToolUsageLabel(
|
|
|
103
114
|
): string | null {
|
|
104
115
|
if (!usage) return null;
|
|
105
116
|
const toolText = mapToolLabel(usage.toolId, usage.toolLabel);
|
|
106
|
-
const modeText = mapModeLabel(usage.mode);
|
|
107
117
|
const timestamp = usage.timestamp ? formatTimestamp(usage.timestamp) : null;
|
|
108
118
|
const parts = [toolText];
|
|
109
|
-
if (modeText) {
|
|
110
|
-
parts.push(modeText);
|
|
111
|
-
}
|
|
112
119
|
if (timestamp) {
|
|
113
120
|
parts.push(timestamp);
|
|
114
121
|
}
|
|
@@ -168,17 +175,81 @@ export function formatBranchItem(
|
|
|
168
175
|
changesIcon = " ".repeat(COLUMN_WIDTH);
|
|
169
176
|
}
|
|
170
177
|
|
|
171
|
-
// Column 4: Remote
|
|
172
|
-
let
|
|
178
|
+
// Column 4: Remote status (✓ for tracked, L for local-only, R for remote-only)
|
|
179
|
+
let remoteStatusStr: string;
|
|
180
|
+
if (branch.type === "remote") {
|
|
181
|
+
// リモートのみのブランチ
|
|
182
|
+
remoteStatusStr = padIcon(remoteMarkers.remoteOnly);
|
|
183
|
+
} else if (branch.hasRemoteCounterpart) {
|
|
184
|
+
// ローカルブランチで同名リモートあり
|
|
185
|
+
remoteStatusStr = padIcon(remoteMarkers.tracked);
|
|
186
|
+
} else {
|
|
187
|
+
// ローカルブランチでリモートなし
|
|
188
|
+
remoteStatusStr = padIcon(remoteMarkers.localOnly);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Column 5: Sync status (=, ↑N, ↓N, ↕, -)
|
|
192
|
+
// 5文字固定幅(アイコン1文字 + 数字最大4桁)、9999超は「9999+」表示
|
|
193
|
+
const SYNC_COLUMN_WIDTH = 6; // アイコン1 + 数字4 + スペース1
|
|
194
|
+
|
|
195
|
+
// 数字を4桁以内にフォーマット(9999超は9999+)
|
|
196
|
+
const formatSyncNumber = (n: number): string => {
|
|
197
|
+
if (n > 9999) return "9999+";
|
|
198
|
+
return String(n);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// Sync列を固定幅でパディング
|
|
202
|
+
const padSyncColumn = (content: string): string => {
|
|
203
|
+
const width = stringWidth(content);
|
|
204
|
+
const padding = Math.max(0, SYNC_COLUMN_WIDTH - width);
|
|
205
|
+
return content + " ".repeat(padding);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
let syncStatusStr: string;
|
|
209
|
+
if (branch.type === "remote") {
|
|
210
|
+
// リモートのみ → 比較不可
|
|
211
|
+
syncStatusStr = padSyncColumn(syncIcons.none);
|
|
212
|
+
} else if (branch.divergence) {
|
|
213
|
+
const { ahead, behind, upToDate } = branch.divergence;
|
|
214
|
+
if (upToDate) {
|
|
215
|
+
syncStatusStr = padSyncColumn(syncIcons.upToDate);
|
|
216
|
+
} else if (ahead > 0 && behind > 0) {
|
|
217
|
+
// diverged: ↕ のみ表示(詳細は別途表示可能)
|
|
218
|
+
syncStatusStr = padSyncColumn(syncIcons.diverged);
|
|
219
|
+
} else if (ahead > 0) {
|
|
220
|
+
// ahead: ↑N の形式
|
|
221
|
+
syncStatusStr = padSyncColumn(
|
|
222
|
+
`${syncIcons.ahead}${formatSyncNumber(ahead)}`,
|
|
223
|
+
);
|
|
224
|
+
} else {
|
|
225
|
+
// behind: ↓N の形式
|
|
226
|
+
syncStatusStr = padSyncColumn(
|
|
227
|
+
`${syncIcons.behind}${formatSyncNumber(behind)}`,
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
} else {
|
|
231
|
+
// divergence情報なし
|
|
232
|
+
syncStatusStr = padSyncColumn(syncIcons.none);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Build Local/Remote name for display
|
|
236
|
+
// ローカルブランチ: ブランチ名を表示
|
|
237
|
+
// リモートのみ: origin/xxxをフル表示
|
|
238
|
+
let displayName: string;
|
|
239
|
+
let remoteName: string | null = null;
|
|
240
|
+
|
|
173
241
|
if (branch.type === "remote") {
|
|
174
|
-
|
|
242
|
+
// リモートのみのブランチ: フルのリモートブランチ名を表示
|
|
243
|
+
displayName = branch.name; // origin/xxx
|
|
244
|
+
remoteName = branch.name;
|
|
175
245
|
} else {
|
|
176
|
-
|
|
246
|
+
// ローカルブランチ: ブランチ名を表示
|
|
247
|
+
displayName = branch.name;
|
|
177
248
|
}
|
|
178
249
|
|
|
179
250
|
// Build label with fixed-width columns
|
|
180
|
-
// Format: [Type][Worktree][Changes][Remote]
|
|
181
|
-
const label = `${branchTypeIcon}${worktreeIcon}${changesIcon}${
|
|
251
|
+
// Format: [Type][Worktree][Changes][Remote][Sync] DisplayName
|
|
252
|
+
const label = `${branchTypeIcon}${worktreeIcon}${changesIcon}${remoteStatusStr}${syncStatusStr}${displayName}`;
|
|
182
253
|
|
|
183
254
|
// Collect icons for compatibility
|
|
184
255
|
const icons: string[] = [];
|
|
@@ -208,6 +279,27 @@ export function formatBranchItem(
|
|
|
208
279
|
icons.push(remoteIcon);
|
|
209
280
|
}
|
|
210
281
|
|
|
282
|
+
// Determine sync status for BranchItem
|
|
283
|
+
let syncStatus: BranchItem["syncStatus"];
|
|
284
|
+
if (branch.type === "remote") {
|
|
285
|
+
syncStatus = "remote-only";
|
|
286
|
+
} else if (!branch.hasRemoteCounterpart) {
|
|
287
|
+
syncStatus = "no-upstream";
|
|
288
|
+
} else if (branch.divergence) {
|
|
289
|
+
const { ahead, behind, upToDate } = branch.divergence;
|
|
290
|
+
if (upToDate) {
|
|
291
|
+
syncStatus = "up-to-date";
|
|
292
|
+
} else if (ahead > 0 && behind > 0) {
|
|
293
|
+
syncStatus = "diverged";
|
|
294
|
+
} else if (ahead > 0) {
|
|
295
|
+
syncStatus = "ahead";
|
|
296
|
+
} else {
|
|
297
|
+
syncStatus = "behind";
|
|
298
|
+
}
|
|
299
|
+
} else {
|
|
300
|
+
syncStatus = "no-upstream";
|
|
301
|
+
}
|
|
302
|
+
|
|
211
303
|
return {
|
|
212
304
|
// Copy all properties from BranchInfo
|
|
213
305
|
...branch,
|
|
@@ -218,6 +310,9 @@ export function formatBranchItem(
|
|
|
218
310
|
label,
|
|
219
311
|
value: branch.name,
|
|
220
312
|
lastToolUsageLabel: buildLastToolUsageLabel(branch.lastToolUsage),
|
|
313
|
+
syncStatus,
|
|
314
|
+
syncInfo: undefined,
|
|
315
|
+
remoteName: remoteName ?? undefined,
|
|
221
316
|
};
|
|
222
317
|
}
|
|
223
318
|
|
|
@@ -11,11 +11,7 @@ describe("modelOptions", () => {
|
|
|
11
11
|
it("lists Claude official aliases and sets Opus 4.5 as default", () => {
|
|
12
12
|
const options = getModelOptions("claude-code");
|
|
13
13
|
const ids = options.map((m) => m.id);
|
|
14
|
-
expect(ids).toEqual([
|
|
15
|
-
"opus",
|
|
16
|
-
"sonnet",
|
|
17
|
-
"haiku",
|
|
18
|
-
]);
|
|
14
|
+
expect(ids).toEqual(["opus", "sonnet", "haiku"]);
|
|
19
15
|
const defaultModel = getDefaultModelOption("claude-code");
|
|
20
16
|
expect(defaultModel?.id).toBe("opus");
|
|
21
17
|
expect(defaultModel?.label).toBe("Opus 4.5");
|
|
@@ -34,7 +30,9 @@ describe("modelOptions", () => {
|
|
|
34
30
|
});
|
|
35
31
|
|
|
36
32
|
it("uses medium as default reasoning for codex-max", () => {
|
|
37
|
-
const codexMax = getModelOptions("codex-cli").find(
|
|
33
|
+
const codexMax = getModelOptions("codex-cli").find(
|
|
34
|
+
(m) => m.id === "gpt-5.1-codex-max",
|
|
35
|
+
);
|
|
38
36
|
expect(getDefaultInferenceForModel(codexMax)).toBe("medium");
|
|
39
37
|
});
|
|
40
38
|
|
package/src/config/index.ts
CHANGED
|
@@ -136,7 +136,8 @@ export async function saveSession(sessionData: SessionData): Promise<void> {
|
|
|
136
136
|
branch: sessionData.lastBranch,
|
|
137
137
|
worktreePath: sessionData.lastWorktreePath,
|
|
138
138
|
toolId: sessionData.lastUsedTool ?? "unknown",
|
|
139
|
-
toolLabel:
|
|
139
|
+
toolLabel:
|
|
140
|
+
sessionData.toolLabel ?? sessionData.lastUsedTool ?? "Custom",
|
|
140
141
|
mode: sessionData.mode ?? null,
|
|
141
142
|
model: sessionData.model ?? null,
|
|
142
143
|
timestamp: sessionData.timestamp,
|
package/src/git.ts
CHANGED
|
@@ -174,11 +174,9 @@ export async function getWorktreeRoot(): Promise<string> {
|
|
|
174
174
|
export async function getCurrentBranch(): Promise<string | null> {
|
|
175
175
|
try {
|
|
176
176
|
const repoRoot = await getRepositoryRoot();
|
|
177
|
-
const { stdout } = await execa(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
{ cwd: repoRoot },
|
|
181
|
-
);
|
|
177
|
+
const { stdout } = await execa("git", ["branch", "--show-current"], {
|
|
178
|
+
cwd: repoRoot,
|
|
179
|
+
});
|
|
182
180
|
return stdout.trim() || null;
|
|
183
181
|
} catch {
|
|
184
182
|
try {
|
|
@@ -195,11 +193,15 @@ async function getBranchCommitTimestamps(
|
|
|
195
193
|
cwd?: string,
|
|
196
194
|
): Promise<Map<string, number>> {
|
|
197
195
|
try {
|
|
198
|
-
const { stdout = "" } = (await execa(
|
|
199
|
-
"
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
196
|
+
const { stdout = "" } = (await execa(
|
|
197
|
+
"git",
|
|
198
|
+
[
|
|
199
|
+
"for-each-ref",
|
|
200
|
+
"--format=%(refname:short)%00%(committerdate:unix)",
|
|
201
|
+
...refs,
|
|
202
|
+
],
|
|
203
|
+
cwd ? { cwd } : undefined,
|
|
204
|
+
)) ?? { stdout: "" };
|
|
203
205
|
|
|
204
206
|
const map = new Map<string, number>();
|
|
205
207
|
|
|
@@ -222,9 +224,10 @@ async function getBranchCommitTimestamps(
|
|
|
222
224
|
export async function getLocalBranches(): Promise<BranchInfo[]> {
|
|
223
225
|
try {
|
|
224
226
|
const commitMap = await getBranchCommitTimestamps(["refs/heads"]);
|
|
225
|
-
const { stdout = "" } =
|
|
226
|
-
|
|
227
|
-
|
|
227
|
+
const { stdout = "" } = (await execa("git", [
|
|
228
|
+
"branch",
|
|
229
|
+
"--format=%(refname:short)",
|
|
230
|
+
])) ?? { stdout: "" };
|
|
228
231
|
return stdout
|
|
229
232
|
.split("\n")
|
|
230
233
|
.filter((line) => line.trim())
|
|
@@ -250,9 +253,11 @@ export async function getLocalBranches(): Promise<BranchInfo[]> {
|
|
|
250
253
|
export async function getRemoteBranches(): Promise<BranchInfo[]> {
|
|
251
254
|
try {
|
|
252
255
|
const commitMap = await getBranchCommitTimestamps(["refs/remotes"]);
|
|
253
|
-
const { stdout = "" } =
|
|
254
|
-
|
|
255
|
-
|
|
256
|
+
const { stdout = "" } = (await execa("git", [
|
|
257
|
+
"branch",
|
|
258
|
+
"-r",
|
|
259
|
+
"--format=%(refname:short)",
|
|
260
|
+
])) ?? { stdout: "" };
|
|
256
261
|
return stdout
|
|
257
262
|
.split("\n")
|
|
258
263
|
.filter((line) => line.trim() && !line.includes("HEAD"))
|
|
@@ -299,6 +304,41 @@ export async function getAllBranches(): Promise<BranchInfo[]> {
|
|
|
299
304
|
return [...localBranches, ...remoteBranches];
|
|
300
305
|
}
|
|
301
306
|
|
|
307
|
+
/**
|
|
308
|
+
* ローカルブランチのupstream(追跡ブランチ)情報を取得
|
|
309
|
+
* @param cwd - 作業ディレクトリ(省略時はリポジトリルート)
|
|
310
|
+
* @returns Map<ローカルブランチ名, upstreamブランチ名>
|
|
311
|
+
*/
|
|
312
|
+
export async function collectUpstreamMap(
|
|
313
|
+
cwd?: string,
|
|
314
|
+
): Promise<Map<string, string>> {
|
|
315
|
+
const workDir = cwd ?? (await getRepositoryRoot());
|
|
316
|
+
try {
|
|
317
|
+
const { stdout } = await execa(
|
|
318
|
+
"git",
|
|
319
|
+
[
|
|
320
|
+
"for-each-ref",
|
|
321
|
+
"--format=%(refname:short)|%(upstream:short)",
|
|
322
|
+
"refs/heads",
|
|
323
|
+
],
|
|
324
|
+
{ cwd: workDir },
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
return stdout
|
|
328
|
+
.split("\n")
|
|
329
|
+
.filter((line) => line.includes("|"))
|
|
330
|
+
.reduce((map, line) => {
|
|
331
|
+
const [branch, upstream] = line.split("|");
|
|
332
|
+
if (branch?.trim() && upstream?.trim()) {
|
|
333
|
+
map.set(branch.trim(), upstream.trim());
|
|
334
|
+
}
|
|
335
|
+
return map;
|
|
336
|
+
}, new Map<string, string>());
|
|
337
|
+
} catch {
|
|
338
|
+
return new Map();
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
302
342
|
export async function createBranch(
|
|
303
343
|
branchName: string,
|
|
304
344
|
baseBranch = "main",
|
|
@@ -425,17 +425,22 @@ export function BranchDetailPage() {
|
|
|
425
425
|
worktreePath: branch.worktreePath ?? null,
|
|
426
426
|
toolId:
|
|
427
427
|
first.toolType === "custom"
|
|
428
|
-
? first.toolName ?? "custom"
|
|
428
|
+
? (first.toolName ?? "custom")
|
|
429
429
|
: (first.toolType as LastToolUsage["toolId"]),
|
|
430
430
|
toolLabel:
|
|
431
431
|
first.toolType === "custom"
|
|
432
|
-
? first.toolName ?? "Custom"
|
|
432
|
+
? (first.toolName ?? "Custom")
|
|
433
433
|
: toolLabel(first.toolType),
|
|
434
434
|
mode: first.mode ?? "normal",
|
|
435
435
|
model: null,
|
|
436
436
|
timestamp: first.startedAt ? Date.parse(first.startedAt) : Date.now(),
|
|
437
437
|
};
|
|
438
|
-
}, [
|
|
438
|
+
}, [
|
|
439
|
+
branch?.lastToolUsage,
|
|
440
|
+
branch?.name,
|
|
441
|
+
branch?.worktreePath,
|
|
442
|
+
branchSessions,
|
|
443
|
+
]);
|
|
439
444
|
|
|
440
445
|
const handleSessionExit = (code: number) => {
|
|
441
446
|
setActiveSessionId(null);
|
|
@@ -57,9 +57,13 @@ export async function registerSessionRoutes(
|
|
|
57
57
|
|
|
58
58
|
// 履歴を永続化(best-effort)
|
|
59
59
|
try {
|
|
60
|
-
const { stdout: repoRoot } = await execa(
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
const { stdout: repoRoot } = await execa(
|
|
61
|
+
"git",
|
|
62
|
+
["rev-parse", "--show-toplevel"],
|
|
63
|
+
{
|
|
64
|
+
cwd: worktreePath,
|
|
65
|
+
},
|
|
66
|
+
);
|
|
63
67
|
let branchName: string | null = null;
|
|
64
68
|
try {
|
|
65
69
|
const { stdout: branchStdout } = await execa(
|
|
@@ -75,9 +79,12 @@ export async function registerSessionRoutes(
|
|
|
75
79
|
await saveSession({
|
|
76
80
|
lastWorktreePath: worktreePath,
|
|
77
81
|
lastBranch: branchName,
|
|
78
|
-
lastUsedTool:
|
|
82
|
+
lastUsedTool:
|
|
83
|
+
toolType === "custom" ? (toolName ?? "custom") : toolType,
|
|
79
84
|
toolLabel:
|
|
80
|
-
toolType === "custom"
|
|
85
|
+
toolType === "custom"
|
|
86
|
+
? (toolName ?? "Custom")
|
|
87
|
+
: toolLabelFromType(toolType),
|
|
81
88
|
mode,
|
|
82
89
|
timestamp: Date.now(),
|
|
83
90
|
repositoryRoot: repoRoot.trim(),
|