[PR #1991] [MERGED] Fix Conversation chat load latency #5376

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/conversation-chat-load-latency


📝 Commits (2)

  • 5b3e70e Fix conversation chat load latency
  • 21998bc Refresh PR metadata checks

📊 Changes

4 files changed (+149 additions, -4 deletions)

View changed files

➕ src/features/modes/router/components/ModeSurface.test.tsx (+69 -0)
📝 src/features/modes/router/components/ModeSurface.tsx (+6 -3)
➕ src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.test.tsx (+73 -0)
📝 src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.ts (+1 -1)

📄 Description

Linked issue

No linked issue yet; filed from Celia's local bug report that Conversation mode takes too long to load a chat even when that chat only has one message.

Why this change

  • Conversation chat selection could serialize route selection and message loading behind the full chat-detail query. That made tiny existing Conversation chats feel stalled even when there was almost no transcript work to do.

What changed

  • Let ModeSurface use cached chat summaries to choose the active mode while chat detail is still hydrating.
  • Let useChatSurfaceData start loading messages as soon as an activeChatId exists instead of waiting for chat detail.
  • Added focused regression tests for cached-summary routing and immediate message-query enablement.

Refactor impact

Primary owner:

Shared mode UI.

Impact areas reviewed:

  • Conversation mode chat switching/loading.
  • Shared chat surface data used by Conversation, Roleplay, and the game conversation pane.
  • Mode routing from cached chat summaries versus full chat detail.

Boundary notes:

  • Frontend-only change. No engine, shared API wrapper, Rust, storage, remote-runtime, schema, dependency, or version changes.
  • Invalid chat ids still rely on the existing chat-detail 404 path to clear active chat state.

Pressure points touched:

  • ModeSurface
  • Shared chat UI useChatSurfaceData

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 ran pnpm test src/features/modes/router/components/ModeSurface.test.tsx src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.test.tsx in the clean PR worktree: passed.
  • Codex ran pnpm check in the clean PR worktree after the final staged diff: passed.
  • Codex ran node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json: passed.
  • Live Tauri smoke from the original checkout selected a one-message Conversation row and reached usable input in 38 ms with zero Conversation loading spinners.

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:

  • This is a bugfix for existing Conversation chat loading behavior and does not add a 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

After selecting a one-message Conversation chat:

Conversation chat load proof


🔄 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/1991 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/2/2026 **Status:** ✅ Merged **Merged:** 6/2/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/conversation-chat-load-latency` --- ### 📝 Commits (2) - [`5b3e70e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5b3e70ee81c3247ae2c34d7608c8d39e6729b674) Fix conversation chat load latency - [`21998bc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/21998bc3a4210d407daa9a08438b48e9e9641dcc) Refresh PR metadata checks ### 📊 Changes **4 files changed** (+149 additions, -4 deletions) <details> <summary>View changed files</summary> ➕ `src/features/modes/router/components/ModeSurface.test.tsx` (+69 -0) 📝 `src/features/modes/router/components/ModeSurface.tsx` (+6 -3) ➕ `src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.test.tsx` (+73 -0) 📝 `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 <!-- Every user-facing PR should reference a feature request or issue report when practical. --> No linked issue yet; filed from Celia's local bug report that Conversation mode takes too long to load a chat even when that chat only has one message. ## Why this change <!-- What user problem, bug, refactor goal, or maintenance need does this solve? --> - Conversation chat selection could serialize route selection and message loading behind the full chat-detail query. That made tiny existing Conversation chats feel stalled even when there was almost no transcript work to do. ## What changed <!-- List the key changes in this PR. --> - Let `ModeSurface` use cached chat summaries to choose the active mode while chat detail is still hydrating. - Let `useChatSurfaceData` start loading messages as soon as an `activeChatId` exists instead of waiting for chat detail. - Added focused regression tests for cached-summary routing and immediate message-query enablement. ## Refactor impact Primary owner: <!-- Examples: app shell, catalog, chat mode, roleplay mode, game mode, runtime generation, world-state, shared API, engine generation, Rust storage, imports, remote runtime. --> Shared mode UI. Impact areas reviewed: - Conversation mode chat switching/loading. - Shared chat surface data used by Conversation, Roleplay, and the game conversation pane. - Mode routing from cached chat summaries versus full chat detail. Boundary notes: <!-- Note engine/shared-api/feature/Rust/remote-runtime boundaries. Say "none" only if you checked. --> - Frontend-only change. No engine, shared API wrapper, Rust, storage, remote-runtime, schema, dependency, or version changes. - Invalid chat ids still rely on the existing chat-detail 404 path to clear active chat state. Pressure points touched: <!-- Mention ModeSurface, GameSurface, shared mode UI, src-tauri/src/lib.rs command registration, or import modules if touched. --> - `ModeSurface` - Shared chat UI `useChatSurfaceData` ## 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. --> - [ ] 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 <!-- Describe exact commands and manual steps, including typecheck/build/docs/architecture/Rust/browser/remote-runtime checks when they apply. If an AI agent filled this out, verify it yourself before ticking boxes. --> - Codex ran `pnpm test src/features/modes/router/components/ModeSurface.test.tsx src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.test.tsx` in the clean PR worktree: passed. - Codex ran `pnpm check` in the clean PR worktree after the final staged diff: passed. - Codex ran `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json`: passed. - Live Tauri smoke from the original checkout selected a one-message Conversation row and reached usable input in 38 ms with zero Conversation loading spinners. ## 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: - This is a bugfix for existing Conversation chat loading behavior and does not add a 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 <!-- Add before/after screenshots or recordings for visible UI changes. --> After selecting a one-message Conversation chat: ![Conversation chat load proof](https://gist.githubusercontent.com/cha1latte/652c4c2a35c41be0919d02ca6f709240/raw/conversation-load-after-select.png) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:15:46 +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#5376
No description provided.