[PR #1460] [MERGED] Add URL binary API wrapper #5100

Closed
opened 2026-10-22 04:13:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1460
Author: @Xelvanis
Created: 5/28/2026
Status: ✅ Merged
Merged: 5/28/2026
Merged by: @Xelvanis

Base: refactor ← Head: chore/raw-invoketauri-url-binary


📝 Commits (2)

  • da33248 Add URL binary API wrapper
  • 1659e5e Harden URL binary failure paths

📊 Changes

5 files changed (+196 additions, -13 deletions)

View changed files

📝 src/shared/api/tauri-client.test.ts (+2 -1)
➕ src/shared/api/url-binary-api.test.ts (+59 -0)
➕ src/shared/api/url-binary-api.ts (+60 -0)
➕ src/shared/lib/url-blob.test.ts (+73 -0)
📝 src/shared/lib/url-blob.ts (+2 -12)

📄 Description

Linked issue

Part of #1457

Why this change

src/shared/lib/url-blob.ts still called invokeTauri("load_url_binary") directly. That kept the URL-binary command name, payload shape, response decoding, and malformed-response behavior inside a broad shared utility instead of a focused shared API wrapper.

This slice moves that command contract into src/shared/api, where remote-capable Tauri command wrappers belong, and adds failure-path coverage for the binary response contract.

What changed

  • Added src/shared/api/url-binary-api.ts for the load_url_binary command.
  • Updated src/shared/lib/url-blob.ts to call urlBinaryApi.load(...) instead of raw invokeTauri.
  • Added wrapper tests for command payloads, fallback MIME behavior, malformed responses, command error messages, and invalid base64 data.
  • Added url-blob tests for data URLs, non-GET rejection, remote wrapper calls, caller error copy, array-buffer conversion, and urlToDataUrl passthrough.
  • Added remote-runtime routing coverage for load_url_binary in the shared invokeTauri routing test.

Refactor impact

Primary owner:

Shared API wrapper / frontend shared URL helper.

Impact areas reviewed:

  • src/shared/api/url-binary-api.ts
  • src/shared/lib/url-blob.ts
  • src/shared/api/tauri-client.test.ts
  • Existing Rust command and HTTP dispatch contract for load_url_binary
  • Current callers of loadUrlBlob, loadUrlArrayBuffer, and urlToDataUrl

Boundary notes:

  • Feature and shared utility callers now depend on a focused shared API wrapper instead of importing tauri-client.ts directly.
  • load_url_binary was already remote-capable through remote-runtime.ts and src-tauri/src/http_dispatch.rs; this PR adds frontend routing coverage for that expectation.
  • No Rust command behavior changed.

Pressure points touched:

  • Shared binary URL loading used by bot browser asset loads, avatar/sprite URL conversion, GIF attachment loading, and game audio loading.

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

Agent-run local proof:

  • pnpm vitest run src/shared/api/url-binary-api.test.ts src/shared/lib/url-blob.test.ts src/shared/api/tauri-client.test.ts passed.
  • pnpm check passed, including architecture, frontend typecheck, Rust check, and docs.
  • pnpm test passed: 49 test files, 315 tests.
  • git diff --check passed.

Not run:

  • Native Tauri manual QA; this slice changes TypeScript wrapper/test behavior and leaves the Rust command path unchanged.
  • Graphify update; skipped per local instruction unless explicitly requested.
  • Remote runtime live smoke; routing is covered by unit test, but no live remote runtime was launched.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

No docs changes were made. This is an internal shared API wrapper migration slice with test coverage and no user-facing copy change.

UI evidence

No UI screenshots. There is no visible UI change.

Summary by CodeRabbit

  • Tests

    • Added comprehensive test coverage for URL binary data loading functionality, including validation of payload responses, error handling, and MIME type fallback behavior.
  • Refactor

    • Improved internal code organization for URL binary data handling with dedicated API abstraction layer.

Review Change Stack


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/1460 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/28/2026 **Status:** ✅ Merged **Merged:** 5/28/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `chore/raw-invoketauri-url-binary` --- ### 📝 Commits (2) - [`da33248`](https://github.com/Pasta-Devs/Marinara-Engine/commit/da33248cf0b66c87ede53f418361ca46b3ac760c) Add URL binary API wrapper - [`1659e5e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1659e5e38f0fbee265ed7ed569e0f46d2d89136d) Harden URL binary failure paths ### 📊 Changes **5 files changed** (+196 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `src/shared/api/tauri-client.test.ts` (+2 -1) ➕ `src/shared/api/url-binary-api.test.ts` (+59 -0) ➕ `src/shared/api/url-binary-api.ts` (+60 -0) ➕ `src/shared/lib/url-blob.test.ts` (+73 -0) 📝 `src/shared/lib/url-blob.ts` (+2 -12) </details> ### 📄 Description ## Linked issue Part of #1457 ## Why this change `src/shared/lib/url-blob.ts` still called `invokeTauri("load_url_binary")` directly. That kept the URL-binary command name, payload shape, response decoding, and malformed-response behavior inside a broad shared utility instead of a focused shared API wrapper. This slice moves that command contract into `src/shared/api`, where remote-capable Tauri command wrappers belong, and adds failure-path coverage for the binary response contract. ## What changed - Added `src/shared/api/url-binary-api.ts` for the `load_url_binary` command. - Updated `src/shared/lib/url-blob.ts` to call `urlBinaryApi.load(...)` instead of raw `invokeTauri`. - Added wrapper tests for command payloads, fallback MIME behavior, malformed responses, command error messages, and invalid base64 data. - Added `url-blob` tests for data URLs, non-GET rejection, remote wrapper calls, caller error copy, array-buffer conversion, and `urlToDataUrl` passthrough. - Added remote-runtime routing coverage for `load_url_binary` in the shared `invokeTauri` routing test. ## Refactor impact Primary owner: Shared API wrapper / frontend shared URL helper. Impact areas reviewed: - `src/shared/api/url-binary-api.ts` - `src/shared/lib/url-blob.ts` - `src/shared/api/tauri-client.test.ts` - Existing Rust command and HTTP dispatch contract for `load_url_binary` - Current callers of `loadUrlBlob`, `loadUrlArrayBuffer`, and `urlToDataUrl` Boundary notes: - Feature and shared utility callers now depend on a focused shared API wrapper instead of importing `tauri-client.ts` directly. - `load_url_binary` was already remote-capable through `remote-runtime.ts` and `src-tauri/src/http_dispatch.rs`; this PR adds frontend routing coverage for that expectation. - No Rust command behavior changed. Pressure points touched: - Shared binary URL loading used by bot browser asset loads, avatar/sprite URL conversion, GIF attachment loading, and game audio loading. ## Validation - [x] `pnpm check` passes locally - [x] `pnpm typecheck` passes locally - [x] `pnpm build` passes locally - [x] `pnpm check:architecture` passes locally - [x] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant ### Manual verification notes Agent-run local proof: - `pnpm vitest run src/shared/api/url-binary-api.test.ts src/shared/lib/url-blob.test.ts src/shared/api/tauri-client.test.ts` passed. - `pnpm check` passed, including architecture, frontend typecheck, Rust check, and docs. - `pnpm test` passed: 49 test files, 315 tests. - `git diff --check` passed. Not run: - Native Tauri manual QA; this slice changes TypeScript wrapper/test behavior and leaves the Rust command path unchanged. - Graphify update; skipped per local instruction unless explicitly requested. - Remote runtime live smoke; routing is covered by unit test, but no live remote runtime was launched. ## Docs and release impact - [x] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [x] Confirmed this PR does not restore old staging/package-workspace/release claims No docs changes were made. This is an internal shared API wrapper migration slice with test coverage and no user-facing copy change. ## UI evidence No UI screenshots. There is no visible UI change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Added comprehensive test coverage for URL binary data loading functionality, including validation of payload responses, error handling, and MIME type fallback behavior. * **Refactor** * Improved internal code organization for URL binary data handling with dedicated API abstraction layer. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/1460?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:13:14 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5100
No description provided.