fix(scan/chat): make the logged-out "Ask Shinny" follow-up actually work - #85
Conversation
Adversarial self-review of the Round 17 chat hand-off found three
interacting bugs on the logged-out path (all would silently drop the
follow-up question) plus a desktop dead-end and an imprecise seed:
- Seed eaten on the throwaway mount: takeChatSeed() ran on chat mount
before the auth redirect fired, clearing the seed during the brief
pre-redirect render. Now gated on authChecked && isAuthenticated, so
it's consumed exactly once, on the mount that renders the composer.
- No return path: chat's unauth redirect and login both hardcoded
/dashboard. Chat now passes next=/{locale}/chat; login honours a
validated same-origin ?next= (rejects //host, /\host, scheme URLs β
no open redirect). The logged-out flow now round-trips scan β chat β
login β back to chat with the question pre-filled.
- Desktop Menu/Drink dead-end: the result-action block was only in the
meal desktop sidebar; the shared bottom block was lg:hidden, so a
large-screen menu/drink scan had no buttons at all. Bottom block is
now lg:hidden only for meal (which has the sidebar), visible on all
viewports for menu/drink.
- Generic seed subject neutralised ("this" not "my meal") since it
fires for menu/drink scans.
type-check + i18n (233/233) + 193/193 unit green; next build clean.
No e2e pins the old loginβdashboard target.
|
Caution Review failedThe pull request is closed. βΉοΈ Recent review infoβοΈ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: π Files selected for processing (8)
π WalkthroughWalkthroughThis PR hardens the scan β chat context hand-off for logged-out users: the login page now redirects to a safe ChangesScan to Chat Hand-off Fixes
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant ChatPage
participant LoginPage
participant AuthState
User->>ChatPage: Visit /chat with seeded draft
ChatPage->>AuthState: Check authChecked/isAuthenticated
AuthState-->>ChatPage: Not authenticated
ChatPage->>LoginPage: Redirect to /login?next=/{locale}/chat
User->>LoginPage: Log in
LoginPage->>AuthState: isAuthenticated becomes true
LoginPage->>LoginPage: Validate next param as safe path
LoginPage->>ChatPage: Redirect to /{locale}/chat
ChatPage->>AuthState: authChecked & isAuthenticated true
ChatPage->>ChatPage: takeChatSeed consumes seeded draft
Possibly related PRs
β¨ Finishing Touchesπ Generate docstrings
π§ͺ 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 |
Adversarial self-review of the Round 17 chat hand-off (#84) found the "just ask on chat further" flow was broken for logged-out users β three interacting bugs that would each silently drop the follow-up question β plus a desktop dead-end and an imprecise seed. All fixed.
The logged-out flow was broken in three ways
takeChatSeed()ran on chat mount before the auth redirect fired, so a logged-out visit cleared the seed during the brief pre-redirect render β gone by the time the user returned from login. Now gated onauthChecked && isAuthenticated: consumed exactly once, on the mount that actually renders the composer./login?mode=loginand login always bounced to/dashboard. Chat now passesnext=/{locale}/chat; login honours a validated?next=(same-origin absolute path only β rejects//host,/\host, and scheme URLs, so no open redirect).lg:hidden, so on a large screen a Menu/Drink scan had no action buttons at all. Nowlg:hiddenonly for meal (which has the sidebar); visible on all viewports for menu/drink.Net: a logged-out "Ask Shinny" now round-trips scan β chat β login β back to chat with the question pre-filled.
Also: the generic seed subject is neutral ("this") instead of "my meal", since it fires for menu/drink scans.
Verification
type-check+check:i18n(233/233) + 193/193 unit green;next buildclean.<img>lint warnings remain (app-wide, not introduced here).π€ Generated with Claude Code
Generated by Claude Code
Summary by CodeRabbit
Bug Fixes
Style