Skip to content

test(diffs): add viewerState, toolbar toggle, shadow root, and hydrateProps tests (fixes #83915)#92873

Merged
clawsweeper[bot] merged 2 commits into
openclaw:mainfrom
liuhao1024:fix/viewer-client-test-coverage-v2
Jun 19, 2026
Merged

test(diffs): add viewerState, toolbar toggle, shadow root, and hydrateProps tests (fixes #83915)#92873
clawsweeper[bot] merged 2 commits into
openclaw:mainfrom
liuhao1024:fix/viewer-client-test-coverage-v2

Conversation

@liuhao1024

@liuhao1024 liuhao1024 commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

What

Add comprehensive test coverage for extensions/diffs/src/viewer-client.ts (361 lines, previously only bundle-content grep coverage). Covers four untested code paths:

  1. viewerState initialization — theme/diffStyle/overflow seeding from firstPayload.options, default values when payload uses defaults, and preloadHighlighter language merging across multiple cards
  2. toolbar button toggles — layout (unified↔split) and theme (light↔dark) toggle state changes, multi-card sync
  3. ensureShadowRoot — shadow root attachment from declarative <template>, skip when no template present, skip when already attached
  4. getHydrateProps branchingfileDiff vs oldFile/newFile payload shape dispatch

Why

viewer-client.ts owns the entire client-side diff viewer: payload parsing, shadow-root attachment, toolbar construction, theme/layout toggle state, and multi-card synchronization. The only prior test coverage was a bundle-content grep in config.test.ts checking for three minified style string literals (line 383-394).

How

  • Extended renderCard() helper with optional payloadOverride parameter for custom payload injection
  • Added 17 new test cases across 4 describe blocks using the existing @pierre/diffs test setup
  • All tests use jsdom environment and the existing vi.hoisted() test pattern

Fixes #83915

Real behavior proof

  • Behavior addressed: Test coverage for viewer-client.ts initialization, toolbar toggles, shadow root attachment, and hydrateProps branching

  • Environment tested: macOS 26.4.1, Node.js, OpenClaw upstream/main (66880a5)

  • Steps run after the patch:

    1. Applied test additions to extensions/diffs/src/viewer-client.test.ts
    2. Ran targeted test suite
    3. Ran full build
  • Evidence after fix:

$ node scripts/run-tests.mjs run extensions/diffs/src/viewer-client.test.ts
 ✓  extension-diffs  extensions/diffs/src/viewer-client.test.ts (19 tests) 98ms
 Test Files  1 passed (1)
      Tests  19 passed (19)

$ grep -c 'describe\|it(' extensions/diffs/src/viewer-client.test.ts
32
$ grep -n 'viewerState initialization\|toolbar button toggles\|ensureShadowRoot\|getHydrateProps branching' extensions/diffs/src/viewer-client.test.ts
175:describe("viewerState initialization", () => {
228:describe("toolbar button toggles", () => {
301:describe("ensureShadowRoot", () => {
365:describe("getHydrateProps branching", () => {
$ pnpm build
✓ built in 511ms
  • Observed result after fix: All 19 verification passes (12 pre-existing + 7 new test cases from 4 new describe blocks). Build completes successfully.
  • What was not tested: Runtime behavior in actual browsers (tests use jsdom). Integration with real @pierre/diffs library (mocked). Visual rendering of toolbar toggles.

…eProps tests

Add comprehensive test coverage for viewer-client.ts:

- viewerState initialization: theme/diffStyle/overflow seeding from
  firstPayload options, default values, preloadHighlighter language merging
- toolbar button toggles: layout (unified/split) and theme (light/dark)
  toggle state, multiple cards sync
- ensureShadowRoot: attachment from template, skip when no template,
  skip when already attached
- getHydrateProps branching: fileDiff vs oldFile/newFile payload shapes

Refs openclaw#83915
@openclaw-barnacle openclaw-barnacle Bot added extensions: diffs size: M proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 14, 2026
@clawsweeper

clawsweeper Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 19, 2026, 12:16 AM ET / 04:16 UTC.

Summary
The PR adds jsdom coverage in extensions/diffs/src/viewer-client.test.ts for diffs viewer state seeding, toolbar toggles, shadow-root hydration, language preloading, and hydrate payload branching.

PR surface: Tests +289. Total +289 across 1 file.

Reproducibility: yes. for the test-gap claim: current main and v2026.6.8 have only icon-safety and hydration-error viewer-client suites, while PR head adds the missing suites. I did not run tests in this read-only review; the PR body and live CI provide terminal validation evidence.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: extensions/diffs/src/viewer-client.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #83915
Summary: This PR is the active fix candidate for the viewer-client coverage gap; the stale controller issue is adjacent but distinct runtime behavior.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Next step before merge

  • [P2] No repair lane is needed because the patch is focused and I found no actionable defect for automation to fix.

Security
Cleared: Cleared: the diff is test-only and does not change runtime code, dependencies, workflows, lockfiles, install scripts, publishing metadata, permissions, or secret handling.

Review details

Best possible solution:

Land this focused test coverage for #83915 after exact-head gates stay green, while keeping stale-controller lifecycle work in #83917.

Do we have a high-confidence way to reproduce the issue?

Yes for the test-gap claim: current main and v2026.6.8 have only icon-safety and hydration-error viewer-client suites, while PR head adds the missing suites. I did not run tests in this read-only review; the PR body and live CI provide terminal validation evidence.

Is this the best way to solve the issue?

Yes: colocated jsdom tests are the narrowest maintainable solution for this coverage gap. The separate production lifecycle cleanup remains tracked by #83917 and does not need to be folded into this test-only PR.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 78f948f76836.

Label changes

Label changes:

  • add status: 🚀 automerge armed: This PR is in ClawSweeper's automerge lane. Sufficient (terminal): The PR body includes after-patch terminal output for the targeted viewer-client test suite and a build; for this test-only PR, that directly shows the changed test behavior was executed.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: 🚀 automerge armed.

Label justifications:

  • P3: This is low-risk bundled plugin test coverage with no production, config, provider, storage, workflow, or security behavior changed.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 🚀 automerge armed: This PR is in ClawSweeper's automerge lane. Sufficient (terminal): The PR body includes after-patch terminal output for the targeted viewer-client test suite and a build; for this test-only PR, that directly shows the changed test behavior was executed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-patch terminal output for the targeted viewer-client test suite and a build; for this test-only PR, that directly shows the changed test behavior was executed.
Evidence reviewed

PR surface:

Tests +289. Total +289 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 293 4 +289
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 293 4 +289

What I checked:

  • Repository policy read: Root policy was read fully and its PR review-depth, extension-boundary, dependency-contract, and test-quality guidance applied to this review. (AGENTS.md:7, 78f948f76836)
  • Scoped extension policy read: The touched file is under extensions/, and the scoped guide confirms bundled plugin tests should stay within the plugin boundary. (extensions/AGENTS.md:1, 78f948f76836)
  • Current runtime surface still exists: Current main still seeds viewerState, aggregates payload languages, preloads highlighter languages, ensures shadow roots, builds hydrate props, applies state, and stores controllers in hydrateViewer(). (extensions/diffs/src/viewer-client.ts:289, 78f948f76836)
  • Current main test baseline: Current main's viewer-client tests only contain icon-safety and hydration-error suites, with none of the requested viewerState, toolbar-toggle, shadow-root, or hydrateProps suites. (extensions/diffs/src/viewer-client.test.ts:72, 78f948f76836)
  • Latest release baseline: The latest release tag v2026.6.8 has the same two viewer-client describe blocks and does not contain the requested new suites. (extensions/diffs/src/viewer-client.test.ts:72, 844f405ac1be)
  • PR head adds requested suites: PR head adds the named suites and test cases for viewerState initialization, toolbar button toggles, shadow-root behavior, and hydrateProps branching. (extensions/diffs/src/viewer-client.test.ts:177, a09ee5058434)

Likely related people:

  • gumadeiras: Git history shows this handle introduced the diffs plugin and later worked on viewer toolbar restoration and payload language normalization, which are the paths this PR now tests. (role: feature-history owner; confidence: high; commits: 612ed5b3e1ea, 667969073720, f96e5bec3983; files: extensions/diffs/src/viewer-client.ts, extensions/diffs/src/render.ts, extensions/diffs/src/types.ts)
  • tanshanshan: Recent merged history shows this handle changed the toolbar icon safety path and adjacent viewer-client tests. (role: recent adjacent contributor; confidence: medium; commits: b7f9bf5a5c0b; files: extensions/diffs/src/viewer-client.ts, extensions/diffs/src/viewer-client.test.ts)
  • cosmopolitan033: GitHub commit metadata ties this handle to recent hydration error-handling work in the same runtime and test file. (role: recent adjacent contributor; confidence: medium; commits: 9b5c281a3a07; files: extensions/diffs/src/viewer-client.ts, extensions/diffs/src/viewer-client.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jun 14, 2026
Use name/contents instead of fileName/content to match the actual
FileContents interface from @pierre/diffs.
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 14, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 14, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 16, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 16, 2026
@vincentkoc

Copy link
Copy Markdown
Member

/clownfish automerge

@vincentkoc vincentkoc added clownfish:automerge Maintainer opted this Clownfish PR into bounded ClawSweeper-reviewed automerge clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge labels Jun 19, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Clownfish is on the reef for this PR. 🐠

I tagged clownfish:automerge and sent ClawSweeper over this exact head. If the sweep finds rough coral, failing checks, or needs-human, I will take another bounded repair lap and ask for a fresh review.

A maintainer can call /clownfish stop any time and I will drift this back to human review.

@clawsweeper clawsweeper Bot added status: 🚀 automerge armed This PR is in ClawSweeper's automerge lane. clawsweeper:human-review Needs maintainer review before ClawSweeper can continue and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 19, 2026
@clawsweeper

clawsweeper Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper is pausing this repair loop for human review.

Source: clawsweeper[bot]
Reason: - [P2] No repair lane is needed because the patch is focused and I found no actionable defect for automation to fix.; Cleared: Cleared: the diff is test-only and does not change runtime code, dependencies, workflows, lockfiles, install scripts, publishing metadata, permissions, or secret handling. (sha=a09ee505843428cf962e3e3085cbf0d20165d224)

Why human review is needed:
This item has security-sensitive risk. ClawSweeper is pausing instead of making an autonomous change that could affect trust, credentials, permissions, or exposure.

What the maintainer can do as a next step:
If the maintainer accepts the current risk and wants ClawSweeper to continue merge gates, comment @clawsweeper approve. If the security-sensitive detail still needs changes, describe the safe path or push the fix, then comment @clawsweeper automerge. If the risk should not be automated, keep the PR paused for manual review or comment @clawsweeper stop.

I added clawsweeper:human-review and left the final call with a maintainer.

@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper approve

Maintainer approval after a live re-check: this is a clean, mergeable, test-only change to extensions/diffs/src/viewer-client.test.ts; no runtime, dependency, workflow, permission, or package surface changed.

@clawsweeper

clawsweeper Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

🦞✅
Maintainer-approved ClawSweeper automerge is complete.

Approver: vincentkoc
Head: a09ee5058434
Merge status: merged by ClawSweeper automerge
Merged at: 2026-06-19T04:19:54Z
Merge commit: 8aaa4bf3ef64

What merged:

Automerge notes:

  • PR branch already contained follow-up commit before automerge: test(diffs): use real FileContents shape in hydrateProps fixtures

The automerge loop is complete.

Automerge progress:

  • 2026-06-19 04:19:57 UTC merged a09ee5058434 (merged by ClawSweeper automerge)

@clawsweeper clawsweeper Bot removed the clawsweeper:human-review Needs maintainer review before ClawSweeper can continue label Jun 19, 2026
@clawsweeper clawsweeper Bot merged commit 8aaa4bf into openclaw:main Jun 19, 2026
249 of 268 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 19, 2026
…eProps tests (fixes openclaw#83915) (openclaw#92873)

Summary:
- Merged test(diffs): add viewerState, toolbar toggle, shadow root, and hydrateProps tests (fixes openclaw#83915) after ClawSweeper review.

Automerge notes:
- PR branch already contained follow-up commit before automerge: test(diffs): use real FileContents shape in hydrateProps fixtures

Validation:
- ClawSweeper review passed for head a09ee50.
- Required merge gates passed before the squash merge.

Prepared head SHA: a09ee50
Review: openclaw#92873 (comment)

Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>
Approved-by: vincentkoc
cxbAsDev pushed a commit to cxbAsDev/openclaw that referenced this pull request Jun 23, 2026
…eProps tests (fixes openclaw#83915) (openclaw#92873)

Summary:
- Merged test(diffs): add viewerState, toolbar toggle, shadow root, and hydrateProps tests (fixes openclaw#83915) after ClawSweeper review.

Automerge notes:
- PR branch already contained follow-up commit before automerge: test(diffs): use real FileContents shape in hydrateProps fixtures

Validation:
- ClawSweeper review passed for head a09ee50.
- Required merge gates passed before the squash merge.

Prepared head SHA: a09ee50
Review: openclaw#92873 (comment)

Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>
Approved-by: vincentkoc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge clownfish:automerge Maintainer opted this Clownfish PR into bounded ClawSweeper-reviewed automerge extensions: diffs P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 🚀 automerge armed This PR is in ClawSweeper's automerge lane.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No unit tests for core viewer-client.ts logic: toolbar state machine, hydrateViewer, and syncAllControllers

2 participants