Add "Ask a follow-up" chat drawer on report pages#1036
Open
SakshiKekre wants to merge 3 commits into
Open
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>
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.
Summary
ChatDrawercomponent embeds policyengine-uk-chat as an iframe inside aSheet.ReportActionButtonsopens the drawer.ReportOutputLayoutexposes an opt-inchatScenarioContextprop; when set, the button renders and the chat is seeded with the report's scenario.How seeding works
The drawer constructs the iframe URL with two query params:
scenario_context=<plain-English summary>— the chat reads this on mount and forwards it to its/chat/messagebackend, where it lands in the system prompt after the cache breakpoints (so it doesn't bust the prompt cache).model_backend=uk_python— pins the chat to the Python engine, the same one PE-API uses, so numerical answers are comparable to the report.This depends on the chat-side
scenario_contextsupport in policyengine-uk-chat#51. Until that merges, the drawer still works — the chat just won't pick up the context.Try it
Set
NEXT_PUBLIC_UK_CHAT_ORIGINto a chat preview URL when running locally:Then pass any non-empty
chatScenarioContextto aReportOutputLayoutinstance — the button appears.Not in scope here
ReportOutputLayoutto actually compose achatScenarioContextfrom real report data — that's the next PR (per-report-type formatter).