Skip to content

Handle non-git drafts in local mode#1930

Open
SAKETH11111 wants to merge 2 commits intopingdotgg:mainfrom
SAKETH11111:fix-non-git-draft-local-mode
Open

Handle non-git drafts in local mode#1930
SAKETH11111 wants to merge 2 commits intopingdotgg:mainfrom
SAKETH11111:fix-non-git-draft-local-mode

Conversation

@SAKETH11111
Copy link
Copy Markdown

@SAKETH11111 SAKETH11111 commented Apr 11, 2026

Closes #1914

What was broken

Draft threads could stay in New worktree mode for directories that are not Git repositories. On the first send, that pushed users into the base-branch guard even though the project could only run locally.

Root cause

The draft env-mode resolver treated persisted worktree mode as authoritative without considering the active project's Git status, so non-git drafts kept a worktree-only send path.

What changed

  • fall back to local mode when the active project is known to be non-git
  • normalize draft thread state away from stale worktree metadata for non-git projects
  • add regression coverage for the shared env-mode resolver and the browser send flow

Note

Handle non-git projects in local draft mode by falling back from worktree to local send

  • resolveEffectiveEnvMode in BranchToolbar.logic.ts gains an optional isGitRepo flag; when false, it returns 'local' regardless of the draft's persisted mode.
  • Local drafts on non-git projects automatically reset their thread context to local mode (null branch and worktree path) via a new useEffect in ChatView.tsx.
  • Before enforcing the base-branch requirement on a first worktree-mode message, ChatView now calls refreshGitStatus; if the project is not a git repo, it falls back to a local send and skips prepareWorktree.
  • Behavioral Change: drafts saved in worktree mode will silently send as local when the project is not a git repo.

Macroscope summarized f56bf0c.


Note

Medium Risk
Touches the first-send dispatch path and draft thread state normalization for worktree creation, which could affect message sending/worktree bootstrapping behavior. Changes are scoped and covered by new unit + browser regression tests but still impact a core interaction flow.

Overview
Fixes drafts getting stuck in New worktree mode for non-git projects by making env-mode resolution explicitly fall back to local when isRepo is false, even if worktree was persisted.

Normalizes local draft thread state when git status indicates a non-repo (clearing branch/worktreePath and forcing envMode: "local"), and updates the send flow to refresh git status before enforcing the worktree base-branch guard—falling back to local dispatch (or persisting the detected branch) based on the refreshed result.

Adds regression coverage in BranchToolbar.logic tests and full-app ChatView.browser tests for non-git fallback and the pending-status refresh race.

Reviewed by Cursor Bugbot for commit f56bf0c. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 11, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f2215670-c9f7-43f4-8550-d674cdb5c5e6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Apr 11, 2026
@SAKETH11111 SAKETH11111 force-pushed the fix-non-git-draft-local-mode branch from 8f78b0a to 6aa1871 Compare April 11, 2026 15:08
@github-actions github-actions bot added size:M 30-99 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Apr 11, 2026
@SAKETH11111 SAKETH11111 marked this pull request as ready for review April 12, 2026 21:04
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 12, 2026

Approvability

Verdict: Needs human review

This PR modifies runtime behavior in the message send flow by adding git status checks and fallback logic for non-git projects. While the changes are well-tested and the edge case handling is sensible, the modifications to critical path code (message sending) warrant human review to verify the interaction with existing worktree/local mode logic.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Can't launch thread in non git directory, when new worktree is set to default.

1 participant