Skip to content

fix(web): restore focus after closing a workflow run - #46779

Merged
juliusmarminge merged 8 commits into
pingdotgg:mainfrom
StiensWout:wf/find-66982ca19f0f0307c3f41484
Dec 1, 2026
Merged

juliusmarminge merged 8 commits into
pingdotgg:mainfrom
StiensWout:wf/find-66982ca19f0f0307c3f41484

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

Closing a workflow run with the keyboard could send focus to Definitions or leave it on the page body. Focus now returns to the run row when available, with Toggle right panel as the fallback. Closing just the companion pane returns focus to the subject chip that opened it, even when the layout temporarily hides the chip, and closing both panes returns focus to the panel toggle.

Related: #35465, #46511, #46449, #46207, #44721

Reproduction on main

Commit 96d2a89d0a (main), in the running web app:

  1. Start the T3 Code web app and open it in a browser window at least 768 pixels wide.
  2. Open Settings → Labs and turn on Workflows.
  3. Open the command palette and choose Open workflows.
  4. Click Definitions.
  5. Click New file, enter report.ts, and click Create.
  6. Click Save to save the default my-workflow definition.
  7. Run t3 workflow start my-workflow --key one from the command line.
  8. Click Workflows in the breadcrumb, then reload the page so the run opens in the right panel.
  9. Click the run's tab in the right panel header to focus it.
  10. Press Control+Alt+B (or Command+Option+B on macOS) to close the right panel.

Keyboard focus moves to the Definitions button in the header instead of the Toggle right panel button. Expected: With no earlier control to return focus to, keyboard focus moves to the Toggle right panel button in the header, matching other right panels in the app.

The cause is at apps/web/src/components/workflows/WorkflowRunsView.tsx:544. Ran pnpm scenarios:prove scripts/scenarios/closing-workflow-panel-keeps-keyboard-focus.e2e.ts --target web with the repro scenario added: it failed in 2 of 2 runs on a clean checkout, with expect.toBeFocused failed in the output.

Evidence

Environment: The web app in Chromium on Linux x64, a fresh checkout.

Proven: the repro fails at the test commit 1be31d72f9 and passes on the head e9fa6557ab, both on main 3763606d20.

Before After
Commit 1be31d72f9 e9fa6557ab
Result ASSERTION_FAILED: expect.toBeFocused failed passed
after closing from the keyboard Before: after closing from the keyboard Before: after closing from the keyboard (changed region)
Keyboard focus moves to the Definitions button in the header instead of the Toggle right panel button.
After: after closing from the keyboard After: after closing from the keyboard (changed region)
With no earlier control to return focus to, keyboard focus moves to the Toggle right panel button in the header, matching other right panels in the app.
failure Before: failure
Recording Before: recording After: recording

Outside view: a person sees it in the running web app by following the steps under Reproduction on main.

Tests

  • 1be31d72f9 adds the failing test, alone, before the fix.
  • pnpm exec vp run check:changed 3763606d20cd834ebfb419ef1525695b397af793 passed on head.

Not in this change

  • Browser coverage includes wide, intermediate, and narrow layouts. Electron-specific shortcut dispatch is outside that coverage.
  • The supplementary before-and-after captures and recording are available locally for attachment.

Who did the work

  • Repro written by GPT 6.2 Sol, in Codex
  • Outside view by Gemini 4 Neon, in Antigravity
  • Duplicate check judged by Claude Opus 5.5, in Claude Code
  • Written by GPT 6.2 Sol, in Codex
  • Trimmed by Claude Opus 5.5, in Claude Code
  • Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex, and by Gemini 4 Neon, in Antigravity
  • Reproduction, checks and proof run by a program on base and head, not by an agent

Made in T3 Code by GPT 6.2 Sol, Claude Opus 5.5 and Gemini 4 Neon

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Dec 1, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Dec 1, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at b0db06a

Macroscope's review found this PR approvable — Restores focus to the workflow run row or reference button after its panel closes. The change is limited to browser focus behavior and preserves safeguards against moving focus away from another active control.

Notes:

  • No code objects were reviewed. Approvability was decided on eligibility alone.

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

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes add configurable focus restoration for preview panels. Workflow navigation now passes opener buttons to panel callbacks and records them as restoration targets. Browser and end-to-end tests cover focus after closing workflow panels.

Changes: Workflow panel focus restoration

Layer / File(s) Summary
Panel unmount restoration
apps/web/src/components/RightPanelTabs.tsx, apps/web/src/components/preview/PreviewPanelShell.tsx
RightPanelTabs can forward a focus-restoration callback. PreviewPanelShell uses it to select the focus target during unmount cleanup; without a callback, restoration remains tied to collapsible.
Workflow opener tracking
apps/web/src/components/workflows/WorkflowReferences.tsx, apps/web/src/components/workflows/WorkflowRunFeed.tsx, apps/web/src/components/workflows/WorkflowRunsView.tsx, apps/web/src/components/workflows/WorkflowsPage.tsx, apps/web/src/components/workflows/WorkflowRunsView.browser.test.tsx
Workflow reference callbacks pass the clicked button through the workflow views to WorkflowsPage. The page records the opener and selects a restoration target based on panel state and whether the opener can receive focus. Run-row buttons are marked as eligible focus origins. Browser assertions check the forwarded buttons.
Focus restoration scenarios
scripts/scenarios/workflow-panels-restore-the-right-focus-target.e2e.ts
End-to-end scenarios check focus after closing workflow panels opened from different controls and at several viewport widths.

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant WorkflowReferenceChip
  participant WorkflowRunsView
  participant WorkflowsPage
  participant PreviewPanelShell
  WorkflowReferenceChip->>WorkflowRunsView: Pass reference and opener button
  WorkflowRunsView->>WorkflowsPage: Pass run ID, reference, and opener
  WorkflowsPage->>WorkflowsPage: Save opener when opening or switching panes
  PreviewPanelShell->>WorkflowsPage: Request restoration target on unmount
  WorkflowsPage-->>PreviewPanelShell: Return saved opener, origin, or null
Loading

Suggested reviewers: iamshadmantaqi, juliusmarminge

Merge Risk: Minimal · up to b0db0

This change restores keyboard focus to the run row, subject chip, or panel toggle after a workflow pane closes. I found no concrete regression risk in the changed code, and the change is covered by browser and end-to-end tests.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(web): restore focus after closing a workflow run" matches the main change in the raw summary. The changes add focus restoration to PreviewPanelShell, WorkflowsPage, and WorkflowRunsView…
Description check Passed The description is mostly complete and follows the template. It has a clear Problem section with reproduction steps and expected behavior, and a Change section that explains the fix at a high level. T…
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 "fix(web): restore focus after closing a workflow run" matches the main change in the raw summary. The changes add focus restoration to PreviewPanelShell, WorkflowsPage, and WorkflowRunsView, and the PR objectives describe the same goal. The title follows the conventional commit format from the description template and is specific enough for a teammate to understand the primary change.

Full details: Description check

Explanation

The description is mostly complete and follows the template. It has a clear Problem section with reproduction steps and expected behavior, and a Change section that explains the fix at a high level. The Verification section includes focused test results and before/after evidence. The Scope section lists related issues, but it does not state why the bug needs no issue or whether a maintainer requested the PR. The Change section also does not explain the focus-restoration design for the workflow panes. The description includes a long model and harness attribution list, which the template asks for only as a single closing line. These gaps are minor, so the check passes.

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 5b7bb11 and b0db06a.

Files selected for processing: 1

  • scripts/scenarios/workflow-panels-restore-the-right-focus-target.e2e.ts
Files with no reviewable changes: 1

  • scripts/scenarios/workflow-panels-restore-the-right-focus-target.e2e.ts

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

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Dec 1, 2026
@macroscopeapp
macroscopeapp Bot dismissed their stale review December 1, 2026 13:15

Dismissing prior approval to re-evaluate b0db06a

@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Environment: Real web app, e2e Chromium browser, light theme, Linux; scenarios:prove ran separate base/head checkouts and fresh isolated server databases. Synthetic demo project and finished workflow with example.com subject were created through the scenario project helper, workflow definition, server settings RPC and real workflow CLI. No provider response was needed.

Steps: At 1280×800, open /workflows with a finished Nightly report run automatically selected; focus its tab and press Ctrl+W. Focus the run row and press Enter, focus its tab and press Ctrl+W. Reopen from the row, focus the tab and press Ctrl+Alt+B. Reopen from the row; focus the example.com subject chip and press Enter, then focus Close the pane and press Enter, at 1280×800 and 1024×800 (chip hidden while pane is open at 1024). Reopen the companion, focus Close the pane and press Ctrl+W to close both panes. At 650×800, reopen with Toggle right panel, focus the run tab and press Ctrl+W.

Scenario: Workflow panels restore focus to the control that can reopen them

Proven: the scenario fails on base 3763606d20 and passes on head b0db06a485.

Base 3763606d20 Head b0db06a485
Result ❌ failed
ASSERTION_FAILED: expected ["panel toggle","subject chip 1280","subject chip 1024","panel toggle"] to equal []
✅ passed
wide toggle focused Base 3763606d20: wide toggle focused Head b0db06a485: wide toggle focused
run row focused Base 3763606d20: run row focused Head b0db06a485: run row focused
toggle shortcut row focused Base 3763606d20: toggle shortcut row focused Head b0db06a485: toggle shortcut row focused
subject focused 1280 Base 3763606d20: subject focused 1280 Head b0db06a485: subject focused 1280
subject focused 1024 Base 3763606d20: subject focused 1024 Head b0db06a485: subject focused 1024
both panes closed toggle focused Base 3763606d20: both panes closed toggle focused Head b0db06a485: both panes closed toggle focused
after closing in narrow layout Base 3763606d20: after closing in narrow layout Head b0db06a485: after closing in narrow layout
failure Base 3763606d20: failure
Recording Before After
Same scripted interactions Before video After video

Scenario and seed script

Base reproduces the auto-opened-run and both companion-pane defects, plus failure to restore the panel toggle when closing both panes. Head restores every expected focus target. Row close, toggle shortcut and the 650px case pass on both.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Dec 1, 2026
@juliusmarminge
juliusmarminge merged commit a989ee8 into pingdotgg:main Dec 1, 2026
60 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Dec 1, 2026
@StiensWout
StiensWout deleted the wf/find-66982ca19f0f0307c3f41484 branch December 2, 2026 07:33
imetn added a commit to imetn/t4code that referenced this pull request Dec 2, 2026
Surgically ports 62 upstream Web UI fixes from pingdotgg/t3code
(772e3d4..1e6e7d7) into apps/web and scripts/scenarios while
preserving all 31 locked T4 customizations, T4 branding, and
t4-overrides.css.

Also restores React Compiler compilation for Sidebar by moving the
default new Set(...) parameter inside settleLaunchGroup into the
function body so switching threads produces 0 unaffected row re-renders.

Ported (62 commits):
- 1a08049 (pingdotgg#46481): right-panel launcher keys blocked while context menu open
- 6bdd718 (pingdotgg#46489): Enter restores highlighted stashed prompt (scenario e2e; web code already absorbed)
- 347f551 (pingdotgg#46490): Escape closes open context menu before layer beneath it
- afa3003 (pingdotgg#46487): workflows page uses width of wide window
- a2ba869 (pingdotgg#46485): keep joined emoji whole in screen-reader announcements
- a8ee725 (pingdotgg#46493): holding stash shortcut keeps prompt saved (scenario e2e; web code already absorbed)
- 5048c80 (pingdotgg#46499): Mod+S moves edited queued reply to prompt stash
- 179e6c3 (pingdotgg#46506): holding stash delete shortcut removes one prompt (scenario e2e; web code already absorbed)
- c101437 (pingdotgg#44079): fold PR diff whose header was clicked
- 9b27e5a (pingdotgg#46562): second Mod+T keeps right-panel Add menu shortcuts working
- 62cf1fe (pingdotgg#46592): wait for dialog focus before opening context menu over it
- fda1c30 (pingdotgg#46579): resting on issue row prefetches detail
- 28f0c93 (pingdotgg#46593): slash-command description tooltip closes when modal opens
- 789784b (pingdotgg#46603): keep selected tab in Workflows links
- 2bc37d9 (pingdotgg#46597): / and Mod+F in Settings ignore open context menu
- b21923b (pingdotgg#46640): effort shortcut closes nested Permissions menu in model picker
- a5a39fa (pingdotgg#46641): inline thread details card grows with interface font size
- 36983d6 (pingdotgg#46644): workflow runs open in resizable right panel
- 2ad902f (pingdotgg#46691): Mod+F on PRs page ignores open menu
- 97d727c (pingdotgg#46699): Link pull request dialog closes when leaving thread
- 7a9d213 (pingdotgg#46729): refuse saving edit to deleted project script action
- bdda9ce (pingdotgg#46745): settling open delegated task opens next thread
- 3763606 (pingdotgg#46760): command menu description tooltip closes on composer focus loss
- 00eae4b (pingdotgg#46764): reopen workflow run on first click
- 19094fd (pingdotgg#46765): boring sidebar folder rows offer snooze again
- dec756c (pingdotgg#46766): reopen last workflow run after hiding panel
- 33ce571 (pingdotgg#46777): keep workflow runs open behind tab menus
- a989ee8 (pingdotgg#46779): restore focus after closing workflow run
- 5c42b2e (pingdotgg#46786): reopen closed workflow run tabs
- caec30f (pingdotgg#46792): cancel tab drags when switching threads
- 27cf2cf (pingdotgg#46794): disable empty panel shortcuts as it closes
- d65936e (pingdotgg#46791): reveal all side panel tabs when they fit
- a9daa0b (pingdotgg#46781): right-panel shortcuts ignore presses while menu/dialog open
- 35b6c5f (pingdotgg#46801): dismissing PR checkout toast cancels handoff
- e9da1b0 (pingdotgg#46818): boring sidebar folder row actions keep height and clicks
- 9feac49 (pingdotgg#46855): long PR search preserves grapheme clusters
- acef160 (pingdotgg#46849): find shared voice dictionary by Japanese label
- 19da14d (pingdotgg#46796): scrolled right panel tabs no longer block chat titlebar drag
- 506bc36 (pingdotgg#46853): close guest share and handoff dialogs when leaving thread
- b4fd7ba (pingdotgg#46879): let Escape and app shortcuts pass through terminal font preview
- f5689ae (pingdotgg#46835): long history load errors wrap without timeline horizontal overflow
- 6b64b0c (pingdotgg#46890): focus command dialog popup when search input disabled
- 70c9da7 (pingdotgg#46900): focus PR Author/Labels filter search inputs on keyboard open
- 891bf1a (pingdotgg#46924): late slash results no longer open tooltip after focus leaves
- 80f0f8a (pingdotgg#46930): copying failed message keeps its images
- e9ca942 (pingdotgg#46659): show workflow question kinds only in filter
- aa8c7c7 (pingdotgg#46941): queued message moves to stash only once removed
- 3ea13b6 (pingdotgg#46940): editing answer while image prepares cancels held submit
- a143526 (pingdotgg#46970): pasting copied file over reattach marker no longer reports failure
- b33c330 (pingdotgg#47011): stub addComposerFilesToDraft with new return shape in test
- a0fb9d1 (pingdotgg#46974): Issues Labels/Assignee filters focus search on keyboard open
- cb525f4 (pingdotgg#47029): clicking anywhere on terminal or panel tab activates it
- 498a3b6 (pingdotgg#47022): syncing messages line no longer shifts whole chat
- e903c85 (pingdotgg#47046): pasted messages with thread link keep picture
- 6a13142 (pingdotgg#47013): limit style invalidation during right-panel resize
- cd8961e (pingdotgg#47078): pasting copied file no longer takes preparing screenshot slot
- 8d0fb4b (pingdotgg#47100): stop showing previous Usage period as loading after failure
- 515b8c9 (pingdotgg#47114): Tab from Permissions menu keeps focus inside model picker
- a681dd5 (pingdotgg#47125): middle-clicking file link no longer opens broken tab
- bbde8dc (pingdotgg#44842): use plus icon for project new-thread buttons
- 59af88f (pingdotgg#47105): switching threads no longer re-renders unaffected sidebar rows
- 1e6e7d7 (pingdotgg#47080): Reopen Closed Tab skips workflow runs removed from history

Already absorbed in HEAD (3 commits):
- 20a0e5f (pingdotgg#46927), a684090 (pingdotgg#47026), c557dab (pingdotgg#47076)

Skipped cleanly (3 commits):
- 70224ca (pingdotgg#46712): depends on unported ui/open-popups.tsx (pingdotgg#45341)
- cf475c4 (pingdotgg#47034): depends on unported ui/open-popups.tsx (pingdotgg#45341)
- be3cc6c (pingdotgg#47145): depends on unported fitsWithAllowance/workGroupOverflowAllowance in TimelineWorkGroupRows.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted 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