Skip to content

fix(android): preserve chat back stack in the PR viewer - #18839

Open
PixPMusic wants to merge 1 commit into
pingdotgg:mainfrom
PixPMusic:t3/fix-pr-viewer-back-stack
Open

PixPMusic wants to merge 1 commit into
pingdotgg:mainfrom
PixPMusic:t3/fix-pr-viewer-back-stack

Conversation

@PixPMusic

Copy link
Copy Markdown
Contributor

Problem

On Android, opening a PR link from chat or Git controls resets navigation to the PR workspace. Back then lands on the PR list instead of the original chat.

Change

  • Open the PR viewer above chat, replacing the Git controls sheet when appropriate. Toolbar Back and native back gestures follow the existing route history.
  • Preserve the return path when continuing a linked thread or opening an unsent PR draft.
  • After the first message is saved to the local outbox, reset an immediately started Android thread to Home → new thread.

This is also a small feature: intelligent back stack updates. A draft keeps its cancellation history while the user is deciding what to do; an accepted first send makes the new thread the current workspace. Offline and attachment-upload queue paths retain their existing return behavior.

Scope and approval

Focused follow-up to #18372 for the reported Android chat-to-PR navigation regression. The draft/first-send boundary belongs to that same return path and was explicitly requested alongside the fix. Explicit tab and sidebar selections continue to replace peer details. The change uses the existing PR viewer and task-submission paths.

Verification

  • 32 tests passed across the contextual PR back-stack, Android workspace navigation, Home thread selection, and Git overview navigation suites. They cover original route-key preservation, sheet replacement, linked-thread continuation, draft cancellation, accepted first-send pruning, keyboard Back, cold links, queued sends, and the existing iOS replacement action.
  • vp run --filter @t3tools/mobile typecheck passed. Targeted lint and formatting passed; existing React warnings remain in NewTaskDraftScreen.
  • Android 15 emulator: chat link and Git-controls entry return to the original chat; an unsent draft unwinds through PR to chat; an accepted first send returns directly to Chats; continuing an existing thread returns to PR and then chat.
  • Phone and wide layouts were checked. The wide sidebar stays on Chats while the PR viewer is open. Native iOS was not rerun; its existing navigation actions are covered by the focused tests.

Matched phone captures use the same synthetic chat, theme, and 1080 × 2400 emulator. The environment label is synthetic and the PR content is public.

Before Back After Back
Back from a chat PR link lands on the Pull requests list Back from the PR viewer restores the original chat

Before recording · After recording · Draft cancellation and first-send history update

Model: GPT-6.1 Sol | Harness: Codex in T3 Code

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Oct 12, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR changes established Android navigation semantics across PR viewing, linked threads, workspace Back handling, and first-send stack pruning. Although the production diff is focused and supported by targeted tests, the cross-cutting user-visible route behavior warrants human review.

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

@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 29a4df66-ce53-4d9f-aed6-8f14cc24b355
📥 Commits

Reviewing files that changed from the base of the PR and between a3c4e9e and 457acb4.

📒 Files selected for processing (6)
  • apps/mobile/src/features/pull-requests/pull-request-back-stack.test.ts
  • apps/mobile/src/features/pull-requests/usePullRequestThreads.ts
  • apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
  • apps/mobile/src/features/threads/new-task-submit-navigation.ts
  • apps/mobile/src/features/workspace/useAndroidWorkspaceNavigation.ts
  • apps/mobile/src/native/useOpenPullRequest.ts

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

📝 Walkthrough

Walkthrough

The mobile navigation changes adjust Android Back handling, pull-request and thread route navigation, and new-task submission routing. Added tests cover route history, keyboard dismissal, queued and immediate sends, and iOS sheet replacement.

Changes

Mobile navigation behavior

Layer / File(s) Summary
Pull-request and workspace navigation
apps/mobile/src/features/workspace/useAndroidWorkspaceNavigation.ts, apps/mobile/src/features/pull-requests/usePullRequestThreads.ts, apps/mobile/src/native/useOpenPullRequest.ts, apps/mobile/src/features/pull-requests/pull-request-back-stack.test.ts
Android Back now dismisses a visible keyboard, lets navigation handle Back when possible, and returns to the list otherwise. Pull-request and linked-thread navigation use route actions across platforms. Tests cover Back behavior and route history.
New-task submission navigation
apps/mobile/src/features/threads/new-task-submit-navigation.ts, apps/mobile/src/features/threads/NewTaskDraftScreen.tsx, apps/mobile/src/features/pull-requests/pull-request-back-stack.test.ts
Queued submissions return to the prior route. Immediate submissions reset Android navigation or replace the route on other platforms. Tests cover queued and immediate Android sends and the iOS route shape.

Priority: ➖ Normal

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant AndroidBack
  participant useAndroidWorkspaceBack
  participant Keyboard
  participant Navigation
  participant WorkspaceList
  AndroidBack->>useAndroidWorkspaceBack: hardware Back event
  useAndroidWorkspaceBack->>Keyboard: check visibility
  alt Keyboard is visible
    useAndroidWorkspaceBack->>Keyboard: dismiss keyboard
  else Keyboard is hidden
    useAndroidWorkspaceBack->>Navigation: check canGoBack()
    alt Navigation can go back
      Navigation-->>useAndroidWorkspaceBack: handle Back
    else Navigation cannot go back
      useAndroidWorkspaceBack->>WorkspaceList: return to list
    end
  end
Loading

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 457ac

No actionable navigation issue is established; the change is mergeable after normal checks.

Security Architecture Review Risk: 🔵 Low · up to 457ac

Security Architecture Review

Security architecture risk: 🔵 Low · up to 457ac

The change is confined to mobile navigation. Existing environment scoping and save-before-navigation ordering remain in place, and no security regression was identified. Some interruption, concurrent-submission, and recovery behavior remains unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The observed exposure change is local route retention and pruning within a user's mobile session. The reviewed transitions do not add destination authority or change the environment/thread parameters supplied to existing task and PR paths.

Trust Boundaries and Controls

  • observed — Existing client-side controls remain: connected task submission checks orchestration-operate scope, and PR task actions distinguish orchestration-operate and source-control-write permissions. Offline composition remains permitted as local draft work. Delivery-side authorization was not traced and is not established by these call-site checks.

Resilience and Maintainability Implications

  • observed — Deferred submission navigation waits for removal guards to clear and cancels its scheduled frame on effect cleanup. Accepted-message ownership resides in the application outbox rather than the discarded routes. Its existing manager serializes writes, rolls back failed enqueues by object reference, and loads persisted messages without overwriting live edits.
Pre-merge checks · Passed 4
Passed Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary Android navigation fix: preserving the chat back stack when opening the PR viewer.
Description check Passed The description includes all required sections and explains the problem, implementation, scope, approval context, focused verification, test results, platform limitations, screenshots, and recordings.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 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.

@TimPeterNL

Copy link
Copy Markdown

Confirmed on Android 2.0.0 beta. Back from a PR opened in a thread lands on the PR list; this fixes it. 🙏

Small aside, not blocking: "Continue thread" to the same thread you came from adds a second copy of it to the stack (RN 7 navigate doesn't pop without getId). navigate(…, { pop: true }) in openThread might avoid that.

This branch has not been deployed

No deployments
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:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants