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
+11
-2
@@ -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<Layout> {
|
||||
|
||||
export function parseLayout(raw: unknown): Layout {
|
||||
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);
|
||||
|
||||
+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. */
|
||||
const [listWidthPref, setListWidthPref] = useState<number | null>(props.layout?.listWidth ?? null);
|
||||
const [detailsWidthPref, setDetailsWidthPref] = useState<number | null>(props.layout?.detailsWidth ?? null);
|
||||
const layoutNow = useRef<Layout>({ listWidth: listWidthPref, detailsWidth: detailsWidthPref });
|
||||
layoutNow.current = { listWidth: listWidthPref, detailsWidth: detailsWidthPref };
|
||||
const [listHidden, setListHidden] = useState(props.layout?.listHidden ?? false);
|
||||
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. */
|
||||
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. */
|
||||
const [resizing, setResizing] = useState<"list" | "details" | null>(null);
|
||||
const [diff, setDiff] = useState<DiffState | null>(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
|
||||
<Button label="ctrl+k" shortcut="commands" plain onPress={openPalette} />
|
||||
</box>
|
||||
<box flexDirection="row" flexGrow={1} flexShrink={1} minHeight={0} overflow="hidden">
|
||||
{attached ? null : (
|
||||
{!showList ? null : (
|
||||
<ThreadList
|
||||
rows={rows}
|
||||
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)}
|
||||
/>
|
||||
)}
|
||||
{attached ? null : <ResizeHandle active={resizing === "list"} onStart={() => setResizing("list")} onReset={() => {
|
||||
{!showList ? null : <ResizeHandle active={resizing === "list"} onStart={() => setResizing("list")} onReset={() => {
|
||||
setListWidthPref(null);
|
||||
saveLayoutNow({ listWidth: null });
|
||||
}} />}
|
||||
|
||||
@@ -21,6 +21,9 @@ export function useDetails(deps: {
|
||||
readonly session: T3Session;
|
||||
readonly live: boolean;
|
||||
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 project: OrchestrationProjectShell | undefined;
|
||||
/** 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;
|
||||
/** 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 [unfolded, setUnfolded] = useState<ReadonlySet<DetailsFold>>(() => new Set());
|
||||
const show = pref ?? deps.width >= AUTO_WIDTH;
|
||||
|
||||
Reference in new issue
Block a user