Hide Favourites from guest mode switcher on dashboard#934
Conversation
Wire ClinicalDashboard to session Favourites access and fail closed in MasterSearchHeader so signed-out users no longer see Favourites in the mode menu (sidebar already gated via Your library).
📝 WalkthroughWalkthroughFavourites access is now session-aware across the dashboard, search surfaces, applications launcher, tool catalog, route prefetching, and account setup. Guest users receive filtered UI or an account setup gate, while authenticated and demo sessions retain Favourites access. ChangesFavourites access gating
Review support updates
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant ClinicalDashboard
participant SearchSurface
participant SessionAccess
participant AccountSetupDialog
User->>ClinicalDashboard: select Favourites
ClinicalDashboard->>SessionAccess: check access
SessionAccess-->>ClinicalDashboard: inaccessible
ClinicalDashboard->>AccountSetupDialog: open favourites setup
User->>SearchSurface: search or change mode
SearchSurface->>SessionAccess: filter Favourites targets
SessionAccess-->>SearchSurface: filtered modes and results
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Move guide/settings/account-setup chrome helpers into a dedicated hook so ClinicalDashboard can wire session-gated Favourites without exceeding the maintainability line budget.
Move session Favourites access and transient-surface closing into useDashboardShellActions so prettier-formatted ClinicalDashboard stays under the maintainability budget.
Hide Favourites from composer cross-mode chips, Tools Saved workflows, universal tools ranking, also-matches, and prefetch for non-demo guests, while keeping signed-in and demo sessions unchanged.
CI triageCI failed on this PR. Automated classification of the 2 failed job(s):
Compared with main CI run #3715 (success). Classification is evidence routing, not permission to ignore a failure. Exact quarantined Playwright identities remain governed by the flake ledger. |
Default tool ranking to guest session filtering, stop double-ORing demoMode in mode/chip filters, normalize gated deep-link mode chrome, and add MasterSearchHeader DOM coverage for the mode menu.
Final review closeout (agent)Corrected PR summary for this branch (the PR description currently appears to describe an unrelated admin/migration change — please replace the PR body with this if the Sync PR policy job overwrote it): Summary: Total guest blackout for Favourites when not logged in (and not demo). Guests no longer see Favourites in the mode switcher, sidebar Your library, composer cross-mode chips, Tools Saved workflows/filter/shortcut, universal tools ranking, also-matches, or prefetch. Direct Final hardening on Local verification: focused Vitest 37/37; Residual: intentional deep-link to |
…s-guest-mode-a26d
|
Merged latest |
…s-guest-mode-a26d
Replace the stale admin/migration PR_POLICY_BODY.md inherited from main with the Favourites guest-blackout summary, verification, risk, and fully checked Clinical Governance Preflight (TGA N/A for nav-only).
Generate Clinical Governance Preflight checkboxes from the required policy strings so Sync PR policy body matches what PR Policy validates.
Empty commit so pull_request_target PR Policy evaluates the already synced Clinical Governance Preflight checklist on synchronize.
Main removed the stale PR_POLICY_BODY.md sync template (#942). Drop it here too so CI stops overwriting the Favourites PR description; the Clinical Governance Preflight checklist already synced onto the PR body.
Harden gotoHome so the 1366px overlap case does not fail on a transient duplicate header during client remount/hydration.
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/components/clinical-dashboard/master-search-header.tsx`:
- Around line 269-287: Update the mode-menu option active-state comparison to
use the computed modeTriggerId instead of raw searchMode, so guest Favourites
deep links select the Answer option and preserve aria-checked and tabbable
behavior. Keep the existing fallback calculation and option filtering unchanged.
🪄 Autofix (Beta)
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 986e213c-df76-4d91-b8a9-76d47cf2f02d
📒 Files selected for processing (18)
docs/branch-review-ledger.mdsrc/components/ClinicalDashboard.tsxsrc/components/applications-launcher-page.tsxsrc/components/clinical-dashboard/favourites-guest-gate.tsxsrc/components/clinical-dashboard/global-search-shell.tsxsrc/components/clinical-dashboard/master-search-header.tsxsrc/components/clinical-dashboard/search-results-header-band.tsxsrc/components/clinical-dashboard/universal-search-also-matches.tsxsrc/components/clinical-dashboard/universal-search-command-surface.tsxsrc/components/clinical-dashboard/use-dashboard-shell-actions.tssrc/lib/app-modes.tssrc/lib/tools-catalog.tssrc/lib/universal-search.tstests/app-modes.test.tstests/favourites-auth-gate.dom.test.tsxtests/favourites-auth-gate.test.tstests/tools-catalog.test.tstests/ui-overlap.spec.ts
| * Defaults to false (fail closed) so guests never see Favourites unless the host | ||
| * explicitly grants access from the current session / demo mode. | ||
| */ | ||
| canAccessFavourites?: boolean; | ||
| /** Invoked when the user tries to open Favourites without access. */ | ||
| onRequestAccountSetup?: () => void; | ||
| }) { | ||
| // Hosts pass the precomputed session decision in canAccessFavourites (auth || demo). | ||
| // Do not OR demoMode again here — that would reopen Favourites when props diverge. | ||
| const visibleAppModeOptions = visibleAppModeDefinitionsForSession({ | ||
| authenticated: canAccessFavourites, | ||
| demoMode: false, | ||
| }); | ||
| const trimmedQuery = query.trim(); | ||
| const selectedSearch = appModeSearchConfig(searchMode); | ||
| const selectedAppMode = appModeDefinition(searchMode); | ||
| // Guests on /favourites keep the route gate, but the mode trigger must not claim | ||
| // Favourites is a selectable guest mode when it is omitted from the menu. | ||
| const modeTriggerId = searchMode === "favourites" && !canAccessFavourites ? "answer" : searchMode; | ||
| const selectedAppMode = appModeDefinition(modeTriggerId); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Keep the mode-menu selection aligned with the guest fallback.
For a guest deep link with searchMode === "favourites", this displays Answer, but the menu later compares each option to raw searchMode. Because Favourites is omitted, no option is aria-checked or tabbable. Use modeTriggerId for that active-state comparison.
Proposed fix
- const active = mode.id === searchMode;
+ const active = mode.id === modeTriggerId;🤖 Prompt for 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.
In `@src/components/clinical-dashboard/master-search-header.tsx` around lines 269
- 287, Update the mode-menu option active-state comparison to use the computed
modeTriggerId instead of raw searchMode, so guest Favourites deep links select
the Answer option and preserve aria-checked and tabbable behavior. Keep the
existing fallback calculation and option filtering unchanged.
Summary
/favouritesdirectly stay on a signup gate (intent="favourites"). Authenticated and demo sessions keep Favourites access.Verification
npm run verify:cheap— passed on PR head (lint, typecheck, unit suite, runtime/CI-scope/sitemap guards).npm run verify:pr-local— passed (format, full unit suite once, production build + client-bundle scan, RAG fixture/manifest validation).npm run verify:ui— hosted Production UI gate on this PR head succeeded (UI-scoped paths include mode header, global search shell, Tools launcher, and Favourites guest gate)./favouritesshows signup gate.Risk and rollout
Clinical Governance Preflight
Clinical KB Database(sjrfecxgysukkwxsowpy)Notes
/favouritesand see the account signup gate. Mockup routes remain out of scope.use-dashboard-shell-actions.tssoClinicalDashboard.tsxstays within the hotspot budget.Summary by CodeRabbit
New Features
Bug Fixes
Tests