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

docs: correct the GoalsCard test pointer and the urgency-null precondition (#2675)

[._.]/ Adam Eivy39bbe54ddbfe
diff --git a/client/src/components/character/GoalsCard.jsx b/client/src/components/character/GoalsCard.jsx
index c82073ab28..8f304d6b69 100644
--- a/client/src/components/character/GoalsCard.jsx
+++ b/client/src/components/character/GoalsCard.jsx
@@ -20,11 +20,12 @@ export const GOALS_PATH = '/goals/list';
const TOP_N = 4;
-// `urgency` is null until the user sets a birth date — the horizon math has no denominator
-// without one. That is NOT the same as urgency 0 ("plenty of time"), so nulls sort last
-// instead of being coerced to a number they don't have: a user with no birth date still gets
-// their goals listed in service order rather than a bogus ranking. Ties keep the service's
-// order because Array#sort is stable.
+// `urgency` is null whenever the goals service has nothing to rank against — no birth date
+// (the horizon math has no denominator without one), or a goal carrying no horizon. That is
+// NOT the same as urgency 0 ("plenty of time"), so nulls sort last instead of being coerced
+// to a number they don't have: a user with no birth date still gets their goals listed in
+// service order rather than a bogus ranking. Ties keep the service's order because Array#sort
+// is stable. Real urgencies are clamped to [0,1] server-side, so -1 can never collide.
const urgencyRank = (urgency) => (Number.isFinite(urgency) ? urgency : -1);
export function selectTopGoals(goals, limit = TOP_N) {
diff --git a/client/src/components/character/GoalsCard.test.jsx b/client/src/components/character/GoalsCard.test.jsx
index 842fe13d0a..a75cfd6a9d 100644
--- a/client/src/components/character/GoalsCard.test.jsx
+++ b/client/src/components/character/GoalsCard.test.jsx
@@ -59,8 +59,8 @@ describe('selectTopGoals', () => {
});
it('sorts un-ranked goals last rather than treating null urgency as 0', () => {
- // urgency is null until a birth date is set — that is "we don't know", not "plenty of
- // time". A null must never outrank a real 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.
const picked = selectTopGoals([
goal({ id: 'unranked', urgency: null }),
goal({ id: 'relaxed', urgency: 0 }),
diff --git a/client/src/pages/CharacterSheet.metrics.test.jsx b/client/src/pages/CharacterSheet.metrics.test.jsx
index b812088c79..98961c64fe 100644
--- a/client/src/pages/CharacterSheet.metrics.test.jsx
+++ b/client/src/pages/CharacterSheet.metrics.test.jsx
@@ -13,7 +13,8 @@ vi.mock('../services/api', () => ({
default: { get: (...a) => get(...a), post: vi.fn(), put: vi.fn() },
generateAvatar: vi.fn(() => Promise.resolve({})),
// The sheet's GoalsCard fetches goals itself (#2675); stubbed empty so this suite stays
- // scoped to the metrics grid. GoalsCard's own states are covered in CharacterSheet.goals.test.jsx.
+ // scoped to the metrics grid. GoalsCard's own states are covered next to it, in
+ // components/character/GoalsCard.test.jsx.
getGoals: vi.fn(() => Promise.resolve({ goals: [] })),
}));