Let the conversation use the whole width of the window
Prose stopped at 100 columns however wide the terminal was. Remove that cap. Work labels and changed files were cut to fit it too, so they now use the text's own truncation, which follows the real width. Images keep their limit of 100 columns by 12 rows.
This commit is contained in:
1 parent
1856b80f39
commit
e519b65d04
2 files changed
+15
-14
No files matched your search
+7
-13
@@ -17,7 +17,7 @@ import { BAR } from "./edges.ts";
|
|||||||
import type { T3Session, ThreadHistory } from "../client/session.ts";
|
import type { T3Session, ThreadHistory } from "../client/session.ts";
|
||||||
import { liveWorkEntryLabel, workEntryDisplayLabel, type MessagesTimelineRow, type Timeline, type WorkLogEntry } from "../model/timeline.ts";
|
import { liveWorkEntryLabel, workEntryDisplayLabel, type MessagesTimelineRow, type Timeline, type WorkLogEntry } from "../model/timeline.ts";
|
||||||
import { blockFor } from "../model/transcript.ts";
|
import { blockFor } from "../model/transcript.ts";
|
||||||
import { firstLine, truncate } from "./text.ts";
|
import { firstLine } from "./text.ts";
|
||||||
import { colors, scrollbarOptions, toneColor, useMarkdownStyle } from "./theme.ts";
|
import { colors, scrollbarOptions, toneColor, useMarkdownStyle } from "./theme.ts";
|
||||||
|
|
||||||
/** What a right-click in the conversation was on. */
|
/** What a right-click in the conversation was on. */
|
||||||
@@ -39,9 +39,6 @@ export interface ConversationMouse {
|
|||||||
readonly click: (x: number, y: number) => void;
|
readonly click: (x: number, y: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Prose stops at this width on wide terminals, left-aligned. */
|
|
||||||
const CONTENT_WIDTH = 100;
|
|
||||||
|
|
||||||
/** The conversation, row for row as the web app derives it (MessagesTimeline.logic). */
|
/** The conversation, row for row as the web app derives it (MessagesTimeline.logic). */
|
||||||
export function ThreadView(props: {
|
export function ThreadView(props: {
|
||||||
readonly timeline: Timeline | null;
|
readonly timeline: Timeline | null;
|
||||||
@@ -75,8 +72,7 @@ export function ThreadView(props: {
|
|||||||
) : null}
|
) : null}
|
||||||
{props.error ? <text fg={colors.bad} flexShrink={0}>{props.error}</text> : null}
|
{props.error ? <text fg={colors.bad} flexShrink={0}>{props.error}</text> : null}
|
||||||
<scrollbox ref={props.scrollRef} flexGrow={1} flexShrink={1} minHeight={0} stickyScroll stickyStart="bottom" scrollbarOptions={scrollbarOptions()}>
|
<scrollbox ref={props.scrollRef} flexGrow={1} flexShrink={1} minHeight={0} stickyScroll stickyStart="bottom" scrollbarOptions={scrollbarOptions()}>
|
||||||
{/* Prose stops at reading width on wide terminals; the composer below stays full width. */}
|
<box flexDirection="column">
|
||||||
<box flexDirection="column" maxWidth={CONTENT_WIDTH}>
|
|
||||||
{props.loading && !timeline ? <text fg={colors.muted}>Loading…</text> : null}
|
{props.loading && !timeline ? <text fg={colors.muted}>Loading…</text> : null}
|
||||||
{history?.hasMore || history?.error ? <LoadEarlier history={history} onLoad={props.mouse.loadEarlier} /> : null}
|
{history?.hasMore || history?.error ? <LoadEarlier history={history} onLoad={props.mouse.loadEarlier} /> : null}
|
||||||
{timeline?.rows.filter((row) => !isPendingApprovalRow(row, pendingIds)).map((row) => (
|
{timeline?.rows.filter((row) => !isPendingApprovalRow(row, pendingIds)).map((row) => (
|
||||||
@@ -284,10 +280,9 @@ function ChangedFiles({ summary, onOpenTurnDiff }: { readonly summary: ThreadChe
|
|||||||
|
|
||||||
function ChangedFile({ path, additions, deletions, onPress }: { readonly path: string; readonly additions: number; readonly deletions: number; readonly onPress: () => void }) {
|
function ChangedFile({ path, additions, deletions, onPress }: { readonly path: string; readonly additions: number; readonly deletions: number; readonly onPress: () => void }) {
|
||||||
const [hover, hoverProps] = useHover();
|
const [hover, hoverProps] = useHover();
|
||||||
const counts = (additions > 0 ? `+${additions}`.length : 0) + (deletions > 0 ? `−${deletions}`.length : 0) + (additions > 0 && deletions > 0 ? 1 : 0);
|
|
||||||
return (
|
return (
|
||||||
<box flexDirection="row" {...hoverProps} onMouseDown={(event: MouseEvent) => isLeftClick(event) && onPress()}>
|
<box flexDirection="row" {...hoverProps} onMouseDown={(event: MouseEvent) => isLeftClick(event) && onPress()}>
|
||||||
<text fg={hover ? colors.text : colors.muted} selectable={false} wrapMode="none">{truncate(path, CONTENT_WIDTH - 2 - (counts ? counts + 2 : 0))}</text>
|
<text fg={hover ? colors.text : colors.muted} flexShrink={1} selectable={false} wrapMode="none" truncate>{path}</text>
|
||||||
<box flexGrow={1} />
|
<box flexGrow={1} />
|
||||||
<DiffCounts additions={additions} deletions={deletions} />
|
<DiffCounts additions={additions} deletions={deletions} />
|
||||||
</box>
|
</box>
|
||||||
@@ -326,13 +321,14 @@ function UserMessage({ session, text, attachments, messageId, selected, onSelect
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const IMAGE_COLUMNS = 100;
|
||||||
const IMAGE_ROWS = 12;
|
const IMAGE_ROWS = 12;
|
||||||
|
|
||||||
/** A sent image, shown in the terminal's best image protocol; its name alone until it loads, or if it can't. */
|
/** A sent image, shown in the terminal's best image protocol; its name alone until it loads, or if it can't. */
|
||||||
function MessageImage({ session, attachment }: { readonly session: T3Session; readonly attachment: ChatAttachment }) {
|
function MessageImage({ session, attachment }: { readonly session: T3Session; readonly attachment: ChatAttachment }) {
|
||||||
const [bytes, setBytes] = useState<Uint8Array | null>(null);
|
const [bytes, setBytes] = useState<Uint8Array | null>(null);
|
||||||
const [failed, setFailed] = useState(false);
|
const [failed, setFailed] = useState(false);
|
||||||
const [size, setSize] = useState({ width: CONTENT_WIDTH, height: IMAGE_ROWS });
|
const [size, setSize] = useState({ width: IMAGE_COLUMNS, height: IMAGE_ROWS });
|
||||||
const image = useRef<ImageRenderable | null>(null);
|
const image = useRef<ImageRenderable | null>(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
@@ -356,7 +352,7 @@ function MessageImage({ session, attachment }: { readonly session: T3Session; re
|
|||||||
width={size.width}
|
width={size.width}
|
||||||
maxWidth="100%"
|
maxWidth="100%"
|
||||||
height={size.height}
|
height={size.height}
|
||||||
onLoad={() => image.current && setSize(image.current.getFittedSize(CONTENT_WIDTH, IMAGE_ROWS))}
|
onLoad={() => image.current && setSize(image.current.getFittedSize(IMAGE_COLUMNS, IMAGE_ROWS))}
|
||||||
onError={() => setFailed(true)}
|
onError={() => setFailed(true)}
|
||||||
/>
|
/>
|
||||||
{name}
|
{name}
|
||||||
@@ -388,12 +384,10 @@ function OmittedOutput({ session, source }: { readonly session: T3Session; reado
|
|||||||
|
|
||||||
/** One work/tool line, everywhere the same: glyph, label, result details right-aligned. */
|
/** One work/tool line, everywhere the same: glyph, label, result details right-aligned. */
|
||||||
function WorkLine(props: { readonly glyph: string; readonly glyphColor: string; readonly label: string; readonly labelColor: string; readonly detail?: string; readonly selectable?: boolean }) {
|
function WorkLine(props: { readonly glyph: string; readonly glyphColor: string; readonly label: string; readonly labelColor: string; readonly detail?: string; readonly selectable?: boolean }) {
|
||||||
// The label gives up whatever the right-hand details take, within the reading width.
|
|
||||||
const label = truncate(props.label, CONTENT_WIDTH - 2 - (props.detail ? props.detail.length + 2 : 0));
|
|
||||||
return (
|
return (
|
||||||
<box flexDirection="row" width="100%">
|
<box flexDirection="row" width="100%">
|
||||||
<text fg={props.glyphColor} flexShrink={0} selectable={false}>{`${props.glyph} `}</text>
|
<text fg={props.glyphColor} flexShrink={0} selectable={false}>{`${props.glyph} `}</text>
|
||||||
<text fg={props.labelColor} flexShrink={1} wrapMode="none" selectable={props.selectable ?? false}>{label}</text>
|
<text fg={props.labelColor} flexShrink={1} wrapMode="none" truncate selectable={props.selectable ?? false}>{props.label.replace(/\s+/g, " ")}</text>
|
||||||
{props.detail ? (
|
{props.detail ? (
|
||||||
<>
|
<>
|
||||||
<box flexGrow={1} />
|
<box flexGrow={1} />
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { afterEach, describe, expect, test } from "bun:test";
|
import { afterEach, describe, expect, test } from "bun:test";
|
||||||
import type { OrchestrationV2ThreadProjection } from "@t3tools/contracts";
|
import type { OrchestrationV2ThreadProjection } from "@t3tools/contracts";
|
||||||
|
|
||||||
import { omittedCommand, withApproval, withCompletedTurn, withOmittedOutput, withQuestion, withWorking } from "./fixtures.ts";
|
import { omittedCommand, withApproval, withCompletedTurn, withOmittedOutput, withQuestion, withReply, withWorking } from "./fixtures.ts";
|
||||||
import { loadLayout } from "../../src/layout.ts";
|
import { loadLayout } from "../../src/layout.ts";
|
||||||
import { fakeSession, renderApp, v2Projection, v2ThreadId } from "./harness.tsx";
|
import { fakeSession, renderApp, v2Projection, v2ThreadId } from "./harness.tsx";
|
||||||
|
|
||||||
@@ -151,6 +151,13 @@ describe("palette and pickers", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("a finished turn", () => {
|
describe("a finished turn", () => {
|
||||||
|
test("the conversation uses the whole width of a wide window", async () => {
|
||||||
|
const reply = Array.from({ length: 20 }, (_, index) => `word${index}`).join(" ");
|
||||||
|
const app = await open({ width: 240, height: 30, session: fakeSession({ projection: withReply(reply, false) }) });
|
||||||
|
const line = app.frame().split("\n").find((text) => text.includes("word0 "))!;
|
||||||
|
expect(line).toContain("word19");
|
||||||
|
});
|
||||||
|
|
||||||
test("its changed files fold out under the reply, and a file opens the turn's diff", async () => {
|
test("its changed files fold out under the reply, and a file opens the turn's diff", async () => {
|
||||||
const patch = "diff --git a/src/index.ts b/src/index.ts\n--- a/src/index.ts\n+++ b/src/index.ts\n@@ -1 +1 @@\n-old\n+new\n";
|
const patch = "diff --git a/src/index.ts b/src/index.ts\n--- a/src/index.ts\n+++ b/src/index.ts\n@@ -1 +1 @@\n-old\n+new\n";
|
||||||
const app = await open({ session: fakeSession({ projection: withCompletedTurn(), results: { turnDiff: { diff: patch } } }) });
|
const app = await open({ session: fakeSession({ projection: withCompletedTurn(), results: { turnDiff: { diff: patch } } }) });
|
||||||
|
|||||||
Reference in new issue
Block a user