Live status pinned above the composer
This commit is contained in:
1 parent
3a7c183e1c
commit
bb6d67ec1b
6 files changed
+83
-21
No files matched your search
+10
-1
@@ -17,7 +17,8 @@ import { paletteEntries, paletteGroups, pickerGroups, type Picker, type PickerIt
|
|||||||
import { pullRequestRepository } from "../model/pullRequests.ts";
|
import { pullRequestRepository } from "../model/pullRequests.ts";
|
||||||
import { serverSettingLines, settingRows } from "../model/settings.ts";
|
import { serverSettingLines, settingRows } from "../model/settings.ts";
|
||||||
import { resetCreditOutcome, usageLimits, usageSummaryLines } from "../model/usage.ts";
|
import { resetCreditOutcome, usageLimits, usageSummaryLines } from "../model/usage.ts";
|
||||||
import { buildTimeline, type Timeline } from "../model/timeline.ts";
|
import { buildTimeline, liveWorkEntryLabel, type Timeline } from "../model/timeline.ts";
|
||||||
|
import { formatWorkingDurationLabel } from "@t3tools/client-runtime/state/models";
|
||||||
import { statusLabel, type Section } from "../model/threads.ts";
|
import { statusLabel, type Section } from "../model/threads.ts";
|
||||||
import { ComposerMenu } from "./ComposerMenu.tsx";
|
import { ComposerMenu } from "./ComposerMenu.tsx";
|
||||||
import { ConfirmBar, type Confirmation } from "./ConfirmBar.tsx";
|
import { ConfirmBar, type Confirmation } from "./ConfirmBar.tsx";
|
||||||
@@ -33,6 +34,7 @@ import { useThreadMenu } from "./useThreadMenu.ts";
|
|||||||
import { editInEditor } from "./editor.ts";
|
import { editInEditor } from "./editor.ts";
|
||||||
import { Palette } from "./Palette.tsx";
|
import { Palette } from "./Palette.tsx";
|
||||||
import { ApprovalPanel } from "./ApprovalPanel.tsx";
|
import { ApprovalPanel } from "./ApprovalPanel.tsx";
|
||||||
|
import { LiveStatus } from "./LiveStatus.tsx";
|
||||||
import { QuestionPanel } from "./QuestionPanel.tsx";
|
import { QuestionPanel } from "./QuestionPanel.tsx";
|
||||||
import { QueuePanel } from "./QueuePanel.tsx";
|
import { QueuePanel } from "./QueuePanel.tsx";
|
||||||
import { SecretPanel } from "./SecretPanel.tsx";
|
import { SecretPanel } from "./SecretPanel.tsx";
|
||||||
@@ -254,6 +256,12 @@ export function App(props: { readonly session: T3Session; readonly config: Tui3C
|
|||||||
const pendingApproval = current?.pending.approvals[0];
|
const pendingApproval = current?.pending.approvals[0];
|
||||||
const pendingInput = current?.pending.userInputs[0];
|
const pendingInput = current?.pending.userInputs[0];
|
||||||
const working = current?.isWorking ?? false;
|
const working = current?.isWorking ?? false;
|
||||||
|
// The status line above the composer: the timeline's working/thinking rows live here now.
|
||||||
|
const liveRow = current?.rows.findLast((row) => row.kind === "work-live");
|
||||||
|
const liveTool = liveRow?.kind === "work-live" ? truncate(firstLine(liveWorkEntryLabel(liveRow.entry, threadShell?.worktreePath ?? undefined, liveRow.active)), 60) : null;
|
||||||
|
const liveVerb = current?.rows.some((row) => row.kind === "working" && row.compacting) ? "Compacting" : !liveRow && current?.rows.some((row) => row.kind === "thinking") ? "Thinking" : "Working";
|
||||||
|
const liveSince = current?.workStartedAt ? Date.parse(current.workStartedAt) : NaN;
|
||||||
|
const liveLabel = Number.isFinite(liveSince) ? `${liveVerb} for ${formatWorkingDurationLabel(now - liveSince)}` : `${liveVerb}…`;
|
||||||
|
|
||||||
// A thread opens at its latest message: once its first snapshot renders, jump to the bottom.
|
// A thread opens at its latest message: once its first snapshot renders, jump to the bottom.
|
||||||
const loaded = current !== null;
|
const loaded = current !== null;
|
||||||
@@ -1171,6 +1179,7 @@ export function App(props: { readonly session: T3Session; readonly config: Tui3C
|
|||||||
<Button label="+ file" shortcut="a" onPress={attach.attachFile} />
|
<Button label="+ file" shortcut="a" onPress={attach.attachFile} />
|
||||||
</box>
|
</box>
|
||||||
) : null}
|
) : null}
|
||||||
|
{working && threadId && !draft ? <LiveStatus label={liveLabel} tool={liveTool} /> : null}
|
||||||
{threadId || draft ? (
|
{threadId || draft ? (
|
||||||
<box flexDirection="column" flexShrink={0} marginTop={1} marginLeft={1} marginRight={1}>
|
<box flexDirection="column" flexShrink={0} marginTop={1} marginLeft={1} marginRight={1}>
|
||||||
{pendingApproval && !draft ? (
|
{pendingApproval && !draft ? (
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
import { SPINNER } from "./ThreadList.tsx";
|
||||||
|
import { colors } from "./theme.ts";
|
||||||
|
|
||||||
|
/** The one live status line pinned above the composer while a run is active. */
|
||||||
|
export function LiveStatus(props: { readonly label: string; readonly tool?: string | null }) {
|
||||||
|
const [spin, setSpin] = useState(0);
|
||||||
|
useEffect(() => {
|
||||||
|
const timer = setInterval(() => setSpin((frame) => frame + 1), 100);
|
||||||
|
return () => clearInterval(timer);
|
||||||
|
}, []);
|
||||||
|
return (
|
||||||
|
<box flexDirection="row" flexShrink={0} marginLeft={1} marginRight={1} paddingLeft={2}>
|
||||||
|
<text fg={colors.info} selectable={false}>{SPINNER[spin % SPINNER.length]!}</text>
|
||||||
|
<text fg={colors.muted} selectable={false}>{` ${props.label}`}</text>
|
||||||
|
{props.tool ? <text fg={colors.faint} selectable={false} wrapMode="none">{` · ${props.tool}`}</text> : null}
|
||||||
|
</box>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -8,7 +8,8 @@ import { BAR } from "./edges.ts";
|
|||||||
import { truncate } from "./text.ts";
|
import { truncate } from "./text.ts";
|
||||||
import { colors, statusColor } from "./theme.ts";
|
import { colors, statusColor } from "./theme.ts";
|
||||||
|
|
||||||
const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
/** The braille spinner's frames, for anything that is working. */
|
||||||
|
export const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
||||||
|
|
||||||
/** The 2-column gutter's mark for a row: a spinner while it works, then what it needs from you. */
|
/** The 2-column gutter's mark for a row: a spinner while it works, then what it needs from you. */
|
||||||
function statusGlyph(row: ThreadRow, spin: number): { readonly glyph: string; readonly color: string } {
|
function statusGlyph(row: ThreadRow, spin: number): { readonly glyph: string; readonly color: string } {
|
||||||
|
|||||||
+4
-18
@@ -1,6 +1,5 @@
|
|||||||
import type { MouseEvent, ScrollBoxRenderable } from "@opentui/core";
|
import type { MouseEvent, ScrollBoxRenderable } from "@opentui/core";
|
||||||
import type { ThreadId, TurnItemId } from "@t3tools/contracts";
|
import type { ThreadId, TurnItemId } from "@t3tools/contracts";
|
||||||
import { formatWorkingDurationLabel } from "@t3tools/client-runtime/state/models";
|
|
||||||
import { liveThoughtLine, workEntryDisplayIndicatesToolFailure, type ToolGroupSummaryKind } from "@t3tools/client-runtime/work-log/presentation";
|
import { liveThoughtLine, workEntryDisplayIndicatesToolFailure, type ToolGroupSummaryKind } from "@t3tools/client-runtime/work-log/presentation";
|
||||||
import { memo, useEffect, useState, type RefObject } from "react";
|
import { memo, useEffect, useState, type RefObject } from "react";
|
||||||
import { findTextSegments } from "../model/search.ts";
|
import { findTextSegments } from "../model/search.ts";
|
||||||
@@ -84,8 +83,6 @@ export function ThreadView(props: {
|
|||||||
activeOccurrence={props.findMatch?.entryId === row.id ? props.findMatch.occurrence : null}
|
activeOccurrence={props.findMatch?.entryId === row.id ? props.findMatch.occurrence : null}
|
||||||
workspaceRoot={props.workspaceRoot}
|
workspaceRoot={props.workspaceRoot}
|
||||||
footer={assistantFooter(row, timeline, props.timestampFormat, props.now)}
|
footer={assistantFooter(row, timeline, props.timestampFormat, props.now)}
|
||||||
now={row.kind === "working" ? props.now : 0}
|
|
||||||
workStartedAt={timeline.workStartedAt}
|
|
||||||
onOpenThread={props.onOpenThread}
|
onOpenThread={props.onOpenThread}
|
||||||
mouse={props.mouse}
|
mouse={props.mouse}
|
||||||
/>
|
/>
|
||||||
@@ -144,8 +141,7 @@ function Divider({ label, color, onPress }: { readonly label: string; readonly c
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Memoized: computeStableMessagesTimelineRows keeps unchanged rows identical,
|
* Memoized: computeStableMessagesTimelineRows keeps unchanged rows identical,
|
||||||
* so a streamed update re-renders only its own rows. `now` is nonzero only for
|
* so a streamed update re-renders only its own rows.
|
||||||
* the working row, which ticks.
|
|
||||||
*/
|
*/
|
||||||
const Row = memo(function Row(props: {
|
const Row = memo(function Row(props: {
|
||||||
readonly row: MessagesTimelineRow;
|
readonly row: MessagesTimelineRow;
|
||||||
@@ -158,8 +154,6 @@ const Row = memo(function Row(props: {
|
|||||||
readonly workspaceRoot: string | undefined;
|
readonly workspaceRoot: string | undefined;
|
||||||
/** The turn footer's text for this row, or "" for none. */
|
/** The turn footer's text for this row, or "" for none. */
|
||||||
readonly footer: string;
|
readonly footer: string;
|
||||||
readonly now: number;
|
|
||||||
readonly workStartedAt: string | null;
|
|
||||||
readonly onOpenThread: (threadId: ThreadId) => void;
|
readonly onOpenThread: (threadId: ThreadId) => void;
|
||||||
readonly mouse: ConversationMouse;
|
readonly mouse: ConversationMouse;
|
||||||
}) {
|
}) {
|
||||||
@@ -219,18 +213,10 @@ const Row = memo(function Row(props: {
|
|||||||
<WorkEntry entry={row.entry} expanded={row.expanded} label={liveWorkEntryLabel(row.entry, workspaceRoot, row.active)} onOpenThread={props.onOpenThread} onMenu={mouse.menu} session={props.session} streamCommandOutput={props.streamCommandOutput} scrollRef={props.scrollRef} />
|
<WorkEntry entry={row.entry} expanded={row.expanded} label={liveWorkEntryLabel(row.entry, workspaceRoot, row.active)} onOpenThread={props.onOpenThread} onMenu={mouse.menu} session={props.session} streamCommandOutput={props.streamCommandOutput} scrollRef={props.scrollRef} />
|
||||||
</box>
|
</box>
|
||||||
);
|
);
|
||||||
case "working": {
|
case "working":
|
||||||
const since = props.workStartedAt ? Date.parse(props.workStartedAt) : NaN;
|
|
||||||
const verb = row.compacting ? "Compacting" : "Working";
|
|
||||||
return (
|
|
||||||
<text marginTop={1} fg={colors.muted}>
|
|
||||||
<span fg={colors.info}>◐</span>
|
|
||||||
{Number.isFinite(since) ? ` ${verb} for ${formatWorkingDurationLabel(props.now - since)}` : ` ${verb}…`}
|
|
||||||
</text>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
case "thinking":
|
case "thinking":
|
||||||
return <text marginTop={1} fg={colors.faint}>∴ Thinking…</text>;
|
// The live status line above the composer carries these now.
|
||||||
|
return null;
|
||||||
case "context-compaction":
|
case "context-compaction":
|
||||||
return <Divider label={row.failed ? `${row.title ?? "Compaction failed"}${row.failure ? `: ${row.failure}` : ""}` : (row.title ?? row.label)} color={row.failed ? colors.bad : colors.faint} />;
|
return <Divider label={row.failed ? `${row.title ?? "Compaction failed"}${row.failure ? `: ${row.failure}` : ""}` : (row.title ?? row.label)} color={row.failed ? colors.bad : colors.faint} />;
|
||||||
case "proposed-plan":
|
case "proposed-plan":
|
||||||
|
|||||||
+18
-1
@@ -1,6 +1,6 @@
|
|||||||
import { afterEach, describe, expect, test } from "bun:test";
|
import { afterEach, describe, expect, test } from "bun:test";
|
||||||
|
|
||||||
import { omittedCommand, withApproval, withCompletedTurn, withOmittedOutput, withQuestion } from "./fixtures.ts";
|
import { omittedCommand, withApproval, withCompletedTurn, withOmittedOutput, withQuestion, withWorking } from "./fixtures.ts";
|
||||||
import { loadLayout } from "../../src/layout.ts";
|
import { loadLayout } from "../../src/layout.ts";
|
||||||
import { fakeSession, renderApp, v2ThreadId } from "./harness.tsx";
|
import { fakeSession, renderApp, v2ThreadId } from "./harness.tsx";
|
||||||
|
|
||||||
@@ -163,6 +163,23 @@ describe("a finished turn", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("live status", () => {
|
||||||
|
test("while working, one status line sits above the composer and none in the timeline", async () => {
|
||||||
|
const app = await open({ session: fakeSession({ projection: withWorking() }) });
|
||||||
|
const frame = app.frame();
|
||||||
|
expect(frame).toMatch(/[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏] Working for /);
|
||||||
|
expect(frame.split("Working for")).toHaveLength(2);
|
||||||
|
expect(frame).not.toContain("◐");
|
||||||
|
const lines = frame.split("\n");
|
||||||
|
const status = lines.findIndex((line) => line.includes("Working for"));
|
||||||
|
const composer = lines.findIndex((line) => line.includes("Press i to type"));
|
||||||
|
expect(status).toBeGreaterThan(-1);
|
||||||
|
expect(status).toBeLessThan(composer);
|
||||||
|
// The live tool itself stays a timeline row.
|
||||||
|
expect(frame).toContain("Running bun");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("approvals", () => {
|
describe("approvals", () => {
|
||||||
test("the request shows in the composer's place, with its buttons, and not in the timeline", async () => {
|
test("the request shows in the composer's place, with its buttons, and not in the timeline", async () => {
|
||||||
const app = await open({ session: fakeSession({ projection: withApproval() }) });
|
const app = await open({ session: fakeSession({ projection: withApproval() }) });
|
||||||
|
|||||||
@@ -130,6 +130,35 @@ export function withCompletedTurn(): OrchestrationV2ThreadProjection {
|
|||||||
} as unknown as OrchestrationV2ThreadProjection;
|
} as unknown as OrchestrationV2ThreadProjection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A thread mid-run, with a command under way. */
|
||||||
|
export function withWorking(): OrchestrationV2ThreadProjection {
|
||||||
|
const base = {
|
||||||
|
threadId: v2Projection.thread.id,
|
||||||
|
runId: "run-1",
|
||||||
|
nodeId: null,
|
||||||
|
providerThreadId: null,
|
||||||
|
providerTurnId: null,
|
||||||
|
nativeItemRef: null,
|
||||||
|
parentItemId: null,
|
||||||
|
title: null,
|
||||||
|
};
|
||||||
|
const turnItems = [
|
||||||
|
{ ...base, id: "item-user", ordinal: 0, status: "completed", startedAt: at, completedAt: at, updatedAt: at, type: "user_message", createdBy: "user", creationSource: "web", messageId: "msg-user-1", inputIntent: "turn_start", text: "Run the tests", attachments: [] },
|
||||||
|
{ ...base, id: "item-cmd", ordinal: 1, status: "running", startedAt: after(10), completedAt: null, updatedAt: after(10), type: "command_execution", input: "bun test", output: "" },
|
||||||
|
];
|
||||||
|
return {
|
||||||
|
...v2Projection,
|
||||||
|
runs: [
|
||||||
|
{ id: "run-1", threadId: v2Projection.thread.id, ordinal: 1, providerInstanceId: "codex", modelSelection: { instanceId: "codex", model: "gpt-5.4" }, providerThreadId: null, userMessageId: "msg-user-1", rootNodeId: null, activeAttemptId: null, status: "running", requestedAt: at, startedAt: at, completedAt: null, checkpointId: null, contextHandoffId: null },
|
||||||
|
],
|
||||||
|
messages: [
|
||||||
|
{ createdBy: "user", creationSource: "web", id: "msg-user-1", threadId: v2Projection.thread.id, runId: "run-1", nodeId: null, role: "user", text: "Run the tests", attachments: [], streaming: false, createdAt: at, updatedAt: at },
|
||||||
|
],
|
||||||
|
turnItems,
|
||||||
|
visibleTurnItems: turnItems.map((item, position) => ({ position, visibility: "local", sourceThreadId: v2Projection.thread.id, sourceItemId: item.id, item })),
|
||||||
|
} as unknown as OrchestrationV2ThreadProjection;
|
||||||
|
}
|
||||||
|
|
||||||
export function withOmittedOutput(): OrchestrationV2ThreadProjection {
|
export function withOmittedOutput(): OrchestrationV2ThreadProjection {
|
||||||
return {
|
return {
|
||||||
...v2Projection,
|
...v2Projection,
|
||||||
|
|||||||
Reference in new issue
Block a user