The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import type { PreviewMiniPlayerFrame } from "../preview/previewMiniPlayerLayout"; |
| 2 | import { DETAILS_CARD_CLEARANCE } from "./chatCanvasLayout"; |
| 3 | |
| 4 | export const THREAD_DETAILS_CARD_GAP = 12; |
| 5 | // Keep in sync with --thread-details-panel-width. |
| 6 | const THREAD_DETAILS_CARD_WIDTH = 280; |
| 7 | |
| 8 | export 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 | |
| 17 | export function resolveThreadDetailsCardLayout({ |
| 18 | container, |
| 19 | narrowestWidth = container.width, |
| 20 | lane, |
| 21 | frame, |
| 22 | overlapsDetailsCard = false, |
| 23 | topInset = 0, |
| 24 | }: { |
| 25 | container: { width: number; height: number }; |
| 26 | // While a panel animates the container, the card fits only if it fits at both ends. |
| 27 | narrowestWidth?: number; |
| 28 | lane: { padding: number; minChatWidth: number }; |
| 29 | frame: PreviewMiniPlayerFrame | null; |
| 30 | overlapsDetailsCard?: boolean; |
| 31 | topInset?: number; |
| 32 | }) { |
| 33 | const gap = THREAD_DETAILS_CARD_GAP; |
| 34 | const width = THREAD_DETAILS_CARD_WIDTH; |
| 35 | const x = container.width - width - gap; |
| 36 | // The transition ends are sampled once, so a resize mid-animation can leave them |
| 37 | // wider than the container is now. |
| 38 | const fitWidth = Math.min(narrowestWidth, container.width); |
| 39 | if (fitWidth - width - gap - DETAILS_CARD_CLEARANCE - lane.padding < lane.minChatWidth) |
| 40 | return null; |
| 41 | const y = gap + topInset; |
| 42 | const height = |
| 43 | overlapsDetailsCard && frame && frame.x + frame.width > x - gap && frame.x < x + width + gap |
| 44 | ? Math.min(container.height - y - gap, frame.y - y - gap) |
| 45 | : container.height - y - gap; |
| 46 | if (height < 160) return null; |
| 47 | return { |
| 48 | x, |
| 49 | right: gap, |
| 50 | width, |
| 51 | y, |
| 52 | height, |
| 53 | } as const; |
| 54 | } |