Skip to content

perf(desktop): persist private history across app restarts - #300

Merged
nixuuu merged 1 commit into
devfrom
perf/tail-first-1
Nov 6, 2026
Merged

nixuuu merged 1 commit into
devfrom
perf/tail-first-1

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Restarting Electron previously discarded all thread, bot chat and exchange state. This stage saves public protobuf projections in the app's private data directory and restores them before the first watch, so reopening sends the saved journal checkpoint.

The shared durable LRU holds 32 views / 96 MiB, at most 16 MiB per entry. Atomic rename, 0700 directories, 0600 files, projection validation and generation fences protect partial writes and session changes. Mode change, unpair and revocation clear disk and memory. Plain browser sessions deliberately remain memory-only: no conversation content in IndexedDB or localStorage. Polish desktop documentation records the boundary and limits.

Restart findings and measurements

The existing mobile caches really do survive force-stop/relaunch. On an Android Fold emulator, using the current development binary, reopening a 3,000-message thread sent a 433-byte protobuf delta and reopening a 3,000-message bot chat sent a 310-byte delta with zero messages. Cached bot content rendered before the delta arrived. No mobile persistence/schema-key fix was needed. An obsolete development binary initially buffered small streaming responses; the check was repeated on the current build.

For context, the uncached full thread response was 3,559,707 protobuf bytes. Desktop persistence plus a real gateway restart is verified by integration tests; native Electron shell launch-to-paint timing and an actual packaged Electron quit/relaunch remain unverified. The client paging stages below address uncached opens.

Verification

No migrations or new native mobile dependencies. No UI copy changes in this stage.

@nixuuu
nixuuu added this pull request to stack #303 November 6, 2026 20:28
@nixuuu
nixuuu marked this pull request as ready for review November 6, 2026 20:38
@nixuuu
nixuuu force-pushed the perf/tail-first-1 branch from afee425 to cf16038 Compare November 6, 2026 21:04
@nixuuu
nixuuu merged commit 5dd1efd into dev Nov 6, 2026
10 checks passed
@nixuuu
nixuuu deleted the perf/tail-first-1 branch November 6, 2026 21:09
nixuuu added a commit that referenced this pull request Nov 20, 2026
## Change

- Web and desktop show the loaded timeline immediately. Scrolling up to
a gap reads one older page. “Show earlier work” loads the selected turn,
including turns that span several pages. On mobile, a gesture toward the
history edge loads at most one page.
- Web, desktop and mobile keep the live stream open when an older page
covers the changes already received. If the stream advanced past the
page, the client replays from the page checkpoint to recover concurrent
edits and deletions.
- Desktop persists a bounded history tail. Web and desktop limit
inactive expanded content to 32 items and 8 MiB and cancel obsolete
reads on reset. An oversized result stays available while in use.
Clients reuse the measured size of an unchanged snapshot when leaving a
conversation.
- Header-only updates preserve the timeline rows. Unchanged controls and
heartbeats still run validation and connection diagnostics while
avoiding redundant view updates.

## Verification

- Chromium on Linux, 2,160 items and 19 subagents. Opening the thread
issued 0 older-page requests, down from 16 (453,590 response bytes).
Checked scroll restoration, a multi-page turn, a quote, retry after a
failed read and a timeline that fits on screen. Tested wide and narrow
viewports in both themes.
- Android emulator. A layout change after scrolling issued 0 history
reads, down from 16. A gesture fetched one page on the existing stream.
Twelve pairs of unchanged controls and heartbeats produced 0 React
commits, down from 21. Sending a message and resuming from the
background advanced and restored the live checkpoint.
- With 4,608 synthetic items, 32 exits from an unchanged cached thread
required 0 full encodings, down from 32. In a 10,000-item renderer
probe, median header-update processing fell from 3.10 ms to 0.007 ms.
Forty-eight expanded outputs of 512 KiB retained 7.5 MiB of inactive
content, down from 24 MiB.
- Targeted domain, history cache, gRPC replay, continuity, work-window
and mobile synchronization checks passed, along with web, mobile and
domain typechecks and repository lint on the edited files. The
concurrent-deletion test compares a paged-and-resumed client with a
continuously connected client.
- Copy audit (§8) passed. The former idle “Loading earlier work…” label
now reads “Show earlier work” and acts as a button. “Loading earlier
work…” appears during a read and “Retry” after failure. The native
equivalent uses the existing “Show earlier messages” button.
- The Windows Electron and day-long Windows session remain unmeasured.
Native testing used Android. Additional Expo ESLint reported
pre-existing hook findings.

Fixes: #300
Fixes: #302
Fixes: #541
Fixes: #556
Fixes: #672
Fixes: #687
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant