perf: session cache mirror writes full message arrays on every SSE token #460
Labels
No labels
backend
bug
chore
duplication
effort:complex
effort:medium
effort:trivial
enhancement
frontend
fullstack
priority:high
ready-for-agent
refactor
security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dries/ocman#460
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Code-quality audit (P2).
frontend/src/pages/session-detail/useSession.ts:361-374.Why it matters
The effect depends on
view.messages/view.parts, whose identity changes on every streaming token delta. Each run clones the entiresessionCacheMap (apiStore.ts:209) and writes a newSessionDetail, which notifies everyuseApiStoresubscriber. At token rate, with up to 200 retained messages and their parts, that is a Map clone plus a store-wide notification per token — the dominant cost of watching a streaming session.The cache exists only to make a revisit warm. It does not need to be current mid-stream.
Suggested fix
Debounce the mirror (~500 ms), or better: flush only on the
session.idleedge and on unmount. Both give the same warm-revisit behaviour at a tiny fraction of the writes.Acceptance criteria
Effort: S.