blob: 19ecaee918c5cf7d9c7245b0074c5a61352bfee7 [file]
import { safeLocalStorageGet } from './browser-storage.js';
/**
* 480 rather than the original 400: the trace tab's overview is a two-column
* data grid, and at 400 its figures had to be squeezed against their labels
* before the qualifier column had room. The stored width still wins, so only
* a reader who never dragged the handle sees the change.
*/
export const SESSION_WORKBAR_DEFAULT_WIDTH = 480;
export const SESSION_WORKBAR_MIN_WIDTH = 320;
export const SESSION_WORKBAR_MAX_WIDTH = 600;
export const SESSION_BOTTOM_PANEL_DEFAULT_HEIGHT = 300;
export const SESSION_BOTTOM_PANEL_MIN_HEIGHT = 180;
export const SESSION_BOTTOM_PANEL_MAX_HEIGHT = 520;
/**
* Seeds `useResizable`'s `defaultSize`. Deliberately unclamped: the hook clamps
* whatever it is handed against `minSizePx`/`maxSizePx`, so a second clamp here
* would be a duplicate authority over the bounds.
*
* Rounding is a different job, and still ours. `clampSize` bounds without
* rounding, so a fractional stored value survives hydration and reaches the
* panel, storage and `aria-valuenow` unchanged until the next drag. Every other
* way a width enters the app is already integral; this is the one entry point
* reading a value the app cannot vouch for.
*/
export function readSessionWorkbarWidth(): number {
const stored = Number(safeLocalStorageGet('maka-session-workbar-width-v1'));
return Number.isFinite(stored) && stored > 0 ? Math.round(stored) : SESSION_WORKBAR_DEFAULT_WIDTH;
}
export function readSessionWorkbarCollapsed(): boolean {
const stored = safeLocalStorageGet('maka-session-workbar-collapsed-v1');
if (stored === 'false') return false;
if (stored === 'true') return true;
return true;
}
export function readSessionBottomPanelHeight(): number {
const stored = Number(safeLocalStorageGet('maka-session-bottom-panel-height-v1'));
return Number.isFinite(stored) && stored > 0
? Math.round(stored)
: SESSION_BOTTOM_PANEL_DEFAULT_HEIGHT;
}
export function readSessionBottomPanelOpen(): boolean {
return safeLocalStorageGet('maka-session-bottom-panel-open-v1') === 'true';
}