fix(mobile): Back from a PR opened in a chat returns to the chat on Android#27050

closed3
main
GitHub fork: fix/android-pr-link-back-stack
opened12d agobyBbitmvk
View on GitHubTwo-way sync enabledPR last imported 11d ago

Fixes #24753. This is a smaller alternative to #18839: it leaves first-send behavior alone and only changes how links and Back work.

Problem

On Android, opening a PR from a chat (or a chat from a PR, or one stacked PR from another) replaced the whole stack, so Back landed on the PR list instead of the chat. iOS already pushes these pages.

Cause and fix

Link callers took an Android-only selectDetail branch, which replaces the stack and switches the list tab. On top of that, PR and chat pages selected their own tab whenever they gained focus, and Back reset straight to the list.

diff
1 open PR/chat/stacked-PR link
2- android: selectDetail (replace stack, select tab)
3+ push (same as iOS)
4 PR/chat page focus
5- select "pullRequests" | "threads"
6 Back (toolbar or system)
7- reset to list unless a distinct thread is below
8+ go to the previous page, skipping duplicate copies of the same thread
9+ nothing below: reset to list
10 app cold-starts on a page (outside link)
11+ start on that page's list

The list tab now changes only when you tap a tab or a list row, so Back from a page returns to the list you came from. A cold start straight into a PR from an outside link starts on the Pulls list, so Back still lands there.

Evidence

android-workspace-navigation.test.ts, extended inside the existing Back test:

  • [Home, Thread, PR] → Back → [Home, Thread]. Fails on main, where it gives [Home].
  • [Home, T, child, child-copy] → Back → [Home, T]. Fails on main, where it gives [Home].

Android 16 emulator, with both the system Back and the toolbar back arrow:

  • Chats → chat → PR link → Back → the same chat → Back → the Chats list, with the Chats tab still selected.
  • Pulls → PR → "Work on PR" chat → Back → the same PR → Back → the Pulls list.
  • List rows and bottom tabs behave as before. The keyboard closes when a PR link opens from the composer.
  • Not tested on a device: stacked-PR links, because the test data has no stacked PRs, and cold-start links, because the dev client's launcher screen catches them before the app loads. Stacked PRs use the same push and Back path. If the cold-start tab weren't picked up, the list would start on Chats, as it does today.

vp run check:changed passes.

Merge Danger

Door: two-way. It changes no data or contracts, and a revert restores the old behavior.

Blast Radius: small. Android's link and Back navigation only: iOS was already on the push path, and the shared Back hook keeps its iOS branch unchanged.

Fixed by Claude Opus 5.5 in Claude Code (T3 Code). First implementation by GPT-6.1-Sol (Codex). Reviewed by GLM-5.3 Flash; device pass partly run by DeepSeek V4.1 Flash.

🤖 Generated with Claude Code

Checks

21 successful · 15 skipped
All checks passed
a63819c

Added 1 commit

  • fix(mobile): Back from a PR opened in a chat returns to the chat on Android16f73fc
Synced from GitHub

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — Android Back now preserves the chat/PR navigation history. The accompanying change from Pulls to Chats as the Back destination after a cold-start external PR link needs a human product decision.

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

Synced from GitHub

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

External image Run configuration
External image Commits

Reviewing files that changed from the base of the PR and between d26280ce9513622e3cf324ada21fa032ac917767 and a63819c719744afac05bff280c7f072a33c193ab.

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

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 16f73fc2311f6180e8b70f93048e7e04e2b1cc1b and d26280ce9513622e3cf324ada21fa032ac917767.

External image Files selected for processing: 4
  • apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
  • apps/mobile/src/features/workspace/AndroidWorkspaceTabsProvider.tsx
  • apps/mobile/src/features/workspace/WorkspaceTabsContext.tsx
  • apps/mobile/src/features/workspace/workspace-tabs-state.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

Pull-request and thread routes now use stack pushes across platforms. Android Back handling uses navigation history to return to a prior destination. Workspace tab state can initialize from the current route.

Changes: Mobile navigation history

Layer / File(s)Summary
Push pull-request and thread routes
apps/mobile/src/features/pull-requests/PullRequestStackCard.tsx, apps/mobile/src/features/pull-requests/usePullRequestThreads.ts, apps/mobile/src/native/useOpenPullRequest.ts
Opening pull-request stack layers, threads, and pull requests uses navigation pushes instead of Android detail selection.
Choose the prior Android destination
apps/mobile/src/lib/android-workspace-navigation.ts, apps/mobile/src/lib/android-workspace-navigation.test.ts, apps/mobile/src/features/workspace/useAndroidWorkspaceNavigation.ts, apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx, apps/mobile/src/features/threads/NewTaskDraftScreen.tsx, apps/mobile/src/features/threads/ThreadHeader.tsx, apps/mobile/src/features/threads/ThreadRouteScreen.tsx
Android Back handling skips consecutive parent-thread routes when finding a target, then goes back or resets the stack through that target. Tests cover pull-request history and duplicate thread routes. Workspace back hooks no longer accept or select a tab, and callers no longer pass one.
Initialize workspace tab from route
apps/mobile/src/features/workspace/workspace-tabs-state.ts, apps/mobile/src/features/workspace/WorkspaceTabsContext.tsx, apps/mobile/src/features/workspace/AndroidWorkspaceTabsProvider.tsx, apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
Workspace tab state accepts an initial tab. Android derives it from the first route that is not Home, and detail selection uses the shared route-name mapping.

Priority: External image Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • pingdotgg/t3code#24753: The change pushes pull-request routes onto navigation history and updates Android Back handling to return to a prior destination.

Possibly related PRs

  • pingdotgg/t3code#24742: This PR changes the same Android pull-request and thread navigation paths from detail selection to stack pushes.
  • pingdotgg/t3code#18839: This PR addresses preserving chat history when opening a pull request from a thread.

Suggested reviewers: pixpmusic, juliusmarminge

Merge Risk: External image Minimal · previous review d2628

No actionable merge-blocking risk is established for this change.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check nameStatusExplanationResolution
Description checkWarningThe description follows the template's main sections. It has a Problem section that explains the Android stack replacement and the Back behavior. It has a Change section with a diff that shows the old…Add a Scope and approval section. Link the triaged bug issue #24753 and the maintainer comment that approves this direction and scope. If no maintainer approval exists, explain why this focused Android fix qualifies without prior approval. …
Passed Passed checks: 3 passed
Check nameStatusExplanation
Title checkPassedThe title names the main change: Back from a PR opened in a chat should return to the chat on Android. The raw summary and PR objectives both show the changes that make this happen: links use push ins…
Linked Issues checkPassedIssue #24753 requires Android Back from a pull request opened from a thread to return to the originating thread through both toolbar and system Back. The link callers now use StackActions.push inste…
Out of Scope Changes checkPassedThe changed navigation code stays within the Android workspace link and Back behavior for issue #24753. The stacked-PR and chat-link changes use the same push path and support preservation of the orig…
Full details: Title check

Explanation

The title names the main change: Back from a PR opened in a chat should return to the chat on Android. The raw summary and PR objectives both show the changes that make this happen: links use push instead of the Android-only selectDetail replace path, and Back returns to the previous page while skipping duplicate threads. The title is short, specific, and follows the conventional commit form the repository template recommends. The title is accurate and not vague.

Full details: Linked Issues check

Explanation

Issue #24753 requires Android Back from a pull request opened from a thread to return to the originating thread through both toolbar and system Back. The link callers now use StackActions.push instead of Android-only selectDetail in useOpenPullRequest.ts, usePullRequestThreads.ts, and PullRequestStackCard.tsx. useWorkspaceBackNavigation now calls returnToAndroidWorkspaceList without forcing a tab. That function follows stack history and skips duplicate copies of the current thread. The focused tests cover a pull request above a thread and duplicate thread routes. The reported Android toolbar and system Back checks support the same behavior.

Full details: Out of Scope Changes check

Explanation

The changed navigation code stays within the Android workspace link and Back behavior for issue #24753. The stacked-PR and chat-link changes use the same push path and support preservation of the originating history. The tab-state changes prevent focus from overwriting the originating list and initialize the list for a cold-start detail route. Call-site signature updates and navigation tests support these changes. No unrelated data, contract, or feature changes are shown.

Full details: Description check

Explanation

The description follows the template's main sections. It has a Problem section that explains the Android stack replacement and the Back behavior. It has a Change section with a diff that shows the old and new flow. It has a Verification section with unit test cases, emulator checks for both Back paths, a note on what was not tested, and a passing check command. The Scope and approval section is missing. It does not link a triaged bug issue or maintainer approval. The description does say it fixes #24753, but it does not show that the issue is triaged or approved for this direction, and it does not explain why this is a small fix that needs no prior discussion. The template also asks for an approval link or a qualifying explanation, so that part is incomplete. The Merge Danger section and the model attribution are extra content that the template does not require.

Resolution

Add a Scope and approval section. Link the triaged bug issue #24753 and the maintainer comment that approves this direction and scope. If no maintainer approval exists, explain why this focused Android fix qualifies without prior approval. Keep the existing Problem, Change, and Verification sections. The Merge Danger section is not part of the template and can stay or move below the required sections.

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Added 2 commits

  • fix(mobile): cold-start PR links start on the Pulls list on Androidd26280c
  • Merge branch 'main' into fix/android-pr-link-back-stacka63819c
Synced from GitHub

closing at @StiensWout's request under Provide evidence for the changed behavior.

Changes Android PR/chat navigation and selected list-tab behavior, including hardware/toolbar Back destinations. Manual steps and stack tests are supplied, but no before/after UI screenshots or short navigation recording are attached. Linked #18839's historical capture predates this separate implementation and does not demonstrate its Back behavior.

submission evidence: "Android 16 emulator, with both the system Back and the toolbar back arrow:"

Attach before/after Android captures and a short recording of chat → PR → Back and PR → chat → Back, preserving originating list tab.

thanks for trying to help improve t3 code. if you think this closure was a mistake, please open a fresh pr addressing the requirement above, and link back to this one.