fix(telos): crash guards for one-mission users in Life Dashboard
Problem
Any user with fewer than 2 missions defined gets an immediate TypeError on the Telos page:
TypeError: Cannot read properties of undefined (reading 'horizon')
Three spots used missions[1] as a fallback:
sections.tsxline 89 — fallback mission for renderinghorizon.tsxline 15 — sameapp.tsx— initial mission state hardcoded to"M1"; when live data loads with onlyM0, no valid mission is selected
Fix
sections.tsx + horizon.tsx: missions[1] → missions[0] + explicit null guard so the component can return null cleanly if no missions exist at all.
app.tsx: initial state "M1" → "M0"; added useEffect to reset to the first available mission ID when live data arrives with different IDs than the initial state assumed.
How This Fits With the Other Telos PRs
Three open PRs each fix a different layer of the telos stack — all complementary, no conflicts:
| PR | Layer | Files |
|---|---|---|
| #1127 (jmmarkiewicz) | CLI summary generator | GenerateTelosSummary.ts — regex, strategy bullets, goal section classifier |
| #1147 (Alessandro-Improta) | Live data pipeline | observability.ts parser robustness + use-telos-data.ts fetch wired to /api/telos/overview |
| #1154 (this PR) | Crash prevention | sections.tsx, horizon.tsx, app.tsx — guards for < 2 missions |
Recommended merge order: #1127 (standalone) → #1147 (data plumbing) → #1154 (crash guards surface once data flows).
Revision Note
Originally this PR also introduced a new /telos endpoint in pulse.ts + modules/telos.ts. After reviewing #1147, that approach was dropped — #1147's use of the existing /api/telos/overview endpoint is architecturally correct and avoids a parallel endpoint. This PR is now focused exclusively on crash prevention.