Resize the details column by dragging its edge

Like the thread list: drag to resize, right-click to reset, kept as
detailsWidth in layout.json. The conversation keeps its minimum width; a
dragged width gives way to it before the panel goes in place.
This commit is contained in:
Callum Alpass committed 2026-11-03 01:49:12 +11:00
1 parent 9702c31e62
commit bbf8ff49e1
4 files changed
+57 -21

No files matched your search

+6 -3
View File
@@ -10,9 +10,11 @@ import { configDir } from "./client/auth.ts";
export interface Layout {
/** The thread list's width once its border is dragged; null follows the window. */
readonly listWidth: number | null;
/** The details column's width once its border is dragged; null is the default width. */
readonly detailsWidth: number | null;
}
export const DEFAULT_LAYOUT: Layout = { listWidth: null };
export const DEFAULT_LAYOUT: Layout = { listWidth: null, detailsWidth: null };
const layoutPath = () => join(configDir(), "layout.json");
@@ -27,10 +29,11 @@ export async function loadLayout(): Promise<Layout> {
export function parseLayout(raw: unknown): Layout {
const record = raw && typeof raw === "object" ? (raw as Record<string, unknown>) : {};
const width = record.listWidth;
return { listWidth: typeof width === "number" && Number.isInteger(width) && width > 0 ? width : null };
return { listWidth: positiveInteger(record.listWidth), detailsWidth: positiveInteger(record.detailsWidth) };
}
const positiveInteger = (value: unknown) => (typeof value === "number" && Number.isInteger(value) && value > 0 ? value : null);
export async function saveLayout(layout: Layout): Promise<void> {
await mkdir(configDir(), { recursive: true });
await writeFile(layoutPath(), `${JSON.stringify(layout, null, 2)}\n`);