Skip to content

[Task] Add non-creating child-store cache peek for sidebar timestamp reads #475

@Astro-Han

Description

@Astro-Han

Goal

Add a read-only global-sync accessor for cache-only call sites that need to inspect an existing child store without creating, bootstrapping, or pinning a directory store.

The immediate motivating case is PR #471: sidebar timestamp calculation can safely read already-loaded message cache, but it should not need to expand child-store lifecycle just to discover that a directory cache is absent.

Scope

In scope:

  • Investigate current globalSync.child(...), children.child(...), and children.peek(...) semantics.
  • Add a clearly named accessor for "existing child store only" if the investigation confirms cache-only callers need it.
  • The accessor should return undefined or an equivalent safe empty result when the child store does not already exist.
  • It must not call ensureChild(...) for missing directories.
  • It must not bootstrap network/project loading.
  • It must not pin the store to the current owner.
  • Update sidebar timestamp cache reads to use the accessor if it exists and keeps fix(app): use last user message time in sidebar #471's fallback semantics.
  • Add focused tests proving missing directories are not created and existing message caches can still be read.

Out of scope:

  • Do not change session list ordering or pagination. That is tracked in [Feature] Sort initial sidebar sessions by last user message time #473.
  • Do not change persistence schema, backend APIs, desktop shell behavior, or message cache storage.
  • Do not replace all globalSync.child call sites mechanically. Audit each cache-only caller separately.
  • Do not weaken existing child() behavior for normal callers that intentionally create/bootstrap/pin stores.

Relevant files or context

Relevant files:

  • packages/app/src/context/global-sync/child-store.ts
  • packages/app/src/context/global-sync/types.ts
  • packages/app/src/context/global-sync.tsx
  • packages/app/src/context/sync.tsx
  • packages/app/src/pages/layout.tsx
  • packages/app/src/pages/layout/pawwork-session-source.ts

Related:

Verification

  • Add or update unit tests for child-store manager behavior showing the new accessor does not create a missing child store.
  • Add or update a layout/sidebar timestamp test showing missing cache still falls back to session.time.created.
  • Run bun --cwd packages/app test --preload ./happydom.ts with the targeted test files.
  • Run bun --cwd packages/app typecheck.
  • Run git diff --check.

Execution mode

Agent should investigate and propose a plan first

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low priorityappApplication behavior and product flowstaskNarrow execution, audit, spike, migration, tracking, or upstream follow-up work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions