/** Put content into the composer of a chat from anywhere in the app (quote, image viewer, …). */ export interface ComposeDetail { sessionId: string; /** Appended to the text field (a blank line before it if there is text already). */ text?: string; /** Attached like dropped files (images stay images). */ files?: File[]; } export const COMPOSE_EVENT = "codecraft:compose"; export function compose(detail: ComposeDetail) { window.dispatchEvent(new CustomEvent(COMPOSE_EVENT, { detail })); } /** "> quoted\n> lines\n\n" for the composer. */ export function asQuote(text: string) { const lines = text.trim().split("\n").map((l) => `> ${l}`.trimEnd()); return `${lines.join("\n")}\n\n`; }