Skip to content

fix(frontend): enter the portal preview without a reload - #2314

Merged
hello1101n merged 3 commits into
constructorfabric:mainfrom
hello1101n:fix/portal-preview-toggle-live
Aug 7, 2026
Merged

fix(frontend): enter the portal preview without a reload#2314
hello1101n merged 3 commits into
constructorfabric:mainfrom
hello1101n:fix/portal-preview-toggle-live

Conversation

@hello1101n

@hello1101n hello1101n commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Problem

Turning Portal (preview) on from the sidebar while standing on / flipped the
switch 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 in beforeLoad, which runs on
navigation 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 root
shell hands to PortalLayout (isPortalShellPath claims /portal and the person
routes, not /).

The inverse direction already worked: /portal carries a live guard that sends the
reader home when the preview goes off.

Change

The / route component carries the matching guard, so the two directions are
symmetric:

const portal = usePortalEnabled();
if (portal) return <Navigate to="/portal" replace />;

beforeLoad keeps its redirect — a cold load of / with the preview on still
resolves to a real destination in the address bar rather than rendering the portal
under /.

Testing

New src/routes/index.test.tsx (follows the idiom in routes/portal.test.tsx):

  • dashboard renders while the preview is off, no navigation issued
  • flipping the preview on under a mounted / 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 --noEmit and eslint on the
changed files are all clean.

Also

.playwright-cli/ — the session output directory the playwright CLI writes when
driving the UI — is now ignored, so a browser-driven check no longer dirties the tree.

Summary by CodeRabbit

  • New Features

    • Automatically redirects visitors from the home page to the portal when the portal is enabled.
    • Preserves the existing dashboard view when the portal is disabled.
  • Tests

    • Added coverage for home-page rendering and automatic portal redirection, including changes while the page is open.

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>
@hello1101n
hello1101n requested a review from a team as a code owner August 7, 2026 03:48
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2b7a5f22-10df-4190-9bde-6b7e3ba45086

📥 Commits

Reviewing files that changed from the base of the PR and between afeb661 and ef01a65.

📒 Files selected for processing (1)
  • .gitignore
🚧 Files skipped from review as they are similar to previous changes (1)
  • .gitignore

📝 Walkthrough

Walkthrough

The root route redirects to /portal when the portal is enabled. Tests cover dashboard rendering and runtime redirection. Playwright CLI session artifacts are ignored.

Changes

Portal routing

Layer / File(s) Summary
Root route redirect and coverage
src/frontend/src/routes/index.tsx, src/frontend/src/routes/index.test.tsx
IndexRoute observes portal state and replaces the root route with /portal when enabled. Tests cover dashboard rendering and state changes after mount.

Playwright artifact cleanup

Layer / File(s) Summary
Playwright CLI artifact ignore rule
.gitignore
.playwright-cli/ session artifacts are excluded from version control.

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`
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: entering portal preview from the root route without a page reload.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ef81f55 and afeb661.

📒 Files selected for processing (3)
  • .gitignore
  • src/frontend/src/routes/index.test.tsx
  • src/frontend/src/routes/index.tsx

Comment thread src/frontend/src/routes/index.tsx
@hello1101n
hello1101n requested a review from mitasovr August 7, 2026 04:53
@hello1101n
hello1101n enabled auto-merge August 7, 2026 04:56
@hello1101n
hello1101n added this pull request to the merge queue Aug 7, 2026
Merged via the queue into constructorfabric:main with commit 0502826 Aug 7, 2026
51 checks passed
@hello1101n
hello1101n deleted the fix/portal-preview-toggle-live branch August 7, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants