Skip to content

Web: add HEIC media regression and doc fix#38294

Merged
vincentkoc merged 4 commits intomainfrom
vincentkoc-code/web-media-heic-docs-tests
Mar 7, 2026
Merged

Web: add HEIC media regression and doc fix#38294
vincentkoc merged 4 commits intomainfrom
vincentkoc-code/web-media-heic-docs-tests

Conversation

@vincentkoc
Copy link
Copy Markdown
Member

Summary

  • Problem: the Gateway HEIC/input-image work left one stale doc line in the OpenResponses docs and still lacked a regression for the older src/web/media.ts HEIC normalization path.
  • Why it matters: the docs should match the current HEIC/HEIF allowlist, and the existing web/media HEIC path should stay covered so future refactors do not quietly regress it.
  • What changed: added a hermetic src/web/media.test.ts regression that exercises local .heic handling through loadWebMedia, and updated the OpenResponses docs MIME list to include image/heic and image/heif.
  • What did NOT change (scope boundary): no runtime behavior changed in this PR; this is docs + regression coverage only.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • API / contracts
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

  • Docs now list image/heic and image/heif in the current input_image MIME allowlist.

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: Node 22 / pnpm workspace
  • Model/provider: n/a
  • Integration/channel (if any): Web media path + Gateway docs
  • Relevant config (redacted): defaults

Steps

  1. Run pnpm vitest run src/web/media.test.ts.
  2. Confirm the new HEIC local-file regression passes.
  3. Confirm the docs line lists HEIC/HEIF in docs/gateway/openresponses-http-api.md.

Expected

  • The older loadWebMedia HEIC path stays covered and docs match the runtime/schema allowlist.

Actual

  • Before this PR, the docs line was stale and the HEIC web/media path did not have a dedicated regression.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: src/web/media.test.ts including the new HEIC local-file normalization regression.
  • Edge cases checked: .heic input maps to JPEG output and .jpg filename.
  • What you did not verify: full repo test suite.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert this PR.
  • Files/config to restore: src/web/media.test.ts, docs/gateway/openresponses-http-api.md
  • Known bad symptoms reviewers should watch for: test-only regressions or docs drift.

Risks and Mitigations

  • Risk: the HEIC regression could become platform-coupled.
    • Mitigation: the test stubs convertHeicToJpeg only and keeps the rest of the path real, so it stays hermetic.

AI Assistance

  • AI-assisted: yes
  • Testing: focused local verification completed

Verification:

  • pnpm vitest run src/web/media.test.ts
  • pnpm exec oxfmt --check src/web/media.test.ts docs/gateway/openresponses-http-api.md

@vincentkoc vincentkoc self-assigned this Mar 6, 2026
@openclaw-barnacle openclaw-barnacle bot added docs Improvements or additions to documentation channel: whatsapp-web Channel integration: whatsapp-web gateway Gateway runtime size: XS maintainer Maintainer-authored PR labels Mar 6, 2026
@vincentkoc vincentkoc marked this pull request as ready for review March 6, 2026 19:46
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 6, 2026

Greptile Summary

This PR adds a regression test for the existing HEIC local-file normalization path in src/web/media.ts and updates docs/gateway/openresponses-http-api.md to include image/heic and image/heif in the documented input_image MIME allowlist — no runtime behavior is changed.

  • New test (src/web/media.test.ts): A hermetic test "normalizes HEIC local files to JPEG output" is added. It correctly stubs convertHeicToJpeg via a wrapper-function pattern ((...args) => convertHeicToJpegMock(...args)) that defers variable resolution to call-time, safely working around Vitest's vi.mock hoisting. The assertion that convertHeicToJpegMock is called exactly once is accurate because convertHeicToJpeg is invoked only once before the resize-quality loop in optimizeImageToJpeg.
  • Docs fix (docs/gateway/openresponses-http-api.md): The added MIME types match the HEIC_MIME_RE = /^image\/hei[cf]$/i regex in media.ts and the MIME_BY_EXT/EXT_BY_MIME tables in mime.ts, making the docs accurate.
  • Minor style concern: The assertion expect(result.buffer.equals(tinyPngBuffer)).toBe(false) only verifies the buffer was transformed; pairing it with JPEG magic-byte checks (0xFF 0xD8) would make the regression more robust against future refactors that accidentally corrupt the output format.

Confidence Score: 5/5

  • This PR is safe to merge — no runtime behavior is changed; it adds only a test and a docs update.
  • Both changed files are purely additive (a new test case and a single doc-line update). The test logic has been verified to match the actual code path in optimizeImageToJpeg, including the mock setup pattern and assertion count. The docs update exactly mirrors the existing HEIC MIME handling in media.ts and mime.ts.
  • No files require special attention.

Last reviewed commit: cf6edcc

Comment thread src/web/media.test.ts
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@vincentkoc vincentkoc merged commit 6017b73 into main Mar 7, 2026
9 of 10 checks passed
@vincentkoc vincentkoc deleted the vincentkoc-code/web-media-heic-docs-tests branch March 7, 2026 03:49
joshavant pushed a commit that referenced this pull request Mar 7, 2026
* Web: add HEIC media normalization regression

* Docs: list HEIC input_image MIME types

* Update src/web/media.test.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
vincentkoc added a commit to BryanTegomoh/openclaw-fork that referenced this pull request Mar 8, 2026
* Web: add HEIC media normalization regression

* Docs: list HEIC input_image MIME types

* Update src/web/media.test.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Saitop pushed a commit to NomiciAI/openclaw that referenced this pull request Mar 8, 2026
* Web: add HEIC media normalization regression

* Docs: list HEIC input_image MIME types

* Update src/web/media.test.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
jenawant pushed a commit to jenawant/openclaw that referenced this pull request Mar 10, 2026
* Web: add HEIC media normalization regression

* Docs: list HEIC input_image MIME types

* Update src/web/media.test.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
V-Gutierrez pushed a commit to V-Gutierrez/openclaw-vendor that referenced this pull request Mar 17, 2026
* Web: add HEIC media normalization regression

* Docs: list HEIC input_image MIME types

* Update src/web/media.test.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 20, 2026
* Web: add HEIC media normalization regression

* Docs: list HEIC input_image MIME types

* Update src/web/media.test.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
(cherry picked from commit 6017b73)
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 20, 2026
* Web: add HEIC media normalization regression

* Docs: list HEIC input_image MIME types

* Update src/web/media.test.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
(cherry picked from commit 6017b73)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: whatsapp-web Channel integration: whatsapp-web docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant