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-30T12:49:18.220113Z b347a4a New commits
ℹ️ 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 b347a

This change keeps the terminal shortcut from switching to the default session when the terminal route carries a query string. It is a small, localized routing fix with a regression test, and no merge-blocking risk remains. The author did not check it on a device.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix and the affected shortcut: Command+Shift+T keeps the selected terminal session. The changeset adds activeThreadSubroute and uses it in HardwareKeyboardCommandProvider so a term…
Description check Passed The description follows the repository template. It has Problem, Change, Scope, and Verification sections, and each section has substantive content. The Problem section gives reproduction steps, expec…
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 fix and the affected shortcut: Command+Shift+T keeps the selected terminal session. The changeset adds activeThreadSubroute and uses it in HardwareKeyboardCommandProvider so a terminal opened with a terminalId query stays on the selected session. The title is specific and matches the main change. It uses the conventional commit form with the mobile scope, and the wording is plain.

Full details: Description check

Explanation

The description follows the repository template. It has Problem, Change, Scope, and Verification sections, and each section has substantive content. The Problem section gives reproduction steps, expected behavior, and a concrete trace of the bug. The Change section explains the helper and where it is used. The Scope section explains why no issue is linked and says the change is a bug fix. Verification gives a focused test with before and after results, the broader check results, and the item not checked (device testing). The template asks for a conventional commit title; the PR title meets that. The description does not include screenshots, but the change has no UI visuals, so this gap does not matter here.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • 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 1402bc3 and b347a4a.

Files selected for processing: 2

  • 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.

@Marve10s
Marve10s force-pushed the fix/mobile-terminal-shortcut branch from 1402bc3 to b347a4a Compare November 30, 2026 12:47

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