Agentic UI: Return to the last visited site instead of the first site - #4130
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📊 Performance Test ResultsComparing f6486cb vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
|
Thanks for the review @katinthehatsite! 🙌
Can you take another look at this PR, please? |
sejas
left a comment
There was a problem hiding this comment.
Looks good. I confirmed the last selected site is the one that is selected when Studio starts again.
I have two suggestions to consider:
- Change the PR title to say last visited site, instead of last visited session.
- If the left sidebar has scroll and the selected site is at the bottom, then the selected site row is not visible when starting Studio.
latest-selected-site.mp4
Let's address that in #4132 |
Done, thanks for catching that! 🙇 |




Related issues
How AI was used in this PR
The core change was cherry-picked from #3998 (authored there with AI assistance). Claude Code ported it onto trunk, resolved merge conflicts (including the moves to id-based session↔site matching from #4131 and the signed-out gates from #4183), addressed review feedback, and wrote the unit tests for the redirect logic. All code was reviewed and verified locally (lint, typecheck, apps/ui test suite).
Proposed Changes
Studio's agentic UI always lands on the first site (in raw fetch order) at launch, regardless of where the user was working. This PR makes the app reopen on the site the user last worked with:
localStorage./index route opens that site's newest active chat (or a new chat if it has none) — matching exactly what clicking the site in the site-centric sidebar (Agentic UI: Make the sidebar site-centric #4191) does.An earlier revision restored the exact last-visited session. We simplified to site-level restore to stay consistent with the site-centric sidebar model: sites are the primary navigation unit, and a site always opens its newest active chat.
No launch-time cost: the index route already fetched sites and sessions before redirecting; this adds only a synchronous
localStorageread.Testing Instructions
Pre-merge Checklist
🤖 Generated with Claude Code