Add diffs, git actions, servers, automations and a command palette
- Details rows are actionable: view the working-tree diff (whole or per file), run the web app's git quick action or menu after a confirmation, stop a local server, run or toggle an automation, open lineage threads. - Command palette (ctrl+k or :) searching commands and threads with T3's own scoring. - Subagent work entries link to their child threads; u goes to the parent. - Threads open scrolled to the bottom. - Mouse: thread rows, collapsed sections, details rows, palette, composer. - The / filter opens in the thread list. - Multi-line composer: shift+enter, ctrl+j, or a trailing backslash; it grows to 8 lines. - The credential asks for filesystem:read, source-control:write and terminal:operate, and is reissued when a stored one lacks them.
This commit is contained in:
1 parent
248603d9ae
commit
ed36949fa7
15 files changed
+1235
-192
No files matched your search
+90
-25
@@ -1,29 +1,55 @@
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import type { ThreadDetails } from "../model/details.ts";
|
||||
import { MAX_DETAIL_FILES, type DetailsAction, type ThreadDetails } from "../model/details.ts";
|
||||
import { colors, statusColor } from "./theme.ts";
|
||||
|
||||
/** Files listed under Changes before the rest fold into a count. */
|
||||
const MAX_FILES = 8;
|
||||
/** Rows stay readable when the panel takes the conversation's place on a narrow terminal. */
|
||||
const IN_PLACE_MAX_WIDTH = 64;
|
||||
|
||||
/** The web's thread details card as a right-hand column: workspace, branch and PR, changes, lineage, background work, goal. */
|
||||
export function DetailsPanel(props: { readonly details: ThreadDetails | null; readonly width: number; readonly loading: boolean; readonly inPlace?: boolean }) {
|
||||
/**
|
||||
* The web's thread details card as a right-hand column: workspace, branch and PR, git actions,
|
||||
* changes, lineage, servers, automations, background work, goal. Lines that do something are
|
||||
* selectable with the keyboard and clickable.
|
||||
*/
|
||||
export function DetailsPanel(props: {
|
||||
readonly details: ThreadDetails | null;
|
||||
readonly width: number;
|
||||
readonly loading: boolean;
|
||||
readonly inPlace?: boolean;
|
||||
/** The selected line's action id, while the panel has focus. */
|
||||
readonly selected: string | null;
|
||||
readonly onActivate: (id: string) => void;
|
||||
/** Shown when there are no details, which defaults to no thread being selected. */
|
||||
readonly empty?: string;
|
||||
}) {
|
||||
const { details } = props;
|
||||
// In place of the conversation it sits beside the thread list's border and needs none of its own.
|
||||
const width = props.inPlace ? Math.min(props.width, IN_PLACE_MAX_WIDTH) : props.width;
|
||||
const inner = Math.max(10, width - (props.inPlace ? 3 : 4));
|
||||
return (
|
||||
<box {...(props.inPlace ? {} : { border: ["left"] as const, borderColor: colors.border })} width={width} flexShrink={0} flexDirection="column" paddingLeft={1} paddingRight={1} overflow="hidden">
|
||||
{!details ? <text fg={colors.faint}>No thread selected.</text> : <Sections details={details} inner={inner} loading={props.loading} />}
|
||||
<box
|
||||
{...(props.inPlace ? {} : { border: ["left"] as const, borderColor: props.selected ? colors.borderFocused : colors.border })}
|
||||
width={width}
|
||||
flexShrink={0}
|
||||
flexDirection="column"
|
||||
overflow="hidden"
|
||||
>
|
||||
<scrollbox flexGrow={1} minHeight={0} paddingLeft={1} paddingRight={1}>
|
||||
{!details ? <text fg={colors.faint}>{props.empty ?? "No thread selected."}</text> : <Sections details={details} inner={inner} loading={props.loading} selected={props.selected} onActivate={props.onActivate} />}
|
||||
</scrollbox>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
function Sections({ details, inner, loading }: { readonly details: ThreadDetails; readonly inner: number; readonly loading: boolean }) {
|
||||
const { workspace, branch, changes } = details;
|
||||
interface LineProps {
|
||||
readonly selected: string | null;
|
||||
readonly onActivate: (id: string) => void;
|
||||
}
|
||||
|
||||
function Sections({ details, inner, loading, selected, onActivate }: { readonly details: ThreadDetails; readonly inner: number; readonly loading: boolean } & LineProps) {
|
||||
const { workspace, branch, changes, git } = details;
|
||||
const files = changes?.files ?? [];
|
||||
const line = { selected, onActivate };
|
||||
return (
|
||||
<>
|
||||
<Section title="Workspace" first>
|
||||
@@ -35,7 +61,11 @@ function Sections({ details, inner, loading }: { readonly details: ThreadDetails
|
||||
|
||||
{branch ? (
|
||||
<Section title="Branch">
|
||||
<Line left={truncate(branch.name, inner - (branch.upstream?.length ?? 0) - 1)} right={branch.upstream ?? ""} />
|
||||
<box flexDirection="row">
|
||||
<text fg={colors.text}>{truncate(branch.name, inner - (branch.upstream?.length ?? 0) - 1)}</text>
|
||||
<box flexGrow={1} />
|
||||
<text fg={colors.faint}>{branch.upstream ?? ""}</text>
|
||||
</box>
|
||||
{branch.pullRequest ? (
|
||||
<>
|
||||
<box flexDirection="row">
|
||||
@@ -47,15 +77,21 @@ function Sections({ details, inner, loading }: { readonly details: ThreadDetails
|
||||
{branch.pullRequest.title ? <text fg={colors.muted}>{truncate(branch.pullRequest.title, inner)}</text> : null}
|
||||
</>
|
||||
) : null}
|
||||
{git?.quick ? <Selectable id={`git:quick:${git.quick.action}`} {...line} color={colors.accent} text={`▸ ${git.quick.label}`} inner={inner} /> : null}
|
||||
{git?.menu.map((item) => <Selectable key={item.action} id={`git:${item.action}`} {...line} color={colors.muted} text={` ${item.label}`} inner={inner} />)}
|
||||
{git && !git.quick && git.hint ? <text fg={colors.faint}>{truncate(git.hint, inner)}</text> : null}
|
||||
</Section>
|
||||
) : null}
|
||||
|
||||
{changes ? (
|
||||
<Section title="Changes" right={<Counts insertions={changes.insertions} deletions={changes.deletions} />}>
|
||||
{files.slice(0, MAX_FILES).map((file) => (
|
||||
<FileLine key={file.path} path={file.path} insertions={file.insertions} deletions={file.deletions} inner={inner} />
|
||||
{files.length > 0 ? <Selectable id="diff:*" {...line} color={colors.accent} text="▸ View diff" inner={inner} /> : null}
|
||||
{files.slice(0, MAX_DETAIL_FILES).map((file) => (
|
||||
<Selectable key={file.path} id={`diff:${file.path}`} {...line} inner={inner}>
|
||||
<FileLine path={file.path} insertions={file.insertions} deletions={file.deletions} inner={inner} />
|
||||
</Selectable>
|
||||
))}
|
||||
{files.length > MAX_FILES ? <text fg={colors.faint}>{`… ${files.length - MAX_FILES} more files`}</text> : null}
|
||||
{files.length > MAX_DETAIL_FILES ? <text fg={colors.faint}>{`… ${files.length - MAX_DETAIL_FILES} more files (in the full diff)`}</text> : null}
|
||||
{files.length === 0 ? <text fg={colors.faint}>Working tree clean</text> : null}
|
||||
{changes.branchTotal ? (
|
||||
<box flexDirection="row">
|
||||
@@ -74,8 +110,37 @@ function Sections({ details, inner, loading }: { readonly details: ThreadDetails
|
||||
|
||||
{details.lineage.length > 0 ? (
|
||||
<Section title="Lineage">
|
||||
{details.lineage.map((entry) => (
|
||||
<text key={entry.text} fg={colors.muted}>{truncate(`${entry.glyph} ${entry.text}`, inner)}</text>
|
||||
{details.lineage.map((entry) =>
|
||||
entry.threadId ? (
|
||||
<Selectable key={entry.threadId} id={`thread:${entry.threadId}`} {...line} color={colors.muted} text={`${entry.glyph} ${entry.text}`} inner={inner} />
|
||||
) : (
|
||||
<text key={entry.text} fg={colors.muted}>{truncate(`${entry.glyph} ${entry.text}`, inner)}</text>
|
||||
),
|
||||
)}
|
||||
</Section>
|
||||
) : null}
|
||||
|
||||
{details.servers.length > 0 ? (
|
||||
<Section title="Servers">
|
||||
{details.servers.map(({ server, label }) => (
|
||||
<Selectable key={server.port} id={`server:${server.port}`} {...line} color={colors.info} text={`● ${label}`} inner={inner} />
|
||||
))}
|
||||
</Section>
|
||||
) : null}
|
||||
|
||||
{details.automations.length > 0 ? (
|
||||
<Section title="Automations">
|
||||
{details.automations.map((automation) => (
|
||||
<Selectable key={automation.task.id} id={`automation:${automation.task.id}`} {...line} inner={inner}>
|
||||
<box flexDirection="column">
|
||||
<text fg={colors.text}>{truncate(automation.task.title, inner)}</text>
|
||||
<box flexDirection="row">
|
||||
<text fg={colors.faint}>{truncate(automation.schedule, inner - automation.status.length - 1)}</text>
|
||||
<box flexGrow={1} />
|
||||
<text fg={statusColor[automation.tone]}>{automation.status}</text>
|
||||
</box>
|
||||
</box>
|
||||
</Selectable>
|
||||
))}
|
||||
</Section>
|
||||
) : null}
|
||||
@@ -98,6 +163,16 @@ function Sections({ details, inner, loading }: { readonly details: ThreadDetails
|
||||
);
|
||||
}
|
||||
|
||||
/** A line that does something: highlighted when selected, activated by a click. */
|
||||
function Selectable(props: LineProps & { readonly id: DetailsAction["id"]; readonly inner: number; readonly text?: string; readonly color?: string; readonly children?: ReactNode }) {
|
||||
const active = props.selected === props.id;
|
||||
return (
|
||||
<box backgroundColor={active ? colors.selectedBg : "transparent"} onMouseDown={() => props.onActivate(props.id)}>
|
||||
{props.children ?? <text fg={active ? colors.text : (props.color ?? colors.muted)}>{truncate(props.text ?? "", props.inner)}</text>}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
function Section(props: { readonly title: string; readonly right?: ReactNode; readonly first?: boolean; readonly children: ReactNode }) {
|
||||
return (
|
||||
<box flexDirection="column" marginTop={props.first ? 0 : 1} flexShrink={0}>
|
||||
@@ -113,16 +188,6 @@ function Section(props: { readonly title: string; readonly right?: ReactNode; re
|
||||
);
|
||||
}
|
||||
|
||||
function Line({ left, right }: { readonly left: string; readonly right: string }) {
|
||||
return (
|
||||
<box flexDirection="row">
|
||||
<text fg={colors.text}>{left}</text>
|
||||
<box flexGrow={1} />
|
||||
<text fg={colors.faint}>{right}</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
function FileLine(props: { readonly path: string; readonly insertions: number; readonly deletions: number; readonly inner: number }) {
|
||||
const counts = countsText(props.insertions, props.deletions);
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user