fix(app): add non-creating child-store peek for sidebar timestamps (closes #475)#552
Conversation
Astro-Han
left a comment
There was a problem hiding this comment.
Opus second-pass review (product layer / three questions / sidebar timestamp path)
Conclusion: approve
Diff matches the brief shape; both call sites are switched; tests lock the contract.
Three questions
Could this be even less? peekExisting is 5 lines of implementation, the type alias is a 1-liner extracted from the previously inline tuple shape, plus 2 child-store tests and 1 source-level layout invariant. Skipping the type alias would force [Store<State>, SetStoreFunction<State>] to be repeated inline; not worth the saving. Check.
Is what remains good enough?
peekExistingdoes exactlyvalidateChildStoreDirectory + return children[directory]— no ensure, no pin, no bootstrap, no mark, no eviction.- Both
messagesForSessionandpartsForMessageswitched; the per-calltuple?.[0].message[session.id]keeps the existing fallback contract intact. - Source-level invariant test locks
layout.tsxagainst drifting back toglobalSync.child(session.directory, { bootstrap: false, pin: false }). - Check.
Is it reassuring? Sidebar timestamp user path traced:
- First boot, no cache yet:
peekExisting(dir)returnsundefined→tuple?.[0]...short-circuits toundefined→buildPawworkSidebarSessionRowsfalls back tosession.time.created(covered by existing row-builder tests at line 138-143 in the same test file). - After directory has been visited:
peekExisting(dir)returns the existing tuple → cache hit, identical to the oldchild(dir, { bootstrap: false, pin: false })behavior except we no longer materialize vcs/meta/icon caches on the side. - Disk persistence layer untouched; no new I/O introduced.
- Check.
Findings
No P0/P1/P2.
P3 note (not blocking): child() and peek() are now indistinguishable in semantics (both ensure + optional bootstrap; only child pins). That equivalence pre-dates this PR and is out of scope, but worth a follow-up issue if the team wants the manager surface to be smaller.
Approve
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR adds a non-creating child-store peek accessor ( ChangesNon-creating Child Store Accessor
🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
GPT-X engineering final reviewResult: pass. I found no P0/P1/P2 issues. Engineering checks
Binary checkv1 would not crash without this PR, but the previous sidebar timestamp path could still materialize per-directory child stores and persisted caches during row building. This is a focused memory/lifecycle cleanup at the correct layer: cache-only reads get a cache-only accessor, while normal create/bootstrap/pin callers keep their existing APIs. Notes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a peekExisting method to the globalSync context and childStoreManager, allowing for the retrieval of existing child stores without triggering new store creation or side effects. The Layout component was updated to utilize this method for session data lookups, and new tests were added to ensure correct behavior and prevent regressions. I have no feedback to provide.
Summary
peekExisting(directory)as a cache-only child-store accessor.peekExistingso missing directory caches are not materialized during sidebar row building.Why
Sidebar timestamp reads only need cached messages and parts when a child store already exists. Calling
globalSync.child(..., { bootstrap: false, pin: false })still creates a child store and its persisted vcs/project/icon caches just to discover absence.Related Issue
Closes #475.
Human Review Status
Pending. A human should make the final merge decision after reviewing the final diff and verification evidence.
Review Focus
peekExistingmust stay read-only: validate the directory, then returnchildren[directory]without callingensureChild, pinning, bootstrapping, marking, or evicting.child()andpeek()semantics should remain unchanged.messagesForSessionandpartsForMessageshould both use the non-creating accessor.peekExisting semantics
peekExisting(directory)returns the existingChildStoreTupleif present inchildren, otherwiseundefined. It does not callensureChild, does not pin for the current owner, does not bootstrap loading, and does not run eviction. It is intentionally a non-reactive read: if the child store does not yet exist,peekExistingdoes not subscribe to its eventual creation. Sidebar timestamp reads use this to avoid materializing per-directory caches just to discover absence.If a future caller needs absent-to-present reactivity, that is a separate reactive-registry design and out of scope for this PR.
Risk Notes
Low. The new accessor is only used by sidebar timestamp cache reads. Missing caches now return
undefined, which preserves the existing row-builder fallback to session creation time. Existingchild()andpeek()callers keep their current ensure/create behavior.How To Verify
Screenshots or Recordings
Not applicable. This is a cache access behavior change with no intended visible UI change.
Checklist
dev, and my PR title and commit messages use Conventional Commits in EnglishSummary by CodeRabbit
New Features
Improvements