diff --git a/docs/reference.md b/docs/reference.md index 9a417ce..dff5025 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -57,7 +57,8 @@ Navigation: | `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 | | `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 | | `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) | @@ -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. - **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). -- **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 diff --git a/src/layout.ts b/src/layout.ts index ffd3b05..5c72676 100644 --- a/src/layout.ts +++ b/src/layout.ts @@ -12,9 +12,13 @@ export interface Layout { readonly listWidth: number | null; /** The details column's width once its border is dragged; null is the default width. */ 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"); @@ -29,7 +33,12 @@ export async function loadLayout(): Promise { export function parseLayout(raw: unknown): Layout { const record = raw && typeof raw === "object" ? (raw as Record) : {}; - 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); diff --git a/src/ui/App.tsx b/src/ui/App.tsx index de6109e..fbdb4b7 100644 --- a/src/ui/App.tsx +++ b/src/ui/App.tsx @@ -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. */ const [listWidthPref, setListWidthPref] = useState(props.layout?.listWidth ?? null); const [detailsWidthPref, setDetailsWidthPref] = useState(props.layout?.detailsWidth ?? null); - const layoutNow = useRef({ listWidth: listWidthPref, detailsWidth: detailsWidthPref }); - layoutNow.current = { listWidth: listWidthPref, detailsWidth: detailsWidthPref }; + const [listHidden, setListHidden] = useState(props.layout?.listHidden ?? false); + const [detailsPref, setDetailsPrefState] = useState(props.layout?.details ?? null); + const layoutNow = useRef({ 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. */ const saveLayoutNow = (change: Partial = {}) => 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. */ const [resizing, setResizing] = useState<"list" | "details" | null>(null); const [diff, setDiff] = useState(null); @@ -431,6 +442,8 @@ export function App(props: { readonly session: T3Session; readonly config: T3tui session, live, width, + pref: detailsPref, + setPref: setDetailsPref, thread: threadShell, project, 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 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) => { const previous = id === activeComposerKey.current ? composerRef.current?.plainText ?? "" : drafts.current.get(id) ?? ""; 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: ["k", "↑"], run: () => (attached ? scrollBy(-1) : move(-1)) }, !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, projectKey, { 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 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 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. const detailsRoom = width - listWidth - 1 - MIN_CONVERSATION_WIDTH; 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