Skip to content

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

Merged
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
Zeus-Deus:fix/4951-local-thread-branch-null
Aug 15, 2026
Merged

fix(mobile): local-checkout threads record their branch so PR badges show#4986
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
Zeus-Deus:fix/4951-local-thread-branch-null

Conversation

@Zeus-Deus

@Zeus-Deus Zeus-Deus commented Jul 30, 2026

Copy link
Copy Markdown

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 for commit ff916b0. Bugbot is set up for automated code reviews on this repo. Configure here.

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 branch after: new thread row shows feature/checkout-demo

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jul 30, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jul 30, 2026
@macroscopeapp

macroscopeapp Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

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.

@juliusmarminge
juliusmarminge force-pushed the fix/4951-local-thread-branch-null branch from 44c1b4e to 0f5683d Compare August 15, 2026 10:54
@macroscopeapp
macroscopeapp Bot dismissed their stale review August 15, 2026 10:54

Dismissing prior approval to re-evaluate 0f5683d

@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 0f5683d. Configure here.

Comment thread apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Aug 15, 2026
Zeus-Deus and others added 2 commits August 15, 2026 13:35
…show

A thread created from the mobile composer with the untouched
current-checkout default persisted branch: null, and the thread row's
PR hook never subscribes or matches on a null branch, so an open PR
stayed invisible. Online creation now records the live checkout ref
from the project's git status stream - the same value the PR matcher
compares against. An explicit picker choice still wins, and a detached
HEAD, non-repository project, or not-yet-loaded status stays null
rather than fabricating a branch. Queued offline tasks still record
only explicit choices, since a queue-time guess would go stale by the
time the outbox drains.
Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge
juliusmarminge force-pushed the fix/4951-local-thread-branch-null branch from 0f5683d to ff916b0 Compare August 15, 2026 11:36
@macroscopeapp
macroscopeapp Bot dismissed their stale review August 15, 2026 11:36

Dismissing prior approval to re-evaluate ff916b0

@juliusmarminge
juliusmarminge enabled auto-merge (squash) August 15, 2026 11:40
@juliusmarminge
juliusmarminge merged commit f8bb92b into pingdotgg:main Aug 15, 2026
16 checks passed
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Aug 15, 2026
## What's Changed
* fix(desktop): route mouse thumb buttons to the in-app browser by @akosbalogh in pingdotgg/t3code#4459
* fix(web): keep the final segment of directory paths with a trailing separator by @jorvarea in pingdotgg/t3code#5460
* Keep block code plain when copying from rendered markdown by @yashranaway in pingdotgg/t3code#4468
* fix(web): add web app manifest so installed app keeps its scope by @Albro3459 in pingdotgg/t3code#4306
* Skip user hooks during Claude capability probes by @yashranaway in pingdotgg/t3code#4466
* fix(mobile): use Android monospace font family by @tastelessjolt in pingdotgg/t3code#4609
* fix(desktop): timestamps follow the OS locale instead of en-US by @brzzdev in pingdotgg/t3code#6190
* fix(web): keep multi-select questions open after the first click by @RaitP1 in pingdotgg/t3code#6646
* fix(web): stop clipping the changed-files expand hover on Windows by @mrmg in pingdotgg/t3code#6545
* fix(server): allow long-running git pushes by @devchaudhary24k in pingdotgg/t3code#6499
* fix(desktop): keep probing backend readiness while the process is alive by @lgwacker in pingdotgg/t3code#5526
* fix(server): allow install scripts in npm-global provider updates by @hey-jj in pingdotgg/t3code#5646
* fix: detect SSH remotes with non-git user prefixes (e.g. gitlab@) by @JackatDJL in pingdotgg/t3code#3649
* fix(web): describe what Ultracode does in the Reasoning picker by @delltrak in pingdotgg/t3code#6092
* fix(server): settle pending user-input requests when a Claude session stops by @AaronAbuUsama in pingdotgg/t3code#5127
* fix(server): stop replaying a command receipt for a different aggregate by @ostapondo in pingdotgg/t3code#5246
* fix(server): settle snoozed threads immediately by @0bkevin in pingdotgg/t3code#5379
* fix(mobile): prevent crash on sign out in settings by @shubhu121 in pingdotgg/t3code#4899
* fix(mobile): local-checkout threads record their branch so PR badges show by @Zeus-Deus in pingdotgg/t3code#4986
* fix(web): contain long approval commands by @Serendeep in pingdotgg/t3code#6503
* feat(web): make right panel maximize bindable by @husseinraoouf in pingdotgg/t3code#5091
* fix(server): respect inherited OPENCODE_CONFIG_CONTENT by @jonocodes in pingdotgg/t3code#4242
* fix(marketing): detect Mac chip on homepage download button by @mahdibm-dev in pingdotgg/t3code#4197
* Keep the server alive when a response write hits a dead socket by @yashranaway in pingdotgg/t3code#4470
* Limit physical key fallback to non-Latin layout output by @yashranaway in pingdotgg/t3code#4469
* fix: restore CLAUDE.md symlink target by @NgoQuocViet2001 in pingdotgg/t3code#3929
* fix(clients): default clone destination to folder plus repo name by @inayayousfi in pingdotgg/t3code#5989
* fix(web): keep timestamp date and time in the same locale by @juliusmarminge in pingdotgg/t3code#7081
* feat(desktop): add signal macOS DMG installer background by @Brechard in pingdotgg/t3code#6201

## New Contributors
* @akosbalogh made their first contribution in pingdotgg/t3code#4459
* @jorvarea made their first contribution in pingdotgg/t3code#5460
* @yashranaway made their first contribution in pingdotgg/t3code#4468
* @Albro3459 made their first contribution in pingdotgg/t3code#4306
* @tastelessjolt made their first contribution in pingdotgg/t3code#4609
* @brzzdev made their first contribution in pingdotgg/t3code#6190
* @RaitP1 made their first contribution in pingdotgg/t3code#6646
* @devchaudhary24k made their first contribution in pingdotgg/t3code#6499
* @lgwacker made their first contribution in pingdotgg/t3code#5526
* @JackatDJL made their first contribution in pingdotgg/t3code#3649
* @delltrak made their first contribution in pingdotgg/t3code#6092
* @AaronAbuUsama made their first contribution in pingdotgg/t3code#5127
* @0bkevin made their first contribution in pingdotgg/t3code#5379
* @shubhu121 made their first contribution in pingdotgg/t3code#4899
* @Zeus-Deus made their first contribution in pingdotgg/t3code#4986
* @husseinraoouf made their first contribution in pingdotgg/t3code#5091
* @jonocodes made their first contribution in pingdotgg/t3code#4242
* @mahdibm-dev made their first contribution in pingdotgg/t3code#4197
* @NgoQuocViet2001 made their first contribution in pingdotgg/t3code#3929
* @inayayousfi made their first contribution in pingdotgg/t3code#5989

**Full Changelog**: pingdotgg/t3code@v0.0.34-nightly.20260815.1101...v0.0.34-nightly.20260815.1102

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.34-nightly.20260815.1102
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]: Mobile current-checkout threads store a null branch and cannot show PR badges

2 participants