Summary
The VS Code panel is one template string in core (chatHtml() in chat/ui/webview.ts) whose inline script cannot import anything. So every shared behavior lands twice: the quote ref grammar ships as a byte-identical regex copy pinned to notes/quoteRefs.ts by change-BOTH comments (#213), the quote card logic exists in a panel form and a CLI form, and the hydration cap lives under two names. The copies are documented and tested, but every future shared feature pays the same tax, and the two sides drift the moment one is edited alone.
Proposal
Give the panel script a small build step of its own:
- Move the inline script out of the template string into packages/core/src/chat/ui/panel/ as a real module.
- Bundle it with the tsup the repo already uses (IIFE output, no new dependencies).
- chatHtml() inlines the bundled artifact instead of carrying the source. The HTML shell stays a template; only the script becomes a module.
The panel then imports extractQuoteRefs, QUOTE_REFS_MAX, and future shared helpers directly, and the copies plus their pin comments are deleted.
Scope notes
- No behavior, message, or contract change: a refactor of how the panel script is authored, not what it does.
- Incremental migration works: extract the feed and quote section first (where the live duplication is), leave the rest of the script in place until convenient.
- Happy to build it if wanted. Parking the idea here first since it changes how the panel is authored, which is yours to call.
Summary
The VS Code panel is one template string in core (chatHtml() in chat/ui/webview.ts) whose inline script cannot import anything. So every shared behavior lands twice: the quote ref grammar ships as a byte-identical regex copy pinned to notes/quoteRefs.ts by change-BOTH comments (#213), the quote card logic exists in a panel form and a CLI form, and the hydration cap lives under two names. The copies are documented and tested, but every future shared feature pays the same tax, and the two sides drift the moment one is edited alone.
Proposal
Give the panel script a small build step of its own:
The panel then imports extractQuoteRefs, QUOTE_REFS_MAX, and future shared helpers directly, and the copies plus their pin comments are deleted.
Scope notes