Skip to content

refactor(extension): extract Run Inspector view to media files - #44

Merged
jack-champagne merged 2 commits into
mainfrom
jack-champagne/inspector-view-seam
Jun 30, 2026
Merged

refactor(extension): extract Run Inspector view to media files#44
jack-champagne merged 2 commits into
mainfrom
jack-champagne/inspector-view-seam

Conversation

@jack-champagne

@jack-champagne jack-champagne commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

Creates the plumbing ⇄ look-and-feel seam the design lane needs (Kate, this week): the Run Inspector's inline <style> + body markup move out of run_inspector.ts into design-owned resource files, so styling/layout can be iterated without touching the extension-host plumbing.

  • media/inspector.css — all styling (the "feel")
  • media/inspector.html — body markup (the "look")
  • run_inspector.ts::renderHtml now owns only the security/wiring shell: CSP, nonce, and the asWebviewUri resource links. The message contract + buffering/state machine are untouched.
  • inspector_view_contract.test.ts — pins the seam: every DOM id inspector_webview.ts drives must exist in the markup, and the CSP must still authorize the linked stylesheet + nonce'd script. Reds if a look-and-feel change drops an id the plumbing depends on.

chat_panel.ts is intentionally left alone — it's an iframe to opencode with a 3-line reset, not a design surface.

Pure refactor — before/after equivalence

  • Body markup moved byte-identical; CSS identical modulo the 4-space <style> indent (verified by diffing git show main: vs the extracted files).
  • Behavioral suite unchanged: 63 → 63 green (incl. watcher_contract, watcher_statemachine) + 3 new contract tests = 66 pass / 2 skip.
  • Typecheck + build clean. media/ ships in the VSIX (not .vscodeignore'd; both files added to the manifest assertion, which runs only against a locally-built VSIX — not yet a CI gate, see 1.4 — Gate VSIX contents in CI (packaging.test.ts is currently inert) #45).

Test plan

  • CI passes (fast tier)
  • Visual: build the extension, replay the demo run + open the chat panel — inspector renders identical to main (the ~1% node can't assert)
  • pnpm --filter amicode-v2 package → packaging test confirms media/inspector.{html,css} ship in the VSIX

🤖 Generated with Claude Code

Move the inline CSS and body markup out of run_inspector.ts into media/inspector.css and media/inspector.html so the design lane can own look-and-feel without touching the plumbing; renderHtml keeps only the security/wiring shell (CSP, nonce, resource URIs). Pure refactor — body markup byte-identical, CSS identical modulo indent. Adds inspector_view_contract.test.ts pinning the DOM-id + message seam inspector_webview.ts depends on.
@Rchari1

Rchari1 commented Jun 29, 2026

Copy link
Copy Markdown
Member

Looks good, there should not be any conflicts.

Address PR #44 review:
- contract test: assert the computed-form ids (preview-a/b, m-*) the
  literal regex can't see; bind CSP checks to their directive and pin
  the load-bearing 'unsafe-inline' + img-src grants
- run_inspector: trimEnd body so the rendered doc is byte-identical to
  main (no extra blank line); wrap the inspector.html read in try/catch
  with a fallback so a corrupt install degrades to a message, not a
  blank panel; comment why 'unsafe-inline' stays
@jack-champagne
jack-champagne merged commit 6c8afa7 into main Jun 30, 2026
4 checks passed
@kateebonner kateebonner self-assigned this Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants