[PR #2052] [MERGED] Fix catalog summary selector reads #5411

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2052
Author: @cha1latte
Created: 6/3/2026
Status: ✅ Merged
Merged: 6/3/2026
Merged by: @Xelvanis

Base: refactor ← Head: fix/issue-2036-catalog-summary-reads


📝 Commits (5)

  • 7806392 Fix catalog summary selector reads
  • 8f7ed82 Address catalog selector review findings
  • d28876c Fix chat surface data test mock
  • bdb18f2 Merge refactor into catalog summary reads
  • ca8c9af Fix catalog summary review findings

📊 Changes

8 files changed (+476 additions, -34 deletions)

View changed files

📝 src-tauri/crates/storage/src/lib.rs (+415 -3)
📝 src/features/catalog/connections/hooks/use-connections.ts (+34 -1)
📝 src/features/catalog/presets/hooks/use-presets.ts (+16 -20)
📝 src/features/modes/game/components/GameSetupWizard.tsx (+2 -2)
📝 src/features/modes/shared/chat-ui/components/ChatSetupWizard.tsx (+7 -3)
📝 src/features/modes/shared/chat-ui/components/CreatorNotesCssInjector.tsx (+1 -1)
📝 src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.test.tsx (+0 -3)
📝 src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.ts (+1 -1)

📄 Description

Linked issue

Closes #2036

Why this change

  • Large catalog selector surfaces were still doing repeated expensive reads on large profiles: projected storage reads skipped the clean full-row cache, and several selector hooks still requested full rows.
  • This keeps warm selector reads fast while preserving detail-row loading for editors and runtime paths that genuinely need full payloads.

What changed

  • Added a storage-level projected list cache keyed by normalized projection shape, with collection file stamp validation and write invalidation.
  • Switched connection and preset selector hooks to explicit summary projections that keep the fields their existing callers need.
  • Switched the chat surface character lookup and game setup persona picker to existing summary hooks instead of full-row selector reads.
  • Added targeted Rust coverage for projected cache reuse, external-file invalidation, write invalidation, and existing projected-list behavior.

Refactor impact

Primary owner:

  • Rust storage; catalog selectors; shared chat/game setup surfaces.

Impact areas reviewed:

  • storage_list projected read behavior, dirty collection cache semantics, external JSON collection edits, connection/preset/persona selector consumers, chat surface character map assembly.

Boundary notes:

  • Engine code remains React-free. Feature code still uses focused shared API wrappers through existing catalog hooks. No schema, dependency, auth, prompt pipeline, or release metadata changes.

Pressure points touched:

  • src-tauri/crates/storage/src/lib.rs
  • src/features/catalog/connections/hooks/use-connections.ts
  • src/features/catalog/presets/hooks/use-presets.ts
  • src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.ts
  • src/features/modes/game/components/GameSetupWizard.tsx

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • Codex verification:
  • cargo test --manifest-path src-tauri/Cargo.toml -p marinara-storage list_projected_ -- --nocapture passed with 6 projected-list tests.
  • pnpm typecheck passed.
  • pnpm test:allow-empty passed after updating the existing chat-surface hook test mock for useCharacterSummariesByIds.
  • pnpm check passed after the final local diff.
  • Bunny review found two in-scope findings on the first commit; follow-up commits split the default preset summary hook and strengthened projected-cache stamp validation with same-length rewrite coverage. Awaiting fresh PR automation on the latest head.
  • Draft limitation: the workflow proof-gate helper C:/Users/celia/.codex/tools/marinara-proof-gate.mjs is not present in this environment. scratch/bugfix-verification.json is filled with the risk matrix and all available machine proof, but this PR should stay draft until Celia decides whether that missing local gate is acceptable.

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • Internal storage/cache and selector payload fix; no new discoverable feature.

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

UI evidence

N/A. This is a non-visual storage/selector performance fix; verification is command-based.

Summary by CodeRabbit

  • Performance

    • Added cached projection lists with content-aware invalidation to speed repeated collection reads.
    • Reduced payloads by fetching summary projections for connections, presets, personas, and characters.
  • New Features

    • New default-preset summary flow and persona-summary usage in setup wizards.
  • Bug Fixes

    • Projected caches now clear correctly after writes/replacements.
  • Tests

    • Added unit tests covering projection cache behavior and invalidation.

🔄 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/2052 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/3/2026 **Status:** ✅ Merged **Merged:** 6/3/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `fix/issue-2036-catalog-summary-reads` --- ### 📝 Commits (5) - [`7806392`](https://github.com/Pasta-Devs/Marinara-Engine/commit/780639277959ddfdb836d43bf1f36da7a9ad14f1) Fix catalog summary selector reads - [`8f7ed82`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8f7ed82ade7b82763651e88f180a0bcd17c0b303) Address catalog selector review findings - [`d28876c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d28876ca23e2fed9587f79b9368b28606bc41065) Fix chat surface data test mock - [`bdb18f2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bdb18f263a96131b4978b2611734f5fc6ba0e622) Merge refactor into catalog summary reads - [`ca8c9af`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ca8c9afd327c428256c7338566b70b82c02701d6) Fix catalog summary review findings ### 📊 Changes **8 files changed** (+476 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/crates/storage/src/lib.rs` (+415 -3) 📝 `src/features/catalog/connections/hooks/use-connections.ts` (+34 -1) 📝 `src/features/catalog/presets/hooks/use-presets.ts` (+16 -20) 📝 `src/features/modes/game/components/GameSetupWizard.tsx` (+2 -2) 📝 `src/features/modes/shared/chat-ui/components/ChatSetupWizard.tsx` (+7 -3) 📝 `src/features/modes/shared/chat-ui/components/CreatorNotesCssInjector.tsx` (+1 -1) 📝 `src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.test.tsx` (+0 -3) 📝 `src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.ts` (+1 -1) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue Closes #2036 ## Why this change - Large catalog selector surfaces were still doing repeated expensive reads on large profiles: projected storage reads skipped the clean full-row cache, and several selector hooks still requested full rows. - This keeps warm selector reads fast while preserving detail-row loading for editors and runtime paths that genuinely need full payloads. ## What changed - Added a storage-level projected list cache keyed by normalized projection shape, with collection file stamp validation and write invalidation. - Switched connection and preset selector hooks to explicit summary projections that keep the fields their existing callers need. - Switched the chat surface character lookup and game setup persona picker to existing summary hooks instead of full-row selector reads. - Added targeted Rust coverage for projected cache reuse, external-file invalidation, write invalidation, and existing projected-list behavior. ## Refactor impact Primary owner: - Rust storage; catalog selectors; shared chat/game setup surfaces. Impact areas reviewed: - `storage_list` projected read behavior, dirty collection cache semantics, external JSON collection edits, connection/preset/persona selector consumers, chat surface character map assembly. Boundary notes: - Engine code remains React-free. Feature code still uses focused shared API wrappers through existing catalog hooks. No schema, dependency, auth, prompt pipeline, or release metadata changes. Pressure points touched: - `src-tauri/crates/storage/src/lib.rs` - `src/features/catalog/connections/hooks/use-connections.ts` - `src/features/catalog/presets/hooks/use-presets.ts` - `src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.ts` - `src/features/modes/game/components/GameSetupWizard.tsx` ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> <!-- Do not submit *.test.ts or *.test.tsx files as PR proof; cite existing checks, command output, app/browser/Tauri verification, or manual notes instead. --> - [x] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [x] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - Codex verification: - `cargo test --manifest-path src-tauri/Cargo.toml -p marinara-storage list_projected_ -- --nocapture` passed with 6 projected-list tests. - `pnpm typecheck` passed. - `pnpm test:allow-empty` passed after updating the existing chat-surface hook test mock for `useCharacterSummariesByIds`. - `pnpm check` passed after the final local diff. - Bunny review found two in-scope findings on the first commit; follow-up commits split the default preset summary hook and strengthened projected-cache stamp validation with same-length rewrite coverage. Awaiting fresh PR automation on the latest head. - Draft limitation: the workflow proof-gate helper `C:/Users/celia/.codex/tools/marinara-proof-gate.mjs` is not present in this environment. `scratch/bugfix-verification.json` is filled with the risk matrix and all available machine proof, but this PR should stay draft until Celia decides whether that missing local gate is acceptable. ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [x] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - Internal storage/cache and selector payload fix; no new discoverable feature. ## 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 ## UI evidence N/A. This is a non-visual storage/selector performance fix; verification is command-based. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Performance** * Added cached projection lists with content-aware invalidation to speed repeated collection reads. * Reduced payloads by fetching summary projections for connections, presets, personas, and characters. * **New Features** * New default-preset summary flow and persona-summary usage in setup wizards. * **Bug Fixes** * Projected caches now clear correctly after writes/replacements. * **Tests** * Added unit tests covering projection cache behavior and invalidation. <!-- 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:16:04 +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#5411
No description provided.