Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

perf(office): stop rendering the floor nobody is looking at

Vyapak Goyal20d1207b2418
diff --git a/src/renderer/src/scene/office/OfficeFloor.tsx b/src/renderer/src/scene/office/OfficeFloor.tsx
index d65d541e..1a883dca 100644
--- a/src/renderer/src/scene/office/OfficeFloor.tsx
+++ b/src/renderer/src/scene/office/OfficeFloor.tsx
@@ -168,6 +168,38 @@ export function OfficeFloor() {
// tears down and rebuilds the whole scene on the new map/cast (see deps below).
const officeTheme = useStore((s) => s.officeTheme);
+ // Is the floor actually on screen? A fullscreen terminal or file editor covers
+ // it completely, and a hidden window shows nothing at all — but the Pixi ticker
+ // went on running the whole scene regardless: every character, thought cloud,
+ // coffee run and envelope animating, and the renderer drawing every frame, into
+ // pixels nobody can see. On a floor of twenty agents that is the app's single
+ // largest continuous cost, and users who live in the fullscreen terminal (the
+ // normal way to work with one agent) paid it 100% of the time.
+ //
+ // Stop the ticker instead of unmounting: the WebGL context, textures and the
+ // whole scene graph stay alive, so coming back out of fullscreen is instant
+ // rather than a full theme reload. Nothing in the scene reads wall-clock time —
+ // every update is driven by the ticker's own delta — so a paused floor simply
+ // resumes where it left off.
+ const fullscreenAgentId = useStore((s) => s.fullscreenAgentId);
+ const fullscreenFilePath = useStore((s) => s.fullscreenFilePath);
+ const [docHidden, setDocHidden] = useState(() => document.hidden);
+ useEffect(() => {
+ const onVis = () => setDocHidden(document.hidden);
+ document.addEventListener('visibilitychange', onVis);
+ return () => document.removeEventListener('visibilitychange', onVis);
+ }, []);
+ const paused = !!fullscreenAgentId || !!fullscreenFilePath || docHidden;
+ // Read inside init(), which finishes asynchronously and would otherwise start a
+ // ticker the effect below had already been asked to stop.
+ const pausedRef = useRef(paused);
+ useEffect(() => {
+ pausedRef.current = paused;
+ const ticker = appRef.current?.ticker;
+ if (!ticker) return; // app.init() hasn't created it yet — init() applies it
+ if (paused) ticker.stop(); else ticker.start();
+ }, [paused]);
+
useEffect(() => {
const host = hostRef.current;
if (!host) return;
@@ -1653,6 +1685,9 @@ export function OfficeFloor() {
}
};
app.ticker.add(onTick);
+ // init() is async: the floor may already be behind a fullscreen terminal by
+ // the time we get here, and app.init() starts the ticker itself.
+ if (pausedRef.current) app.ticker.stop();
const resize = new ResizeObserver((entries) => {
for (const e of entries) {