@agimon-ai/po-web-dashboard 0.0.0-alpha.32 → 0.0.0-alpha.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,7 @@ let _agimon_ai_po_web_components = require("@agimon-ai/po-web-components");
23
23
  //#region src/web/features/session/Composer.tsx
24
24
  /** The input grows with the draft up to this many pixels, then scrolls. */
25
25
  const MAX_INPUT_HEIGHT_PX = 192;
26
- const FILE_SEARCH_DEBOUNCE_MS = 50;
26
+ const FILE_SEARCH_DEBOUNCE_MS = 300;
27
27
  const IMAGE_TYPES = /* @__PURE__ */ new Set([
28
28
  "image/png",
29
29
  "image/jpeg",
@@ -1 +1 @@
1
- {"version":3,"file":"Composer.cjs","names":["uploadSessionAttachment","inlineTextBytes","composerStore","TRIGGER_CHARS","useStore","sessionsStore","useActiveSessionMeta","useActiveSession","useToolPrompt","useComposerState","useState","composerSubmissionStore","useRef","registerPromptInput","useCallback","triggerTokenAt","commandCompletions","searchSessionFiles","fileCompletions","submitComposerDraft","Button","abortRun","StopIcon","WORKFLOW_STEP_SESSION_PROVENANCE","DormantPanel","QueueSheet","clearQueuedMessages","deleteQueuedMessage","promoteQueuedMessage","resumeQueuedMessages","ComposerPrompt","AgentLockPanel","Popover","PopoverAnchor","PopoverContent","OptionRow","OptionLabel","PopoverFooter","Kbd","Textarea","updateComposerState","CloseIcon","PopoverTrigger","PlusIcon","optionRowVariants","PluginSurface","HOST_SLOTS","SendIcon"],"sources":["../../../../src/web/features/session/Composer.tsx"],"sourcesContent":["import { WORKFLOW_STEP_SESSION_PROVENANCE } from '@agimon-ai/po-core/hubChannel';\nimport type { TransientTab } from '@agimon-ai/po-core/web';\nimport {\n Button,\n CloseIcon,\n Kbd,\n OptionLabel,\n OptionRow,\n optionRowVariants,\n PlusIcon,\n SendIcon,\n Popover,\n PopoverAnchor,\n PopoverContent,\n PopoverFooter,\n PopoverTrigger,\n StopIcon,\n Textarea,\n} from '@agimon-ai/po-web-components';\nimport { useStore } from '@tanstack/react-store';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { PluginSurface } from '../../components/PluginSurface';\nimport {\n type CompletionItem,\n type CompletionKind,\n commandCompletions,\n fileCompletions,\n TRIGGER_CHARS,\n triggerTokenAt,\n} from '../../lib/composerCompletion';\nimport { searchSessionFiles } from '../../lib/hubApi';\nimport { HOST_SLOTS } from '../../lib/pluginRegistry';\nimport { registerPromptInput } from '../../lib/promptFocus';\nimport { uploadSessionAttachment } from '../../lib/sessionAsset';\nimport type { QueuedEntry } from '../../lib/sessionModel';\nimport {\n composerStore,\n type ComposerAttachment,\n type ComposerSessionState,\n inlineTextBytes,\n MAX_COMPOSER_UPLOAD_BYTES,\n MAX_COMPOSER_ATTACHMENTS,\n MAX_COMPOSER_IMAGE_BYTES,\n MAX_COMPOSER_TEXT_BYTES,\n MAX_COMPOSER_TOTAL_IMAGE_BYTES,\n MAX_COMPOSER_TOTAL_TEXT_BYTES,\n updateComposerState,\n useComposerState,\n} from '../../stores/composerStore';\nimport { composerSubmissionStore, submitComposerDraft } from '../../stores/composerSubmissionStore';\nimport { openPalette } from '../../stores/paletteStore';\nimport { sessionsStore, useActiveSessionMeta } from '../../stores/sessionsStore';\nimport {\n abortRun,\n clearQueuedMessages,\n deleteQueuedMessage,\n promoteQueuedMessage,\n resumeQueuedMessages,\n useActiveSession,\n} from '../../stores/sessionStore';\nimport { useToolPrompt } from '../../stores/useToolPrompt';\nimport { AgentLockPanel } from './AgentLockPanel';\nimport { ComposerPrompt } from './ComposerPrompt';\nimport { DormantPanel } from './DormantPanel';\nimport { QueueSheet } from './QueueSheet';\n\n/** The input grows with the draft up to this many pixels, then scrolls. */\nconst MAX_INPUT_HEIGHT_PX = 192;\nconst FILE_SEARCH_DEBOUNCE_MS = 50;\nconst IMAGE_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp']);\nconst TEXT_EXTENSIONS = new Set([\n 'c',\n 'cpp',\n 'css',\n 'csv',\n 'go',\n 'h',\n 'hpp',\n 'html',\n 'ini',\n 'java',\n 'js',\n 'json',\n 'jsonl',\n 'jsx',\n 'log',\n 'md',\n 'markdown',\n 'py',\n 'rb',\n 'rs',\n 'sh',\n 'sql',\n 'toml',\n 'ts',\n 'tsv',\n 'tsx',\n 'txt',\n 'xml',\n 'yaml',\n 'yml',\n]);\n\nfunction isReadableText(file: File): boolean {\n const extension = file.name.toLowerCase().split('.').pop() ?? '';\n return file.type.startsWith('text/') || TEXT_EXTENSIONS.has(extension);\n}\n\nfunction readDataUrl(file: File): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () =>\n typeof reader.result === 'string' ? resolve(reader.result) : reject(new Error('No file data'));\n reader.onerror = () => reject(reader.error ?? new Error('Could not read file'));\n reader.readAsDataURL(file);\n });\n}\n\n/**\n * Stores a copy on the host so a tool can be handed the file by path. Images and\n * text still travel inline, so for them a failed upload only means no path.\n */\nasync function storedPath(sessionId: string, file: File): Promise<string | undefined> {\n try {\n return (await uploadSessionAttachment(sessionId, file)).path;\n } catch {\n return undefined; // Documented fallback: the inline copy is still sent.\n }\n}\n\nconst TOO_MANY_ATTACHMENTS = `Only ${String(MAX_COMPOSER_ATTACHMENTS)} attachments are allowed.`;\n\n/** Why one more image or text file would break a total budget, or '' when it fits. */\nfunction totalBudgetRejection(\n attachments: ComposerAttachment[],\n kind: ComposerAttachment['kind'],\n name: string,\n size: number,\n): string {\n if (kind === 'image') {\n const imageBytes = attachments.reduce((total, item) => total + (item.kind === 'image' ? item.size : 0), 0);\n return imageBytes + size > MAX_COMPOSER_TOTAL_IMAGE_BYTES ? `${name} exceeds the 20 MB total image limit.` : '';\n }\n if (kind === 'text' && inlineTextBytes(attachments) + size > MAX_COMPOSER_TOTAL_TEXT_BYTES) {\n return `${name} exceeds the 200 KB total text limit.`;\n }\n return '';\n}\n\n/**\n * Reads picked, pasted or dropped files into new attachments, numbered from\n * `current.nextAttachmentId` and budgeted after the ones already staged.\n */\nexport async function readComposerFiles(\n sessionId: string,\n files: File[],\n current: Pick<ComposerSessionState, 'attachments' | 'nextAttachmentId'>,\n): Promise<Pick<ComposerSessionState, 'attachments' | 'attachmentError'>> {\n const next = [...current.attachments];\n const rejected: string[] = [];\n let attachmentId = current.nextAttachmentId;\n\n for (const file of files) {\n if (next.length >= MAX_COMPOSER_ATTACHMENTS) {\n rejected.push(TOO_MANY_ATTACHMENTS);\n break;\n }\n const id = `attachment-${String(attachmentId++)}`;\n if (IMAGE_TYPES.has(file.type)) {\n if (file.size > MAX_COMPOSER_IMAGE_BYTES) {\n rejected.push(`${file.name} exceeds the 10 MB image limit.`);\n continue;\n }\n const overBudget = totalBudgetRejection(next, 'image', file.name, file.size);\n if (overBudget) {\n rejected.push(overBudget);\n continue;\n }\n try {\n const dataUrl = await readDataUrl(file);\n const path = file.size > MAX_COMPOSER_UPLOAD_BYTES ? undefined : await storedPath(sessionId, file);\n next.push({\n id,\n kind: 'image',\n name: file.name,\n size: file.size,\n dataUrl,\n data: dataUrl.slice(dataUrl.indexOf(',') + 1),\n mimeType: file.type,\n ...(path === undefined ? {} : { path }),\n });\n } catch {\n rejected.push(`${file.name} could not be read.`);\n }\n continue;\n }\n if (!isReadableText(file)) {\n if (file.size > MAX_COMPOSER_UPLOAD_BYTES) {\n rejected.push(`\"${file.name}\" exceeds the 8 MB file limit.`);\n continue;\n }\n try {\n const stored = await uploadSessionAttachment(sessionId, file);\n next.push({\n id,\n kind: 'file',\n name: file.name,\n size: stored.size,\n mimeType: stored.mimeType,\n path: stored.path,\n });\n } catch {\n rejected.push(`\"${file.name}\" could not be uploaded.`);\n }\n continue;\n }\n if (file.size > MAX_COMPOSER_TEXT_BYTES) {\n rejected.push(`${file.name} exceeds the 100 KB text file limit.`);\n continue;\n }\n const overBudget = totalBudgetRejection(next, 'text', file.name, file.size);\n if (overBudget) {\n rejected.push(overBudget);\n continue;\n }\n try {\n const content = await file.text();\n const path = await storedPath(sessionId, file);\n next.push({\n id,\n kind: 'text',\n name: file.name,\n size: file.size,\n content,\n ...(path === undefined ? {} : { path }),\n });\n } catch {\n rejected.push(`${file.name} could not be read.`);\n }\n }\n return { attachments: next.slice(current.attachments.length), attachmentError: rejected.join(' ') };\n}\n\n/**\n * Stages files on a session's composer. Reading and uploading are async, so\n * the batch reserves its ids and marks itself pending up front, then appends\n * to whatever the composer holds by the time it finishes: chips removed, a\n * message sent, or another batch staged meanwhile all stay as they are, and\n * the count and total budgets are checked again against that latest state.\n */\nexport async function addComposerFiles(sessionId: string, files: File[]): Promise<void> {\n if (files.length === 0) return;\n let current: Pick<ComposerSessionState, 'attachments' | 'nextAttachmentId'> = {\n attachments: [],\n nextAttachmentId: 0,\n };\n updateComposerState(sessionId, (state) => {\n current = state;\n return {\n ...state,\n nextAttachmentId: state.nextAttachmentId + files.length,\n pendingAttachments: state.pendingAttachments + 1,\n };\n });\n const read = await readComposerFiles(sessionId, files, current);\n if (composerStore.state[sessionId] === undefined) return; // The session left while the files were read.\n updateComposerState(sessionId, (state) => {\n const attachments = [...state.attachments];\n const rejected = read.attachmentError ? [read.attachmentError] : [];\n for (const attachment of read.attachments) {\n if (attachments.length >= MAX_COMPOSER_ATTACHMENTS) {\n if (!read.attachmentError.includes(TOO_MANY_ATTACHMENTS)) rejected.push(TOO_MANY_ATTACHMENTS);\n break;\n }\n const overBudget = totalBudgetRejection(attachments, attachment.kind, attachment.name, attachment.size);\n if (overBudget) rejected.push(overBudget);\n else attachments.push(attachment);\n }\n return {\n ...state,\n attachments,\n attachmentError: rejected.join(' '),\n pendingAttachments: Math.max(0, state.pendingAttachments - 1),\n };\n });\n}\n\ninterface CompletionState {\n kind: CompletionKind;\n /** Index of the trigger character in the draft. */\n tokenStart: number;\n query: string;\n items: CompletionItem[];\n selected: number;\n}\n\n/**\n * Whether accepting the highlighted item would leave the draft as it is. The\n * popup still shows what a longer name would complete to, but the keystroke\n * that would change nothing is handed back to the composer to send.\n */\nfunction isCompletionRedundant(state: CompletionState): boolean {\n const item = state.items[state.selected];\n return item !== undefined && item.insert.trimEnd() === `${TRIGGER_CHARS[state.kind]}${state.query}`;\n}\n\nexport function Composer({ composerContext }: { composerContext?: TransientTab['composerContext'] } = {}) {\n const sessionId = useStore(sessionsStore, (state) => state.activeId);\n const meta = useActiveSessionMeta();\n const streaming = useActiveSession((state) => state.streaming);\n const lifecycle = useActiveSession((state) => state.lifecycle);\n const agentLocked = useActiveSession((state) => state.agentLocked);\n const active = lifecycle === null ? streaming : lifecycle.operation !== null;\n const aborting = lifecycle?.operation?.status === 'aborting';\n const queuedEntries = useActiveSession((state) =>\n state.entries.filter((entry): entry is QueuedEntry => entry.kind === 'queued'),\n );\n const commands = useActiveSession((state) => state.commands);\n const editorTextRequest = useActiveSession((state) => state.editorTextRequest);\n const prompt = useToolPrompt();\n const { draft, caret, dismissedToken, attachments, attachmentError, pendingAttachments } =\n useComposerState(sessionId);\n const [completion, setCompletion] = useState<CompletionState | null>(null);\n const [draggingFiles, setDraggingFiles] = useState(false);\n const [menuOpen, setMenuOpen] = useState(false);\n const pendingSubmission = useStore(\n composerSubmissionStore,\n (pending) => sessionId !== null && pending.has(sessionId),\n );\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const searchTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n const dormant = meta?.summary.dormant === true;\n const attached = !dormant && meta?.attach === 'attached';\n const queued = lifecycle === null ? queuedEntries.length : lifecycle.queue.length;\n\n // Completion and drag state are transient. The draft and attachments below\n // come from the newly focused session immediately after this reset, so the\n // reset is done during render rather than in an effect: a frame of the\n // previous session's popup would otherwise be painted over the new draft.\n const [shownSession, setShownSession] = useState(sessionId);\n if (shownSession !== sessionId) {\n setShownSession(sessionId);\n setCompletion(null);\n setDraggingFiles(false);\n setMenuOpen(false);\n }\n\n // The completion popup and the '+' menu are two popovers over one composer,\n // and the completion one exempts its own anchor from outside clicks. Keeping\n // them mutually exclusive means that guard never has to reason about the\n // other's portalled content. Adjusted during render, like the session reset\n // above, so the menu is already gone in the frame the popup appears in.\n if (menuOpen && completion !== null) setMenuOpen(false);\n useEffect(() => {\n if (searchTimer.current) clearTimeout(searchTimer.current);\n }, [sessionId]);\n\n // Overlays hand the keyboard back here when they close. Re-registered when\n // a tool prompt stands the input down and again when it gives it back:\n // otherwise the ref stays as it was and every later hand-back goes nowhere.\n useEffect(() => registerPromptInput(inputRef.current), [dormant, prompt]);\n\n useEffect(() => {\n if (editorTextRequest === null) return;\n updateComposerState(sessionId, (state) => {\n const draft = editorTextRequest.append\n ? `${state.draft}${state.draft && !/\\s$/u.test(state.draft) ? ' ' : ''}${editorTextRequest.text}`\n : editorTextRequest.text;\n return { ...state, draft, caret: draft.length, dismissedToken: null };\n });\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n const length = inputRef.current?.value.length ?? 0;\n inputRef.current?.setSelectionRange(length, length);\n });\n }, [editorTextRequest, sessionId]);\n\n // Auto-grow: measure after every draft change so pasted stack traces are\n // actually visible instead of scrolling inside one line.\n const resize = useCallback((): void => {\n const input = inputRef.current;\n if (!input) return;\n input.style.height = 'auto';\n input.style.height = `${String(Math.min(input.scrollHeight, MAX_INPUT_HEIGHT_PX))}px`;\n }, []);\n useEffect(() => resize(), [draft, resize]);\n\n const closeCompletion = useCallback((): void => {\n if (searchTimer.current) clearTimeout(searchTimer.current);\n setCompletion(null);\n }, []);\n\n /** Esc dismisses the popup for the token being typed; edits re-arm it. */\n const dismissCompletion = useCallback((): void => {\n const trigger = triggerTokenAt(draft, caret);\n updateComposerState(sessionId, (state) => ({ ...state, dismissedToken: trigger?.start ?? null }));\n closeCompletion();\n }, [draft, caret, closeCompletion, sessionId]);\n\n // The popup is derived state: any change to the draft, caret, session\n // commands, or attachment recomputes it, so data arriving after a keystroke\n // still opens it.\n useEffect(() => {\n const trigger = triggerTokenAt(draft, caret);\n if (!trigger || !attached || dismissedToken === trigger.start) {\n // eslint-disable-next-line react/set-state-in-effect -- the popup tracks an async, debounced search; closing it is the synchronous arm of that same effect.\n closeCompletion();\n return;\n }\n if (trigger.kind === 'command' || trigger.kind === 'skill') {\n const items = commandCompletions(commands, trigger.kind, trigger.query);\n setCompletion(\n items.length > 0\n ? { kind: trigger.kind, tokenStart: trigger.start, query: trigger.query, items, selected: 0 }\n : null,\n );\n return;\n }\n if (searchTimer.current) clearTimeout(searchTimer.current);\n searchTimer.current = setTimeout(() => {\n if (sessionId === null) return;\n void searchSessionFiles(sessionId, trigger.query).then((files) => {\n // The session or draft may have moved on while the lookup ran.\n const input = inputRef.current;\n if (\n sessionsStore.state.activeId !== sessionId ||\n !input ||\n triggerTokenAt(input.value, input.selectionStart)?.query !== trigger.query\n )\n return;\n const items = fileCompletions(files);\n setCompletion(\n items.length > 0\n ? { kind: 'file', tokenStart: trigger.start, query: trigger.query, items, selected: 0 }\n : null,\n );\n });\n }, FILE_SEARCH_DEBOUNCE_MS);\n return () => {\n if (searchTimer.current) clearTimeout(searchTimer.current);\n };\n }, [draft, caret, commands, attached, dismissedToken, closeCompletion, sessionId]);\n\n // Clicking anywhere outside the composer closes the popup.\n useEffect(() => {\n if (!completion) return;\n const onPointerDown = (event: MouseEvent): void => {\n if (containerRef.current && event.target instanceof Node && !containerRef.current.contains(event.target)) {\n closeCompletion();\n }\n };\n document.addEventListener('mousedown', onPointerDown);\n return () => document.removeEventListener('mousedown', onPointerDown);\n }, [completion, closeCompletion]);\n\n const accept = (state: CompletionState, index: number): void => {\n const item = state.items[index];\n if (!item) return;\n const next = draft.slice(0, state.tokenStart) + item.insert + draft.slice(caret);\n const position = state.tokenStart + item.insert.length;\n updateComposerState(sessionId, (current) => ({\n ...current,\n draft: next,\n caret: position,\n dismissedToken: state.tokenStart,\n }));\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n inputRef.current?.setSelectionRange(position, position);\n });\n };\n\n const addFiles = useCallback(\n async (files: File[]): Promise<void> => {\n if (sessionId === null) return;\n await addComposerFiles(sessionId, files);\n },\n [sessionId],\n );\n\n const submit = (): void => {\n void submitComposerDraft(sessionId, 'submit', composerContext);\n };\n const queue = (): void => {\n void submitComposerDraft(sessionId, 'queue', composerContext);\n };\n\n const placeholder = !attached\n ? 'Waiting for the session…'\n : active\n ? 'Interrupt the run and respond…'\n : 'Ask anything · / for commands · $ for skills · @ for files…';\n const abortAction = (\n <Button\n variant=\"danger-outline\"\n size=\"lg\"\n data-testid=\"composer-abort\"\n disabled={aborting}\n onClick={() => abortRun(sessionId)}\n >\n <StopIcon className=\"h-2 w-2 fill-current\" />\n {aborting ? 'Aborting…' : 'Abort'}\n </Button>\n );\n\n // A finished workflow step is history, never a session the composer may wake.\n if (dormant && meta?.summary.sessionProvenance === WORKFLOW_STEP_SESSION_PROVENANCE) return null;\n\n if (dormant && meta !== null && sessionId !== null) {\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-2.5 sm:px-5\">\n <DormantPanel key={sessionId} meta={meta} />\n </div>\n );\n }\n\n // A tool waiting on an answer takes the input's place rather than opening\n // over the conversation: the transcript is what the reader needs in order\n // to answer, and there is nothing to type here until the agent is unblocked.\n if (prompt !== null) {\n return (\n <div className=\"flex min-h-0 flex-col px-3 pt-3 pb-2.5 sm:px-5\">\n <QueueSheet\n key={sessionId}\n sessionId={sessionId}\n count={queued}\n disabled={!attached || lifecycle === null || aborting}\n entries={queuedEntries}\n onClear={() => clearQueuedMessages(sessionId)}\n onDelete={(id) => deleteQueuedMessage(id, queued, sessionId)}\n onPromote={(id, operationId) => promoteQueuedMessage(id, operationId, sessionId)}\n onResume={() => resumeQueuedMessages(sessionId)}\n operationId={lifecycle?.operation?.id}\n paused={lifecycle?.paused}\n />\n <div className=\"flex min-h-0 flex-col rounded-lg border border-po-edge-magenta bg-po-deep\">\n <ComposerPrompt claim={prompt} sessionId={sessionId} />\n </div>\n {active ? <div className=\"mt-2 flex justify-end\">{abortAction}</div> : null}\n </div>\n );\n }\n\n // A remote call can still ask the user something while the local agent is locked.\n if (agentLocked && sessionId !== null) {\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-2.5 sm:px-5\">\n <AgentLockPanel key={sessionId} sessionId={sessionId} />\n </div>\n );\n }\n\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-2.5 sm:px-5\">\n <QueueSheet\n key={sessionId}\n sessionId={sessionId}\n count={queued}\n disabled={!attached || lifecycle === null || aborting}\n entries={queuedEntries}\n onClear={() => clearQueuedMessages(sessionId)}\n onDelete={(id) => deleteQueuedMessage(id, queued, sessionId)}\n onPromote={(id, operationId) => promoteQueuedMessage(id, operationId, sessionId)}\n onResume={() => resumeQueuedMessages(sessionId)}\n operationId={lifecycle?.operation?.id}\n paused={lifecycle?.paused}\n />\n <Popover\n open={completion !== null}\n onOpenChange={(next) => {\n if (!next) dismissCompletion();\n }}\n >\n <PopoverAnchor asChild>\n <div\n ref={containerRef}\n onDragOver={(event) => {\n if (!attached || !event.dataTransfer.types.includes('Files')) return;\n event.preventDefault();\n event.dataTransfer.dropEffect = 'copy';\n setDraggingFiles(true);\n }}\n onDragLeave={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setDraggingFiles(false);\n }}\n onDrop={(event) => {\n setDraggingFiles(false);\n if (!attached || event.dataTransfer.files.length === 0) return;\n event.preventDefault();\n void addFiles(Array.from(event.dataTransfer.files));\n }}\n className={`relative rounded-xl border transition-colors focus-within:border-po-blue/60 focus-within:ring-2 focus-within:ring-po-blue/10 ${\n draggingFiles ? 'border-po-blue bg-po-blue/5' : active ? 'border-po-edge-yellow' : 'border-po-border'\n }`}\n >\n {completion ? (\n <PopoverContent\n side=\"top\"\n align=\"start\"\n sideOffset={8}\n data-testid=\"composer-completion\"\n // The keys belong to the textarea, so the menu never takes\n // focus; a click in the composer is a caret move, not a\n // dismissal, which is why the anchor is exempt from outside.\n onOpenAutoFocus={(event) => event.preventDefault()}\n onCloseAutoFocus={(event) => event.preventDefault()}\n onInteractOutside={(event) => {\n if (containerRef.current?.contains(event.target as Node) === true) event.preventDefault();\n }}\n className=\"max-h-[min(16rem,40dvh,var(--radix-popover-content-available-height))] w-[420px] max-w-[85vw] rounded-md p-0 shadow-xl sm:max-h-[min(20rem,50dvh,var(--radix-popover-content-available-height))]\"\n >\n <div className=\"min-h-0 overflow-y-auto overscroll-contain\" data-testid=\"composer-completion-options\">\n {completion.items.map((item, index) => (\n <OptionRow\n key={item.label}\n density=\"compact\"\n active={index === completion.selected}\n data-testid={`composer-completion-item-${String(index)}`}\n onMouseEnter={() => setCompletion({ ...completion, selected: index })}\n onMouseDown={(event) => {\n event.preventDefault();\n accept(completion, index);\n }}\n className=\"w-full items-baseline gap-2.5 rounded-none px-3 py-1.5\"\n >\n <span className=\"min-w-0 truncate text-base font-semibold text-po-hi\">{item.label}</span>\n {item.detail ? (\n <OptionLabel density=\"compact\" className=\"text-sm text-po-dim\">\n {item.detail}\n </OptionLabel>\n ) : null}\n </OptionRow>\n ))}\n </div>\n <PopoverFooter className=\"py-1\">\n <span className=\"flex items-center gap-1.5\">\n <Kbd>tab</Kbd> or <Kbd>enter</Kbd> completes · <Kbd>esc</Kbd> closes\n </span>\n </PopoverFooter>\n </PopoverContent>\n ) : null}\n <div className=\"flex min-w-0 items-start px-3 pt-3 sm:px-4 sm:pt-3.5\">\n <Textarea\n variant=\"bare\"\n ref={inputRef}\n data-testid=\"composer-input\"\n value={draft}\n disabled={!attached}\n onChange={(event) => {\n updateComposerState(sessionId, (state) => ({\n ...state,\n draft: event.target.value,\n caret: event.target.selectionStart,\n dismissedToken: null,\n }));\n }}\n onClick={(event) =>\n updateComposerState(sessionId, (state) => ({ ...state, caret: event.currentTarget.selectionStart }))\n }\n onPaste={(event) => {\n const files = Array.from(event.clipboardData.files);\n if (files.length === 0) return;\n event.preventDefault();\n void addFiles(files);\n }}\n onKeyUp={(event) =>\n updateComposerState(sessionId, (state) => ({ ...state, caret: event.currentTarget.selectionStart }))\n }\n onKeyDown={(event) => {\n // The TUI's leader key: space with nothing typed opens Leader Space.\n if (event.key === ' ' && draft === '') {\n event.preventDefault();\n openPalette();\n return;\n }\n if (completion) {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n const delta = event.key === 'ArrowDown' ? 1 : -1;\n const count = completion.items.length;\n setCompletion({ ...completion, selected: (completion.selected + delta + count) % count });\n return;\n }\n if (event.key === 'Tab') {\n event.preventDefault();\n accept(completion, completion.selected);\n return;\n }\n // Enter completes, unless the token is already the whole\n // thing: completing then would only add a space, so the\n // keystroke would read as doing nothing and the reader would\n // have to press enter twice to send what they had typed.\n if (event.key === 'Enter' && !isCompletionRedundant(completion)) {\n event.preventDefault();\n accept(completion, completion.selected);\n return;\n }\n if (event.key === 'Escape') {\n event.preventDefault();\n dismissCompletion();\n return;\n }\n }\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n submit();\n }\n if (event.key === 'Escape' && active && !aborting) {\n event.preventDefault();\n abortRun(sessionId);\n }\n }}\n rows={1}\n placeholder={placeholder}\n className=\"min-h-12 min-w-0 flex-1 text-lg leading-relaxed\"\n />\n </div>\n {attachments.length > 0 ? (\n <div className=\"flex flex-wrap gap-1.5 px-3.5 pt-2\" data-testid=\"composer-attachments\">\n {attachments.map((attachment) => (\n <span\n key={attachment.id}\n data-testid={`composer-attachment-${attachment.id}`}\n className=\"flex max-w-full items-center gap-1.5 rounded border border-po-border bg-po-panel px-1.5 py-1 text-sm text-po-dim\"\n >\n {attachment.kind === 'image' ? (\n <img src={attachment.dataUrl} alt=\"\" className=\"h-6 w-6 rounded object-cover\" />\n ) : (\n <span className=\"font-semibold text-po-hi\">\n {attachment.kind === 'context' ? 'CTX' : attachment.kind === 'file' ? 'FILE' : 'TXT'}\n </span>\n )}\n <span className=\"max-w-40 truncate\">{attachment.name}</span>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n aria-label={`Remove ${attachment.name}`}\n className=\"text-po-faint hover:text-po-text\"\n onClick={() => {\n updateComposerState(sessionId, (state) => ({\n ...state,\n attachments: state.attachments.filter((item) => item.id !== attachment.id),\n attachmentError: '',\n }));\n }}\n >\n <CloseIcon className=\"h-2.5 w-2.5\" />\n </Button>\n </span>\n ))}\n </div>\n ) : null}\n {attachmentError ? (\n <p role=\"alert\" data-testid=\"composer-attachment-error\" className=\"px-3.5 pt-1.5 text-sm text-po-red\">\n {attachmentError}\n </p>\n ) : null}\n <div className=\"flex flex-wrap items-center gap-2 px-2 pt-2 pb-2.5 sm:flex-nowrap sm:px-3 sm:pb-3\">\n <Popover\n open={menuOpen}\n onOpenChange={(next) => {\n setMenuOpen(next);\n if (next) dismissCompletion();\n }}\n >\n <PopoverTrigger asChild>\n <Button\n variant=\"ghost\"\n size=\"icon-md\"\n data-testid=\"composer-attach\"\n title=\"Add to this message\"\n aria-label=\"Add to this message\"\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen}\n className=\"shrink-0 text-po-dim\"\n >\n <PlusIcon className=\"size-4\" />\n </Button>\n </PopoverTrigger>\n {menuOpen ? (\n <PopoverContent\n side=\"top\"\n align=\"start\"\n sideOffset={8}\n data-testid=\"composer-menu\"\n className=\"w-56 rounded-md p-1.5 shadow-xl\"\n // A menu entry is a way out of the menu: whatever a plugin\n // opens, the menu has done its part. The upload row is the\n // exception, because its click opens the file chooser and\n // unmounting the input under it would strand the pick.\n onClick={(event) => {\n const clicked = event.target as Element | null;\n if (clicked?.closest('[data-testid=\"composer-attach-row\"]')) return;\n setMenuOpen(false);\n }}\n >\n {/* prefer-shared-primitive: ignore -- OptionRow is a button, and a file input may not nest inside one. */}\n <label\n aria-disabled={!attached}\n data-testid=\"composer-attach-row\"\n className={`relative overflow-hidden text-base font-medium text-po-text hover:bg-po-tint-blue ${optionRowVariants(\n { density: 'compact' },\n )} ${attached ? '' : 'pointer-events-none opacity-40'}`}\n >\n <PlusIcon className=\"h-3 w-3 shrink-0\" />\n <span className=\"min-w-0 flex-1 truncate\">File upload</span>\n {/* prefer-shared-primitive: ignore -- iOS needs the native file input itself to cover the visible tap target. */}\n <input\n type=\"file\"\n multiple\n disabled={!attached}\n aria-label=\"Attach files\"\n className=\"absolute inset-0 cursor-pointer opacity-0\"\n data-testid=\"composer-file-input\"\n onChange={(event) => {\n void addFiles(Array.from(event.currentTarget.files ?? []));\n event.currentTarget.value = '';\n setMenuOpen(false);\n }}\n />\n </label>\n <span className=\"contents\" data-testid=\"composer-menu-items\">\n <PluginSurface slot={HOST_SLOTS.composerMenu} sessionId={sessionId} />\n </span>\n </PopoverContent>\n ) : null}\n </Popover>\n <span className=\"min-w-0 flex-1\" />\n <span data-testid=\"composer-hint\" className=\"text-sm text-po-dim max-md:hidden\">\n {active\n ? aborting\n ? 'Abort requested · waiting for the turn to stop'\n : 'Enter steers the run · esc aborts'\n : 'Shift + Enter for a new line'}\n </span>\n {active ? abortAction : null}\n <span className=\"contents\" data-testid=\"composer-actions\">\n <PluginSurface slot={HOST_SLOTS.composerActions} sessionId={sessionId} />\n </span>\n <Button\n variant=\"outline\"\n size=\"lg\"\n data-testid=\"composer-queue\"\n onClick={queue}\n disabled={\n !attached ||\n pendingSubmission ||\n pendingAttachments > 0 ||\n (!draft.trim() && attachments.length === 0)\n }\n title=\"Deliver after the current run settles\"\n >\n Queue\n </Button>\n <Button\n variant=\"primary\"\n size=\"lg\"\n data-testid=\"composer-send\"\n onClick={submit}\n disabled={\n !attached ||\n pendingSubmission ||\n pendingAttachments > 0 ||\n (!draft.trim() && attachments.length === 0)\n }\n className=\"gap-2 px-3 disabled:opacity-60 sm:px-4\"\n >\n <SendIcon aria-hidden className=\"size-4\" />\n {active ? 'Steer' : 'Send'}\n </Button>\n </div>\n </div>\n </PopoverAnchor>\n </Popover>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAM,sBAAsB;AAC5B,MAAM,0BAA0B;AAChC,MAAM,8BAAc,IAAI,IAAI;CAAC;CAAa;CAAc;CAAa;AAAY,CAAC;AAClF,MAAM,kCAAkB,IAAI,IAAI;CAC9B;CACA;C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ACjE,CAAA,CACQ;SACd,CAAA,IAAA,IACG;;QACT,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD,EAAM,WAAU,iBAAkB,CAAA;QAClC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;SAAM,eAAY;SAAgB,WAAU;SACzC,UAAA,SACG,WACE,mDACA,sCACF;QACA,CAAA;QACL,SAAS,cAAc;QACxB,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;SAAM,WAAU;SAAW,eAAY;SACrC,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACD,sBAAAA,eAAD;UAAe,MAAMC,uBAAAA,WAAW;UAA4B;SAAY,CAAA;QACpE,CAAA;QACN,iBAAA,GAAA,kBAAA,IAAA,CAAC1B,6BAAAA,QAAD;SACE,SAAQ;SACR,MAAK;SACL,eAAY;SACZ,SAAS;SACT,UACE,CAAC,YACD,qBACA,qBAAqB,KACpB,CAAC,MAAM,KAAK,KAAK,YAAY,WAAW;SAE3C,OAAM;SACP,UAAA;QAEO,CAAA;QACR,iBAAA,GAAA,kBAAA,KAAA,CAACA,6BAAAA,QAAD;SACE,SAAQ;SACR,MAAK;SACL,eAAY;SACZ,SAAS;SACT,UACE,CAAC,YACD,qBACA,qBAAqB,KACpB,CAAC,MAAM,KAAK,KAAK,YAAY,WAAW;SAE3C,WAAU;SAXZ,UAAA,CAaE,iBAAA,GAAA,kBAAA,IAAA,CAAC2B,6BAAAA,UAAD;UAAU,eAAA;UAAY,WAAU;SAAU,CAAA,GACzC,SAAS,UAAU,MACd;;OACL;;KACF;;GACQ,CAAA;EACR,CAAA,CACN;;AAET"}
1
+ {"version":3,"file":"Composer.cjs","names":["uploadSessionAttachment","inlineTextBytes","composerStore","TRIGGER_CHARS","useStore","sessionsStore","useActiveSessionMeta","useActiveSession","useToolPrompt","useComposerState","useState","composerSubmissionStore","useRef","registerPromptInput","useCallback","triggerTokenAt","commandCompletions","searchSessionFiles","fileCompletions","submitComposerDraft","Button","abortRun","StopIcon","WORKFLOW_STEP_SESSION_PROVENANCE","DormantPanel","QueueSheet","clearQueuedMessages","deleteQueuedMessage","promoteQueuedMessage","resumeQueuedMessages","ComposerPrompt","AgentLockPanel","Popover","PopoverAnchor","PopoverContent","OptionRow","OptionLabel","PopoverFooter","Kbd","Textarea","updateComposerState","CloseIcon","PopoverTrigger","PlusIcon","optionRowVariants","PluginSurface","HOST_SLOTS","SendIcon"],"sources":["../../../../src/web/features/session/Composer.tsx"],"sourcesContent":["import { WORKFLOW_STEP_SESSION_PROVENANCE } from '@agimon-ai/po-core/hubChannel';\nimport type { TransientTab } from '@agimon-ai/po-core/web';\nimport {\n Button,\n CloseIcon,\n Kbd,\n OptionLabel,\n OptionRow,\n optionRowVariants,\n PlusIcon,\n SendIcon,\n Popover,\n PopoverAnchor,\n PopoverContent,\n PopoverFooter,\n PopoverTrigger,\n StopIcon,\n Textarea,\n} from '@agimon-ai/po-web-components';\nimport { useStore } from '@tanstack/react-store';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { PluginSurface } from '../../components/PluginSurface';\nimport {\n type CompletionItem,\n type CompletionKind,\n commandCompletions,\n fileCompletions,\n TRIGGER_CHARS,\n triggerTokenAt,\n} from '../../lib/composerCompletion';\nimport { searchSessionFiles } from '../../lib/hubApi';\nimport { HOST_SLOTS } from '../../lib/pluginRegistry';\nimport { registerPromptInput } from '../../lib/promptFocus';\nimport { uploadSessionAttachment } from '../../lib/sessionAsset';\nimport type { QueuedEntry } from '../../lib/sessionModel';\nimport {\n composerStore,\n type ComposerAttachment,\n type ComposerSessionState,\n inlineTextBytes,\n MAX_COMPOSER_UPLOAD_BYTES,\n MAX_COMPOSER_ATTACHMENTS,\n MAX_COMPOSER_IMAGE_BYTES,\n MAX_COMPOSER_TEXT_BYTES,\n MAX_COMPOSER_TOTAL_IMAGE_BYTES,\n MAX_COMPOSER_TOTAL_TEXT_BYTES,\n updateComposerState,\n useComposerState,\n} from '../../stores/composerStore';\nimport { composerSubmissionStore, submitComposerDraft } from '../../stores/composerSubmissionStore';\nimport { openPalette } from '../../stores/paletteStore';\nimport { sessionsStore, useActiveSessionMeta } from '../../stores/sessionsStore';\nimport {\n abortRun,\n clearQueuedMessages,\n deleteQueuedMessage,\n promoteQueuedMessage,\n resumeQueuedMessages,\n useActiveSession,\n} from '../../stores/sessionStore';\nimport { useToolPrompt } from '../../stores/useToolPrompt';\nimport { AgentLockPanel } from './AgentLockPanel';\nimport { ComposerPrompt } from './ComposerPrompt';\nimport { DormantPanel } from './DormantPanel';\nimport { QueueSheet } from './QueueSheet';\n\n/** The input grows with the draft up to this many pixels, then scrolls. */\nconst MAX_INPUT_HEIGHT_PX = 192;\nconst FILE_SEARCH_DEBOUNCE_MS = 300;\nconst IMAGE_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp']);\nconst TEXT_EXTENSIONS = new Set([\n 'c',\n 'cpp',\n 'css',\n 'csv',\n 'go',\n 'h',\n 'hpp',\n 'html',\n 'ini',\n 'java',\n 'js',\n 'json',\n 'jsonl',\n 'jsx',\n 'log',\n 'md',\n 'markdown',\n 'py',\n 'rb',\n 'rs',\n 'sh',\n 'sql',\n 'toml',\n 'ts',\n 'tsv',\n 'tsx',\n 'txt',\n 'xml',\n 'yaml',\n 'yml',\n]);\n\nfunction isReadableText(file: File): boolean {\n const extension = file.name.toLowerCase().split('.').pop() ?? '';\n return file.type.startsWith('text/') || TEXT_EXTENSIONS.has(extension);\n}\n\nfunction readDataUrl(file: File): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () =>\n typeof reader.result === 'string' ? resolve(reader.result) : reject(new Error('No file data'));\n reader.onerror = () => reject(reader.error ?? new Error('Could not read file'));\n reader.readAsDataURL(file);\n });\n}\n\n/**\n * Stores a copy on the host so a tool can be handed the file by path. Images and\n * text still travel inline, so for them a failed upload only means no path.\n */\nasync function storedPath(sessionId: string, file: File): Promise<string | undefined> {\n try {\n return (await uploadSessionAttachment(sessionId, file)).path;\n } catch {\n return undefined; // Documented fallback: the inline copy is still sent.\n }\n}\n\nconst TOO_MANY_ATTACHMENTS = `Only ${String(MAX_COMPOSER_ATTACHMENTS)} attachments are allowed.`;\n\n/** Why one more image or text file would break a total budget, or '' when it fits. */\nfunction totalBudgetRejection(\n attachments: ComposerAttachment[],\n kind: ComposerAttachment['kind'],\n name: string,\n size: number,\n): string {\n if (kind === 'image') {\n const imageBytes = attachments.reduce((total, item) => total + (item.kind === 'image' ? item.size : 0), 0);\n return imageBytes + size > MAX_COMPOSER_TOTAL_IMAGE_BYTES ? `${name} exceeds the 20 MB total image limit.` : '';\n }\n if (kind === 'text' && inlineTextBytes(attachments) + size > MAX_COMPOSER_TOTAL_TEXT_BYTES) {\n return `${name} exceeds the 200 KB total text limit.`;\n }\n return '';\n}\n\n/**\n * Reads picked, pasted or dropped files into new attachments, numbered from\n * `current.nextAttachmentId` and budgeted after the ones already staged.\n */\nexport async function readComposerFiles(\n sessionId: string,\n files: File[],\n current: Pick<ComposerSessionState, 'attachments' | 'nextAttachmentId'>,\n): Promise<Pick<ComposerSessionState, 'attachments' | 'attachmentError'>> {\n const next = [...current.attachments];\n const rejected: string[] = [];\n let attachmentId = current.nextAttachmentId;\n\n for (const file of files) {\n if (next.length >= MAX_COMPOSER_ATTACHMENTS) {\n rejected.push(TOO_MANY_ATTACHMENTS);\n break;\n }\n const id = `attachment-${String(attachmentId++)}`;\n if (IMAGE_TYPES.has(file.type)) {\n if (file.size > MAX_COMPOSER_IMAGE_BYTES) {\n rejected.push(`${file.name} exceeds the 10 MB image limit.`);\n continue;\n }\n const overBudget = totalBudgetRejection(next, 'image', file.name, file.size);\n if (overBudget) {\n rejected.push(overBudget);\n continue;\n }\n try {\n const dataUrl = await readDataUrl(file);\n const path = file.size > MAX_COMPOSER_UPLOAD_BYTES ? undefined : await storedPath(sessionId, file);\n next.push({\n id,\n kind: 'image',\n name: file.name,\n size: file.size,\n dataUrl,\n data: dataUrl.slice(dataUrl.indexOf(',') + 1),\n mimeType: file.type,\n ...(path === undefined ? {} : { path }),\n });\n } catch {\n rejected.push(`${file.name} could not be read.`);\n }\n continue;\n }\n if (!isReadableText(file)) {\n if (file.size > MAX_COMPOSER_UPLOAD_BYTES) {\n rejected.push(`\"${file.name}\" exceeds the 8 MB file limit.`);\n continue;\n }\n try {\n const stored = await uploadSessionAttachment(sessionId, file);\n next.push({\n id,\n kind: 'file',\n name: file.name,\n size: stored.size,\n mimeType: stored.mimeType,\n path: stored.path,\n });\n } catch {\n rejected.push(`\"${file.name}\" could not be uploaded.`);\n }\n continue;\n }\n if (file.size > MAX_COMPOSER_TEXT_BYTES) {\n rejected.push(`${file.name} exceeds the 100 KB text file limit.`);\n continue;\n }\n const overBudget = totalBudgetRejection(next, 'text', file.name, file.size);\n if (overBudget) {\n rejected.push(overBudget);\n continue;\n }\n try {\n const content = await file.text();\n const path = await storedPath(sessionId, file);\n next.push({\n id,\n kind: 'text',\n name: file.name,\n size: file.size,\n content,\n ...(path === undefined ? {} : { path }),\n });\n } catch {\n rejected.push(`${file.name} could not be read.`);\n }\n }\n return { attachments: next.slice(current.attachments.length), attachmentError: rejected.join(' ') };\n}\n\n/**\n * Stages files on a session's composer. Reading and uploading are async, so\n * the batch reserves its ids and marks itself pending up front, then appends\n * to whatever the composer holds by the time it finishes: chips removed, a\n * message sent, or another batch staged meanwhile all stay as they are, and\n * the count and total budgets are checked again against that latest state.\n */\nexport async function addComposerFiles(sessionId: string, files: File[]): Promise<void> {\n if (files.length === 0) return;\n let current: Pick<ComposerSessionState, 'attachments' | 'nextAttachmentId'> = {\n attachments: [],\n nextAttachmentId: 0,\n };\n updateComposerState(sessionId, (state) => {\n current = state;\n return {\n ...state,\n nextAttachmentId: state.nextAttachmentId + files.length,\n pendingAttachments: state.pendingAttachments + 1,\n };\n });\n const read = await readComposerFiles(sessionId, files, current);\n if (composerStore.state[sessionId] === undefined) return; // The session left while the files were read.\n updateComposerState(sessionId, (state) => {\n const attachments = [...state.attachments];\n const rejected = read.attachmentError ? [read.attachmentError] : [];\n for (const attachment of read.attachments) {\n if (attachments.length >= MAX_COMPOSER_ATTACHMENTS) {\n if (!read.attachmentError.includes(TOO_MANY_ATTACHMENTS)) rejected.push(TOO_MANY_ATTACHMENTS);\n break;\n }\n const overBudget = totalBudgetRejection(attachments, attachment.kind, attachment.name, attachment.size);\n if (overBudget) rejected.push(overBudget);\n else attachments.push(attachment);\n }\n return {\n ...state,\n attachments,\n attachmentError: rejected.join(' '),\n pendingAttachments: Math.max(0, state.pendingAttachments - 1),\n };\n });\n}\n\ninterface CompletionState {\n kind: CompletionKind;\n /** Index of the trigger character in the draft. */\n tokenStart: number;\n query: string;\n items: CompletionItem[];\n selected: number;\n}\n\n/**\n * Whether accepting the highlighted item would leave the draft as it is. The\n * popup still shows what a longer name would complete to, but the keystroke\n * that would change nothing is handed back to the composer to send.\n */\nfunction isCompletionRedundant(state: CompletionState): boolean {\n const item = state.items[state.selected];\n return item !== undefined && item.insert.trimEnd() === `${TRIGGER_CHARS[state.kind]}${state.query}`;\n}\n\nexport function Composer({ composerContext }: { composerContext?: TransientTab['composerContext'] } = {}) {\n const sessionId = useStore(sessionsStore, (state) => state.activeId);\n const meta = useActiveSessionMeta();\n const streaming = useActiveSession((state) => state.streaming);\n const lifecycle = useActiveSession((state) => state.lifecycle);\n const agentLocked = useActiveSession((state) => state.agentLocked);\n const active = lifecycle === null ? streaming : lifecycle.operation !== null;\n const aborting = lifecycle?.operation?.status === 'aborting';\n const queuedEntries = useActiveSession((state) =>\n state.entries.filter((entry): entry is QueuedEntry => entry.kind === 'queued'),\n );\n const commands = useActiveSession((state) => state.commands);\n const editorTextRequest = useActiveSession((state) => state.editorTextRequest);\n const prompt = useToolPrompt();\n const { draft, caret, dismissedToken, attachments, attachmentError, pendingAttachments } =\n useComposerState(sessionId);\n const [completion, setCompletion] = useState<CompletionState | null>(null);\n const [draggingFiles, setDraggingFiles] = useState(false);\n const [menuOpen, setMenuOpen] = useState(false);\n const pendingSubmission = useStore(\n composerSubmissionStore,\n (pending) => sessionId !== null && pending.has(sessionId),\n );\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const searchTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n const dormant = meta?.summary.dormant === true;\n const attached = !dormant && meta?.attach === 'attached';\n const queued = lifecycle === null ? queuedEntries.length : lifecycle.queue.length;\n\n // Completion and drag state are transient. The draft and attachments below\n // come from the newly focused session immediately after this reset, so the\n // reset is done during render rather than in an effect: a frame of the\n // previous session's popup would otherwise be painted over the new draft.\n const [shownSession, setShownSession] = useState(sessionId);\n if (shownSession !== sessionId) {\n setShownSession(sessionId);\n setCompletion(null);\n setDraggingFiles(false);\n setMenuOpen(false);\n }\n\n // The completion popup and the '+' menu are two popovers over one composer,\n // and the completion one exempts its own anchor from outside clicks. Keeping\n // them mutually exclusive means that guard never has to reason about the\n // other's portalled content. Adjusted during render, like the session reset\n // above, so the menu is already gone in the frame the popup appears in.\n if (menuOpen && completion !== null) setMenuOpen(false);\n useEffect(() => {\n if (searchTimer.current) clearTimeout(searchTimer.current);\n }, [sessionId]);\n\n // Overlays hand the keyboard back here when they close. Re-registered when\n // a tool prompt stands the input down and again when it gives it back:\n // otherwise the ref stays as it was and every later hand-back goes nowhere.\n useEffect(() => registerPromptInput(inputRef.current), [dormant, prompt]);\n\n useEffect(() => {\n if (editorTextRequest === null) return;\n updateComposerState(sessionId, (state) => {\n const draft = editorTextRequest.append\n ? `${state.draft}${state.draft && !/\\s$/u.test(state.draft) ? ' ' : ''}${editorTextRequest.text}`\n : editorTextRequest.text;\n return { ...state, draft, caret: draft.length, dismissedToken: null };\n });\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n const length = inputRef.current?.value.length ?? 0;\n inputRef.current?.setSelectionRange(length, length);\n });\n }, [editorTextRequest, sessionId]);\n\n // Auto-grow: measure after every draft change so pasted stack traces are\n // actually visible instead of scrolling inside one line.\n const resize = useCallback((): void => {\n const input = inputRef.current;\n if (!input) return;\n input.style.height = 'auto';\n input.style.height = `${String(Math.min(input.scrollHeight, MAX_INPUT_HEIGHT_PX))}px`;\n }, []);\n useEffect(() => resize(), [draft, resize]);\n\n const closeCompletion = useCallback((): void => {\n if (searchTimer.current) clearTimeout(searchTimer.current);\n setCompletion(null);\n }, []);\n\n /** Esc dismisses the popup for the token being typed; edits re-arm it. */\n const dismissCompletion = useCallback((): void => {\n const trigger = triggerTokenAt(draft, caret);\n updateComposerState(sessionId, (state) => ({ ...state, dismissedToken: trigger?.start ?? null }));\n closeCompletion();\n }, [draft, caret, closeCompletion, sessionId]);\n\n // The popup is derived state: any change to the draft, caret, session\n // commands, or attachment recomputes it, so data arriving after a keystroke\n // still opens it.\n useEffect(() => {\n const trigger = triggerTokenAt(draft, caret);\n if (!trigger || !attached || dismissedToken === trigger.start) {\n // eslint-disable-next-line react/set-state-in-effect -- the popup tracks an async, debounced search; closing it is the synchronous arm of that same effect.\n closeCompletion();\n return;\n }\n if (trigger.kind === 'command' || trigger.kind === 'skill') {\n const items = commandCompletions(commands, trigger.kind, trigger.query);\n setCompletion(\n items.length > 0\n ? { kind: trigger.kind, tokenStart: trigger.start, query: trigger.query, items, selected: 0 }\n : null,\n );\n return;\n }\n if (searchTimer.current) clearTimeout(searchTimer.current);\n searchTimer.current = setTimeout(() => {\n if (sessionId === null) return;\n void searchSessionFiles(sessionId, trigger.query).then((files) => {\n // The session or draft may have moved on while the lookup ran.\n const input = inputRef.current;\n if (\n sessionsStore.state.activeId !== sessionId ||\n !input ||\n triggerTokenAt(input.value, input.selectionStart)?.query !== trigger.query\n )\n return;\n const items = fileCompletions(files);\n setCompletion(\n items.length > 0\n ? { kind: 'file', tokenStart: trigger.start, query: trigger.query, items, selected: 0 }\n : null,\n );\n });\n }, FILE_SEARCH_DEBOUNCE_MS);\n return () => {\n if (searchTimer.current) clearTimeout(searchTimer.current);\n };\n }, [draft, caret, commands, attached, dismissedToken, closeCompletion, sessionId]);\n\n // Clicking anywhere outside the composer closes the popup.\n useEffect(() => {\n if (!completion) return;\n const onPointerDown = (event: MouseEvent): void => {\n if (containerRef.current && event.target instanceof Node && !containerRef.current.contains(event.target)) {\n closeCompletion();\n }\n };\n document.addEventListener('mousedown', onPointerDown);\n return () => document.removeEventListener('mousedown', onPointerDown);\n }, [completion, closeCompletion]);\n\n const accept = (state: CompletionState, index: number): void => {\n const item = state.items[index];\n if (!item) return;\n const next = draft.slice(0, state.tokenStart) + item.insert + draft.slice(caret);\n const position = state.tokenStart + item.insert.length;\n updateComposerState(sessionId, (current) => ({\n ...current,\n draft: next,\n caret: position,\n dismissedToken: state.tokenStart,\n }));\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n inputRef.current?.setSelectionRange(position, position);\n });\n };\n\n const addFiles = useCallback(\n async (files: File[]): Promise<void> => {\n if (sessionId === null) return;\n await addComposerFiles(sessionId, files);\n },\n [sessionId],\n );\n\n const submit = (): void => {\n void submitComposerDraft(sessionId, 'submit', composerContext);\n };\n const queue = (): void => {\n void submitComposerDraft(sessionId, 'queue', composerContext);\n };\n\n const placeholder = !attached\n ? 'Waiting for the session…'\n : active\n ? 'Interrupt the run and respond…'\n : 'Ask anything · / for commands · $ for skills · @ for files…';\n const abortAction = (\n <Button\n variant=\"danger-outline\"\n size=\"lg\"\n data-testid=\"composer-abort\"\n disabled={aborting}\n onClick={() => abortRun(sessionId)}\n >\n <StopIcon className=\"h-2 w-2 fill-current\" />\n {aborting ? 'Aborting…' : 'Abort'}\n </Button>\n );\n\n // A finished workflow step is history, never a session the composer may wake.\n if (dormant && meta?.summary.sessionProvenance === WORKFLOW_STEP_SESSION_PROVENANCE) return null;\n\n if (dormant && meta !== null && sessionId !== null) {\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-2.5 sm:px-5\">\n <DormantPanel key={sessionId} meta={meta} />\n </div>\n );\n }\n\n // A tool waiting on an answer takes the input's place rather than opening\n // over the conversation: the transcript is what the reader needs in order\n // to answer, and there is nothing to type here until the agent is unblocked.\n if (prompt !== null) {\n return (\n <div className=\"flex min-h-0 flex-col px-3 pt-3 pb-2.5 sm:px-5\">\n <QueueSheet\n key={sessionId}\n sessionId={sessionId}\n count={queued}\n disabled={!attached || lifecycle === null || aborting}\n entries={queuedEntries}\n onClear={() => clearQueuedMessages(sessionId)}\n onDelete={(id) => deleteQueuedMessage(id, queued, sessionId)}\n onPromote={(id, operationId) => promoteQueuedMessage(id, operationId, sessionId)}\n onResume={() => resumeQueuedMessages(sessionId)}\n operationId={lifecycle?.operation?.id}\n paused={lifecycle?.paused}\n />\n <div className=\"flex min-h-0 flex-col rounded-lg border border-po-edge-magenta bg-po-deep\">\n <ComposerPrompt claim={prompt} sessionId={sessionId} />\n </div>\n {active ? <div className=\"mt-2 flex justify-end\">{abortAction}</div> : null}\n </div>\n );\n }\n\n // A remote call can still ask the user something while the local agent is locked.\n if (agentLocked && sessionId !== null) {\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-2.5 sm:px-5\">\n <AgentLockPanel key={sessionId} sessionId={sessionId} />\n </div>\n );\n }\n\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-2.5 sm:px-5\">\n <QueueSheet\n key={sessionId}\n sessionId={sessionId}\n count={queued}\n disabled={!attached || lifecycle === null || aborting}\n entries={queuedEntries}\n onClear={() => clearQueuedMessages(sessionId)}\n onDelete={(id) => deleteQueuedMessage(id, queued, sessionId)}\n onPromote={(id, operationId) => promoteQueuedMessage(id, operationId, sessionId)}\n onResume={() => resumeQueuedMessages(sessionId)}\n operationId={lifecycle?.operation?.id}\n paused={lifecycle?.paused}\n />\n <Popover\n open={completion !== null}\n onOpenChange={(next) => {\n if (!next) dismissCompletion();\n }}\n >\n <PopoverAnchor asChild>\n <div\n ref={containerRef}\n onDragOver={(event) => {\n if (!attached || !event.dataTransfer.types.includes('Files')) return;\n event.preventDefault();\n event.dataTransfer.dropEffect = 'copy';\n setDraggingFiles(true);\n }}\n onDragLeave={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setDraggingFiles(false);\n }}\n onDrop={(event) => {\n setDraggingFiles(false);\n if (!attached || event.dataTransfer.files.length === 0) return;\n event.preventDefault();\n void addFiles(Array.from(event.dataTransfer.files));\n }}\n className={`relative rounded-xl border transition-colors focus-within:border-po-blue/60 focus-within:ring-2 focus-within:ring-po-blue/10 ${\n draggingFiles ? 'border-po-blue bg-po-blue/5' : active ? 'border-po-edge-yellow' : 'border-po-border'\n }`}\n >\n {completion ? (\n <PopoverContent\n side=\"top\"\n align=\"start\"\n sideOffset={8}\n data-testid=\"composer-completion\"\n // The keys belong to the textarea, so the menu never takes\n // focus; a click in the composer is a caret move, not a\n // dismissal, which is why the anchor is exempt from outside.\n onOpenAutoFocus={(event) => event.preventDefault()}\n onCloseAutoFocus={(event) => event.preventDefault()}\n onInteractOutside={(event) => {\n if (containerRef.current?.contains(event.target as Node) === true) event.preventDefault();\n }}\n className=\"max-h-[min(16rem,40dvh,var(--radix-popover-content-available-height))] w-[420px] max-w-[85vw] rounded-md p-0 shadow-xl sm:max-h-[min(20rem,50dvh,var(--radix-popover-content-available-height))]\"\n >\n <div className=\"min-h-0 overflow-y-auto overscroll-contain\" data-testid=\"composer-completion-options\">\n {completion.items.map((item, index) => (\n <OptionRow\n key={item.label}\n density=\"compact\"\n active={index === completion.selected}\n data-testid={`composer-completion-item-${String(index)}`}\n onMouseEnter={() => setCompletion({ ...completion, selected: index })}\n onMouseDown={(event) => {\n event.preventDefault();\n accept(completion, index);\n }}\n className=\"w-full items-baseline gap-2.5 rounded-none px-3 py-1.5\"\n >\n <span className=\"min-w-0 truncate text-base font-semibold text-po-hi\">{item.label}</span>\n {item.detail ? (\n <OptionLabel density=\"compact\" className=\"text-sm text-po-dim\">\n {item.detail}\n </OptionLabel>\n ) : null}\n </OptionRow>\n ))}\n </div>\n <PopoverFooter className=\"py-1\">\n <span className=\"flex items-center gap-1.5\">\n <Kbd>tab</Kbd> or <Kbd>enter</Kbd> completes · <Kbd>esc</Kbd> closes\n </span>\n </PopoverFooter>\n </PopoverContent>\n ) : null}\n <div className=\"flex min-w-0 items-start px-3 pt-3 sm:px-4 sm:pt-3.5\">\n <Textarea\n variant=\"bare\"\n ref={inputRef}\n data-testid=\"composer-input\"\n value={draft}\n disabled={!attached}\n onChange={(event) => {\n updateComposerState(sessionId, (state) => ({\n ...state,\n draft: event.target.value,\n caret: event.target.selectionStart,\n dismissedToken: null,\n }));\n }}\n onClick={(event) =>\n updateComposerState(sessionId, (state) => ({ ...state, caret: event.currentTarget.selectionStart }))\n }\n onPaste={(event) => {\n const files = Array.from(event.clipboardData.files);\n if (files.length === 0) return;\n event.preventDefault();\n void addFiles(files);\n }}\n onKeyUp={(event) =>\n updateComposerState(sessionId, (state) => ({ ...state, caret: event.currentTarget.selectionStart }))\n }\n onKeyDown={(event) => {\n // The TUI's leader key: space with nothing typed opens Leader Space.\n if (event.key === ' ' && draft === '') {\n event.preventDefault();\n openPalette();\n return;\n }\n if (completion) {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n const delta = event.key === 'ArrowDown' ? 1 : -1;\n const count = completion.items.length;\n setCompletion({ ...completion, selected: (completion.selected + delta + count) % count });\n return;\n }\n if (event.key === 'Tab') {\n event.preventDefault();\n accept(completion, completion.selected);\n return;\n }\n // Enter completes, unless the token is already the whole\n // thing: completing then would only add a space, so the\n // keystroke would read as doing nothing and the reader would\n // have to press enter twice to send what they had typed.\n if (event.key === 'Enter' && !isCompletionRedundant(completion)) {\n event.preventDefault();\n accept(completion, completion.selected);\n return;\n }\n if (event.key === 'Escape') {\n event.preventDefault();\n dismissCompletion();\n return;\n }\n }\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n submit();\n }\n if (event.key === 'Escape' && active && !aborting) {\n event.preventDefault();\n abortRun(sessionId);\n }\n }}\n rows={1}\n placeholder={placeholder}\n className=\"min-h-12 min-w-0 flex-1 text-lg leading-relaxed\"\n />\n </div>\n {attachments.length > 0 ? (\n <div className=\"flex flex-wrap gap-1.5 px-3.5 pt-2\" data-testid=\"composer-attachments\">\n {attachments.map((attachment) => (\n <span\n key={attachment.id}\n data-testid={`composer-attachment-${attachment.id}`}\n className=\"flex max-w-full items-center gap-1.5 rounded border border-po-border bg-po-panel px-1.5 py-1 text-sm text-po-dim\"\n >\n {attachment.kind === 'image' ? (\n <img src={attachment.dataUrl} alt=\"\" className=\"h-6 w-6 rounded object-cover\" />\n ) : (\n <span className=\"font-semibold text-po-hi\">\n {attachment.kind === 'context' ? 'CTX' : attachment.kind === 'file' ? 'FILE' : 'TXT'}\n </span>\n )}\n <span className=\"max-w-40 truncate\">{attachment.name}</span>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n aria-label={`Remove ${attachment.name}`}\n className=\"text-po-faint hover:text-po-text\"\n onClick={() => {\n updateComposerState(sessionId, (state) => ({\n ...state,\n attachments: state.attachments.filter((item) => item.id !== attachment.id),\n attachmentError: '',\n }));\n }}\n >\n <CloseIcon className=\"h-2.5 w-2.5\" />\n </Button>\n </span>\n ))}\n </div>\n ) : null}\n {attachmentError ? (\n <p role=\"alert\" data-testid=\"composer-attachment-error\" className=\"px-3.5 pt-1.5 text-sm text-po-red\">\n {attachmentError}\n </p>\n ) : null}\n <div className=\"flex flex-wrap items-center gap-2 px-2 pt-2 pb-2.5 sm:flex-nowrap sm:px-3 sm:pb-3\">\n <Popover\n open={menuOpen}\n onOpenChange={(next) => {\n setMenuOpen(next);\n if (next) dismissCompletion();\n }}\n >\n <PopoverTrigger asChild>\n <Button\n variant=\"ghost\"\n size=\"icon-md\"\n data-testid=\"composer-attach\"\n title=\"Add to this message\"\n aria-label=\"Add to this message\"\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen}\n className=\"shrink-0 text-po-dim\"\n >\n <PlusIcon className=\"size-4\" />\n </Button>\n </PopoverTrigger>\n {menuOpen ? (\n <PopoverContent\n side=\"top\"\n align=\"start\"\n sideOffset={8}\n data-testid=\"composer-menu\"\n className=\"w-56 rounded-md p-1.5 shadow-xl\"\n // A menu entry is a way out of the menu: whatever a plugin\n // opens, the menu has done its part. The upload row is the\n // exception, because its click opens the file chooser and\n // unmounting the input under it would strand the pick.\n onClick={(event) => {\n const clicked = event.target as Element | null;\n if (clicked?.closest('[data-testid=\"composer-attach-row\"]')) return;\n setMenuOpen(false);\n }}\n >\n {/* prefer-shared-primitive: ignore -- OptionRow is a button, and a file input may not nest inside one. */}\n <label\n aria-disabled={!attached}\n data-testid=\"composer-attach-row\"\n className={`relative overflow-hidden text-base font-medium text-po-text hover:bg-po-tint-blue ${optionRowVariants(\n { density: 'compact' },\n )} ${attached ? '' : 'pointer-events-none opacity-40'}`}\n >\n <PlusIcon className=\"h-3 w-3 shrink-0\" />\n <span className=\"min-w-0 flex-1 truncate\">File upload</span>\n {/* prefer-shared-primitive: ignore -- iOS needs the native file input itself to cover the visible tap target. */}\n <input\n type=\"file\"\n multiple\n disabled={!attached}\n aria-label=\"Attach files\"\n className=\"absolute inset-0 cursor-pointer opacity-0\"\n data-testid=\"composer-file-input\"\n onChange={(event) => {\n void addFiles(Array.from(event.currentTarget.files ?? []));\n event.currentTarget.value = '';\n setMenuOpen(false);\n }}\n />\n </label>\n <span className=\"contents\" data-testid=\"composer-menu-items\">\n <PluginSurface slot={HOST_SLOTS.composerMenu} sessionId={sessionId} />\n </span>\n </PopoverContent>\n ) : null}\n </Popover>\n <span className=\"min-w-0 flex-1\" />\n <span data-testid=\"composer-hint\" className=\"text-sm text-po-dim max-md:hidden\">\n {active\n ? aborting\n ? 'Abort requested · waiting for the turn to stop'\n : 'Enter steers the run · esc aborts'\n : 'Shift + Enter for a new line'}\n </span>\n {active ? abortAction : null}\n <span className=\"contents\" data-testid=\"composer-actions\">\n <PluginSurface slot={HOST_SLOTS.composerActions} sessionId={sessionId} />\n </span>\n <Button\n variant=\"outline\"\n size=\"lg\"\n data-testid=\"composer-queue\"\n onClick={queue}\n disabled={\n !attached ||\n pendingSubmission ||\n pendingAttachments > 0 ||\n (!draft.trim() && attachments.length === 0)\n }\n title=\"Deliver after the current run settles\"\n >\n Queue\n </Button>\n <Button\n variant=\"primary\"\n size=\"lg\"\n data-testid=\"composer-send\"\n onClick={submit}\n disabled={\n !attached ||\n pendingSubmission ||\n pendingAttachments > 0 ||\n (!draft.trim() && attachments.length === 0)\n }\n className=\"gap-2 px-3 disabled:opacity-60 sm:px-4\"\n >\n <SendIcon aria-hidden className=\"size-4\" />\n {active ? 'Steer' : 'Send'}\n </Button>\n </div>\n </div>\n </PopoverAnchor>\n </Popover>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAM,sBAAsB;AAC5B,MAAM,0BAA0B;AAChC,MAAM,8BAAc,IAAI,IAAI;CAAC;CAAa;CAAc;CAAa;AAAY,CAAC;AAClF,MAAM,kCAAkB,IAAI,IAAI;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,eAAe,MAAqB;CAC3C,MAAM,YAAY,KAAK,KAAK,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK;CAC9D,OAAO,KAAK,KAAK,WAAW,OAAO,KAAK,gBAAgB,IAAI,SAAS;AACvE;AAEA,SAAS,YAAY,MAA6B;CAChD,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,SAAS,IAAI,WAAW;EAC9B,OAAO,eACL,OAAO,OAAO,WAAW,WAAW,QAAQ,OAAO,MAAM,IAAI,uBAAO,IAAI,MAAM,cAAc,CAAC;EAC/F,OAAO,gBAAgB,OAAO,OAAO,yBAAS,IAAI,MAAM,qBAAqB,CAAC;EAC9E,OAAO,cAAc,IAAI;CAC3B,CAAC;AACH;;;;;AAMA,eAAe,WAAW,WAAmB,MAAyC;CACpF,IAAI;EACF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6BAAAA,QAAD;SACE,SAAQ;SACR,MAAK;SACL,eAAY;SACZ,SAAS;SACT,UACE,CAAC,YACD,qBACA,qBAAqB,KACpB,CAAC,MAAM,KAAK,KAAK,YAAY,WAAW;SAE3C,WAAU;SAXZ,UAAA,CAaE,iBAAA,GAAA,kBAAA,IAAA,CAAC2B,6BAAAA,UAAD;UAAU,eAAA;UAAY,WAAU;SAAU,CAAA,GACzC,SAAS,UAAU,MACd;;OACL;;KACF;;GACQ,CAAA;EACR,CAAA,CACN;;AAET"}
@@ -23,7 +23,7 @@ import { Button, CloseIcon, Kbd, OptionLabel, OptionRow, PlusIcon, Popover, Popo
23
23
  //#region src/web/features/session/Composer.tsx
24
24
  /** The input grows with the draft up to this many pixels, then scrolls. */
25
25
  const MAX_INPUT_HEIGHT_PX = 192;
26
- const FILE_SEARCH_DEBOUNCE_MS = 50;
26
+ const FILE_SEARCH_DEBOUNCE_MS = 300;
27
27
  const IMAGE_TYPES = /* @__PURE__ */ new Set([
28
28
  "image/png",
29
29
  "image/jpeg",
@@ -1 +1 @@
1
- {"version":3,"file":"Composer.mjs","names":[],"sources":["../../../../src/web/features/session/Composer.tsx"],"sourcesContent":["import { WORKFLOW_STEP_SESSION_PROVENANCE } from '@agimon-ai/po-core/hubChannel';\nimport type { TransientTab } from '@agimon-ai/po-core/web';\nimport {\n Button,\n CloseIcon,\n Kbd,\n OptionLabel,\n OptionRow,\n optionRowVariants,\n PlusIcon,\n SendIcon,\n Popover,\n PopoverAnchor,\n PopoverContent,\n PopoverFooter,\n PopoverTrigger,\n StopIcon,\n Textarea,\n} from '@agimon-ai/po-web-components';\nimport { useStore } from '@tanstack/react-store';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { PluginSurface } from '../../components/PluginSurface';\nimport {\n type CompletionItem,\n type CompletionKind,\n commandCompletions,\n fileCompletions,\n TRIGGER_CHARS,\n triggerTokenAt,\n} from '../../lib/composerCompletion';\nimport { searchSessionFiles } from '../../lib/hubApi';\nimport { HOST_SLOTS } from '../../lib/pluginRegistry';\nimport { registerPromptInput } from '../../lib/promptFocus';\nimport { uploadSessionAttachment } from '../../lib/sessionAsset';\nimport type { QueuedEntry } from '../../lib/sessionModel';\nimport {\n composerStore,\n type ComposerAttachment,\n type ComposerSessionState,\n inlineTextBytes,\n MAX_COMPOSER_UPLOAD_BYTES,\n MAX_COMPOSER_ATTACHMENTS,\n MAX_COMPOSER_IMAGE_BYTES,\n MAX_COMPOSER_TEXT_BYTES,\n MAX_COMPOSER_TOTAL_IMAGE_BYTES,\n MAX_COMPOSER_TOTAL_TEXT_BYTES,\n updateComposerState,\n useComposerState,\n} from '../../stores/composerStore';\nimport { composerSubmissionStore, submitComposerDraft } from '../../stores/composerSubmissionStore';\nimport { openPalette } from '../../stores/paletteStore';\nimport { sessionsStore, useActiveSessionMeta } from '../../stores/sessionsStore';\nimport {\n abortRun,\n clearQueuedMessages,\n deleteQueuedMessage,\n promoteQueuedMessage,\n resumeQueuedMessages,\n useActiveSession,\n} from '../../stores/sessionStore';\nimport { useToolPrompt } from '../../stores/useToolPrompt';\nimport { AgentLockPanel } from './AgentLockPanel';\nimport { ComposerPrompt } from './ComposerPrompt';\nimport { DormantPanel } from './DormantPanel';\nimport { QueueSheet } from './QueueSheet';\n\n/** The input grows with the draft up to this many pixels, then scrolls. */\nconst MAX_INPUT_HEIGHT_PX = 192;\nconst FILE_SEARCH_DEBOUNCE_MS = 50;\nconst IMAGE_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp']);\nconst TEXT_EXTENSIONS = new Set([\n 'c',\n 'cpp',\n 'css',\n 'csv',\n 'go',\n 'h',\n 'hpp',\n 'html',\n 'ini',\n 'java',\n 'js',\n 'json',\n 'jsonl',\n 'jsx',\n 'log',\n 'md',\n 'markdown',\n 'py',\n 'rb',\n 'rs',\n 'sh',\n 'sql',\n 'toml',\n 'ts',\n 'tsv',\n 'tsx',\n 'txt',\n 'xml',\n 'yaml',\n 'yml',\n]);\n\nfunction isReadableText(file: File): boolean {\n const extension = file.name.toLowerCase().split('.').pop() ?? '';\n return file.type.startsWith('text/') || TEXT_EXTENSIONS.has(extension);\n}\n\nfunction readDataUrl(file: File): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () =>\n typeof reader.result === 'string' ? resolve(reader.result) : reject(new Error('No file data'));\n reader.onerror = () => reject(reader.error ?? new Error('Could not read file'));\n reader.readAsDataURL(file);\n });\n}\n\n/**\n * Stores a copy on the host so a tool can be handed the file by path. Images and\n * text still travel inline, so for them a failed upload only means no path.\n */\nasync function storedPath(sessionId: string, file: File): Promise<string | undefined> {\n try {\n return (await uploadSessionAttachment(sessionId, file)).path;\n } catch {\n return undefined; // Documented fallback: the inline copy is still sent.\n }\n}\n\nconst TOO_MANY_ATTACHMENTS = `Only ${String(MAX_COMPOSER_ATTACHMENTS)} attachments are allowed.`;\n\n/** Why one more image or text file would break a total budget, or '' when it fits. */\nfunction totalBudgetRejection(\n attachments: ComposerAttachment[],\n kind: ComposerAttachment['kind'],\n name: string,\n size: number,\n): string {\n if (kind === 'image') {\n const imageBytes = attachments.reduce((total, item) => total + (item.kind === 'image' ? item.size : 0), 0);\n return imageBytes + size > MAX_COMPOSER_TOTAL_IMAGE_BYTES ? `${name} exceeds the 20 MB total image limit.` : '';\n }\n if (kind === 'text' && inlineTextBytes(attachments) + size > MAX_COMPOSER_TOTAL_TEXT_BYTES) {\n return `${name} exceeds the 200 KB total text limit.`;\n }\n return '';\n}\n\n/**\n * Reads picked, pasted or dropped files into new attachments, numbered from\n * `current.nextAttachmentId` and budgeted after the ones already staged.\n */\nexport async function readComposerFiles(\n sessionId: string,\n files: File[],\n current: Pick<ComposerSessionState, 'attachments' | 'nextAttachmentId'>,\n): Promise<Pick<ComposerSessionState, 'attachments' | 'attachmentError'>> {\n const next = [...current.attachments];\n const rejected: string[] = [];\n let attachmentId = current.nextAttachmentId;\n\n for (const file of files) {\n if (next.length >= MAX_COMPOSER_ATTACHMENTS) {\n rejected.push(TOO_MANY_ATTACHMENTS);\n break;\n }\n const id = `attachment-${String(attachmentId++)}`;\n if (IMAGE_TYPES.has(file.type)) {\n if (file.size > MAX_COMPOSER_IMAGE_BYTES) {\n rejected.push(`${file.name} exceeds the 10 MB image limit.`);\n continue;\n }\n const overBudget = totalBudgetRejection(next, 'image', file.name, file.size);\n if (overBudget) {\n rejected.push(overBudget);\n continue;\n }\n try {\n const dataUrl = await readDataUrl(file);\n const path = file.size > MAX_COMPOSER_UPLOAD_BYTES ? undefined : await storedPath(sessionId, file);\n next.push({\n id,\n kind: 'image',\n name: file.name,\n size: file.size,\n dataUrl,\n data: dataUrl.slice(dataUrl.indexOf(',') + 1),\n mimeType: file.type,\n ...(path === undefined ? {} : { path }),\n });\n } catch {\n rejected.push(`${file.name} could not be read.`);\n }\n continue;\n }\n if (!isReadableText(file)) {\n if (file.size > MAX_COMPOSER_UPLOAD_BYTES) {\n rejected.push(`\"${file.name}\" exceeds the 8 MB file limit.`);\n continue;\n }\n try {\n const stored = await uploadSessionAttachment(sessionId, file);\n next.push({\n id,\n kind: 'file',\n name: file.name,\n size: stored.size,\n mimeType: stored.mimeType,\n path: stored.path,\n });\n } catch {\n rejected.push(`\"${file.name}\" could not be uploaded.`);\n }\n continue;\n }\n if (file.size > MAX_COMPOSER_TEXT_BYTES) {\n rejected.push(`${file.name} exceeds the 100 KB text file limit.`);\n continue;\n }\n const overBudget = totalBudgetRejection(next, 'text', file.name, file.size);\n if (overBudget) {\n rejected.push(overBudget);\n continue;\n }\n try {\n const content = await file.text();\n const path = await storedPath(sessionId, file);\n next.push({\n id,\n kind: 'text',\n name: file.name,\n size: file.size,\n content,\n ...(path === undefined ? {} : { path }),\n });\n } catch {\n rejected.push(`${file.name} could not be read.`);\n }\n }\n return { attachments: next.slice(current.attachments.length), attachmentError: rejected.join(' ') };\n}\n\n/**\n * Stages files on a session's composer. Reading and uploading are async, so\n * the batch reserves its ids and marks itself pending up front, then appends\n * to whatever the composer holds by the time it finishes: chips removed, a\n * message sent, or another batch staged meanwhile all stay as they are, and\n * the count and total budgets are checked again against that latest state.\n */\nexport async function addComposerFiles(sessionId: string, files: File[]): Promise<void> {\n if (files.length === 0) return;\n let current: Pick<ComposerSessionState, 'attachments' | 'nextAttachmentId'> = {\n attachments: [],\n nextAttachmentId: 0,\n };\n updateComposerState(sessionId, (state) => {\n current = state;\n return {\n ...state,\n nextAttachmentId: state.nextAttachmentId + files.length,\n pendingAttachments: state.pendingAttachments + 1,\n };\n });\n const read = await readComposerFiles(sessionId, files, current);\n if (composerStore.state[sessionId] === undefined) return; // The session left while the files were read.\n updateComposerState(sessionId, (state) => {\n const attachments = [...state.attachments];\n const rejected = read.attachmentError ? [read.attachmentError] : [];\n for (const attachment of read.attachments) {\n if (attachments.length >= MAX_COMPOSER_ATTACHMENTS) {\n if (!read.attachmentError.includes(TOO_MANY_ATTACHMENTS)) rejected.push(TOO_MANY_ATTACHMENTS);\n break;\n }\n const overBudget = totalBudgetRejection(attachments, attachment.kind, attachment.name, attachment.size);\n if (overBudget) rejected.push(overBudget);\n else attachments.push(attachment);\n }\n return {\n ...state,\n attachments,\n attachmentError: rejected.join(' '),\n pendingAttachments: Math.max(0, state.pendingAttachments - 1),\n };\n });\n}\n\ninterface CompletionState {\n kind: CompletionKind;\n /** Index of the trigger character in the draft. */\n tokenStart: number;\n query: string;\n items: CompletionItem[];\n selected: number;\n}\n\n/**\n * Whether accepting the highlighted item would leave the draft as it is. The\n * popup still shows what a longer name would complete to, but the keystroke\n * that would change nothing is handed back to the composer to send.\n */\nfunction isCompletionRedundant(state: CompletionState): boolean {\n const item = state.items[state.selected];\n return item !== undefined && item.insert.trimEnd() === `${TRIGGER_CHARS[state.kind]}${state.query}`;\n}\n\nexport function Composer({ composerContext }: { composerContext?: TransientTab['composerContext'] } = {}) {\n const sessionId = useStore(sessionsStore, (state) => state.activeId);\n const meta = useActiveSessionMeta();\n const streaming = useActiveSession((state) => state.streaming);\n const lifecycle = useActiveSession((state) => state.lifecycle);\n const agentLocked = useActiveSession((state) => state.agentLocked);\n const active = lifecycle === null ? streaming : lifecycle.operation !== null;\n const aborting = lifecycle?.operation?.status === 'aborting';\n const queuedEntries = useActiveSession((state) =>\n state.entries.filter((entry): entry is QueuedEntry => entry.kind === 'queued'),\n );\n const commands = useActiveSession((state) => state.commands);\n const editorTextRequest = useActiveSession((state) => state.editorTextRequest);\n const prompt = useToolPrompt();\n const { draft, caret, dismissedToken, attachments, attachmentError, pendingAttachments } =\n useComposerState(sessionId);\n const [completion, setCompletion] = useState<CompletionState | null>(null);\n const [draggingFiles, setDraggingFiles] = useState(false);\n const [menuOpen, setMenuOpen] = useState(false);\n const pendingSubmission = useStore(\n composerSubmissionStore,\n (pending) => sessionId !== null && pending.has(sessionId),\n );\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const searchTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n const dormant = meta?.summary.dormant === true;\n const attached = !dormant && meta?.attach === 'attached';\n const queued = lifecycle === null ? queuedEntries.length : lifecycle.queue.length;\n\n // Completion and drag state are transient. The draft and attachments below\n // come from the newly focused session immediately after this reset, so the\n // reset is done during render rather than in an effect: a frame of the\n // previous session's popup would otherwise be painted over the new draft.\n const [shownSession, setShownSession] = useState(sessionId);\n if (shownSession !== sessionId) {\n setShownSession(sessionId);\n setCompletion(null);\n setDraggingFiles(false);\n setMenuOpen(false);\n }\n\n // The completion popup and the '+' menu are two popovers over one composer,\n // and the completion one exempts its own anchor from outside clicks. Keeping\n // them mutually exclusive means that guard never has to reason about the\n // other's portalled content. Adjusted during render, like the session reset\n // above, so the menu is already gone in the frame the popup appears in.\n if (menuOpen && completion !== null) setMenuOpen(false);\n useEffect(() => {\n if (searchTimer.current) clearTimeout(searchTimer.current);\n }, [sessionId]);\n\n // Overlays hand the keyboard back here when they close. Re-registered when\n // a tool prompt stands the input down and again when it gives it back:\n // otherwise the ref stays as it was and every later hand-back goes nowhere.\n useEffect(() => registerPromptInput(inputRef.current), [dormant, prompt]);\n\n useEffect(() => {\n if (editorTextRequest === null) return;\n updateComposerState(sessionId, (state) => {\n const draft = editorTextRequest.append\n ? `${state.draft}${state.draft && !/\\s$/u.test(state.draft) ? ' ' : ''}${editorTextRequest.text}`\n : editorTextRequest.text;\n return { ...state, draft, caret: draft.length, dismissedToken: null };\n });\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n const length = inputRef.current?.value.length ?? 0;\n inputRef.current?.setSelectionRange(length, length);\n });\n }, [editorTextRequest, sessionId]);\n\n // Auto-grow: measure after every draft change so pasted stack traces are\n // actually visible instead of scrolling inside one line.\n const resize = useCallback((): void => {\n const input = inputRef.current;\n if (!input) return;\n input.style.height = 'auto';\n input.style.height = `${String(Math.min(input.scrollHeight, MAX_INPUT_HEIGHT_PX))}px`;\n }, []);\n useEffect(() => resize(), [draft, resize]);\n\n const closeCompletion = useCallback((): void => {\n if (searchTimer.current) clearTimeout(searchTimer.current);\n setCompletion(null);\n }, []);\n\n /** Esc dismisses the popup for the token being typed; edits re-arm it. */\n const dismissCompletion = useCallback((): void => {\n const trigger = triggerTokenAt(draft, caret);\n updateComposerState(sessionId, (state) => ({ ...state, dismissedToken: trigger?.start ?? null }));\n closeCompletion();\n }, [draft, caret, closeCompletion, sessionId]);\n\n // The popup is derived state: any change to the draft, caret, session\n // commands, or attachment recomputes it, so data arriving after a keystroke\n // still opens it.\n useEffect(() => {\n const trigger = triggerTokenAt(draft, caret);\n if (!trigger || !attached || dismissedToken === trigger.start) {\n // eslint-disable-next-line react/set-state-in-effect -- the popup tracks an async, debounced search; closing it is the synchronous arm of that same effect.\n closeCompletion();\n return;\n }\n if (trigger.kind === 'command' || trigger.kind === 'skill') {\n const items = commandCompletions(commands, trigger.kind, trigger.query);\n setCompletion(\n items.length > 0\n ? { kind: trigger.kind, tokenStart: trigger.start, query: trigger.query, items, selected: 0 }\n : null,\n );\n return;\n }\n if (searchTimer.current) clearTimeout(searchTimer.current);\n searchTimer.current = setTimeout(() => {\n if (sessionId === null) return;\n void searchSessionFiles(sessionId, trigger.query).then((files) => {\n // The session or draft may have moved on while the lookup ran.\n const input = inputRef.current;\n if (\n sessionsStore.state.activeId !== sessionId ||\n !input ||\n triggerTokenAt(input.value, input.selectionStart)?.query !== trigger.query\n )\n return;\n const items = fileCompletions(files);\n setCompletion(\n items.length > 0\n ? { kind: 'file', tokenStart: trigger.start, query: trigger.query, items, selected: 0 }\n : null,\n );\n });\n }, FILE_SEARCH_DEBOUNCE_MS);\n return () => {\n if (searchTimer.current) clearTimeout(searchTimer.current);\n };\n }, [draft, caret, commands, attached, dismissedToken, closeCompletion, sessionId]);\n\n // Clicking anywhere outside the composer closes the popup.\n useEffect(() => {\n if (!completion) return;\n const onPointerDown = (event: MouseEvent): void => {\n if (containerRef.current && event.target instanceof Node && !containerRef.current.contains(event.target)) {\n closeCompletion();\n }\n };\n document.addEventListener('mousedown', onPointerDown);\n return () => document.removeEventListener('mousedown', onPointerDown);\n }, [completion, closeCompletion]);\n\n const accept = (state: CompletionState, index: number): void => {\n const item = state.items[index];\n if (!item) return;\n const next = draft.slice(0, state.tokenStart) + item.insert + draft.slice(caret);\n const position = state.tokenStart + item.insert.length;\n updateComposerState(sessionId, (current) => ({\n ...current,\n draft: next,\n caret: position,\n dismissedToken: state.tokenStart,\n }));\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n inputRef.current?.setSelectionRange(position, position);\n });\n };\n\n const addFiles = useCallback(\n async (files: File[]): Promise<void> => {\n if (sessionId === null) return;\n await addComposerFiles(sessionId, files);\n },\n [sessionId],\n );\n\n const submit = (): void => {\n void submitComposerDraft(sessionId, 'submit', composerContext);\n };\n const queue = (): void => {\n void submitComposerDraft(sessionId, 'queue', composerContext);\n };\n\n const placeholder = !attached\n ? 'Waiting for the session…'\n : active\n ? 'Interrupt the run and respond…'\n : 'Ask anything · / for commands · $ for skills · @ for files…';\n const abortAction = (\n <Button\n variant=\"danger-outline\"\n size=\"lg\"\n data-testid=\"composer-abort\"\n disabled={aborting}\n onClick={() => abortRun(sessionId)}\n >\n <StopIcon className=\"h-2 w-2 fill-current\" />\n {aborting ? 'Aborting…' : 'Abort'}\n </Button>\n );\n\n // A finished workflow step is history, never a session the composer may wake.\n if (dormant && meta?.summary.sessionProvenance === WORKFLOW_STEP_SESSION_PROVENANCE) return null;\n\n if (dormant && meta !== null && sessionId !== null) {\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-2.5 sm:px-5\">\n <DormantPanel key={sessionId} meta={meta} />\n </div>\n );\n }\n\n // A tool waiting on an answer takes the input's place rather than opening\n // over the conversation: the transcript is what the reader needs in order\n // to answer, and there is nothing to type here until the agent is unblocked.\n if (prompt !== null) {\n return (\n <div className=\"flex min-h-0 flex-col px-3 pt-3 pb-2.5 sm:px-5\">\n <QueueSheet\n key={sessionId}\n sessionId={sessionId}\n count={queued}\n disabled={!attached || lifecycle === null || aborting}\n entries={queuedEntries}\n onClear={() => clearQueuedMessages(sessionId)}\n onDelete={(id) => deleteQueuedMessage(id, queued, sessionId)}\n onPromote={(id, operationId) => promoteQueuedMessage(id, operationId, sessionId)}\n onResume={() => resumeQueuedMessages(sessionId)}\n operationId={lifecycle?.operation?.id}\n paused={lifecycle?.paused}\n />\n <div className=\"flex min-h-0 flex-col rounded-lg border border-po-edge-magenta bg-po-deep\">\n <ComposerPrompt claim={prompt} sessionId={sessionId} />\n </div>\n {active ? <div className=\"mt-2 flex justify-end\">{abortAction}</div> : null}\n </div>\n );\n }\n\n // A remote call can still ask the user something while the local agent is locked.\n if (agentLocked && sessionId !== null) {\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-2.5 sm:px-5\">\n <AgentLockPanel key={sessionId} sessionId={sessionId} />\n </div>\n );\n }\n\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-2.5 sm:px-5\">\n <QueueSheet\n key={sessionId}\n sessionId={sessionId}\n count={queued}\n disabled={!attached || lifecycle === null || aborting}\n entries={queuedEntries}\n onClear={() => clearQueuedMessages(sessionId)}\n onDelete={(id) => deleteQueuedMessage(id, queued, sessionId)}\n onPromote={(id, operationId) => promoteQueuedMessage(id, operationId, sessionId)}\n onResume={() => resumeQueuedMessages(sessionId)}\n operationId={lifecycle?.operation?.id}\n paused={lifecycle?.paused}\n />\n <Popover\n open={completion !== null}\n onOpenChange={(next) => {\n if (!next) dismissCompletion();\n }}\n >\n <PopoverAnchor asChild>\n <div\n ref={containerRef}\n onDragOver={(event) => {\n if (!attached || !event.dataTransfer.types.includes('Files')) return;\n event.preventDefault();\n event.dataTransfer.dropEffect = 'copy';\n setDraggingFiles(true);\n }}\n onDragLeave={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setDraggingFiles(false);\n }}\n onDrop={(event) => {\n setDraggingFiles(false);\n if (!attached || event.dataTransfer.files.length === 0) return;\n event.preventDefault();\n void addFiles(Array.from(event.dataTransfer.files));\n }}\n className={`relative rounded-xl border transition-colors focus-within:border-po-blue/60 focus-within:ring-2 focus-within:ring-po-blue/10 ${\n draggingFiles ? 'border-po-blue bg-po-blue/5' : active ? 'border-po-edge-yellow' : 'border-po-border'\n }`}\n >\n {completion ? (\n <PopoverContent\n side=\"top\"\n align=\"start\"\n sideOffset={8}\n data-testid=\"composer-completion\"\n // The keys belong to the textarea, so the menu never takes\n // focus; a click in the composer is a caret move, not a\n // dismissal, which is why the anchor is exempt from outside.\n onOpenAutoFocus={(event) => event.preventDefault()}\n onCloseAutoFocus={(event) => event.preventDefault()}\n onInteractOutside={(event) => {\n if (containerRef.current?.contains(event.target as Node) === true) event.preventDefault();\n }}\n className=\"max-h-[min(16rem,40dvh,var(--radix-popover-content-available-height))] w-[420px] max-w-[85vw] rounded-md p-0 shadow-xl sm:max-h-[min(20rem,50dvh,var(--radix-popover-content-available-height))]\"\n >\n <div className=\"min-h-0 overflow-y-auto overscroll-contain\" data-testid=\"composer-completion-options\">\n {completion.items.map((item, index) => (\n <OptionRow\n key={item.label}\n density=\"compact\"\n active={index === completion.selected}\n data-testid={`composer-completion-item-${String(index)}`}\n onMouseEnter={() => setCompletion({ ...completion, selected: index })}\n onMouseDown={(event) => {\n event.preventDefault();\n accept(completion, index);\n }}\n className=\"w-full items-baseline gap-2.5 rounded-none px-3 py-1.5\"\n >\n <span className=\"min-w-0 truncate text-base font-semibold text-po-hi\">{item.label}</span>\n {item.detail ? (\n <OptionLabel density=\"compact\" className=\"text-sm text-po-dim\">\n {item.detail}\n </OptionLabel>\n ) : null}\n </OptionRow>\n ))}\n </div>\n <PopoverFooter className=\"py-1\">\n <span className=\"flex items-center gap-1.5\">\n <Kbd>tab</Kbd> or <Kbd>enter</Kbd> completes · <Kbd>esc</Kbd> closes\n </span>\n </PopoverFooter>\n </PopoverContent>\n ) : null}\n <div className=\"flex min-w-0 items-start px-3 pt-3 sm:px-4 sm:pt-3.5\">\n <Textarea\n variant=\"bare\"\n ref={inputRef}\n data-testid=\"composer-input\"\n value={draft}\n disabled={!attached}\n onChange={(event) => {\n updateComposerState(sessionId, (state) => ({\n ...state,\n draft: event.target.value,\n caret: event.target.selectionStart,\n dismissedToken: null,\n }));\n }}\n onClick={(event) =>\n updateComposerState(sessionId, (state) => ({ ...state, caret: event.currentTarget.selectionStart }))\n }\n onPaste={(event) => {\n const files = Array.from(event.clipboardData.files);\n if (files.length === 0) return;\n event.preventDefault();\n void addFiles(files);\n }}\n onKeyUp={(event) =>\n updateComposerState(sessionId, (state) => ({ ...state, caret: event.currentTarget.selectionStart }))\n }\n onKeyDown={(event) => {\n // The TUI's leader key: space with nothing typed opens Leader Space.\n if (event.key === ' ' && draft === '') {\n event.preventDefault();\n openPalette();\n return;\n }\n if (completion) {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n const delta = event.key === 'ArrowDown' ? 1 : -1;\n const count = completion.items.length;\n setCompletion({ ...completion, selected: (completion.selected + delta + count) % count });\n return;\n }\n if (event.key === 'Tab') {\n event.preventDefault();\n accept(completion, completion.selected);\n return;\n }\n // Enter completes, unless the token is already the whole\n // thing: completing then would only add a space, so the\n // keystroke would read as doing nothing and the reader would\n // have to press enter twice to send what they had typed.\n if (event.key === 'Enter' && !isCompletionRedundant(completion)) {\n event.preventDefault();\n accept(completion, completion.selected);\n return;\n }\n if (event.key === 'Escape') {\n event.preventDefault();\n dismissCompletion();\n return;\n }\n }\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n submit();\n }\n if (event.key === 'Escape' && active && !aborting) {\n event.preventDefault();\n abortRun(sessionId);\n }\n }}\n rows={1}\n placeholder={placeholder}\n className=\"min-h-12 min-w-0 flex-1 text-lg leading-relaxed\"\n />\n </div>\n {attachments.length > 0 ? (\n <div className=\"flex flex-wrap gap-1.5 px-3.5 pt-2\" data-testid=\"composer-attachments\">\n {attachments.map((attachment) => (\n <span\n key={attachment.id}\n data-testid={`composer-attachment-${attachment.id}`}\n className=\"flex max-w-full items-center gap-1.5 rounded border border-po-border bg-po-panel px-1.5 py-1 text-sm text-po-dim\"\n >\n {attachment.kind === 'image' ? (\n <img src={attachment.dataUrl} alt=\"\" className=\"h-6 w-6 rounded object-cover\" />\n ) : (\n <span className=\"font-semibold text-po-hi\">\n {attachment.kind === 'context' ? 'CTX' : attachment.kind === 'file' ? 'FILE' : 'TXT'}\n </span>\n )}\n <span className=\"max-w-40 truncate\">{attachment.name}</span>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n aria-label={`Remove ${attachment.name}`}\n className=\"text-po-faint hover:text-po-text\"\n onClick={() => {\n updateComposerState(sessionId, (state) => ({\n ...state,\n attachments: state.attachments.filter((item) => item.id !== attachment.id),\n attachmentError: '',\n }));\n }}\n >\n <CloseIcon className=\"h-2.5 w-2.5\" />\n </Button>\n </span>\n ))}\n </div>\n ) : null}\n {attachmentError ? (\n <p role=\"alert\" data-testid=\"composer-attachment-error\" className=\"px-3.5 pt-1.5 text-sm text-po-red\">\n {attachmentError}\n </p>\n ) : null}\n <div className=\"flex flex-wrap items-center gap-2 px-2 pt-2 pb-2.5 sm:flex-nowrap sm:px-3 sm:pb-3\">\n <Popover\n open={menuOpen}\n onOpenChange={(next) => {\n setMenuOpen(next);\n if (next) dismissCompletion();\n }}\n >\n <PopoverTrigger asChild>\n <Button\n variant=\"ghost\"\n size=\"icon-md\"\n data-testid=\"composer-attach\"\n title=\"Add to this message\"\n aria-label=\"Add to this message\"\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen}\n className=\"shrink-0 text-po-dim\"\n >\n <PlusIcon className=\"size-4\" />\n </Button>\n </PopoverTrigger>\n {menuOpen ? (\n <PopoverContent\n side=\"top\"\n align=\"start\"\n sideOffset={8}\n data-testid=\"composer-menu\"\n className=\"w-56 rounded-md p-1.5 shadow-xl\"\n // A menu entry is a way out of the menu: whatever a plugin\n // opens, the menu has done its part. The upload row is the\n // exception, because its click opens the file chooser and\n // unmounting the input under it would strand the pick.\n onClick={(event) => {\n const clicked = event.target as Element | null;\n if (clicked?.closest('[data-testid=\"composer-attach-row\"]')) return;\n setMenuOpen(false);\n }}\n >\n {/* prefer-shared-primitive: ignore -- OptionRow is a button, and a file input may not nest inside one. */}\n <label\n aria-disabled={!attached}\n data-testid=\"composer-attach-row\"\n className={`relative overflow-hidden text-base font-medium text-po-text hover:bg-po-tint-blue ${optionRowVariants(\n { density: 'compact' },\n )} ${attached ? '' : 'pointer-events-none opacity-40'}`}\n >\n <PlusIcon className=\"h-3 w-3 shrink-0\" />\n <span className=\"min-w-0 flex-1 truncate\">File upload</span>\n {/* prefer-shared-primitive: ignore -- iOS needs the native file input itself to cover the visible tap target. */}\n <input\n type=\"file\"\n multiple\n disabled={!attached}\n aria-label=\"Attach files\"\n className=\"absolute inset-0 cursor-pointer opacity-0\"\n data-testid=\"composer-file-input\"\n onChange={(event) => {\n void addFiles(Array.from(event.currentTarget.files ?? []));\n event.currentTarget.value = '';\n setMenuOpen(false);\n }}\n />\n </label>\n <span className=\"contents\" data-testid=\"composer-menu-items\">\n <PluginSurface slot={HOST_SLOTS.composerMenu} sessionId={sessionId} />\n </span>\n </PopoverContent>\n ) : null}\n </Popover>\n <span className=\"min-w-0 flex-1\" />\n <span data-testid=\"composer-hint\" className=\"text-sm text-po-dim max-md:hidden\">\n {active\n ? aborting\n ? 'Abort requested · waiting for the turn to stop'\n : 'Enter steers the run · esc aborts'\n : 'Shift + Enter for a new line'}\n </span>\n {active ? abortAction : null}\n <span className=\"contents\" data-testid=\"composer-actions\">\n <PluginSurface slot={HOST_SLOTS.composerActions} sessionId={sessionId} />\n </span>\n <Button\n variant=\"outline\"\n size=\"lg\"\n data-testid=\"composer-queue\"\n onClick={queue}\n disabled={\n !attached ||\n pendingSubmission ||\n pendingAttachments > 0 ||\n (!draft.trim() && attachments.length === 0)\n }\n title=\"Deliver after the current run settles\"\n >\n Queue\n </Button>\n <Button\n variant=\"primary\"\n size=\"lg\"\n data-testid=\"composer-send\"\n onClick={submit}\n disabled={\n !attached ||\n pendingSubmission ||\n pendingAttachments > 0 ||\n (!draft.trim() && attachments.length === 0)\n }\n className=\"gap-2 px-3 disabled:opacity-60 sm:px-4\"\n >\n <SendIcon aria-hidden className=\"size-4\" />\n {active ? 'Steer' : 'Send'}\n </Button>\n </div>\n </div>\n </PopoverAnchor>\n </Popover>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAM,sBAAsB;AAC5B,MAAM,0BAA0B;AAChC,MAAM,8BAAc,IAAI,IAAI;CAAC;CAAa;CAAc;CAAa;AAAY,CAAC;AAClF,MAAM,kCAAkB,IAAI,IAAI;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,eAAe,MAAqB;CAC3C,MAAM,YAAY,KAAK,KAAK,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAA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AAC,QAAD;SAAM,eAAY;SAAgB,WAAU;SACzC,UAAA,SACG,WACE,mDACA,sCACF;QACA,CAAA;QACL,SAAS,cAAc;QACxB,oBAAC,QAAD;SAAM,WAAU;SAAW,eAAY;SACrC,UAAA,oBAAC,eAAD;UAAe,MAAM,WAAW;UAA4B;SAAY,CAAA;QACpE,CAAA;QACN,oBAAC,QAAD;SACE,SAAQ;SACR,MAAK;SACL,eAAY;SACZ,SAAS;SACT,UACE,CAAC,YACD,qBACA,qBAAqB,KACpB,CAAC,MAAM,KAAK,KAAK,YAAY,WAAW;SAE3C,OAAM;SACP,UAAA;QAEO,CAAA;QACR,qBAAC,QAAD;SACE,SAAQ;SACR,MAAK;SACL,eAAY;SACZ,SAAS;SACT,UACE,CAAC,YACD,qBACA,qBAAqB,KACpB,CAAC,MAAM,KAAK,KAAK,YAAY,WAAW;SAE3C,WAAU;SAXZ,UAAA,CAaE,oBAAC,UAAD;UAAU,eAAA;UAAY,WAAU;SAAU,CAAA,GACzC,SAAS,UAAU,MACd;;OACL;;KACF;;GACQ,CAAA;EACR,CAAA,CACN;;AAET"}
1
+ {"version":3,"file":"Composer.mjs","names":[],"sources":["../../../../src/web/features/session/Composer.tsx"],"sourcesContent":["import { WORKFLOW_STEP_SESSION_PROVENANCE } from '@agimon-ai/po-core/hubChannel';\nimport type { TransientTab } from '@agimon-ai/po-core/web';\nimport {\n Button,\n CloseIcon,\n Kbd,\n OptionLabel,\n OptionRow,\n optionRowVariants,\n PlusIcon,\n SendIcon,\n Popover,\n PopoverAnchor,\n PopoverContent,\n PopoverFooter,\n PopoverTrigger,\n StopIcon,\n Textarea,\n} from '@agimon-ai/po-web-components';\nimport { useStore } from '@tanstack/react-store';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { PluginSurface } from '../../components/PluginSurface';\nimport {\n type CompletionItem,\n type CompletionKind,\n commandCompletions,\n fileCompletions,\n TRIGGER_CHARS,\n triggerTokenAt,\n} from '../../lib/composerCompletion';\nimport { searchSessionFiles } from '../../lib/hubApi';\nimport { HOST_SLOTS } from '../../lib/pluginRegistry';\nimport { registerPromptInput } from '../../lib/promptFocus';\nimport { uploadSessionAttachment } from '../../lib/sessionAsset';\nimport type { QueuedEntry } from '../../lib/sessionModel';\nimport {\n composerStore,\n type ComposerAttachment,\n type ComposerSessionState,\n inlineTextBytes,\n MAX_COMPOSER_UPLOAD_BYTES,\n MAX_COMPOSER_ATTACHMENTS,\n MAX_COMPOSER_IMAGE_BYTES,\n MAX_COMPOSER_TEXT_BYTES,\n MAX_COMPOSER_TOTAL_IMAGE_BYTES,\n MAX_COMPOSER_TOTAL_TEXT_BYTES,\n updateComposerState,\n useComposerState,\n} from '../../stores/composerStore';\nimport { composerSubmissionStore, submitComposerDraft } from '../../stores/composerSubmissionStore';\nimport { openPalette } from '../../stores/paletteStore';\nimport { sessionsStore, useActiveSessionMeta } from '../../stores/sessionsStore';\nimport {\n abortRun,\n clearQueuedMessages,\n deleteQueuedMessage,\n promoteQueuedMessage,\n resumeQueuedMessages,\n useActiveSession,\n} from '../../stores/sessionStore';\nimport { useToolPrompt } from '../../stores/useToolPrompt';\nimport { AgentLockPanel } from './AgentLockPanel';\nimport { ComposerPrompt } from './ComposerPrompt';\nimport { DormantPanel } from './DormantPanel';\nimport { QueueSheet } from './QueueSheet';\n\n/** The input grows with the draft up to this many pixels, then scrolls. */\nconst MAX_INPUT_HEIGHT_PX = 192;\nconst FILE_SEARCH_DEBOUNCE_MS = 300;\nconst IMAGE_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp']);\nconst TEXT_EXTENSIONS = new Set([\n 'c',\n 'cpp',\n 'css',\n 'csv',\n 'go',\n 'h',\n 'hpp',\n 'html',\n 'ini',\n 'java',\n 'js',\n 'json',\n 'jsonl',\n 'jsx',\n 'log',\n 'md',\n 'markdown',\n 'py',\n 'rb',\n 'rs',\n 'sh',\n 'sql',\n 'toml',\n 'ts',\n 'tsv',\n 'tsx',\n 'txt',\n 'xml',\n 'yaml',\n 'yml',\n]);\n\nfunction isReadableText(file: File): boolean {\n const extension = file.name.toLowerCase().split('.').pop() ?? '';\n return file.type.startsWith('text/') || TEXT_EXTENSIONS.has(extension);\n}\n\nfunction readDataUrl(file: File): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () =>\n typeof reader.result === 'string' ? resolve(reader.result) : reject(new Error('No file data'));\n reader.onerror = () => reject(reader.error ?? new Error('Could not read file'));\n reader.readAsDataURL(file);\n });\n}\n\n/**\n * Stores a copy on the host so a tool can be handed the file by path. Images and\n * text still travel inline, so for them a failed upload only means no path.\n */\nasync function storedPath(sessionId: string, file: File): Promise<string | undefined> {\n try {\n return (await uploadSessionAttachment(sessionId, file)).path;\n } catch {\n return undefined; // Documented fallback: the inline copy is still sent.\n }\n}\n\nconst TOO_MANY_ATTACHMENTS = `Only ${String(MAX_COMPOSER_ATTACHMENTS)} attachments are allowed.`;\n\n/** Why one more image or text file would break a total budget, or '' when it fits. */\nfunction totalBudgetRejection(\n attachments: ComposerAttachment[],\n kind: ComposerAttachment['kind'],\n name: string,\n size: number,\n): string {\n if (kind === 'image') {\n const imageBytes = attachments.reduce((total, item) => total + (item.kind === 'image' ? item.size : 0), 0);\n return imageBytes + size > MAX_COMPOSER_TOTAL_IMAGE_BYTES ? `${name} exceeds the 20 MB total image limit.` : '';\n }\n if (kind === 'text' && inlineTextBytes(attachments) + size > MAX_COMPOSER_TOTAL_TEXT_BYTES) {\n return `${name} exceeds the 200 KB total text limit.`;\n }\n return '';\n}\n\n/**\n * Reads picked, pasted or dropped files into new attachments, numbered from\n * `current.nextAttachmentId` and budgeted after the ones already staged.\n */\nexport async function readComposerFiles(\n sessionId: string,\n files: File[],\n current: Pick<ComposerSessionState, 'attachments' | 'nextAttachmentId'>,\n): Promise<Pick<ComposerSessionState, 'attachments' | 'attachmentError'>> {\n const next = [...current.attachments];\n const rejected: string[] = [];\n let attachmentId = current.nextAttachmentId;\n\n for (const file of files) {\n if (next.length >= MAX_COMPOSER_ATTACHMENTS) {\n rejected.push(TOO_MANY_ATTACHMENTS);\n break;\n }\n const id = `attachment-${String(attachmentId++)}`;\n if (IMAGE_TYPES.has(file.type)) {\n if (file.size > MAX_COMPOSER_IMAGE_BYTES) {\n rejected.push(`${file.name} exceeds the 10 MB image limit.`);\n continue;\n }\n const overBudget = totalBudgetRejection(next, 'image', file.name, file.size);\n if (overBudget) {\n rejected.push(overBudget);\n continue;\n }\n try {\n const dataUrl = await readDataUrl(file);\n const path = file.size > MAX_COMPOSER_UPLOAD_BYTES ? undefined : await storedPath(sessionId, file);\n next.push({\n id,\n kind: 'image',\n name: file.name,\n size: file.size,\n dataUrl,\n data: dataUrl.slice(dataUrl.indexOf(',') + 1),\n mimeType: file.type,\n ...(path === undefined ? {} : { path }),\n });\n } catch {\n rejected.push(`${file.name} could not be read.`);\n }\n continue;\n }\n if (!isReadableText(file)) {\n if (file.size > MAX_COMPOSER_UPLOAD_BYTES) {\n rejected.push(`\"${file.name}\" exceeds the 8 MB file limit.`);\n continue;\n }\n try {\n const stored = await uploadSessionAttachment(sessionId, file);\n next.push({\n id,\n kind: 'file',\n name: file.name,\n size: stored.size,\n mimeType: stored.mimeType,\n path: stored.path,\n });\n } catch {\n rejected.push(`\"${file.name}\" could not be uploaded.`);\n }\n continue;\n }\n if (file.size > MAX_COMPOSER_TEXT_BYTES) {\n rejected.push(`${file.name} exceeds the 100 KB text file limit.`);\n continue;\n }\n const overBudget = totalBudgetRejection(next, 'text', file.name, file.size);\n if (overBudget) {\n rejected.push(overBudget);\n continue;\n }\n try {\n const content = await file.text();\n const path = await storedPath(sessionId, file);\n next.push({\n id,\n kind: 'text',\n name: file.name,\n size: file.size,\n content,\n ...(path === undefined ? {} : { path }),\n });\n } catch {\n rejected.push(`${file.name} could not be read.`);\n }\n }\n return { attachments: next.slice(current.attachments.length), attachmentError: rejected.join(' ') };\n}\n\n/**\n * Stages files on a session's composer. Reading and uploading are async, so\n * the batch reserves its ids and marks itself pending up front, then appends\n * to whatever the composer holds by the time it finishes: chips removed, a\n * message sent, or another batch staged meanwhile all stay as they are, and\n * the count and total budgets are checked again against that latest state.\n */\nexport async function addComposerFiles(sessionId: string, files: File[]): Promise<void> {\n if (files.length === 0) return;\n let current: Pick<ComposerSessionState, 'attachments' | 'nextAttachmentId'> = {\n attachments: [],\n nextAttachmentId: 0,\n };\n updateComposerState(sessionId, (state) => {\n current = state;\n return {\n ...state,\n nextAttachmentId: state.nextAttachmentId + files.length,\n pendingAttachments: state.pendingAttachments + 1,\n };\n });\n const read = await readComposerFiles(sessionId, files, current);\n if (composerStore.state[sessionId] === undefined) return; // The session left while the files were read.\n updateComposerState(sessionId, (state) => {\n const attachments = [...state.attachments];\n const rejected = read.attachmentError ? [read.attachmentError] : [];\n for (const attachment of read.attachments) {\n if (attachments.length >= MAX_COMPOSER_ATTACHMENTS) {\n if (!read.attachmentError.includes(TOO_MANY_ATTACHMENTS)) rejected.push(TOO_MANY_ATTACHMENTS);\n break;\n }\n const overBudget = totalBudgetRejection(attachments, attachment.kind, attachment.name, attachment.size);\n if (overBudget) rejected.push(overBudget);\n else attachments.push(attachment);\n }\n return {\n ...state,\n attachments,\n attachmentError: rejected.join(' '),\n pendingAttachments: Math.max(0, state.pendingAttachments - 1),\n };\n });\n}\n\ninterface CompletionState {\n kind: CompletionKind;\n /** Index of the trigger character in the draft. */\n tokenStart: number;\n query: string;\n items: CompletionItem[];\n selected: number;\n}\n\n/**\n * Whether accepting the highlighted item would leave the draft as it is. The\n * popup still shows what a longer name would complete to, but the keystroke\n * that would change nothing is handed back to the composer to send.\n */\nfunction isCompletionRedundant(state: CompletionState): boolean {\n const item = state.items[state.selected];\n return item !== undefined && item.insert.trimEnd() === `${TRIGGER_CHARS[state.kind]}${state.query}`;\n}\n\nexport function Composer({ composerContext }: { composerContext?: TransientTab['composerContext'] } = {}) {\n const sessionId = useStore(sessionsStore, (state) => state.activeId);\n const meta = useActiveSessionMeta();\n const streaming = useActiveSession((state) => state.streaming);\n const lifecycle = useActiveSession((state) => state.lifecycle);\n const agentLocked = useActiveSession((state) => state.agentLocked);\n const active = lifecycle === null ? streaming : lifecycle.operation !== null;\n const aborting = lifecycle?.operation?.status === 'aborting';\n const queuedEntries = useActiveSession((state) =>\n state.entries.filter((entry): entry is QueuedEntry => entry.kind === 'queued'),\n );\n const commands = useActiveSession((state) => state.commands);\n const editorTextRequest = useActiveSession((state) => state.editorTextRequest);\n const prompt = useToolPrompt();\n const { draft, caret, dismissedToken, attachments, attachmentError, pendingAttachments } =\n useComposerState(sessionId);\n const [completion, setCompletion] = useState<CompletionState | null>(null);\n const [draggingFiles, setDraggingFiles] = useState(false);\n const [menuOpen, setMenuOpen] = useState(false);\n const pendingSubmission = useStore(\n composerSubmissionStore,\n (pending) => sessionId !== null && pending.has(sessionId),\n );\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const searchTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n const dormant = meta?.summary.dormant === true;\n const attached = !dormant && meta?.attach === 'attached';\n const queued = lifecycle === null ? queuedEntries.length : lifecycle.queue.length;\n\n // Completion and drag state are transient. The draft and attachments below\n // come from the newly focused session immediately after this reset, so the\n // reset is done during render rather than in an effect: a frame of the\n // previous session's popup would otherwise be painted over the new draft.\n const [shownSession, setShownSession] = useState(sessionId);\n if (shownSession !== sessionId) {\n setShownSession(sessionId);\n setCompletion(null);\n setDraggingFiles(false);\n setMenuOpen(false);\n }\n\n // The completion popup and the '+' menu are two popovers over one composer,\n // and the completion one exempts its own anchor from outside clicks. Keeping\n // them mutually exclusive means that guard never has to reason about the\n // other's portalled content. Adjusted during render, like the session reset\n // above, so the menu is already gone in the frame the popup appears in.\n if (menuOpen && completion !== null) setMenuOpen(false);\n useEffect(() => {\n if (searchTimer.current) clearTimeout(searchTimer.current);\n }, [sessionId]);\n\n // Overlays hand the keyboard back here when they close. Re-registered when\n // a tool prompt stands the input down and again when it gives it back:\n // otherwise the ref stays as it was and every later hand-back goes nowhere.\n useEffect(() => registerPromptInput(inputRef.current), [dormant, prompt]);\n\n useEffect(() => {\n if (editorTextRequest === null) return;\n updateComposerState(sessionId, (state) => {\n const draft = editorTextRequest.append\n ? `${state.draft}${state.draft && !/\\s$/u.test(state.draft) ? ' ' : ''}${editorTextRequest.text}`\n : editorTextRequest.text;\n return { ...state, draft, caret: draft.length, dismissedToken: null };\n });\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n const length = inputRef.current?.value.length ?? 0;\n inputRef.current?.setSelectionRange(length, length);\n });\n }, [editorTextRequest, sessionId]);\n\n // Auto-grow: measure after every draft change so pasted stack traces are\n // actually visible instead of scrolling inside one line.\n const resize = useCallback((): void => {\n const input = inputRef.current;\n if (!input) return;\n input.style.height = 'auto';\n input.style.height = `${String(Math.min(input.scrollHeight, MAX_INPUT_HEIGHT_PX))}px`;\n }, []);\n useEffect(() => resize(), [draft, resize]);\n\n const closeCompletion = useCallback((): void => {\n if (searchTimer.current) clearTimeout(searchTimer.current);\n setCompletion(null);\n }, []);\n\n /** Esc dismisses the popup for the token being typed; edits re-arm it. */\n const dismissCompletion = useCallback((): void => {\n const trigger = triggerTokenAt(draft, caret);\n updateComposerState(sessionId, (state) => ({ ...state, dismissedToken: trigger?.start ?? null }));\n closeCompletion();\n }, [draft, caret, closeCompletion, sessionId]);\n\n // The popup is derived state: any change to the draft, caret, session\n // commands, or attachment recomputes it, so data arriving after a keystroke\n // still opens it.\n useEffect(() => {\n const trigger = triggerTokenAt(draft, caret);\n if (!trigger || !attached || dismissedToken === trigger.start) {\n // eslint-disable-next-line react/set-state-in-effect -- the popup tracks an async, debounced search; closing it is the synchronous arm of that same effect.\n closeCompletion();\n return;\n }\n if (trigger.kind === 'command' || trigger.kind === 'skill') {\n const items = commandCompletions(commands, trigger.kind, trigger.query);\n setCompletion(\n items.length > 0\n ? { kind: trigger.kind, tokenStart: trigger.start, query: trigger.query, items, selected: 0 }\n : null,\n );\n return;\n }\n if (searchTimer.current) clearTimeout(searchTimer.current);\n searchTimer.current = setTimeout(() => {\n if (sessionId === null) return;\n void searchSessionFiles(sessionId, trigger.query).then((files) => {\n // The session or draft may have moved on while the lookup ran.\n const input = inputRef.current;\n if (\n sessionsStore.state.activeId !== sessionId ||\n !input ||\n triggerTokenAt(input.value, input.selectionStart)?.query !== trigger.query\n )\n return;\n const items = fileCompletions(files);\n setCompletion(\n items.length > 0\n ? { kind: 'file', tokenStart: trigger.start, query: trigger.query, items, selected: 0 }\n : null,\n );\n });\n }, FILE_SEARCH_DEBOUNCE_MS);\n return () => {\n if (searchTimer.current) clearTimeout(searchTimer.current);\n };\n }, [draft, caret, commands, attached, dismissedToken, closeCompletion, sessionId]);\n\n // Clicking anywhere outside the composer closes the popup.\n useEffect(() => {\n if (!completion) return;\n const onPointerDown = (event: MouseEvent): void => {\n if (containerRef.current && event.target instanceof Node && !containerRef.current.contains(event.target)) {\n closeCompletion();\n }\n };\n document.addEventListener('mousedown', onPointerDown);\n return () => document.removeEventListener('mousedown', onPointerDown);\n }, [completion, closeCompletion]);\n\n const accept = (state: CompletionState, index: number): void => {\n const item = state.items[index];\n if (!item) return;\n const next = draft.slice(0, state.tokenStart) + item.insert + draft.slice(caret);\n const position = state.tokenStart + item.insert.length;\n updateComposerState(sessionId, (current) => ({\n ...current,\n draft: next,\n caret: position,\n dismissedToken: state.tokenStart,\n }));\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n inputRef.current?.setSelectionRange(position, position);\n });\n };\n\n const addFiles = useCallback(\n async (files: File[]): Promise<void> => {\n if (sessionId === null) return;\n await addComposerFiles(sessionId, files);\n },\n [sessionId],\n );\n\n const submit = (): void => {\n void submitComposerDraft(sessionId, 'submit', composerContext);\n };\n const queue = (): void => {\n void submitComposerDraft(sessionId, 'queue', composerContext);\n };\n\n const placeholder = !attached\n ? 'Waiting for the session…'\n : active\n ? 'Interrupt the run and respond…'\n : 'Ask anything · / for commands · $ for skills · @ for files…';\n const abortAction = (\n <Button\n variant=\"danger-outline\"\n size=\"lg\"\n data-testid=\"composer-abort\"\n disabled={aborting}\n onClick={() => abortRun(sessionId)}\n >\n <StopIcon className=\"h-2 w-2 fill-current\" />\n {aborting ? 'Aborting…' : 'Abort'}\n </Button>\n );\n\n // A finished workflow step is history, never a session the composer may wake.\n if (dormant && meta?.summary.sessionProvenance === WORKFLOW_STEP_SESSION_PROVENANCE) return null;\n\n if (dormant && meta !== null && sessionId !== null) {\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-2.5 sm:px-5\">\n <DormantPanel key={sessionId} meta={meta} />\n </div>\n );\n }\n\n // A tool waiting on an answer takes the input's place rather than opening\n // over the conversation: the transcript is what the reader needs in order\n // to answer, and there is nothing to type here until the agent is unblocked.\n if (prompt !== null) {\n return (\n <div className=\"flex min-h-0 flex-col px-3 pt-3 pb-2.5 sm:px-5\">\n <QueueSheet\n key={sessionId}\n sessionId={sessionId}\n count={queued}\n disabled={!attached || lifecycle === null || aborting}\n entries={queuedEntries}\n onClear={() => clearQueuedMessages(sessionId)}\n onDelete={(id) => deleteQueuedMessage(id, queued, sessionId)}\n onPromote={(id, operationId) => promoteQueuedMessage(id, operationId, sessionId)}\n onResume={() => resumeQueuedMessages(sessionId)}\n operationId={lifecycle?.operation?.id}\n paused={lifecycle?.paused}\n />\n <div className=\"flex min-h-0 flex-col rounded-lg border border-po-edge-magenta bg-po-deep\">\n <ComposerPrompt claim={prompt} sessionId={sessionId} />\n </div>\n {active ? <div className=\"mt-2 flex justify-end\">{abortAction}</div> : null}\n </div>\n );\n }\n\n // A remote call can still ask the user something while the local agent is locked.\n if (agentLocked && sessionId !== null) {\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-2.5 sm:px-5\">\n <AgentLockPanel key={sessionId} sessionId={sessionId} />\n </div>\n );\n }\n\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-2.5 sm:px-5\">\n <QueueSheet\n key={sessionId}\n sessionId={sessionId}\n count={queued}\n disabled={!attached || lifecycle === null || aborting}\n entries={queuedEntries}\n onClear={() => clearQueuedMessages(sessionId)}\n onDelete={(id) => deleteQueuedMessage(id, queued, sessionId)}\n onPromote={(id, operationId) => promoteQueuedMessage(id, operationId, sessionId)}\n onResume={() => resumeQueuedMessages(sessionId)}\n operationId={lifecycle?.operation?.id}\n paused={lifecycle?.paused}\n />\n <Popover\n open={completion !== null}\n onOpenChange={(next) => {\n if (!next) dismissCompletion();\n }}\n >\n <PopoverAnchor asChild>\n <div\n ref={containerRef}\n onDragOver={(event) => {\n if (!attached || !event.dataTransfer.types.includes('Files')) return;\n event.preventDefault();\n event.dataTransfer.dropEffect = 'copy';\n setDraggingFiles(true);\n }}\n onDragLeave={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setDraggingFiles(false);\n }}\n onDrop={(event) => {\n setDraggingFiles(false);\n if (!attached || event.dataTransfer.files.length === 0) return;\n event.preventDefault();\n void addFiles(Array.from(event.dataTransfer.files));\n }}\n className={`relative rounded-xl border transition-colors focus-within:border-po-blue/60 focus-within:ring-2 focus-within:ring-po-blue/10 ${\n draggingFiles ? 'border-po-blue bg-po-blue/5' : active ? 'border-po-edge-yellow' : 'border-po-border'\n }`}\n >\n {completion ? (\n <PopoverContent\n side=\"top\"\n align=\"start\"\n sideOffset={8}\n data-testid=\"composer-completion\"\n // The keys belong to the textarea, so the menu never takes\n // focus; a click in the composer is a caret move, not a\n // dismissal, which is why the anchor is exempt from outside.\n onOpenAutoFocus={(event) => event.preventDefault()}\n onCloseAutoFocus={(event) => event.preventDefault()}\n onInteractOutside={(event) => {\n if (containerRef.current?.contains(event.target as Node) === true) event.preventDefault();\n }}\n className=\"max-h-[min(16rem,40dvh,var(--radix-popover-content-available-height))] w-[420px] max-w-[85vw] rounded-md p-0 shadow-xl sm:max-h-[min(20rem,50dvh,var(--radix-popover-content-available-height))]\"\n >\n <div className=\"min-h-0 overflow-y-auto overscroll-contain\" data-testid=\"composer-completion-options\">\n {completion.items.map((item, index) => (\n <OptionRow\n key={item.label}\n density=\"compact\"\n active={index === completion.selected}\n data-testid={`composer-completion-item-${String(index)}`}\n onMouseEnter={() => setCompletion({ ...completion, selected: index })}\n onMouseDown={(event) => {\n event.preventDefault();\n accept(completion, index);\n }}\n className=\"w-full items-baseline gap-2.5 rounded-none px-3 py-1.5\"\n >\n <span className=\"min-w-0 truncate text-base font-semibold text-po-hi\">{item.label}</span>\n {item.detail ? (\n <OptionLabel density=\"compact\" className=\"text-sm text-po-dim\">\n {item.detail}\n </OptionLabel>\n ) : null}\n </OptionRow>\n ))}\n </div>\n <PopoverFooter className=\"py-1\">\n <span className=\"flex items-center gap-1.5\">\n <Kbd>tab</Kbd> or <Kbd>enter</Kbd> completes · <Kbd>esc</Kbd> closes\n </span>\n </PopoverFooter>\n </PopoverContent>\n ) : null}\n <div className=\"flex min-w-0 items-start px-3 pt-3 sm:px-4 sm:pt-3.5\">\n <Textarea\n variant=\"bare\"\n ref={inputRef}\n data-testid=\"composer-input\"\n value={draft}\n disabled={!attached}\n onChange={(event) => {\n updateComposerState(sessionId, (state) => ({\n ...state,\n draft: event.target.value,\n caret: event.target.selectionStart,\n dismissedToken: null,\n }));\n }}\n onClick={(event) =>\n updateComposerState(sessionId, (state) => ({ ...state, caret: event.currentTarget.selectionStart }))\n }\n onPaste={(event) => {\n const files = Array.from(event.clipboardData.files);\n if (files.length === 0) return;\n event.preventDefault();\n void addFiles(files);\n }}\n onKeyUp={(event) =>\n updateComposerState(sessionId, (state) => ({ ...state, caret: event.currentTarget.selectionStart }))\n }\n onKeyDown={(event) => {\n // The TUI's leader key: space with nothing typed opens Leader Space.\n if (event.key === ' ' && draft === '') {\n event.preventDefault();\n openPalette();\n return;\n }\n if (completion) {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n const delta = event.key === 'ArrowDown' ? 1 : -1;\n const count = completion.items.length;\n setCompletion({ ...completion, selected: (completion.selected + delta + count) % count });\n return;\n }\n if (event.key === 'Tab') {\n event.preventDefault();\n accept(completion, completion.selected);\n return;\n }\n // Enter completes, unless the token is already the whole\n // thing: completing then would only add a space, so the\n // keystroke would read as doing nothing and the reader would\n // have to press enter twice to send what they had typed.\n if (event.key === 'Enter' && !isCompletionRedundant(completion)) {\n event.preventDefault();\n accept(completion, completion.selected);\n return;\n }\n if (event.key === 'Escape') {\n event.preventDefault();\n dismissCompletion();\n return;\n }\n }\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n submit();\n }\n if (event.key === 'Escape' && active && !aborting) {\n event.preventDefault();\n abortRun(sessionId);\n }\n }}\n rows={1}\n placeholder={placeholder}\n className=\"min-h-12 min-w-0 flex-1 text-lg leading-relaxed\"\n />\n </div>\n {attachments.length > 0 ? (\n <div className=\"flex flex-wrap gap-1.5 px-3.5 pt-2\" data-testid=\"composer-attachments\">\n {attachments.map((attachment) => (\n <span\n key={attachment.id}\n data-testid={`composer-attachment-${attachment.id}`}\n className=\"flex max-w-full items-center gap-1.5 rounded border border-po-border bg-po-panel px-1.5 py-1 text-sm text-po-dim\"\n >\n {attachment.kind === 'image' ? (\n <img src={attachment.dataUrl} alt=\"\" className=\"h-6 w-6 rounded object-cover\" />\n ) : (\n <span className=\"font-semibold text-po-hi\">\n {attachment.kind === 'context' ? 'CTX' : attachment.kind === 'file' ? 'FILE' : 'TXT'}\n </span>\n )}\n <span className=\"max-w-40 truncate\">{attachment.name}</span>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n aria-label={`Remove ${attachment.name}`}\n className=\"text-po-faint hover:text-po-text\"\n onClick={() => {\n updateComposerState(sessionId, (state) => ({\n ...state,\n attachments: state.attachments.filter((item) => item.id !== attachment.id),\n attachmentError: '',\n }));\n }}\n >\n <CloseIcon className=\"h-2.5 w-2.5\" />\n </Button>\n </span>\n ))}\n </div>\n ) : null}\n {attachmentError ? (\n <p role=\"alert\" data-testid=\"composer-attachment-error\" className=\"px-3.5 pt-1.5 text-sm text-po-red\">\n {attachmentError}\n </p>\n ) : null}\n <div className=\"flex flex-wrap items-center gap-2 px-2 pt-2 pb-2.5 sm:flex-nowrap sm:px-3 sm:pb-3\">\n <Popover\n open={menuOpen}\n onOpenChange={(next) => {\n setMenuOpen(next);\n if (next) dismissCompletion();\n }}\n >\n <PopoverTrigger asChild>\n <Button\n variant=\"ghost\"\n size=\"icon-md\"\n data-testid=\"composer-attach\"\n title=\"Add to this message\"\n aria-label=\"Add to this message\"\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen}\n className=\"shrink-0 text-po-dim\"\n >\n <PlusIcon className=\"size-4\" />\n </Button>\n </PopoverTrigger>\n {menuOpen ? (\n <PopoverContent\n side=\"top\"\n align=\"start\"\n sideOffset={8}\n data-testid=\"composer-menu\"\n className=\"w-56 rounded-md p-1.5 shadow-xl\"\n // A menu entry is a way out of the menu: whatever a plugin\n // opens, the menu has done its part. The upload row is the\n // exception, because its click opens the file chooser and\n // unmounting the input under it would strand the pick.\n onClick={(event) => {\n const clicked = event.target as Element | null;\n if (clicked?.closest('[data-testid=\"composer-attach-row\"]')) return;\n setMenuOpen(false);\n }}\n >\n {/* prefer-shared-primitive: ignore -- OptionRow is a button, and a file input may not nest inside one. */}\n <label\n aria-disabled={!attached}\n data-testid=\"composer-attach-row\"\n className={`relative overflow-hidden text-base font-medium text-po-text hover:bg-po-tint-blue ${optionRowVariants(\n { density: 'compact' },\n )} ${attached ? '' : 'pointer-events-none opacity-40'}`}\n >\n <PlusIcon className=\"h-3 w-3 shrink-0\" />\n <span className=\"min-w-0 flex-1 truncate\">File upload</span>\n {/* prefer-shared-primitive: ignore -- iOS needs the native file input itself to cover the visible tap target. */}\n <input\n type=\"file\"\n multiple\n disabled={!attached}\n aria-label=\"Attach files\"\n className=\"absolute inset-0 cursor-pointer opacity-0\"\n data-testid=\"composer-file-input\"\n onChange={(event) => {\n void addFiles(Array.from(event.currentTarget.files ?? []));\n event.currentTarget.value = '';\n setMenuOpen(false);\n }}\n />\n </label>\n <span className=\"contents\" data-testid=\"composer-menu-items\">\n <PluginSurface slot={HOST_SLOTS.composerMenu} sessionId={sessionId} />\n </span>\n </PopoverContent>\n ) : null}\n </Popover>\n <span className=\"min-w-0 flex-1\" />\n <span data-testid=\"composer-hint\" className=\"text-sm text-po-dim max-md:hidden\">\n {active\n ? aborting\n ? 'Abort requested · waiting for the turn to stop'\n : 'Enter steers the run · esc aborts'\n : 'Shift + Enter for a new line'}\n </span>\n {active ? abortAction : null}\n <span className=\"contents\" data-testid=\"composer-actions\">\n <PluginSurface slot={HOST_SLOTS.composerActions} sessionId={sessionId} />\n </span>\n <Button\n variant=\"outline\"\n size=\"lg\"\n data-testid=\"composer-queue\"\n onClick={queue}\n disabled={\n !attached ||\n pendingSubmission ||\n pendingAttachments > 0 ||\n (!draft.trim() && attachments.length === 0)\n }\n title=\"Deliver after the current run settles\"\n >\n Queue\n </Button>\n <Button\n variant=\"primary\"\n size=\"lg\"\n data-testid=\"composer-send\"\n onClick={submit}\n disabled={\n !attached ||\n pendingSubmission ||\n pendingAttachments > 0 ||\n (!draft.trim() && attachments.length === 0)\n }\n className=\"gap-2 px-3 disabled:opacity-60 sm:px-4\"\n >\n <SendIcon aria-hidden className=\"size-4\" />\n {active ? 'Steer' : 'Send'}\n </Button>\n </div>\n </div>\n </PopoverAnchor>\n </Popover>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAM,sBAAsB;AAC5B,MAAM,0BAA0B;AAChC,MAAM,8BAAc,IAAI,IAAI;CAAC;CAAa;CAAc;CAAa;AAAY,CAAC;AAClF,MAAM,kCAAkB,IAAI,IAAI;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,eAAe,MAAqB;CAC3C,MAAM,YAAY,KAAK,KAAK,YAAY,CAAC,CAAC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WAAU,iBAAkB,CAAA;QAClC,oBAAC,QAAD;SAAM,eAAY;SAAgB,WAAU;SACzC,UAAA,SACG,WACE,mDACA,sCACF;QACA,CAAA;QACL,SAAS,cAAc;QACxB,oBAAC,QAAD;SAAM,WAAU;SAAW,eAAY;SACrC,UAAA,oBAAC,eAAD;UAAe,MAAM,WAAW;UAA4B;SAAY,CAAA;QACpE,CAAA;QACN,oBAAC,QAAD;SACE,SAAQ;SACR,MAAK;SACL,eAAY;SACZ,SAAS;SACT,UACE,CAAC,YACD,qBACA,qBAAqB,KACpB,CAAC,MAAM,KAAK,KAAK,YAAY,WAAW;SAE3C,OAAM;SACP,UAAA;QAEO,CAAA;QACR,qBAAC,QAAD;SACE,SAAQ;SACR,MAAK;SACL,eAAY;SACZ,SAAS;SACT,UACE,CAAC,YACD,qBACA,qBAAqB,KACpB,CAAC,MAAM,KAAK,KAAK,YAAY,WAAW;SAE3C,WAAU;SAXZ,UAAA,CAaE,oBAAC,UAAD;UAAU,eAAA;UAAY,WAAU;SAAU,CAAA,GACzC,SAAS,UAAU,MACd;;OACL;;KACF;;GACQ,CAAA;EACR,CAAA,CACN;;AAET"}
@@ -1,4 +1,5 @@
1
1
  const require_sessionSummary = require("./sessionSummary.cjs");
2
+ let _agimon_ai_po_core_hubChannel = require("@agimon-ai/po-core/hubChannel");
2
3
  //#region src/web/lib/sessionRailModel.ts
3
4
  /** Sessions recorded without a workspace are grouped under this id. */
4
5
  const LEGACY_WORKSPACE_ID = "legacy-workspace";
@@ -75,6 +76,7 @@ function buildRailWorkspaces(input) {
75
76
  const workspace = input.workspacesById[workspaceId];
76
77
  if (workspace === void 0) continue;
77
78
  const ids = input.order.filter((id) => input.byId[id]?.summary.workspaceId === workspaceId);
79
+ if (!ids.length && Object.values(input.byId).some(({ summary }) => summary.workspaceId === workspaceId && summary.sessionProvenance === _agimon_ai_po_core_hubChannel.VOICE_ORCHESTRATOR_SESSION_PROVENANCE)) continue;
78
80
  for (const id of ids) grouped.add(id);
79
81
  workspaces.push({
80
82
  id: workspaceId,
@@ -1 +1 @@
1
- {"version":3,"file":"sessionRailModel.cjs","names":["sessionStatusLine","personaInitials"],"sources":["../../../src/web/lib/sessionRailModel.ts"],"sourcesContent":["import type {\n WebTemplateRailPendingSetup,\n WebTemplateRailSession,\n WebTemplateRailWorkspace,\n} from '@agimon-ai/po-core/web';\n\nimport type { SessionSummary, WorkspaceSummary } from '../../types/hub';\nimport { personaInitials, sessionStatusLine, type AttachPhase } from './sessionSummary';\n\n/** Sessions recorded without a workspace are grouped under this id. */\nexport const LEGACY_WORKSPACE_ID = 'legacy-workspace';\n\nexport interface RailSessionInput {\n summary: SessionSummary;\n attach: AttachPhase;\n}\n\n/** A restart the rail asked for: in flight, or failed with a reason. */\nexport interface RailRestartState {\n restarting: boolean;\n error?: string;\n}\n\nexport interface SessionRailModelInput {\n /** Rail order across every workspace; positions become the 1-9 ordinals. */\n order: readonly string[];\n byId: Readonly<Record<string, RailSessionInput>>;\n activeId: string | null;\n workspaceOrder: readonly string[];\n workspacesById: Readonly<Record<string, WorkspaceSummary>>;\n /** Sessions rendered under their parent. */\n nested: ReadonlySet<string>;\n now: number;\n restarts: Readonly<Record<string, RailRestartState>>;\n /** Loaded profile avatars by session id. */\n avatarUrls: Readonly<Record<string, string>>;\n}\n\nexport function workspaceName(workspace: Pick<WorkspaceSummary, 'root' | 'name'>): string {\n if (workspace.name) return workspace.name;\n const trimmed = workspace.root.replace(/\\/+$/u, '');\n return trimmed.slice(trimmed.lastIndexOf('/') + 1) || workspace.root;\n}\n\ntype PendingSetup = NonNullable<SessionSummary['pendingSetups']>[number];\n\n/** The status and recovery copy for a setup-only child reservation. */\nexport function pendingSetupView(setup: PendingSetup): WebTemplateRailPendingSetup {\n const setupType =\n setup.setupKind === 'existing-directory'\n ? 'conversation directory'\n : setup.setupKind === 'managed-worktree'\n ? 'automatic worktree'\n : 'conversation';\n const status =\n setup.status === 'failed'\n ? `${setupType} setup failed`\n : setup.status === 'interrupted'\n ? `${setupType} setup interrupted`\n : `${setupType} provisioning`;\n const recovery =\n setup.setupKind === undefined && setup.cwd !== undefined\n ? 'This existing setup has no verified provider. Inspect its ownership in Po before retrying.'\n : setup.errorCode === 'SESSION_UNAVAILABLE'\n ? 'The existing session is unavailable. Inspect or resume it in Po before retrying the conversation.'\n : setup.status === 'interrupted'\n ? 'Retry the authenticated conversation to resume this setup. The same setup will be reused.'\n : setup.setupKind === 'existing-directory'\n ? 'Inspect the selected directory, then retry the authenticated conversation. The same setup will be reused.'\n : 'Resolve the Git setup, then retry the authenticated conversation. The same setup will be reused.';\n const needsRecovery = setup.status === 'failed' || setup.status === 'interrupted';\n return {\n id: setup.id,\n name: setup.name,\n status,\n failed: setup.status === 'failed',\n ...(needsRecovery ? { recovery } : {}),\n };\n}\n\nfunction sessionView(id: string, ordinal: number, input: SessionRailModelInput): WebTemplateRailSession {\n const { summary, attach } = input.byId[id]!;\n const restart = input.restarts[id];\n const restarting = restart?.restarting === true;\n const status = restarting\n ? 'restarting…'\n : sessionStatusLine(\n {\n attach,\n backgroundWorkActive: summary.backgroundWorkActive,\n phase: summary.phase,\n phaseSince: summary.phaseSince,\n awaitingInput: summary.awaitingInput,\n everPrompted: summary.everPrompted,\n lastSettledAt: summary.lastSettledAt,\n dormant: summary.dormant,\n ...(summary.activity === undefined ? {} : { activity: summary.activity }),\n },\n input.now,\n );\n const nested = input.nested.has(id);\n const profile = summary.profile;\n const label = profile === undefined ? undefined : (profile.displayName ?? profile.name);\n const avatarUrl = input.avatarUrls[id];\n return {\n id,\n name: summary.name,\n ordinal,\n active: id === input.activeId,\n nested,\n ...(nested && summary.sessionProvenance !== undefined ? { provenance: summary.sessionProvenance } : {}),\n status,\n // The same priority the status copy uses: a refusal outranks the question,\n // and a restarting card is describing the restart, not the run it ended.\n // Background work that needs the reader, such as a failed workflow, is\n // marked the same way while the agent itself is idle.\n awaitingInput:\n (summary.awaitingInput ||\n (summary.activity?.attention === true && summary.phase === 'idle' && summary.dormant !== true)) &&\n attach !== 'refused' &&\n !restarting,\n restarting,\n restartBlocked: summary.dormant !== true && summary.phase !== undefined && summary.phase !== 'idle',\n ...(restart?.error === undefined ? {} : { error: restart.error }),\n ...(summary.git === undefined ? {} : { git: { branch: summary.git.branch, dirty: summary.git.dirty } }),\n ...(summary.groups === undefined || summary.groups.length === 0 ? {} : { groups: summary.groups }),\n ...(profile === undefined || label === undefined\n ? {}\n : {\n profile: {\n name: profile.name,\n label,\n initials: personaInitials(label),\n ...(avatarUrl === undefined ? {} : { avatarUrl }),\n },\n }),\n pendingSetups: (summary.pendingSetups ?? []).map(pendingSetupView),\n };\n}\n\n/** The rail's workspaces in host order, each with its sessions; ungrouped sessions last. */\nexport function buildRailWorkspaces(input: SessionRailModelInput): WebTemplateRailWorkspace[] {\n const ordinals = new Map(input.order.map((id, index) => [id, index + 1]));\n const grouped = new Set<string>();\n const workspaces: WebTemplateRailWorkspace[] = [];\n for (const workspaceId of input.workspaceOrder) {\n const workspace = input.workspacesById[workspaceId];\n if (workspace === undefined) continue;\n const ids = input.order.filter((id) => input.byId[id]?.summary.workspaceId === workspaceId);\n for (const id of ids) grouped.add(id);\n workspaces.push({\n id: workspaceId,\n name: workspaceName(workspace),\n root: workspace.root,\n available: workspace.available !== false,\n legacy: false,\n sessions: ids.map((id) => sessionView(id, ordinals.get(id) ?? 0, input)),\n });\n }\n const legacy = input.order.filter((id) => !grouped.has(id) && input.byId[id] !== undefined);\n if (legacy.length > 0) {\n const root = input.byId[legacy[0]!]!.summary.cwd;\n workspaces.push({\n id: LEGACY_WORKSPACE_ID,\n name: workspaceName({ root }),\n root,\n available: false,\n legacy: true,\n sessions: legacy.map((id) => sessionView(id, ordinals.get(id) ?? 0, input)),\n });\n }\n return workspaces;\n}\n"],"mappings":";;;AAUA,MAAa,sBAAsB;AA4BnC,SAAgB,cAAc,WAA4D;CACxF,IAAI,UAAU,MAAM,OAAO,UAAU;CACrC,MAAM,UAAU,UAAU,KAAK,QAAQ,SAAS,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G,EAAE,QAAQ,gBAAgB,WAAW;EAC1F,KAAK,MAAM,MAAM,KAAK,QAAQ,IAAI,EAAE;EACpC,WAAW,KAAK;GACd,IAAI;GACJ,MAAM,cAAc,SAAS;GAC7B,MAAM,UAAU;GAChB,WAAW,UAAU,cAAc;GACnC,QAAQ;GACR,UAAU,IAAI,KAAK,OAAO,YAAY,IAAI,SAAS,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;EACzE,CAAC;CACH;CACA,MAAM,SAAS,MAAM,MAAM,QAAQ,OAAO,CAAC,QAAQ,IAAI,EAAE,KAAK,MAAM,KAAK,QAAQ,KAAA,CAAS;CAC1F,IAAI,OAAO,SAAS,GAAG;EACrB,MAAM,OAAO,MAAM,KAAK,OAAO,GAAI,CAAE,QAAQ;EAC7C,WAAW,KAAK;GACd,IAAI;GACJ,MAAM,cAAc,EAAE,KAAK,CAAC;GAC5B;GACA,WAAW;GACX,QAAQ;GACR,UAAU,OAAO,KAAK,OAAO,YAAY,IAAI,SAAS,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;EAC5E,CAAC;CACH;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"sessionRailModel.cjs","names":["sessionStatusLine","personaInitials","VOICE_ORCHESTRATOR_SESSION_PROVENANCE"],"sources":["../../../src/web/lib/sessionRailModel.ts"],"sourcesContent":["import { VOICE_ORCHESTRATOR_SESSION_PROVENANCE } from '@agimon-ai/po-core/hubChannel';\nimport type {\n WebTemplateRailPendingSetup,\n WebTemplateRailSession,\n WebTemplateRailWorkspace,\n} from '@agimon-ai/po-core/web';\n\nimport type { SessionSummary, WorkspaceSummary } from '../../types/hub';\nimport { personaInitials, sessionStatusLine, type AttachPhase } from './sessionSummary';\n\n/** Sessions recorded without a workspace are grouped under this id. */\nexport const LEGACY_WORKSPACE_ID = 'legacy-workspace';\n\nexport interface RailSessionInput {\n summary: SessionSummary;\n attach: AttachPhase;\n}\n\n/** A restart the rail asked for: in flight, or failed with a reason. */\nexport interface RailRestartState {\n restarting: boolean;\n error?: string;\n}\n\nexport interface SessionRailModelInput {\n /** Rail order across every workspace; positions become the 1-9 ordinals. */\n order: readonly string[];\n byId: Readonly<Record<string, RailSessionInput>>;\n activeId: string | null;\n workspaceOrder: readonly string[];\n workspacesById: Readonly<Record<string, WorkspaceSummary>>;\n /** Sessions rendered under their parent. */\n nested: ReadonlySet<string>;\n now: number;\n restarts: Readonly<Record<string, RailRestartState>>;\n /** Loaded profile avatars by session id. */\n avatarUrls: Readonly<Record<string, string>>;\n}\n\nexport function workspaceName(workspace: Pick<WorkspaceSummary, 'root' | 'name'>): string {\n if (workspace.name) return workspace.name;\n const trimmed = workspace.root.replace(/\\/+$/u, '');\n return trimmed.slice(trimmed.lastIndexOf('/') + 1) || workspace.root;\n}\n\ntype PendingSetup = NonNullable<SessionSummary['pendingSetups']>[number];\n\n/** The status and recovery copy for a setup-only child reservation. */\nexport function pendingSetupView(setup: PendingSetup): WebTemplateRailPendingSetup {\n const setupType =\n setup.setupKind === 'existing-directory'\n ? 'conversation directory'\n : setup.setupKind === 'managed-worktree'\n ? 'automatic worktree'\n : 'conversation';\n const status =\n setup.status === 'failed'\n ? `${setupType} setup failed`\n : setup.status === 'interrupted'\n ? `${setupType} setup interrupted`\n : `${setupType} provisioning`;\n const recovery =\n setup.setupKind === undefined && setup.cwd !== undefined\n ? 'This existing setup has no verified provider. Inspect its ownership in Po before retrying.'\n : setup.errorCode === 'SESSION_UNAVAILABLE'\n ? 'The existing session is unavailable. Inspect or resume it in Po before retrying the conversation.'\n : setup.status === 'interrupted'\n ? 'Retry the authenticated conversation to resume this setup. The same setup will be reused.'\n : setup.setupKind === 'existing-directory'\n ? 'Inspect the selected directory, then retry the authenticated conversation. The same setup will be reused.'\n : 'Resolve the Git setup, then retry the authenticated conversation. The same setup will be reused.';\n const needsRecovery = setup.status === 'failed' || setup.status === 'interrupted';\n return {\n id: setup.id,\n name: setup.name,\n status,\n failed: setup.status === 'failed',\n ...(needsRecovery ? { recovery } : {}),\n };\n}\n\nfunction sessionView(id: string, ordinal: number, input: SessionRailModelInput): WebTemplateRailSession {\n const { summary, attach } = input.byId[id]!;\n const restart = input.restarts[id];\n const restarting = restart?.restarting === true;\n const status = restarting\n ? 'restarting…'\n : sessionStatusLine(\n {\n attach,\n backgroundWorkActive: summary.backgroundWorkActive,\n phase: summary.phase,\n phaseSince: summary.phaseSince,\n awaitingInput: summary.awaitingInput,\n everPrompted: summary.everPrompted,\n lastSettledAt: summary.lastSettledAt,\n dormant: summary.dormant,\n ...(summary.activity === undefined ? {} : { activity: summary.activity }),\n },\n input.now,\n );\n const nested = input.nested.has(id);\n const profile = summary.profile;\n const label = profile === undefined ? undefined : (profile.displayName ?? profile.name);\n const avatarUrl = input.avatarUrls[id];\n return {\n id,\n name: summary.name,\n ordinal,\n active: id === input.activeId,\n nested,\n ...(nested && summary.sessionProvenance !== undefined ? { provenance: summary.sessionProvenance } : {}),\n status,\n // The same priority the status copy uses: a refusal outranks the question,\n // and a restarting card is describing the restart, not the run it ended.\n // Background work that needs the reader, such as a failed workflow, is\n // marked the same way while the agent itself is idle.\n awaitingInput:\n (summary.awaitingInput ||\n (summary.activity?.attention === true && summary.phase === 'idle' && summary.dormant !== true)) &&\n attach !== 'refused' &&\n !restarting,\n restarting,\n restartBlocked: summary.dormant !== true && summary.phase !== undefined && summary.phase !== 'idle',\n ...(restart?.error === undefined ? {} : { error: restart.error }),\n ...(summary.git === undefined ? {} : { git: { branch: summary.git.branch, dirty: summary.git.dirty } }),\n ...(summary.groups === undefined || summary.groups.length === 0 ? {} : { groups: summary.groups }),\n ...(profile === undefined || label === undefined\n ? {}\n : {\n profile: {\n name: profile.name,\n label,\n initials: personaInitials(label),\n ...(avatarUrl === undefined ? {} : { avatarUrl }),\n },\n }),\n pendingSetups: (summary.pendingSetups ?? []).map(pendingSetupView),\n };\n}\n\n/** The rail's workspaces in host order, each with its sessions; ungrouped sessions last. */\nexport function buildRailWorkspaces(input: SessionRailModelInput): WebTemplateRailWorkspace[] {\n const ordinals = new Map(input.order.map((id, index) => [id, index + 1]));\n const grouped = new Set<string>();\n const workspaces: WebTemplateRailWorkspace[] = [];\n for (const workspaceId of input.workspaceOrder) {\n const workspace = input.workspacesById[workspaceId];\n if (workspace === undefined) continue;\n const ids = input.order.filter((id) => input.byId[id]?.summary.workspaceId === workspaceId);\n if (\n !ids.length &&\n Object.values(input.byId).some(\n ({ summary }) =>\n summary.workspaceId === workspaceId && summary.sessionProvenance === VOICE_ORCHESTRATOR_SESSION_PROVENANCE,\n )\n )\n continue;\n for (const id of ids) grouped.add(id);\n workspaces.push({\n id: workspaceId,\n name: workspaceName(workspace),\n root: workspace.root,\n available: workspace.available !== false,\n legacy: false,\n sessions: ids.map((id) => sessionView(id, ordinals.get(id) ?? 0, input)),\n });\n }\n const legacy = input.order.filter((id) => !grouped.has(id) && input.byId[id] !== undefined);\n if (legacy.length > 0) {\n const root = input.byId[legacy[0]!]!.summary.cwd;\n workspaces.push({\n id: LEGACY_WORKSPACE_ID,\n name: workspaceName({ root }),\n root,\n available: false,\n legacy: true,\n sessions: legacy.map((id) => sessionView(id, ordinals.get(id) ?? 0, input)),\n });\n }\n return workspaces;\n}\n"],"mappings":";;;;AAWA,MAAa,sBAAsB;AA4BnC,SAAgB,cAAc,WAA4D;CACxF,IAAI,UAAU,MAAM,OAAO,UAAU;CACrC,MAAM,UAAU,UAAU,KAAK,QAAQ,SAAS,EAAE;CAClD,OAAO,QAAQ,MAAM,QAAQ,YAAY,GAAG,IAAI,CAAC,KAAK,UAAU;AAClE;;AAKA,SAAgB,iBAAiB,OAAkD;CACjF,MAAM,YACJ,MAAM,cAAc,uBAChB,2BACA,MAAM,cAAc,qBAClB,uBACA;CACR,MAAM,SACJ,MAAM,WAAW,WACb,GAAG,UAAU,iBACb,MAAM,WAAW,gBACf,GAAG,UAAU,sBACb,GAAG,UAAU;CACrB,MAAM,WACJ,MAAM,cAAc,KAAA,KAAa,MAAM,QAAQ,KAAA,IAC3C,+FACA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OAAO,YAAY,IAAI,SAAS,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;EACzE,CAAC;CACH;CACA,MAAM,SAAS,MAAM,MAAM,QAAQ,OAAO,CAAC,QAAQ,IAAI,EAAE,KAAK,MAAM,KAAK,QAAQ,KAAA,CAAS;CAC1F,IAAI,OAAO,SAAS,GAAG;EACrB,MAAM,OAAO,MAAM,KAAK,OAAO,GAAI,CAAE,QAAQ;EAC7C,WAAW,KAAK;GACd,IAAI;GACJ,MAAM,cAAc,EAAE,KAAK,CAAC;GAC5B;GACA,WAAW;GACX,QAAQ;GACR,UAAU,OAAO,KAAK,OAAO,YAAY,IAAI,SAAS,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;EAC5E,CAAC;CACH;CACA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"sessionRailModel.d.mts","names":[],"sources":["../../../src/web/lib/sessionRailModel.ts"],"mappings":";;;;;qBAUa;iBAEI;EACf,SAAS;EACT,QAAQ;;;iBAIO;EACf;EACA;;iBAGe;;EAEf;EACA,MAAM,SAAS,eAAe;EAC9B;EACA;EACA,gBAAgB,SAAS,eAAe;;EAExC,QAAQ;EACR;EACA,UAAU,SAAS,eAAe;;EAElC,YAAY,SAAS;;wBAGP,cAAc,WAAW,KAAK;KAMzC,eAAe,YAAY;;wBAGhB,iBAAiB,OAAO,eAAe;;wBA8FvC,oBAAoB,OAAO,wBAAwB"}
1
+ {"version":3,"file":"sessionRailModel.d.mts","names":[],"sources":["../../../src/web/lib/sessionRailModel.ts"],"mappings":";;;;;qBAWa;iBAEI;EACf,SAAS;EACT,QAAQ;;;iBAIO;EACf;EACA;;iBAGe;;EAEf;EACA,MAAM,SAAS,eAAe;EAC9B;EACA;EACA,gBAAgB,SAAS,eAAe;;EAExC,QAAQ;EACR;EACA,UAAU,SAAS,eAAe;;EAElC,YAAY,SAAS;;wBAGP,cAAc,WAAW,KAAK;KAMzC,eAAe,YAAY;;wBAGhB,iBAAiB,OAAO,eAAe;;wBA8FvC,oBAAoB,OAAO,wBAAwB"}
@@ -1,4 +1,5 @@
1
1
  import { personaInitials, sessionStatusLine } from "./sessionSummary.mjs";
2
+ import { VOICE_ORCHESTRATOR_SESSION_PROVENANCE } from "@agimon-ai/po-core/hubChannel";
2
3
  //#region src/web/lib/sessionRailModel.ts
3
4
  /** Sessions recorded without a workspace are grouped under this id. */
4
5
  const LEGACY_WORKSPACE_ID = "legacy-workspace";
@@ -75,6 +76,7 @@ function buildRailWorkspaces(input) {
75
76
  const workspace = input.workspacesById[workspaceId];
76
77
  if (workspace === void 0) continue;
77
78
  const ids = input.order.filter((id) => input.byId[id]?.summary.workspaceId === workspaceId);
79
+ if (!ids.length && Object.values(input.byId).some(({ summary }) => summary.workspaceId === workspaceId && summary.sessionProvenance === VOICE_ORCHESTRATOR_SESSION_PROVENANCE)) continue;
78
80
  for (const id of ids) grouped.add(id);
79
81
  workspaces.push({
80
82
  id: workspaceId,
@@ -1 +1 @@
1
- {"version":3,"file":"sessionRailModel.mjs","names":[],"sources":["../../../src/web/lib/sessionRailModel.ts"],"sourcesContent":["import type {\n WebTemplateRailPendingSetup,\n WebTemplateRailSession,\n WebTemplateRailWorkspace,\n} from '@agimon-ai/po-core/web';\n\nimport type { SessionSummary, WorkspaceSummary } from '../../types/hub';\nimport { personaInitials, sessionStatusLine, type AttachPhase } from './sessionSummary';\n\n/** Sessions recorded without a workspace are grouped under this id. */\nexport const LEGACY_WORKSPACE_ID = 'legacy-workspace';\n\nexport interface RailSessionInput {\n summary: SessionSummary;\n attach: AttachPhase;\n}\n\n/** A restart the rail asked for: in flight, or failed with a reason. */\nexport interface RailRestartState {\n restarting: boolean;\n error?: string;\n}\n\nexport interface SessionRailModelInput {\n /** Rail order across every workspace; positions become the 1-9 ordinals. */\n order: readonly string[];\n byId: Readonly<Record<string, RailSessionInput>>;\n activeId: string | null;\n workspaceOrder: readonly string[];\n workspacesById: Readonly<Record<string, WorkspaceSummary>>;\n /** Sessions rendered under their parent. */\n nested: ReadonlySet<string>;\n now: number;\n restarts: Readonly<Record<string, RailRestartState>>;\n /** Loaded profile avatars by session id. */\n avatarUrls: Readonly<Record<string, string>>;\n}\n\nexport function workspaceName(workspace: Pick<WorkspaceSummary, 'root' | 'name'>): string {\n if (workspace.name) return workspace.name;\n const trimmed = workspace.root.replace(/\\/+$/u, '');\n return trimmed.slice(trimmed.lastIndexOf('/') + 1) || workspace.root;\n}\n\ntype PendingSetup = NonNullable<SessionSummary['pendingSetups']>[number];\n\n/** The status and recovery copy for a setup-only child reservation. */\nexport function pendingSetupView(setup: PendingSetup): WebTemplateRailPendingSetup {\n const setupType =\n setup.setupKind === 'existing-directory'\n ? 'conversation directory'\n : setup.setupKind === 'managed-worktree'\n ? 'automatic worktree'\n : 'conversation';\n const status =\n setup.status === 'failed'\n ? `${setupType} setup failed`\n : setup.status === 'interrupted'\n ? `${setupType} setup interrupted`\n : `${setupType} provisioning`;\n const recovery =\n setup.setupKind === undefined && setup.cwd !== undefined\n ? 'This existing setup has no verified provider. Inspect its ownership in Po before retrying.'\n : setup.errorCode === 'SESSION_UNAVAILABLE'\n ? 'The existing session is unavailable. Inspect or resume it in Po before retrying the conversation.'\n : setup.status === 'interrupted'\n ? 'Retry the authenticated conversation to resume this setup. The same setup will be reused.'\n : setup.setupKind === 'existing-directory'\n ? 'Inspect the selected directory, then retry the authenticated conversation. The same setup will be reused.'\n : 'Resolve the Git setup, then retry the authenticated conversation. The same setup will be reused.';\n const needsRecovery = setup.status === 'failed' || setup.status === 'interrupted';\n return {\n id: setup.id,\n name: setup.name,\n status,\n failed: setup.status === 'failed',\n ...(needsRecovery ? { recovery } : {}),\n };\n}\n\nfunction sessionView(id: string, ordinal: number, input: SessionRailModelInput): WebTemplateRailSession {\n const { summary, attach } = input.byId[id]!;\n const restart = input.restarts[id];\n const restarting = restart?.restarting === true;\n const status = restarting\n ? 'restarting…'\n : sessionStatusLine(\n {\n attach,\n backgroundWorkActive: summary.backgroundWorkActive,\n phase: summary.phase,\n phaseSince: summary.phaseSince,\n awaitingInput: summary.awaitingInput,\n everPrompted: summary.everPrompted,\n lastSettledAt: summary.lastSettledAt,\n dormant: summary.dormant,\n ...(summary.activity === undefined ? {} : { activity: summary.activity }),\n },\n input.now,\n );\n const nested = input.nested.has(id);\n const profile = summary.profile;\n const label = profile === undefined ? undefined : (profile.displayName ?? profile.name);\n const avatarUrl = input.avatarUrls[id];\n return {\n id,\n name: summary.name,\n ordinal,\n active: id === input.activeId,\n nested,\n ...(nested && summary.sessionProvenance !== undefined ? { provenance: summary.sessionProvenance } : {}),\n status,\n // The same priority the status copy uses: a refusal outranks the question,\n // and a restarting card is describing the restart, not the run it ended.\n // Background work that needs the reader, such as a failed workflow, is\n // marked the same way while the agent itself is idle.\n awaitingInput:\n (summary.awaitingInput ||\n (summary.activity?.attention === true && summary.phase === 'idle' && summary.dormant !== true)) &&\n attach !== 'refused' &&\n !restarting,\n restarting,\n restartBlocked: summary.dormant !== true && summary.phase !== undefined && summary.phase !== 'idle',\n ...(restart?.error === undefined ? {} : { error: restart.error }),\n ...(summary.git === undefined ? {} : { git: { branch: summary.git.branch, dirty: summary.git.dirty } }),\n ...(summary.groups === undefined || summary.groups.length === 0 ? {} : { groups: summary.groups }),\n ...(profile === undefined || label === undefined\n ? {}\n : {\n profile: {\n name: profile.name,\n label,\n initials: personaInitials(label),\n ...(avatarUrl === undefined ? {} : { avatarUrl }),\n },\n }),\n pendingSetups: (summary.pendingSetups ?? []).map(pendingSetupView),\n };\n}\n\n/** The rail's workspaces in host order, each with its sessions; ungrouped sessions last. */\nexport function buildRailWorkspaces(input: SessionRailModelInput): WebTemplateRailWorkspace[] {\n const ordinals = new Map(input.order.map((id, index) => [id, index + 1]));\n const grouped = new Set<string>();\n const workspaces: WebTemplateRailWorkspace[] = [];\n for (const workspaceId of input.workspaceOrder) {\n const workspace = input.workspacesById[workspaceId];\n if (workspace === undefined) continue;\n const ids = input.order.filter((id) => input.byId[id]?.summary.workspaceId === workspaceId);\n for (const id of ids) grouped.add(id);\n workspaces.push({\n id: workspaceId,\n name: workspaceName(workspace),\n root: workspace.root,\n available: workspace.available !== false,\n legacy: false,\n sessions: ids.map((id) => sessionView(id, ordinals.get(id) ?? 0, input)),\n });\n }\n const legacy = input.order.filter((id) => !grouped.has(id) && input.byId[id] !== undefined);\n if (legacy.length > 0) {\n const root = input.byId[legacy[0]!]!.summary.cwd;\n workspaces.push({\n id: LEGACY_WORKSPACE_ID,\n name: workspaceName({ root }),\n root,\n available: false,\n legacy: true,\n sessions: legacy.map((id) => sessionView(id, ordinals.get(id) ?? 0, input)),\n });\n }\n return workspaces;\n}\n"],"mappings":";;;AAUA,MAAa,sBAAsB;AA4BnC,SAAgB,cAAc,WAA4D;CACxF,IAAI,UAAU,MAAM,OAAO,UAAU;CACrC,MAAM,UAAU,UAAU,KAAK,QAAQ,SAAS,EAAE;CAClD,OAAO,QAAQ,MAAM,QAAQ,YAAY,GAAG,IAAI,CAAC,KAAK,UAAU;AAClE;;AAKA,SAAgB,iBAAiB,OAAkD;CACjF,MAAM,YACJ,MAAM,cAAc,uBAChB,2BACA,MAAM,cAAc,qBAClB,uBACA;CACR,MAAM,SACJ,MAAM,WAAW,WACb,GAAG,UAAU,iBACb,MAAM,WAAW,gBACf,GAAG,UAAU,sBACb,GAAG,UAAU;CACrB,MAAM,WACJ,MAAM,cAAc,KAAA,KAAa,MAAM,QAAQ,KAAA,IAC3C,+FACA,MAAM,cAAc,wBAClB,sGACA,MAAM,WAAW,gBACf,8FACA,MAAM,cAAc,uBAClB,8GACA;CACZ,MAAM,gBAAgB,MAAM,WAAW,YAAY,MAAM,WAAW;CACpE,OAAO;EACL,IAAI,MAAM;EACV,MAAM,MAAM;EACZ;EACA,QAAQ,MAAM,WAAW;EACzB,GAAI,gBAAgB,EAAE,SAAS,IAAI,CAAC;CACtC;AACF;AAEA,SAAS,YAAY,IAAY,SAAiB,OAAsD;CACtG,MAAM,EAAE,SAAS,WAAW,MAAM,KAAK;CAC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"sessionRailModel.mjs","names":[],"sources":["../../../src/web/lib/sessionRailModel.ts"],"sourcesContent":["import { VOICE_ORCHESTRATOR_SESSION_PROVENANCE } from '@agimon-ai/po-core/hubChannel';\nimport type {\n WebTemplateRailPendingSetup,\n WebTemplateRailSession,\n WebTemplateRailWorkspace,\n} from '@agimon-ai/po-core/web';\n\nimport type { SessionSummary, WorkspaceSummary } from '../../types/hub';\nimport { personaInitials, sessionStatusLine, type AttachPhase } from './sessionSummary';\n\n/** Sessions recorded without a workspace are grouped under this id. */\nexport const LEGACY_WORKSPACE_ID = 'legacy-workspace';\n\nexport interface RailSessionInput {\n summary: SessionSummary;\n attach: AttachPhase;\n}\n\n/** A restart the rail asked for: in flight, or failed with a reason. */\nexport interface RailRestartState {\n restarting: boolean;\n error?: string;\n}\n\nexport interface SessionRailModelInput {\n /** Rail order across every workspace; positions become the 1-9 ordinals. */\n order: readonly string[];\n byId: Readonly<Record<string, RailSessionInput>>;\n activeId: string | null;\n workspaceOrder: readonly string[];\n workspacesById: Readonly<Record<string, WorkspaceSummary>>;\n /** Sessions rendered under their parent. */\n nested: ReadonlySet<string>;\n now: number;\n restarts: Readonly<Record<string, RailRestartState>>;\n /** Loaded profile avatars by session id. */\n avatarUrls: Readonly<Record<string, string>>;\n}\n\nexport function workspaceName(workspace: Pick<WorkspaceSummary, 'root' | 'name'>): string {\n if (workspace.name) return workspace.name;\n const trimmed = workspace.root.replace(/\\/+$/u, '');\n return trimmed.slice(trimmed.lastIndexOf('/') + 1) || workspace.root;\n}\n\ntype PendingSetup = NonNullable<SessionSummary['pendingSetups']>[number];\n\n/** The status and recovery copy for a setup-only child reservation. */\nexport function pendingSetupView(setup: PendingSetup): WebTemplateRailPendingSetup {\n const setupType =\n setup.setupKind === 'existing-directory'\n ? 'conversation directory'\n : setup.setupKind === 'managed-worktree'\n ? 'automatic worktree'\n : 'conversation';\n const status =\n setup.status === 'failed'\n ? `${setupType} setup failed`\n : setup.status === 'interrupted'\n ? `${setupType} setup interrupted`\n : `${setupType} provisioning`;\n const recovery =\n setup.setupKind === undefined && setup.cwd !== undefined\n ? 'This existing setup has no verified provider. Inspect its ownership in Po before retrying.'\n : setup.errorCode === 'SESSION_UNAVAILABLE'\n ? 'The existing session is unavailable. Inspect or resume it in Po before retrying the conversation.'\n : setup.status === 'interrupted'\n ? 'Retry the authenticated conversation to resume this setup. The same setup will be reused.'\n : setup.setupKind === 'existing-directory'\n ? 'Inspect the selected directory, then retry the authenticated conversation. The same setup will be reused.'\n : 'Resolve the Git setup, then retry the authenticated conversation. The same setup will be reused.';\n const needsRecovery = setup.status === 'failed' || setup.status === 'interrupted';\n return {\n id: setup.id,\n name: setup.name,\n status,\n failed: setup.status === 'failed',\n ...(needsRecovery ? { recovery } : {}),\n };\n}\n\nfunction sessionView(id: string, ordinal: number, input: SessionRailModelInput): WebTemplateRailSession {\n const { summary, attach } = input.byId[id]!;\n const restart = input.restarts[id];\n const restarting = restart?.restarting === true;\n const status = restarting\n ? 'restarting…'\n : sessionStatusLine(\n {\n attach,\n backgroundWorkActive: summary.backgroundWorkActive,\n phase: summary.phase,\n phaseSince: summary.phaseSince,\n awaitingInput: summary.awaitingInput,\n everPrompted: summary.everPrompted,\n lastSettledAt: summary.lastSettledAt,\n dormant: summary.dormant,\n ...(summary.activity === undefined ? {} : { activity: summary.activity }),\n },\n input.now,\n );\n const nested = input.nested.has(id);\n const profile = summary.profile;\n const label = profile === undefined ? undefined : (profile.displayName ?? profile.name);\n const avatarUrl = input.avatarUrls[id];\n return {\n id,\n name: summary.name,\n ordinal,\n active: id === input.activeId,\n nested,\n ...(nested && summary.sessionProvenance !== undefined ? { provenance: summary.sessionProvenance } : {}),\n status,\n // The same priority the status copy uses: a refusal outranks the question,\n // and a restarting card is describing the restart, not the run it ended.\n // Background work that needs the reader, such as a failed workflow, is\n // marked the same way while the agent itself is idle.\n awaitingInput:\n (summary.awaitingInput ||\n (summary.activity?.attention === true && summary.phase === 'idle' && summary.dormant !== true)) &&\n attach !== 'refused' &&\n !restarting,\n restarting,\n restartBlocked: summary.dormant !== true && summary.phase !== undefined && summary.phase !== 'idle',\n ...(restart?.error === undefined ? {} : { error: restart.error }),\n ...(summary.git === undefined ? {} : { git: { branch: summary.git.branch, dirty: summary.git.dirty } }),\n ...(summary.groups === undefined || summary.groups.length === 0 ? {} : { groups: summary.groups }),\n ...(profile === undefined || label === undefined\n ? {}\n : {\n profile: {\n name: profile.name,\n label,\n initials: personaInitials(label),\n ...(avatarUrl === undefined ? {} : { avatarUrl }),\n },\n }),\n pendingSetups: (summary.pendingSetups ?? []).map(pendingSetupView),\n };\n}\n\n/** The rail's workspaces in host order, each with its sessions; ungrouped sessions last. */\nexport function buildRailWorkspaces(input: SessionRailModelInput): WebTemplateRailWorkspace[] {\n const ordinals = new Map(input.order.map((id, index) => [id, index + 1]));\n const grouped = new Set<string>();\n const workspaces: WebTemplateRailWorkspace[] = [];\n for (const workspaceId of input.workspaceOrder) {\n const workspace = input.workspacesById[workspaceId];\n if (workspace === undefined) continue;\n const ids = input.order.filter((id) => input.byId[id]?.summary.workspaceId === workspaceId);\n if (\n !ids.length &&\n Object.values(input.byId).some(\n ({ summary }) =>\n summary.workspaceId === workspaceId && summary.sessionProvenance === VOICE_ORCHESTRATOR_SESSION_PROVENANCE,\n )\n )\n continue;\n for (const id of ids) grouped.add(id);\n workspaces.push({\n id: workspaceId,\n name: workspaceName(workspace),\n root: workspace.root,\n available: workspace.available !== false,\n legacy: false,\n sessions: ids.map((id) => sessionView(id, ordinals.get(id) ?? 0, input)),\n });\n }\n const legacy = input.order.filter((id) => !grouped.has(id) && input.byId[id] !== undefined);\n if (legacy.length > 0) {\n const root = input.byId[legacy[0]!]!.summary.cwd;\n workspaces.push({\n id: LEGACY_WORKSPACE_ID,\n name: workspaceName({ root }),\n root,\n available: false,\n legacy: true,\n sessions: legacy.map((id) => sessionView(id, ordinals.get(id) ?? 0, input)),\n });\n }\n return workspaces;\n}\n"],"mappings":";;;;AAWA,MAAa,sB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AAe;EACvC,IAAI,cAAc,KAAA,GAAW;EAC7B,MAAM,MAAM,MAAM,MAAM,QAAQ,OAAO,MAAM,KAAK,GAAG,EAAE,QAAQ,gBAAgB,WAAW;EAC1F,IACE,CAAC,IAAI,UACL,OAAO,OAAO,MAAM,IAAI,CAAC,CAAC,MACvB,EAAE,cACD,QAAQ,gBAAgB,eAAe,QAAQ,sBAAsB,qCACzE,GAEA;EACF,KAAK,MAAM,MAAM,KAAK,QAAQ,IAAI,EAAE;EACpC,WAAW,KAAK;GACd,IAAI;GACJ,MAAM,cAAc,SAAS;GAC7B,MAAM,UAAU;GAChB,WAAW,UAAU,cAAc;GACnC,QAAQ;GACR,UAAU,IAAI,KAAK,OAAO,YAAY,IAAI,SAAS,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;EACzE,CAAC;CACH;CACA,MAAM,SAAS,MAAM,MAAM,QAAQ,OAAO,CAAC,QAAQ,IAAI,EAAE,KAAK,MAAM,KAAK,QAAQ,KAAA,CAAS;CAC1F,IAAI,OAAO,SAAS,GAAG;EACrB,MAAM,OAAO,MAAM,KAAK,OAAO,GAAI,CAAE,QAAQ;EAC7C,WAAW,KAAK;GACd,IAAI;GACJ,MAAM,cAAc,EAAE,KAAK,CAAC;GAC5B;GACA,WAAW;GACX,QAAQ;GACR,UAAU,OAAO,KAAK,OAAO,YAAY,IAAI,SAAS,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;EAC5E,CAAC;CACH;CACA,OAAO;AACT"}
@@ -41,10 +41,10 @@ function resolveParentId(byId, id) {
41
41
  }
42
42
  return parent;
43
43
  }
44
- /** A session read somewhere other than the rail: a workflow step's, or a workflow dispatcher's. */
44
+ /** Internal sessions keep their history but take no rail row or keyboard ordinal. */
45
45
  function railHidden(meta) {
46
46
  const provenance = meta.summary.sessionProvenance;
47
- return provenance === _agimon_ai_po_core_hubChannel.WORKFLOW_STEP_SESSION_PROVENANCE || provenance === _agimon_ai_po_core_hubChannel.WORKFLOW_DISPATCHER_SESSION_PROVENANCE;
47
+ return provenance === _agimon_ai_po_core_hubChannel.WORKFLOW_STEP_SESSION_PROVENANCE || provenance === _agimon_ai_po_core_hubChannel.WORKFLOW_DISPATCHER_SESSION_PROVENANCE || provenance === _agimon_ai_po_core_hubChannel.VOICE_ORCHESTRATOR_SESSION_PROVENANCE;
48
48
  }
49
49
  /**
50
50
  * Where a session sits in the rail: under its nearest ancestor the rail shows.
@@ -1 +1 @@
1
- {"version":3,"file":"sessionsStore.cjs","names":["Store","bindSessionApiWorkspace","WORKFLOW_STEP_SESSION_PROVENANCE","WORKFLOW_DISPATCHER_SESSION_PROVENANCE","useStore"],"sources":["../../../src/web/stores/sessionsStore.ts"],"sourcesContent":["import {\n WORKFLOW_DISPATCHER_SESSION_PROVENANCE,\n WORKFLOW_STEP_SESSION_PROVENANCE,\n} from '@agimon-ai/po-core/hubChannel';\nimport { bindSessionApiWorkspace } from '@agimon-ai/po-core/web';\nimport { useStore } from '@tanstack/react-store';\nimport { Store } from '@tanstack/store';\n\nimport type { SessionSummary } from '../../types/hub';\nimport type { AttachPhase } from '../lib/sessionSummary';\n\n/** One rail entry: the hub's summary plus this page's view of its connection. */\nexport interface SessionMeta {\n summary: SessionSummary;\n /** summary.attach adjusted for sticky refusals and a lost page socket. */\n attach: AttachPhase;\n reason: string;\n /** Frames replayed into this page's timeline on the last subscribe. */\n replayed: number;\n /** Frames the hub's bounded ring lost before this page subscribed. */\n dropped: number;\n}\n\nexport interface SessionsState {\n /** Session ids in rail order: each parent immediately followed by its children. */\n order: string[];\n byId: Record<string, SessionMeta>;\n activeId: string | null;\n /** URL/tab ownership stays with the parent when a tab focuses another session. */\n tabOwnerId?: string | null;\n /** Destination shown while an autonomous voice handoff changes route and media ownership. */\n transferringToId: string | null;\n /** False until the first snapshot; routing waits for it before redirecting. */\n hydrated: boolean;\n /** The server needs newer client code. Only a reload clears it. */\n updateRequired: boolean;\n}\n\n/** The one reason every session shows once the server needs newer client code. */\nexport const UPDATE_REQUIRED_REASON = 'This app is older than the Po server. Update Po to reconnect.';\n\nconst initialState: SessionsState = {\n order: [],\n byId: {},\n activeId: null,\n transferringToId: null,\n hydrated: false,\n updateRequired: false,\n};\n\nexport const sessionsStore = new Store<SessionsState>(initialState);\nbindSessionApiWorkspace((sessionId) => sessionsStore.state.byId[sessionId]?.summary.workspaceId);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction asSummary(value: unknown): SessionSummary | undefined {\n if (!isRecord(value) || typeof value.id !== 'string' || value.id === '') return undefined;\n return value as unknown as SessionSummary;\n}\n\n/**\n * The parent this session nests under, or undefined when it renders at the top\n * level.\n *\n * A parent that has since closed, this session itself, a parent in another\n * workspace, or a cycle all resolve to undefined. The only safe failure is to\n * render the row where it can still be seen rather than to hide or duplicate it.\n */\nexport function resolveParentId(byId: Record<string, SessionMeta>, id: string): string | undefined {\n const parent = byId[id]?.summary.parentSessionId;\n if (\n parent === undefined ||\n parent === id ||\n byId[parent] === undefined ||\n byId[parent].summary.workspaceId !== byId[id].summary.workspaceId\n )\n return undefined;\n let hops = 0;\n const limit = Object.keys(byId).length;\n for (let at: string | undefined = parent; at !== undefined; at = byId[at]?.summary.parentSessionId) {\n if (at === id) return undefined;\n if (++hops > limit) return undefined;\n }\n return parent;\n}\n\n/** A session read somewhere other than the rail: a workflow step's, or a workflow dispatcher's. */\nfunction railHidden(meta: SessionMeta): boolean {\n const provenance = meta.summary.sessionProvenance;\n return provenance === WORKFLOW_STEP_SESSION_PROVENANCE || provenance === WORKFLOW_DISPATCHER_SESSION_PROVENANCE;\n}\n\n/**\n * Where a session sits in the rail: under its nearest ancestor the rail shows.\n *\n * A fork or worktree a step session opens is a real session, and under a\n * parent the rail leaves out it would never be listed, so it moves up to the\n * first ancestor that is, or becomes a root.\n */\nfunction railParentId(byId: Record<string, SessionMeta>, id: string): string | undefined {\n let parent = resolveParentId(byId, id);\n let hops = 0;\n const limit = Object.keys(byId).length;\n while (parent !== undefined && railHidden(byId[parent]) && hops++ <= limit) parent = resolveParentId(byId, parent);\n return parent;\n}\n\n/**\n * The rail's order: roots by creation, each immediately followed by its own\n * children.\n *\n * Ordinal shortcuts index this array positionally, which is why a child sits\n * directly after its parent instead of in a separate group: a worktree spawned\n * from the focused session lands on the next digit. With no lineage present\n * every session is a root and this produces exactly the flat creation sort it\n * replaces.\n */\nfunction sortedOrder(byId: Record<string, SessionMeta>): string[] {\n // A workflow step's session is read inside its workflow, never from the rail, so it\n // takes no row and no ordinal. It stays in `byId` for that view to follow. A\n // workflow dispatcher is a short-lived helper whose runs belong to its parent.\n const byCreation = (left: string, right: string): number => {\n const a = byId[left].summary;\n const b = byId[right].summary;\n return a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id);\n };\n const children = new Map<string, string[]>();\n const roots: string[] = [];\n for (const id of Object.keys(byId)) {\n if (railHidden(byId[id])) continue;\n const parent = railParentId(byId, id);\n if (parent === undefined) {\n roots.push(id);\n continue;\n }\n const siblings = children.get(parent);\n if (siblings === undefined) children.set(parent, [id]);\n else siblings.push(id);\n }\n roots.sort(byCreation);\n for (const siblings of children.values()) siblings.sort(byCreation);\n const order: string[] = [];\n const visit = (id: string): void => {\n order.push(id);\n for (const child of children.get(id) ?? []) visit(child);\n };\n for (const root of roots) visit(root);\n return order;\n}\n\nfunction mergeSummary(\n previous: SessionMeta | undefined,\n summary: SessionSummary,\n updateRequired: boolean,\n): SessionMeta {\n // HTTP still lists sessions after the socket stopped for good; none of them is reachable from here.\n if (updateRequired)\n return {\n summary,\n attach: 'offline',\n reason: UPDATE_REQUIRED_REASON,\n replayed: previous?.replayed ?? 0,\n dropped: previous?.dropped ?? 0,\n };\n // A refusal is sticky: the hub keeps retrying underneath, and reporting each\n // attempt would flicker the card between \"refused\" and \"connecting\" while\n // nothing has actually changed. Only a successful attach clears it.\n const sticky = previous?.attach === 'refused' && summary.attach === 'connecting';\n return {\n summary,\n attach: sticky ? 'refused' : summary.attach,\n reason: sticky ? previous.reason : (summary.attachReason ?? ''),\n replayed: previous?.replayed ?? 0,\n dropped: previous?.dropped ?? 0,\n };\n}\n\nexport function applySessionsSnapshot(frame: Record<string, unknown>): void {\n if (!Array.isArray(frame.sessions)) return;\n const summaries = frame.sessions.map(asSummary).filter((summary): summary is SessionSummary => Boolean(summary));\n sessionsStore.setState((state) => {\n const byId: Record<string, SessionMeta> = {};\n for (const summary of summaries)\n byId[summary.id] = mergeSummary(state.byId[summary.id], summary, state.updateRequired);\n return { ...state, byId, order: sortedOrder(byId), hydrated: true };\n });\n}\n\nexport function applySessionUpsert(frame: Record<string, unknown>): void {\n const summary = asSummary(frame.session);\n if (!summary) return;\n sessionsStore.setState((state) => {\n const byId = {\n ...state.byId,\n [summary.id]: mergeSummary(state.byId[summary.id], summary, state.updateRequired),\n };\n return { ...state, byId, order: sortedOrder(byId) };\n });\n}\n\nexport function applySessionRemoved(frame: Record<string, unknown>): void {\n const sessionId = frame.sessionId;\n if (typeof sessionId !== 'string') return;\n sessionsStore.setState((state) => {\n if (!(sessionId in state.byId)) return state;\n const byId = { ...state.byId };\n delete byId[sessionId];\n return { ...state, byId, order: sortedOrder(byId) };\n });\n}\n\n/** Records what the hub replayed into this page when a subscription started. */\nexport function applySessionBacklog(sessionId: string, replayed: number, dropped: number): void {\n sessionsStore.setState((state) => {\n const meta = state.byId[sessionId];\n if (!meta) return state;\n return { ...state, byId: { ...state.byId, [sessionId]: { ...meta, replayed, dropped } } };\n });\n}\n\n/**\n * The page socket died; every session is unreachable until it comes back.\n * Self-healing: the snapshot on reconnect restores the real states.\n */\nexport function markSocketClosed(): void {\n sessionsStore.setState((state) => {\n const byId: Record<string, SessionMeta> = {};\n for (const [id, meta] of Object.entries(state.byId)) {\n byId[id] = {\n ...meta,\n attach: 'offline',\n reason: state.updateRequired ? UPDATE_REQUIRED_REASON : 'The cockpit lost its bridge.',\n };\n }\n return { ...state, byId };\n });\n}\n\n/**\n * The server needs newer client code; every session is unreachable until the\n * page reloads with it. Unlike a closed socket nothing here heals on its own,\n * so later session lists keep the same state and reason.\n */\nexport function markUpdateRequired(): void {\n sessionsStore.setState((state) => {\n const byId: Record<string, SessionMeta> = {};\n for (const [id, meta] of Object.entries(state.byId)) {\n byId[id] = { ...meta, attach: 'offline', reason: UPDATE_REQUIRED_REASON };\n }\n return { ...state, byId, updateRequired: true };\n });\n}\n\nconst APPEAR_TIMEOUT_MS = 15_000;\n\n/**\n * Resolves once the session shows up in the rail, or false on timeout.\n *\n * A freshly created session exists on disk before its upsert reaches this\n * page; navigating to it too early trips the unknown-session fallback and\n * bounces the user back. Waiting here is what makes \"create, then land on it\"\n * one motion.\n */\nexport function waitForSession(sessionId: string, timeoutMs = APPEAR_TIMEOUT_MS): Promise<boolean> {\n if (sessionId in sessionsStore.state.byId) return Promise.resolve(true);\n return new Promise((resolve) => {\n const finish = (found: boolean): void => {\n clearTimeout(timer);\n subscription.unsubscribe();\n resolve(found);\n };\n const subscription = sessionsStore.subscribe(() => {\n if (sessionId in sessionsStore.state.byId) finish(true);\n });\n const timer = setTimeout(() => finish(false), timeoutMs);\n });\n}\n\n/** Reads the focused session's rail entry, or null while nothing is focused. */\nexport function useActiveSessionMeta(): SessionMeta | null {\n return useStore(sessionsStore, (state) => (state.activeId !== null ? (state.byId[state.activeId] ?? null) : null));\n}\n\n/**\n * True once the hub has answered and reported no sessions at all.\n *\n * Several surfaces stand down on this, so the rule is named once rather than\n * spelled out at each of them. The hydration half is what keeps it honest: an\n * empty order before the first snapshot only means the hub has not answered\n * yet, and treating that as \"no sessions\" would flash an onboarding screen at\n * someone who has ten.\n */\nexport function noSessions(state: SessionsState): boolean {\n return state.hydrated && state.order.length === 0;\n}\n\nexport function useNoSessions(): boolean {\n return useStore(sessionsStore, noSessions);\n}\n\nexport function setActiveSession(sessionId: string | null, tabOwnerId: string | null = sessionId): void {\n sessionsStore.setState((state) =>\n state.activeId === sessionId && (state.tabOwnerId ?? state.activeId) === tabOwnerId\n ? state\n : { ...state, activeId: sessionId, tabOwnerId },\n );\n}\n\nexport function beginSessionTransfer(sessionId: string): void {\n sessionsStore.setState((state) =>\n state.transferringToId === sessionId ? state : { ...state, transferringToId: sessionId },\n );\n}\n\nexport function completeSessionTransfer(sessionId: string): void {\n sessionsStore.setState((state) =>\n state.transferringToId === sessionId ? { ...state, transferringToId: null } : state,\n );\n}\n\nexport function activeSessionId(): string | null {\n return sessionsStore.state.activeId;\n}\n\nexport function resetSessions(): void {\n sessionsStore.setState(() => initialState);\n}\n"],"mappings":";;;;;;AAuCA,MAAa,yBAAyB;AAEtC,MAAM,eAA8B;CAClC,OAAO,CAAC;CACR,MAAM,CAAC;CACP,UAAU;CACV,kBAAkB;CAClB,UAAU;CACV,gBAAgB;AAClB;AAEA,MAAa,gBAAgB,IAAIA,gBAAAA,MAAqB,YAAY;CAClEC,GAAAA,uBAAAA,wBAAAA,EAAyB,cAAc,cAAc,MAAM,KAAK,UAAU,EAAE,QAAQ,WAAW;AAE/F,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,UAAU,OAA4C;CAC7D,IAAI,CAAC,SAAS,KAAK,KAAK,OAAO,MAAM,OAAO,YAAY,MAAM,OAAO,IAAI,OAAO,KAAA;CAChF,OAAO;AACT;;;;;;;;;AAUA,SAAgB,gBAAgB,MAAmC,IAAgC;CACjG,MAAM,SAAS,KAAK,GAAG,EAAE,QAAQ;CACjC,IACE,WAAW,KAAA,KACX,WAAW,MACX,KAAK,YAAY,KAAA,KACjB,KAAK,OAAO,CAAC,QAAQ,gBAAgB,KAAK,GAAG,CAAC,QAAQ,aAEtD,OAAO,KAAA;CACT,IAAI,OAAO;CACX,MAAM,QAAQ,OAAO,KAAK,IAAI,CAAC,CAAC;CAChC,KAAK,IAAI,KAAyB,QAAQ,OAAO,KAAA,GAAW,KAAK,KAAK,GAAG,EAAE,QAAQ,iBAAiB;E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yB;GACvC,aAAa,KAAK;GAClB,aAAa,YAAY;GACzB,QAAQ,KAAK;EACf;EACA,MAAM,eAAe,cAAc,gBAAgB;GACjD,IAAI,aAAa,cAAc,MAAM,MAAM,OAAO,IAAI;EACxD,CAAC;EACD,MAAM,QAAQ,iBAAiB,OAAO,KAAK,GAAG,SAAS;CACzD,CAAC;AACH;;AAGA,SAAgB,uBAA2C;CACzD,QAAA,GAAOC,sBAAAA,SAAAA,CAAS,gBAAgB,UAAW,MAAM,aAAa,OAAQ,MAAM,KAAK,MAAM,aAAa,OAAQ,IAAK;AACnH;;;;;;;;;;AAWA,SAAgB,WAAW,OAA+B;CACxD,OAAO,MAAM,YAAY,MAAM,MAAM,WAAW;AAClD;AAEA,SAAgB,gBAAyB;CACvC,QAAA,GAAOA,sBAAAA,SAAAA,CAAS,eAAe,UAAU;AAC3C;AAEA,SAAgB,iBAAiB,WAA0B,aAA4B,WAAiB;CACtG,cAAc,UAAU,UACtB,MAAM,aAAa,cAAc,MAAM,cAAc,MAAM,cAAc,aACrE,QACA;EAAE,GAAG;EAAO,UAAU;EAAW;CAAW,CAClD;AACF;AAEA,SAAgB,qBAAqB,WAAyB;CAC5D,cAAc,UAAU,UACtB,MAAM,qBAAqB,YAAY,QAAQ;EAAE,GAAG;EAAO,kBAAkB;CAAU,CACzF;AACF;AAEA,SAAgB,wBAAwB,WAAyB;CAC/D,cAAc,UAAU,UACtB,MAAM,qBAAqB,YAAY;EAAE,GAAG;EAAO,kBAAkB;CAAK,IAAI,KAChF;AACF;AAEA,SAAgB,kBAAiC;CAC/C,OAAO,cAAc,MAAM;AAC7B;AAEA,SAAgB,gBAAsB;CACpC,cAAc,eAAe,YAAY;AAC3C"}
1
+ {"version":3,"file":"sessionsStore.cjs","names":["Store","bindSessionApiWorkspace","WORKFLOW_STEP_SESSION_PROVENANCE","WORKFLOW_DISPATCHER_SESSION_PROVENANCE","VOICE_ORCHESTRATOR_SESSION_PROVENANCE","useStore"],"sources":["../../../src/web/stores/sessionsStore.ts"],"sourcesContent":["import {\n VOICE_ORCHESTRATOR_SESSION_PROVENANCE,\n WORKFLOW_DISPATCHER_SESSION_PROVENANCE,\n WORKFLOW_STEP_SESSION_PROVENANCE,\n} from '@agimon-ai/po-core/hubChannel';\nimport { bindSessionApiWorkspace } from '@agimon-ai/po-core/web';\nimport { useStore } from '@tanstack/react-store';\nimport { Store } from '@tanstack/store';\n\nimport type { SessionSummary } from '../../types/hub';\nimport type { AttachPhase } from '../lib/sessionSummary';\n\n/** One rail entry: the hub's summary plus this page's view of its connection. */\nexport interface SessionMeta {\n summary: SessionSummary;\n /** summary.attach adjusted for sticky refusals and a lost page socket. */\n attach: AttachPhase;\n reason: string;\n /** Frames replayed into this page's timeline on the last subscribe. */\n replayed: number;\n /** Frames the hub's bounded ring lost before this page subscribed. */\n dropped: number;\n}\n\nexport interface SessionsState {\n /** Session ids in rail order: each parent immediately followed by its children. */\n order: string[];\n byId: Record<string, SessionMeta>;\n activeId: string | null;\n /** URL/tab ownership stays with the parent when a tab focuses another session. */\n tabOwnerId?: string | null;\n /** Destination shown while an autonomous voice handoff changes route and media ownership. */\n transferringToId: string | null;\n /** False until the first snapshot; routing waits for it before redirecting. */\n hydrated: boolean;\n /** The server needs newer client code. Only a reload clears it. */\n updateRequired: boolean;\n}\n\n/** The one reason every session shows once the server needs newer client code. */\nexport const UPDATE_REQUIRED_REASON = 'This app is older than the Po server. Update Po to reconnect.';\n\nconst initialState: SessionsState = {\n order: [],\n byId: {},\n activeId: null,\n transferringToId: null,\n hydrated: false,\n updateRequired: false,\n};\n\nexport const sessionsStore = new Store<SessionsState>(initialState);\nbindSessionApiWorkspace((sessionId) => sessionsStore.state.byId[sessionId]?.summary.workspaceId);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction asSummary(value: unknown): SessionSummary | undefined {\n if (!isRecord(value) || typeof value.id !== 'string' || value.id === '') return undefined;\n return value as unknown as SessionSummary;\n}\n\n/**\n * The parent this session nests under, or undefined when it renders at the top\n * level.\n *\n * A parent that has since closed, this session itself, a parent in another\n * workspace, or a cycle all resolve to undefined. The only safe failure is to\n * render the row where it can still be seen rather than to hide or duplicate it.\n */\nexport function resolveParentId(byId: Record<string, SessionMeta>, id: string): string | undefined {\n const parent = byId[id]?.summary.parentSessionId;\n if (\n parent === undefined ||\n parent === id ||\n byId[parent] === undefined ||\n byId[parent].summary.workspaceId !== byId[id].summary.workspaceId\n )\n return undefined;\n let hops = 0;\n const limit = Object.keys(byId).length;\n for (let at: string | undefined = parent; at !== undefined; at = byId[at]?.summary.parentSessionId) {\n if (at === id) return undefined;\n if (++hops > limit) return undefined;\n }\n return parent;\n}\n\n/** Internal sessions keep their history but take no rail row or keyboard ordinal. */\nfunction railHidden(meta: SessionMeta): boolean {\n const provenance = meta.summary.sessionProvenance;\n return (\n provenance === WORKFLOW_STEP_SESSION_PROVENANCE ||\n provenance === WORKFLOW_DISPATCHER_SESSION_PROVENANCE ||\n provenance === VOICE_ORCHESTRATOR_SESSION_PROVENANCE\n );\n}\n\n/**\n * Where a session sits in the rail: under its nearest ancestor the rail shows.\n *\n * A fork or worktree a step session opens is a real session, and under a\n * parent the rail leaves out it would never be listed, so it moves up to the\n * first ancestor that is, or becomes a root.\n */\nfunction railParentId(byId: Record<string, SessionMeta>, id: string): string | undefined {\n let parent = resolveParentId(byId, id);\n let hops = 0;\n const limit = Object.keys(byId).length;\n while (parent !== undefined && railHidden(byId[parent]) && hops++ <= limit) parent = resolveParentId(byId, parent);\n return parent;\n}\n\n/**\n * The rail's order: roots by creation, each immediately followed by its own\n * children.\n *\n * Ordinal shortcuts index this array positionally, which is why a child sits\n * directly after its parent instead of in a separate group: a worktree spawned\n * from the focused session lands on the next digit. With no lineage present\n * every session is a root and this produces exactly the flat creation sort it\n * replaces.\n */\nfunction sortedOrder(byId: Record<string, SessionMeta>): string[] {\n // A workflow step's session is read inside its workflow, never from the rail, so it\n // takes no row and no ordinal. It stays in `byId` for that view to follow. A\n // workflow dispatcher is a short-lived helper whose runs belong to its parent.\n const byCreation = (left: string, right: string): number => {\n const a = byId[left].summary;\n const b = byId[right].summary;\n return a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id);\n };\n const children = new Map<string, string[]>();\n const roots: string[] = [];\n for (const id of Object.keys(byId)) {\n if (railHidden(byId[id])) continue;\n const parent = railParentId(byId, id);\n if (parent === undefined) {\n roots.push(id);\n continue;\n }\n const siblings = children.get(parent);\n if (siblings === undefined) children.set(parent, [id]);\n else siblings.push(id);\n }\n roots.sort(byCreation);\n for (const siblings of children.values()) siblings.sort(byCreation);\n const order: string[] = [];\n const visit = (id: string): void => {\n order.push(id);\n for (const child of children.get(id) ?? []) visit(child);\n };\n for (const root of roots) visit(root);\n return order;\n}\n\nfunction mergeSummary(\n previous: SessionMeta | undefined,\n summary: SessionSummary,\n updateRequired: boolean,\n): SessionMeta {\n // HTTP still lists sessions after the socket stopped for good; none of them is reachable from here.\n if (updateRequired)\n return {\n summary,\n attach: 'offline',\n reason: UPDATE_REQUIRED_REASON,\n replayed: previous?.replayed ?? 0,\n dropped: previous?.dropped ?? 0,\n };\n // A refusal is sticky: the hub keeps retrying underneath, and reporting each\n // attempt would flicker the card between \"refused\" and \"connecting\" while\n // nothing has actually changed. Only a successful attach clears it.\n const sticky = previous?.attach === 'refused' && summary.attach === 'connecting';\n return {\n summary,\n attach: sticky ? 'refused' : summary.attach,\n reason: sticky ? previous.reason : (summary.attachReason ?? ''),\n replayed: previous?.replayed ?? 0,\n dropped: previous?.dropped ?? 0,\n };\n}\n\nexport function applySessionsSnapshot(frame: Record<string, unknown>): void {\n if (!Array.isArray(frame.sessions)) return;\n const summaries = frame.sessions.map(asSummary).filter((summary): summary is SessionSummary => Boolean(summary));\n sessionsStore.setState((state) => {\n const byId: Record<string, SessionMeta> = {};\n for (const summary of summaries)\n byId[summary.id] = mergeSummary(state.byId[summary.id], summary, state.updateRequired);\n return { ...state, byId, order: sortedOrder(byId), hydrated: true };\n });\n}\n\nexport function applySessionUpsert(frame: Record<string, unknown>): void {\n const summary = asSummary(frame.session);\n if (!summary) return;\n sessionsStore.setState((state) => {\n const byId = {\n ...state.byId,\n [summary.id]: mergeSummary(state.byId[summary.id], summary, state.updateRequired),\n };\n return { ...state, byId, order: sortedOrder(byId) };\n });\n}\n\nexport function applySessionRemoved(frame: Record<string, unknown>): void {\n const sessionId = frame.sessionId;\n if (typeof sessionId !== 'string') return;\n sessionsStore.setState((state) => {\n if (!(sessionId in state.byId)) return state;\n const byId = { ...state.byId };\n delete byId[sessionId];\n return { ...state, byId, order: sortedOrder(byId) };\n });\n}\n\n/** Records what the hub replayed into this page when a subscription started. */\nexport function applySessionBacklog(sessionId: string, replayed: number, dropped: number): void {\n sessionsStore.setState((state) => {\n const meta = state.byId[sessionId];\n if (!meta) return state;\n return { ...state, byId: { ...state.byId, [sessionId]: { ...meta, replayed, dropped } } };\n });\n}\n\n/**\n * The page socket died; every session is unreachable until it comes back.\n * Self-healing: the snapshot on reconnect restores the real states.\n */\nexport function markSocketClosed(): void {\n sessionsStore.setState((state) => {\n const byId: Record<string, SessionMeta> = {};\n for (const [id, meta] of Object.entries(state.byId)) {\n byId[id] = {\n ...meta,\n attach: 'offline',\n reason: state.updateRequired ? UPDATE_REQUIRED_REASON : 'The cockpit lost its bridge.',\n };\n }\n return { ...state, byId };\n });\n}\n\n/**\n * The server needs newer client code; every session is unreachable until the\n * page reloads with it. Unlike a closed socket nothing here heals on its own,\n * so later session lists keep the same state and reason.\n */\nexport function markUpdateRequired(): void {\n sessionsStore.setState((state) => {\n const byId: Record<string, SessionMeta> = {};\n for (const [id, meta] of Object.entries(state.byId)) {\n byId[id] = { ...meta, attach: 'offline', reason: UPDATE_REQUIRED_REASON };\n }\n return { ...state, byId, updateRequired: true };\n });\n}\n\nconst APPEAR_TIMEOUT_MS = 15_000;\n\n/**\n * Resolves once the session shows up in the rail, or false on timeout.\n *\n * A freshly created session exists on disk before its upsert reaches this\n * page; navigating to it too early trips the unknown-session fallback and\n * bounces the user back. Waiting here is what makes \"create, then land on it\"\n * one motion.\n */\nexport function waitForSession(sessionId: string, timeoutMs = APPEAR_TIMEOUT_MS): Promise<boolean> {\n if (sessionId in sessionsStore.state.byId) return Promise.resolve(true);\n return new Promise((resolve) => {\n const finish = (found: boolean): void => {\n clearTimeout(timer);\n subscription.unsubscribe();\n resolve(found);\n };\n const subscription = sessionsStore.subscribe(() => {\n if (sessionId in sessionsStore.state.byId) finish(true);\n });\n const timer = setTimeout(() => finish(false), timeoutMs);\n });\n}\n\n/** Reads the focused session's rail entry, or null while nothing is focused. */\nexport function useActiveSessionMeta(): SessionMeta | null {\n return useStore(sessionsStore, (state) => (state.activeId !== null ? (state.byId[state.activeId] ?? null) : null));\n}\n\n/**\n * True once the hub has answered and reported no sessions at all.\n *\n * Several surfaces stand down on this, so the rule is named once rather than\n * spelled out at each of them. The hydration half is what keeps it honest: an\n * empty order before the first snapshot only means the hub has not answered\n * yet, and treating that as \"no sessions\" would flash an onboarding screen at\n * someone who has ten.\n */\nexport function noSessions(state: SessionsState): boolean {\n return state.hydrated && state.order.length === 0;\n}\n\nexport function useNoSessions(): boolean {\n return useStore(sessionsStore, noSessions);\n}\n\nexport function setActiveSession(sessionId: string | null, tabOwnerId: string | null = sessionId): void {\n sessionsStore.setState((state) =>\n state.activeId === sessionId && (state.tabOwnerId ?? state.activeId) === tabOwnerId\n ? state\n : { ...state, activeId: sessionId, tabOwnerId },\n );\n}\n\nexport function beginSessionTransfer(sessionId: string): void {\n sessionsStore.setState((state) =>\n state.transferringToId === sessionId ? state : { ...state, transferringToId: sessionId },\n );\n}\n\nexport function completeSessionTransfer(sessionId: string): void {\n sessionsStore.setState((state) =>\n state.transferringToId === sessionId ? { ...state, transferringToId: null } : state,\n );\n}\n\nexport function activeSessionId(): string | null {\n return sessionsStore.state.activeId;\n}\n\nexport function resetSessions(): void {\n sessionsStore.setState(() => initialState);\n}\n"],"mappings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BAaxB,WAAW,OAAO;wBAIlB;wBAIA,iBAAiB,0BAA0B;wBAQ3C,qBAAqB;wBAMrB,wBAAwB;wBAMxB;wBAIA"}
1
+ {"version":3,"file":"sessionsStore.d.mts","names":[],"sources":["../../../src/web/stores/sessionsStore.ts"],"mappings":";;;;;iBAaiB;EACf,SAAS;;EAET,QAAQ;EACR;;EAEA;;EAEA;;iBAGe;;EAEf;EACA,MAAM,eAAe;EACrB;;EAEA;;EAEA;;EAEA;;EAEA;;;qBAIW;qBAWA,eAAa,MAAA;;;;;;;;;wBAoBV,gBAAgB,MAAM,eAAe,cAAc;wBAiHnD,sBAAsB,OAAO;wBAW7B,mBAAmB,OAAO;wBAY1B,oBAAoB,OAAO;;wBAY3B,oBAAoB,mBAAmB,kBAAkB;;;;;wBAYzD;;;;;;wBAmBA;;;;;;;;;wBAoBA,eAAe,mBAAmB,qBAAgC;;wBAgBlE,wBAAwB;;;;;;;;;;wBAaxB,WAAW,OAAO;wBAIlB;wBAIA,iBAAiB,0BAA0B;wBAQ3C,qBAAqB;wBAMrB,wBAAwB;wBAMxB;wBAIA"}
@@ -1,6 +1,6 @@
1
1
  import { bindSessionApiWorkspace } from "@agimon-ai/po-core/web";
2
2
  import { Store } from "@tanstack/store";
3
- import { WORKFLOW_DISPATCHER_SESSION_PROVENANCE, WORKFLOW_STEP_SESSION_PROVENANCE } from "@agimon-ai/po-core/hubChannel";
3
+ import { VOICE_ORCHESTRATOR_SESSION_PROVENANCE, WORKFLOW_DISPATCHER_SESSION_PROVENANCE, WORKFLOW_STEP_SESSION_PROVENANCE } from "@agimon-ai/po-core/hubChannel";
4
4
  import { useStore } from "@tanstack/react-store";
5
5
  //#region src/web/stores/sessionsStore.ts
6
6
  /** The one reason every session shows once the server needs newer client code. */
@@ -41,10 +41,10 @@ function resolveParentId(byId, id) {
41
41
  }
42
42
  return parent;
43
43
  }
44
- /** A session read somewhere other than the rail: a workflow step's, or a workflow dispatcher's. */
44
+ /** Internal sessions keep their history but take no rail row or keyboard ordinal. */
45
45
  function railHidden(meta) {
46
46
  const provenance = meta.summary.sessionProvenance;
47
- return provenance === WORKFLOW_STEP_SESSION_PROVENANCE || provenance === WORKFLOW_DISPATCHER_SESSION_PROVENANCE;
47
+ return provenance === WORKFLOW_STEP_SESSION_PROVENANCE || provenance === WORKFLOW_DISPATCHER_SESSION_PROVENANCE || provenance === VOICE_ORCHESTRATOR_SESSION_PROVENANCE;
48
48
  }
49
49
  /**
50
50
  * Where a session sits in the rail: under its nearest ancestor the rail shows.
@@ -1 +1 @@
1
- {"version":3,"file":"sessionsStore.mjs","names":[],"sources":["../../../src/web/stores/sessionsStore.ts"],"sourcesContent":["import {\n WORKFLOW_DISPATCHER_SESSION_PROVENANCE,\n WORKFLOW_STEP_SESSION_PROVENANCE,\n} from '@agimon-ai/po-core/hubChannel';\nimport { bindSessionApiWorkspace } from '@agimon-ai/po-core/web';\nimport { useStore } from '@tanstack/react-store';\nimport { Store } from '@tanstack/store';\n\nimport type { SessionSummary } from '../../types/hub';\nimport type { AttachPhase } from '../lib/sessionSummary';\n\n/** One rail entry: the hub's summary plus this page's view of its connection. */\nexport interface SessionMeta {\n summary: SessionSummary;\n /** summary.attach adjusted for sticky refusals and a lost page socket. */\n attach: AttachPhase;\n reason: string;\n /** Frames replayed into this page's timeline on the last subscribe. */\n replayed: number;\n /** Frames the hub's bounded ring lost before this page subscribed. */\n dropped: number;\n}\n\nexport interface SessionsState {\n /** Session ids in rail order: each parent immediately followed by its children. */\n order: string[];\n byId: Record<string, SessionMeta>;\n activeId: string | null;\n /** URL/tab ownership stays with the parent when a tab focuses another session. */\n tabOwnerId?: string | null;\n /** Destination shown while an autonomous voice handoff changes route and media ownership. */\n transferringToId: string | null;\n /** False until the first snapshot; routing waits for it before redirecting. */\n hydrated: boolean;\n /** The server needs newer client code. Only a reload clears it. */\n updateRequired: boolean;\n}\n\n/** The one reason every session shows once the server needs newer client code. */\nexport const UPDATE_REQUIRED_REASON = 'This app is older than the Po server. Update Po to reconnect.';\n\nconst initialState: SessionsState = {\n order: [],\n byId: {},\n activeId: null,\n transferringToId: null,\n hydrated: false,\n updateRequired: false,\n};\n\nexport const sessionsStore = new Store<SessionsState>(initialState);\nbindSessionApiWorkspace((sessionId) => sessionsStore.state.byId[sessionId]?.summary.workspaceId);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction asSummary(value: unknown): SessionSummary | undefined {\n if (!isRecord(value) || typeof value.id !== 'string' || value.id === '') return undefined;\n return value as unknown as SessionSummary;\n}\n\n/**\n * The parent this session nests under, or undefined when it renders at the top\n * level.\n *\n * A parent that has since closed, this session itself, a parent in another\n * workspace, or a cycle all resolve to undefined. The only safe failure is to\n * render the row where it can still be seen rather than to hide or duplicate it.\n */\nexport function resolveParentId(byId: Record<string, SessionMeta>, id: string): string | undefined {\n const parent = byId[id]?.summary.parentSessionId;\n if (\n parent === undefined ||\n parent === id ||\n byId[parent] === undefined ||\n byId[parent].summary.workspaceId !== byId[id].summary.workspaceId\n )\n return undefined;\n let hops = 0;\n const limit = Object.keys(byId).length;\n for (let at: string | undefined = parent; at !== undefined; at = byId[at]?.summary.parentSessionId) {\n if (at === id) return undefined;\n if (++hops > limit) return undefined;\n }\n return parent;\n}\n\n/** A session read somewhere other than the rail: a workflow step's, or a workflow dispatcher's. */\nfunction railHidden(meta: SessionMeta): boolean {\n const provenance = meta.summary.sessionProvenance;\n return provenance === WORKFLOW_STEP_SESSION_PROVENANCE || provenance === WORKFLOW_DISPATCHER_SESSION_PROVENANCE;\n}\n\n/**\n * Where a session sits in the rail: under its nearest ancestor the rail shows.\n *\n * A fork or worktree a step session opens is a real session, and under a\n * parent the rail leaves out it would never be listed, so it moves up to the\n * first ancestor that is, or becomes a root.\n */\nfunction railParentId(byId: Record<string, SessionMeta>, id: string): string | undefined {\n let parent = resolveParentId(byId, id);\n let hops = 0;\n const limit = Object.keys(byId).length;\n while (parent !== undefined && railHidden(byId[parent]) && hops++ <= limit) parent = resolveParentId(byId, parent);\n return parent;\n}\n\n/**\n * The rail's order: roots by creation, each immediately followed by its own\n * children.\n *\n * Ordinal shortcuts index this array positionally, which is why a child sits\n * directly after its parent instead of in a separate group: a worktree spawned\n * from the focused session lands on the next digit. With no lineage present\n * every session is a root and this produces exactly the flat creation sort it\n * replaces.\n */\nfunction sortedOrder(byId: Record<string, SessionMeta>): string[] {\n // A workflow step's session is read inside its workflow, never from the rail, so it\n // takes no row and no ordinal. It stays in `byId` for that view to follow. A\n // workflow dispatcher is a short-lived helper whose runs belong to its parent.\n const byCreation = (left: string, right: string): number => {\n const a = byId[left].summary;\n const b = byId[right].summary;\n return a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id);\n };\n const children = new Map<string, string[]>();\n const roots: string[] = [];\n for (const id of Object.keys(byId)) {\n if (railHidden(byId[id])) continue;\n const parent = railParentId(byId, id);\n if (parent === undefined) {\n roots.push(id);\n continue;\n }\n const siblings = children.get(parent);\n if (siblings === undefined) children.set(parent, [id]);\n else siblings.push(id);\n }\n roots.sort(byCreation);\n for (const siblings of children.values()) siblings.sort(byCreation);\n const order: string[] = [];\n const visit = (id: string): void => {\n order.push(id);\n for (const child of children.get(id) ?? []) visit(child);\n };\n for (const root of roots) visit(root);\n return order;\n}\n\nfunction mergeSummary(\n previous: SessionMeta | undefined,\n summary: SessionSummary,\n updateRequired: boolean,\n): SessionMeta {\n // HTTP still lists sessions after the socket stopped for good; none of them is reachable from here.\n if (updateRequired)\n return {\n summary,\n attach: 'offline',\n reason: UPDATE_REQUIRED_REASON,\n replayed: previous?.replayed ?? 0,\n dropped: previous?.dropped ?? 0,\n };\n // A refusal is sticky: the hub keeps retrying underneath, and reporting each\n // attempt would flicker the card between \"refused\" and \"connecting\" while\n // nothing has actually changed. Only a successful attach clears it.\n const sticky = previous?.attach === 'refused' && summary.attach === 'connecting';\n return {\n summary,\n attach: sticky ? 'refused' : summary.attach,\n reason: sticky ? previous.reason : (summary.attachReason ?? ''),\n replayed: previous?.replayed ?? 0,\n dropped: previous?.dropped ?? 0,\n };\n}\n\nexport function applySessionsSnapshot(frame: Record<string, unknown>): void {\n if (!Array.isArray(frame.sessions)) return;\n const summaries = frame.sessions.map(asSummary).filter((summary): summary is SessionSummary => Boolean(summary));\n sessionsStore.setState((state) => {\n const byId: Record<string, SessionMeta> = {};\n for (const summary of summaries)\n byId[summary.id] = mergeSummary(state.byId[summary.id], summary, state.updateRequired);\n return { ...state, byId, order: sortedOrder(byId), hydrated: true };\n });\n}\n\nexport function applySessionUpsert(frame: Record<string, unknown>): void {\n const summary = asSummary(frame.session);\n if (!summary) return;\n sessionsStore.setState((state) => {\n const byId = {\n ...state.byId,\n [summary.id]: mergeSummary(state.byId[summary.id], summary, state.updateRequired),\n };\n return { ...state, byId, order: sortedOrder(byId) };\n });\n}\n\nexport function applySessionRemoved(frame: Record<string, unknown>): void {\n const sessionId = frame.sessionId;\n if (typeof sessionId !== 'string') return;\n sessionsStore.setState((state) => {\n if (!(sessionId in state.byId)) return state;\n const byId = { ...state.byId };\n delete byId[sessionId];\n return { ...state, byId, order: sortedOrder(byId) };\n });\n}\n\n/** Records what the hub replayed into this page when a subscription started. */\nexport function applySessionBacklog(sessionId: string, replayed: number, dropped: number): void {\n sessionsStore.setState((state) => {\n const meta = state.byId[sessionId];\n if (!meta) return state;\n return { ...state, byId: { ...state.byId, [sessionId]: { ...meta, replayed, dropped } } };\n });\n}\n\n/**\n * The page socket died; every session is unreachable until it comes back.\n * Self-healing: the snapshot on reconnect restores the real states.\n */\nexport function markSocketClosed(): void {\n sessionsStore.setState((state) => {\n const byId: Record<string, SessionMeta> = {};\n for (const [id, meta] of Object.entries(state.byId)) {\n byId[id] = {\n ...meta,\n attach: 'offline',\n reason: state.updateRequired ? UPDATE_REQUIRED_REASON : 'The cockpit lost its bridge.',\n };\n }\n return { ...state, byId };\n });\n}\n\n/**\n * The server needs newer client code; every session is unreachable until the\n * page reloads with it. Unlike a closed socket nothing here heals on its own,\n * so later session lists keep the same state and reason.\n */\nexport function markUpdateRequired(): void {\n sessionsStore.setState((state) => {\n const byId: Record<string, SessionMeta> = {};\n for (const [id, meta] of Object.entries(state.byId)) {\n byId[id] = { ...meta, attach: 'offline', reason: UPDATE_REQUIRED_REASON };\n }\n return { ...state, byId, updateRequired: true };\n });\n}\n\nconst APPEAR_TIMEOUT_MS = 15_000;\n\n/**\n * Resolves once the session shows up in the rail, or false on timeout.\n *\n * A freshly created session exists on disk before its upsert reaches this\n * page; navigating to it too early trips the unknown-session fallback and\n * bounces the user back. Waiting here is what makes \"create, then land on it\"\n * one motion.\n */\nexport function waitForSession(sessionId: string, timeoutMs = APPEAR_TIMEOUT_MS): Promise<boolean> {\n if (sessionId in sessionsStore.state.byId) return Promise.resolve(true);\n return new Promise((resolve) => {\n const finish = (found: boolean): void => {\n clearTimeout(timer);\n subscription.unsubscribe();\n resolve(found);\n };\n const subscription = sessionsStore.subscribe(() => {\n if (sessionId in sessionsStore.state.byId) finish(true);\n });\n const timer = setTimeout(() => finish(false), timeoutMs);\n });\n}\n\n/** Reads the focused session's rail entry, or null while nothing is focused. */\nexport function useActiveSessionMeta(): SessionMeta | null {\n return useStore(sessionsStore, (state) => (state.activeId !== null ? (state.byId[state.activeId] ?? null) : null));\n}\n\n/**\n * True once the hub has answered and reported no sessions at all.\n *\n * Several surfaces stand down on this, so the rule is named once rather than\n * spelled out at each of them. The hydration half is what keeps it honest: an\n * empty order before the first snapshot only means the hub has not answered\n * yet, and treating that as \"no sessions\" would flash an onboarding screen at\n * someone who has ten.\n */\nexport function noSessions(state: SessionsState): boolean {\n return state.hydrated && state.order.length === 0;\n}\n\nexport function useNoSessions(): boolean {\n return useStore(sessionsStore, noSessions);\n}\n\nexport function setActiveSession(sessionId: string | null, tabOwnerId: string | null = sessionId): void {\n sessionsStore.setState((state) =>\n state.activeId === sessionId && (state.tabOwnerId ?? state.activeId) === tabOwnerId\n ? state\n : { ...state, activeId: sessionId, tabOwnerId },\n );\n}\n\nexport function beginSessionTransfer(sessionId: string): void {\n sessionsStore.setState((state) =>\n state.transferringToId === sessionId ? state : { ...state, transferringToId: sessionId },\n );\n}\n\nexport function completeSessionTransfer(sessionId: string): void {\n sessionsStore.setState((state) =>\n state.transferringToId === sessionId ? { ...state, transferringToId: null } : state,\n );\n}\n\nexport function activeSessionId(): string | null {\n return sessionsStore.state.activeId;\n}\n\nexport function resetSessions(): void {\n sessionsStore.setState(() => initialState);\n}\n"],"mappings":";;;;;;AAuCA,MAAa,yBAAyB;AAEtC,MAAM,eAA8B;CAClC,OAAO,CAAC;CACR,MAAM,CAAC;CACP,UAAU;CACV,kBAAkB;CAClB,UAAU;CACV,gBAAgB;AAClB;AAEA,MAAa,gBAAgB,IAAI,MAAqB,YAAY;AAClE,yBAAyB,cAAc,cAAc,MAAM,KAAK,UAAU,EAAE,QAAQ,WAAW;AAE/F,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,UAAU,OAA4C;CAC7D,IAAI,CAAC,SAAS,KAAK,KAAK,OAAO,MAAM,OAAO,YAAY,MAAM,OAAO,IAAI,OAAO,KAAA;CAChF,OAAO;AACT;;;;;;;;;AAUA,SAAgB,gBAAgB,MAAmC,IAAgC;CACjG,MAAM,SAAS,KAAK,GAAG,EAAE,QAAQ;CACjC,IACE,WAAW,KAAA,KACX,WAAW,MACX,KAAK,YAAY,KAAA,KACjB,KAAK,OAAO,CAAC,QAAQ,gBAAgB,KAAK,GAAG,CAAC,QAAQ,aAEtD,OAAO,KAAA;CACT,IAAI,OAAO;CACX,MAAM,QAAQ,OAAO,KAAK,IAAI,CAAC,CAAC;CAChC,KAAK,IAAI,KAAyB,QAAQ,OAAO,KAAA,GAAW,KAAK,KAAK,GAAG,EAAE,QAAQ,iBAAiB;EAClG,IAAI,OAAO,IAAI,OAAO,KAAA;EACtB,IAAI,EAAE,OAAO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Ae,cAAc,gBAAgB;GACjD,IAAI,aAAa,cAAc,MAAM,MAAM,OAAO,IAAI;EACxD,CAAC;EACD,MAAM,QAAQ,iBAAiB,OAAO,KAAK,GAAG,SAAS;CACzD,CAAC;AACH;;AAGA,SAAgB,uBAA2C;CACzD,OAAO,SAAS,gBAAgB,UAAW,MAAM,aAAa,OAAQ,MAAM,KAAK,MAAM,aAAa,OAAQ,IAAK;AACnH;;;;;;;;;;AAWA,SAAgB,WAAW,OAA+B;CACxD,OAAO,MAAM,YAAY,MAAM,MAAM,WAAW;AAClD;AAEA,SAAgB,gBAAyB;CACvC,OAAO,SAAS,eAAe,UAAU;AAC3C;AAEA,SAAgB,iBAAiB,WAA0B,aAA4B,WAAiB;CACtG,cAAc,UAAU,UACtB,MAAM,aAAa,cAAc,MAAM,cAAc,MAAM,cAAc,aACrE,QACA;EAAE,GAAG;EAAO,UAAU;EAAW;CAAW,CAClD;AACF;AAEA,SAAgB,qBAAqB,WAAyB;CAC5D,cAAc,UAAU,UACtB,MAAM,qBAAqB,YAAY,QAAQ;EAAE,GAAG;EAAO,kBAAkB;CAAU,CACzF;AACF;AAEA,SAAgB,wBAAwB,WAAyB;CAC/D,cAAc,UAAU,UACtB,MAAM,qBAAqB,YAAY;EAAE,GAAG;EAAO,kBAAkB;CAAK,IAAI,KAChF;AACF;AAEA,SAAgB,kBAAiC;CAC/C,OAAO,cAAc,MAAM;AAC7B;AAEA,SAAgB,gBAAsB;CACpC,cAAc,eAAe,YAAY;AAC3C"}
1
+ {"version":3,"file":"sessionsStore.mjs","names":[],"sources":["../../../src/web/stores/sessionsStore.ts"],"sourcesContent":["import {\n VOICE_ORCHESTRATOR_SESSION_PROVENANCE,\n WORKFLOW_DISPATCHER_SESSION_PROVENANCE,\n WORKFLOW_STEP_SESSION_PROVENANCE,\n} from '@agimon-ai/po-core/hubChannel';\nimport { bindSessionApiWorkspace } from '@agimon-ai/po-core/web';\nimport { useStore } from '@tanstack/react-store';\nimport { Store } from '@tanstack/store';\n\nimport type { SessionSummary } from '../../types/hub';\nimport type { AttachPhase } from '../lib/sessionSummary';\n\n/** One rail entry: the hub's summary plus this page's view of its connection. */\nexport interface SessionMeta {\n summary: SessionSummary;\n /** summary.attach adjusted for sticky refusals and a lost page socket. */\n attach: AttachPhase;\n reason: string;\n /** Frames replayed into this page's timeline on the last subscribe. */\n replayed: number;\n /** Frames the hub's bounded ring lost before this page subscribed. */\n dropped: number;\n}\n\nexport interface SessionsState {\n /** Session ids in rail order: each parent immediately followed by its children. */\n order: string[];\n byId: Record<string, SessionMeta>;\n activeId: string | null;\n /** URL/tab ownership stays with the parent when a tab focuses another session. */\n tabOwnerId?: string | null;\n /** Destination shown while an autonomous voice handoff changes route and media ownership. */\n transferringToId: string | null;\n /** False until the first snapshot; routing waits for it before redirecting. */\n hydrated: boolean;\n /** The server needs newer client code. Only a reload clears it. */\n updateRequired: boolean;\n}\n\n/** The one reason every session shows once the server needs newer client code. */\nexport const UPDATE_REQUIRED_REASON = 'This app is older than the Po server. Update Po to reconnect.';\n\nconst initialState: SessionsState = {\n order: [],\n byId: {},\n activeId: null,\n transferringToId: null,\n hydrated: false,\n updateRequired: false,\n};\n\nexport const sessionsStore = new Store<SessionsState>(initialState);\nbindSessionApiWorkspace((sessionId) => sessionsStore.state.byId[sessionId]?.summary.workspaceId);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction asSummary(value: unknown): SessionSummary | undefined {\n if (!isRecord(value) || typeof value.id !== 'string' || value.id === '') return undefined;\n return value as unknown as SessionSummary;\n}\n\n/**\n * The parent this session nests under, or undefined when it renders at the top\n * level.\n *\n * A parent that has since closed, this session itself, a parent in another\n * workspace, or a cycle all resolve to undefined. The only safe failure is to\n * render the row where it can still be seen rather than to hide or duplicate it.\n */\nexport function resolveParentId(byId: Record<string, SessionMeta>, id: string): string | undefined {\n const parent = byId[id]?.summary.parentSessionId;\n if (\n parent === undefined ||\n parent === id ||\n byId[parent] === undefined ||\n byId[parent].summary.workspaceId !== byId[id].summary.workspaceId\n )\n return undefined;\n let hops = 0;\n const limit = Object.keys(byId).length;\n for (let at: string | undefined = parent; at !== undefined; at = byId[at]?.summary.parentSessionId) {\n if (at === id) return undefined;\n if (++hops > limit) return undefined;\n }\n return parent;\n}\n\n/** Internal sessions keep their history but take no rail row or keyboard ordinal. */\nfunction railHidden(meta: SessionMeta): boolean {\n const provenance = meta.summary.sessionProvenance;\n return (\n provenance === WORKFLOW_STEP_SESSION_PROVENANCE ||\n provenance === WORKFLOW_DISPATCHER_SESSION_PROVENANCE ||\n provenance === VOICE_ORCHESTRATOR_SESSION_PROVENANCE\n );\n}\n\n/**\n * Where a session sits in the rail: under its nearest ancestor the rail shows.\n *\n * A fork or worktree a step session opens is a real session, and under a\n * parent the rail leaves out it would never be listed, so it moves up to the\n * first ancestor that is, or becomes a root.\n */\nfunction railParentId(byId: Record<string, SessionMeta>, id: string): string | undefined {\n let parent = resolveParentId(byId, id);\n let hops = 0;\n const limit = Object.keys(byId).length;\n while (parent !== undefined && railHidden(byId[parent]) && hops++ <= limit) parent = resolveParentId(byId, parent);\n return parent;\n}\n\n/**\n * The rail's order: roots by creation, each immediately followed by its own\n * children.\n *\n * Ordinal shortcuts index this array positionally, which is why a child sits\n * directly after its parent instead of in a separate group: a worktree spawned\n * from the focused session lands on the next digit. With no lineage present\n * every session is a root and this produces exactly the flat creation sort it\n * replaces.\n */\nfunction sortedOrder(byId: Record<string, SessionMeta>): string[] {\n // A workflow step's session is read inside its workflow, never from the rail, so it\n // takes no row and no ordinal. It stays in `byId` for that view to follow. A\n // workflow dispatcher is a short-lived helper whose runs belong to its parent.\n const byCreation = (left: string, right: string): number => {\n const a = byId[left].summary;\n const b = byId[right].summary;\n return a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id);\n };\n const children = new Map<string, string[]>();\n const roots: string[] = [];\n for (const id of Object.keys(byId)) {\n if (railHidden(byId[id])) continue;\n const parent = railParentId(byId, id);\n if (parent === undefined) {\n roots.push(id);\n continue;\n }\n const siblings = children.get(parent);\n if (siblings === undefined) children.set(parent, [id]);\n else siblings.push(id);\n }\n roots.sort(byCreation);\n for (const siblings of children.values()) siblings.sort(byCreation);\n const order: string[] = [];\n const visit = (id: string): void => {\n order.push(id);\n for (const child of children.get(id) ?? []) visit(child);\n };\n for (const root of roots) visit(root);\n return order;\n}\n\nfunction mergeSummary(\n previous: SessionMeta | undefined,\n summary: SessionSummary,\n updateRequired: boolean,\n): SessionMeta {\n // HTTP still lists sessions after the socket stopped for good; none of them is reachable from here.\n if (updateRequired)\n return {\n summary,\n attach: 'offline',\n reason: UPDATE_REQUIRED_REASON,\n replayed: previous?.replayed ?? 0,\n dropped: previous?.dropped ?? 0,\n };\n // A refusal is sticky: the hub keeps retrying underneath, and reporting each\n // attempt would flicker the card between \"refused\" and \"connecting\" while\n // nothing has actually changed. Only a successful attach clears it.\n const sticky = previous?.attach === 'refused' && summary.attach === 'connecting';\n return {\n summary,\n attach: sticky ? 'refused' : summary.attach,\n reason: sticky ? previous.reason : (summary.attachReason ?? ''),\n replayed: previous?.replayed ?? 0,\n dropped: previous?.dropped ?? 0,\n };\n}\n\nexport function applySessionsSnapshot(frame: Record<string, unknown>): void {\n if (!Array.isArray(frame.sessions)) return;\n const summaries = frame.sessions.map(asSummary).filter((summary): summary is SessionSummary => Boolean(summary));\n sessionsStore.setState((state) => {\n const byId: Record<string, SessionMeta> = {};\n for (const summary of summaries)\n byId[summary.id] = mergeSummary(state.byId[summary.id], summary, state.updateRequired);\n return { ...state, byId, order: sortedOrder(byId), hydrated: true };\n });\n}\n\nexport function applySessionUpsert(frame: Record<string, unknown>): void {\n const summary = asSummary(frame.session);\n if (!summary) return;\n sessionsStore.setState((state) => {\n const byId = {\n ...state.byId,\n [summary.id]: mergeSummary(state.byId[summary.id], summary, state.updateRequired),\n };\n return { ...state, byId, order: sortedOrder(byId) };\n });\n}\n\nexport function applySessionRemoved(frame: Record<string, unknown>): void {\n const sessionId = frame.sessionId;\n if (typeof sessionId !== 'string') return;\n sessionsStore.setState((state) => {\n if (!(sessionId in state.byId)) return state;\n const byId = { ...state.byId };\n delete byId[sessionId];\n return { ...state, byId, order: sortedOrder(byId) };\n });\n}\n\n/** Records what the hub replayed into this page when a subscription started. */\nexport function applySessionBacklog(sessionId: string, replayed: number, dropped: number): void {\n sessionsStore.setState((state) => {\n const meta = state.byId[sessionId];\n if (!meta) return state;\n return { ...state, byId: { ...state.byId, [sessionId]: { ...meta, replayed, dropped } } };\n });\n}\n\n/**\n * The page socket died; every session is unreachable until it comes back.\n * Self-healing: the snapshot on reconnect restores the real states.\n */\nexport function markSocketClosed(): void {\n sessionsStore.setState((state) => {\n const byId: Record<string, SessionMeta> = {};\n for (const [id, meta] of Object.entries(state.byId)) {\n byId[id] = {\n ...meta,\n attach: 'offline',\n reason: state.updateRequired ? UPDATE_REQUIRED_REASON : 'The cockpit lost its bridge.',\n };\n }\n return { ...state, byId };\n });\n}\n\n/**\n * The server needs newer client code; every session is unreachable until the\n * page reloads with it. Unlike a closed socket nothing here heals on its own,\n * so later session lists keep the same state and reason.\n */\nexport function markUpdateRequired(): void {\n sessionsStore.setState((state) => {\n const byId: Record<string, SessionMeta> = {};\n for (const [id, meta] of Object.entries(state.byId)) {\n byId[id] = { ...meta, attach: 'offline', reason: UPDATE_REQUIRED_REASON };\n }\n return { ...state, byId, updateRequired: true };\n });\n}\n\nconst APPEAR_TIMEOUT_MS = 15_000;\n\n/**\n * Resolves once the session shows up in the rail, or false on timeout.\n *\n * A freshly created session exists on disk before its upsert reaches this\n * page; navigating to it too early trips the unknown-session fallback and\n * bounces the user back. Waiting here is what makes \"create, then land on it\"\n * one motion.\n */\nexport function waitForSession(sessionId: string, timeoutMs = APPEAR_TIMEOUT_MS): Promise<boolean> {\n if (sessionId in sessionsStore.state.byId) return Promise.resolve(true);\n return new Promise((resolve) => {\n const finish = (found: boolean): void => {\n clearTimeout(timer);\n subscription.unsubscribe();\n resolve(found);\n };\n const subscription = sessionsStore.subscribe(() => {\n if (sessionId in sessionsStore.state.byId) finish(true);\n });\n const timer = setTimeout(() => finish(false), timeoutMs);\n });\n}\n\n/** Reads the focused session's rail entry, or null while nothing is focused. */\nexport function useActiveSessionMeta(): SessionMeta | null {\n return useStore(sessionsStore, (state) => (state.activeId !== null ? (state.byId[state.activeId] ?? null) : null));\n}\n\n/**\n * True once the hub has answered and reported no sessions at all.\n *\n * Several surfaces stand down on this, so the rule is named once rather than\n * spelled out at each of them. The hydration half is what keeps it honest: an\n * empty order before the first snapshot only means the hub has not answered\n * yet, and treating that as \"no sessions\" would flash an onboarding screen at\n * someone who has ten.\n */\nexport function noSessions(state: SessionsState): boolean {\n return state.hydrated && state.order.length === 0;\n}\n\nexport function useNoSessions(): boolean {\n return useStore(sessionsStore, noSessions);\n}\n\nexport function setActiveSession(sessionId: string | null, tabOwnerId: string | null = sessionId): void {\n sessionsStore.setState((state) =>\n state.activeId === sessionId && (state.tabOwnerId ?? state.activeId) === tabOwnerId\n ? state\n : { ...state, activeId: sessionId, tabOwnerId },\n );\n}\n\nexport function beginSessionTransfer(sessionId: string): void {\n sessionsStore.setState((state) =>\n state.transferringToId === sessionId ? state : { ...state, transferringToId: sessionId },\n );\n}\n\nexport function completeSessionTransfer(sessionId: string): void {\n sessionsStore.setState((state) =>\n state.transferringToId === sessionId ? { ...state, transferringToId: null } : state,\n );\n}\n\nexport function activeSessionId(): string | null {\n return sessionsStore.state.activeId;\n}\n\nexport function resetSessions(): void {\n sessionsStore.setState(() => initialState);\n}\n"],"mappings":";;;;;;AAwCA,MAAa,yBAAyB;AAEtC,MAAM,eAA8B;CAClC,OAAO,CAAC;CACR,MAAM,CAAC;CACP,UAAU;CACV,kBAAkB;CAClB,UAAU;CACV,gBAAgB;AAClB;AAEA,MAAa,gBAAgB,IAAI,MAAqB,YAAY;AAClE,yBAAyB,cAAc,cAAc,MAAM,KAAK,UAAU,EAAE,QAAQ,WAAW;AA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UAAU;EAAW;CAAW,CAClD;AACF;AAEA,SAAgB,qBAAqB,WAAyB;CAC5D,cAAc,UAAU,UACtB,MAAM,qBAAqB,YAAY,QAAQ;EAAE,GAAG;EAAO,kBAAkB;CAAU,CACzF;AACF;AAEA,SAAgB,wBAAwB,WAAyB;CAC/D,cAAc,UAAU,UACtB,MAAM,qBAAqB,YAAY;EAAE,GAAG;EAAO,kBAAkB;CAAK,IAAI,KAChF;AACF;AAEA,SAAgB,kBAAiC;CAC/C,OAAO,cAAc,MAAM;AAC7B;AAEA,SAAgB,gBAAsB;CACpC,cAAc,eAAe,YAAY;AAC3C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-web-dashboard",
3
- "version": "0.0.0-alpha.32",
3
+ "version": "0.0.0-alpha.34",
4
4
  "description": "Shared browser state, actions and optional views for Po dashboard templates.",
5
5
  "keywords": [
6
6
  "ai",
@@ -61,9 +61,9 @@
61
61
  "access": "public"
62
62
  },
63
63
  "dependencies": {
64
- "@agimon-ai/po-core": "0.0.0-alpha.32",
65
- "@agimon-ai/po-web-components": "0.0.0-alpha.32",
66
- "@agimon-ai/po-web-security": "0.0.0-alpha.32",
64
+ "@agimon-ai/po-core": "0.0.0-alpha.34",
65
+ "@agimon-ai/po-web-components": "0.0.0-alpha.34",
66
+ "@agimon-ai/po-web-security": "0.0.0-alpha.34",
67
67
  "@earendil-works/chord": "1.3.0",
68
68
  "@simplewebauthn/browser": "^14.0.0",
69
69
  "@tanstack/react-router": "1.170.44",
@@ -73,7 +73,7 @@
73
73
  "qrcode-generator": "^2.0.4"
74
74
  },
75
75
  "devDependencies": {
76
- "@agimon-ai/vibe-lint-plugin-po-web": "0.0.0-alpha.32",
76
+ "@agimon-ai/vibe-lint-plugin-po-web": "0.0.0-alpha.34",
77
77
  "@types/node": "26.6.5",
78
78
  "@types/react": "19.3.0",
79
79
  "@types/react-dom": "19.3.0",