[codex] Extract sun session store#458
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR extracts shared session constants and safety model into
Confidence Score: 5/5Clean refactoring — no public API is removed or altered, and the new dedup logic for concurrent rehydration is correct and covered by new tests. All previously-public symbols remain re-exported from sun.js with preserved object identity. The _runHydrateSession helper correctly gates concurrent rehydrateStaleSessions calls on the same session-id promise, and the new test in section 12 verifies exactly one fetchAtmosphere call fires per stale session under concurrency. The service-worker and phase-2 correctness test are kept in sync. No logic was changed — only moved. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
sunjs["sun.js\n(public facade)"]
model["sun-session-model.js\nEXPOSURE_PRESETS\nPOSTURE_MULTIPLIERS\nSURFACE_ALBEDO\nPHOTOSENSITIVE_MED_TIERS\nphotosensitiveMedScale\n_normalizePSMTier"]
store["sun-sessions-store.js\ngetSessions / getActiveSession\nstartSession / stopSession\nlogCompletedSession / deleteSession\npause / resume / updateSession\nhydrateSession\nrehydrateStaleSessions\n_applyAtmOverrides"]
active["sun-active-session.js\n(live ticker + UI)"]
ui["sun-session-ui.js\n(saved session rows + edit UI)"]
consumers["sun-ai-analysis.js\nsun-correlations.js\nlight-devices.js\nlight-today-ai.js\n…"]
model -->|"imports constants"| store
model -->|"imports constants"| active
model -->|"re-exports"| sunjs
store -->|"re-exports"| sunjs
active -->|"re-exports quickLog / modal helpers"| sunjs
ui -->|"re-exports session row / detail"| sunjs
sunjs -->|"import getSessions\nchannelTier, formatChannelUnit…"| consumers
store -->|"storeDeps injected by"| sunjs
active -->|"activeDeps injected by"| sunjs
Reviews (2): Last reviewed commit: "Deduplicate sun session rehydration" | Re-trigger Greptile |
What changed
sun-session-model.js.sun-sessions-store.js.sun.jsas the public facade for existing imports/window bindings, with injected hooks for live active-session state.version.jsto1.8.286.Why
sun.jshad accumulated storage, hydration, constants, UI facade, and aggregate logic in one large module. This separates the sensitive persisted session lifecycle from active UI/modal code while preserving the existing public API.Validation
node --check js/sun.jsnode --check js/sun-session-model.jsnode --check js/sun-sessions-store.jsnode --check js/sun-active-session.jsnode --check tests/test-sun.jsnode --check tests/test-correctness-phase2.jsnode tests/test-sun.jsnode tests/test-correctness-phase2.jsnode tests/test-sun-context.jsnode tests/test-sun-ai-analysis.jsnode tests/test-light-devices.js./run-tests.sh