Cache conversation sidebar metadata by head commit - #170
Open
nishu-builder wants to merge 1 commit into
Open
Conversation
Every sidebar listing walked every conversation's event history from its head all the way to the root — remote_conversation_metadata needs the newest user activity and the durable parent, and both lived at the far end of the chain. That is O(events) commit reads per conversation per listing, each one a server round trip when the commit is not yet local; the tui pays it at startup for the whole sidebar and again on every 500ms remote poll, and a fresh process (the tui launches one per run) started from nothing. The answer for a head is pure content: a commit fixes its first-parent chain, so its metadata can never go stale. Cache it per head — a process-wide memo plus one sidecar file per git dir, loaded once and appended as heads are summarized (compacted to the newest entries when it grows past a bound). A walk now stops at any previously summarized head and combines: the newest user activity is whichever comes first from the tip, and the parent lives on the root either way, so a listing reads only the events that landed since the last one — across process restarts too — and a fork stops at its source conversation's summarized spine the same way. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AZgAh1BJk17ge3SasEaCJJ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack 2/2, on top of #169 — merge that first, then retarget this to
main(or let GitHub retarget it automatically when #169's branch is deleted on merge). The diff shown against the stack base is exactly this PR's one commit.Problem
Every sidebar listing walked every conversation's event history from its head all the way to the root —
remote_conversation_metadataneeds the newest user activity and the durable parent, and both live at the far end of the chain. That is O(events) commit reads per conversation per listing, each one a server round trip when the commit is not yet local; the tui pays it at startup for the whole sidebar and again on every 500ms remote poll, and a fresh process (the tui launches one per run) started from nothing.Change
The answer for a head is pure content: a commit fixes its first-parent chain, so its metadata can never go stale. Cache it per head:
.git/caos-conversation-metadata), loaded once per process and appended as heads are summarized; compacted to the newest 2048 entries when it grows past 8192 lines. Torn or hand-edited lines are skipped, never an error — a cache read must only ever cost the rewalk it failed to save.GitTransportgains agit_dir()accessor for the sidecar path (per-checkout: linked worktrees keep their own, a deleted checkout takes its cache with it).Validation
caos(32),caos-clilib (51) and tui bin (138) suites green, including four new tests: cache-line round-trip + junk skipping; an advanced head that provably reuses the cached boundary (the old commit's loose object is deleted first, so a rewalk would fail loudly); sidecar entries serving a fresh repo with no objects at all; compaction of an oversized sidecar.cargo check --workspace,cargo fmt --checkclean; clippy shows only a pre-existing warning in untouched code.nix buildand the saltedrun-tool testgate.🤖 Generated with Claude Code
https://claude.ai/code/session_01AZgAh1BJk17ge3SasEaCJJ
Generated by Claude Code