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 { serverSettingLines, settingRows } from "../model/settings.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 { ComposerMenu } from "./ComposerMenu.tsx";
|
||||
import { ConfirmBar, type Confirmation } from "./ConfirmBar.tsx";
|
||||
@@ -33,6 +34,7 @@ import { useThreadMenu } from "./useThreadMenu.ts";
|
||||
import { editInEditor } from "./editor.ts";
|
||||
import { Palette } from "./Palette.tsx";
|
||||
import { ApprovalPanel } from "./ApprovalPanel.tsx";
|
||||
import { LiveStatus } from "./LiveStatus.tsx";
|
||||
import { QuestionPanel } from "./QuestionPanel.tsx";
|
||||
import { QueuePanel } from "./QueuePanel.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 pendingInput = current?.pending.userInputs[0];
|
||||
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.
|
||||
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} />
|
||||
</box>
|
||||
) : null}
|
||||
{working && threadId && !draft ? <LiveStatus label={liveLabel} tool={liveTool} /> : null}
|
||||
{threadId || draft ? (
|
||||
<box flexDirection="column" flexShrink={0} marginTop={1} marginLeft={1} marginRight={1}>
|
||||
{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 { 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. */
|
||||
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 { 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 { memo, useEffect, useState, type RefObject } from "react";
|
||||
import { findTextSegments } from "../model/search.ts";
|
||||
@@ -84,8 +83,6 @@ export function ThreadView(props: {
|
||||
activeOccurrence={props.findMatch?.entryId === row.id ? props.findMatch.occurrence : null}
|
||||
workspaceRoot={props.workspaceRoot}
|
||||
footer={assistantFooter(row, timeline, props.timestampFormat, props.now)}
|
||||
now={row.kind === "working" ? props.now : 0}
|
||||
workStartedAt={timeline.workStartedAt}
|
||||
onOpenThread={props.onOpenThread}
|
||||
mouse={props.mouse}
|
||||
/>
|
||||
@@ -144,8 +141,7 @@ function Divider({ label, color, onPress }: { readonly label: string; readonly c
|
||||
|
||||
/**
|
||||
* Memoized: computeStableMessagesTimelineRows keeps unchanged rows identical,
|
||||
* so a streamed update re-renders only its own rows. `now` is nonzero only for
|
||||
* the working row, which ticks.
|
||||
* so a streamed update re-renders only its own rows.
|
||||
*/
|
||||
const Row = memo(function Row(props: {
|
||||
readonly row: MessagesTimelineRow;
|
||||
@@ -158,8 +154,6 @@ const Row = memo(function Row(props: {
|
||||
readonly workspaceRoot: string | undefined;
|
||||
/** The turn footer's text for this row, or "" for none. */
|
||||
readonly footer: string;
|
||||
readonly now: number;
|
||||
readonly workStartedAt: string | null;
|
||||
readonly onOpenThread: (threadId: ThreadId) => void;
|
||||
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} />
|
||||
</box>
|
||||
);
|
||||
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 "working":
|
||||
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":
|
||||
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":
|
||||
|
||||
Reference in new issue
Block a user