Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): local-checkout threads record their branch so PR badges show #4986

MergedZeus-Deus(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/4986/headmerged by juliusmarminge View on GitHub

Fixes #4951

Problem

Creating a thread from the mobile composer with the untouched current-checkout default persisted branch: null: the local workspace mode never writes a workspaceSelection into the draft, and the automatic branch selection effect only runs for worktree mode. useThreadPr refuses to subscribe when thread.branch === null and matches on exact equality with the live status.refName, so an open PR for the work was never surfaced on the thread row — while threads with explicit branch metadata showed their badge fine.

Fix

Online creation now resolves the branch through a small pure helper, resolveProjectThreadCreationBranch: an explicit picker choice always wins; an untouched local-checkout draft records the live checkout ref; worktree mode is unchanged. The current checkout comes from the project's vcsEnvironment.status stream (refName) — the exact value the PR matcher compares against, parsed fresh per publish — not from the ref list, whose current flag is served from a server-side cache with a 10-minute TTL. The subscription is deduped per (environmentId, cwd) with the ones thread rows already open and lives only while the composer sheet is mounted.

No branch is ever fabricated: a detached HEAD, a non-repository project, or a status that has not arrived yet all resolve to null, i.e. exactly the pre-fix behavior. Nothing is written back into the draft's workspaceSelection, so the untouched default stays distinguishable from an explicit choice.

Scope note: queued/offline tasks still record only explicit choices. A queued local task drains against whatever is checked out at drain time, so recording a queue-time guess would pin a stale branch to a thread that ran somewhere else; that trade is commented at the call site.

Visible side effects: mobile-created local threads now show a branch label on their rows and become eligible for web's informational local-checkout mismatch banner, the same treatment web gives its own local threads (web self-heals the branch on next send). Composer sessions open one deduped status subscription per project cwd.

Tests

New projectThreadCreationValidation.test.ts with 5 cases: the regression (untouched local default records the checkout), explicit selection wins (local and worktree), no checked-out ref stays null, and worktree mode never borrows the checkout. Each behavior was mutation-checked (reverting it fails exactly its test). Scoped mobile typecheck, lint, and format checks are green, plus adjacent suites (thread-outbox, threadListV2, use-thread-pr — 45 tests). Verified via unit tests on Linux; no native iOS run was performed.


Implemented and reviewed with Claude Code (Fable 5).


Note

Low Risk Scoped mobile composer/thread-creation logic with a pure helper and deduped existing VCS status queries; no auth or server changes.

Overview Fixes #4951 by persisting a branch on mobile threads created from the default local-checkout composer, so PR badges and row branch labels can match live git status.

Adds resolveProjectThreadCreationBranch: explicit picker choice wins; otherwise local mode uses the live checkout ref from vcsEnvironment.status (refName), not the branch list’s cached current flag. Worktree mode and detached / missing status still resolve to null. NewTaskFlowProvider exposes currentCheckoutBranchName while the composer is open; NewTaskDraftScreen uses the helper for the displayed branch label and the createProjectThread payload.

Queued/offline tasks are unchanged: only explicit workspaceSelection.branch is stored, with a comment that a queue-time checkout guess would go stale at drain time. Five unit tests cover the resolver matrix.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ff916b0beca8fbc4323607c2af37336d95966fb6. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Record live checkout branch on local-checkout threads so PR badges display

  • Adds resolveProjectThreadCreationBranch in projectThreadCreationValidation.ts to determine which branch to record: uses the explicit picker selection if provided, falls back to the live checked-out branch for local workspace mode, and returns null for worktree mode without an explicit selection.
  • Exposes currentCheckoutBranchName from live VCS status in new-task-flow-provider.tsx by issuing a vcsEnvironment status query for the selected environment/cwd.
  • Updates NewTaskDraftScreen.tsx to pass the resolved branch to createProjectThread, so threads created without an explicit branch selection still record the current checkout.
Macroscope summarized ff916b0.

Screenshots (Android emulator, synthetic data)

Verified end-to-end on a Linux-hosted Android emulator against a disposable local T3 environment with a synthetic git repo checked out on feature/checkout-demo. Threads created on pre-fix code persisted an empty branch; the thread created with this fix live recorded feature/checkout-demo (confirmed in projection_threads), and the row shows the branch label. iOS behavior is the same shared React Native code path.

Before (pre-fix code)After (fix active)
before: rows show no branchafter: new thread row shows feature/checkout-demo
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      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: 9e1bf817-3082-4363-b22d-eca74302640b

      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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved ff916b0

      Straightforward bug fix that adds a simple branch resolution function with unit tests. The change ensures local-checkout threads properly record their branch name so PR badges display correctly - limited scope with clear intent.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. 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](https://www.cursor.com/dashboard/bugbot).

      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](https://cursor.com/bugbot) for commit 0f5683d325b602db2d647c9dbf6a8fe90b090123. Configure [here](https://www.cursor.com/dashboard/bugbot).
    5. juliusmarminge merged thisf8bb92b

    6. juliusmarminge closed this

Sign in to join this conversation.