fix(frontend): enter the portal preview without a reload - #2314
Conversation
The "/" route chooses between the dashboard and the portal in `beforeLoad`, which runs on navigation only. Turning the preview on from the sidebar while "/" is mounted flipped the switch and persisted the flag, but left the dashboard on screen until the next reload — the store emitted, and nothing that re-rendered owned the decision. The route component now carries the guard `/portal` already has for the inverse case: with the preview on it redirects into the portal, so the same emit that repaints the switch moves the reader. The two directions are now symmetric. Signed-off-by: hello1101n <hello1101n@users.noreply.github.com>
Signed-off-by: hello1101n <hello1101n@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe root route redirects to ChangesPortal routing
Playwright artifact cleanup
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant IndexRoute
participant PortalState
participant Router
IndexRoute->>PortalState: Read portal enablement
PortalState-->>IndexRoute: Return enabled state
IndexRoute->>Router: Replace route with `/portal`
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/frontend/src/routes/index.tsx`:
- Around line 20-23: Keep IndexRoute as a screen wrapper by removing its
usePortalEnabled() call and conditional Navigate branch. Move both into the
screen component rendered by IndexRoute, preserving the redirect to "/portal"
with replace enabled when the portal is active.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: c060d4d6-2ac3-4612-96c3-661e7520da5c
📒 Files selected for processing (3)
.gitignoresrc/frontend/src/routes/index.test.tsxsrc/frontend/src/routes/index.tsx
Problem
Turning Portal (preview) on from the sidebar while standing on
/flipped theswitch and persisted the flag, but the dashboard stayed on screen. The portal only
appeared after a manual reload.
/decides between the dashboard and the portal inbeforeLoad, which runs onnavigation only. The store emitted and the switch repainted, but nothing that
re-rendered owned the dashboard-vs-portal decision, and
/is not a path the rootshell hands to
PortalLayout(isPortalShellPathclaims/portaland the personroutes, not
/).The inverse direction already worked:
/portalcarries a live guard that sends thereader home when the preview goes off.
Change
The
/route component carries the matching guard, so the two directions aresymmetric:
beforeLoadkeeps its redirect — a cold load of/with the preview on stillresolves to a real destination in the address bar rather than rendering the portal
under
/.Testing
New
src/routes/index.test.tsx(follows the idiom inroutes/portal.test.tsx):/issues{ to: "/portal", replace: true }Verified on a local compose stand in a browser, both directions, without reloading:
toggle on at
/lands on/portal; toggle off inside the portal returns to/.vitest --project=unit(120 files / 816 tests),tsc -b --noEmitandeslinton thechanged files are all clean.
Also
.playwright-cli/— the session output directory the playwright CLI writes whendriving the UI — is now ignored, so a browser-driven check no longer dirties the tree.
Summary by CodeRabbit
New Features
Tests