diff --git a/apps/desktop/src/index.css b/apps/desktop/src/index.css index e8b2634cc..2c844387d 100644 --- a/apps/desktop/src/index.css +++ b/apps/desktop/src/index.css @@ -1866,3 +1866,23 @@ inset: -4px -12px; z-index: -1; } + +.turn-history { + --turn-fade-top: 0px; + --turn-fade-bottom: 0px; + mask-image: linear-gradient( + to bottom, + transparent, + #000 var(--turn-fade-top), + #000 calc(100% - var(--turn-fade-bottom)), + transparent + ); +} + +.turn-history[data-more-above] { + --turn-fade-top: 18px; +} + +.turn-history[data-more-below] { + --turn-fade-bottom: 18px; +} diff --git a/apps/desktop/src/state/turnEvents.test.ts b/apps/desktop/src/state/turnEvents.test.ts index 12c524348..bde862ca9 100644 --- a/apps/desktop/src/state/turnEvents.test.ts +++ b/apps/desktop/src/state/turnEvents.test.ts @@ -3,7 +3,7 @@ import type { TranscriptItem } from "./thread"; import { eventsText, keepEvent, turnEvents } from "./turnEvents"; const items = [ - { kind: "user", id: "u", text: "Fix it", at: 1 }, + { kind: "user", id: "u", text: "Fix it\nKeep the sidebar visible.", at: 1 }, { kind: "thought", id: "t", text: "Reading the request\nmore", summary: false, startedAt: 2, done: true }, { kind: "tool", @@ -24,20 +24,23 @@ const items = [ test("a turn's rows become its events in order, with badges and kinds", () => { const events = turnEvents(items); expect(events.map((e) => [e.badge, e.kind, e.at])).toEqual([ + ["You", "user", 1], ["Thinking", "thinking", 2], ["Bash", "run", 3], ["Edit", "failed", 4], ["Agent", "agent", 5], ]); - expect(events[0]!.line).toBe("Reading the request"); - expect(events[1]!.body).toContain("bun test"); - expect(events[1]!.body).toContain("ok"); + expect(events[0]!.line).toBe("Fix it"); + expect(events[0]!.body).toBe("Fix it\nKeep the sidebar visible."); + expect(events[1]!.line).toBe("Reading the request"); + expect(events[2]!.body).toContain("bun test"); + expect(events[2]!.body).toContain("ok"); }); test("filters keep what they name", () => { const events = turnEvents(items); expect(events.filter((e) => keepEvent(e, "tools")).map((e) => e.id)).toEqual(["c", "f"]); - expect(events.filter((e) => keepEvent(e, "agent")).map((e) => e.id)).toEqual(["t", "a"]); + expect(events.filter((e) => keepEvent(e, "agent")).map((e) => e.id)).toEqual(["u", "t", "a"]); expect(events.filter((e) => keepEvent(e, "failed")).map((e) => e.id)).toEqual(["f"]); - expect(eventsText(events)).toStartWith("#1 Thinking: Reading the request"); + expect(eventsText(events)).toStartWith("#1 You: Fix it"); }); diff --git a/apps/desktop/src/state/turnEvents.ts b/apps/desktop/src/state/turnEvents.ts index c9a2ad8c3..8b4b2a63d 100644 --- a/apps/desktop/src/state/turnEvents.ts +++ b/apps/desktop/src/state/turnEvents.ts @@ -3,13 +3,13 @@ import { stripHarnessMarkup } from "./threadFormat"; import { displayTool, usefulSummary } from "./toolNames"; /** - * A turn as a list of events, for the turn's event log (ui/TurnEvents.tsx): what the agent said, + * A turn as a list of events, for the turn's event log (ui/TurnEvents.tsx): what the user and agent said, * what it thought and each tool call, in the order they happened, each with a short line for its * row and the whole text for when the row is opened. The trace (lib/trace.ts) says where the time * went; this says what was done. */ /** What an event is, which picks its badge's colour and the filter it falls under. */ -export type TurnEventKind = "agent" | "thinking" | "run" | "read" | "edit" | "tool" | "failed"; +export type TurnEventKind = "user" | "agent" | "thinking" | "run" | "read" | "edit" | "tool" | "failed"; export interface TurnEvent { id: string; @@ -37,9 +37,9 @@ export type EventFilter = (typeof EVENT_FILTERS)[number]["id"]; export function keepEvent(event: TurnEvent, filter: EventFilter): boolean { if (filter === "all") return true; - if (filter === "agent") return event.kind === "agent" || event.kind === "thinking"; if (filter === "failed") return event.kind === "failed"; - return event.kind !== "agent" && event.kind !== "thinking"; + const message = event.kind === "user" || event.kind === "agent" || event.kind === "thinking"; + return filter === "agent" ? message : !message; } type ToolItem = Extract; @@ -93,13 +93,14 @@ function callParts(item: ToolItem): { input?: string; output?: string } { export function turnEvents(items: readonly TranscriptItem[]): TurnEvent[] { const events: TurnEvent[] = []; for (const item of items) { - if (item.kind === "assistant") { + if (item.kind === "user" || item.kind === "assistant") { + if (item.kind === "user" && (item.wake || item.continued)) continue; const text = stripHarnessMarkup(item.text).trim(); if (!text) continue; events.push({ id: item.id, - kind: "agent", - badge: "Agent", + kind: item.kind === "user" ? "user" : "agent", + badge: item.kind === "user" ? "You" : "Agent", line: firstLine(text), body: text, at: item.at, diff --git a/apps/desktop/src/ui/ThreadDetails.tsx b/apps/desktop/src/ui/ThreadDetails.tsx index 017ae1056..f48f48d2b 100644 --- a/apps/desktop/src/ui/ThreadDetails.tsx +++ b/apps/desktop/src/ui/ThreadDetails.tsx @@ -3,7 +3,7 @@ // branch), its uncommitted files, its pull requests, lineage, and activity (counts, tokens, cost, // age, context). The full diff and pull list open from their sections (ui/RightPanel.tsx). -import { type ReactNode, useEffect, useMemo, useState } from "react"; +import { type ReactNode, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"; import { pullErrorTitle } from "../acp/rustcode"; import { modelName, projectName } from "../acp/types"; import { STATUS_LABEL } from "../acp/v2"; @@ -146,7 +146,7 @@ export function ThreadDetails() { const openChanges = () => showPanel("changes"); return ( -
+
@@ -244,7 +244,7 @@ export function ThreadDetails() {
)} - +
); } @@ -312,11 +312,7 @@ const OUTCOME = { failed: { icon: CircleX, tone: "text-danger", label: "Failed" }, } as const; -/** - * Every finished turn, newest first: what opened it, how long it ran, what it cost, and a Trace - * chip that opens its waterfall beside the card (ui/TurnTrace.tsx) where the app watched the turn. - * A press on the turn opens its event log: every message and call, laid flat (ui/TurnEvents.tsx). - */ +/** Finished turns, newest first. Open a row for its messages and calls. */ function TurnsSection({ items, model, @@ -352,13 +348,13 @@ function TurnsSection({ count={turns.length || undefined} action={ turns.length > 1 ? ( - + ) : undefined @@ -367,19 +363,20 @@ function TurnsSection({ onToggle={onToggle} grow > - {turns.length === 0 && ( -

No turns yet.

- )} - {turns.map((turn) => { - const outcome = OUTCOME[turn.outcome]; - const Icon = outcome.icon; - const end = ends.get(turn.id); - return ( -
+ + {turns.length === 0 && ( +

No turns yet.

+ )} + {turns.map((turn) => { + const outcome = OUTCOME[turn.outcome]; + const Icon = outcome.icon; + return ( - - {end && turnHasTrace(turn) && ( - + ) : ( + )} - -
- ); - })} + + + ); + })} + {log && ( (null); + const content = useRef(null); + + useLayoutEffect(() => { + const node = viewport.current; + const rows = content.current; + if (!node || !rows) return; + + const update = () => { + node.toggleAttribute("data-more-above", node.scrollTop > 1); + node.toggleAttribute("data-more-below", node.scrollHeight - node.clientHeight - node.scrollTop > 1); + }; + const observer = new ResizeObserver(update); + observer.observe(node); + observer.observe(rows); + node.addEventListener("scroll", update, { passive: true }); + update(); + return () => { + observer.disconnect(); + node.removeEventListener("scroll", update); + }; + }, []); + + return ( +
+
+ {children} +
+
+ ); +} + /** A section's way to its full view: the diff, the pull list. */ function OpenButton({ label, onClick }: { label: string; onClick: () => void }) { return ( diff --git a/apps/desktop/src/ui/TurnEvents.tsx b/apps/desktop/src/ui/TurnEvents.tsx index d7b0a6d4e..79ef9793f 100644 --- a/apps/desktop/src/ui/TurnEvents.tsx +++ b/apps/desktop/src/ui/TurnEvents.tsx @@ -25,6 +25,7 @@ export interface LogTurn { /** Each kind's badge and strip cell: commands in the accent, the agent's words in green. */ const TONE: Record = { + user: { badge: "bg-fill-strong text-fg", cell: "bg-fg-muted" }, agent: { badge: "bg-success/15 text-success", cell: "bg-success/70" }, thinking: { badge: "bg-fill text-fg-muted", cell: "bg-fill-strong" }, run: { badge: "bg-accent/15 text-accent", cell: "bg-accent/70" },