Skip to content

Bundle the panel script so it can import core (one source of truth for shared feature code) #215

Description

@RemilioNubilio

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:

  1. Move the inline script out of the template string into packages/core/src/chat/ui/panel/ as a real module.
  2. Bundle it with the tsup the repo already uses (IIFE output, no new dependencies).
  3. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions