Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(verse): measure a level gain that lands before the first progression read

rubenluetke10-beep9c2ff1c37495
diff --git a/jarvis/ui/web/frontend/src/components/society/progression/LevelHud.tsx b/jarvis/ui/web/frontend/src/components/society/progression/LevelHud.tsx
index c99edf0ba9..acbbed9f79 100644
--- a/jarvis/ui/web/frontend/src/components/society/progression/LevelHud.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/progression/LevelHud.tsx
@@ -60,7 +60,7 @@ export function LevelRing({ kind, level, fraction, size = 44 }: { kind: SubjectK
const r = 20, c = 2 * Math.PI * r;
return (
<span className="level-ring" style={{ width: size, height: size }} data-kind={kind} data-tier={RANK_INFO[rank].tier}>
- <svg viewBox="0 0 48 48" width={size} height={size} aria-hidden>
+ <svg className="level-ring-gauge" viewBox="0 0 48 48" width={size} height={size} aria-hidden>
<circle cx="24" cy="24" r={r} className="level-ring-track" />
<circle cx="24" cy="24" r={r} className="level-ring-fill" strokeDasharray={`${c * fraction} ${c}`} transform="rotate(-90 24 24)" />
<circle cx="24" cy="24" r="16.5" className="level-ring-medal" />
diff --git a/jarvis/ui/web/frontend/src/components/society/progression/progression.css b/jarvis/ui/web/frontend/src/components/society/progression/progression.css
index c1d24f78c8..d98cbdee3c 100644
--- a/jarvis/ui/web/frontend/src/components/society/progression/progression.css
+++ b/jarvis/ui/web/frontend/src/components/society/progression/progression.css
@@ -20,7 +20,7 @@
/* ---------- ring and bar ---------- */
.level-ring { position:relative; display:inline-flex; flex:none; align-items:center; justify-content:center; }
-.level-ring svg { position:absolute; inset:0; }
+.level-ring-gauge { position:absolute; inset:0; }
.level-ring-track { fill:none; stroke:hsl(var(--border)); stroke-width:3; }
.level-ring-fill { fill:none; stroke-width:3; stroke-linecap:round; stroke:#d9ab47; transition:stroke-dasharray .7s cubic-bezier(.2,.8,.2,1); }
.level-ring[data-kind="pet"] .level-ring-fill { stroke:#2dd4bf; }
diff --git a/jarvis/ui/web/frontend/src/components/society/progression/progression.test.ts b/jarvis/ui/web/frontend/src/components/society/progression/progression.test.ts
index a49eb78f48..4f22337d0c 100644
--- a/jarvis/ui/web/frontend/src/components/society/progression/progression.test.ts
+++ b/jarvis/ui/web/frontend/src/components/society/progression/progression.test.ts
@@ -114,6 +114,16 @@ describe("progressionStore", () => {
expect(useProgression.getState().subjects.person.xp).toBe(50);
});
+ it("measures a push that arrived before the first read once the curve is there", () => {
+ useProgression.setState({ snapshot: null, subjects: {} });
+ // No curve yet: the level is known, the distance to the next one is not.
+ useProgression.getState().apply({ seq: 6, subjectId: "person", kind: "person", source: "daily_visit", xp: 25, totalXp: 130, level: 3, previousLevel: 3, title: "private_second_class", unlocked: [] }, 0);
+ expect(useProgression.getState().subjects.person.xpForNext).toBe(0);
+ // The read is older than the push (105 XP), so the push stays — measured on the curve now.
+ useProgression.getState().hydrate(snapshot({ subjects: [{ subjectId: "person", kind: "person", xp: 105, level: 3, xpIntoLevel: 0, xpForNext: 90, title: "private_second_class" }] }), []);
+ expect(useProgression.getState().subjects.person).toMatchObject({ xp: 130, xpIntoLevel: 25, xpForNext: 90 });
+ });
+
it("ignores a late duplicate push", () => {
const award = { seq: 4, subjectId: "person", kind: "person" as const, source: "chat_turn", xp: 5, totalXp: 5, level: 1, previousLevel: 1, title: "newcomer", unlocked: [] };
useProgression.getState().apply(award, 1000);
diff --git a/jarvis/ui/web/frontend/src/components/society/progression/progressionStore.ts b/jarvis/ui/web/frontend/src/components/society/progression/progressionStore.ts
index 58fc80b5c5..a3e4846fb4 100644
--- a/jarvis/ui/web/frontend/src/components/society/progression/progressionStore.ts
+++ b/jarvis/ui/web/frontend/src/components/society/progression/progressionStore.ts
@@ -104,6 +104,12 @@ export const useProgression = create<ProgressionState>((set, get) => ({
const known = subjects[row.subjectId];
if (!known || known.xp <= row.xp) subjects[row.subjectId] = row;
}
+ // A push applied before the first read had no curve to measure the level by: measure it now.
+ for (const [id, subject] of Object.entries(subjects)) {
+ const atCap = subject.level >= snapshot.maxLevel;
+ const { into, size } = progressFor(snapshot.levelXp, subject.xp, subject.level);
+ if (!atCap && subject.xpForNext <= 0) subjects[id] = { ...subject, xpIntoLevel: into, xpForNext: size };
+ }
const banners = [...s.banners, ...away.filter((c) => c.kind !== "agent")];
const toasts = [...s.toasts, ...away.filter((c) => c.kind === "agent")].slice(-MAX_TOASTS);
return { snapshot, subjects, petId: snapshot.petId, banners, toasts };