okami.mom/strata

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

Niko1221merge f-split-ui3 088f8685a (live status line, reasoning panel, goal bar, tool rows, time-skip comparison) into f-split-int334dde73a

main
1.2 KiB18 linesraw
1/** The newest line of the model's reasoning, trimmed for one compact row (while it is still reasoning, the row shows what it is thinking about). */
2export function lastReasoningLine(text: string | undefined, max = 110): string {
3  const lines = String(text ?? '').split(/\r?\n/).map(l => l.replace(/^[\s>*#\-•\d.]+/, '').replace(/[*_`]/g, '').trim()).filter(Boolean);
4  const line = lines.at(-1) ?? '';
5  return line.length > max ? `${line.slice(0, max - 1)}…` : line;
6}
7
8/** "38s", "1m 04s": how long the model reasoned. null when it is too short to be worth saying. */
9export function thoughtDuration(ms: number | undefined): string | null {
10  if (typeof ms !== 'number' || !Number.isFinite(ms) || ms < 1000) return null;
11  const total = Math.round(ms / 1000);
12  return total < 60 ? `${total}s` : `${Math.floor(total / 60)}m ${String(total % 60).padStart(2, '0')}s`;
13}
14
15/** Is a scrolling box at its bottom (within a few pixels)? Reasoning sticks to the bottom only while the person has not scrolled up. */
16export function atBottom(el: { scrollHeight: number; scrollTop: number; clientHeight: number }, slack = 24): boolean {
17  return el.scrollHeight - el.scrollTop - el.clientHeight <= slack;
18}