[GH-ISSUE #3616] [Issue]: Client server state is split between React Query and Zustand #1956

Closed
opened 2026-10-21 05:44:09 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @Xelvanis on GitHub (Jul 14, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3616

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Client server state is split between React Query and Zustand despite the documented client boundary requiring async server calls to live in React Query hooks. Game Assets currently has independent React Query and Zustand server-data paths, while the sidecar Zustand store also owns duplicated SSE transport parsing and silently discards some delete/unload failures.

This creates two sources of truth: a mutation can refresh one cache while consumers of the other continue using stale state. Sidecar failures can also become silent no-ops in the UI.

Expected behavior

  • React Query owns server-backed status, manifests, CRUD mutations, caching, and invalidation.
  • Zustand retains only transient UI/runtime state such as playback selection, progress, and cancellation state.
  • SSE parsing is shared rather than independently implemented for model/runtime and speech downloads.
  • Failed destructive actions are surfaced to the caller or shown to the user.

Actual behavior

  • game-asset.store.ts fetches and stores /game-assets/manifest and performs /game-assets/rescan independently of use-game-assets.ts.
  • useRescanGameAssets() invalidates only the React Query tree key; the Zustand manifest has a separate refresh lifecycle.
  • sidecar.store.ts contains separate SSE reader/parser implementations for general and speech downloads.
  • deleteModel(), deleteSpeechModel(), and unloadModel() catch request failures without reporting or rethrowing them. The Local Speech Model delete action is wired directly to this silent path.

Steps to reproduce

  1. Load Game Mode so game-asset.store.ts fetches the asset manifest.
  2. Rescan or mutate assets through the Game Assets Browser, which uses the React Query hooks.
  3. Observe from the code path that the React Query tree is invalidated, but the independently stored Zustand manifest is not; mounted Game Mode consumers can continue reading the old manifest until their separate fetch runs.
  4. For the concrete silent-failure path, download a Local Speech Model, then block DELETE /api/sidecar/speech/model in browser DevTools (or otherwise make it return a non-2xx response).
  5. Click the Local Speech Model trash button in Connections.
  6. The request fails, but deleteSpeechModel() consumes the error and the UI shows no failure message.

Runtime reproduction was not performed for this report; the missing cross-cache invalidation, duplicated readers, and swallowed error paths were verified by static inspection of current staging.

Environment

  • Marinara Engine version: staging at 694bc88f16bd99838aa52b70bd07b56fe9e354e4 (2026-07-15)
  • Install type: source inspection
  • OS + version: Not applicable (static inspection)
  • Browser or app shell: Not applicable (static inspection)

Logs, screenshots, or video

None. This report is based on static inspection; no runtime logs or screenshots were captured.

Additional context

Documented boundary:

Game Assets split ownership:

Sidecar transport/error handling:

Suggested remediation:

  1. Add a React Query manifest query and migrate Game Assets server operations to the query layer, with mutations invalidating the relevant tree and manifest keys.
  2. Keep playback selection and other transient Game Mode state in Zustand.
  3. Extract the common SSE reader/parser while retaining operation-specific progress updates and cancellation state.
  4. Surface destructive-operation failures instead of treating them as best-effort success.

Related but not duplicate: #2720 covered sidecar busy guards, abort/disconnect plumbing, and download lifecycle failures. It did not address the broader state-ownership boundary, duplicated model/speech SSE readers, or these remaining swallowed delete/unload errors.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Xelvanis on GitHub (Jul 14, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3616 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Client server state is split between React Query and Zustand despite the documented client boundary requiring async server calls to live in React Query hooks. Game Assets currently has independent React Query and Zustand server-data paths, while the sidecar Zustand store also owns duplicated SSE transport parsing and silently discards some delete/unload failures. This creates two sources of truth: a mutation can refresh one cache while consumers of the other continue using stale state. Sidecar failures can also become silent no-ops in the UI. ## Expected behavior - React Query owns server-backed status, manifests, CRUD mutations, caching, and invalidation. - Zustand retains only transient UI/runtime state such as playback selection, progress, and cancellation state. - SSE parsing is shared rather than independently implemented for model/runtime and speech downloads. - Failed destructive actions are surfaced to the caller or shown to the user. ## Actual behavior - `game-asset.store.ts` fetches and stores `/game-assets/manifest` and performs `/game-assets/rescan` independently of `use-game-assets.ts`. - `useRescanGameAssets()` invalidates only the React Query tree key; the Zustand manifest has a separate refresh lifecycle. - `sidecar.store.ts` contains separate SSE reader/parser implementations for general and speech downloads. - `deleteModel()`, `deleteSpeechModel()`, and `unloadModel()` catch request failures without reporting or rethrowing them. The Local Speech Model delete action is wired directly to this silent path. ## Steps to reproduce 1. Load Game Mode so `game-asset.store.ts` fetches the asset manifest. 2. Rescan or mutate assets through the Game Assets Browser, which uses the React Query hooks. 3. Observe from the code path that the React Query tree is invalidated, but the independently stored Zustand manifest is not; mounted Game Mode consumers can continue reading the old manifest until their separate fetch runs. 4. For the concrete silent-failure path, download a Local Speech Model, then block `DELETE /api/sidecar/speech/model` in browser DevTools (or otherwise make it return a non-2xx response). 5. Click the Local Speech Model trash button in Connections. 6. The request fails, but `deleteSpeechModel()` consumes the error and the UI shows no failure message. Runtime reproduction was not performed for this report; the missing cross-cache invalidation, duplicated readers, and swallowed error paths were verified by static inspection of current `staging`. ## Environment - Marinara Engine version: `staging` at `694bc88f16bd99838aa52b70bd07b56fe9e354e4` (2026-07-15) - Install type: source inspection - OS + version: Not applicable (static inspection) - Browser or app shell: Not applicable (static inspection) ## Logs, screenshots, or video None. This report is based on static inspection; no runtime logs or screenshots were captured. ## Additional context Documented boundary: - [`packages/client/.instructions.md` requires server calls in React Query hooks and synchronous Zustand actions](https://github.com/Pasta-Devs/Marinara-Engine/blob/694bc88f16bd99838aa52b70bd07b56fe9e354e4/packages/client/.instructions.md#L151-L165) Game Assets split ownership: - [`game-asset.store.ts` manifest fetch and rescan](https://github.com/Pasta-Devs/Marinara-Engine/blob/694bc88f16bd99838aa52b70bd07b56fe9e354e4/packages/client/src/stores/game-asset.store.ts#L61-L80) - [`useRescanGameAssets()` React Query mutation and tree invalidation](https://github.com/Pasta-Devs/Marinara-Engine/blob/694bc88f16bd99838aa52b70bd07b56fe9e354e4/packages/client/src/hooks/use-game-assets.ts#L144-L155) Sidecar transport/error handling: - [General download SSE reader](https://github.com/Pasta-Devs/Marinara-Engine/blob/694bc88f16bd99838aa52b70bd07b56fe9e354e4/packages/client/src/stores/sidecar.store.ts#L153-L283) - [Parallel speech-download SSE reader](https://github.com/Pasta-Devs/Marinara-Engine/blob/694bc88f16bd99838aa52b70bd07b56fe9e354e4/packages/client/src/stores/sidecar.store.ts#L284-L414) - [Silently discarded delete/unload failures](https://github.com/Pasta-Devs/Marinara-Engine/blob/694bc88f16bd99838aa52b70bd07b56fe9e354e4/packages/client/src/stores/sidecar.store.ts#L624-L669) Suggested remediation: 1. Add a React Query manifest query and migrate Game Assets server operations to the query layer, with mutations invalidating the relevant tree and manifest keys. 2. Keep playback selection and other transient Game Mode state in Zustand. 3. Extract the common SSE reader/parser while retaining operation-specific progress updates and cancellation state. 4. Surface destructive-operation failures instead of treating them as best-effort success. Related but not duplicate: #2720 covered sidecar busy guards, abort/disconnect plumbing, and download lifecycle failures. It did not address the broader state-ownership boundary, duplicated model/speech SSE readers, or these remaining swallowed delete/unload errors. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:44:09 +07:00
  • closed this issue
  • added the
    in-pr
    label
Author
Owner

@SpicyMarinara commented on GitHub (Jul 14, 2026):

Ownership: @SpicyMarinara is addressing this in fix/3616-3625-open-issues. A staging-targeted draft PR will be linked as soon as the first reproducible fix is committed.

<!-- gh-comment-id:4974861924 --> @SpicyMarinara commented on GitHub (Jul 14, 2026): Ownership: @SpicyMarinara is addressing this in `fix/3616-3625-open-issues`. A staging-targeted draft PR will be linked as soon as the first reproducible fix is committed.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 14, 2026):

Draft implementation PR is now open: #3626. It remains draft while the linked regression lanes are implemented and validated.

<!-- gh-comment-id:4974876095 --> @SpicyMarinara commented on GitHub (Jul 14, 2026): Draft implementation PR is now open: #3626. It remains draft while the linked regression lanes are implemented and validated.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 14, 2026):

Addressed in ready-for-review PR #3626 targeting staging. The fix and regression coverage have been pushed and validated locally.

<!-- gh-comment-id:4975033904 --> @SpicyMarinara commented on GitHub (Jul 14, 2026): Addressed in ready-for-review PR #3626 targeting staging. The fix and regression coverage have been pushed and validated locally.
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#1956
No description provided.