Skip to content

fix(mobile): fall back to current checkout for non-git projects - #7927

Closed
andybergon wants to merge 4 commits into
pingdotgg:mainfrom
andybergon:fix/mobile-non-git-worktree-fallback
Closed

andybergon wants to merge 4 commits into
pingdotgg:mainfrom
andybergon:fix/mobile-non-git-worktree-fallback

Conversation

@andybergon

@andybergon andybergon commented Aug 22, 2026 •

Copy link
Copy Markdown

Closes #7926

Android before and after

Before After
Before: New worktree leaves the branch loader active and Queue task disabled After: Current checkout is forced and the branch control is removed

Problem

With the default thread env mode set to New worktree, the mobile new-task flow cannot start a task for a project that is not a git repository: the branch control shows Choose branch with nothing to choose and Start stays disabled. Desktop already resolves this case to Current checkout through resolveSendEnvMode; mobile resolved its default without looking at the project's git status.

Fix

  • Add resolveSendableThreadEnvMode to @t3tools/shared/threadEnvMode and make the web resolveSendEnvMode delegate to it, so both clients apply the same rule.
  • Mobile new-task-flow-provider.tsx reads the project's vcs.status before resolving the workspace mode, exposes isGitRepo and gitStatusSettled, and clears stale branch and worktree metadata for a non-repository.
  • NewTaskDraftScreen.tsx applies the same fallback on the send path, disables the workspace toggle with a matching accessibility hint, and hides the branch control when the project is not a repository. A connected worktree send waits for the git status to settle instead of trusting the provisional default; offline queueing still works.
  • use-thread-outbox-drain.ts re-checks repository status before replaying a queued worktree task, bounds that query to 10 seconds so one hung read cannot block the global outbox, preserves worktree mode when status is unknown, routes known non-repositories through the shared fallback, and re-confirms the exact queued payload plus edit lock after the await so a saved edit cannot dispatch stale text or attachments.

Verification

  • Original focused suites across shared thread-env mode, web logic, mobile state, and mobile thread creation: 195 tests passed.
  • Review follow-up: vp test run packages/client-runtime/src/state/runtime.test.ts apps/mobile/src/state/thread-outbox.test.ts packages/shared/src/threadEnvMode.test.ts apps/mobile/src/features/threads/projectThreadCreationValidation.test.ts: 4 files and 55 tests passed. After the latest review, vp test run apps/mobile/src/state/thread-outbox.test.ts: 1 file and 22 tests passed.
  • Typechecks passed in packages/shared, apps/web, and apps/mobile for the original fix. Mobile and client-runtime typechecks passed again after the bounded-query review follow-up. Mobile typecheck, targeted lint, and format passed again after the stale-payload guard.
  • Reproduced the non-git project flow on the same Android emulator at 1080 x 1920. Before, New worktree leaves the branch loader active and Queue task disabled. After, Current checkout is forced and the branch control is removed.

Claude Fable 5 in Claude Code, with three Codex review passes.

🤖 Generated with Claude Code


Note

Medium Risk
Touches thread creation and outbox drain: worktree tasks can be rewritten to local after a VCS check, and query timeouts now interrupt atom queries. A hung status read can delay a queued worktree send by up to 10s.

Overview
Mobile new-task no longer gets stuck in worktree mode for projects that are not git repos. Shared resolveSendableThreadEnvMode forces local when isGitRepo is false; web resolveSendEnvMode now uses the same helper.

The composer reads VCS status, treats repo as true until status settles (to avoid a checkout flash), then hides the branch picker and disables the workspace toggle. Connected worktree sends wait for status; offline queueing still works. Stale branch/worktree metadata is cleared for non-repos.

Queued worktree creations re-check repo status on drain (10s query timeout). Known non-repos drain as local; unknown status keeps the queued mode. After the await, drain re-confirms the payload so an in-flight edit is not sent. executeAtomQuery gains optional timeoutMs.

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

Note

Fix mobile worktree mode to fall back to local for non-git projects

  • Adds shared resolveSendableThreadEnvMode which coerces worktree mode to local when isGitRepo is false; web and mobile clients route send paths through this single decision point
  • Mobile NewTaskFlowProvider queries VCS status for the selected project, exposes isGitRepo and gitStatusSettled to consumers, and clears selectedBranchName/selectedWorktreePath for non-repos
  • NewTaskDraftScreen hides the branch picker and disables the workspace toggle for non-repo projects, and blocks sending when git status is unsettled while connected
  • Outbox drain (useThreadOutboxDrain) reads VCS status with a 10s timeout before sending queued worktree messages, coercing to local and clearing branch/worktree for known non-repos; skips dispatch if the message enters edit state during the await
  • executeAtomQuery gains optional timeoutMs that interrupts the query via Effect.interrupt on timeout
  • Risk: executeAtomQuery now maps timeouts to interrupted failures — callers checking for interruption may see timeout-induced interrupts; the new 10s VCS status timeout in useThreadOutboxDrain could delay queued worktree sends by up to 10s before fallback
📊 Macroscope summarized dd7f915. 4 files reviewed, 1 issue evaluated, 0 issues filtered, 1 comment posted

🗂️ Filtered Issues

A project that is not a git repository cannot host a worktree, yet the mobile
new-task flow kept the New worktree default and disabled Start because no
base branch exists. Desktop already resolved this to local in
resolveSendEnvMode. Move that rule into @t3tools/shared so both clients share
it, apply it to the mobile draft, send, and outbox paths, and hide the branch
control when the project is not a repository.

A connected worktree send now waits for the project's git status instead of
trusting the provisional repo default, a non-repository clears stale branch
and worktree metadata, and the outbox drain re-checks the repository before
replaying a queued worktree task so it drains as local.

Closes pingdotgg#7926
@coderabbitai

coderabbitai Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

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 Plus

Run ID: 15ebb83b-df38-4216-937f-31b254838de8

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

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.

@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 Aug 22, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1664926. Configure here.

Comment thread apps/mobile/src/features/threads/new-task-flow-provider.tsx
@macroscopeapp

macroscopeapp Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 4933663

Macroscope's review found this PR approvable — The PR is a focused mobile bug fix that enables existing task creation for non-git projects, with conditional VCS checks and outbox safeguards. Existing defaults and ordinary git/local paths remain intact, and the supporting behavior is covered by targeted tests.

Notes:

  • Diff unchanged. Approvability was decided on eligibility alone.

You can add or adjust custom eligibility rules. Learn more.

Treat the skipped VCS query for a queued-task stand-in as complete so an
existing branch selection does not leave Start disabled forever.
Prevent a stalled repository query from blocking the global mobile outbox and cover queued mode fallback for known non-repositories.
Comment thread apps/mobile/src/state/use-thread-outbox-drain.ts Outdated
@t3dotgg

t3dotgg commented Sep 4, 2026

Copy link
Copy Markdown
Member

Note

🤖 GPT-6 Astra (preview) responding on behalf of Theo

This note is part of an automated cleanup pass.

Preserving these details from items reviewed in the cleanup pass.

Preserve the offline display behavior from #8791 at its head commit. Its unfiltered useBranches result keeps data.isRepo available when branch search changes or the environment goes offline. Known non-Git projects then show Current checkout and clear branch/worktree selections. Unknown capability preserves the requested mode. This cache can help the UI, but must not replace fresh send/replay validation. The retained fix still needs non-Git normalization before the branchless isQueuedThreadCreationSendable guard, or existing queued rows never reach the repair.

Carryover from #5907 at b42e30c422: once status establishes that a project is not a Git repository, disable its branchTarget and loadBranches query. Keep the non-Git selection normalization case that clears branch/worktree metadata and uses the current checkout. Unknown status must not become permission to send invalid metadata. Existing branchless worktree outbox rows must reach normalization before the sendability guard. This records the case without claiming the delivery fix is complete.

@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Sep 30, 2026 — with ChatGPT Codex Connector
@t3dotgg

t3dotgg commented Oct 1, 2026

Copy link
Copy Markdown
Member

Note

🤖 GPT-6 Astra responding on behalf of Theo

We're closing this as part of a cleanup of stale PRs. Thank you for the time and care you put into this contribution.

A local merge check found conflicts in 10 files against the current target branch. The latest implementation commit is from 2026-08-24, and there has been no contribution update in over a week.

At this point, regenerating a focused patch against the current intended base would be easier to review and maintain than updating this PR. We appreciate the work and will keep this thread as a reference. If you revisit it, please check the current direction with us and link the fresh PR back here.

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

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:L 100-499 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]: Mobile keeps New worktree default for non-git projects and cannot start a task

3 participants