{"version":291,"agent":"box-grants","message":"abso news --follow (abso 690): a frame is a wake. On one, --follow reads the seat's news (POST news, which marks it heard) and prints that answer, one read at a time; frames arriving meanwhile fold into one more read. When the read is empty (staging 1418 counts a frame as heard already, or another chat took it), it prints the frames it hasn't printed. That's for Read Speed's fix, where frames stop counting as heard so a dead Monitor socket loses nothing, and it works on today's server too. Live on staging: 1.5 s, printed once. Tests: client/test/news-stream.test.ts.","time":1792121199646,"timeIso":"2026-10-16T03:26:39.646Z","changes":7,"change":4575,"files":["client/src/announce.ts","client/src/news-stream.ts","client/test/news-stream.test.ts"],"draft":null,"diff":[{"path":"client/src/announce.ts","added":2,"removed":0,"diff":"--- a/client/src/announce.ts\n+++ b/client/src/announce.ts\n@@ -107,6 +107,8 @@\n \t\ttry {\n \t\t\tconst ended = await follow({\n \t\t\t\tmint: () => api.newsTicket(),\n+\t\t\t\t// A frame is a wake: read the news, which marks it heard, and print that (news-stream.ts).\n+\t\t\t\ttake: async () => newsLines((await api.news()).news),\n \t\t\t\tconnect: (url, protocols) => new WebSocket(url, [...protocols]) as unknown as Socket,\n \t\t\t\twrite: (line) => {\n \t\t\t\t\tlogNews(root, [line]);"},{"path":"client/src/news-stream.ts","added":48,"removed":2,"diff":"--- a/client/src/news-stream.ts\n+++ b/client/src/news-stream.ts\n@@ -94,6 +94,8 @@\n \tsleep(ms: number): Promise<void>;\n \tnow(): number;\n \tevery(ms: number, fn: () => void): () => void;\n+\t/** Reads the seat's news, marking it heard (POST news); a frame calls it. Without it, frames are printed as they come. */\n+\ttake?(): Promise<readonly string[]>;\n \t/** Called when a socket opens and at each ping: the stream is held until the next ping is due, and a little more. */\n \theld?(until: number): void;\n \t/** Set when --follow should stop (Ctrl-C, or a test). */\n@@ -107,10 +109,53 @@\n }\n \n /**\n+ * A frame is a wake (abso 690): on one, read the seat's news (which marks it heard) and print what that answers, one\n+ * read at a time, with frames that arrive meanwhile folded into one more read. When the read answers nothing (a server\n+ * that counts a frame as heard already, or another chat on the seat took it first), the frames themselves are printed.\n+ */\n+function frameReads(deps: FollowDeps): { frame(text: string): void; idle(): Promise<void> } {\n+\tlet frames: string[] = [];\n+\t/** The lines printed lately, so a frame a read already printed isn't printed again. */\n+\tconst shown: string[] = [];\n+\tconst show = (line: string) => {\n+\t\tdeps.write(line);\n+\t\tshown.push(line);\n+\t\tif (shown.length > 200) shown.shift();\n+\t};\n+\tlet running: Promise<void> | undefined;\n+\tlet again = false;\n+\tconst pass = async () => {\n+\t\tdo {\n+\t\t\tagain = false;\n+\t\t\tconst these = frames;\n+\t\t\tframes = [];\n+\t\t\tlet items: readonly string[] = [];\n+\t\t\ttry {\n+\t\t\t\titems = await deps.take!();\n+\t\t\t} catch (err) {\n+\t\t\t\tdeps.note(`(abso news --follow: couldn't read the news: ${(err as Error).message}; showing the frames)`);\n+\t\t\t}\n+\t\t\tif (items.length > 0) for (const line of items) show(line);\n+\t\t\telse for (const line of these) if (!shown.includes(line)) show(line);\n+\t\t} while (again);\n+\t\trunning = undefined;\n+\t};\n+\treturn {\n+\t\tframe(text) {\n+\t\t\tframes.push(text);\n+\t\t\tif (running !== undefined) again = true;\n+\t\t\telse running = pass();\n+\t\t},\n+\t\tidle: () => running ?? Promise.resolve(),\n+\t};\n+}\n+\n+/**\n  * Holds the seat's stream, printing one line per item, until the key is refused or `stopped()`.\n  * Returns why it ended.\n  */\n export async function follow(deps: FollowDeps): Promise<{ ended: \"refused\" | \"stopped\"; reason: string }> {\n+\tconst reads = frameReads(deps);\n \tlet wait = 1_000;\n \twhile (!deps.stopped()) {\n \t\tlet ticket: NewsTicket;\n@@ -139,12 +184,13 @@\n \t\t\t};\n \t\t\tsocket.onmessage = (e) => {\n \t\t\t\tif (typeof e.data !== \"string\" || e.data === PONG) return;\n-\t\t\t\tdeps.write(e.data);\n+\t\t\t\tif (deps.take === undefined) deps.write(e.data);\n+\t\t\t\telse reads.frame(e.data);\n \t\t\t};\n \t\t\tsocket.onerror = () => {};\n \t\t\tsocket.onclose = (e) => {\n \t\t\t\tstopPing();\n-\t\t\t\tdone({ code: e.code, reason: e.reason });\n+\t\t\t\tvoid reads.idle().then(() => done({ code: e.code, reason: e.reason }));\n \t\t\t};\n \t\t});\n \t\tif (isRefusal(closed.code)) return { ended: \"refused\", reason: closed.reason || `closed ${closed.code}` };"},{"path":"client/test/news-stream.test.ts","added":31,"removed":0,"diff":"--- a/client/test/news-stream.test.ts\n+++ b/client/test/news-stream.test.ts\n@@ -134,6 +134,37 @@\n \tassert.equal(w.notes.length, 0);\n });\n \n+test(\"a frame is a wake: --follow reads the news and prints that once; an empty read prints the frames\", async () => {\n+\t// The server's frames don't count as heard (abso 690): the read takes them, so each item prints once.\n+\tconst w = world([{ frames: [\"fe told you: hello\", \"cloud asks: ship it?\"], close: { code: 1006 } }]);\n+\tconst reads: string[][] = [[\"fe told you: hello\", \"cloud asks: ship it?\"], []];\n+\tlet calls = 0;\n+\tw.deps.take = async () => {\n+\t\tcalls++;\n+\t\treturn reads.shift() ?? [];\n+\t};\n+\tawait follow(w.deps);\n+\t// Two frames, one read in flight: the second folds into one more read, which finds nothing new; its frame was\n+\t// already printed by the first read, so nothing prints twice.\n+\tassert.equal(calls, 2);\n+\tassert.deepEqual(w.lines, [\"fe told you: hello\", \"cloud asks: ship it?\"]);\n+\n+\t// A server that counts a frame as heard already (staging 1418): the read is empty, so the frame is what shows.\n+\tconst old = world([{ frames: [\"fe told you: hello\"], close: { code: 1006 } }]);\n+\told.deps.take = async () => [];\n+\tawait follow(old.deps);\n+\tassert.deepEqual(old.lines, [\"fe told you: hello\"]);\n+\n+\t// A read that fails shows the frames and says why.\n+\tconst down = world([{ frames: [\"fe told you: hello\"], close: { code: 1006 } }]);\n+\tdown.deps.take = async () => {\n+\t\tthrow new Error(\"could not reach the server\");\n+\t};\n+\tawait follow(down.deps);\n+\tassert.deepEqual(down.lines, [\"fe told you: hello\"]);\n+\tassert.match(down.notes[0]!, /couldn't read the news: could not reach the server/);\n+});\n+\n test(\"--follow keeps an idle socket open with a ping the object answers without waking\", async () => {\n \tconst w = world([{ frames: [], close: { code: 1006 } }]);\n \tconst held: number[] = [];"}],"ci":null}