Refactor context/global-sync.tsx into domain modules while preserving behavior.
packages/app/src/context/global-sync.tsx is a large multi-domain module (1,000+ LOC) that currently owns queue scheduling, bootstrap, child store creation, persistence bridges, session trimming, and event reduction. This workstream splits it into clear domains without changing runtime behavior.
useGlobalSync() public API unchanged.This workstream owns:
packages/app/src/context/global-sync.tsxpackages/app/src/context/global-sync/**This workstream must not edit:
packages/app/src/context/file.tsx (spec 13)packages/app/src/components/prompt-input.tsx (spec 11)packages/app/src/pages/session.tsx and packages/app/src/pages/layout.tsx (specs 09/10)Create packages/app/src/context/global-sync/ modules like:
types.ts - shared types.queue.ts - refresh queue and drain scheduler.child-store.ts - child store creation, persistence wiring, cache maps.session-trim.ts - pure session sorting/trimming helpers.bootstrap.ts - global and per-directory bootstrap flows.event-reducer.ts - event handlers for SDK event stream.Keep global-sync.tsx as provider/composition entry point.
cmp, session trim/recent logic) first.useGlobalSync() remains backward compatible.global-sync.tsx is substantially reduced (target: under 500 LOC).bun run typecheck (from packages/app).e2e/app/session.spec.tse2e/sidebar/sidebar-session-links.spec.tse2e/projects/projects-switch.spec.ts