okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221merge f-split-ui5 e9a2ca44a (round-7 UI, time-skip fixes, mode switch mid-goal, /plan, queued messages, uninstaller icon; includes agent6 eecb29593) into f-split-int743a6b3c6

main
1.6 KiB32 linesraw
1import { useEffect, useState } from 'react';
2import { tr } from '../lib/i18n';
3import { elapsedText, isPlayful, statusWords, useLiveStatus } from '../lib/live-status';
4
5/**
6 * The line under the newest message while the model works: a small pulse, what it is doing (a playful word while it only thinks,
7 * the real action once a tool runs), how long, and how many tokens. It shows the latest status frame only and nothing older.
8 */
9export function StatusLine({ sessionId, startedAt, tokens }: { sessionId: string | null; startedAt: number; tokens?: number }) {
10  const frame = useLiveStatus(sessionId);
11  const [now, setNow] = useState(() => Date.now());
12  const [rotation, setRotation] = useState(0);
13  useEffect(() => {
14    if (!frame) return;
15    const tick = setInterval(() => setNow(Date.now()), 1000);
16    return () => clearInterval(tick);
17  }, [!!frame]);
18  const playful = !!frame && isPlayful(frame);
19  useEffect(() => {
20    if (!playful) return;
21    const spin = setInterval(() => setRotation(r => r + 1), 3500);
22    return () => clearInterval(spin);
23  }, [playful]);
24  if (!frame) return null;
25  const count = frame.tokens ?? tokens;
26  return <div className="live-status" data-phase={frame.phase} aria-live="off">
27    <span className="live-status__pulse" aria-hidden="true"><i/><i/></span>
28    <span className="live-status__verb" key={playful ? rotation : frame.code + String(frame.args?.target ?? '')} title={statusWords(frame, rotation)}>{statusWords(frame, rotation)}</span>
29    <span className="live-status__time">{elapsedText(startedAt, now)}</span>
30    <span className="live-status__tokens">{count ? tr('{0} tokens', [count.toLocaleString()]) : ''}</span>
31  </div>;
32}