fix(mobile): mark the thread worktree's branch as current#23436

merged4
main
GitHub fork: r13/a130-mark-the-worktree-s-checked-out-branch-a
opened9d agobyOonly21mil
View on GitHubTwo-way sync enabledPR last imported 9h ago

Problem

In a mobile thread attached to a linked worktree, open Git > Branches & worktrees. With the project root on main and the thread worktree on feature/mobile, the header shows feature/mobile but the branch list marks main as current. The row's selected accessibility state also comes from that incorrect flag.

The branch query runs against the project root. The server computes each ref's current flag relative to the requested checkout, so sharing a repository's refs does not make its current-branch flags interchangeable between worktrees.

Change

Request branches using selectedThreadCwd, the same checkout used by the thread's Git actions and the sheet's status query. Include that checkout in the memo dependencies so switching between threads in the same project updates the branch query. Remove the now-unused project selection from the hook.

The existing worktree resolver falls back to the project root for threads without a linked worktree. Branch creation and checkout actions keep their existing behavior.

Scope and approval

This is a small, focused fix for an obvious bug under CONTRIBUTING.md's exception. The sheet disagrees with its own current-branch header because two reads target different checkouts. No issue or maintainer approval is claimed. The same hook serves iOS and Android.

Verification

The focused regression uses real Git refs from a root checkout and a linked worktree. With the base hook it fails because main is returned where feature/mobile is expected. With the candidate it passes root -> linked worktree -> root.

Commands passed:

  • pnpm exec vp test run --project react src/state/use-selected-thread-git-state.test.tsx in the mobile package.
  • pnpm exec vp lint and pnpm exec vp fmt --check on the hook, regression and mobile test configuration.
  • pnpm --filter @t3tools/mobile typecheck.

Base regression, with the linked checkout reporting the wrong current branch.

Regression failing on base

Candidate regression, including switching back to the root checkout.

Regression passing on candidate

Production JavaScript on iOS 26.5 and Android 16, with matching Debug native clients. On base, main sorts first with the current-row style for the linked thread; on the candidate, feature/mobile does. The rows' accessibility selected state matches, and it follows a switch to a root-checkout thread and back. Images are cropped to the sheet.

iOS base branch sheet

iOS candidate branch sheet

Android base and candidate show the same branch selection change.

Android base branch sheet

Android candidate branch sheet

Not checked:

  • Full repository suite and upstream CI.
  • Physical devices.

Prior PRs: Jacob's #20754 touches this hook for VCS terminology but retains the root-based refs query. My open #23241 fixes the unedited new-worktree base field in the same sheet. Neither is the same fix. Adamulek123's closed #9475 addressed missing labels in thread-list rows and excluded worktree threads. This change reuses no code from those PRs.

Production fix, tests, PR description and images written with GPT-6.1 Sol in T3 Code Nightly.

🤖 Generated with GPT-6.1 Sol in T3 Code Nightly

Checks

22 successful · 14 skipped
All checks passed
b04d948

Added 2 commits

  • test(mobile): follow node imports and observe committed hook state9b11511
  • fix(mobile): mark the thread worktree branch as currenta13c589
Synced from GitHub

Approvability

Verdict: Approved at 9b11511

Macroscope's review found this PR approvable — This is a focused mobile bug fix that makes branch-current indicators use the selected thread’s worktree while preserving project-root behavior for ordinary threads. It adds a targeted real-Git regression test and does not alter schemas, defaults, deployment, or static-analysis configuration.

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

Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review.

External image Recent review info
External image Run configuration
External image Commits

Reviewing files that changed from the base of the PR and between d088814f04f7ca028ef40acbeb499bb387705217 and b04d9487e5611034313bc1e0a6a2aaae2a837e5f.

External image Files selected for processing: 2
  • apps/mobile/src/state/use-selected-thread-git-state.ts
  • apps/mobile/vite.config.ts

Limit details: You’ve used all 10 included reviews currently available.

Walkthrough

useSelectedThreadGitState now queries branches from the selected thread’s working directory. A React test checks the reported branch as the selected checkout changes from main to feature/mobile and back.

Changes: Selected Thread Branch State

Layer / File(s)Summary
Query branch state from the selected checkout
apps/mobile/src/state/use-selected-thread-git-state.ts, apps/mobile/src/state/use-selected-thread-git-state.test.tsx, apps/mobile/vite.config.ts
The hook targets the selected thread’s working directory for branch queries. The test checks branch updates across linked worktrees, and the Vite React test list includes the test.

Priority: External image Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: macroscopeapp, t3dotgg

Merge Risk: External image Minimal · up to b04d9

The selected thread now shows the branch checked out in its linked worktree while root threads retain their existing behavior, with no actionable merge-blocking risk identified.

Pre-merge checks: Passed 4
Check nameStatusExplanation
Title checkPassedThe title is concise, specific, and accurately describes the main fix: marking the linked thread worktree's branch as current in the mobile interface.
Description checkPassedThe description includes all required sections: Problem, Change, Scope and approval, and Verification. It explains the bug, implementation, scope rationale, focused test coverage, observed results, li…
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes all required sections: Problem, Change, Scope and approval, and Verification. It explains the bug, implementation, scope rationale, focused test coverage, observed results, limitations, screenshots, and agent details.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

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

Added 1 commit

  • fix(mobile): resolve branch-state test configuration conflict with maind088814

Note

Written by gpt-6.1-sol on behalf of Maria

@only21mil, thanks for identifying that branch-current flags belong to a checkout. your three-line fix is already minimal, so i kept it and both original commits unchanged.

i merged current main (ed44f251d89d) and resolved the mobile test-list conflict by retaining both entries. no production changes were needed beyond your original fix. the final diff remains three files: the hook, its real-git regression, and test registration.

verification passed through blacksmith:

  • the existing regression fails with main's hook (main instead of feature/mobile) and passes with the fix, including root -> linked worktree -> root.
  • vp run check:changed: format, lint, both knip passes, mobile and scripts typechecks, and the regression.

unverified this run: native styling/accessibility and branch interactions on ios/android. the default dev server started successfully and was stopped; this vm has no connected android device, and the native mobile app supports only ios/android, so chrome cannot provide valid screenshots of this sheet. the original evidence remains in the description. no substitute ui or screenshots are claimed. upstream ci is pending on the new head.

Note

Written by gpt-6.1-sol on behalf of Maria

Verified in a real dev environment

no changed app behavior could be verified in this run. this is an environment-blocker report, not a runtime pass.

inspected the exact head d088814f04f7ca028ef40acbeb499bb387705217, description, full diff, discussion, commit authors and current checks. the pr is open, with no pr commits authored by juliusmarminge or t3dotgg. git.cafe maps this to #23436. its 28 reported checks are successful; those do not establish runtime correctness.

the production change is mobile-only: useSelectedThreadGitState queries refs using selectedThreadCwd instead of the project root, including that cwd in memo dependencies. the user path is a linked-worktree thread -> git -> branches & worktrees. the expected result is the linked branch marked current, consistent with the sheet header and accessibility selection. the mobile app declares only ios/android platforms; the web client does not execute this hook.

runtime prerequisite results on this linux boat vm:

text
1t3 device_list:
2Agent device access is turned off for this environment.
3
4timeout 20 adb devices -l:
5List of devices attached
6[no devices]
7
8command -v emulator:
9[no executable]

Not verified

main reproduction, candidate native rendering and selected accessibility state, switching root -> linked-worktree -> root, branch creation/checkout and occupied-worktree guards remain unverified. no real codex gpt-6.1-sol turn was run because there was no supported client to exercise the changed path. no before/after images or recording were captured, and no existing contributor captures are claimed as evidence from this run.

the repository's mobile verification skill explicitly requires stopping verification when t3 device tools or the selected device are unavailable. therefore no worktree install, dev server, substitute mobile web renderer, source edits or pushes were performed. chrome testing of the separate web client would not prove this mobile fix. this needs an android device host with t3 device access enabled, or an authorized ios host, followed by main/candidate verification through the native client with real provider turns.

Note

Written by gpt-6.1-sol on behalf of Maria

Verified on Android emulator (API 35) against a real dev server

verified head d088814f04f7ca028ef40acbeb499bb387705217 using the t3 android emulator, the matching cached development client, metro, and an isolated server on port 13773 with state in /home/user/t3code/.t3.

created a real git project on main, a linked worktree, and two threads. real Codex gpt-6.1-sol turns ran git branch --show-current and pwd. android displayed the real replies confirming the root checkout and feature/android-23436 in its linked directory. no replay provider, mocks, or demo data were used.

reproduced the wrong selection using the hook from this pr's actual base, ed44f251d89d: the linked thread's sheet selected main while its base-branch field showed feature/android-23436. restored the exact candidate hook and restarted metro: the sheet selected feature/android-23436, including its native accessibility selected state. switching to the root thread selected main; switching back selected the linked branch again.

neighbor checks: creating the linked worktree through android succeeded, and branches occupied by other worktrees remained disabled. the checkout was clean after restoring the candidate. no production changes, commits, or pushes were needed.

vp run check:changed ed44f251d89d4dae2f8dcf11c24fb3dec9dda4c7 passed through blacksmith: format, lint, both knip passes, two package typechecks, and the existing regression. the explicit base was needed because the remote runner initially lacked merge-base history. the pr also reports 28 successful upstream checks.

before, actual base hook with the same project and linked thread:

android base selects main for the linked thread

after, exact pr candidate:

android candidate selects feature/android-23436 for the linked thread

root thread fallback:

android root thread selects main

recording of switching from linked to root and back, with real provider replies visible:

android root and linked thread branch selection recording

Not verified

ios and physical devices. this was a base-hook comparison on the candidate checkout, not a full run of current github/main. branch creation/checkout beyond worktree creation was not exercised. the existing "Loading branches..." label remains visible on both base and candidate; its lifecycle is outside this fix. the root row also retains its existing "Checked out in another worktree" subtitle/disabled state despite being selected. neither is claimed fixed by this pr.

Added 1 commit

  • fix(mobile): merge main and preserve selected checkout branch stateb04d948

Note

Written by gpt-6.1-sol on behalf of Maria

merged github/main 476590d0aded into the existing head, without rebasing. resolved the hook conflict by retaining main's plain target objects and this pr's selected-checkout cwd. the diff remains three files, 109 additions and two deletions.

blacksmith passed vp run check:changed 476590d0adede15a4eec0d05b8adac8c63736452: format, lint, both knip passes, mobile/scripts typechecks, existing real-git regression, and react compiler checks. two independent read-only reviews approved b04d9487e5611034313bc1e0a6a2aaae2a837e5f without findings.

native verification was not repeated on this merge. the existing android evidence above is for d088814f04; no new ui behavior was added. upstream ci is running on the new head.