Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

1.4 KB
Raw Blame
import { safeWindowRect, windowDivision, type WindowGeometry } from '@/platform/windowGeometry';

/** Navigation consumes space only when the remaining conversation is comfortably usable. */
export function sessionPaneLayout(g: WindowGeometry, requestedWidth: number | null = null) {
  const safe = safeWindowRect(g);
  const division = windowDivision(g);
  const splitAtFold = division?.axis === 'vertical' && division.first.width >= 240 && division.second.width >= 320;
  const persistent = !!splitAtFold || (!division && g.regularWidth && safe.width >= 760 && safe.height >= 480);
  // An actual reserved hinge cannot move. Flat windows can trade space between
  // the list and conversation without losing either pane's usable minimum.
  const resizeBounds = persistent && !splitAtFold ? { min: 240, max: Math.min(420, safe.width - 400) } : null;
  const preferredWidth = requestedWidth !== null && Number.isFinite(requestedWidth)
    ? requestedWidth : Math.min(320, Math.round(safe.width * 0.34));
  const sidebarWidth = splitAtFold ? division!.first.width : resizeBounds
    ? Math.round(Math.max(resizeBounds.min, Math.min(resizeBounds.max, preferredWidth))) : 0;
  const sidebarGap = splitAtFold ? division!.second.x - safe.x - sidebarWidth : 0;
  const pane = { ...safe, x: safe.x + sidebarWidth + sidebarGap, width: safe.width - sidebarWidth - sidebarGap };
  return { persistent, sidebarWidth, sidebarGap, detail: pane, resizeBounds };
}