Count the drawer's edge row, let the drawer shrink in the conversation's place, and name clicked files from the workspace

This commit is contained in:
Callum Alpass committed 2026-11-03 08:41:59 +11:00
1 parent 0d7a5cc051
commit 2e531df11b
4 files changed
+44 -6

No files matched your search

+6 -3
View File
@@ -5,6 +5,7 @@ import { ATTACHMENT_ONLY_BOOTSTRAP_PROMPT } from "@t3tools/shared/composerContex
import type { OrchestrationV2ThreadShell, ProviderApprovalDecision, ThreadId, TurnItemId } from "@t3tools/contracts";
import { existsSync, statSync } from "node:fs";
import { homedir } from "node:os";
import { isAbsolute, relative } from "node:path";
import { parseFileUrlHref, resolvePathLinkTarget, splitFilePathPosition } from "@t3tools/shared/fileLinks";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
@@ -614,7 +615,8 @@ export function App(props: { readonly session: T3Session; readonly config: T3tui
const raw = url ? (url.startsWith("file:") ? decodeURIComponent(parseFileUrlHref(url)?.path ?? "") : url) : shown && pathAt(shown.text, shown.index);
if (!raw || !attachCwd) return;
const { path } = splitFilePathPosition(resolvePathLinkTarget(raw, attachCwd));
if (existsSync(path) && statSync(path).isFile()) editFile(path, attachCwd);
const inside = relative(attachCwd, path);
if (existsSync(path) && statSync(path).isFile()) editFile(inside.startsWith("..") || isAbsolute(inside) ? path : inside, attachCwd);
};
const settingsRows = settingRows(config);
@@ -1128,7 +1130,8 @@ export function App(props: { readonly session: T3Session; readonly config: T3tui
const rightColumn = columnVisible && !columnInPlace;
// The drawer leaves the conversation some rows, or takes its place when it can't.
const drawer = placement === "bottom" ? panes.terminal : null;
const drawerRoom = areaHeight - MIN_CONVERSATION_ROWS;
// The edge above it takes a row too.
const drawerRoom = areaHeight - MIN_CONVERSATION_ROWS - 1;
const drawerInPlace = drawer !== null && drawerRoom < MIN_DRAWER_ROWS;
const drawerHeight = Math.max(MIN_DRAWER_ROWS, Math.min(drawerRoom, drawerHeightPref ?? Math.round(areaHeight * DRAWER_SHARE)));
const conversationHidden = (columnVisible && columnInPlace) || drawerInPlace;
@@ -1336,7 +1339,7 @@ export function App(props: { readonly session: T3Session; readonly config: T3tui
}}
/>
)}
<box flexDirection="column" flexShrink={0} minHeight={0} {...(drawerInPlace ? { flexGrow: 1 } : { height: drawerHeight })}>
<box flexDirection="column" minHeight={0} {...(drawerInPlace ? { flexGrow: 1, flexShrink: 1 } : { height: drawerHeight, flexShrink: 0 })}>
{terminalPane}
</box>
</>
+3 -3
View File
@@ -63,7 +63,7 @@ describe("links and paths in replies", () => {
expect(opened()).toEqual(["https://example.com/docs", "https://bare.example.org/x"]);
});
test("a click on a workspace file's path opens it in the editor pane", async () => {
test("a click on a workspace file's path opens it in the column's editor, named from the workspace", async () => {
delete process.env.VISUAL;
process.env.EDITOR = "sleep 3; :";
const { snapshot } = workspace();
@@ -73,8 +73,8 @@ describe("links and paths in replies", () => {
expect(app.frame()).not.toContain("Editing");
const path = app.find("a.ts:3");
await app.click(path.x, path.y);
expect(app.frame()).toContain("Editing ");
expect(app.frame()).toContain("src/a.ts");
expect(app.frame()).toContain("Details Editor");
expect(app.frame()).toContain("Editing src/a.ts ");
});
test("a drag over a link selects it rather than opening it", async () => {
+26
View File
@@ -230,4 +230,30 @@ describe("editing a changed file", () => {
restoreEditor(previous);
}
});
test("on a narrow window the column, editor and all, takes the conversation's place", async () => {
const root = mkdtempSync(join(tmpdir(), "t3tui-edit-"));
writeFileSync(join(root, "README.md"), "hello\n");
const project = { ...v2ShellSnapshot.projects[0]!, workspaceRoot: root };
const previous = { visual: process.env.VISUAL, editor: process.env.EDITOR };
delete process.env.VISUAL;
process.env.EDITOR = "sleep 3; true";
try {
const app = await open({ width: 100, session: fakeSession({ vcs, snapshot: { ...v2ShellSnapshot, projects: [project] }, projection: withReply("The reply under the column.", false) }) });
await app.press("d");
await app.press("l");
await app.press("o");
expect(app.find("Editing README.md").x).toBeLessThan(50);
expect(app.frame()).not.toContain("The reply under");
expect(app.frame()).toContain("Press i to type");
// d hides the column, editor and all, and brings it back with the editor still running.
await app.press("\\", { ctrl: true });
await app.press("d");
expect(app.frame()).toContain("The reply under");
await app.press("d");
expect(app.frame()).toContain("Editing README.md");
} finally {
restoreEditor(previous);
}
});
});
+9
View File
@@ -1,6 +1,7 @@
import { describe, expect, test } from "bun:test";
import { cycleConfig, DEFAULT_CONFIG, formatClock, parseConfig } from "../src/config.ts";
import { DEFAULT_LAYOUT, parseLayout } from "../src/layout.ts";
import { settingRows } from "../src/model/settings.ts";
describe("config", () => {
@@ -32,3 +33,11 @@ describe("config", () => {
expect(rows[0]?.value).toBe("queues");
});
});
describe("layout", () => {
test("keeps the drawer's height and where terminals go, and defaults the rest", () => {
expect(parseLayout({ drawerHeight: 14, terminalPlacement: "side" })).toEqual({ ...DEFAULT_LAYOUT, drawerHeight: 14, terminalPlacement: "side" });
expect(parseLayout({ drawerHeight: -3, terminalPlacement: "left" })).toEqual(DEFAULT_LAYOUT);
expect(parseLayout(null)).toEqual(DEFAULT_LAYOUT);
});
});