Open History to see the last commit
1import type { PreviewMiniPlayerFrame } from "../preview/previewMiniPlayerLayout";
2import { DETAILS_CARD_CLEARANCE } from "./chatCanvasLayout";
3
4export const THREAD_DETAILS_CARD_GAP = 12;
5// Keep in sync with --thread-details-panel-width.
6const THREAD_DETAILS_CARD_WIDTH = 280;
7
8export function resolveThreadDetailsCardDensity(
9 height: number,
10 content: { full: number; compact: number },
11) {
12 if (content.full === 0 || content.full <= height) return "full";
13 if (content.compact === 0 || content.compact <= height) return "compact";
14 return "essential";
15}
16
17export function resolveThreadDetailsCardLayout({
18 container,
19 lane,
20 frame,
21 overlapsDetailsCard = false,
22 topInset = 0,
23}: {
24 container: { width: number; height: number };
25 lane: { padding: number; minChatWidth: number };
26 frame: PreviewMiniPlayerFrame | null;
27 overlapsDetailsCard?: boolean;
28 topInset?: number;
29}) {
30 const gap = THREAD_DETAILS_CARD_GAP;
31 const width = THREAD_DETAILS_CARD_WIDTH;
32 const x = container.width - width - gap;
33 if (x - DETAILS_CARD_CLEARANCE - lane.padding < lane.minChatWidth) return null;
34 const y = gap + topInset;
35 const height =
36 overlapsDetailsCard && frame && frame.x + frame.width > x - gap && frame.x < x + width + gap
37 ? Math.min(container.height - y - gap, frame.y - y - gap)
38 : container.height - y - gap;
39 if (height < 160) return null;
40 return {
41 x,
42 right: gap,
43 width,
44 y,
45 height,
46 } as const;
47}