// Console chrome around the shared chat composer. While the agent works, Send // follows the workspace's choice (queue or steer) and the other choice sits // beside it (also Cmd/Ctrl+Enter), so there is no per-message mode to track. import { ChatComposer } from "../../components/chat-composer"; import { useFileAttachments, type UseFileAttachmentsResult, } from "../../hooks/use-file-attachments"; import type { ChatComposerMessages } from "../../components/composer"; import type { ComposerState } from "../../hooks/use-composer"; import type { SlashCommandContext } from "../../hooks/use-slash-commands"; import type { ComposerQueuedRecall } from "../../hooks/use-queued-prompt-recall"; import { resolveWorkspaceVoiceInputEnabled } from "@opengeni/sdk/browser"; import type { EffectiveSessionControl } from "@opengeni/sdk"; import { useRef, type ComponentProps, type ReactNode } from "react"; import { useAppContext, type AppContextValue } from "../app-context"; import { useAppShotTarget } from "./desktop/app-shots"; import { MessageContextPills } from "./message-context-pills"; import { ComposerUsageNotice } from "./usage/usage-entry"; import { inferenceFeatureRestriction } from "../../inference-region"; import { t } from "../lib/console-text"; export function useDraftAttachments( workspaceId: string, scope: "workspace" | "personal" = "workspace", ): UseFileAttachmentsResult { return useFileAttachments({ workspaceId, scope }); } /** * The composer's mic for this workspace. EU-only without an EU speech-to-text * route: the mic stays, switched off, and says "Not supported in EU". Voice * input not available here: no mic. */ export function composerTranscription( context: Pick, workspaceId: string, ): ComponentProps["transcription"] { const restricted = inferenceFeatureRestriction(t, context.clientConfig, "voice_input"); if (restricted) { return { client: null, workspaceId, capability: null, workspaceEnabled: false, messages: { unavailable: restricted }, }; } if (!context.clientConfig.voiceInput?.available) return undefined; const workspace = context.workspaces.find((candidate) => candidate.id === workspaceId); return { client: context.client, workspaceId, capability: context.clientConfig.voiceInput, workspaceEnabled: resolveWorkspaceVoiceInputEnabled(workspace?.settings) ?? true, }; } export function ConsoleComposer(props: { workspaceId: string; composer: ComposerState; attachments: UseFileAttachmentsResult; effectiveControl?: EffectiveSessionControl | null | undefined; queuedAheadCount?: number | undefined; canControlWorkspace?: boolean | undefined; controlLinks?: | { workspaceHref?: string | undefined; sessionHref?: ((sessionId: string) => string) | undefined; } | undefined; placeholder?: string | undefined; autoFocus?: boolean | undefined; disabled?: boolean | undefined; fileUploadsEnabled: boolean; /** Rendered before attach (mobile “+” lives here). */ controlsLeading?: ReactNode | undefined; /** Session setup controls rendered above the message input. */ header?: ReactNode | undefined; controls?: ReactNode | undefined; actions?: ReactNode | undefined; commandContext?: SlashCommandContext | undefined; onClearView?: (() => void) | undefined; /** Route-specific composer copy, including an exact disabled-send explanation. */ messages?: Partial | undefined; /** Soft-hide dictate while realtime voice is active. */ transcriptionSuppressed?: boolean | undefined; /** Re-read the near/at-limit usage line when this changes (for example the session status). */ usageRefreshKey?: unknown | undefined; /** Up in an empty composer pulls the latest waiting prompt back for editing. */ queuedRecall?: ComposerQueuedRecall | undefined; /** Work this session started is running, or a wake is pending; keeps Pause available while it is idle. */ running?: boolean | undefined; }) { const context = useAppContext(); const transcription = composerTranscription(context, props.workspaceId); // In the desktop app, the app-shot shortcut attaches the captured window here. const regionRef = useRef(null); useAppShotTarget(props.fileUploadsEnabled ? props.attachments : null, regionRef); return (
{props.header} } // The actions menu owns attachments when supplied. attachButtonClassName={props.controlsLeading ? "hidden" : undefined} controlsStart={props.controls} actionsStart={props.actions} transcriptionSuppressed={props.transcriptionSuppressed === true} {...(transcription ? { transcription } : {})} />
); }