graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Hide the stream caret when a turn is done; typewrite the first chunk.
justrachc354ada925e4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 91415bf8..c25ea3f1 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,7 @@ current is part of cutting a release.## Unreleased+- `#1011`: live replies keep the typewriter and block caret; the caret hides when the turn is done, and the first chunk reveals instead of painting in as one blob.- Accord Unix 0600 is a standing duplex per live session (`GRAFF_ACCORD=0` opts out); JSONL stays the durable room (ADR 0134). `/debug` reports Accord session count and RSS.- Engine messaging (idle peer mail, #1007) is the same latch on line REPL, TUI, and `graff acp`.- `#1001`: idle TUI and line REPL start a turn when the durable peer room has new unread mail (one auto-turn per batch; inbox consume resets).diff --git a/apps/native/components/primitives/Markdown.tsx b/apps/native/components/primitives/Markdown.tsxindex 713af05c..a589685a 100644--- a/apps/native/components/primitives/Markdown.tsx+++ b/apps/native/components/primitives/Markdown.tsx@@ -128,7 +128,9 @@ export default function Markdown({onOpenPath,}: {text: string;- /** A turn is still arriving: heal the open tail and show the caret. */+ /** A turn is still arriving: heal the open tail and show the caret.+ * Once it settles, omit the caret — the block glyph is the typing cursor,+ * not a settled mark (#1011). */streaming?: boolean;/** The whole text is already here (a file in the files pane): one parse,* no block splitting, no tail healing. */@@ -149,7 +151,7 @@ export default function Markdown({<Streamdownmode={asDocument ? "static" : "streaming"}isAnimating={streaming}- caret="block"+ caret={streaming ? "block" : undefined}plugins={PLUGINS}mermaid={mermaidOptions}components={components}diff --git a/apps/native/components/site/useSmoothStream.ts b/apps/native/components/site/useSmoothStream.tsindex 38af0a4f..af923eb7 100644--- a/apps/native/components/site/useSmoothStream.ts+++ b/apps/native/components/site/useSmoothStream.ts@@ -4,17 +4,19 @@ import { useEffect, useRef, useState } from "react";import { createSmoothStream } from "@/lib/smooth-stream";/** Reveal live text only while visible and motion is welcome. Switching either- * condition off flushes the latest text and cancels the pending frame. */+ * condition off flushes the latest text and cancels the pending frame.+ * The controller starts empty so the first live chunk typewrites instead of+ * painting in as one blob — same as `createSmoothStream("")` in the unit tests. */export function useSmoothStream(target: string, live: boolean): string {- const [shown, setShown] = useState(target);+ const [shown, setShown] = useState(live ? "" : target);const latest = useRef(target);latest.current = target;const animated = useRef(false);const stream = useRef<ReturnType<typeof createSmoothStream> | null>(null);useEffect(() => {if (!live) return;- const controller = createSmoothStream(latest.current, setShown);- setShown(latest.current);+ const controller = createSmoothStream("", setShown);+ setShown("");const reduced = window.matchMedia("(prefers-reduced-motion: reduce)");const syncMotion = () => {animated.current = !document.hidden && !reduced.matches;diff --git a/apps/native/lib/markdown-caret.test.tsx b/apps/native/lib/markdown-caret.test.tsxnew file mode 100644index 00000000..8cb9786d--- /dev/null+++ b/apps/native/lib/markdown-caret.test.tsx@@ -0,0 +1,10 @@+import { expect, test } from "bun:test";+import { renderToStaticMarkup } from "react-dom/server";+import Markdown from "../components/primitives/Markdown";++test("the block caret is only on a live reply", () => {+ const live = renderToStaticMarkup(<Markdown text="Checking the motion lifecycle" streaming />);+ const done = renderToStaticMarkup(<Markdown text="Checking the motion lifecycle" />);+ expect(live).toContain("--streamdown-caret");+ expect(done).not.toContain("--streamdown-caret");+});diff --git a/apps/native/lib/smooth-stream.test.ts b/apps/native/lib/smooth-stream.test.tsindex 9fc0dc6c..ed282291 100644--- a/apps/native/lib/smooth-stream.test.ts+++ b/apps/native/lib/smooth-stream.test.ts@@ -10,6 +10,31 @@ function fixture() {return { stream, frames, painted, tick(index: number) { now += 1000 / 120; frames[index](now); } };}+test("starting on the full string never typewrites — the live hook must start empty", () => {+ const painted: string[] = [];+ const frames: ((now: number) => void)[] = [];+ let now = 0;+ const blob = "The whole answer arrives in one chunk. ".repeat(20);+ const stream = createSmoothStream(blob, text => painted.push(text), {+ now: () => now, frame(callback) { frames.push(callback); return frames.length; }, cancel() {},+ });+ stream.update(blob, true);+ expect(frames.length).toBe(0);+ expect(painted).toEqual([]);+ stream.dispose();+});++test("an empty start reveals the first live chunk instead of painting it in", () => {+ const { stream, frames, painted, tick } = fixture();+ const blob = "The whole answer arrives in one chunk. ".repeat(20);+ stream.update(blob, true);+ expect(frames.length).toBe(1);+ tick(0);+ expect(painted.at(-1)?.length).toBeGreaterThan(0);+ expect(painted.at(-1)?.length).toBeLessThan(blob.length);+ stream.dispose();+});+test("120 Hz deliveries update the pending reveal instead of cancelling it", () => {const { stream, frames, painted, tick } = fixture();let target = "";