Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): right panel launcher letters work when the panel opens after page load #21556

Closedfixfon(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/21556/headopened View on GitHub

Problem

When the right panel is opened after the page has loaded, pressing a launcher letter in the empty "Open a surface" launcher (T for Terminal, B for Browser, ...) types the letter into the composer instead of opening the surface (#21541). Type-to-focus and the launcher both add a capture keydown listener on window. Type-to-focus registers when the chat view mounts, the launcher when it mounts, so a launcher opened later runs second. Type-to-focus types the letter into the composer and prevents the event, and the launcher ignores a prevented event. The launcher still advertises its letters in data-surface-launcher-keys, but the type-to-focus check that read it was dropped in #2829.

Change

shouldTypeToFocusComposer in composerFocusRedirect.ts returns false for a key the mounted launcher advertises in data-surface-launcher-keys (case-insensitive), so the launcher gets those letters whatever order the listeners were added in. Other letters still go to the composer, and with no launcher mounted nothing changes. Listener order, the launcher matcher and non-Latin layout handling (#21508) are untouched.

Scope and approval

Triaged and accepted by the maintainer, who confirmed the listener-order cause on main: https://github.com/pingdotgg/t3code/issues/21541#issuecomment-6260987421

Verification

Three cases in a new apps/web/src/components/chat/useChatShortcuts.browser.test.tsx (#22557 removed composerFocusRedirect.browser.test.ts on main, so the earlier cases moved here). The test mounts the real useChatShortcuts first, then a launcher stand-in that registers its keydown listener afterwards, the order from the issue, and presses real keys:

  • leaves the launcher's letters to the launcher, in either case fails without the change (expected [] to deeply equal [ 't', 'T' ]) and passes with it.
  • still types other letters into the composer while the launcher is open and types the letter into the composer again once the launcher closes pass before and after.

Format, lint and apps/web typecheck are clean. I also merged this branch with #21508 locally: no conflicts, and the type-to-focus and RightPanelTabs tests pass together (28 tests).

In the dev app (Chromium), following the issue's steps: load the page, open the right panel with its toolbar button, press T. I checked T only; the other launcher letters go through the same check.

On non-Latin keyboard layouts, when the panel opens after page load, the letter still goes to the composer even with #21508, because this check compares event.key; also matching event.code here would cover that and could be a follow-up.

Before: t lands in the composer and the launcher stays open.

before

After: Terminal 1 opens and the composer stays empty.

after

Closes #21541

Claude Sonnet 5.5 (xhigh) via T3 Code.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. Approvability

      Verdict: Approved at 3f8d38a

      Macroscope's review found this PR approvable — This is a narrowly scoped keyboard-routing bug fix that preserves existing composer behavior except when an open right-panel launcher explicitly advertises the pressed key. The change is isolated to the web event guard and targeted browser tests, with no schema, deployment, security, billing, or product-default impact.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      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: 2c7b5383-7a8f-4cd1-9d69-c5289d27b653
      📥 Commits

      Reviewing files that changed from the base of the PR and between 3f8d38a629faa33407202d11845a7c28f6ab478d and ed87ebf1327111370c53e4445d1f20bffbdf77b9.

      📒 Files selected for processing: 1
      • apps/web/src/components/chat/useChatShortcuts.browser.test.tsx

      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

      The composer focus redirect now checks the right-panel launcher’s registered keys and does not redirect matching printable keys to the composer. Browser tests cover launcher key handling, unrelated typing, and behavior after the launcher closes.

      Changes: Right-panel launcher key handling

      Layer / File(s)Summary
      Skip launcher keys during composer focus redirect
      apps/web/src/components/chat/composerFocusRedirect.ts, apps/web/src/components/chat/useChatShortcuts.browser.test.tsx
      The redirect checks the launcher’s registered keys without regard to case and skips matching keys. Browser tests cover matching launcher keys, unrelated composer typing, and composer handling after the launcher closes.

      Priority: ⬇️ Low

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

      Change: Bug fix · Severity of issue fixed: Low

      Merge Risk: ⚪ Minimal · up to ed87e

      The launcher-key behavior is covered for the reported post-load interaction, with no actionable merge-blocking risk identified.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Description checkPassedThe description includes all required sections: Problem, Change, Scope and approval, and Verification. It explains the cause and fix, links maintainer approval, documents focused tests and manual veri…
      Title checkPassedThe title clearly and concisely describes the main fix: launcher letters work when the right panel opens after page load.
      Linked Issues checkPassedThe change satisfies the coding requirement in #21541. shouldTypeToFocusComposer skips a case-insensitive match for keys in data-surface-launcher-keys, so a launcher listener can handle the key. T…
      Out of Scope Changes checkPassedThe changed source code implements the launcher-key arbitration required by #21541. The added browser tests verify that behavior and related regression cases. No unrelated product change is identified…
      Full details: Description check

      Explanation

      The description includes all required sections: Problem, Change, Scope and approval, and Verification. It explains the cause and fix, links maintainer approval, documents focused tests and manual verification, records limitations, and includes before/after UI evidence.

      Full details: Linked Issues check

      Explanation

      The change satisfies the coding requirement in #21541. shouldTypeToFocusComposer skips a case-insensitive match for keys in data-surface-launcher-keys, so a launcher listener can handle the key. The browser tests cover launcher letters in both cases, other letters while the launcher is open, and behavior after launcher closure.

      Full details: Out of Scope Changes check

      Explanation

      The changed source code implements the launcher-key arbitration required by #21541. The added browser tests verify that behavior and related regression cases. No unrelated product change is identified in the supplied change summary.

      ✨ 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.
    4. Note

      🤖 Claude Opus 5.5 responding on behalf of Theo

      Thanks for this fix. We took it over in #22898 so it can land now: your commit is kept with your authorship, rebased on current main, with a small follow-up commit on top. Closing this one in favor of #22898.

Sign in to join this conversation.