[GH-ISSUE #2675] [Bug]: Inconsistent Chat Sidebar Position Update #1321

Closed
opened 2026-10-21 05:31:31 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Gunterlie on GitHub (Jun 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2675

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Navigating to a chat does not consistently update its position in the sidebar (sorted by updatedAt):

  • Roleplay / visual novel chats jump to the top on first navigation — but only once, and only as a side effect.
  • Conversation chats never jump to the top on navigation.

Root Cause

The jump for RP chats is an unintentional side effect of the background persistence logic in ChatArea.tsx. When navigating to an RP/visual_novel chat with no saved background in metadata:

  1. The restore effect sets chatBackground = defaultRoleplayBackground
  2. The persist effect detects savedBackground (null) !== nextBackground and fires updateMeta.mutate({ id, background: nextBackground })
  3. The server patchMetadata call touches updatedAt by default
  4. chatKeys.list() is invalidated → list refetches → chat sorts to top

After the first visit the background is saved, so no write fires on subsequent navigations — the RP chat stops jumping.

Conversation chats have no equivalent write on navigation.

Files Involved

  • packages/client/src/components/chat/ChatArea.tsx — background restore/persist effects
  • packages/server/src/services/storage/chats.storage.ts — patchMetadata / touchUpdatedAt
  • packages/client/src/components/layout/ChatSidebar.tsx — sorts by updatedAt
Originally created by @Gunterlie on GitHub (Jun 20, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2675 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Navigating to a chat does not consistently update its position in the sidebar (sorted by `updatedAt`): - **Roleplay / visual novel chats** jump to the top on *first* navigation — but only once, and only as a side effect. - **Conversation chats** never jump to the top on navigation. ## Root Cause The jump for RP chats is an unintentional side effect of the background persistence logic in `ChatArea.tsx`. When navigating to an RP/visual_novel chat with no saved background in metadata: 1. The restore effect sets `chatBackground = defaultRoleplayBackground` 2. The persist effect detects `savedBackground (null) !== nextBackground` and fires `updateMeta.mutate({ id, background: nextBackground })` 3. The server `patchMetadata` call touches `updatedAt` by default 4. `chatKeys.list()` is invalidated → list refetches → chat sorts to top After the first visit the background is saved, so no write fires on subsequent navigations — the RP chat stops jumping. Conversation chats have no equivalent write on navigation. ## Files Involved - `packages/client/src/components/chat/ChatArea.tsx` — background restore/persist effects - `packages/server/src/services/storage/chats.storage.ts` — `patchMetadata` / `touchUpdatedAt` - `packages/client/src/components/layout/ChatSidebar.tsx` — sorts by `updatedAt`
bsakaguchi 2026-10-21 05:31:31 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@SpicyMarinara commented on GitHub (Jun 21, 2026):

Fixed in the issue sweep branch by adding an explicit chat touch path when a chat is opened, so sidebar recency sorting no longer depends on incidental metadata writes from roleplay backgrounds. Final validation and PR are coming after the full issue pass.

<!-- gh-comment-id:4761428973 --> @SpicyMarinara commented on GitHub (Jun 21, 2026): Fixed in the issue sweep branch by adding an explicit chat touch path when a chat is opened, so sidebar recency sorting no longer depends on incidental metadata writes from roleplay backgrounds. Final validation and PR are coming after the full issue pass.
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#1321
No description provided.