Files
codeg/src/lib/session-attachment-events.ts
2026-03-23 18:15:30 +08:00

36 lines
833 B
TypeScript

export const ATTACH_FILE_TO_SESSION_EVENT = "codeg:attach-file-to-session"
export interface AttachFileToSessionDetail {
tabId: string
path: string
}
export function emitAttachFileToSession(
detail: AttachFileToSessionDetail
): void {
if (typeof window === "undefined") return
window.dispatchEvent(
new CustomEvent<AttachFileToSessionDetail>(ATTACH_FILE_TO_SESSION_EVENT, {
detail,
})
)
}
export const APPEND_TEXT_TO_SESSION_EVENT = "codeg:append-text-to-session"
export interface AppendTextToSessionDetail {
tabId: string
text: string
}
export function emitAppendTextToSession(
detail: AppendTextToSessionDetail
): void {
if (typeof window === "undefined") return
window.dispatchEvent(
new CustomEvent<AppendTextToSessionDetail>(APPEND_TEXT_TO_SESSION_EVENT, {
detail,
})
)
}