perf(sessions): persist conversation build caches across task re-opens - #76788
perf(sessions): persist conversation build caches across task re-opens#76788arnohillen wants to merge 3 commits into
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
Reviews (1): Last reviewed commit: "chore(sessions): add lru-cache to the ui..." | Re-trigger Greptile |
|
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the |
Generated-By: PostHog Desktop Task-Id: 6ee186ae-f972-424a-9636-b747d12e9cc8
feaf227 to
58d2773
Compare
|
React Doctor found 2 issues in 2 files · 2 errors. Errors
Reviewed by React Doctor for commit |
HostHog preview —
|
Keeps the persistent conversation build cache and master's transcript stall logging: the stall-detection fields now live on ConversationBuildCache, so they survive a task re-open along with the builder. Generated-By: PostHog Desktop Task-Id: 341e450d-132c-42dd-abf2-52b22f99c3f6
🤖 CI report✅ Trunk lane — does not run backend Python testsThis PR is assigned to a lane that does not run backend Python tests. |
Ports PostHog/code#3976 onto
products/desktop/after the desktop import (the code repo'smainis frozen). Original commits and authorship are preserved viagit am.Problem
Clicking a task in the sidebar takes seconds before the transcript renders, even when the session data is already warm in the store. The task detail route fully unmounts on navigation, and the incremental conversation builder (
useConversationItems) and thread grouper both live in component-scoped refs, so every re-open falls back to a full O(n) re-parse of the transcript on the main thread.yieldToPaintalready documents the mount blocking "for hundreds of ms"; with multi-MB transcripts it is seconds.Changes
conversationDerivedCachemodule: a small LRU cache (8 tasks per scope, backed bylru-cache, already a workspace dependency via harness) keyed per call site + task that keeps the incremental builder state and thread grouper alive across mounts.useConversationItemsaccepts an optional persist key; without one, behavior is unchanged (per-component ref).ConversationViewandAcpChatThreadopt in with distinct scopes;ChatThreadFooternow receivesfooterStateand usage fromAcpChatThreadinstead of running its own duplicate parse.Warm re-opens (session still in the store) now reuse already-built items: idle sessions return the memoized result identity, and streaming sessions take the append-only fast path because the store keeps appending while the view is unmounted and immer preserves element identity.
Compared to the source PR, the only monorepo-specific change is the lockfile: instead of carrying the source
pnpm-lock.yamlhunk blindly, theproducts/desktop/pnpm-lock.yamlimporter entry was regenerated for the newpackages/uidependency (same resolution,lru-cache@11.2.5).How did you test this code?
evictEvents/removeSession, and the no-session exemption (guards rebuild churn on archive surfaces).products/desktop/:pnpm install --frozen-lockfile,pnpm typecheck(24/24 packages), and the full@posthog/uivitest suite (305 files, 2519 tests passing).Automatic notifications
Docs update
Not applicable (desktop app internals),
skip-inkeep-docslabel applied.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
This PR is a port of PostHog/code#3976, recreated here by PostHog Code following the /porting-code-prs skill: patch series applied with
git am --directory=products/desktop/(original authorship and commit messages preserved), source lockfile hunk excluded and re-derived against the monorepo lockfile instead. Part 1 of 3 ported PRs on task re-open latency.Created with PostHog Code