Skip to content

Commit be5423e

Browse files
committed
fix: rename git branch during workspace rename, handle creating status
Two fixes: 1. WorktreeRuntime.renameWorkspace now renames the git branch via `git branch -m` after moving the worktree directory. Previously only the directory was moved, leaving the branch with the old name. 2. ReviewPanel shows a loading state when workspace status is 'creating'. This prevents errors when the panel tries to run git commands on a workspace that doesn't exist on disk yet. Props added: AIView.status, RightSidebar.isCreating, ReviewPanel.isCreating
1 parent 38d07ca commit be5423e

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

src/browser/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ function AppInner() {
589589
namedWorkspacePath={selectedWorkspace.namedWorkspacePath ?? ""}
590590
runtimeConfig={currentMetadata?.runtimeConfig}
591591
incompatibleRuntime={currentMetadata?.incompatibleRuntime}
592+
status={currentMetadata?.status}
592593
/>
593594
</ErrorBoundary>
594595
);

src/browser/components/AIView.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ interface AIViewProps {
5555
className?: string;
5656
/** If set, workspace is incompatible (from newer mux version) and this error should be displayed */
5757
incompatibleRuntime?: string;
58+
/** If 'creating', workspace is still being set up (git operations in progress) */
59+
status?: "creating";
5860
}
5961

6062
const AIViewInner: React.FC<AIViewProps> = ({
@@ -65,6 +67,7 @@ const AIViewInner: React.FC<AIViewProps> = ({
6567
namedWorkspacePath,
6668
runtimeConfig,
6769
className,
70+
status,
6871
}) => {
6972
const { api } = useAPI();
7073
const chatAreaRef = useRef<HTMLDivElement>(null);
@@ -637,6 +640,7 @@ const AIViewInner: React.FC<AIViewProps> = ({
637640
onStartResize={isReviewTabActive ? startResize : undefined} // Pass resize handler when Review active
638641
isResizing={isResizing} // Pass resizing state
639642
onReviewNote={handleReviewNote} // Pass review note handler to append to chat
643+
isCreating={status === "creating"} // Workspace still being set up
640644
/>
641645
</div>
642646
);

src/browser/components/RightSidebar.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ interface RightSidebarProps {
8484
isResizing?: boolean;
8585
/** Callback when user adds a review note from Code Review tab */
8686
onReviewNote?: (note: string) => void;
87+
/** Workspace is still being created (git operations in progress) */
88+
isCreating?: boolean;
8789
}
8890

8991
const RightSidebarComponent: React.FC<RightSidebarProps> = ({
@@ -95,6 +97,7 @@ const RightSidebarComponent: React.FC<RightSidebarProps> = ({
9597
onStartResize,
9698
isResizing = false,
9799
onReviewNote,
100+
isCreating = false,
98101
}) => {
99102
// Global tab preference (not per-workspace)
100103
const [selectedTab, setSelectedTab] = usePersistedState<TabType>("right-sidebar-tab", "costs");
@@ -298,6 +301,7 @@ const RightSidebarComponent: React.FC<RightSidebarProps> = ({
298301
workspacePath={workspacePath}
299302
onReviewNote={onReviewNote}
300303
focusTrigger={focusTrigger}
304+
isCreating={isCreating}
301305
/>
302306
</div>
303307
)}

src/browser/components/RightSidebar/CodeReview/ReviewPanel.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ interface ReviewPanelProps {
4545
onReviewNote?: (note: string) => void;
4646
/** Trigger to focus panel (increment to trigger) */
4747
focusTrigger?: number;
48+
/** Workspace is still being created (git operations in progress) */
49+
isCreating?: boolean;
4850
}
4951

5052
interface ReviewSearchState {
@@ -120,6 +122,7 @@ export const ReviewPanel: React.FC<ReviewPanelProps> = ({
120122
workspacePath,
121123
onReviewNote,
122124
focusTrigger,
125+
isCreating = false,
123126
}) => {
124127
const { api } = useAPI();
125128
const panelRef = useRef<HTMLDivElement>(null);
@@ -618,6 +621,17 @@ export const ReviewPanel: React.FC<ReviewPanelProps> = ({
618621
return () => window.removeEventListener("keydown", handleKeyDown);
619622
}, []);
620623

624+
// Show loading state while workspace is being created
625+
if (isCreating) {
626+
return (
627+
<div className="flex h-full flex-col items-center justify-center p-8 text-center">
628+
<div className="mb-4 text-2xl"></div>
629+
<p className="text-secondary text-sm">Setting up workspace...</p>
630+
<p className="text-secondary mt-1 text-xs">Review will be available once ready</p>
631+
</div>
632+
);
633+
}
634+
621635
return (
622636
<div
623637
ref={panelRef}

src/node/runtime/WorktreeRuntime.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,18 @@ export class WorktreeRuntime extends LocalBaseRuntime {
177177
const newPath = this.getWorkspacePath(projectPath, newName);
178178

179179
try {
180-
// Use git worktree move to rename the worktree directory
181-
// This updates git's internal worktree metadata correctly
182-
using proc = execAsync(`git -C "${projectPath}" worktree move "${oldPath}" "${newPath}"`);
183-
await proc.result;
180+
// Move the worktree directory (updates git's internal worktree metadata)
181+
using moveProc = execAsync(`git -C "${projectPath}" worktree move "${oldPath}" "${newPath}"`);
182+
await moveProc.result;
183+
184+
// Rename the git branch to match the new workspace name
185+
// Run from the new worktree path since that's where the branch is checked out
186+
using branchProc = execAsync(`git -C "${newPath}" branch -m "${oldName}" "${newName}"`);
187+
await branchProc.result;
184188

185189
return { success: true, oldPath, newPath };
186190
} catch (error) {
187-
return { success: false, error: `Failed to move worktree: ${getErrorMessage(error)}` };
191+
return { success: false, error: `Failed to rename workspace: ${getErrorMessage(error)}` };
188192
}
189193
}
190194

0 commit comments

Comments
 (0)