Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6af78e9dd | ||
|
|
7ab503e4f5 | ||
|
|
eaf11a7696 | ||
|
|
4738233580 | ||
|
|
cb25320ea0 | ||
|
|
ff52dd9812 | ||
|
|
f3a5cad789 | ||
|
|
fffd2a55f3 | ||
|
|
563a35d2ec | ||
|
|
9dead5652e |
@@ -777,7 +777,7 @@ async fn unpushed_commits_block_kill_and_force_keeps_the_tree() {
|
|||||||
other => panic!("expected a kill_guarded refusal, got {other:?}"),
|
other => panic!("expected a kill_guarded refusal, got {other:?}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force overrides the refusal and nothing else: session gone, tree kept.
|
// Force overrides the refusal: session gone, tree removed.
|
||||||
client.kill_session_forced(s.id).await.expect("forced kill");
|
client.kill_session_forced(s.id).await.expect("forced kill");
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
@@ -789,12 +789,12 @@ async fn unpushed_commits_block_kill_and_force_keeps_the_tree() {
|
|||||||
.any(|x| x.id == s.id),
|
.any(|x| x.id == s.id),
|
||||||
"the forced kill ends the session"
|
"the forced kill ends the session"
|
||||||
);
|
);
|
||||||
assert!(wt.is_dir(), "a guarded worktree must stay on disk");
|
assert!(!wt.is_dir(), "a forced kill removes the worktree");
|
||||||
assert!(
|
assert!(
|
||||||
git_worktree_list(base.path())
|
!git_worktree_list(base.path())
|
||||||
.iter()
|
.iter()
|
||||||
.any(|l| l.contains("feature/local")),
|
.any(|l| l.contains("feature/local")),
|
||||||
"the kept tree stays registered in git"
|
"the removed tree is unregistered from git"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -70,7 +70,7 @@ command. `<duration>` follows in the rail's colour when shown. There is no
|
|||||||
state word and no second badge: the rail exists so the state is still legible
|
state word and no second badge: the rail exists so the state is still legible
|
||||||
when a row is dimmed or the terminal renders the duration in the default fg.
|
when a row is dimmed or the terminal renders the duration in the default fg.
|
||||||
|
|
||||||
In the **web client** the rail is a 5px bar pinned to the row's own left
|
In the **web client** the rail is a 7px bar pinned to the row's own left
|
||||||
edge, square corners, spanning the full card height edge to edge — it
|
edge, square corners, spanning the full card height edge to edge — it
|
||||||
shifts outward with nesting depth along with the row's own padding, since
|
shifts outward with nesting depth along with the row's own padding, since
|
||||||
it is positioned relative to the row. It carries motion only for states that
|
it is positioned relative to the row. It carries motion only for states that
|
||||||
|
|||||||
+7
-13
@@ -190,19 +190,13 @@ choices, not daemon ones.
|
|||||||
from the transcript; the TUI may show the current plan in its status line,
|
from the transcript; the TUI may show the current plan in its status line,
|
||||||
while the web client deliberately has no stats or plan rail.
|
while the web client deliberately has no stats or plan rail.
|
||||||
- The web client groups two or more tool rows after the same `User` row into
|
- The web client groups two or more tool rows after the same `User` row into
|
||||||
one collapsed turn activity block. `AgentText` and `AgentThought` rows that
|
one collapsed turn activity block. `AgentText` and `AgentThought` rows stay
|
||||||
appear *between* tool rows in the same turn are absorbed into the group
|
outside the group as standalone transcript items — the operator sees all
|
||||||
(intermediate narration); the last `AgentText` with no subsequent tool stays
|
reasoning without expanding. Resolved approval rows between tools are
|
||||||
outside as the prominent final answer. While a turn is still active
|
absorbed into the group. The collapsed header reads "N tool calls · Label
|
||||||
(responding or thinking), the most recent trailing text or thought row is
|
'arg'" where the label and argument come from the last tool row's
|
||||||
kept outside as visible narration — the operator always sees the agent's
|
`splitToolTitle` — the operator sees which command is current at a glance.
|
||||||
latest reasoning without opening the group. It is replaced by the next text
|
Opening the group reveals tool rows in chronological order.
|
||||||
row when one arrives, and absorbed into the group when the turn ends (unless
|
|
||||||
it is `AgentText`, which stays outside as the final answer). The collapsed
|
|
||||||
header reads "N tool calls · Label 'arg'" where the label and argument come
|
|
||||||
from the last tool row's `splitToolTitle` — the operator sees which command
|
|
||||||
is current at a glance. Opening the group reveals tools and intermediate
|
|
||||||
text in chronological order, with the text rendered in a subdued style.
|
|
||||||
- The web client's user, agent, thought, tool-detail, and notice text blocks
|
- The web client's user, agent, thought, tool-detail, and notice text blocks
|
||||||
copy their complete source text when clicked or keyboard-activated.
|
copy their complete source text when clicked or keyboard-activated.
|
||||||
- The web client consumes `available_commands_update` notices as the live
|
- The web client consumes `available_commands_update` notices as the live
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ describe("MultiView", () => {
|
|||||||
expect(screen.getByText("Tab 1 · 1")).toBeTruthy();
|
expect(screen.getByText("Tab 1 · 1")).toBeTruthy();
|
||||||
const pane = document.querySelector('[data-session-id="s9"]');
|
const pane = document.querySelector('[data-session-id="s9"]');
|
||||||
expect(pane).toBeTruthy();
|
expect(pane).toBeTruthy();
|
||||||
expect(pane!.querySelector(".bg-preview-tint")).toBeTruthy();
|
expect(pane!.classList.contains("is-preview")).toBe(true);
|
||||||
expect(screen.getByText("preview")).toBeTruthy();
|
expect(screen.getByText("preview")).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -188,8 +188,9 @@ function Pane({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={
|
className={
|
||||||
"mv-pane flex h-full min-h-0 min-w-0 flex-col border " +
|
"mv-pane flex h-full min-h-0 min-w-0 flex-col" +
|
||||||
(isFocused && !isPreview ? "border-accent" : "border-border-strong")
|
(isFocused ? " is-focused" : "") +
|
||||||
|
(isPreview ? " is-preview" : "")
|
||||||
}
|
}
|
||||||
data-leaf-id={leaf.id}
|
data-leaf-id={leaf.id}
|
||||||
data-session-id={leaf.sessionId ?? undefined}
|
data-session-id={leaf.sessionId ?? undefined}
|
||||||
@@ -201,10 +202,7 @@ function Pane({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={
|
className="mv-pane-header attach-header flex items-center justify-between gap-sp-2 border-b border-border-strong px-sp-2 py-sp-1 text-fs-12"
|
||||||
"mv-pane-header flex items-center justify-between gap-sp-2 border-b border-border-strong px-sp-2 py-sp-1 text-fs-12 " +
|
|
||||||
(isPreview ? "bg-preview-tint text-preview" : "bg-surface")
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{leaf.sessionId ? (
|
{leaf.sessionId ? (
|
||||||
<PaneTitle sessionId={leaf.sessionId} session={session} />
|
<PaneTitle sessionId={leaf.sessionId} session={session} />
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export interface PaneTitleProps {
|
|||||||
export function PaneTitle({ sessionId, session, className }: PaneTitleProps) {
|
export function PaneTitle({ sessionId, session, className }: PaneTitleProps) {
|
||||||
if (!session) {
|
if (!session) {
|
||||||
return (
|
return (
|
||||||
<span className={className ?? "at-title"} title={sessionId}>
|
<span className={className ?? "attach-title"} title={sessionId}>
|
||||||
session <span className="sid">{sessionId.slice(0, 8)}</span>
|
session <span className="sid">{sessionId.slice(0, 8)}</span>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
@@ -27,7 +27,7 @@ export function PaneTitle({ sessionId, session, className }: PaneTitleProps) {
|
|||||||
const icon = tool ? toolIconSvg(tool) : null;
|
const icon = tool ? toolIconSvg(tool) : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className={className ?? "at-title"} title={`${name} · ${session.command} (${sessionId})`}>
|
<span className={className ?? "attach-title"} title={`${name} · ${session.command} (${sessionId})`}>
|
||||||
<span className="at-name">{name}</span>
|
<span className="at-name">{name}</span>
|
||||||
{showCommand && (
|
{showCommand && (
|
||||||
<span className="at-cmd">
|
<span className="at-cmd">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// docs/SIDEBAR.md: a 5px bar pinned to the row's own left edge, square
|
// docs/SIDEBAR.md: a 7px bar pinned to the row's own left edge, square
|
||||||
// corners, full card height. It paints for every card, Idle included, and it
|
// corners, full card height. It paints for every card, Idle included, and it
|
||||||
// carries the accessible name of the state so status is never colour-only.
|
// carries the accessible name of the state so status is never colour-only.
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ export function ActivityRail({ activity }: { activity: ActivityState | string |
|
|||||||
const word = STATE_WORDS[slug] ?? STATE_WORDS.idle;
|
const word = STATE_WORDS[slug] ?? STATE_WORDS.idle;
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={`absolute left-0 top-0 bottom-0 w-[5px] ${RAIL_CLASS[slug] ?? RAIL_CLASS.idle}`}
|
className={`absolute left-0 top-0 bottom-0 w-[7px] ${RAIL_CLASS[slug] ?? RAIL_CLASS.idle}`}
|
||||||
data-activity={slug}
|
data-activity={slug}
|
||||||
role="img"
|
role="img"
|
||||||
title={word}
|
title={word}
|
||||||
|
|||||||
@@ -44,14 +44,17 @@ export interface SessionCardProps {
|
|||||||
onRenameCancel(): void;
|
onRenameCancel(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The fill ladder from docs/SIDEBAR.md "Which row is filled", furthest down
|
/** The fill ladder from docs/SIDEBAR.md "Which row is filled" — the CSS
|
||||||
* wins. Written as one ordered run so the precedence is the order it reads in. */
|
* cascade in styles.css carries the actual fills via `.is-active`, `.is-open`,
|
||||||
function rowFill(p: SessionCardProps): string {
|
* `.is-previewing` (all inside `:where()` so source order is the precedence).
|
||||||
if (p.active) return "bg-accent-fill";
|
* We just apply the right class names here. */
|
||||||
if (p.previewing) return "bg-preview-tint";
|
function rowClasses(p: SessionCardProps): string {
|
||||||
if (p.open) return "bg-accent/[0.06]";
|
const cls: string[] = [];
|
||||||
if (p.highlighted) return "bg-preview-tint";
|
if (p.active) cls.push("is-active");
|
||||||
return "";
|
if (p.open) cls.push("is-open");
|
||||||
|
if (p.previewing) cls.push("is-previewing");
|
||||||
|
if (p.highlighted) cls.push("is-highlighted");
|
||||||
|
return cls.join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SessionCard(props: SessionCardProps) {
|
export function SessionCard(props: SessionCardProps) {
|
||||||
@@ -62,7 +65,7 @@ export function SessionCard(props: SessionCardProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
className={`session-card tree-leaf no-underline ${rowFill(props)} ${
|
className={`session-card tree-leaf no-underline ${rowClasses(props)} ${
|
||||||
running ? "" : "opacity-60"
|
running ? "" : "opacity-60"
|
||||||
}`}
|
}`}
|
||||||
href={`#/attach/${encodeURIComponent(s.id)}`}
|
href={`#/attach/${encodeURIComponent(s.id)}`}
|
||||||
|
|||||||
@@ -323,6 +323,26 @@ describe("prompt and cancel", () => {
|
|||||||
await waitFor(() => expect(sendStructuredPrompt).toHaveBeenCalledWith("s1", "next up"));
|
await waitFor(() => expect(sendStructuredPrompt).toHaveBeenCalledWith("s1", "next up"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("concatenates multiple queued messages into a single prompt", async () => {
|
||||||
|
const { socket } = mount();
|
||||||
|
snapshot(socket, [], busy);
|
||||||
|
const input = document.querySelector<HTMLTextAreaElement>(".structured-input")!;
|
||||||
|
const form = document.querySelector("form.structured-composer")!;
|
||||||
|
|
||||||
|
fireEvent.change(input, { target: { value: "first" } });
|
||||||
|
fireEvent.submit(form);
|
||||||
|
fireEvent.change(input, { target: { value: "second" } });
|
||||||
|
fireEvent.submit(form);
|
||||||
|
|
||||||
|
expect(sendStructuredPrompt).not.toHaveBeenCalled();
|
||||||
|
const queued = document.querySelectorAll(".st-row-queued");
|
||||||
|
expect(queued).toHaveLength(2);
|
||||||
|
|
||||||
|
socket.emit({ type: "reduced_state", state: idle });
|
||||||
|
await waitFor(() => expect(sendStructuredPrompt).toHaveBeenCalledWith("s1", "first\n\nsecond"));
|
||||||
|
expect(sendStructuredPrompt).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
it("hands a failed send's draft back to the operator", async () => {
|
it("hands a failed send's draft back to the operator", async () => {
|
||||||
vi.mocked(sendStructuredPrompt).mockRejectedValueOnce(new Error("boom"));
|
vi.mocked(sendStructuredPrompt).mockRejectedValueOnce(new Error("boom"));
|
||||||
const { socket } = mount();
|
const { socket } = mount();
|
||||||
|
|||||||
@@ -251,14 +251,16 @@ export const StructuredPane = forwardRef<StructuredPaneHandle, StructuredPanePro
|
|||||||
[sessionId, socketGeneration, session],
|
[sessionId, socketGeneration, session],
|
||||||
);
|
);
|
||||||
|
|
||||||
// A queued message goes out as soon as the projected turn is idle — the
|
// Queued messages are concatenated into a single prompt so the agent sees
|
||||||
// daemon answers a second prompt `409 turn_in_flight`, so the queue is
|
// one user turn instead of N back-to-back turns. The daemon rejects a
|
||||||
// client-local (docs/STRUCTURED-VIEW.md).
|
// second prompt while a turn is in flight (`409 turn_in_flight`), so the
|
||||||
|
// queue is client-local (docs/STRUCTURED-VIEW.md).
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (active || promptPending.current || queue.length === 0) return;
|
if (active || promptPending.current || queue.length === 0) return;
|
||||||
const [next, ...rest] = queue;
|
const text = queue.map((q) => q.text).join("\n\n");
|
||||||
setQueue(rest);
|
const files = queue.flatMap((q) => q.attachments);
|
||||||
dispatchPrompt(next.text, next.attachments);
|
setQueue([]);
|
||||||
|
dispatchPrompt(text, files);
|
||||||
}, [active, queue, dispatchPrompt]);
|
}, [active, queue, dispatchPrompt]);
|
||||||
|
|
||||||
const submit = (text: string, files: File[]) => {
|
const submit = (text: string, files: File[]) => {
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ describe("activity grouping", () => {
|
|||||||
expect(activityGroupsByTurn(rows, null, false).size).toBe(0);
|
expect(activityGroupsByTurn(rows, null, false).size).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("absorbs intermediate narration but keeps the final answer outside", () => {
|
it("keeps intermediate text outside the group as standalone items", () => {
|
||||||
const rows = [
|
const rows = [
|
||||||
text("user:1", "user", "go"),
|
text("user:1", "user", "go"),
|
||||||
tool("tool:1"),
|
tool("tool:1"),
|
||||||
@@ -133,11 +133,11 @@ describe("activity grouping", () => {
|
|||||||
text("agent:2", "agent_text", "done"),
|
text("agent:2", "agent_text", "done"),
|
||||||
];
|
];
|
||||||
const group = activityGroupsByTurn(rows, null, false).get("turn:user:1")!;
|
const group = activityGroupsByTurn(rows, null, false).get("turn:user:1")!;
|
||||||
expect(group.rows.map((r) => r.id)).toEqual(["tool:1", "agent:1", "tool:2"]);
|
expect(group.rows.map((r) => r.id)).toEqual(["tool:1", "tool:2"]);
|
||||||
expect(group.toolCount).toBe(2);
|
expect(group.toolCount).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("keeps the newest thought outside while the turn is still live", () => {
|
it("keeps thoughts outside the group as standalone items", () => {
|
||||||
const rows = [
|
const rows = [
|
||||||
text("user:1", "user", "go"),
|
text("user:1", "user", "go"),
|
||||||
tool("tool:1"),
|
tool("tool:1"),
|
||||||
@@ -145,26 +145,8 @@ describe("activity grouping", () => {
|
|||||||
text("thought:1", "agent_thought", "hmm"),
|
text("thought:1", "agent_thought", "hmm"),
|
||||||
text("thought:2", "agent_thought", "aha"),
|
text("thought:2", "agent_thought", "aha"),
|
||||||
];
|
];
|
||||||
const live = activityGroupsByTurn(rows, null, true).get("turn:user:1")!;
|
const group = activityGroupsByTurn(rows, null, false).get("turn:user:1")!;
|
||||||
expect(live.rows.map((r) => r.id)).toEqual(["tool:1", "tool:2", "thought:1"]);
|
expect(group.rows.map((r) => r.id)).toEqual(["tool:1", "tool:2"]);
|
||||||
const ended = activityGroupsByTurn(rows, null, false).get("turn:user:1")!;
|
|
||||||
expect(ended.rows.map((r) => r.id)).toEqual(["tool:1", "tool:2", "thought:1", "thought:2"]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("keeps the newest agent_text outside while the turn is still live", () => {
|
|
||||||
const rows = [
|
|
||||||
text("user:1", "user", "go"),
|
|
||||||
tool("tool:1"),
|
|
||||||
text("agent:1", "agent_text", "working on it"),
|
|
||||||
tool("tool:2"),
|
|
||||||
text("agent:2", "agent_text", "almost done"),
|
|
||||||
];
|
|
||||||
const live = activityGroupsByTurn(rows, null, true).get("turn:user:1")!;
|
|
||||||
// "almost done" stays outside as visible narration while the turn is live
|
|
||||||
expect(live.rows.map((r) => r.id)).toEqual(["tool:1", "agent:1", "tool:2"]);
|
|
||||||
const ended = activityGroupsByTurn(rows, null, false).get("turn:user:1")!;
|
|
||||||
// Once ended, the final agent_text stays outside as the answer
|
|
||||||
expect(ended.rows.map((r) => r.id)).toEqual(["tool:1", "agent:1", "tool:2"]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("tracks the last tool's label and argument for the collapsed header", () => {
|
it("tracks the last tool's label and argument for the collapsed header", () => {
|
||||||
|
|||||||
@@ -144,9 +144,10 @@ export function turnIsActive(state: ReducedState): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ActivityGroup {
|
export interface ActivityGroup {
|
||||||
/** Header label count — tool rows only, never absorbed text. */
|
/** Header label count — tool rows only. */
|
||||||
toolCount: number;
|
toolCount: number;
|
||||||
/** Tools plus absorbed intermediate text/approvals, in transcript order. */
|
/** Tool rows and resolved approvals, in transcript order. Text/thought
|
||||||
|
* rows stay outside the group as standalone transcript items. */
|
||||||
rows: TranscriptRow[];
|
rows: TranscriptRow[];
|
||||||
/** `splitToolTitle` of the last tool row — the collapsed header shows it. */
|
/** `splitToolTitle` of the last tool row — the collapsed header shows it. */
|
||||||
lastToolLabel: string;
|
lastToolLabel: string;
|
||||||
@@ -154,23 +155,16 @@ export interface ActivityGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Group tool rows (and intermediate agent text / resolved approvals between
|
* Group tool rows (and resolved approvals between them) by turn. Text and
|
||||||
* them) by turn. An agent_text/agent_thought row is "intermediate" when a tool
|
* thought rows stay outside the group as standalone transcript items — the
|
||||||
* row follows it in the same turn — it gets absorbed into the group so the
|
* operator sees all reasoning without expanding anything.
|
||||||
* collapsed block preserves chronological order. Resolved approval rows (not
|
|
||||||
* the currently pending one) are absorbed the same way. The *last* agent text
|
|
||||||
* with no subsequent tool stays standalone (the prominent final answer).
|
|
||||||
*
|
|
||||||
* While a turn is still live, the most recent text or thought row trailing the
|
|
||||||
* group also stays outside as visible narration — the operator always sees the
|
|
||||||
* agent's latest reasoning without opening the group.
|
|
||||||
*
|
*
|
||||||
* Returns groups keyed by `turn:<userId>`.
|
* Returns groups keyed by `turn:<userId>`.
|
||||||
*/
|
*/
|
||||||
export function activityGroupsByTurn(
|
export function activityGroupsByTurn(
|
||||||
rows: TranscriptRow[],
|
rows: TranscriptRow[],
|
||||||
pendingApprovalId: string | null,
|
pendingApprovalId: string | null,
|
||||||
turnActive: boolean,
|
_turnActive: boolean,
|
||||||
): Map<string, ActivityGroup> {
|
): Map<string, ActivityGroup> {
|
||||||
// First: count tools per turn to know which turns qualify for grouping.
|
// First: count tools per turn to know which turns qualify for grouping.
|
||||||
const toolCounts = new Map<string, number>();
|
const toolCounts = new Map<string, number>();
|
||||||
@@ -181,11 +175,9 @@ export function activityGroupsByTurn(
|
|||||||
const gid = `turn:${turnId}`;
|
const gid = `turn:${turnId}`;
|
||||||
toolCounts.set(gid, (toolCounts.get(gid) ?? 0) + 1);
|
toolCounts.set(gid, (toolCounts.get(gid) ?? 0) + 1);
|
||||||
}
|
}
|
||||||
// Second: build groups with interleaved text for turns with 2+ tools.
|
// Second: build groups for turns with 2+ tools.
|
||||||
const groups = new Map<string, ActivityGroup>();
|
const groups = new Map<string, ActivityGroup>();
|
||||||
turnId = "before-first-message";
|
turnId = "before-first-message";
|
||||||
// Pending rows that might be intermediate (not yet confirmed by a following
|
|
||||||
// tool). If no tool follows, they stay standalone.
|
|
||||||
let pending: TranscriptRow[] = [];
|
let pending: TranscriptRow[] = [];
|
||||||
let currentGid = `turn:${turnId}`;
|
let currentGid = `turn:${turnId}`;
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
@@ -197,15 +189,13 @@ export function activityGroupsByTurn(
|
|||||||
}
|
}
|
||||||
const count = toolCounts.get(currentGid) ?? 0;
|
const count = toolCounts.get(currentGid) ?? 0;
|
||||||
if (count < 2) continue;
|
if (count < 2) continue;
|
||||||
const isIntermediateText = row.kind === "agent_text" || row.kind === "agent_thought";
|
|
||||||
const isResolvedApproval = row.kind === "approval" && row.id !== pendingApprovalId;
|
const isResolvedApproval = row.kind === "approval" && row.id !== pendingApprovalId;
|
||||||
if (isIntermediateText || isResolvedApproval) {
|
if (isResolvedApproval) {
|
||||||
pending.push(row);
|
pending.push(row);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (row.kind === "tool_call" || row.kind === "tool_diff") {
|
if (row.kind === "tool_call" || row.kind === "tool_diff") {
|
||||||
const group = groups.get(currentGid) ?? { toolCount: count, rows: [], lastToolLabel: "", lastToolArg: "" };
|
const group = groups.get(currentGid) ?? { toolCount: count, rows: [], lastToolLabel: "", lastToolArg: "" };
|
||||||
// Flush any pending rows — a tool follows, so they're intermediate.
|
|
||||||
group.rows.push(...pending);
|
group.rows.push(...pending);
|
||||||
pending = [];
|
pending = [];
|
||||||
group.rows.push(row);
|
group.rows.push(row);
|
||||||
@@ -216,25 +206,6 @@ export function activityGroupsByTurn(
|
|||||||
groups.set(currentGid, group);
|
groups.set(currentGid, group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Trailing text/thought rows after the last tool in this turn.
|
|
||||||
// While the turn is still live, the newest one stays outside as visible
|
|
||||||
// narration — the operator always sees the agent's latest reasoning.
|
|
||||||
// A final agent_text (the "answer") stays outside regardless.
|
|
||||||
const lastGroup = groups.get(currentGid);
|
|
||||||
if (lastGroup && pending.length > 0) {
|
|
||||||
const allThoughts = pending.every((row) => row.kind === "agent_thought");
|
|
||||||
if (allThoughts) {
|
|
||||||
// Pure thoughts: absorb all when done, keep the newest outside while live.
|
|
||||||
const absorb = turnActive ? pending.slice(0, -1) : pending;
|
|
||||||
lastGroup.rows.push(...absorb);
|
|
||||||
} else if (turnActive) {
|
|
||||||
// Mixed or agent_text trailing: keep the very last row outside while live,
|
|
||||||
// absorb the rest.
|
|
||||||
lastGroup.rows.push(...pending.slice(0, -1));
|
|
||||||
}
|
|
||||||
// When the turn ends with agent_text last, nothing extra is absorbed — the
|
|
||||||
// text stays outside as the final answer.
|
|
||||||
}
|
|
||||||
|
|
||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,12 +196,24 @@ export function useStructuredSession(
|
|||||||
connect();
|
connect();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Mobile browsers suspend timers and silently kill WebSockets in the
|
||||||
|
// background. Kick a fresh connect when the page becomes visible again.
|
||||||
|
const onVisibility = () => {
|
||||||
|
if (document.visibilityState !== "visible" || disposed) return;
|
||||||
|
if (socket && (socket.readyState === WebSocket.OPEN || socket.readyState === WebSocket.CONNECTING)) return;
|
||||||
|
cancelTimer();
|
||||||
|
setStatus("reconnecting");
|
||||||
|
connect();
|
||||||
|
};
|
||||||
|
document.addEventListener("visibilitychange", onVisibility);
|
||||||
|
|
||||||
setStatus("connecting");
|
setStatus("connecting");
|
||||||
connect();
|
connect();
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
disposed = true;
|
disposed = true;
|
||||||
reconnectRef.current = () => {};
|
reconnectRef.current = () => {};
|
||||||
|
document.removeEventListener("visibilitychange", onVisibility);
|
||||||
cancelTimer();
|
cancelTimer();
|
||||||
closeSocket();
|
closeSocket();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -302,6 +302,24 @@ export const TerminalPane = forwardRef<TerminalPaneHandle, TerminalPaneProps>(
|
|||||||
ta?.addEventListener("focus", onTaFocus);
|
ta?.addEventListener("focus", onTaFocus);
|
||||||
ta?.addEventListener("blur", onTaBlur);
|
ta?.addEventListener("blur", onTaBlur);
|
||||||
|
|
||||||
|
// Mobile browsers (Android especially) suspend timers and silently kill
|
||||||
|
// WebSockets when the app goes to background. The backoff timer set by
|
||||||
|
// onclose is frozen too, so recovery stalls until visibility returns. Kick
|
||||||
|
// a fresh connect immediately when the page becomes visible again.
|
||||||
|
const onVisibility = () => {
|
||||||
|
if (document.visibilityState !== "visible" || disposed) return;
|
||||||
|
if (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING) return;
|
||||||
|
// Cancel any pending backoff — we're reconnecting right now.
|
||||||
|
if (reconnectTimer !== null) {
|
||||||
|
window.clearTimeout(reconnectTimer);
|
||||||
|
reconnectTimer = null;
|
||||||
|
}
|
||||||
|
reconnectMs = INITIAL_RECONNECT_MS;
|
||||||
|
onStatusChange?.("reconnecting");
|
||||||
|
connect();
|
||||||
|
};
|
||||||
|
document.addEventListener("visibilitychange", onVisibility);
|
||||||
|
|
||||||
window.addEventListener("resize", onResize);
|
window.addEventListener("resize", onResize);
|
||||||
const visual = window.visualViewport ?? null;
|
const visual = window.visualViewport ?? null;
|
||||||
visual?.addEventListener("resize", onResize);
|
visual?.addEventListener("resize", onResize);
|
||||||
@@ -326,6 +344,7 @@ export const TerminalPane = forwardRef<TerminalPaneHandle, TerminalPaneProps>(
|
|||||||
reconnectTimer = null;
|
reconnectTimer = null;
|
||||||
}
|
}
|
||||||
ro.disconnect();
|
ro.disconnect();
|
||||||
|
document.removeEventListener("visibilitychange", onVisibility);
|
||||||
window.removeEventListener("resize", onResize);
|
window.removeEventListener("resize", onResize);
|
||||||
visual?.removeEventListener("resize", onResize);
|
visual?.removeEventListener("resize", onResize);
|
||||||
ta?.removeEventListener("focus", onTaFocus);
|
ta?.removeEventListener("focus", onTaFocus);
|
||||||
|
|||||||
+1
-1
@@ -1623,7 +1623,7 @@ input.leaf-rename:focus {
|
|||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 5px;
|
width: 7px;
|
||||||
background: currentColor;
|
background: currentColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user