fix(dashboard): make demo navigation public-safe#507
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ 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 |
Greptile SummaryThis PR tightens the demo website experience to be public-safe by hiding admin-only surfaces in navigation and command search, keeping Goals and Funnels visible but read-only, and replacing the sanitize-for-demo pattern on flags and target groups with a hard
Confidence Score: 4/5Safe to merge; changes are additive guards that block access rather than relax it, and the new filesystem-backed test provides a regression harness for future nav additions. The logic is straightforward and the RPC changes are conservative (blocking rather than sanitizing). The one pre-existing subtlety — auth inside queryFn in funnels — was only latent because the cache was disabled; the fix is correct and positions the endpoint safely for when the cache is enabled. No mutation paths are affected. No files require special attention. The funnels.ts auth-before-cache refactor is worth a quick read since it changes control flow, but the intent is clear and backed by integration tests. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Client as Demo Caller
participant RPC as RPC Handler
participant Cache as Drizzle Cache
participant DB as Database
note over Client,DB: flags.list / target-groups.list (NEW)
Client->>RPC: request (demo tier)
RPC->>RPC: authorizeFlagRead / withPublicWorkspace
RPC->>RPC: requireAuthedFlagRead → throws UNAUTHORIZED
RPC-->>Client: 401 UNAUTHORIZED
note over Client,DB: funnels.list auth-before-cache fix (NEW)
Client->>RPC: request (public/demo)
RPC->>RPC: withPublicWorkspace runs BEFORE cache
RPC->>Cache: withCache(key, queryFn)
Cache-->>RPC: hit → return cached rows
RPC-->>Client: funnel list (auth always checked)
note over Client,DB: funnels.list (OLD — auth inside queryFn)
Client->>RPC: request
RPC->>Cache: withCache(key, queryFn)
Cache-->>RPC: hit → skip queryFn (auth never ran!)
RPC-->>Client: cached data (auth bypassed on cache hit)
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Client as Demo Caller
participant RPC as RPC Handler
participant Cache as Drizzle Cache
participant DB as Database
note over Client,DB: flags.list / target-groups.list (NEW)
Client->>RPC: request (demo tier)
RPC->>RPC: authorizeFlagRead / withPublicWorkspace
RPC->>RPC: requireAuthedFlagRead → throws UNAUTHORIZED
RPC-->>Client: 401 UNAUTHORIZED
note over Client,DB: funnels.list auth-before-cache fix (NEW)
Client->>RPC: request (public/demo)
RPC->>RPC: withPublicWorkspace runs BEFORE cache
RPC->>Cache: withCache(key, queryFn)
Cache-->>RPC: hit → return cached rows
RPC-->>Client: funnel list (auth always checked)
note over Client,DB: funnels.list (OLD — auth inside queryFn)
Client->>RPC: request
RPC->>Cache: withCache(key, queryFn)
Cache-->>RPC: hit → skip queryFn (auth never ran!)
RPC-->>Client: cached data (auth bypassed on cache hit)
Reviews (1): Last reviewed commit: "fix(dashboard): make demo navigation pub..." | Re-trigger Greptile |
Summary
Validation
bun test apps/dashboard/components/layout/navigation/nav-item-active.test.ts apps/dashboard/next-config.test.ts packages/ai/src/query/builders/public-access.test.tsbunx ultracite checkbun run --cwd packages/rpc check-typesbun run --cwd apps/dashboard check-typesdotenv -- turbo run check-types+enforce-formatdotenv -- turbo run testNotes
Summary by cubic
Tightened the demo website experience to be public-safe: hide admin-only surfaces in navigation and command search, keep Goals and Funnels visible but read-only, and block demo/public RPC reads of flags and target groups. Removed demo routes that exposed non-public features.
hideFromDemoon unsafe items (Agent, Flags, Revenue, Users, Realtime, Anomalies, Settings); tests ensure only demo-backed pages appear./demo/*./demo/[id]/flags,/demo/[id]/revenue,/demo/[id]/users(and user detail).Written for commit 5ac30ee. Summary will update on new commits.