mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 05:37:19 +01:00
From a phone the owner could not switch a session from Fable to Opus, and
opening the terminal showed a black pane before the screen appeared.
- The model sheet offers each family by Claude Code's own alias: Fable,
Opus, Sonnet, Haiku. Fable was missing. Versions are never written
down, because the aliases resolve to the newest model in each family.
- Claude Code's own "Set model to Opus 5.5", "Set effort level to high"
and refusals ("Model 'x' isn't available for your account") are read
from the session log as setting items. The sheet settles on them at
once and shows a refusal in Claude Code's words. The conversation
gets a quiet line where the change happened. A runner too old to send
these items still settles on the next answer.
- The chip reads "Model · Auto" instead of "Model? · Auto".
- The box's book button is now a slash button labelled "Commands and
prompts". It always opened the agent's commands above the library.
- The terminal pane says "Opening the screen…" until the first frame.
The server remembers each session's last screen, and a new viewer sees
it at once, marked "Last screen · updating", until the runner's live
replay lands. A remembered screen never counts as proof of life for
the stall watchdog, and closing a session forgets it.
- The conversation view's wait reads "Opening the conversation…".
- Fleet Runner 0.8.46 carries the log reader.
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
Co-authored-by: Claude <noreply@anthropic.com>
62 lines
3.1 KiB
TypeScript
62 lines
3.1 KiB
TypeScript
/**
|
|
* A session's last screen paints at once for the next viewer, marked as not
|
|
* yet live, instead of a black pane until the runner answers peek_start
|
|
* (owner, 2026-10-18: "the first thing I see is this screen, and only then,
|
|
* a little bit later, the terminal appears").
|
|
*
|
|
* Run: npx tsx scripts/test/peek-screen-cache.ts
|
|
*/
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { emitPeekFrame, forgetScreen, lastScreen } from "@/lib/sse-bus";
|
|
|
|
const user = "u-screen";
|
|
const at = Date.now();
|
|
|
|
// A delta with no screen under it is never replayed on its own.
|
|
emitPeekFrame(user, "solo", { seq: 0, frame: "[no live agent]", at, append: true }, "cloud");
|
|
assert.equal(lastScreen(user, "solo", "cloud"), null, "a delta alone is not a screen");
|
|
|
|
// A snapshot, then deltas: replayed as one screen, under both keys.
|
|
emitPeekFrame(user, "Center", { seq: 1, frame: "screen", at }, "cloud");
|
|
emitPeekFrame(user, "Center", { seq: 2, frame: "+more", at, append: true }, "cloud");
|
|
assert.equal(lastScreen(user, "Center", "cloud")?.frame, "screen+more", "snapshot plus deltas");
|
|
assert.equal(lastScreen(user, "center")?.frame, "screen+more", "the any-channel key, any case");
|
|
assert.equal(lastScreen(user, "Center", "local"), null, "never another builder's screen");
|
|
|
|
// A new snapshot replaces what came before.
|
|
emitPeekFrame(user, "Center", { seq: 3, frame: "fresh", at }, "cloud");
|
|
assert.equal(lastScreen(user, "Center", "cloud")?.frame, "fresh", "a snapshot starts over");
|
|
|
|
// Bounded, keeping the newest bytes; and forgotten once old.
|
|
emitPeekFrame(user, "Big", { seq: 0, frame: "a".repeat(250_000), at }, "cloud");
|
|
emitPeekFrame(user, "Big", { seq: 1, frame: "b".repeat(10_000), at, append: true }, "cloud");
|
|
const big = lastScreen(user, "Big", "cloud")!.frame;
|
|
assert.equal(big.length, 256_000, "capped like the runner's own replay");
|
|
assert.ok(big.endsWith("b".repeat(10_000)), "the newest bytes are the ones kept");
|
|
assert.equal(
|
|
lastScreen(user, "Center", "cloud", at + 7 * 60 * 60 * 1000),
|
|
null,
|
|
"a screen hours old is not shown as the session",
|
|
);
|
|
|
|
// Closing a session forgets its screen on every builder.
|
|
forgetScreen(user, "CENTER");
|
|
assert.equal(lastScreen(user, "Center", "cloud"), null, "closed: not shown again");
|
|
assert.equal(lastScreen(user, "Center"), null, "under any key");
|
|
assert.ok(lastScreen(user, "Big", "cloud"), "other sessions keep theirs");
|
|
assert.match(
|
|
readFileSync("src/app/api/control/close-tab/route.ts", "utf8"),
|
|
/forgetScreen\(userId, dataOrResp\.tab\)/,
|
|
"the close route forgets it",
|
|
);
|
|
|
|
// The stream sends it marked, and the transport tells the view it is not live.
|
|
const route = readFileSync("src/app/api/control/peek-stream/route.ts", "utf8");
|
|
assert.match(route, /lastScreen\(userId, tab, runnerChannel\)/, "the stream reads it");
|
|
assert.match(route, /append: false, cached: true/, "as a snapshot marked cached");
|
|
const transport = readFileSync("src/components/terminal/terminal-transport.ts", "utf8");
|
|
assert.match(transport, /h\.onCached\?\.\(cached === true\)/, "the transport passes the mark on");
|
|
|
|
console.log("✓ peek-screen-cache: the last screen paints at once, marked until the live one lands");
|