Allow empty server threads to bootstrap new worktrees#1936
Allow empty server threads to bootstrap new worktrees#1936juliusmarminge merged 5 commits intomainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Pending override state leaks between empty server threads
- Added a ref to track the previous thread ID so the cleanup effect resets pendingServerThreadEnvMode and pendingServerThreadBranch whenever activeThread.id changes, even when canOverrideServerThreadEnvMode remains true for both threads.
Or push these changes by commenting:
@cursor push a440ab779e
Preview (a440ab779e)
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -2228,12 +2228,15 @@
isGitRepo,
});
+ const prevThreadIdForPendingReset = useRef(activeThread?.id);
useEffect(() => {
- if (canOverrideServerThreadEnvMode) {
- return;
+ const threadChanged = prevThreadIdForPendingReset.current !== activeThread?.id;
+ prevThreadIdForPendingReset.current = activeThread?.id;
+
+ if (threadChanged || !canOverrideServerThreadEnvMode) {
+ setPendingServerThreadEnvMode(null);
+ setPendingServerThreadBranch(undefined);
}
- setPendingServerThreadEnvMode(null);
- setPendingServerThreadBranch(undefined);
}, [canOverrideServerThreadEnvMode, activeThread?.id]);
useEffect(() => {You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 9efc9f9. Configure here.
ApprovabilityVerdict: Needs human review This PR introduces new feature capability allowing empty server threads to be configured for worktree mode before the first message is sent. While well-tested and the code is reasonable, this changes runtime behavior for thread bootstrapping workflows and introduces new user-facing functionality that warrants human review. You can customize Macroscope's approvability policy. Learn more. |
- Let the first send on an empty server thread override env mode and base branch - Use shorter locked workspace labels in the branch toolbar - Add coverage for worktree bootstrap and env-mode resolution
9efc9f9 to
db1833b
Compare
- Clear staged server thread env/branch overrides when the active thread changes - Add regression coverage for switching between empty server threads
- Move worktree branch prefix and matcher into shared git utils - Add coverage for temporary branch detection
- Generate temp worktree branch names in `packages/shared` - Update the web chat view to use the shared helper - Add coverage for the generated branch format


Summary
New worktreemode and bootstrap the first send without forcing a separate draft thread.Testing
bun fmtbun lintbun typecheckbun run testapps/web/src/components/ChatView.browser.tsxfor:New worktreemode from an empty server threadNote
Medium Risk
Medium risk because it changes first-send behavior and branch/env-mode selection for server threads, which affects worktree creation and command dispatch paths; mistakes could create worktrees off the wrong base branch or leave UI state inconsistent.
Overview
Enables empty server threads (no messages, no worktree) to temporarily opt into
New worktreemode, select a base branch in the toolbar, and have that choice used to bootstrap worktree creation on the first send (via pending overrides cleared on thread switch / when no longer eligible).Extracts temporary-worktree branch utilities into
@t3tools/shared/git(WORKTREE_BRANCH_PREFIX,buildTemporaryWorktreeBranchName,isTemporaryWorktreeBranch) and updates server/web to use them, while addingresolveSendEnvModeto forcelocalsends for non-git repos.UI/UX tweaks: introduces
resolveLockedWorkspaceLabelso locked workspace state shows shorter labels, and expands unit + browser tests to cover the new first-send bootstrap and override-reset flows.Reviewed by Cursor Bugbot for commit ae19339. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Allow empty server threads to bootstrap new worktrees with a user-selected base branch
pendingServerThreadEnvModeandpendingServerThreadBranchstate toChatView.tsxso empty server threads can remain in 'New worktree' mode before the first message is sent.prepareWorktreeusing a temporaryt3code/<8-hex>branch name generated by the newbuildTemporaryWorktreeBranchNamehelper inpackages/shared/src/git.ts.WORKTREE_BRANCH_PREFIX,buildTemporaryWorktreeBranchName, andisTemporaryWorktreeBranchinto the sharedgitmodule, removing duplicate definitions fromChatView.logic.tsandProviderCommandReactor.ts.resolveSendEnvModeinChatView.logic.tsto force non-git repositories to'local'mode regardless of the user's selected env mode.BranchToolbarandBranchToolbarBranchSelectorto accept override props for env mode and active branch, enabling the pre-send selection UI for empty server threads.Macroscope summarized ae19339.