Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(agentic-ide): read thread thoughts as one short line that opens to the full text

rubenluetke10-beepf129a847cfb0
diff --git a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.test.tsx
index 592895a742..f81583ed00 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.test.tsx
@@ -44,9 +44,11 @@ describe("thread work log", () => {
expect(screen.getByTestId("thread-working").textContent).toMatch(/^Working for /);
});
- it("writes a live thought out as it comes in", () => {
- show(turn([thought("r1", "Reading the config.\n\nNow the router.", true)], "running"));
- expect(screen.getByText("Reading the config.")).toBeTruthy();
+ it("shows a thought as one short line that opens to its full text", () => {
+ show(turn([thought("r1", "Reading the config. It has three sections.\n\nNow the router.", true)], "running"));
+ const line = screen.getByRole("button", { name: "Reading the config." });
+ expect(screen.queryByText("Now the router.")).toBeNull();
+ fireEvent.click(line);
expect(screen.getByText("Now the router.")).toBeTruthy();
});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.tsx b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.tsx
index 6620db86e4..54b342a9dd 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.tsx
@@ -8,7 +8,7 @@ import { readableOutput, traceDuration, type Call } from "@/components/agentchat
import { useT } from "@/i18n";
import { robustCopy } from "@/lib/clipboard";
import { cn } from "@/lib/utils";
-import { buildThreadRows, isFailed, type ThreadRow, type WorkGroup, type WorkItem } from "./threadWork";
+import { buildThreadRows, isFailed, thoughtGist, type ThreadRow, type WorkGroup, type WorkItem } from "./threadWork";
/**
* A thread's conversation: the person's messages on the right, the agent's
@@ -226,9 +226,25 @@ function CallRow({ call, stamp, grouped = false, onOpenChange }: { call: Call; s
const THOUGHT_PROSE = cn(PROSE, "text-foreground-secondary dark:text-foreground-secondary prose-p:text-foreground-secondary prose-li:text-foreground-secondary");
-/** A thought in the agent's own words: a paragraph between its work, a step quieter than the answer. */
+/**
+ * A thought between the agent's work, read at a glance: one short line — its
+ * heading or first sentence — a step quieter than the answer. A click opens
+ * the whole text below; nothing long ever stands in the thread unasked.
+ */
function ThoughtView({ text }: { text: string }) {
- return <div className={THOUGHT_PROSE} data-testid="thread-thought"><ChatMarkdown text={text} /></div>;
+ const [open, setOpen] = useState(false);
+ const gist = useMemo(() => thoughtGist(text), [text]);
+ const more = gist !== text.trim();
+ return <div className="min-w-0" data-testid="thread-thought">
+ {more
+ ? <button type="button" aria-expanded={open} onClick={() => setOpen((value) => !value)}
+ className="group/thought block w-full rounded-md py-1 text-left text-base leading-6 text-foreground-secondary transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
+ {gist}
+ <ChevronRight aria-hidden className={cn("ml-1 inline h-3.5 w-3.5 align-[-2px] text-muted-foreground opacity-0 transition duration-200 group-hover/thought:opacity-70 group-focus-visible/thought:opacity-70", open && "rotate-90 opacity-70")} />
+ </button>
+ : <p className="m-0 py-1 text-base leading-6 text-foreground-secondary">{gist}</p>}
+ {open && <div className={cn(THOUGHT_PROSE, "border-l border-border pl-3 text-sm")}><ChatMarkdown text={text} /></div>}
+ </div>;
}
/** The wordless thought the running turn is having: one live "Thinking" step. */
diff --git a/jarvis/ui/web/frontend/src/components/agentic/threads/threadWork.test.ts b/jarvis/ui/web/frontend/src/components/agentic/threads/threadWork.test.ts
index b3c599d4bd..d38f80083f 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/threads/threadWork.test.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/threads/threadWork.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, it } from "vitest";
import en from "@/i18n/locales/en.json";
import type { ToolBlock, TurnBlock, TurnStatus } from "@/components/agentchat/reduce";
-import { buildThreadRows, type ThreadRow, type WorkGroup } from "./threadWork";
+import { buildThreadRows, GIST_MAX, thoughtGist, type ThreadRow, type WorkGroup } from "./threadWork";
type Dict = Record<string, unknown>;
const t = (key: string): string => {
@@ -85,3 +85,20 @@ describe("thread work groups", () => {
expect(list.map((row) => row.kind)).toEqual(["work", "pending", "work"]);
});
});
+
+describe("thought gist", () => {
+ it("reads a thought's heading as its gist", () => {
+ expect(thoughtGist("**Checking the build**\n\nI will run the tests first and then look at the logs.")).toBe("Checking the build");
+ expect(thoughtGist("## Planning the fix\nMore text.")).toBe("Planning the fix");
+ });
+
+ it("falls back to the first sentence without Markdown marks", () => {
+ expect(thoughtGist("I need to read `src/app.ts` first. Then the router.")).toBe("I need to read src/app.ts first.");
+ });
+
+ it("cuts a long sentence at a word", () => {
+ const gist = thoughtGist(`${"word ".repeat(60)}end.`);
+ expect(gist.length).toBeLessThanOrEqual(GIST_MAX + 1);
+ expect(gist.endsWith("word…")).toBe(true);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/threads/threadWork.ts b/jarvis/ui/web/frontend/src/components/agentic/threads/threadWork.ts
index f1847aa0e1..770b3b67dd 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/threads/threadWork.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/threads/threadWork.ts
@@ -49,6 +49,32 @@ export function isFailed(call: Call): boolean {
return call.status === "failed" || call.status === "blocked" || call.status === "declined";
}
+/** How long a thought's gist may run before it is cut at a word. */
+export const GIST_MAX = 140;
+
+/**
+ * A thought as one short line a reader takes in at a glance: its heading
+ * when it opens with one ("**Checking the build**"), else its first
+ * sentence, without Markdown marks and cut at a word past GIST_MAX.
+ */
+export function thoughtGist(text: string): string {
+ const source = text.trim();
+ const heading = /^(?:#{1,6}\s+(.+)|\*\*([^*\n]+)\*\*\s*(?:\n|$))/.exec(source);
+ const raw = heading ? (heading[1] ?? heading[2]) : source.split(/\n\s*\n/)[0];
+ const plain = raw
+ .replace(/```[^\n]*\n?/g, " ")
+ .replace(/\[([^\]]+)\]\([^)]*\)/g, "$1")
+ .replace(/^\s{0,3}(>|[-*+]|\d+[.)])\s+/gm, "")
+ .replace(/(\*\*|__|~~|`)/g, "")
+ .replace(/\s+/g, " ")
+ .trim();
+ const sentence = /^.+?[.!?:](?=\s|$)/.exec(plain)?.[0] ?? plain;
+ if (sentence.length <= GIST_MAX) return sentence;
+ const cut = sentence.slice(0, GIST_MAX);
+ const space = cut.lastIndexOf(" ");
+ return `${(space > GIST_MAX / 2 ? cut.slice(0, space) : cut).replace(/[\s,;:]+$/, "")}…`;
+}
+
function soleKind(items: WorkItem[]): WorkGroup["sole"] {
const calls = items.flatMap((item) => item.kind === "call" ? [item.call] : []);
if (calls.length === 0) return "thought";