Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: keep status-less goals on the Character sheet instead of faking an empty state (#2675)

[._.]/ Adam Eivy4b5716843e77
diff --git a/PLAN.md b/PLAN.md
index ee770f16ea..12de2a6106 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -189,6 +189,10 @@ by `/do:replan --issues`:
- [ ] **Give Goals a routed per-goal detail so the Character sheet's goal rows can deep-link to the goal itself.** `client/src/components/character/GoalsCard.jsx` links every row to `/goals/list` (`GOALS_PATH`) rather than to the specific goal, because no routed per-goal detail exists to link to: `App.jsx:256-257` registers only `/goals` → `/goals/tree` and `/goals/:tab`, and `client/src/components/goals/GoalsListView.jsx:193` holds the opened goal in a local `const [selectedGoal, setSelectedGoal] = useState(null)` that feeds `GoalDetailPanel` (:487-490) — so "which goal is open" is invisible to the URL. This violates the repo's ID-based-deep-linking convention on its own terms (the selection is not shareable, bookmarkable, reload-safe, or reachable from ⌘K/voice), independent of the Character sheet. Fix shape: route the selection through the URL (a `:goalId` route param, or at minimum a `?goal=<id>` search param honored by `GoalsListView` on mount, with a not-found fallback for a stale/deleted id and a `navigate()` back to the index on delete/clear), then point `GOALS_PATH`'s per-row link at the id'd route and assert the href in `GoalsCard.test.jsx`. Deferred from #2675 because that slice is scoped to a read-only mirror on the Character surface — converting the goals list's selection model is the goals feature's own change, wants its own tests, and #2677 (the Character reframe) must not be blocked behind it.
+- [ ] **Re-derive (or clock-adjust) `longevity.timeHorizons` on read, so goal urgency stops decaying silently.** `computeGoalUrgency` (`server/services/identity/goals.js:65-81`) ranks off `timeHorizons.yearsRemaining`, but `getGoalsTree()` (:345) reads the *persisted* horizons via `loadJSON(LONGEVITY_FILE, …)` — and only `deriveLongevity()` (`server/services/identity/longevity.js:22`) ever consults the current date. So `yearsRemaining` is frozen as of the last derive (`setBirthDate`, or an explicit `/longevity/derive`), and every urgency in the app drifts further from the truth the longer that goes unrun — silently, since nothing surfaces when the horizons were last computed. Affects every consumer that ranks or gates on urgency (`getGoalsTree`, `jobGates.js:57`, `goalCheckIn.js:44`, `identity/insights.js`, `telegram.js`, and the Character sheet's Life Goals card), so all of them are consistently stale rather than any one being wrong. Fix shape: either recompute horizons from `birthDate` + today inside `getGoalsTree`/`getLongevity` (cheap — it's arithmetic, not I/O) rather than trusting the stored snapshot, or stamp `derivedAt` and re-derive lazily when it's older than a day. Deferred from #2675: the Character card is a read-only mirror of the goals service and deliberately ranks off the exact source `/goals` uses, so it must not re-derive longevity on its own (that would write on a read path and make the sheet disagree with the page it links to) — this is the goals/longevity feature's own fix, and it wants its own tests.
+
+- [ ] **Decide one active-goal predicate and apply it everywhere.** The codebase disagrees on whether a goal with no `status` is active. `server/services/voice/tools/goals.js:26,49` and `client/src/components/character/GoalsCard.jsx` (`isActive`) treat a missing status as active; `jobGates.js:57`, `telegram.js:475,517,588`, `goalCheckIn.js:44`, `identity/insights.js:104,127`, `identity/status.js:89`, and `goals.js:224` / `getGoalsTree`'s own enrichment (:352) all use a strict `status === 'active'` and silently skip it. The shape is reachable: MortalLoom-synced goals are normalized only through `normalizeGoal` (`server/services/identity/store.js:23`), whose `PORTOS_GOAL_DEFAULTS` backfills every field **except** `status`. Consequence today: a MortalLoom user with status-less goals gets them ranked by the voice tool and the Character card, but skipped by check-in scheduling, Telegram digests, insights, and — notably — `getGoalsTree`'s urgency enrichment, so those goals reach the UI un-ranked. Fix shape: either add `status: 'active'` to `PORTOS_GOAL_DEFAULTS` (normalizes at the boundary, one line, makes every strict consumer correct at once — preferred) or export a shared `isActiveGoal(goal)` predicate and route all ten call sites through it. Deferred from #2675 because backfilling the default touches the MortalLoom sync boundary shared with the goals/identity services and deserves its own PR + tests; the card defends itself locally in the meantime.
+
### CoS stat-card follow-ups
- [ ] **Retire or wire up `StatCard`'s never-passed `activeLabel` prop, and de-dup the two hand-rolled Learning cards.** `activeLabel` (`client/src/components/cos/StatCard.jsx:1`) has **zero callers** across the client — no `activeLabel=` usage and no spread props into `<StatCard>`. It is *visually* rendered only by the default variant (:59-63); the `compact` (:4-22) and `mini` (:24-42) variants honor it only through the `ariaLabel` interpolation at :2 (consumed via `aria-label` at :8 / :28) — i.e. it reaches the accessible name but is never displayed. So it is not fully inert: deleting it changes the accname on two variants. Either delete the prop + its render branch + the `ariaLabel` clause together, or make compact/mini render it. Related: the two Learning cards (`client/src/pages/ChiefOfStaff.jsx` ~512-540 compact, ~836-862 ascii `mini`) are hand-rolled buttons rather than `StatCard`s precisely because StatCard supports neither `onClick` nor a status-driven border color nor a visible sub-label on the compact variant — and each duplicates the same `status === 'critical' ? … : 'warning' ? …` color ternary twice (once for the border, once for the icon). Wiring a visible sub-label slot through all variants plus `onClick`/border-tone props would let both collapse onto StatCard. Deferred from the mobile-overflow fix (which only restructured the compact card's value/label stacking): removing or re-speccing a prop on a shared component used by every CoS stat card is a distinct refactor deserving its own PR + tests, and the overflow fix must not ride on it.
diff --git a/client/src/components/character/GoalsCard.jsx b/client/src/components/character/GoalsCard.jsx
index 09f1df4b91..eae84dbf45 100644
--- a/client/src/components/character/GoalsCard.jsx
+++ b/client/src/components/character/GoalsCard.jsx
@@ -28,9 +28,18 @@ const TOP_N = 4;
// is stable. Real urgencies are clamped to [0,1] server-side, so -1 can never collide.
const urgencyRank = (urgency) => (Number.isFinite(urgency) ? urgency : -1);
+// A missing `status` counts as active, matching server/services/voice/tools/goals.js. Goals
+// synced in from MortalLoom are only run through `normalizeGoal` (server/services/identity/
+// store.js), whose PORTOS_GOAL_DEFAULTS backfills every field EXCEPT status — so a
+// status-less goal is a real, reachable shape, and dropping it here would render a
+// user's populated goal list as "No active goals yet". Erring toward showing a goal is the
+// safe direction: the cost is at worst one stale row, versus a card that lies about the
+// user having no goals at all.
+const isActive = (goal) => Boolean(goal) && (goal.status === 'active' || !goal.status);
+
export function selectTopGoals(goals, limit = TOP_N) {
return goals
- .filter((goal) => goal?.status === 'active')
+ .filter(isActive)
.sort((a, b) => urgencyRank(b.urgency) - urgencyRank(a.urgency))
.slice(0, limit);
}
@@ -76,11 +85,16 @@ export default function GoalsCard() {
useEffect(() => {
let cancelled = false;
// The TREE endpoint, not the flat one: `urgency` is only *persisted* when a goal is
- // written or a birth date is set, and it decays from `timeHorizons.yearsRemaining` — so
- // the stored value drifts stale with the mere passage of time, and `getGoals()` hands it
- // back unrecomputed. `getGoalsTree().flat` re-derives urgency from current longevity, and
- // is the exact source /goals ranks by, so the sheet can never disagree with the page it
- // links to. (Enriching the flat endpoint instead would change a shared API's semantics.)
+ // written or a birth date is set, so `getGoals()` hands back whatever was last stored.
+ // `getGoalsTree().flat` re-derives urgency from the longevity horizons the goals feature
+ // maintains, and is the exact source /goals ranks by — so the sheet can never disagree
+ // with the page it links to. (Enriching the flat endpoint instead would change a shared
+ // API's semantics.)
+ //
+ // Those horizons are themselves only as fresh as the last deriveLongevity() run — every
+ // consumer shares that, and re-deriving from this read-only card would both write on a
+ // read path and make the sheet disagree with /goals. Tracked in PLAN.md as the goals
+ // feature's own fix.
//
// silent: this card owns its own error UI (the message below), so letting request() toast
// as well would surface the same failure twice.
diff --git a/client/src/components/character/GoalsCard.test.jsx b/client/src/components/character/GoalsCard.test.jsx
index b604be3a03..b3968e7f81 100644
--- a/client/src/components/character/GoalsCard.test.jsx
+++ b/client/src/components/character/GoalsCard.test.jsx
@@ -58,6 +58,19 @@ describe('selectTopGoals', () => {
expect(picked.map(g => g.id)).toEqual(['a']);
});
+ it('keeps a status-less goal rather than dropping it', () => {
+ // MortalLoom-synced goals pass through normalizeGoal, whose defaults backfill every field
+ // EXCEPT status. Dropping them would render a populated goal list as "No active goals
+ // yet" — the exact lie the empty state must never tell.
+ const picked = selectTopGoals([goal({ id: 'ml', status: undefined })]);
+ expect(picked.map(g => g.id)).toEqual(['ml']);
+ });
+
+ it('ignores null entries without dropping the rest of the list', () => {
+ const picked = selectTopGoals([null, goal({ id: 'a' })]);
+ expect(picked.map(g => g.id)).toEqual(['a']);
+ });
+
it('sorts un-ranked goals last rather than treating null urgency as 0', () => {
// urgency is null when the service has no horizon to rank against — that is "we don't
// know", not "plenty of time". A null must never outrank a real 0.
@@ -170,6 +183,14 @@ describe('GoalsCard — empty', () => {
expect(card.queryByRole('link', { name: /Open in Goals/ })).not.toBeInTheDocument();
});
+ it('does NOT show the empty state for a MortalLoom-shaped goal with no status', async () => {
+ // The false-empty regression, pinned at the rendered level: a user whose goals sync in
+ // without a status field must still see them on the sheet.
+ const card = await renderCard([goal({ title: 'Example Synced Goal', status: undefined })]);
+ expect(card.getByText('Example Synced Goal')).toBeInTheDocument();
+ expect(card.queryByText('No active goals yet.')).not.toBeInTheDocument();
+ });
+
it('shows the empty state when every goal is completed or abandoned', async () => {
// Goals exist, but none are active — the card is about what you're working toward now.
const card = await renderCard([