Add UK chat integration (drawer on reports + standalone page)#1036
Open
SakshiKekre wants to merge 5 commits into
Open
Add UK chat integration (drawer on reports + standalone page)#1036SakshiKekre wants to merge 5 commits into
SakshiKekre wants to merge 5 commits into
Conversation
Renders an icon button in ReportActionButtons that opens a Sheet containing an iframe to policyengine-uk-chat. The chat receives the report's scenario as a scenario_context URL param so the assistant knows what report the user is looking at. Opt-in: pass chatScenarioContext to ReportOutputLayout. Without it, no button renders. Defaults to prod chat URL; override with VITE_UK_CHAT_ORIGIN to point at a preview. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
CI failures were from leaning on import.meta.env (Vite-only) in code that's also built by Next.js for calculator-app. Switch to NEXT_PUBLIC_UK_CHAT_ORIGIN — works in Next.js natively, no shim. Also collapse the icon import to one line to satisfy prettier. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Composes a minimal scenario context (country, year, label, model/data version) and passes it to ReportOutputLayout. Restricts to UK reports — the chat backend doesn't model US policy. With this, the "Ask a follow-up" button now actually renders on UK report pages. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When NEXT_PUBLIC_UK_CHAT_BYPASS_TOKEN is set, the iframe URL carries the Vercel "Protection Bypass for Automation" secret so the embedded chat preview deploy serves through deployment protection. samesitenone on set-bypass-cookie is required for the cookie to flow on cross-origin iframe requests. Empty / unset in production where the chat is public. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Complements the existing report-page drawer with the alternative positioning: a full-page chat surface for users who want to ask without building a report. - New shared util chatUrl.ts — buildChatUrl + iframe sandbox constant. Both ChatDrawer (supplement) and the new Chat.page (alternative) consume it so any URL/bypass-token tweak lives in one place. - ChatDrawer refactored to use the shared util. - New Chat.page renders the chat iframe full-height with a brief intro. Reachable at /:countryId/chat via both the Vite-era CalculatorRouter and the Next.js route wrapper in calculator-app. - New AskChatCta — tinted banner with sparkle icon + "New" badge on Reports.page (UK-only). Sits above the table, doesn't compete with the primary "Create report" action.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds two surfaces for policyengine-uk-chat in app-v2:
Both surfaces share `buildChatUrl()` (in `app/src/utils/chatUrl.ts`) so the iframe URL / model_backend / Vercel bypass-token plumbing lives in one place.
What's in the diff
Supplement (already there from earlier commits):
Alternative (new):
Why two surfaces
The eval framing in uk-chat #52 treats supplement and alternative as two distinct product positionings. Shipping both lets us collect signal on which one users actually engage with — without committing to either as the canonical placement.
Preview / env
Test plan
Deferred