Details, palette and settings in the same treatment

Panels without dividers or rounded borders: bold titles, muted bodies, the selected row's accent bar over the full width. The in-place details panel now takes its column's height instead of spilling over the composer.
This commit is contained in:
Callum Alpass committed 2026-11-02 23:58:19 +11:00
1 parent 0d59ec0fd3
commit 2653209b14
3 files changed
+50 -31

No files matched your search

+22 -13
View File
@@ -25,16 +25,20 @@ export function DetailsPanel(props: {
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));
// A column of padding on each side, and one more for the scrollbox's scrollbar.
const inner = Math.max(10, width - 3);
return (
<box
{...(props.inPlace ? {} : { border: ["left"] as const, borderColor: props.selected ? colors.borderFocused : colors.border })}
width={width}
flexShrink={0}
// In place of the conversation the panel must take its column's height, or its
// scrollbox grows with its content and spills over the composer below.
flexGrow={props.inPlace ? 1 : 0}
flexShrink={props.inPlace ? 1 : 0}
minHeight={0}
flexDirection="column"
overflow="hidden"
backgroundColor={colors.panel}
>
<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} />}
@@ -55,7 +59,7 @@ function Sections({ details, inner, loading, selected, onActivate }: { readonly
return (
<>
<Section title="Workspace" first>
<text fg={colors.text}>{startTruncate(workspace.path, inner)}</text>
<text fg={colors.muted}>{startTruncate(workspace.path, inner)}</text>
{workspace.worktree ? <text fg={colors.faint}>worktree</text> : null}
<text fg={colors.muted}>{truncate(workspace.model, inner)}</text>
{workspace.mode ? <text fg={colors.muted}>{truncate(workspace.mode, inner)}</text> : null}
@@ -64,14 +68,14 @@ function Sections({ details, inner, loading, selected, onActivate }: { readonly
{branch ? (
<Section title="Branch">
<box flexDirection="row">
<text fg={colors.text}>{truncate(branch.name, inner - (branch.upstream?.length ?? 0) - 1)}</text>
<text fg={colors.muted}>{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">
<text fg={colors.text}>{`PR #${branch.pullRequest.number} `}</text>
<text fg={colors.muted}>{`PR #${branch.pullRequest.number} `}</text>
<text fg={statusColor(branch.pullRequest.tone)}>{branch.pullRequest.state}</text>
<box flexGrow={1} />
{branch.pullRequest.checks ? <text fg={statusColor(branch.pullRequest.checks.tone)}>{branch.pullRequest.checks.text}</text> : null}
@@ -135,7 +139,7 @@ function Sections({ details, inner, loading, selected, onActivate }: { readonly
{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>
<text fg={colors.muted}>{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} />
@@ -157,7 +161,7 @@ function Sections({ details, inner, loading, selected, onActivate }: { readonly
{details.goal ? (
<Section title="Goal">
<text fg={colors.text}>{details.goal.objective}</text>
<text fg={colors.muted}>{details.goal.objective}</text>
<text fg={statusColor(details.goal.tone)}>{details.goal.status}</text>
</Section>
) : null}
@@ -165,12 +169,17 @@ function Sections({ details, inner, loading, selected, onActivate }: { readonly
);
}
/** A line that does something: highlighted when selected, activated by a click. */
/**
* A line that does something: highlighted when selected, activated by a click. The negative
* margins pull the row over the panel's padding, so the selection bar sits at the panel's
* edge and its background runs the full width, as in the thread list.
*/
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 (
<ClickRow selected={active} onPress={() => props.onActivate(props.id)}>
{props.children ?? <text fg={active ? colors.text : (props.color ?? colors.muted)}>{truncate(props.text ?? "", props.inner)}</text>}
<ClickRow flexDirection="row" marginLeft={-1} marginRight={-1} paddingRight={1} selected={active} onPress={() => props.onActivate(props.id)}>
<text fg={colors.accent} flexShrink={0} selectable={false}>{active ? "▌" : " "}</text>
{props.children ? <box flexGrow={1} flexDirection="column">{props.children}</box> : <text fg={active ? colors.text : (props.color ?? colors.muted)}>{truncate(props.text ?? "", props.inner)}</text>}
</ClickRow>
);
}
@@ -179,7 +188,7 @@ function Section(props: { readonly title: string; readonly right?: ReactNode; re
return (
<box flexDirection="column" marginTop={props.first ? 0 : 1} flexShrink={0}>
<box flexDirection="row">
<text fg={colors.muted}>
<text fg={colors.text}>
<strong>{props.title}</strong>
</text>
<box flexGrow={1} />
+12 -11
View File
@@ -2,6 +2,7 @@ import type { PaletteEntry, PaletteGroup } from "../model/palette.ts";
import type { MouseEvent } from "@opentui/core";
import { ClickRow, wheelStep } from "./Button.tsx";
import { BAR } from "./edges.ts";
import { truncate } from "./text.ts";
import { colors } from "./theme.ts";
@@ -35,20 +36,19 @@ export function Palette(props: {
}
const selectedRow = rows.findIndex((row) => row.kind === "entry" && row.index === props.selected);
const start = Math.max(0, Math.min(selectedRow - Math.floor(listHeight / 2), rows.length - listHeight));
const inner = width - 4;
const inner = width - 3;
return (
<box position="absolute" top={2} left={Math.floor((props.width - width) / 2)} width={width} zIndex={10} flexDirection="column" border borderStyle="rounded" borderColor={colors.borderFocused} backgroundColor={colors.panel}>
<box paddingLeft={1} paddingRight={1} height={1} flexDirection="row">
<text fg={colors.accent}>{"› "}</text>
<input focused flexGrow={1} placeholder={props.placeholder ?? "Search commands and threads (> for commands only)"} value={props.query} onInput={props.onQuery} onSubmit={props.onSubmit} backgroundColor={colors.panel} focusedBackgroundColor={colors.panel} />
<box position="absolute" top={2} left={Math.floor((props.width - width) / 2)} width={width} zIndex={10} flexDirection="column" paddingLeft={1} paddingRight={1} paddingTop={1} paddingBottom={1} backgroundColor={colors.panel}>
<box border={["left"]} customBorderChars={BAR} borderColor={colors.accent} backgroundColor={colors.element} height={1} flexDirection="row" flexShrink={0}>
<input focused flexGrow={1} placeholder={props.placeholder ?? "Search commands and threads (> for commands only)"} value={props.query} onInput={props.onQuery} onSubmit={props.onSubmit} backgroundColor={colors.element} focusedBackgroundColor={colors.element} />
</box>
{props.status ? <text fg={colors.muted} paddingLeft={1}>{props.status}</text> : null}
<box border={["top"]} borderColor={colors.border} flexDirection="column" height={listHeight + 1} onMouseScroll={(event: MouseEvent) => { const step = wheelStep(event); if (step) props.onMove(step); }}>
{rows.length === 0 ? <text fg={colors.muted} paddingLeft={1}>No matches</text> : null}
{props.status ? <text fg={colors.muted}>{props.status}</text> : null}
<box flexDirection="column" height={listHeight} marginTop={1} onMouseScroll={(event: MouseEvent) => { const step = wheelStep(event); if (step) props.onMove(step); }}>
{rows.length === 0 ? <text fg={colors.muted}>No matches</text> : null}
{rows.slice(start, start + listHeight).map((row) =>
row.kind === "header" ? (
<text key={row.key} fg={colors.faint} paddingLeft={1}>
{row.label}
<text key={row.key} fg={colors.faint}>
<strong>{row.label}</strong>
</text>
) : (
<Row key={entryKey(row.entry)} entry={row.entry} selected={row.index === props.selected} inner={inner} onPick={() => props.onPick(row.index)} />
@@ -64,7 +64,8 @@ function Row(props: { readonly entry: PaletteEntry; readonly selected: boolean;
const right = entry.kind === "command" ? (entry.command.shortcut ?? "") : entry.project;
const title = entry.kind === "command" ? entry.command.title : `${entry.subagent ? "↳ " : ""}${entry.snippet ? truncate(entry.title, Math.max(12, Math.floor(props.inner / 3))) : entry.title}${entry.snippet ? ` — ${entry.snippet}` : ""}`;
return (
<ClickRow flexDirection="row" paddingLeft={1} paddingRight={1} selected={props.selected} onPress={props.onPick}>
<ClickRow flexDirection="row" selected={props.selected} onPress={props.onPick}>
<text fg={colors.accent} flexShrink={0} selectable={false}>{props.selected ? "▌" : " "}</text>
<text fg={props.selected ? colors.text : entry.kind === "command" ? colors.text : colors.muted}>{truncate(title, props.inner - right.length - 2)}</text>
<box flexGrow={1} />
<text fg={colors.faint}>{right}</text>
+16 -7
View File
@@ -24,31 +24,40 @@ export function SettingsView(props: {
<box flexGrow={1} />
<text fg={colors.faint}>esc close</text>
</box>
<text fg={colors.faint} marginTop={1}>{`tui3 · ${props.path}`}</text>
<text fg={colors.text} marginTop={1}>
<strong>{`tui3 · ${props.path}`}</strong>
</text>
{props.rows.map((row, index) => {
const selected = index === props.selected;
return (
<ClickRow key={row.key} flexDirection="row" height={1} selected={selected} onPress={() => props.onCycle(index)}>
<text fg={colors.muted} flexShrink={0}>{`${selected ? "▸ " : " "}${row.label.padEnd(labelWidth)}`}</text>
<text fg={colors.text} flexShrink={0}>{row.value}</text>
<text fg={colors.accent} flexShrink={0} selectable={false}>{selected ? "▌" : " "}</text>
<text fg={colors.muted} flexShrink={0}>{` ${row.label.padEnd(labelWidth)}`}</text>
<text fg={selected ? colors.text : colors.muted} flexShrink={0}>{row.value}</text>
<text fg={colors.faint} wrapMode="none">{` ${row.help}`}</text>
</ClickRow>
);
})}
<text fg={colors.faint} marginTop={1}>T3 Code · change these in the app</text>
<text fg={colors.text} marginTop={1}>
<strong>T3 Code · change these in the app</strong>
</text>
{props.serverStatus === "loading" ? <text fg={colors.muted}> Loading…</text> : null}
{props.serverStatus === "error" ? <text fg={colors.bad}> Could not read the server's settings.</text> : null}
{props.server.map((line) => (
<box key={line.label} flexDirection="row" height={1}>
<text fg={colors.muted} flexShrink={0}>{` ${line.label.padEnd(labelWidth)}`}</text>
<text fg={colors.text}>{line.value}</text>
<text fg={colors.muted}>{line.value}</text>
</box>
))}
{usage.length > 0 ? <text fg={colors.faint} marginTop={1}>Usage</text> : null}
{usage.length > 0 ? (
<text fg={colors.text} marginTop={1}>
<strong>Usage</strong>
</text>
) : null}
{usage.map((line) => (
<box key={`${line.label}:${line.value}`} flexDirection="row" height={1}>
<text fg={colors.muted} flexShrink={0}>{` ${line.label.padEnd(labelWidth)}`}</text>
<text fg={colors.text}>{line.value}</text>
<text fg={colors.muted}>{line.value}</text>
</box>
))}
</box>