[GH-ISSUE #4724] [Issue]: Tracker panel's hardcoded pageSize-20 observer hijacks the shared chat-messages query when messages-per-page differs (same class as #4721) #2594

Closed
opened 2026-10-21 05:50:56 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @kolacheee on GitHub (Aug 7, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4724

Originally assigned to: @SpicyMarinara on GitHub.

Summary

The tracker panel's sprite-expression lookup mounts a useChatMessages observer with a hardcoded pageSize: 20 on the same React Query key the chat transcript uses with the user's messages-per-page — the same options mis-share fixed for the Chat Settings drawer in #4721, from a different observer. When messages-per-page is set to anything other than 20, whichever observer rendered last owns the shared query's fetch closures, and the transcript's pagination runs with the wrong page size.

Expected behavior

The tracker panel's message reads have no effect on the transcript's pagination: refetches fetch messages-per-page-sized pages and "Load More" reflects the real history.

Actual behavior

With messages-per-page ≠ 20 and the tracker panel mounted with sprite-expression lookup enabled:

  • When the tracker's observer wins the options race, an invalidation-driven refetch fetches the newest page at limit=20 instead of the user's setting.
  • ChatArea's hasNextPage is computed from its observer options, so getNextPageParam evaluates a 20-row page against pageSize = 50 (for example): 20 < 50 → undefined → "Load More" disappears with older history still present. The defensive newest-page trim doesn't compensate — it only trims pages longer than the transcript's page size.

Code locations (current staging):

  • packages/client/src/features/tracker-panel/hooks/use-tracker-panel-model.ts:74 — useChatMessages(activeChatId, 20, spriteExpressionLookupEnabled)
  • packages/client/src/components/chat/ChatArea.tsx:751 — transcript observer at the user's messagesPerPage (0–500 in Settings; default 20 — which is why the default configuration masks the bug)
  • packages/client/src/hooks/use-chats.ts — useChatMessages keys by chat id only; page size lives in the queryFn/getNextPageParam closures

Steps to reproduce

  1. Set Messages-per-page to 50; open a chat with well over 50 messages and sprite-expression lookup active (tracker panel mounted).
  2. Trigger a transcript refetch (complete a generation, or any messages invalidation).
  3. Depending on which observer set options last, the refetch fetches limit=20 and "Load More" can vanish although older history exists.

Environment

  • Marinara Engine version: staging (c4f15f373)
  • Install type: source
  • OS + version: any (React Query v5 semantics)

Logs, screenshots, or video

Found by the adversarial review sweep run on the #4721 fix (the sweep lens explicitly looked for remaining instances of the class). Confirmed against @tanstack/query-core@5.100.9: QueryObserver.setOptions writes the shared query's options with no enabled guard, so the tracker's observer participates even while its enabled gate is false.

Additional context

Same fix shape as #4721 (merged fix pending in its PR): the sprite-expression lookup is a read-only newest-window consumer — it should read through the limit-keyed useChatMessagePeek (or an equivalent dedicated key) rather than observing the shared transcript query. When fixed, extend the #4721 source-scan regression pin (currently guarding only ChatSettingsDrawer.tsx) to cover use-tracker-panel-model.ts, or generalize it to allow only the sanctioned transcript observers on the shared key.

Kept out of the #4721 PR deliberately — pre-existing, different surface, and the tracker's consumer shape (MessageWithSwipes usage for sprite lookups) needs its own look before swapping the data source.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @kolacheee on GitHub (Aug 7, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4724 Originally assigned to: @SpicyMarinara on GitHub. ## Summary The tracker panel's sprite-expression lookup mounts a `useChatMessages` observer with a hardcoded `pageSize: 20` on the **same React Query key** the chat transcript uses with the user's messages-per-page — the same options mis-share fixed for the Chat Settings drawer in #4721, from a different observer. When messages-per-page is set to anything other than 20, whichever observer rendered last owns the shared query's fetch closures, and the transcript's pagination runs with the wrong page size. ## Expected behavior The tracker panel's message reads have no effect on the transcript's pagination: refetches fetch messages-per-page-sized pages and "Load More" reflects the real history. ## Actual behavior With messages-per-page ≠ 20 and the tracker panel mounted with sprite-expression lookup enabled: - When the tracker's observer wins the options race, an invalidation-driven refetch fetches the newest page at `limit=20` instead of the user's setting. - `ChatArea`'s `hasNextPage` is computed from **its** observer options, so `getNextPageParam` evaluates a 20-row page against `pageSize = 50` (for example): `20 < 50` → `undefined` → **"Load More" disappears** with older history still present. The defensive newest-page trim doesn't compensate — it only trims pages *longer* than the transcript's page size. Code locations (current staging): - `packages/client/src/features/tracker-panel/hooks/use-tracker-panel-model.ts:74` — `useChatMessages(activeChatId, 20, spriteExpressionLookupEnabled)` - `packages/client/src/components/chat/ChatArea.tsx:751` — transcript observer at the user's `messagesPerPage` (0–500 in Settings; default 20 — which is why the default configuration masks the bug) - `packages/client/src/hooks/use-chats.ts` — `useChatMessages` keys by chat id only; page size lives in the `queryFn`/`getNextPageParam` closures ## Steps to reproduce 1. Set Messages-per-page to 50; open a chat with well over 50 messages and sprite-expression lookup active (tracker panel mounted). 2. Trigger a transcript refetch (complete a generation, or any messages invalidation). 3. Depending on which observer set options last, the refetch fetches `limit=20` and "Load More" can vanish although older history exists. ## Environment - Marinara Engine version: staging (c4f15f373) - Install type: source - OS + version: any (React Query v5 semantics) ## Logs, screenshots, or video Found by the adversarial review sweep run on the #4721 fix (the sweep lens explicitly looked for remaining instances of the class). Confirmed against `@tanstack/query-core@5.100.9`: `QueryObserver.setOptions` writes the shared query's options with no `enabled` guard, so the tracker's observer participates even while its `enabled` gate is false. ## Additional context Same fix shape as #4721 (merged fix pending in its PR): the sprite-expression lookup is a read-only newest-window consumer — it should read through the limit-keyed `useChatMessagePeek` (or an equivalent dedicated key) rather than observing the shared transcript query. When fixed, extend the #4721 source-scan regression pin (currently guarding only `ChatSettingsDrawer.tsx`) to cover `use-tracker-panel-model.ts`, or generalize it to allow only the sanctioned transcript observers on the shared key. Kept out of the #4721 PR deliberately — pre-existing, different surface, and the tracker's consumer shape (`MessageWithSwipes` usage for sprite lookups) needs its own look before swapping the data source. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:50:56 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Aug 7, 2026):

SpicyMarinara/Codex is implementing this in draft PR #4736 on agent/assigned-issues-4718-4734.

<!-- gh-comment-id:5222378681 --> @SpicyMarinara commented on GitHub (Aug 7, 2026): SpicyMarinara/Codex is implementing this in draft PR #4736 on `agent/assigned-issues-4718-4734`.
Author
Owner

@kolacheee commented on GitHub (Aug 7, 2026):

Resolved by #4736 (staging): use-tracker-panel-model.ts now reads message data through useChatMessagePeek(activeChatId, 20, ...) - the isolated peek query introduced for #4721 - instead of observing the shared chat-messages infinite query with a hardcoded pageSize of 20. With no observer on the shared key, the last-observer-wins options hijack this issue describes can no longer occur; the 20 is now just the peek's own fetch limit, which affects nothing outside the tracker panel. Verified against current staging code. Closing.

<!-- gh-comment-id:5223299142 --> @kolacheee commented on GitHub (Aug 7, 2026): Resolved by #4736 (staging): use-tracker-panel-model.ts now reads message data through useChatMessagePeek(activeChatId, 20, ...) - the isolated peek query introduced for #4721 - instead of observing the shared chat-messages infinite query with a hardcoded pageSize of 20. With no observer on the shared key, the last-observer-wins options hijack this issue describes can no longer occur; the 20 is now just the peek's own fetch limit, which affects nothing outside the tracker panel. Verified against current staging code. Closing.
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#2594
No description provided.