The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { createContext, useContext } from "react"; |
| 2 | import type { resolveChatCanvasLayout } from "./chatCanvasLayout"; |
| 3 | import type { resolveThreadDetailsCardLayout } from "./threadDetailsCardLayout"; |
| 4 | import type { ScopedThreadRef } from "@t3tools/contracts"; |
| 5 | |
| 6 | /** The inline details card's measured full-density height at a card width. */ |
| 7 | export interface DetailsCardMeasurement { |
| 8 | readonly threadRef: ScopedThreadRef; |
| 9 | readonly width: number; |
| 10 | readonly fullContentHeight: number; |
| 11 | } |
| 12 | |
| 13 | export const ChatCanvasContext = createContext<{ |
| 14 | container: { width: number; height: number }; |
| 15 | lane: { padding: number; minChatWidth: number }; |
| 16 | layout: ReturnType<typeof resolveChatCanvasLayout>; |
| 17 | previewKey: string | null; |
| 18 | registerTimeline: (element: HTMLElement | null) => void; |
| 19 | measureDetailsCard: (measurement: DetailsCardMeasurement) => void; |
| 20 | detailsCardTopInset: number; |
| 21 | /** Where an inline card sits when nothing overlaps it; null when the canvas is too narrow. */ |
| 22 | preferredDetailsCard: ReturnType<typeof resolveThreadDetailsCardLayout>; |
| 23 | /** Where the inline card sits now; null when it shows as a popover. */ |
| 24 | detailsCardPlacement: ReturnType<typeof resolveThreadDetailsCardLayout>; |
| 25 | } | null>(null); |
| 26 | |
| 27 | export const useChatCanvas = () => useContext(ChatCanvasContext); |