Skip to content

Hide Favourites from guest mode switcher on dashboard#934

Merged
cursor[bot] merged 18 commits into
mainfrom
cursor/hide-favourites-guest-mode-a26d
Jul 19, 2026
Merged

Hide Favourites from guest mode switcher on dashboard#934
cursor[bot] merged 18 commits into
mainfrom
cursor/hide-favourites-guest-mode-a26d

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Hides Favourites from signed-out guests across dashboard discovery: mode switcher, sidebar Your library, Tools Saved filter/workflows, composer cross-mode chips, universal-search also-matches, tools catalog ranking, and prefetch. Guests who open /favourites directly 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).
  • Focused Vitest for favourites/auth-gate, tools-catalog, and app-modes — passed locally.
  • 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).
  • Browser guest proof — no Your library/Favourites in sidebar; Tools has no Saved filter; /favourites shows signup gate.

Risk and rollout

  • Risk: low — navigation and discovery gating only; no answer-generation, retrieval scoring, ingestion, RLS, or document-access contract changes. Fail-closed defaults hide Favourites when session access is unknown.
  • Rollback: revert the PR commit; guests regain prior Favourites discovery affordances.
  • Provider or production effects: none. No OpenAI, Supabase schema, or edge-function changes.

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy)
  • Service-role keys and private document access remain server-only
  • Demo/synthetic content remains clearly separated from real clinical sources
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative
  • Deployment classification/TGA SaMD impact was checked when clinical decision-support behavior changed

Notes

  • TGA SaMD item: N/A for clinical decision-support behavior — this change only gates Favourites navigation/discovery for guests; answer synthesis, retrieval, and source governance are unchanged.
  • Intentional residual: guests can still deep-link to /favourites and see the account signup gate. Mockup routes remain out of scope.
  • Maintainability: shell actions extracted to use-dashboard-shell-actions.ts so ClinicalDashboard.tsx stays within the hotspot budget.

Summary by CodeRabbit

  • New Features

    • Added account access gating for Favourites across the dashboard, navigation, search, tool launcher, and related shortcuts.
    • Guests now see an account setup prompt instead of Favourites content and cannot navigate directly to restricted views.
    • Demo and authenticated sessions retain access to Favourites and Saved workflows.
  • Bug Fixes

    • Prevented restricted Favourites links, search matches, filters, and route prefetches from appearing for guests.
    • Improved page synchronization during UI loading and remounting.
  • Tests

    • Added coverage for guest and authenticated Favourites access, filtering, navigation, and launcher behavior.

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).
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Favourites 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.

Changes

Favourites access gating

Layer / File(s) Summary
Session-filtered catalog and search contracts
src/lib/app-modes.ts, src/lib/tools-catalog.ts, src/lib/universal-search.ts, tests/app-modes.test.ts, tests/tools-catalog.test.ts
Tool catalogs, ranking, and cross-mode lists exclude Favourites for unauthenticated non-demo sessions and pass session context through search ranking.
Dashboard shell and account setup gate
src/components/clinical-dashboard/use-dashboard-shell-actions.ts, src/components/ClinicalDashboard.tsx, src/components/clinical-dashboard/favourites-guest-gate.tsx, src/components/clinical-dashboard/global-search-shell.tsx
Dashboard actions centralize transient surfaces, guard Favourites navigation and prefetching, and render account setup for inaccessible Favourites views.
Session-aware applications launcher
src/components/applications-launcher-page.tsx, tests/favourites-auth-gate.dom.test.tsx
Launcher apps, shortcuts, filters, selections, and labels are derived from Favourites access state.
Search mode and result filtering
src/components/clinical-dashboard/master-search-header.tsx, src/components/clinical-dashboard/search-results-header-band.tsx, src/components/clinical-dashboard/universal-search-*, tests/favourites-auth-gate.test.ts
Search modes, cross-mode chips, local matches, and also-matches links hide or block Favourites when access is unavailable.

Review support updates

Layer / File(s) Summary
Ledger and UI synchronization updates
docs/branch-review-ledger.md, tests/ui-overlap.spec.ts
Review ledger records are appended, and the home-page helper waits for exactly one visible search header.

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
Loading

Possibly related PRs

Suggested labels: codex

Suggested reviewers: claude

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.39% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: hiding Favourites from guest dashboard mode switching.
Description check ✅ Passed The description matches the template and includes summary, verification, risk/rollout, governance, and notes sections with relevant details.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/hide-favourites-guest-mode-a26d

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

@supabase

supabase Bot commented Jul 19, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

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.
Append the PR #934 local review outcome for HEAD 23d0553 so review
throttling can skip unchanged re-reviews of the same scope.
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.
@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown

CI triage

CI failed on this PR. Automated classification of the 2 failed job(s):

  • Production UIneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • PR requiredneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.

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.
@cursor

cursor Bot commented Jul 19, 2026

Copy link
Copy Markdown

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 /favourites still shows the signup gate. Signed-in + demo unchanged.

Final hardening on 04192653: rankToolRecords fails closed by default; mode/chip filters no longer double-OR demoMode; gated deep-link mode chrome falls back to Answer; MasterSearchHeader mode-menu DOM tests added.

Local verification: focused Vitest 37/37; verify:cheap green earlier; verify:pr-local re-running after stopping the project dev server for build.

Residual: intentional deep-link to /favourites (gated). Mockup routes out of scope.

@cursor
cursor Bot marked this pull request as ready for review July 19, 2026 20:16
@cursor

cursor Bot commented Jul 19, 2026

Copy link
Copy Markdown

Merged latest origin/main (PR #933 Safari dock reserve) into this branch to clear the conflict. Ledger conflict resolved by keeping both review rows. Focused favourites + merge-artifact tests: 48/48. Waiting on CI for head 8755cc6e, then squash-merging.

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.
Resolve branch-review-ledger conflict by retaining both Favourites
guest-blackout review rows and the #933/#942 PR-policy closeout from main.
Bring in #936 documents search header chrome from main and keep Favourites
guest-blackout review rows alongside the #933/#942 PR-policy closeout.
Harden gotoHome so the 1366px overlap case does not fail on a
transient duplicate header during client remount/hydration.
@cursor
cursor Bot merged commit 75f11d3 into main Jul 19, 2026
17 checks passed
@cursor
cursor Bot deleted the cursor/hide-favourites-guest-mode-a26d branch July 19, 2026 20:53

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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/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

📥 Commits

Reviewing files that changed from the base of the PR and between bdc333a and 31192b1.

📒 Files selected for processing (18)
  • docs/branch-review-ledger.md
  • src/components/ClinicalDashboard.tsx
  • src/components/applications-launcher-page.tsx
  • src/components/clinical-dashboard/favourites-guest-gate.tsx
  • src/components/clinical-dashboard/global-search-shell.tsx
  • src/components/clinical-dashboard/master-search-header.tsx
  • src/components/clinical-dashboard/search-results-header-band.tsx
  • src/components/clinical-dashboard/universal-search-also-matches.tsx
  • src/components/clinical-dashboard/universal-search-command-surface.tsx
  • src/components/clinical-dashboard/use-dashboard-shell-actions.ts
  • src/lib/app-modes.ts
  • src/lib/tools-catalog.ts
  • src/lib/universal-search.ts
  • tests/app-modes.test.ts
  • tests/favourites-auth-gate.dom.test.tsx
  • tests/favourites-auth-gate.test.ts
  • tests/tools-catalog.test.ts
  • tests/ui-overlap.spec.ts

Comment on lines +269 to +287
* 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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 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.

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.

2 participants