Skip to content

[Chore] Capture typed host messages in Story Gallery - #1446

Merged
edelauna merged 1 commit into
mainfrom
feat/gallery-message-capture-157cfn81c2ad4
Aug 30, 2026
Merged

[Chore] Capture typed host messages in Story Gallery#1446
edelauna merged 1 commit into
mainfrom
feat/gallery-message-capture-157cfn81c2ad4

Conversation

@zoomote

@zoomote zoomote Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

​Created by Roomote. Follow up by mentioning @roomote, in the web UI, or in Discord.

Related GitHub Issue

Closes: #517

Description

Adds a gallery-local VS Code API shim that captures outbound WebviewMessage values before application modules load. A shared typed Playwright helper exposes those messages to visual tests, and the gallery resets the buffer between story mounts to prevent test leakage.

Migrates the Announcement link visual test away from console parsing and verifies that remounting clears previously captured messages.

Test Procedure

  • Run the Announcement link visual test with Playwright.
  • Run all Story Gallery tests with snapshot comparison disabled.
  • Run pnpm --filter @roo-code/vscode-webview check-types.
  • Run pnpm test.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Visual Snapshot (UI changes only): This is test-infrastructure work with no user-visible UI change; the affected visual test remains covered by its committed snapshot.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Visual Snapshots

No user-visible UI changed. Browser proof is not applicable; the affected Announcement Story Gallery test continues to validate its committed visual baseline.

Videos (interaction / animation only)

Not applicable.

Documentation Updates

  • No user-facing documentation updates are required.
  • Yes, documentation updates are required.

Additional Notes

The captured message list uses the repository's shared WebviewMessage type rather than parsing console output. The shim remains isolated to the Story Gallery document and does not affect extension runtime behavior.

Get in Touch

Mention @roomote on this PR or follow up through the linked task.

@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@edelauna

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3117b665-1c9f-4db5-9505-343defd851d7

📥 Commits

Reviewing files that changed from the base of the PR and between 8187d3c and 3a9f611.

📒 Files selected for processing (5)
  • webview-ui/AGENTS.md
  • webview-ui/playwright/gallery/index.html
  • webview-ui/playwright/gallery/main.tsx
  • webview-ui/playwright/vscode-messages.ts
  • webview-ui/src/components/chat/__tests__/Announcement.links.visual.tsx

Included review availability: Your plan provides up to 4 included reviews per hour; 1 remains after this review.

📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (7)
Enforce repository policy: routine PRs must not add changesets or edit changelogs except during release preparation. Verify documentation describes real behavior and contracts, and deprioritize prose-only nits that do not affect correctness...

⚙️ CodeRabbit configuration file

Files:

  • webview-ui/AGENTS.md
Require regression coverage at the lowest valid harness with behavior-focused assertions, including relevant negative, error, false/unset, and boundary cases. Check cleanup and deterministic async behavior and prefer shared typed test helpe...

⚙️ CodeRabbit configuration file

Files:

  • webview-ui/src/components/chat/__tests__/Announcement.links.visual.tsx
Check strict typing and exhaustive behavior across normal, boundary, error, cancellation, retry, and compatibility paths. Verify promises and errors are handled, existing helpers are reused, and new code introduces no `any`, unjustified dou...

⚙️ CodeRabbit configuration file

Files:

  • webview-ui/playwright/gallery/main.tsx
  • webview-ui/playwright/vscode-messages.ts
  • webview-ui/src/components/chat/__tests__/Announcement.links.visual.tsx
Check React state and effect dependencies, cleanup, accessibility, i18n, and light/dark theme behavior. New markup should use Tailwind; add VS Code CSS variables to `src/index.css` before Tailwind use. Use Vitest for behavior and Playwright...

⚙️ CodeRabbit configuration file

Files:

  • webview-ui/AGENTS.md
  • webview-ui/playwright/gallery/main.tsx
  • webview-ui/playwright/gallery/index.html
  • webview-ui/playwright/vscode-messages.ts
  • webview-ui/src/components/chat/__tests__/Announcement.links.visual.tsx
Act as an adversarial second-opinion reviewer. Verify PR claims against implementation, contracts, and tests. Trace changed inputs through normal, boundary, error, cancellation, retry, and default paths and their consumers. Seek plausible c...

⚙️ CodeRabbit configuration file

Files:

  • webview-ui/AGENTS.md
  • webview-ui/playwright/gallery/main.tsx
  • webview-ui/playwright/gallery/index.html
  • webview-ui/playwright/vscode-messages.ts
  • webview-ui/src/components/chat/__tests__/Announcement.links.visual.tsx
Fix lint violations in new TypeScript code instead of suppressing them.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • webview-ui/playwright/gallery/main.tsx
  • webview-ui/playwright/vscode-messages.ts
  • webview-ui/src/components/chat/__tests__/Announcement.links.visual.tsx
Use `playwright/vscode-messages.ts` to inspect outbound `vscode.postMessage` payloads.

📄 CodeRabbit inference engine (webview-ui/AGENTS.md)

Files:

  • webview-ui/playwright/vscode-messages.ts
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: Zoo-Code-Org/Zoo-Code

Timestamp: 2026-08-30T01:07:12.904Z
Learning: For `SettingsView`, preserve the cached-state pattern from the repo root guidance: inputs should operate on local `cachedState` until the user saves, and tests should distinguish automatic initialization from real user edits.
Learnt from: CR
Repo: Zoo-Code-Org/Zoo-Code

Timestamp: 2026-08-30T01:07:12.904Z
Learning: Use `@/utils/test-utils` `renderWithExtensionState` and `makeExtensionState` for common context/query setup.
Learnt from: CR
Repo: Zoo-Code-Org/Zoo-Code

Timestamp: 2026-08-30T01:07:12.904Z
Learning: Do not attach screenshots to the PR description as evidence; commit the baseline instead so future PRs get regression coverage automatically.
Learnt from: CR
Repo: Zoo-Code-Org/Zoo-Code

Timestamp: 2026-08-30T01:07:12.904Z
Learning: Skip a visual test when the change is behavior-only (state transitions, handler wiring, validation) — those belong in Vitest.
Learnt from: CR
Repo: Zoo-Code-Org/Zoo-Code

Timestamp: 2026-08-30T01:07:12.904Z
Learning: Run visual comparisons with `pnpm test:visual:docker` from `webview-ui/`.
Learnt from: CR
Repo: Zoo-Code-Org/Zoo-Code

Timestamp: 2026-08-30T01:07:12.904Z
Learning: Use the Docker commands when creating or reviewing baselines; host-rendered screenshots are not the source of truth.
🪛 LanguageTool
webview-ui/AGENTS.md

[grammar] ~69-~69: Ensure spelling is correct
Context: ...y resets captured messages before every mount; do not parse the browser console for ho...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🔇 Additional comments (5)
webview-ui/playwright/gallery/index.html (1)

9-20: LGTM!

webview-ui/playwright/vscode-messages.ts (1)

1-13: LGTM!

webview-ui/playwright/gallery/main.tsx (1)

48-48: LGTM!

webview-ui/AGENTS.md (1)

69-69: LGTM!

webview-ui/src/components/chat/__tests__/Announcement.links.visual.tsx (1)

2-4: LGTM!

Also applies to: 42-42, 58-60


📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Improved visual testing for external-link actions by directly verifying messages sent to the extension host.
    • Added checks confirming captured messages are reset between component mounts.
  • Chores
    • Enhanced the Playwright gallery to mock webview APIs and preserve simulated state during tests.
    • Added guidance for inspecting captured webview messages.

Walkthrough

The Playwright gallery now captures typed outbound VS Code messages through a shared helper. It persists mocked webview state, clears captured messages during unmount, and updates the announcement visual test to validate message payloads without parsing browser console output.

Changes

VS Code message capture

Layer / File(s) Summary
Gallery capture infrastructure
webview-ui/playwright/gallery/index.html, webview-ui/playwright/gallery/main.tsx, webview-ui/playwright/vscode-messages.ts, webview-ui/AGENTS.md
The gallery mocks VS Code APIs, captures typed messages, persists state with localStorage, and clears messages on unmount. The authoring guidance documents the shared helper.
Announcement message assertions
webview-ui/src/components/chat/__tests__/Announcement.links.visual.tsx
The visual test reads captured messages, filters openExternal events, preserves link assertions, and verifies that remounting has no messages.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 3a9f6

This change improves Story Gallery test message capture without altering production runtime behavior or user-facing functionality. No actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: edelauna

🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary change: typed host-message capture in the Story Gallery.
Description check ✅ Passed The description includes the linked issue, implementation details, test procedure, completed checklist, snapshot status, documentation status, and reviewer context.
Linked Issues check ✅ Passed The changes satisfy issue #517: they add typed message capture, reset messages between mounts, remove console parsing from the Announcement visual test, verify external-link messages, and keep the shi…
Out of Scope Changes check ✅ Passed All changes support issue #517. The AGENTS.md guidance, gallery shim, typed helper, mount reset, and Announcement visual test update are directly related to Story Gallery message capture.
Regression Evidence ✅ Passed The changed message-capture behavior has focused Playwright coverage. Announcement.links.visual.tsx uses getCapturedVscodeMessages, asserts the five typed openExternal payloads in order, and rem…
Trust And Persistence Invariants ✅ Passed No explicit trust or persistence failure is introduced. The changed gallery shim only appends outbound messages to an in-memory __vscodeMessages array, and vscode-messages.ts reads that array thro…
Full details: Linked Issues check

Explanation

The changes satisfy issue #517: they add typed message capture, reset messages between mounts, remove console parsing from the Announcement visual test, verify external-link messages, and keep the shim isolated to the Story Gallery without changing Extension Host behavior.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (2 skipped: 2 unsupported.)

Full details: Regression Evidence

Explanation

The changed message-capture behavior has focused Playwright coverage. Announcement.links.visual.tsx uses getCapturedVscodeMessages, asserts the five typed openExternal payloads in order, and remounts the story before asserting that the capture buffer is empty. The gallery shim is initialized before the module script, and main.tsx resets the buffer during unmount, which mount always calls. The existing Announcement.spec.tsx also covers link posting and the negative document-level propagation case. The PR changes test infrastructure and message capture only; it does not introduce a durable visible UI change, so no new component snapshot is required. The added getState/setState shim methods mirror the existing browser fallback and have no current production call sites beyond the wrapper, so no separate regression test is required under this check.

Full details: Trust And Persistence Invariants

Explanation

No explicit trust or persistence failure is introduced. The changed gallery shim only appends outbound messages to an in-memory __vscodeMessages array, and vscode-messages.ts reads that array through page.evaluate; it does not execute or transmit message data. main.tsx clears the array after unmount. The localStorage state methods are test-only API shims, have no changed call sites in the gallery, and mirror the existing synchronous browser fallback. The Announcement test uses fixed external-link constants and changes only test observation. No changed path bypasses approval or allowlists, leaks secrets or PII, loses persisted state, or allocates an uncleaned lifecycle resource.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/gallery-message-capture-157cfn81c2ad4

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

webview-ui/playwright/gallery/main.tsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

webview-ui/playwright/vscode-messages.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

webview-ui/src/components/chat/__tests__/Announcement.links.visual.tsx

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@edelauna
edelauna marked this pull request as ready for review August 30, 2026 01:25
@edelauna
edelauna enabled auto-merge August 30, 2026 01:25
@edelauna
edelauna added this pull request to the merge queue Aug 30, 2026
Merged via the queue into main with commit 97265fd Aug 30, 2026
34 checks passed
@edelauna
edelauna deleted the feat/gallery-message-capture-157cfn81c2ad4 branch August 30, 2026 01:35
easonLiangWorldedtech pushed a commit to easonLiangWorldedtech/Zoo-Code that referenced this pull request Aug 30, 2026
…markdown

Per webview-ui/AGENTS.md, this PR changes user-visible markdown rendering, spacing, and overflow styling, so it needs a pixel receipt:

- Add a task-header-markdown story to the shared gallery harness (Zoo-Code-Org#1446): an expanded TaskHeader with representative user-authored markdown (heading, bold, inline code, bullets, external link, soft breaks, and path/@problems/@Terminal mentions) plus enough content to overflow the max-h-80 prompt box.

- Add TaskHeader.visual.tsx: asserts the deterministic expanded state (heading, list items, mention spans, br soft breaks, actual overflow) and snapshots all four VS Code themes.

- Baselines generated in the pinned Docker Playwright container (task-header-markdown-{dark,light,high-contrast,high-contrast-light}.png).

Existing Vitest coverage (semantic behavior) is unchanged.
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.

[ENHANCEMENT] Add shared VS Code message capture to Playwright gallery

2 participants