Skip to content

fix(mobile): Command+Shift+T keeps the selected terminal session - #42387

Open
Marve10s wants to merge 1 commit into
pingdotgg:mainfrom
Marve10s:fix/mobile-terminal-shortcut
Open

Marve10s wants to merge 1 commit into
pingdotgg:mainfrom
Marve10s:fix/mobile-terminal-shortcut

Conversation

@Marve10s

Copy link
Copy Markdown
Contributor

Problem

On iPad, Command+Shift+T on a terminal you picked can switch you to a different terminal. Open term-2 from the thread's terminal menu while term-1 is also running, press Command+Shift+T, and the screen moves to term-1. The same screen also enables the hardware Copy PR link or thread shortcut, which #8994 turned off on the terminal ("terminal focus keeps its existing copy behavior"); on Android, reading the native key handling, that shortcut then takes Ctrl+Shift+C before a focused terminal can send it as an interrupt.

Most ways of opening a terminal pass its terminalId route param: the thread menu, Open new terminal, project scripts and the session switcher. React Navigation serializes it as a query. A script that renders the production provider with React Navigation's serializer, then sends Open Terminal, gives (selected is the terminalId left on the route):

path:   /threads/env/thread-17/terminal?terminalId=term-2
main:   copyEnabled=true   navigations=1   selected=null    (the screen then picks term-1)
fix:    copyEnabled=false  navigations=0   selected="term-2"

HardwareKeyboardCommandProvider checks the raw path: pathname.split("/")[4] is terminal?terminalId=term-2, and /\/terminal(?:\/|$)/ does not match before ?. So the provider thinks it is not on the terminal, navigates there without terminalId, and the screen picks its default running session.

Change

activeThreadSubroute reads the thread's subroute from the path before any ? or #. The copy guard and the Files, Terminal and Review checks use it instead of testing the raw path, so a terminal opened with a session id counts as the terminal.

Scope

This is a small fix for an obvious bug, so it has no issue. In-app navigation opens Review and Files without a query, but a link can carry one, so their checks use the same helper. #42336 stops parseActiveThreadPath reading the query into the thread id; this fixes the subroute checks in the provider, and the two merge cleanly.

Verification

HardwareKeyboardCommandProvider.terminal.test.tsx renders the provider on /threads/env/thread-17/terminal?terminalId=term-2, then checks that the Copy PR link or thread shortcut is not enabled and that Open Terminal does not navigate. Its own file keeps it apart from the provider test in #29679.

main:   Tests  1 failed (1)   (expected [...] to not include 'copyThreadReference')
fix:    Tests  1 passed (1)

vp run check:changed upstream/main passes, and the full @t3tools/mobile suite passes (3771 tests). Not checked on a device.

GPT-6.2 Astra (high, Codex) found the bug. Claude Opus 5.5 and GPT-6.2 Sol (high, Codex) reproduced it independently. Claude Opus 5.5 (Claude Agent in T3 Code) wrote the fix and test.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T19:55:23.526558Z 1402bc3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 24, 2026
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The keyboard command provider now uses activeThreadSubroute to check the active thread subroute. A terminal-route test verifies command availability and that invoking the terminal command does not navigate.

Changes: Thread subroute detection

Layer / File(s) Summary
Identify and check thread subroutes
apps/mobile/src/features/keyboard/hardwareKeyboardCommands.ts, apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx, apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.terminal.test.tsx, apps/mobile/vite.config.ts
activeThreadSubroute strips a query string or fragment before returning pathname segment 4. The provider uses the helper for copy-reference availability and to skip navigation to the active files, terminal, or review subroute. The terminal-route test checks command availability and navigation behavior, and the Vite configuration includes the test.

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

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to 1402b

This change makes the keyboard command provider recognize thread subroutes when the path has a query string, so the terminal route no longer enables the copy shortcut or navigates away. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the primary change: Command+Shift+T on a selected terminal keeps that session. It matches the fix that reads the thread subroute before any query string, so the provider recognizes a t…
Description check Passed The description follows the repository template. It has Problem, Change, Scope, and Verification sections. The Problem section gives the reproduction path, expected behavior, and a before/after script…
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.
Full details: Title check

Explanation

The title names the primary change: Command+Shift+T on a selected terminal keeps that session. It matches the fix that reads the thread subroute before any query string, so the provider recognizes a terminal route with terminalId and does not navigate away. The title is specific and follows the conventional commit format.

Full details: Description check

Explanation

The description follows the repository template. It has Problem, Change, Scope, and Verification sections. The Problem section gives the reproduction path, expected behavior, and a before/after script output. The Change section explains the helper and the affected checks. The Scope section explains why no issue is linked and why the change is a bug fix. The Verification section lists a focused test with main and fix results, a broader check run, and states that device testing was not done. The template's conventional commit title guidance is met. The author also names the model and harness that did the work, as the template requests. The description does not link an issue, but it gives a reason for that choice, which the template allows for small obvious bugs.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 98d940f and 1402bc3.

Files selected for processing: 4

  • apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.terminal.test.tsx
  • apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx
  • apps/mobile/src/features/keyboard/hardwareKeyboardCommands.ts
  • apps/mobile/vite.config.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.

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:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant