Refactor context/file.tsx into focused modules with unchanged API.
packages/app/src/context/file.tsx still combines path normalization, file-content caching/eviction, file-tree loading, watcher event handling, and file-view persistence orchestration. Recent refactoring extracted generic scoped-cache primitives to packages/app/src/utils/scoped-cache.ts, but most file-domain behavior remains in one module. This spec separates those concerns while preserving the existing useFile() interface.
useFile() API stable for all callers.components/file-tree.tsx in this workstream.This workstream owns:
packages/app/src/context/file.tsxpackages/app/src/context/file/**packages/app/src/utils/scoped-cache.ts (only when required for file-view cache extraction)This workstream must not edit:
packages/app/src/context/global-sync.tsx (spec 12)packages/app/src/pages/session.tsx (spec 09)packages/app/src/components/prompt-input.tsx (spec 11)packages/app/src/utils/scoped-cache.ts now exists as a shared cache primitive used by file view persistence.Create packages/app/src/context/file/ modules such as:
path.ts - normalize/strip helpers.content-cache.ts - content LRU + byte caps.view-cache.ts - per-session file view persistence cache (building on createScopedCache).tree-store.ts - directory/node store and list/expand/collapse actions.watcher.ts - watcher event handling and invalidation routines.file.tsx remains the provider entry that composes these modules.
createScopedCache.useFile() return shape unchanged.useFile() API remains backward compatible.context/file.tsx is reduced significantly (target: under 350 LOC).bun run typecheck (from packages/app).e2e/files/file-tree.spec.tse2e/files/file-viewer.spec.tse2e/files/file-open.spec.ts