Gate Favourites to signed-in users with Your library sidebar - #931
Conversation
Hide Favourites from public Tools and the mode menu unless the user is authenticated or demo mode is active. Surface it under a new Your library sidebar section when allowed, and keep /favourites on-page with a favourites-intent account setup dialog for signed-out visitors.
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
📝 WalkthroughWalkthroughFavourites access is now session-aware across app modes, sidebars, search navigation, the command library, and account setup. Account setup supports favourites-specific intent copy, and the prior-answer surface is extracted into its own component. ChangesFavourites access and account setup
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant MasterSearchHeader
participant ClinicalDashboard
participant useFavouritesAccess
participant AccountSetupDialog
User->>MasterSearchHeader: select favourites mode
MasterSearchHeader->>ClinicalDashboard: request account setup when access is unavailable
ClinicalDashboard->>useFavouritesAccess: openAccountSetup("favourites")
useFavouritesAccess->>AccountSetupDialog: provide open state and intent
AccountSetupDialog-->>User: render favourites setup content
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Extract PriorAnswerTurnSurface and share useFavouritesAccess between the shell and dashboard so Favourites gating does not grow the monolith. Derive the favourites signup dialog open state without setState-in-effect.
Cover sidebar visibility, signed-out signup intent, and demo-mode library access. Note that tablet rail Favourites remains available under demo mode.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@cursoragent Please can you resolve all failing CI testing for me and resolve any unresolved comments |
|
PR #931 is fixed and already merged. What failedOnly PR policy — the body was missing the required What I did
CI outcome
PR state: MERGED ( |
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/ClinicalDashboard.tsx`:
- Around line 2658-2663: Update the searchParams/bootstrap handling in
ClinicalDashboard so URL-driven mode=favourites is validated with
favouritesAccessible before rendering or selecting FavouritesHub. When access is
unavailable, route through the existing account-setup fallback (or another
permitted mode), matching selectSearchMode’s behavior, while preserving
accessible favourites navigation.
🪄 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: d7e565e8-9796-4954-b647-14a7d47ab550
📒 Files selected for processing (13)
src/components/ClinicalDashboard.tsxsrc/components/clinical-dashboard/ClinicalSidebar.tsxsrc/components/clinical-dashboard/account-setup-dialog.tsxsrc/components/clinical-dashboard/favourites-command-library-page.tsxsrc/components/clinical-dashboard/global-search-shell.tsxsrc/components/clinical-dashboard/master-search-header.tsxsrc/components/clinical-dashboard/prior-answer-turn-surface.tsxsrc/components/clinical-dashboard/use-favourites-access.tssrc/lib/app-modes.tstests/app-modes.test.tstests/favourites-auth-gate.dom.test.tsxtests/favourites-auth-gate.test.tstests/ui-smoke.spec.ts
| function selectSearchMode(mode: AppModeId) { | ||
| if (mode === "favourites" && !favouritesAccessible) { | ||
| closeDashboardTransientSurfaces("accountSetup"); | ||
| openAccountSetup("favourites"); | ||
| return; | ||
| } |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
fd -i favourites-hub | xargs -I{} ast-grep outline {} --items all
rg -n "favouritesAccessible|canAccessFavouritesMode" src/components/clinical-dashboard/favourites-hub.tsx 2>/dev/null || echo "favourites-hub.tsx not found by that name; search broader"
rg -n "FavouritesHub" -g '*.tsx' -A2 -B2Repository: BigSimmo/Database
Length of output: 1490
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Map relevant files and inspect the specific sections mentioned in the comment.
ast-grep outline src/components/ClinicalDashboard.tsx --items all | sed -n '1,220p'
printf '\n--- ClinicalDashboard around mode-sync / search-mode logic ---\n'
sed -n '2500,2745p' src/components/ClinicalDashboard.tsx
printf '\n--- ClinicalDashboard FavouritesHub rendering area ---\n'
sed -n '3725,3785p' src/components/ClinicalDashboard.tsx
printf '\n--- Favourites hub component outline ---\n'
ast-grep outline src/components/clinical-dashboard/favourites-hub.tsx --items all | sed -n '1,220p'
printf '\n--- Favourites hub access-related searches ---\n'
rg -n "favouritesAccessible|sign up to save favourites|account setup|openAccountSetup|useSavedRegistryFavourites|useDemoMode|isDemoMode|accessible" src/components/clinical-dashboard/favourites-hub.tsx src/components/ClinicalDashboard.tsx tests/favourites-hub-unavailable-controls.dom.test.tsx
printf '\n--- Favourites hub relevant top/mid sections ---\n'
sed -n '1,220p' src/components/clinical-dashboard/favourites-hub.tsx
printf '\n--- Favourites hub later sections ---\n'
sed -n '220,620p' src/components/clinical-dashboard/favourites-hub.tsxRepository: BigSimmo/Database
Length of output: 46458
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the dashboard effects that react to search params / initial URL state.
rg -n "searchParams|window.location.search|setSearchMode\\(|appModeId|appModeVisible|modeSearchSubmitted|executeSearch\\(" src/components/ClinicalDashboard.tsx
printf '\n--- search-param/bootstrap effect region ---\n'
sed -n '1500,1825p' src/components/ClinicalDashboard.tsx
printf '\n--- executeSearch region around the unconditional setSearchMode ---\n'
sed -n '2560,2715p' src/components/ClinicalDashboard.tsx
printf '\n--- any favourites-specific route/guard helpers in dashboard ---\n'
rg -n "favouritesAccessible|openAccountSetup\\(\"favourites\"\\)|mode === \"favourites\"|appModeHomeHref\\(\"favourites\"|appModeVisible" src/components/ClinicalDashboard.tsx src/lib src/components/clinical-dashboard testsRepository: BigSimmo/Database
Length of output: 25197
Guard dashboard URL-driven favourites navigation. searchParams/bootstrap handling in src/components/ClinicalDashboard.tsx still accepts mode=favourites without favouritesAccessible, so a signed-out non-demo user can land in the inline FavouritesHub even though the UI entry point is blocked. Add the same access check there and fall back to account setup or another mode.
🤖 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/ClinicalDashboard.tsx` around lines 2658 - 2663, Update the
searchParams/bootstrap handling in ClinicalDashboard so URL-driven
mode=favourites is validated with favouritesAccessible before rendering or
selecting FavouritesHub. When access is unavailable, route through the existing
account-setup fallback (or another permitted mode), matching selectSearchMode’s
behavior, while preserving accessible favourites navigation.


Summary
Favourites is account-scoped and should not be discoverable for public (signed-out, non-demo) users.
/favouritesstays on the page, shows a gate panel, and auto-opens account setup with Sign up to save favourites copy.Key implementation:
canAccessFavouritesMode/visibleAppModeDefinitionsForSession, shareduseFavouritesAccess, Favourites moved from Tools into Your library, favourites-intent account setup, andPriorAnswerTurnSurfaceextraction to keep ClinicalDashboard under the maintainability budget.Verification
npm run verify:pr-localnpm run verify:uisuite is covered by the CI Production UI job on this PR; local offline-demo Playwright favourites smoke (npm run test:e2e -- tests/ui-smoke.spec.ts— tablet rail, mode menu, favourites routes) passed 7/7.Risk and rollout
Clinical Governance Preflight
Clinical KB Database(sjrfecxgysukkwxsowpy)Notes
supabase/directory changes.Summary by CodeRabbit
New Features
Bug Fixes
Tests