The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(conversations): add live elapsed time hook
Steven Enamakelc19bed5c2b08
diff --git a/app/src/features/conversations/aui/useLiveElapsed.ts b/app/src/features/conversations/aui/useLiveElapsed.tsnew file mode 100644index 0000000000..3f28784344--- /dev/null+++ b/app/src/features/conversations/aui/useLiveElapsed.ts@@ -0,0 +1,55 @@+import { useEffect, useState } from 'react';++/**+ * Elapsed time for a sub-agent delegation that ticks every second while it+ * works, after OpenClaw's live subagent timers.+ *+ * The core reports a delegation's wall-clock `elapsedMs` only once it settles;+ * a running row carries no start time. So the clock is anchored the first time+ * this session sees the task running, in a module-scoped map that outlives+ * assistant-ui's remounts (virtualised history, thread switches). After a+ * reload mid-run the anchor is the reload, so the count restarts — the settled+ * duration from the core replaces it as soon as the run finishes.+ */+const MAX_ANCHORS = 500;+const anchors = new Map<string, number>();++function anchorFor(key: string): number {+ const existing = anchors.get(key);+ if (existing !== undefined) return existing;+ const now = Date.now();+ anchors.set(key, now);+ if (anchors.size > MAX_ANCHORS) {+ const oldest = anchors.keys().next().value;+ if (oldest !== undefined) anchors.delete(oldest);+ }+ return now;+}++/** Forget every anchor. Exposed for tests. */+export function resetLiveElapsedAnchors(): void {+ anchors.clear();+}++/**+ * `settledMs` once the run has finished, else live milliseconds since the run+ * was first seen; `undefined` when neither is known (no key while running).+ */+export function useLiveElapsed(+ key: string | undefined,+ running: boolean,+ settledMs: number | undefined+): number | undefined {+ const ticking = running && key !== undefined;+ const [now, setNow] = useState(() => Date.now());++ useEffect(() => {+ if (!ticking) return undefined;+ const id = setInterval(() => setNow(Date.now()), 1000);+ return () => clearInterval(id);+ }, [ticking]);++ if (!running) return settledMs;+ if (key === undefined) return undefined;+ return Math.max(0, now - anchorFor(key));+}