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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(office): jump with Space, and a sprint jump is faster than a sprint
rubenluetke10-beep3c785b4c5f80
diff --git a/jarvis/ui/web/frontend/src/components/society/office/OfficePlayer.tsx b/jarvis/ui/web/frontend/src/components/society/office/OfficePlayer.tsxindex 0e5fd36914..8c2d2afec1 100644--- a/jarvis/ui/web/frontend/src/components/society/office/OfficePlayer.tsx+++ b/jarvis/ui/web/frontend/src/components/society/office/OfficePlayer.tsx@@ -1,6 +1,7 @@/*** The person's own character: walks with WASD/arrows (camera-relative, Shift- * runs) or by clicking the floor, and interacts with whatever is nearby (E).+ * runs, Space jumps — a sprint jump is faster than a sprint) or by clicking+ * the floor, and interacts with whatever is nearby (E).* Zooming out never requires walking — everything stays clickable from afar.*/import { useEffect, useMemo, useRef } from "react";@@ -19,6 +20,7 @@ import { seatOf, type OfficeLayout } from "./officeLayout";import { chairInReach, useLeadSeat } from "./leadSeat";import { useOfficeDog } from "./dogLife";import { isRunning, useOfficeSettings } from "./officeSettings";+import { jumpSquash, newJump, pressJump, stepJump } from "./officeJump";/** The person's pace: a brisk walk, and a sprint on Shift (m/s). */export const PLAYER_WALK_SPEED = 2.0;@@ -45,10 +47,16 @@ export function ownsKeyboard(target: EventTarget | null): boolean {return tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || !!target.closest("[role='dialog']");}-/** Pressed movement keys, tracked on the window while the office is awake. */-function useMoveKeys(enabled: boolean, onInteract: () => void) {+/** Space on a focused button, tab or switch activates that control, never a jump. */+function activatesControl(target: EventTarget | null): boolean {+ return target instanceof HTMLElement && !!target.closest("button, a[href], [role='button'], [role='tab'], [role='switch'], [role='checkbox']");+}++/** Pressed movement keys (and Space for jumping), tracked on the window while the office is awake. */+function useMoveKeys(enabled: boolean, onInteract: () => void, onJump: () => void) {const pressed = useRef(new Set<string>());const run = useRef(false);+ const jumpHeld = useRef(false);useEffect(() => {if (!enabled) { pressed.current.clear(); return; }const down = (event: KeyboardEvent) => {@@ -56,12 +64,21 @@ function useMoveKeys(enabled: boolean, onInteract: () => void) {run.current = event.shiftKey;if (event.code in MOVE_KEYS) { pressed.current.add(event.code); event.preventDefault(); }else if (event.code === "KeyE" && !event.repeat) { onInteract(); event.preventDefault(); }+ else if (event.code === "Space" && !activatesControl(event.target)) {+ event.preventDefault();+ if (!event.repeat) onJump();+ jumpHeld.current = true;+ }+ };+ const up = (event: KeyboardEvent) => {+ pressed.current.delete(event.code);+ if (event.code === "Space") jumpHeld.current = false;+ run.current = event.shiftKey;};- const up = (event: KeyboardEvent) => { pressed.current.delete(event.code); run.current = event.shiftKey; };// A key held while the window loses focus never sees its keyup; forget// everything then, or the character walks on by itself. (Not on// visibilitychange: the desktop WebView reports visible windows as hidden.)- const release = () => pressed.current.clear();+ const release = () => { pressed.current.clear(); jumpHeld.current = false; };window.addEventListener("keydown", down);window.addEventListener("keyup", up);window.addEventListener("blur", release);@@ -71,8 +88,8 @@ function useMoveKeys(enabled: boolean, onInteract: () => void) {window.removeEventListener("keyup", up);window.removeEventListener("blur", release);};- }, [enabled, onInteract]);- return { pressed, run };+ }, [enabled, onInteract, onJump]);+ return { pressed, run, jumpHeld };}function nearestInteractable(layout: OfficeLayout): Selection | null {@@ -101,7 +118,9 @@ export function OfficePlayer({ layout, grid, look, name, awake, reduced }: {layout: OfficeLayout; grid: NavGrid; look: ToyLook; name: string; awake: boolean; reduced: boolean;}) {const group = useRef<Group>(null);+ const body = useRef<Group>(null);const ring = useRef<Mesh>(null);+ const jump = useMemo(newJump, []);const drive = useRef<FigureDrive>({ mode: "idle", speed: 0 });const camera = useThree((s) => s.camera);const forward = useMemo(() => new Vector3(), []);@@ -116,7 +135,8 @@ export function OfficePlayer({ layout, grid, look, name, awake, reduced }: {const nearby = nearbyRef.current;if (nearby) useOfficeStore.getState().select(nearby);}, []);- const { pressed, run } = useMoveKeys(awake, interact);+ const onJump = useMemo(() => () => pressJump(jump), [jump]);+ const { pressed, run, jumpHeld } = useMoveKeys(awake, interact, onJump);// Arrive by the elevator once per app run; coming back to the map keeps the// character where it was, unless a changed floor plan put that spot in a wall.@@ -150,6 +170,9 @@ export function OfficePlayer({ layout, grid, look, name, awake, reduced }: {player.x = seat.x; player.z = seat.z; player.heading = seat.facing; player.path = []; player.moving = false;drive.current.mode = "sit";drive.current.speed = 0;+ Object.assign(jump, newJump());+ body.current?.position.setY(0);+ body.current?.scale.set(1, 1, 1);group.current?.position.set(player.x, 0, player.z);if (group.current) group.current.rotation.y = player.heading;if (nearbyRef.current) { nearbyRef.current = null; store.setNearby(null); }@@ -172,7 +195,11 @@ export function OfficePlayer({ layout, grid, look, name, awake, reduced }: {// Keyboard movement, relative to where the camera looks.let ix = 0, iz = 0;for (const code of pressed.current) { ix += MOVE_KEYS[code][0]; iz += MOVE_KEYS[code][1]; }- const speed = isRunning(run.current, useOfficeSettings.getState().alwaysRun) ? PLAYER_SPRINT_SPEED : PLAYER_WALK_SPEED;+ const sprinting = isRunning(run.current, useOfficeSettings.getState().alwaysRun);+ const steering = ix !== 0 || iz !== 0 || player.path.length > 0;+ stepJump(jump, dt, jumpHeld.current, sprinting && steering);+ // A sprint jump carries its boost while airborne (eased in and out by stepJump).+ const speed = (sprinting ? PLAYER_SPRINT_SPEED : PLAYER_WALK_SPEED) * jump.speedMul;let moved = 0;if (ix !== 0 || iz !== 0) {player.path = [];@@ -207,6 +234,13 @@ export function OfficePlayer({ layout, grid, look, name, awake, reduced }: {group.current.position.set(player.x, 0, player.z);group.current.rotation.y = player.heading;}+ // The body rides the hop; the gold ring stays on the floor as its shadow.+ if (body.current) {+ body.current.position.y = jump.y;+ const [sw, sh] = reduced ? [1, 1] : jumpSquash(jump);+ body.current.scale.set(sw, sh, sw);+ }+ if (ring.current) ring.current.scale.setScalar(1 - Math.min(0.35, jump.y * 0.6));if (ring.current) (ring.current.material as MeshBasicMaterial).opacity = reduced ? 0.8 : 0.6 + Math.sin(performance.now() / 400) * 0.2;// What can the character reach right now? The lead's chair has its own prompt beside it.const chair = chairInReach(layout.lead.desks, player);@@ -222,13 +256,15 @@ export function OfficePlayer({ layout, grid, look, name, awake, reduced }: {<ringGeometry args={[0.42, 0.52, 40]} /><meshBasicMaterial color="#f5b83d" transparent opacity={0.8} side={DoubleSide} depthWrite={false} /></mesh>- <ToyFigure look={look} drive={drive} paused={!awake} heightM={OFFICE_FIGURE_HEIGHT_M} />- <Html center position={[0, OFFICE_FIGURE_HEIGHT_M + 0.35, 0]} zIndexRange={[25, 0]}>- <span className="office-plate office-plate-player" data-office-ui>- <span className="office-plate-badge" style={{ background: "#f5b83d" }} aria-hidden>★</span>- <span className="office-plate-name">{name}</span>- </span>- </Html>+ <group ref={body}>+ <ToyFigure look={look} drive={drive} paused={!awake} heightM={OFFICE_FIGURE_HEIGHT_M} />+ <Html center position={[0, OFFICE_FIGURE_HEIGHT_M + 0.35, 0]} zIndexRange={[25, 0]}>+ <span className="office-plate office-plate-player" data-office-ui>+ <span className="office-plate-badge" style={{ background: "#f5b83d" }} aria-hidden>★</span>+ <span className="office-plate-name">{name}</span>+ </span>+ </Html>+ </group></group>);}diff --git a/jarvis/ui/web/frontend/src/components/society/office/officeControls.ts b/jarvis/ui/web/frontend/src/components/society/office/officeControls.tsindex 8b2176f7d5..3e8cfa0ea1 100644--- a/jarvis/ui/web/frontend/src/components/society/office/officeControls.ts+++ b/jarvis/ui/web/frontend/src/components/society/office/officeControls.ts@@ -24,6 +24,8 @@ export type MouseGesture = "click" | "double" | "drag" | "right_drag" | "wheel";export const OFFICE_CONTROLS: readonly OfficeControl[] = [{ id: "walk", group: "move", keys: [["W", "A", "S", "D"], ["ArrowUp", "ArrowLeft", "ArrowDown", "ArrowRight"]] },{ id: "run", group: "move", keys: [["Shift"]] },+ { id: "jump", group: "move", keys: [["Space"]] },+ { id: "sprint_jump", group: "move", keys: [["Shift", "+", "Space"]] },{ id: "click_walk", group: "move", keys: [["mouse:click"]] },{ id: "rotate", group: "camera", keys: [["mouse:drag"]] },{ id: "pan", group: "camera", keys: [["mouse:right_drag"], ["Ctrl/⌘", "+", "mouse:drag"]] },diff --git a/jarvis/ui/web/frontend/src/components/society/office/officeJump.test.ts b/jarvis/ui/web/frontend/src/components/society/office/officeJump.test.tsnew file mode 100644index 0000000000..c3b919f24f--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/office/officeJump.test.ts@@ -0,0 +1,92 @@+import { describe, expect, it } from "vitest";+import { JUMP_BUFFER_S, jumpSquash, newJump, pressJump, SPRINT_JUMP_BOOST, stepJump } from "./officeJump";++const DT = 1 / 60;++function hop(running: boolean) {+ const s = newJump();+ pressJump(s);+ let apex = 0, frames = 0, maxMul = 1;+ stepJump(s, DT, false, running);+ while (s.airborne && frames < 600) {+ stepJump(s, DT, false, running);+ apex = Math.max(apex, s.y);+ maxMul = Math.max(maxMul, s.speedMul);+ frames += 1;+ }+ return { s, apex, airS: (frames + 1) * DT, maxMul };+}++describe("office jump", () => {+ it("makes a short hop that lands back on the floor", () => {+ const { s, apex, airS } = hop(false);+ expect(apex).toBeGreaterThan(0.45);+ expect(apex).toBeLessThan(0.65);+ expect(airS).toBeGreaterThan(0.45);+ expect(airS).toBeLessThan(0.6);+ expect(s.y).toBe(0);+ expect(s.airborne).toBe(false);+ });++ it("is smooth: the height never jumps by more than a few centimetres a frame", () => {+ const s = newJump();+ pressJump(s);+ let last = 0;+ for (let i = 0; i < 60; i += 1) {+ stepJump(s, DT, false, false);+ expect(Math.abs(s.y - last)).toBeLessThan(0.08);+ last = s.y;+ }+ });++ it("boosts a sprint jump above sprint speed, easing in rather than snapping", () => {+ const sprint = hop(true);+ expect(sprint.maxMul).toBeGreaterThan(1.2);+ expect(sprint.maxMul).toBeLessThanOrEqual(SPRINT_JUMP_BOOST);+ const s = newJump();+ pressJump(s);+ stepJump(s, DT, false, true);+ expect(s.speedMul).toBeLessThan(1.1);+ });++ it("gives a jump from a walk no extra speed", () => {+ expect(hop(false).maxMul).toBe(1);+ });++ it("drops the boost again after landing", () => {+ const { s } = hop(true);+ for (let i = 0; i < 60; i += 1) stepJump(s, DT, false, true);+ expect(s.speedMul).toBe(1);+ });++ it("keeps a press made just before landing and jumps on touchdown", () => {+ const s = newJump();+ pressJump(s);+ stepJump(s, DT, false, true);+ while (s.vy > 0 || s.y > 0.05) stepJump(s, DT, false, true);+ pressJump(s);+ let again = false;+ for (let t = 0; t < JUMP_BUFFER_S; t += DT) again = stepJump(s, DT, false, true) || again;+ expect(again).toBe(true);+ });++ it("does not jump again in mid-air", () => {+ const s = newJump();+ pressJump(s);+ stepJump(s, DT, false, false);+ const vy = s.vy;+ expect(stepJump(s, DT, true, false)).toBe(false);+ expect(s.vy).toBeLessThan(vy);+ });++ it("squashes and stretches only around take-off and landing", () => {+ const s = newJump();+ expect(jumpSquash(s)).toEqual([1, 1]);+ pressJump(s);+ stepJump(s, 0.08, false, false);+ expect(jumpSquash(s)[1]).toBeGreaterThan(1);+ s.sinceTakeoff = 1;+ s.sinceLanding = 0.09;+ expect(jumpSquash(s)[1]).toBeLessThan(1);+ });+});diff --git a/jarvis/ui/web/frontend/src/components/society/office/officeJump.ts b/jarvis/ui/web/frontend/src/components/society/office/officeJump.tsnew file mode 100644index 0000000000..89e5062d64--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/office/officeJump.ts@@ -0,0 +1,96 @@+/**+ * The person's jump (Space): a short, snappy hop computed per frame, so it is+ * smooth at any frame rate. A jump taken while sprinting carries extra speed+ * for as long as the character is in the air, so hopping along at a sprint is+ * faster than sprinting on the ground. The boost eases in and out instead of+ * snapping, and a press just before landing is kept and fires on touchdown,+ * so chained hops never feel laggy.+ */++/** Take-off speed (m/s) and gravity (m/s²): about a 0.5 m hop, 0.5 s in the air. */+export const JUMP_VELOCITY = 4.2;+export const JUMP_GRAVITY = 16;+/** Ground speed multiplier while airborne on a sprint jump. */+export const SPRINT_JUMP_BOOST = 1.3;+/** How fast the speed multiplier follows its target (1/s); higher is snappier. */+const BOOST_EASE = 9;+/** A press this long before landing still jumps on touchdown (s). */+export const JUMP_BUFFER_S = 0.14;+/** Take-off stretch and landing squash length (s). */+const STRETCH_S = 0.16;+const SQUASH_S = 0.18;++export interface JumpState {+ /** Height of the feet above the floor (m). */+ y: number;+ /** Vertical speed (m/s). */+ vy: number;+ airborne: boolean;+ /** This hop started at a sprint (and keeps its boost while the sprint is held). */+ sprintJump: boolean;+ /** Current ground-speed multiplier, eased toward its target. */+ speedMul: number;+ /** Seconds left in which a buffered press still counts. */+ buffered: number;+ /** Seconds since take-off / since landing (drive the stretch and squash). */+ sinceTakeoff: number;+ sinceLanding: number;+}++export function newJump(): JumpState {+ return { y: 0, vy: 0, airborne: false, sprintJump: false, speedMul: 1, buffered: 0, sinceTakeoff: Infinity, sinceLanding: Infinity };+}++/** Space pressed: jump now if on the floor, else remember the press for a moment. */+export function pressJump(s: JumpState): void {+ s.buffered = JUMP_BUFFER_S;+}++/**+ * Advance one frame. `wantJump` is true while Space is held (holding keeps+ * hopping); `running` whether the character is sprinting and moving right now.+ * Returns true on the frame the character leaves the floor.+ */+export function stepJump(s: JumpState, dt: number, wantJump: boolean, running: boolean): boolean {+ let tookOff = false;+ s.buffered = Math.max(0, s.buffered - dt);+ if (!s.airborne && (s.buffered > 0 || wantJump)) {+ s.airborne = true;+ s.vy = JUMP_VELOCITY;+ s.sprintJump = running;+ s.buffered = 0;+ s.sinceTakeoff = 0;+ tookOff = true;+ }+ if (s.airborne) {+ // Semi-implicit Euler: speed first, then position; exact enough for a hop.+ s.vy -= JUMP_GRAVITY * dt;+ s.y += s.vy * dt;+ if (s.y <= 0) {+ s.y = 0;+ s.vy = 0;+ s.airborne = false;+ s.sinceLanding = 0;+ }+ }+ s.sinceTakeoff += dt;+ s.sinceLanding += dt;+ // The boost holds while airborne on a sprint jump that is still a sprint.+ const target = s.airborne && s.sprintJump && running ? SPRINT_JUMP_BOOST : 1;+ s.speedMul += (target - s.speedMul) * (1 - Math.exp(-BOOST_EASE * dt));+ if (Math.abs(target - s.speedMul) < 1e-3) s.speedMul = target;+ return tookOff;+}++/**+ * The figure's squash-and-stretch as [widthScale, heightScale]: a quick+ * stretch on take-off, a soft squash on landing, 1 in between. Volume stays+ * roughly constant (width shrinks as height grows).+ */+export function jumpSquash(s: JumpState): [number, number] {+ const pulse = (t: number, len: number) => (t < len ? Math.sin((t / len) * Math.PI) : 0);+ const stretch = pulse(s.sinceTakeoff, STRETCH_S) * 0.1;+ const squash = pulse(s.sinceLanding, SQUASH_S) * 0.12;+ const h = 1 + stretch - squash;+ return [1 / Math.sqrt(h), h];+}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json b/jarvis/ui/web/frontend/src/i18n/locales/society/de.jsonindex 92db88a3e6..ddb20e686d 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/de.json@@ -735,7 +735,7 @@"open_agent": "{0} öffnen","overview": "Übersicht","ledger": "Agentenliste",- "help": "WASD laufen · Shift rennt · E benutzen · M Karte · H Hilfe & Einstellungen",+ "help": "WASD laufen · Shift rennt · Leertaste springt · E benutzen · M Karte · H Hilfe & Einstellungen","sample": "Beispiel-Agenten – das Backend ist noch nicht erreichbar.","overflow": "Nur die ersten {0} Agenten haben einen Schreibtisch; die Liste zeigt alle.","open_space": "Open Space",@@ -825,6 +825,8 @@"group_arcade": "Arcade (Pausenraum)","ctl_walk": "Laufen","ctl_run": "Rennen, solange gedrückt",+ "ctl_jump": "Springen; halten, um weiterzuhüpfen",+ "ctl_sprint_jump": "Sprint-Sprung: schneller als nur sprinten","ctl_click_walk": "Boden anklicken, um hinzugehen","ctl_rotate": "Ansicht drehen","ctl_pan": "Ansicht verschieben",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json b/jarvis/ui/web/frontend/src/i18n/locales/society/en.jsonindex 0363b2a3ee..1588e1bd4a 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/en.json@@ -735,7 +735,7 @@"open_agent": "Open {0}","overview": "Overview","ledger": "Agents list",- "help": "WASD walk · Shift runs · E interacts · M map · H help & settings",+ "help": "WASD walk · Shift runs · Space jumps · E interacts · M map · H help & settings","sample": "Sample agents — the backend is not reachable yet.","overflow": "Only the first {0} agents have a desk; the list shows everyone.","open_space": "Open space",@@ -825,6 +825,8 @@"group_arcade": "Arcade (break room)","ctl_walk": "Walk","ctl_run": "Run while held",+ "ctl_jump": "Jump; hold to keep hopping",+ "ctl_sprint_jump": "Sprint jump: faster than sprinting","ctl_click_walk": "Click the floor to walk there","ctl_rotate": "Rotate the view","ctl_pan": "Move the view",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json b/jarvis/ui/web/frontend/src/i18n/locales/society/es.jsonindex ae9477819e..6fae8268fc 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/es.json@@ -735,7 +735,7 @@"open_agent": "Abrir {0}","overview": "Vista general","ledger": "Lista de agentes",- "help": "WASD caminar · Shift corre · E usar · M mapa · H ayuda y ajustes",+ "help": "WASD caminar · Shift corre · Espacio salta · E usar · M mapa · H ayuda y ajustes","sample": "Agentes de ejemplo: el backend aún no está disponible.","overflow": "Solo los primeros {0} agentes tienen escritorio; la lista muestra a todos.","open_space": "Espacio abierto",@@ -825,6 +825,8 @@"group_arcade": "Arcade (sala de descanso)","ctl_walk": "Caminar","ctl_run": "Correr mientras la mantienes",+ "ctl_jump": "Saltar; mantén para seguir saltando",+ "ctl_sprint_jump": "Salto en carrera: más rápido que solo correr","ctl_click_walk": "Haz clic en el suelo para ir allí","ctl_rotate": "Girar la vista","ctl_pan": "Mover la vista",