Hide the thread list with B; both side panels' visibility kept across runs
This commit is contained in:
1 parent
ae1068a1ac
commit
e2d2892c52
5 files changed
+59
-11
No files matched your search
+3
-2
@@ -57,7 +57,8 @@ Navigation:
|
|||||||
| `f` | find in the open thread; `enter` / `shift+enter` or `ctrl+n` / `ctrl+p` move between matches, `esc` closes |
|
| `f` | find in the open thread; `enter` / `shift+enter` or `ctrl+n` / `ctrl+p` move between matches, `esc` closes |
|
||||||
| `A` | show archived threads / return to active threads |
|
| `A` | show archived threads / return to active threads |
|
||||||
| `J` / `K` | move the selected pinned thread down / up |
|
| `J` / `K` | move the selected pinned thread down / up |
|
||||||
| `d` | show or hide thread details |
|
| `d` | show or hide thread details (kept for the next run) |
|
||||||
|
| `B` | hide or show the thread list (kept for the next run) |
|
||||||
| `P` | show the thread's linked pull request |
|
| `P` | show the thread's linked pull request |
|
||||||
| `l` / `→` | move into the details panel: `j`/`k` choose, `enter` opens, `t` turns an automation on or off, `esc` comes back |
|
| `l` / `→` | move into the details panel: `j`/`k` choose, `enter` opens, `t` turns an automation on or off, `esc` comes back |
|
||||||
| `u` | go to the parent thread (from a fork or subagent) |
|
| `u` | go to the parent thread (from a fork or subagent) |
|
||||||
@@ -114,7 +115,7 @@ The layout follows T3 Code's web app, and much of it uses the web app's own code
|
|||||||
- **Buttons:** approvals, questions (click an option), secret requests, confirmations, queued messages (click one to send it now, edit or remove it), attached files (✕ removes one) and the PR view have buttons, each with its key beside it. Every hint along the bottom that names one key is clickable, and so is `commands` at the top.
|
- **Buttons:** approvals, questions (click an option), secret requests, confirmations, queued messages (click one to send it now, edit or remove it), attached files (✕ removes one) and the PR view have buttons, each with its key beside it. Every hint along the bottom that names one key is clickable, and so is `commands` at the top.
|
||||||
- **Conversation:** a click on a prompt selects that turn, as `[`/`]` do; a click on a folded turn or work group opens just that one; a click on a command shows its output; "Load earlier turns" loads them. In a diff, a click on a file selects it and a second click shows the whole file. In the PR view, the URL opens in the browser.
|
- **Conversation:** a click on a prompt selects that turn, as `[`/`]` do; a click on a folded turn or work group opens just that one; a click on a command shows its output; "Load earlier turns" loads them. In a diff, a click on a file selects it and a second click shows the whole file. In the PR view, the URL opens in the browser.
|
||||||
- **Right-click menus:** on a thread (its actions), a prompt (copy, view its changes, revert), a reply (copy), a command (copy the command or its output) and the PR view (its actions).
|
- **Right-click menus:** on a thread (its actions), a prompt (copy, view its changes, revert), a reply (copy), a command (copy the command or its output) and the PR view (its actions).
|
||||||
- **Panes:** clicking the conversation takes the keys out of the message box or details; clicking the message box types. The wheel scrolls the conversation, the thread list (without moving the selection) and the palette. Drag the thread list's right edge to resize it; right-click the edge to reset it.
|
- **Panes:** clicking the conversation takes the keys out of the message box or details; clicking the message box types. The wheel scrolls the conversation, the thread list (without moving the selection) and the palette. Drag the thread list's right edge, or the details column's left edge, to resize it; right-click the edge to reset it.
|
||||||
|
|
||||||
## Thread actions
|
## Thread actions
|
||||||
|
|
||||||
|
|||||||
+11
-2
@@ -12,9 +12,13 @@ export interface Layout {
|
|||||||
readonly listWidth: number | null;
|
readonly listWidth: number | null;
|
||||||
/** The details column's width once its border is dragged; null is the default width. */
|
/** The details column's width once its border is dragged; null is the default width. */
|
||||||
readonly detailsWidth: number | null;
|
readonly detailsWidth: number | null;
|
||||||
|
/** The thread list hidden with `b`. */
|
||||||
|
readonly listHidden: boolean;
|
||||||
|
/** The details column shown or hidden with `d`; null follows the window's width. */
|
||||||
|
readonly details: boolean | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_LAYOUT: Layout = { listWidth: null, detailsWidth: null };
|
export const DEFAULT_LAYOUT: Layout = { listWidth: null, detailsWidth: null, listHidden: false, details: null };
|
||||||
|
|
||||||
const layoutPath = () => join(configDir(), "layout.json");
|
const layoutPath = () => join(configDir(), "layout.json");
|
||||||
|
|
||||||
@@ -29,7 +33,12 @@ export async function loadLayout(): Promise<Layout> {
|
|||||||
|
|
||||||
export function parseLayout(raw: unknown): Layout {
|
export function parseLayout(raw: unknown): Layout {
|
||||||
const record = raw && typeof raw === "object" ? (raw as Record<string, unknown>) : {};
|
const record = raw && typeof raw === "object" ? (raw as Record<string, unknown>) : {};
|
||||||
return { listWidth: positiveInteger(record.listWidth), detailsWidth: positiveInteger(record.detailsWidth) };
|
return {
|
||||||
|
listWidth: positiveInteger(record.listWidth),
|
||||||
|
detailsWidth: positiveInteger(record.detailsWidth),
|
||||||
|
listHidden: record.listHidden === true,
|
||||||
|
details: typeof record.details === "boolean" ? record.details : null,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const positiveInteger = (value: unknown) => (typeof value === "number" && Number.isInteger(value) && value > 0 ? value : null);
|
const positiveInteger = (value: unknown) => (typeof value === "number" && Number.isInteger(value) && value > 0 ? value : null);
|
||||||
|
|||||||
+20
-6
@@ -116,10 +116,21 @@ export function App(props: { readonly session: T3Session; readonly config: T3tui
|
|||||||
/** The thread list's and details column's widths once their edges are dragged; null follows the window. */
|
/** The thread list's and details column's widths once their edges are dragged; null follows the window. */
|
||||||
const [listWidthPref, setListWidthPref] = useState<number | null>(props.layout?.listWidth ?? null);
|
const [listWidthPref, setListWidthPref] = useState<number | null>(props.layout?.listWidth ?? null);
|
||||||
const [detailsWidthPref, setDetailsWidthPref] = useState<number | null>(props.layout?.detailsWidth ?? null);
|
const [detailsWidthPref, setDetailsWidthPref] = useState<number | null>(props.layout?.detailsWidth ?? null);
|
||||||
const layoutNow = useRef<Layout>({ listWidth: listWidthPref, detailsWidth: detailsWidthPref });
|
const [listHidden, setListHidden] = useState(props.layout?.listHidden ?? false);
|
||||||
layoutNow.current = { listWidth: listWidthPref, detailsWidth: detailsWidthPref };
|
const [detailsPref, setDetailsPrefState] = useState<boolean | null>(props.layout?.details ?? null);
|
||||||
|
const layoutNow = useRef<Layout>({ listWidth: listWidthPref, detailsWidth: detailsWidthPref, listHidden, details: detailsPref });
|
||||||
|
layoutNow.current = { listWidth: listWidthPref, detailsWidth: detailsWidthPref, listHidden, details: detailsPref };
|
||||||
/** Kept for the next run; a failed save only costs that. */
|
/** Kept for the next run; a failed save only costs that. */
|
||||||
const saveLayoutNow = (change: Partial<Layout> = {}) => void saveLayout({ ...layoutNow.current, ...change }).catch(() => {});
|
const saveLayoutNow = (change: Partial<Layout> = {}) => void saveLayout({ ...layoutNow.current, ...change }).catch(() => {});
|
||||||
|
const setDetailsPref = (show: boolean) => {
|
||||||
|
setDetailsPrefState(show);
|
||||||
|
saveLayoutNow({ details: show });
|
||||||
|
};
|
||||||
|
const toggleList = () => {
|
||||||
|
setListHidden(!listHidden);
|
||||||
|
saveLayoutNow({ listHidden: !listHidden });
|
||||||
|
};
|
||||||
|
const showList = !attached && !listHidden;
|
||||||
/** The edge being dragged. */
|
/** The edge being dragged. */
|
||||||
const [resizing, setResizing] = useState<"list" | "details" | null>(null);
|
const [resizing, setResizing] = useState<"list" | "details" | null>(null);
|
||||||
const [diff, setDiff] = useState<DiffState | null>(null);
|
const [diff, setDiff] = useState<DiffState | null>(null);
|
||||||
@@ -431,6 +442,8 @@ export function App(props: { readonly session: T3Session; readonly config: T3tui
|
|||||||
session,
|
session,
|
||||||
live,
|
live,
|
||||||
width,
|
width,
|
||||||
|
pref: detailsPref,
|
||||||
|
setPref: setDetailsPref,
|
||||||
thread: threadShell,
|
thread: threadShell,
|
||||||
project,
|
project,
|
||||||
snapshot: detailsSnapshot,
|
snapshot: detailsSnapshot,
|
||||||
@@ -631,7 +644,7 @@ export function App(props: { readonly session: T3Session; readonly config: T3tui
|
|||||||
const scrollPage = (direction: 1 | -1) => scrollRef.current?.scrollBy(direction * Math.max(1, height - 10));
|
const scrollPage = (direction: 1 | -1) => scrollRef.current?.scrollBy(direction * Math.max(1, height - 10));
|
||||||
|
|
||||||
const turns = useTurns({ session, threadId, projection, timeline: current, config: providerConfig, cwd: panel.cwd, ignoreWhitespace: config.diffIgnoreWhitespace, enabled: draft === null, diff, setDiff, scrollRef, confirm, say,
|
const turns = useTurns({ session, threadId, projection, timeline: current, config: providerConfig, cwd: panel.cwd, ignoreWhitespace: config.diffIgnoreWhitespace, enabled: draft === null, diff, setDiff, scrollRef, confirm, say,
|
||||||
showConversation: () => { setMode("nav"); panel.setPref((value) => width < MIN_CONVERSATION_WIDTH + DETAILS_WIDTH ? false : value); },
|
showConversation: () => { setMode("nav"); setDetailsPrefState((value) => (width < MIN_CONVERSATION_WIDTH + DETAILS_WIDTH ? false : value)); },
|
||||||
restorePrompt: (id, text) => {
|
restorePrompt: (id, text) => {
|
||||||
const previous = id === activeComposerKey.current ? composerRef.current?.plainText ?? "" : drafts.current.get(id) ?? "";
|
const previous = id === activeComposerKey.current ? composerRef.current?.plainText ?? "" : drafts.current.get(id) ?? "";
|
||||||
const next = text ? previous ? `${previous}\n\n${text}` : text : previous;
|
const next = text ? previous ? `${previous}\n\n${text}` : text : previous;
|
||||||
@@ -758,6 +771,7 @@ export function App(props: { readonly session: T3Session; readonly config: T3tui
|
|||||||
{ keys: ["j", "↓"], label: "j/k", run: () => (attached ? scrollBy(1) : move(1)), hint: attached ? "scroll" : "threads" },
|
{ keys: ["j", "↓"], label: "j/k", run: () => (attached ? scrollBy(1) : move(1)), hint: attached ? "scroll" : "threads" },
|
||||||
{ keys: ["k", "↑"], run: () => (attached ? scrollBy(-1) : move(-1)) },
|
{ keys: ["k", "↑"], run: () => (attached ? scrollBy(-1) : move(-1)) },
|
||||||
!attached && { keys: ["/"], run: () => setMode("filter"), hint: "filter", command: { id: "filter", title: "Filter threads", keywords: ["search"] } },
|
!attached && { keys: ["/"], run: () => setMode("filter"), hint: "filter", command: { id: "filter", title: "Filter threads", keywords: ["search"] } },
|
||||||
|
!attached && { keys: ["B"], run: toggleList, command: { id: "thread-list", title: listHidden ? "Show thread list" : "Hide thread list", keywords: ["sidebar", "panel", "threads"] } },
|
||||||
typeKey,
|
typeKey,
|
||||||
projectKey,
|
projectKey,
|
||||||
{ keys: ["c"], run: () => newThread.start(), hint: "new", command: { id: "new-thread", title: "New thread", keywords: ["create", "start", "chat"] } },
|
{ keys: ["c"], run: () => newThread.start(), hint: "new", command: { id: "new-thread", title: "New thread", keywords: ["create", "start", "chat"] } },
|
||||||
@@ -981,7 +995,7 @@ export function App(props: { readonly session: T3Session; readonly config: T3tui
|
|||||||
const headerProject = threadRow?.projectName ? truncate(threadRow.projectName, 24) : "";
|
const headerProject = threadRow?.projectName ? truncate(threadRow.projectName, 24) : "";
|
||||||
const headerRoom = width - 18 - (headerProject ? headerProject.length + 3 : 0) - (headerStatus ? headerStatus.text.length + 2 : 0) - (shell.status.type !== "live" ? status.length + 2 : 0) - (usageInfo.note ? usageInfo.note.length + 2 : 0);
|
const headerRoom = width - 18 - (headerProject ? headerProject.length + 3 : 0) - (headerStatus ? headerStatus.text.length + 2 : 0) - (shell.status.type !== "live" ? status.length + 2 : 0) - (usageInfo.note ? usageInfo.note.length + 2 : 0);
|
||||||
const headerTitle = truncate(title, Math.max(8, headerRoom));
|
const headerTitle = truncate(title, Math.max(8, headerRoom));
|
||||||
const listWidth = attached ? 0 : clampListWidth(listWidthPref ?? Math.min(46, Math.max(28, Math.floor(width * 0.3))), width);
|
const listWidth = !showList ? 0 : clampListWidth(listWidthPref ?? Math.min(46, Math.max(28, Math.floor(width * 0.3))), width);
|
||||||
// Room for the details column and its edge beside the conversation; a dragged width gives way to the conversation first.
|
// Room for the details column and its edge beside the conversation; a dragged width gives way to the conversation first.
|
||||||
const detailsRoom = width - listWidth - 1 - MIN_CONVERSATION_WIDTH;
|
const detailsRoom = width - listWidth - 1 - MIN_CONVERSATION_WIDTH;
|
||||||
const detailsWidth = Math.min(detailsWidthPref ?? DETAILS_WIDTH, Math.max(DETAILS_WIDTH, detailsRoom));
|
const detailsWidth = Math.min(detailsWidthPref ?? DETAILS_WIDTH, Math.max(DETAILS_WIDTH, detailsRoom));
|
||||||
@@ -1072,7 +1086,7 @@ export function App(props: { readonly session: T3Session; readonly config: T3tui
|
|||||||
<Button label="ctrl+k" shortcut="commands" plain onPress={openPalette} />
|
<Button label="ctrl+k" shortcut="commands" plain onPress={openPalette} />
|
||||||
</box>
|
</box>
|
||||||
<box flexDirection="row" flexGrow={1} flexShrink={1} minHeight={0} overflow="hidden">
|
<box flexDirection="row" flexGrow={1} flexShrink={1} minHeight={0} overflow="hidden">
|
||||||
{attached ? null : (
|
{!showList ? null : (
|
||||||
<ThreadList
|
<ThreadList
|
||||||
rows={rows}
|
rows={rows}
|
||||||
collapsed={collapsed}
|
collapsed={collapsed}
|
||||||
@@ -1099,7 +1113,7 @@ export function App(props: { readonly session: T3Session; readonly config: T3tui
|
|||||||
shelfStatus={library.error ?? (library.loading ? "Loading…" : library.archived ? "Archived threads · A to go back" : null)}
|
shelfStatus={library.error ?? (library.loading ? "Loading…" : library.archived ? "Archived threads · A to go back" : null)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{attached ? null : <ResizeHandle active={resizing === "list"} onStart={() => setResizing("list")} onReset={() => {
|
{!showList ? null : <ResizeHandle active={resizing === "list"} onStart={() => setResizing("list")} onReset={() => {
|
||||||
setListWidthPref(null);
|
setListWidthPref(null);
|
||||||
saveLayoutNow({ listWidth: null });
|
saveLayoutNow({ listWidth: null });
|
||||||
}} />}
|
}} />}
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ export function useDetails(deps: {
|
|||||||
readonly session: T3Session;
|
readonly session: T3Session;
|
||||||
readonly live: boolean;
|
readonly live: boolean;
|
||||||
readonly width: number;
|
readonly width: number;
|
||||||
|
/** Shown or hidden by `d`, kept across runs; null follows the terminal width. */
|
||||||
|
readonly pref: boolean | null;
|
||||||
|
readonly setPref: (show: boolean) => void;
|
||||||
readonly thread: OrchestrationV2ThreadShell | undefined;
|
readonly thread: OrchestrationV2ThreadShell | undefined;
|
||||||
readonly project: OrchestrationProjectShell | undefined;
|
readonly project: OrchestrationProjectShell | undefined;
|
||||||
/** The shell, with fetched subagent families, so lineage can name idle subagents. */
|
/** The shell, with fetched subagent families, so lineage can name idle subagents. */
|
||||||
@@ -44,7 +47,7 @@ export function useDetails(deps: {
|
|||||||
}) {
|
}) {
|
||||||
const { session, live, thread, project, config, confirm, run, say, setDiff } = deps;
|
const { session, live, thread, project, config, confirm, run, say, setDiff } = deps;
|
||||||
/** null follows the terminal width; d sets it for the rest of the session. */
|
/** null follows the terminal width; d sets it for the rest of the session. */
|
||||||
const [pref, setPref] = useState<boolean | null>(null);
|
const { pref, setPref } = deps;
|
||||||
const [selected, setSelected] = useState<string | null>(null);
|
const [selected, setSelected] = useState<string | null>(null);
|
||||||
const [unfolded, setUnfolded] = useState<ReadonlySet<DetailsFold>>(() => new Set());
|
const [unfolded, setUnfolded] = useState<ReadonlySet<DetailsFold>>(() => new Set());
|
||||||
const show = pref ?? deps.width >= AUTO_WIDTH;
|
const show = pref ?? deps.width >= AUTO_WIDTH;
|
||||||
|
|||||||
@@ -434,6 +434,27 @@ describe("mouse", () => {
|
|||||||
expect(next.find("┃").x).toBe(before + 7);
|
expect(next.find("┃").x).toBe(before + 7);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("B hides the thread list and brings it back, and the next run remembers", async () => {
|
||||||
|
const first = await open();
|
||||||
|
const composer = () => first.find("Press i to type").x;
|
||||||
|
const withList = composer();
|
||||||
|
await first.press("B");
|
||||||
|
expect(composer()).toBeLessThan(withList);
|
||||||
|
expect((await loadLayout()).listHidden).toBe(true);
|
||||||
|
first.destroy();
|
||||||
|
const next = await open({ layout: await loadLayout() });
|
||||||
|
expect(next.find("Press i to type").x).toBeLessThan(withList);
|
||||||
|
await next.press("B");
|
||||||
|
expect(next.find("Press i to type").x).toBe(withList);
|
||||||
|
expect((await loadLayout()).listHidden).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("d's choice for the details column is kept for the next run", async () => {
|
||||||
|
const first = await open({ width: 200 });
|
||||||
|
await first.press("d");
|
||||||
|
expect((await loadLayout()).details).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
test("dragging the details edge resizes it and keeps the width; right-click resets it", async () => {
|
test("dragging the details edge resizes it and keeps the width; right-click resets it", async () => {
|
||||||
// Wide enough for the details column to open by itself.
|
// Wide enough for the details column to open by itself.
|
||||||
const first = await open({ width: 200 });
|
const first = await open({ width: 200 });
|
||||||
|
|||||||
Reference in new issue
Block a user