@opengeni/react 1.0.1 → 2.3.0-canary.0

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.
Files changed (174) hide show
  1. package/README.md +33 -10
  2. package/dist/artifacts-spreadsheet.js +1 -1
  3. package/dist/artifacts.js +1 -1
  4. package/dist/browser-viewer-GXUICIAG.js +14 -0
  5. package/dist/{chunk-R3AZOAB5.js → chunk-4MDLEHXL.js} +9 -115
  6. package/dist/chunk-4MDLEHXL.js.map +1 -0
  7. package/dist/chunk-5YK2ZDIG.js +116 -0
  8. package/dist/chunk-5YK2ZDIG.js.map +1 -0
  9. package/dist/chunk-H5YGYNXS.js +329 -0
  10. package/dist/chunk-H5YGYNXS.js.map +1 -0
  11. package/dist/{chunk-7WCLAEFV.js → chunk-ICA6R6TW.js} +2 -2
  12. package/dist/{chunk-7WCLAEFV.js.map → chunk-ICA6R6TW.js.map} +1 -1
  13. package/dist/{chunk-IGC6A2ZI.js → chunk-JOAVA2TW.js} +589 -217
  14. package/dist/chunk-JOAVA2TW.js.map +1 -0
  15. package/dist/{chunk-Y7OEDUJ5.js → chunk-LS4POUTY.js} +1057 -426
  16. package/dist/chunk-LS4POUTY.js.map +1 -0
  17. package/dist/{chunk-5UQPNLIO.js → chunk-LTCHJ4MS.js} +9 -9
  18. package/dist/chunk-LTCHJ4MS.js.map +1 -0
  19. package/dist/{chunk-C5ZPSSS5.js → chunk-NEXLLTP4.js} +2 -1
  20. package/dist/{chunk-C5ZPSSS5.js.map → chunk-NEXLLTP4.js.map} +1 -1
  21. package/dist/chunk-QGBJ6GHG.js +2300 -0
  22. package/dist/chunk-QGBJ6GHG.js.map +1 -0
  23. package/dist/{chunk-6KLX2RH5.js → chunk-RSXJN73N.js} +365 -21
  24. package/dist/chunk-RSXJN73N.js.map +1 -0
  25. package/dist/{chunk-B6WPZSTT.js → chunk-SE4W4WQ3.js} +78 -16
  26. package/dist/chunk-SE4W4WQ3.js.map +1 -0
  27. package/dist/{chunk-MKPIAGVL.js → chunk-W6NFJXSA.js} +8 -19
  28. package/dist/chunk-W6NFJXSA.js.map +1 -0
  29. package/dist/{chunk-XBZWOM2K.js → chunk-X4A66EWZ.js} +8 -3
  30. package/dist/chunk-X4A66EWZ.js.map +1 -0
  31. package/dist/chunk-X4JAFD5R.js +3907 -0
  32. package/dist/chunk-X4JAFD5R.js.map +1 -0
  33. package/dist/{chunk-HA46CYQK.js → chunk-XXWH2JLC.js} +792 -206
  34. package/dist/chunk-XXWH2JLC.js.map +1 -0
  35. package/dist/client.d.ts +2 -2
  36. package/dist/components/browser-viewer.d.ts +7 -1
  37. package/dist/components/computer-viewer.d.ts +4 -1
  38. package/dist/components/enrollment-consent.d.ts +6 -3
  39. package/dist/components/file-browser.d.ts +7 -1
  40. package/dist/components/human-input-form.d.ts +1 -1
  41. package/dist/components/human-input-surface.d.ts +1 -1
  42. package/dist/components/machine-card.d.ts +4 -1
  43. package/dist/components/machines/machine-detail.d.ts +4 -1
  44. package/dist/components/machines/machine-operation-policy.d.ts +11 -0
  45. package/dist/components/machines-dashboard.d.ts +3 -1
  46. package/dist/components/markdown.d.ts +20 -1
  47. package/dist/components/message-timeline.d.ts +1 -1
  48. package/dist/components/model-policy-picker.d.ts +2 -0
  49. package/dist/components/pierre-file.d.ts +1 -1
  50. package/dist/components/sandbox-files.d.ts +8 -2
  51. package/dist/components/sandbox-workspace.d.ts +33 -3
  52. package/dist/components/session-chrome.d.ts +15 -3
  53. package/dist/components/workspace-dock.d.ts +6 -2
  54. package/dist/composer.js +5 -5
  55. package/dist/computer-viewer-ZOP4Q7A7.js +16 -0
  56. package/dist/computer-viewer-ZOP4Q7A7.js.map +1 -0
  57. package/dist/hooks/channel-cache.d.ts +23 -0
  58. package/dist/hooks/shared-machines-list.d.ts +14 -0
  59. package/dist/hooks/use-attached-browsers.d.ts +2 -1
  60. package/dist/hooks/use-channels.d.ts +1 -0
  61. package/dist/hooks/use-composer.d.ts +37 -9
  62. package/dist/hooks/use-machine-chip.d.ts +3 -3
  63. package/dist/hooks/use-machines.d.ts +19 -1
  64. package/dist/hooks/use-sandbox-files.d.ts +1 -0
  65. package/dist/hooks/use-session-background-commands.d.ts +14 -0
  66. package/dist/hooks/use-turn-queue.d.ts +12 -0
  67. package/dist/hooks/use-workspace-sessions.d.ts +1 -0
  68. package/dist/index.d.ts +7 -5
  69. package/dist/index.js +1096 -623
  70. package/dist/index.js.map +1 -1
  71. package/dist/interaction.js +29 -181
  72. package/dist/interaction.js.map +1 -1
  73. package/dist/lib/interaction-errors.d.ts +3 -0
  74. package/dist/machines.d.ts +4 -2
  75. package/dist/machines.js +10 -2
  76. package/dist/model-policy.d.ts +1 -1
  77. package/dist/model-policy.js +1 -1
  78. package/dist/platform-activity-row-BJHUHXAT.js +169 -0
  79. package/dist/platform-activity-row-BJHUHXAT.js.map +1 -0
  80. package/dist/{queue-surface-implementation-2KVJTYXH.js → queue-surface-implementation-BSKUWHRI.js} +76 -16
  81. package/dist/queue-surface-implementation-BSKUWHRI.js.map +1 -0
  82. package/dist/realtime/realtime-control.d.ts +6 -3
  83. package/dist/realtime.js +36 -14
  84. package/dist/realtime.js.map +1 -1
  85. package/dist/session-ui.d.ts +1 -1
  86. package/dist/session-ui.js +6 -2
  87. package/dist/session.d.ts +2 -2
  88. package/dist/session.js +4 -4
  89. package/dist/timeline/index.d.ts +1 -1
  90. package/dist/timeline/platform-activity-row.d.ts +15 -0
  91. package/dist/timeline/screenshot-lightbox.d.ts +1 -1
  92. package/dist/timeline/shared.d.ts +4 -2
  93. package/dist/timeline/types.d.ts +50 -5
  94. package/dist/types/machines.d.ts +2 -2
  95. package/package.json +3 -3
  96. package/src/client.ts +12 -1
  97. package/src/components/artifacts/editable-spreadsheet.tsx +1 -1
  98. package/src/components/browser-viewer.tsx +361 -58
  99. package/src/components/chat-composer.tsx +1 -1
  100. package/src/components/composer.tsx +6 -6
  101. package/src/components/computer-viewer.tsx +368 -115
  102. package/src/components/enrollment-consent.tsx +64 -6
  103. package/src/components/file-browser.tsx +117 -2
  104. package/src/components/human-input-form.tsx +103 -59
  105. package/src/components/human-input-surface.tsx +1 -1
  106. package/src/components/machine-card.tsx +111 -0
  107. package/src/components/machine-input-display.ts +15 -0
  108. package/src/components/machines/machine-detail.tsx +47 -0
  109. package/src/components/machines/machine-operation-policy.tsx +179 -0
  110. package/src/components/machines-dashboard.tsx +6 -0
  111. package/src/components/markdown.tsx +174 -20
  112. package/src/components/message-timeline.tsx +215 -18
  113. package/src/components/model-policy-picker.tsx +9 -17
  114. package/src/components/pierre-file.tsx +1 -1
  115. package/src/components/queue-surface-implementation.tsx +82 -16
  116. package/src/components/sandbox-files.tsx +135 -19
  117. package/src/components/sandbox-workspace.tsx +204 -92
  118. package/src/components/session-chrome.tsx +415 -208
  119. package/src/components/session-status.tsx +1 -1
  120. package/src/components/user-message-body.tsx +168 -48
  121. package/src/components/workspace-dock.tsx +141 -175
  122. package/src/hooks/channel-cache.ts +104 -0
  123. package/src/hooks/shared-machines-list.ts +239 -0
  124. package/src/hooks/use-attached-browsers.ts +5 -1
  125. package/src/hooks/use-browser-frame-stream.ts +6 -1
  126. package/src/hooks/use-browser-session.ts +6 -4
  127. package/src/hooks/use-browser-sessions.ts +7 -1
  128. package/src/hooks/use-channels.ts +32 -10
  129. package/src/hooks/use-composer.ts +760 -291
  130. package/src/hooks/use-computer-frame-stream.ts +14 -9
  131. package/src/hooks/use-computer-session.ts +16 -14
  132. package/src/hooks/use-computer-sessions.ts +8 -1
  133. package/src/hooks/use-last-started-turn-policy.ts +1 -1
  134. package/src/hooks/use-machine-chip.ts +23 -6
  135. package/src/hooks/use-machines.ts +104 -6
  136. package/src/hooks/use-sandbox-files.ts +195 -140
  137. package/src/hooks/use-sandbox-git.ts +58 -29
  138. package/src/hooks/use-session-background-commands.ts +56 -0
  139. package/src/hooks/use-session-capabilities.ts +18 -0
  140. package/src/hooks/use-turn-queue.ts +111 -12
  141. package/src/hooks/use-workspace-sessions.ts +5 -1
  142. package/src/index.ts +26 -4
  143. package/src/lib/interaction-errors.ts +18 -0
  144. package/src/machines.ts +9 -1
  145. package/src/model-policy.ts +10 -2
  146. package/src/realtime/realtime-control.tsx +53 -17
  147. package/src/session-context.ts +1 -0
  148. package/src/session-ui.ts +6 -1
  149. package/src/session.ts +9 -1
  150. package/src/timeline/activity-rail.tsx +20 -75
  151. package/src/timeline/index.ts +4 -0
  152. package/src/timeline/platform-activity-row.tsx +201 -0
  153. package/src/timeline/projection.ts +529 -25
  154. package/src/timeline/screenshot-lightbox.tsx +48 -14
  155. package/src/timeline/shared.tsx +8 -2
  156. package/src/timeline/tool-renderers.tsx +104 -6
  157. package/src/timeline/turn-summary.tsx +6 -1
  158. package/src/timeline/types.ts +77 -2
  159. package/src/types/machines.ts +10 -0
  160. package/styles/compiled.css +115 -104
  161. package/dist/chunk-5UQPNLIO.js.map +0 -1
  162. package/dist/chunk-6KLX2RH5.js.map +0 -1
  163. package/dist/chunk-B6WPZSTT.js.map +0 -1
  164. package/dist/chunk-HA46CYQK.js.map +0 -1
  165. package/dist/chunk-IGC6A2ZI.js.map +0 -1
  166. package/dist/chunk-LLOLUHVG.js +0 -5937
  167. package/dist/chunk-LLOLUHVG.js.map +0 -1
  168. package/dist/chunk-MKPIAGVL.js.map +0 -1
  169. package/dist/chunk-R3AZOAB5.js.map +0 -1
  170. package/dist/chunk-XBZWOM2K.js.map +0 -1
  171. package/dist/chunk-Y7OEDUJ5.js.map +0 -1
  172. package/dist/interactive-workbench-viewers-TOHBXJEE.js +0 -15
  173. package/dist/queue-surface-implementation-2KVJTYXH.js.map +0 -1
  174. /package/dist/{interactive-workbench-viewers-TOHBXJEE.js.map → browser-viewer-GXUICIAG.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/use-composer.ts"],"sourcesContent":["import {\n DEFAULT_FILE_RESOURCE_MOUNT_ROOT,\n type ComposerDraft,\n type DraftTimelineAnnotation,\n type EffectiveControlResumeOption,\n type EffectiveSessionControl,\n type OpenGeniApiError,\n type ResourceRef,\n type SaveComposerDraftRequest,\n type SendMessageInput,\n type SessionEvent,\n} from \"@opengeni/sdk\";\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport { useEmbeddedSession, type EmbeddedSessionClientOverride } from \"../session-context\";\nimport { useSessionEventTrigger, type SessionEventFeedOptions } from \"./internal\";\n\nexport type ComposerSendExtras = Omit<SendMessageInput, \"text\" | \"clientEventId\" | \"annotations\">;\n\nexport type UseComposerOptions = EmbeddedSessionClientOverride &\n SessionEventFeedOptions & {\n /** Called synchronously after an ordinary Send is accepted by the local UI. */\n onSubmitted?: ((text: string, input: SendMessageInput) => void) | undefined;\n /** Called with the exact accepted wire input after a successful send. */\n onSent?: ((text: string, input: SendMessageInput) => void) | undefined;\n /**\n * Extra message fields (resources, tools, model, reasoningEffort, latencyMode) merged\n * into every send. A function is evaluated at send time so it can read the\n * surrounding UI state (attachment pickers, model selectors, ...).\n */\n sendExtras?: ComposerSendExtras | (() => ComposerSendExtras) | undefined;\n /**\n * Fail-closed delivery guard evaluated at send time. Attachment hosts use\n * this to preserve unresolved upload cards until the operator waits,\n * retries, or removes them; direct hook callers cannot bypass the UI gate.\n */\n sendBlocked?: (() => boolean) | undefined;\n /** Latest server-derived workstream control; bound into Send/Steer OCC. */\n effectiveControl?: EffectiveSessionControl | null | undefined;\n /** Apply durable model/tool/reasoning settings in the host's controlled UI. */\n onDraftApplied?: ((draft: ComposerDraft) => void) | undefined;\n /** Disable remote composer-draft reads and writes for embedded hosts. */\n draftPersistence?: \"durable\" | \"disabled\" | undefined;\n };\n\ntype ComposerDraftShadow = {\n text: string;\n resources: ResourceRef[];\n annotations: DraftTimelineAnnotation[];\n};\n\ntype PendingComposerOperation = {\n delivery: \"send\" | \"steer\";\n input: SendMessageInput;\n draftAtSend: string;\n resourcesAtSend: ResourceRef[];\n annotationsAtSend: DraftTimelineAnnotation[];\n /** Latest local text/resources that must survive an uncertain delivery. */\n newerShadow: ComposerDraftShadow;\n clearDraftOnAccept: boolean;\n /** False after remount when the original input carried secret credentials. */\n canRetry: boolean;\n};\n\ntype StoredPendingComposerOperation = Omit<PendingComposerOperation, \"input\" | \"canRetry\"> & {\n input: Omit<SendMessageInput, \"mcpCredentialUpdates\">;\n hasMcpCredentialUpdates: boolean;\n};\n\nexport type ComposerOptimisticMessage = {\n clientEventId: string;\n text: string;\n annotations: DraftTimelineAnnotation[];\n resources: ResourceRef[];\n occurredAt: string;\n state: \"sending\" | \"queued\" | \"failed\";\n error?: string | undefined;\n outcomeUnknown?: boolean | undefined;\n};\n\ntype OptimisticSendOperation = ComposerOptimisticMessage & {\n input: SendMessageInput;\n draftPayload: SaveComposerDraftRequest | null;\n /** Latest unsent local draft that must survive this operation and remounts. */\n newerShadow: ComposerDraftShadow;\n canRetry: boolean;\n};\n\ntype StoredOptimisticSendOperation = Omit<OptimisticSendOperation, \"input\" | \"canRetry\"> & {\n input: Omit<SendMessageInput, \"mcpCredentialUpdates\">;\n hasMcpCredentialUpdates: boolean;\n};\n\nconst PENDING_COMPOSER_STORAGE_PREFIX = \"opengeni.pending-composer.v1:\";\nconst OPTIMISTIC_SEND_STORAGE_PREFIX = \"opengeni.optimistic-sends.v1:\";\n\n// A remount must not manufacture a new operation while the previous mutation\n// is still outcome-unknown. Keep only non-credential request fields here; the\n// mounted hook retains the exact input, including any credential updates. The\n// safe shadow is also session-scoped so a refresh cannot lose newer edits.\nconst pendingComposerOperations = new Map<string, StoredPendingComposerOperation>();\nconst optimisticSendOperations = new Map<string, StoredOptimisticSendOperation[]>();\n\nfunction pendingComposerOperationKey(\n workspaceId: string,\n sessionId: string | null | undefined,\n): string | null {\n return sessionId ? `${workspaceId}\\u0000${sessionId}` : null;\n}\n\nfunction pendingComposerStorage(): Storage | null {\n try {\n return typeof window === \"undefined\" ? null : window.sessionStorage;\n } catch {\n return null;\n }\n}\n\nfunction pendingComposerStorageKey(key: string): string {\n return `${PENDING_COMPOSER_STORAGE_PREFIX}${encodeURIComponent(key)}`;\n}\n\nfunction optimisticSendStorageKey(key: string): string {\n return `${OPTIMISTIC_SEND_STORAGE_PREFIX}${encodeURIComponent(key)}`;\n}\n\nfunction restoreOptimisticSendOperations(key: string | null): OptimisticSendOperation[] {\n if (!key) return [];\n let stored = optimisticSendOperations.get(key);\n if (!stored) {\n const storage = pendingComposerStorage();\n try {\n const parsed: unknown = JSON.parse(storage?.getItem(optimisticSendStorageKey(key)) ?? \"[]\");\n stored = Array.isArray(parsed)\n ? (parsed.filter(\n (candidate): candidate is StoredOptimisticSendOperation =>\n typeof candidate === \"object\" &&\n candidate !== null &&\n typeof candidate.clientEventId === \"string\" &&\n typeof candidate.text === \"string\" &&\n typeof candidate.occurredAt === \"string\" &&\n (candidate.state === \"sending\" || candidate.state === \"failed\") &&\n typeof candidate.input === \"object\" &&\n candidate.input !== null &&\n typeof candidate.input.text === \"string\" &&\n typeof candidate.hasMcpCredentialUpdates === \"boolean\",\n ) as StoredOptimisticSendOperation[])\n : [];\n } catch {\n stored = [];\n }\n }\n return stored.map(({ hasMcpCredentialUpdates, ...operation }) => ({\n ...operation,\n newerShadow: operation.newerShadow ?? { text: \"\", resources: [], annotations: [] },\n state:\n operation.state === \"sending\" || operation.state === \"queued\" ? \"sending\" : operation.state,\n outcomeUnknown:\n operation.state === \"sending\" || operation.state === \"queued\"\n ? true\n : operation.outcomeUnknown,\n error:\n operation.state === \"sending\"\n ? \"Delivery was interrupted; retry to reconcile this message.\"\n : operation.error,\n input: operation.input,\n canRetry: !hasMcpCredentialUpdates,\n }));\n}\n\nfunction rememberOptimisticSendOperations(\n key: string | null,\n operations: OptimisticSendOperation[],\n): void {\n if (!key) return;\n const stored = operations\n .filter((operation) => operation.state !== \"queued\")\n .map((operation) => {\n const { canRetry: _canRetry, input, ...rest } = operation;\n const { mcpCredentialUpdates: _credentials, ...safeInput } = input;\n return {\n ...rest,\n input: safeInput,\n hasMcpCredentialUpdates: input.mcpCredentialUpdates !== undefined,\n } satisfies StoredOptimisticSendOperation;\n });\n optimisticSendOperations.set(key, stored);\n try {\n pendingComposerStorage()?.setItem(optimisticSendStorageKey(key), JSON.stringify(stored));\n } catch {\n // Best effort; the in-memory queue still owns this mount.\n }\n}\n\nfunction resourceList(value: unknown): value is ResourceRef[] {\n return (\n Array.isArray(value) &&\n value.every((candidate) => {\n if (typeof candidate !== \"object\" || candidate === null) return false;\n const resource = candidate as Record<string, unknown>;\n return resource.kind === \"file\"\n ? typeof resource.fileId === \"string\"\n : resource.kind === \"repository\" &&\n typeof resource.uri === \"string\" &&\n typeof resource.ref === \"string\";\n })\n );\n}\n\nfunction timelineAnnotationList(value: unknown): value is DraftTimelineAnnotation[] {\n return (\n Array.isArray(value) &&\n value.every((candidate) => {\n if (typeof candidate !== \"object\" || candidate === null) return false;\n const annotation = candidate as Record<string, unknown>;\n const source = annotation.source;\n if (typeof source !== \"object\" || source === null) return false;\n const sourceRecord = source as Record<string, unknown>;\n return (\n typeof annotation.id === \"string\" &&\n typeof annotation.quote === \"string\" &&\n typeof annotation.note === \"string\" &&\n typeof sourceRecord.eventId === \"string\" &&\n typeof sourceRecord.eventType === \"string\" &&\n typeof sourceRecord.sequence === \"number\" &&\n (typeof sourceRecord.turnId === \"string\" || sourceRecord.turnId === null) &&\n typeof sourceRecord.startOffset === \"number\" &&\n typeof sourceRecord.endOffset === \"number\" &&\n typeof sourceRecord.contextBefore === \"string\" &&\n typeof sourceRecord.contextAfter === \"string\"\n );\n })\n );\n}\n\nfunction cloneAnnotations(\n annotations: readonly DraftTimelineAnnotation[],\n): DraftTimelineAnnotation[] {\n return annotations.map((annotation) => ({\n ...annotation,\n source: { ...annotation.source },\n }));\n}\n\nfunction readStoredPendingComposerOperation(\n key: string | null,\n): StoredPendingComposerOperation | null {\n const storage = key ? pendingComposerStorage() : null;\n if (!storage || !key) return null;\n try {\n const parsed: unknown = JSON.parse(storage.getItem(pendingComposerStorageKey(key)) ?? \"null\");\n if (typeof parsed !== \"object\" || parsed === null) return null;\n const record = parsed as Record<string, unknown>;\n const input = record.input;\n const shadow = record.newerShadow;\n if (\n typeof input !== \"object\" ||\n input === null ||\n typeof shadow !== \"object\" ||\n shadow === null\n ) {\n return null;\n }\n const inputRecord = input as Record<string, unknown>;\n const shadowRecord = shadow as Record<string, unknown>;\n if (\n (record.delivery !== \"send\" && record.delivery !== \"steer\") ||\n typeof record.draftAtSend !== \"string\" ||\n !resourceList(record.resourcesAtSend) ||\n (record.annotationsAtSend !== undefined &&\n !timelineAnnotationList(record.annotationsAtSend)) ||\n typeof shadowRecord.text !== \"string\" ||\n !resourceList(shadowRecord.resources) ||\n (shadowRecord.annotations !== undefined &&\n !timelineAnnotationList(shadowRecord.annotations)) ||\n typeof record.clearDraftOnAccept !== \"boolean\" ||\n typeof record.hasMcpCredentialUpdates !== \"boolean\" ||\n typeof inputRecord.text !== \"string\" ||\n typeof inputRecord.clientEventId !== \"string\" ||\n \"mcpCredentialUpdates\" in inputRecord ||\n (\"resources\" in inputRecord && !resourceList(inputRecord.resources)) ||\n (\"annotations\" in inputRecord && !timelineAnnotationList(inputRecord.annotations))\n ) {\n return null;\n }\n return {\n ...(record as StoredPendingComposerOperation),\n annotationsAtSend: timelineAnnotationList(record.annotationsAtSend)\n ? record.annotationsAtSend\n : [],\n newerShadow: {\n ...(shadow as ComposerDraftShadow),\n annotations: timelineAnnotationList(shadowRecord.annotations)\n ? shadowRecord.annotations\n : [],\n },\n };\n } catch {\n return null;\n }\n}\n\nfunction writePendingComposerOperation(\n key: string,\n operation: StoredPendingComposerOperation,\n): void {\n const storage = pendingComposerStorage();\n if (!storage) return;\n try {\n storage.setItem(pendingComposerStorageKey(key), JSON.stringify(operation));\n } catch {\n // Storage is best effort; the in-memory record still protects remounts.\n }\n}\n\nfunction restorePendingComposerOperation(key: string | null): PendingComposerOperation | null {\n const stored =\n (key && pendingComposerOperations.get(key)) ?? readStoredPendingComposerOperation(key);\n if (!stored) return null;\n return {\n ...stored,\n input: stored.input,\n newerShadow: stored.newerShadow ?? {\n text: stored.draftAtSend,\n resources: stored.resourcesAtSend,\n annotations: stored.annotationsAtSend,\n },\n canRetry: !stored.hasMcpCredentialUpdates,\n };\n}\n\nfunction rememberPendingComposerOperation(\n key: string | null,\n operation: PendingComposerOperation,\n): void {\n if (!key) return;\n const { canRetry: _retry, ...safeOperation } = operation;\n const { input: originalInput, ...withoutInput } = safeOperation;\n const { mcpCredentialUpdates: _storedMcp, ...safeInput } = originalInput;\n const stored = {\n ...withoutInput,\n input: safeInput,\n hasMcpCredentialUpdates: operation.input.mcpCredentialUpdates !== undefined,\n newerShadow: {\n text: operation.newerShadow.text,\n resources: [...operation.newerShadow.resources],\n annotations: cloneAnnotations(operation.newerShadow.annotations),\n },\n } satisfies StoredPendingComposerOperation;\n pendingComposerOperations.set(key, stored);\n writePendingComposerOperation(key, stored);\n}\n\nfunction forgetPendingComposerOperation(key: string | null): void {\n if (!key) return;\n pendingComposerOperations.delete(key);\n const storage = pendingComposerStorage();\n if (!storage) return;\n try {\n storage.removeItem(pendingComposerStorageKey(key));\n } catch {\n // Ignore a blocked storage implementation; delivery has already settled.\n }\n}\n\nfunction updatePendingComposerShadow(\n key: string | null,\n operation: PendingComposerOperation | null,\n shadow: ComposerDraftShadow,\n): PendingComposerOperation | null {\n if (!key || !operation) return operation;\n const next = {\n ...operation,\n newerShadow: {\n ...shadow,\n resources: [...shadow.resources],\n annotations: cloneAnnotations(shadow.annotations),\n },\n };\n rememberPendingComposerOperation(key, next);\n return next;\n}\n\nexport type ComposerState = {\n value: string;\n setValue: (value: string) => void;\n annotations?: DraftTimelineAnnotation[] | undefined;\n addAnnotation?: ((annotation: DraftTimelineAnnotation) => void) | undefined;\n updateAnnotation?: ((id: string, note: string) => void) | undefined;\n removeAnnotation?: ((id: string) => void) | undefined;\n /** Newly captured annotation the review surface should focus. */\n annotationReviewTargetId?: string | null | undefined;\n clearAnnotationReviewTarget?: (() => void) | undefined;\n /** Read the current draft synchronously before a destructive replacement. */\n hasDraftContent: () => boolean;\n /** Append the draft behind prompts already visible in the queue. */\n send: (text?: string) => Promise<boolean>;\n /** Locally acknowledged ordinary sends awaiting durable timeline reconciliation. */\n optimisticMessages?: ComposerOptimisticMessage[] | undefined;\n retryOptimisticMessage?: ((clientEventId: string) => void) | undefined;\n removeOptimisticMessage?: ((clientEventId: string) => void) | undefined;\n /** Supersede current direction with the draft. */\n steer: (text?: string) => Promise<boolean>;\n /** Optimistic-to-durable projection for a Steer that has not started yet. */\n steering?: ComposerSteeringState | null | undefined;\n /** Immediate mutation-receipt projection while physical cancellation settles. */\n stoppingAttempt?: \"current\" | \"previous\" | null | undefined;\n sending: boolean;\n canSend: boolean;\n /** Pause the session without deleting its prompt queue. */\n pause: (reason?: string) => Promise<void>;\n pausing: boolean;\n resume: (reason?: string) => Promise<void>;\n resumeScope: (option: EffectiveControlResumeOption) => Promise<void>;\n resuming: boolean;\n draft: ComposerDraft | null;\n draftRevision: number;\n draftLoading: boolean;\n draftSaving: boolean;\n draftConflict: Error | null;\n /** Whether this controller owns a durable server-side draft. */\n draftPersistence?: \"durable\" | \"disabled\" | undefined;\n /** Apply an atomic queue Edit checkout without a second read. */\n applyDraft: (draft: ComposerDraft) => void;\n reloadDraft: () => Promise<void>;\n resolveDraftConflict: (choice: \"keep_mine\" | \"use_remote\") => Promise<void>;\n restoredResources: ResourceRef[];\n removeRestoredResource: (index: number) => void;\n error: Error | null;\n clearError: () => void;\n};\n\nexport type ComposerSteeringState = {\n phase: \"submitting\" | \"accepted\";\n text: string;\n clientEventId: string | null;\n triggerEventId: string | null;\n turnId: string | null;\n /** True only when the accepted Steer durably interrupted a live attempt. */\n stoppingPreviousAttempt?: boolean | undefined;\n};\n\ntype ComposerControlStoppingState = {\n controlVersion: number;\n controlEtag: string;\n};\n\nconst STEERING_SETTLEMENT_EVENT_TYPES = new Set([\n \"turn.started\",\n \"turn.completed\",\n \"turn.failed\",\n \"turn.cancelled\",\n \"turn.superseded\",\n]);\n\nfunction isSteeringSettlementEvent(event: SessionEvent): boolean {\n return STEERING_SETTLEMENT_EVENT_TYPES.has(event.type);\n}\n\nfunction steeringAcceptedEvent(\n steering: ComposerSteeringState,\n events: readonly SessionEvent[],\n): SessionEvent | undefined {\n return events.find(\n (event) =>\n event.type === \"user.message\" &&\n steering.clientEventId !== null &&\n event.clientEventId === steering.clientEventId,\n );\n}\n\nfunction steeringSettledByEvents(\n steering: ComposerSteeringState,\n events: readonly SessionEvent[],\n): boolean {\n const acceptedEventId =\n steering.triggerEventId ?? steeringAcceptedEvent(steering, events)?.id ?? null;\n return events.some((event) => {\n if (steering.turnId && event.turnId === steering.turnId && isSteeringSettlementEvent(event)) {\n return true;\n }\n if (event.type !== \"turn.started\" || !acceptedEventId) return false;\n const payload = event.payload;\n return (\n typeof payload === \"object\" &&\n payload !== null &&\n \"triggerEventId\" in payload &&\n payload.triggerEventId === acceptedEventId\n );\n });\n}\n\n/**\n * Draft + send + Pause/Resume state for the chat composer — the only\n * human-to-agent input surface. The draft survives a failed send (nothing is\n * more hostile than losing a typed message); each send carries a generated\n * `clientEventId` so retries stay idempotent server-side.\n */\nexport function useComposer(\n sessionId: string | null | undefined,\n options: UseComposerOptions = {},\n): ComposerState {\n const { client, workspaceId, registerSessionReconciler } = useEmbeddedSession(options);\n const durableDrafts = options.draftPersistence !== \"disabled\";\n const targetKey = `${workspaceId}\\u0000${sessionId ?? \"\"}\\u0000${durableDrafts ? \"durable\" : \"disabled\"}`;\n const pendingOperationKey = pendingComposerOperationKey(workspaceId, sessionId);\n const initialPendingOperation = restorePendingComposerOperation(pendingOperationKey);\n const initialOptimisticSends = restoreOptimisticSendOperations(pendingOperationKey);\n const initialShadow =\n initialPendingOperation?.newerShadow ?? initialOptimisticSends.at(-1)?.newerShadow;\n const [value, setValue] = useState(() => initialShadow?.text ?? \"\");\n const [annotations, setAnnotations] = useState<DraftTimelineAnnotation[]>(\n () => initialShadow?.annotations ?? [],\n );\n const [annotationReviewTargetId, setAnnotationReviewTargetId] = useState<string | null>(null);\n // Keep rendered state behind the committed target identity for one frame:\n // a parent may switch sessionId without remounting this public hook.\n const [stateTargetKey, setStateTargetKey] = useState(targetKey);\n const [sending, setSending] = useState(false);\n const [optimisticSends, setOptimisticSends] =\n useState<OptimisticSendOperation[]>(initialOptimisticSends);\n const [steering, setSteering] = useState<ComposerSteeringState | null>(() =>\n initialPendingOperation?.delivery === \"steer\"\n ? {\n phase: \"submitting\",\n text: initialPendingOperation.input.text,\n clientEventId: initialPendingOperation.input.clientEventId ?? null,\n triggerEventId: null,\n turnId: null,\n }\n : null,\n );\n const [pausing, setPausing] = useState(false);\n const [controlStopping, setControlStopping] = useState<ComposerControlStoppingState | null>(null);\n const [resuming, setResuming] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [draft, setDraft] = useState<ComposerDraft | null>(null);\n const [draftLoading, setDraftLoading] = useState(Boolean(sessionId) && durableDrafts);\n const [draftSaving, setDraftSaving] = useState(false);\n const [draftConflict, setDraftConflict] = useState<Error | null>(null);\n const [restoredResources, setRestoredResources] = useState<ResourceRef[]>(\n () => initialShadow?.resources ?? [],\n );\n const pendingOperationRef = useRef<PendingComposerOperation | null>(initialPendingOperation);\n const optimisticSendsRef = useRef<OptimisticSendOperation[]>(initialOptimisticSends);\n const optimisticProcessorBusyRef = useRef(false);\n const optimisticCallbackIdsRef = useRef(new Set<string>());\n const steeringSettlementEventsRef = useRef<SessionEvent[]>([]);\n const steeringRef = useRef(steering);\n const pendingClientEventId = useRef<string | null>(\n initialPendingOperation?.input.clientEventId ?? null,\n );\n const valueRef = useRef(initialShadow?.text ?? \"\");\n const annotationsRef = useRef<DraftTimelineAnnotation[]>(initialShadow?.annotations ?? []);\n const draftRef = useRef<ComposerDraft | null>(null);\n const restoredResourcesRef = useRef<ResourceRef[]>(initialShadow?.resources ?? []);\n const localEditRevision = useRef(initialShadow ? 1 : 0);\n const targetGeneration = useRef(0);\n const draftReadGeneration = useRef(0);\n const lastSavedSignature = useRef<string | null>(null);\n const saveChain = useRef<Promise<void>>(Promise.resolve());\n const onSent = options.onSent;\n const onSubmitted = options.onSubmitted;\n const onDraftApplied = options.onDraftApplied;\n // Read through a ref so live session/policy projections can replace their\n // apply callback without invalidating the draft loader and re-running its\n // initial-load effect. Publish only committed callbacks: a suspended target\n // render must not retarget an in-flight read owned by the committed session.\n const onDraftAppliedRef = useRef(onDraftApplied);\n useLayoutEffect(() => {\n onDraftAppliedRef.current = onDraftApplied;\n }, [onDraftApplied]);\n useLayoutEffect(() => {\n steeringRef.current = steering;\n }, [steering]);\n // Read through a ref so a new extras closure (created every render by\n // callers passing inline functions) does not invalidate `send`.\n const sendExtrasRef = useRef(options.sendExtras);\n sendExtrasRef.current = options.sendExtras;\n const sendBlockedRef = useRef(options.sendBlocked);\n sendBlockedRef.current = options.sendBlocked;\n const liveExtrasVersion = JSON.stringify(resolveSendExtras(options.sendExtras));\n\n // A composer is bound to one session: switching targets must not leak the\n // previous session's draft, error, or retry idempotency key.\n const targetKeyRef = useRef(targetKey);\n useLayoutEffect(() => {\n if (targetKeyRef.current === targetKey) return;\n targetKeyRef.current = targetKey;\n targetGeneration.current += 1;\n draftReadGeneration.current += 1;\n pendingOperationRef.current = restorePendingComposerOperation(pendingOperationKey);\n const restoredOptimisticSends = restoreOptimisticSendOperations(pendingOperationKey);\n optimisticSendsRef.current = restoredOptimisticSends;\n optimisticProcessorBusyRef.current = false;\n optimisticCallbackIdsRef.current = new Set();\n steeringSettlementEventsRef.current = [];\n pendingClientEventId.current = pendingOperationRef.current?.input.clientEventId ?? null;\n const shadow =\n pendingOperationRef.current?.newerShadow ?? restoredOptimisticSends.at(-1)?.newerShadow;\n localEditRevision.current = shadow ? 1 : 0;\n valueRef.current = shadow?.text ?? \"\";\n annotationsRef.current = shadow?.annotations ?? [];\n draftRef.current = null;\n restoredResourcesRef.current = shadow?.resources ?? [];\n lastSavedSignature.current = null;\n // Old saves may still be awaiting the network. Their generation fence\n // prevents settlement, and a fresh chain avoids blocking this target.\n saveChain.current = Promise.resolve();\n setStateTargetKey(targetKey);\n setValue(shadow?.text ?? \"\");\n setAnnotations(shadow?.annotations ?? []);\n setAnnotationReviewTargetId(null);\n setSending(false);\n setOptimisticSends(restoredOptimisticSends);\n setSteering(\n pendingOperationRef.current?.delivery === \"steer\"\n ? {\n phase: \"submitting\",\n text: pendingOperationRef.current.input.text,\n clientEventId: pendingOperationRef.current.input.clientEventId ?? null,\n triggerEventId: null,\n turnId: null,\n }\n : null,\n );\n setPausing(false);\n setControlStopping(null);\n setResuming(false);\n setError(null);\n setDraft(null);\n setDraftLoading(Boolean(sessionId) && durableDrafts);\n setDraftSaving(false);\n setDraftConflict(null);\n setRestoredResources(shadow?.resources ?? []);\n }, [durableDrafts, pendingOperationKey, sessionId, targetKey]);\n\n const setOptimisticDraftShadow = useCallback(\n (shadow: ComposerDraftShadow): void => {\n if (optimisticSendsRef.current.length === 0) return;\n const next = optimisticSendsRef.current.map((operation) => ({\n ...operation,\n newerShadow: {\n text: shadow.text,\n resources: [...shadow.resources],\n annotations: cloneAnnotations(shadow.annotations),\n },\n }));\n optimisticSendsRef.current = next;\n rememberOptimisticSendOperations(pendingOperationKey, next);\n setOptimisticSends(next);\n },\n [pendingOperationKey],\n );\n\n const applyDraft = useCallback(\n (next: ComposerDraft): void => {\n if (targetKeyRef.current !== targetKey) return;\n if (!durableDrafts) {\n localEditRevision.current += 1;\n valueRef.current = next.text;\n annotationsRef.current = next.annotations ?? [];\n restoredResourcesRef.current = next.resources;\n draftRef.current = null;\n lastSavedSignature.current = null;\n setDraft(null);\n setValue(next.text);\n setAnnotations(next.annotations ?? []);\n setRestoredResources(next.resources);\n pendingOperationRef.current = updatePendingComposerShadow(\n pendingOperationKey,\n pendingOperationRef.current,\n {\n text: next.text,\n resources: mergeResources(\n next.resources,\n resolveSendExtras(sendExtrasRef.current).resources ?? [],\n ),\n annotations: next.annotations ?? [],\n },\n );\n setOptimisticDraftShadow({\n text: next.text,\n resources: mergeResources(\n next.resources,\n resolveSendExtras(sendExtrasRef.current).resources ?? [],\n ),\n annotations: next.annotations ?? [],\n });\n setDraftConflict(null);\n return;\n }\n valueRef.current = next.text;\n annotationsRef.current = next.annotations ?? [];\n draftRef.current = next;\n restoredResourcesRef.current = next.resources;\n lastSavedSignature.current = draftSignature(draftPayload(next));\n localEditRevision.current += 1;\n setDraft(next);\n setValue(next.text);\n setAnnotations(next.annotations ?? []);\n setRestoredResources(next.resources);\n pendingOperationRef.current = updatePendingComposerShadow(\n pendingOperationKey,\n pendingOperationRef.current,\n {\n text: next.text,\n resources: mergeResources(\n next.resources,\n resolveSendExtras(sendExtrasRef.current).resources ?? [],\n ),\n annotations: next.annotations ?? [],\n },\n );\n setOptimisticDraftShadow({\n text: next.text,\n resources: mergeResources(\n next.resources,\n resolveSendExtras(sendExtrasRef.current).resources ?? [],\n ),\n annotations: next.annotations ?? [],\n });\n setDraftConflict(null);\n onDraftAppliedRef.current?.(next);\n },\n [durableDrafts, pendingOperationKey, setOptimisticDraftShadow, targetKey],\n );\n\n const loadDraft = useCallback(\n async (replaceLocal: boolean): Promise<void> => {\n if (targetKeyRef.current !== targetKey) return;\n if (!sessionId || !durableDrafts) {\n setDraftLoading(false);\n return;\n }\n const generation = targetGeneration.current;\n const readTicket = ++draftReadGeneration.current;\n const localAtStart = localEditRevision.current;\n const baseAtStart = draftRef.current;\n const extrasAtStart = resolveSendExtras(sendExtrasRef.current);\n const localSignatureAtStart = baseAtStart\n ? draftSignature(\n composerDraftPayload(\n baseAtStart,\n valueRef.current,\n restoredResourcesRef.current,\n annotationsRef.current,\n extrasAtStart,\n ),\n )\n : null;\n const localWasDirtyAtStart =\n localSignatureAtStart === null\n ? localAtStart !== 0\n : localSignatureAtStart !== lastSavedSignature.current;\n // Only blank the picker on first hydrate / hard reload. Reconcile and\n // event-triggered soft reloads (loadOlder SSE reconnect) must not flicker\n // draftLoading — stale-while-revalidate keeps the settled UI mounted.\n const showLoading = replaceLocal || draftRef.current === null;\n if (showLoading) {\n setDraftLoading(true);\n }\n try {\n const fetched = await client.getComposerDraft(workspaceId, sessionId);\n if (\n generation !== targetGeneration.current ||\n targetKeyRef.current !== targetKey ||\n readTicket !== draftReadGeneration.current\n ) {\n return;\n }\n const currentRevision = draftRef.current?.revision ?? -1;\n if (fetched.revision >= currentRevision) {\n draftRef.current = fetched;\n setDraft(fetched);\n setDraftConflict(null);\n const shadow =\n pendingOperationRef.current?.newerShadow ??\n optimisticSendsRef.current.at(-1)?.newerShadow;\n if (shadow) {\n // The server can only know the original operation. Never replace\n // newer local edits while that operation is still uncertain.\n valueRef.current = shadow.text;\n restoredResourcesRef.current = shadow.resources;\n annotationsRef.current = shadow.annotations;\n localEditRevision.current ||= 1;\n setValue(shadow.text);\n setRestoredResources(shadow.resources);\n setAnnotations(shadow.annotations);\n } else if (\n replaceLocal ||\n (!localWasDirtyAtStart && localAtStart === localEditRevision.current)\n ) {\n // Model/effort/latency ride in sendExtras (outside\n // localEditRevision). If\n // the picker changed during this fetch, skip onDraftApplied so a\n // stale server policy cannot undo the operator's pick.\n const extrasNow = resolveSendExtras(sendExtrasRef.current);\n const pickerChangedDuringFetch =\n extrasNow.model !== extrasAtStart.model ||\n extrasNow.reasoningEffort !== extrasAtStart.reasoningEffort ||\n extrasNow.latencyMode !== extrasAtStart.latencyMode;\n valueRef.current = fetched.text;\n restoredResourcesRef.current = fetched.resources;\n annotationsRef.current = fetched.annotations ?? [];\n lastSavedSignature.current = draftSignature(draftPayload(fetched));\n setValue(fetched.text);\n setRestoredResources(fetched.resources);\n setAnnotations(fetched.annotations ?? []);\n if (replaceLocal || !pickerChangedDuringFetch) {\n onDraftAppliedRef.current?.(fetched);\n }\n }\n }\n } catch (cause) {\n if (\n generation === targetGeneration.current &&\n targetKeyRef.current === targetKey &&\n readTicket === draftReadGeneration.current\n ) {\n setError(asError(cause));\n }\n } finally {\n if (\n generation === targetGeneration.current &&\n targetKeyRef.current === targetKey &&\n readTicket === draftReadGeneration.current\n ) {\n setDraftLoading(false);\n }\n }\n },\n [client, durableDrafts, sessionId, targetKey, workspaceId],\n );\n\n useEffect(() => {\n if (!sessionId || !durableDrafts) {\n setDraftLoading(false);\n return;\n }\n void loadDraft(false);\n }, [durableDrafts, loadDraft, sessionId]);\n // After long background / sleep the in-memory revision is often stale while\n // a prior autosave already advanced the server. Soft-reload on wake so the\n // next keystroke does not OCC against a dead revision.\n useEffect(() => {\n if (!sessionId || !durableDrafts) return;\n const onWake = () => {\n if (typeof document !== \"undefined\" && document.visibilityState === \"hidden\") return;\n void loadDraft(false);\n };\n document.addEventListener(\"visibilitychange\", onWake);\n window.addEventListener(\"pageshow\", onWake);\n return () => {\n document.removeEventListener(\"visibilitychange\", onWake);\n window.removeEventListener(\"pageshow\", onWake);\n };\n }, [durableDrafts, loadDraft, sessionId]);\n useEffect(() => {\n if (!sessionId || !durableDrafts) return;\n return registerSessionReconciler(sessionId, \"composer\", async () => await loadDraft(false));\n }, [durableDrafts, loadDraft, registerSessionReconciler, sessionId]);\n const reconcileSteering = useCallback(async (): Promise<void> => {\n if (!sessionId || !steeringRef.current) return;\n const ownedTargetKey = targetKey;\n let events: SessionEvent[];\n try {\n events = await client.listEvents(workspaceId, sessionId, {\n includeTypes: [\n \"user.message\",\n \"turn.started\",\n \"turn.completed\",\n \"turn.failed\",\n \"turn.cancelled\",\n \"turn.superseded\",\n ],\n limit: 250,\n payloadMode: \"full\",\n });\n } catch {\n // Best effort: the live stream still settles steering when its event arrives.\n return;\n }\n if (targetKeyRef.current !== ownedTargetKey) return;\n setSteering((current) => {\n if (!current) return current;\n if (steeringSettledByEvents(current, events)) {\n steeringSettlementEventsRef.current = [];\n return null;\n }\n const accepted = steeringAcceptedEvent(current, events);\n if (!accepted || current.triggerEventId) return current;\n return {\n ...current,\n phase: \"accepted\",\n triggerEventId: accepted.id,\n };\n });\n }, [client, sessionId, targetKey, workspaceId]);\n useSessionEventTrigger(\n client,\n workspaceId,\n sessionId,\n (event) => isComposerDraftEvent(event) || isSteeringSettlementEvent(event),\n (event) => {\n if (isComposerDraftEvent(event)) void loadDraft(false);\n if (!isSteeringSettlementEvent(event)) return;\n steeringSettlementEventsRef.current = [\n ...steeringSettlementEventsRef.current.slice(-15),\n event,\n ];\n setSteering((current) => {\n if (!current || !steeringSettledByEvents(current, [event])) return current;\n steeringSettlementEventsRef.current = [];\n return null;\n });\n },\n {\n enabled: Boolean(sessionId) && (durableDrafts || steering !== null),\n ...(options.events !== undefined ? { events: options.events } : {}),\n },\n reconcileSteering,\n );\n\n useEffect(() => {\n if (!steering) return;\n const observed = [...(options.events ?? []), ...steeringSettlementEventsRef.current];\n if (!steeringSettledByEvents(steering, observed)) return;\n steeringSettlementEventsRef.current = [];\n setSteering(null);\n }, [options.events, steering]);\n\n useEffect(() => {\n if (!controlStopping) return;\n const effectiveControl = options.effectiveControl;\n if (!effectiveControl || effectiveControl.controlVersion < controlStopping.controlVersion) {\n return;\n }\n if (\n effectiveControl.controlVersion === controlStopping.controlVersion &&\n effectiveControl.controlEtag === controlStopping.controlEtag &&\n effectiveControl.settlement !== null\n ) {\n return;\n }\n // A newer control revision, an impossible same-version/different-etag\n // projection, or quiescence at this exact revision supersedes the local\n // mutation receipt. SessionChrome then falls back to durable queue truth.\n setControlStopping((current) => (current === controlStopping ? null : current));\n }, [controlStopping, options.effectiveControl]);\n\n const currentDraftPayload = useCallback((): SaveComposerDraftRequest | null => {\n if (!durableDrafts || targetKeyRef.current !== targetKey) return null;\n const base = draftRef.current;\n if (!base) return null;\n const extras = resolveSendExtras(sendExtrasRef.current);\n return composerDraftPayload(base, value, restoredResources, annotations, extras);\n }, [annotations, durableDrafts, restoredResources, targetKey, value]);\n\n const persistPayload = useCallback(\n async (payload: SaveComposerDraftRequest): Promise<boolean> => {\n const ownedTargetKey = targetKey;\n const ownedGeneration = targetGeneration.current;\n if (!sessionId || !durableDrafts || targetKeyRef.current !== ownedTargetKey) {\n return false;\n }\n let success = false;\n const run = async () => {\n if (\n targetKeyRef.current !== ownedTargetKey ||\n targetGeneration.current !== ownedGeneration\n ) {\n return;\n }\n const current = draftRef.current;\n if (!current) return;\n const request = { ...payload, expectedRevision: current.revision };\n const signature = draftSignature(request);\n if (signature === lastSavedSignature.current) {\n success = true;\n return;\n }\n setDraftSaving(true);\n try {\n const saved = await saveComposerDraftWithStaleRetry({\n client,\n workspaceId,\n sessionId,\n request,\n onAdoptRemote: (remote) => {\n draftRef.current = remote;\n setDraft(remote);\n },\n });\n if (\n targetKeyRef.current !== ownedTargetKey ||\n targetGeneration.current !== ownedGeneration\n ) {\n return;\n }\n draftRef.current = saved;\n setDraft(saved);\n lastSavedSignature.current = draftSignature({\n ...request,\n expectedRevision: saved.revision,\n });\n setDraftConflict(null);\n setError(null);\n success = true;\n } catch (cause) {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n const problem = asError(cause);\n if (isDraftConflictError(problem)) setDraftConflict(problem);\n setError(problem);\n }\n } finally {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setDraftSaving(false);\n }\n }\n };\n saveChain.current = saveChain.current.then(run, run);\n await saveChain.current;\n return success;\n },\n [client, durableDrafts, sessionId, targetKey, workspaceId],\n );\n\n const replaceOptimisticSends = useCallback(\n (\n update: (current: OptimisticSendOperation[]) => OptimisticSendOperation[],\n ): OptimisticSendOperation[] => {\n const next = update(optimisticSendsRef.current);\n optimisticSendsRef.current = next;\n rememberOptimisticSendOperations(pendingOperationKey, next);\n setOptimisticSends(next);\n return next;\n },\n [pendingOperationKey],\n );\n\n const markOptimisticAccepted = useCallback(\n (operation: OptimisticSendOperation): void => {\n if (!optimisticCallbackIdsRef.current.has(operation.clientEventId)) {\n optimisticCallbackIdsRef.current.add(operation.clientEventId);\n onSent?.(operation.input.text, operation.input);\n }\n replaceOptimisticSends((current) =>\n current.filter((candidate) => candidate.clientEventId !== operation.clientEventId),\n );\n },\n [onSent, replaceOptimisticSends],\n );\n\n useEffect(() => {\n const acceptedIds = new Set(\n (options.events ?? [])\n .filter((event) => event.type === \"user.message\" && event.clientEventId)\n .map((event) => event.clientEventId as string),\n );\n if (acceptedIds.size === 0) return;\n const accepted = optimisticSendsRef.current.filter((operation) =>\n acceptedIds.has(operation.clientEventId),\n );\n for (const operation of accepted) markOptimisticAccepted(operation);\n }, [markOptimisticAccepted, options.events]);\n\n const processOptimisticSends = useCallback((): void => {\n if (!sessionId || optimisticProcessorBusyRef.current) return;\n const currentOperations = optimisticSendsRef.current;\n const operationIndex = currentOperations.findIndex(\n (candidate) => candidate.state === \"sending\",\n );\n const operation = operationIndex < 0 ? undefined : currentOperations[operationIndex];\n if (!operation) return;\n const ownedTargetKey = targetKey;\n const ownedGeneration = targetGeneration.current;\n optimisticProcessorBusyRef.current = true;\n void (async () => {\n try {\n if (operation.outcomeUnknown) {\n const events = await client.listEvents(workspaceId, sessionId, {\n includeTypes: [\"user.message\"],\n limit: 100,\n payloadMode: \"none\",\n });\n if (\n events.some(\n (event) =>\n event.type === \"user.message\" && event.clientEventId === operation.clientEventId,\n )\n ) {\n markOptimisticAccepted(operation);\n return;\n }\n if (!operation.canRetry) {\n throw new Error(\n \"OpenGeni cannot safely retry this uncertain request after remount; reconcile the session before sending again.\",\n );\n }\n }\n let expectedDraftRevision: number | undefined;\n if (durableDrafts && operation.draftPayload) {\n if (!(await persistPayload(operation.draftPayload))) {\n throw new Error(\"The message draft could not be saved before delivery.\");\n }\n expectedDraftRevision = draftRef.current?.revision;\n }\n if (\n targetKeyRef.current !== ownedTargetKey ||\n targetGeneration.current !== ownedGeneration\n ) {\n return;\n }\n const wireInput = {\n ...operation.input,\n ...(expectedDraftRevision !== undefined ? { expectedDraftRevision } : {}),\n };\n await client.sendMessage(workspaceId, sessionId, wireInput);\n if (\n targetKeyRef.current !== ownedTargetKey ||\n targetGeneration.current !== ownedGeneration\n ) {\n return;\n }\n if (options.events === undefined) {\n markOptimisticAccepted({ ...operation, input: wireInput });\n } else {\n replaceOptimisticSends((current) =>\n current.map((candidate) =>\n candidate.clientEventId === operation.clientEventId\n ? { ...candidate, input: wireInput, state: \"queued\", error: undefined }\n : candidate,\n ),\n );\n }\n if (!optimisticCallbackIdsRef.current.has(operation.clientEventId)) {\n optimisticCallbackIdsRef.current.add(operation.clientEventId);\n onSent?.(wireInput.text, wireInput);\n }\n if (durableDrafts && draftRef.current) {\n const cleared = {\n ...draftRef.current,\n revision: 0,\n text: \"\",\n resources: [],\n annotations: [],\n sourceTurnId: null,\n sourceTurnVersion: null,\n updatedAt: null,\n };\n draftRef.current = cleared;\n setDraft(cleared);\n lastSavedSignature.current = draftSignature(draftPayload(cleared));\n }\n } catch (cause) {\n const problem = asError(cause);\n const outcomeUnknown = isOutcomeUnknownError(cause) || operation.outcomeUnknown === true;\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n replaceOptimisticSends((current) =>\n current.map((candidate) =>\n candidate.clientEventId === operation.clientEventId\n ? {\n ...candidate,\n state: \"failed\",\n error: problem.message,\n outcomeUnknown,\n }\n : candidate,\n ),\n );\n }\n } finally {\n optimisticProcessorBusyRef.current = false;\n if (targetKeyRef.current === ownedTargetKey) {\n setOptimisticSends([...optimisticSendsRef.current]);\n }\n }\n })();\n }, [\n client,\n durableDrafts,\n markOptimisticAccepted,\n onSent,\n options.events,\n persistPayload,\n replaceOptimisticSends,\n sessionId,\n targetKey,\n workspaceId,\n ]);\n\n useEffect(() => {\n processOptimisticSends();\n }, [optimisticSends, processOptimisticSends]);\n\n // Private durable autosave. A newer local edit is never replaced by an older\n // response; saves serialize and each reads the latest acknowledged revision.\n useEffect(() => {\n const pending = pendingOperationRef.current;\n if (pending) {\n const shadow = {\n text: valueRef.current,\n resources: mergeResources(\n restoredResourcesRef.current,\n resolveSendExtras(sendExtrasRef.current).resources ?? [],\n ),\n annotations: annotationsRef.current,\n };\n if (\n pending.newerShadow.text !== shadow.text ||\n JSON.stringify(pending.newerShadow.resources) !== JSON.stringify(shadow.resources) ||\n JSON.stringify(pending.newerShadow.annotations) !== JSON.stringify(shadow.annotations)\n ) {\n pendingOperationRef.current = updatePendingComposerShadow(\n pendingOperationKey,\n pending,\n shadow,\n );\n }\n return;\n }\n const optimistic = optimisticSendsRef.current.at(-1);\n if (optimistic) {\n const shadow = {\n text: valueRef.current,\n resources: mergeResources(\n restoredResourcesRef.current,\n resolveSendExtras(sendExtrasRef.current).resources ?? [],\n ),\n annotations: annotationsRef.current,\n };\n if (\n optimistic.newerShadow.text !== shadow.text ||\n JSON.stringify(optimistic.newerShadow.resources) !== JSON.stringify(shadow.resources) ||\n JSON.stringify(optimistic.newerShadow.annotations) !== JSON.stringify(shadow.annotations)\n ) {\n setOptimisticDraftShadow(shadow);\n }\n }\n if (optimisticSendsRef.current.some((operation) => operation.state === \"sending\")) {\n return;\n }\n if (\n !durableDrafts ||\n !sessionId ||\n draftLoading ||\n sending ||\n !draftRef.current ||\n draftConflict\n )\n return;\n const payload = currentDraftPayload();\n if (!payload || draftSignature(payload) === lastSavedSignature.current) return;\n const timer = window.setTimeout(() => void persistPayload(payload), 500);\n return () => window.clearTimeout(timer);\n }, [\n currentDraftPayload,\n durableDrafts,\n draftConflict,\n draftLoading,\n liveExtrasVersion,\n pendingOperationKey,\n persistPayload,\n setOptimisticDraftShadow,\n sending,\n sessionId,\n ]);\n\n const dispatch = useCallback(\n async (delivery: \"send\" | \"steer\", explicit?: string): Promise<boolean> => {\n const ownedTargetKey = targetKey;\n const ownedGeneration = targetGeneration.current;\n const operationKey = pendingComposerOperationKey(workspaceId, sessionId);\n const pending = pendingOperationRef.current ?? restorePendingComposerOperation(operationKey);\n if (pending && !pendingOperationRef.current) {\n pendingOperationRef.current = pending;\n pendingClientEventId.current = pending.input.clientEventId ?? null;\n }\n const draftAtSend = value;\n const annotationsAtSend = annotations;\n const rawText = explicit ?? draftAtSend;\n const hasText = rawText.trim().length > 0;\n const hasAnnotations = annotationsAtSend.length > 0;\n const annotationsComplete = annotationsAtSend.every(\n (annotation) => annotation.note.trim().length > 0,\n );\n // Resolve the extras once: a file-only message (empty text + ≥1 ready\n // resource) is legitimate, so we must not bail on empty text alone.\n const extras = pending ? {} : resolveSendExtras(sendExtrasRef.current);\n const hasResources = restoredResources.length > 0 || (extras.resources?.length ?? 0) > 0;\n if (\n (!pending && (!annotationsComplete || (!hasText && !hasResources && !hasAnnotations))) ||\n !sessionId ||\n sending ||\n sendBlockedRef.current?.() === true ||\n targetKeyRef.current !== ownedTargetKey\n ) {\n return false;\n }\n\n const clearPending = (): void => {\n pendingOperationRef.current = null;\n pendingClientEventId.current = null;\n forgetPendingComposerOperation(operationKey);\n };\n\n let keepSteering = pending?.delivery === \"steer\";\n\n const settleAccepted = (operation: PendingComposerOperation): void => {\n clearPending();\n const draftWasUnchanged = valueRef.current === operation.draftAtSend;\n const resourcesWereUnchanged =\n JSON.stringify(restoredResourcesRef.current) ===\n JSON.stringify(operation.resourcesAtSend);\n const annotationsWereUnchanged =\n JSON.stringify(annotationsRef.current) === JSON.stringify(operation.annotationsAtSend);\n const previousDraft = draftRef.current;\n if (previousDraft) {\n const cleared = {\n ...previousDraft,\n revision: 0,\n text: \"\",\n resources: [],\n annotations: [],\n sourceTurnId: null,\n sourceTurnVersion: null,\n updatedAt: null,\n };\n draftRef.current = cleared;\n setDraft(cleared);\n lastSavedSignature.current = draftSignature(draftPayload(cleared));\n }\n if (resourcesWereUnchanged) {\n restoredResourcesRef.current = [];\n setRestoredResources([]);\n }\n if (annotationsWereUnchanged) {\n annotationsRef.current = [];\n setAnnotations([]);\n setAnnotationReviewTargetId(null);\n }\n if (operation.clearDraftOnAccept && draftWasUnchanged) {\n valueRef.current = \"\";\n setValue(\"\");\n }\n onSent?.(operation.input.text, operation.input);\n };\n\n const deliver = async (operation: PendingComposerOperation) => {\n if (operation.delivery === \"steer\") {\n return await client.steerMessage(workspaceId, sessionId, operation.input);\n }\n await client.sendMessage(workspaceId, sessionId, operation.input);\n return null;\n };\n\n if (delivery === \"steer\") {\n setSteering({\n phase: \"submitting\",\n text: rawText,\n clientEventId: pending?.input.clientEventId ?? pendingClientEventId.current,\n triggerEventId: null,\n turnId: null,\n });\n }\n setSending(true);\n setError(null);\n try {\n if (pending) {\n let acceptedEvent: SessionEvent | null = null;\n try {\n const events = await client.listEvents(workspaceId, sessionId, {\n includeTypes: [\"user.message\"],\n limit: 100,\n payloadMode: \"none\",\n });\n acceptedEvent =\n events.find(\n (event) =>\n event.type === \"user.message\" &&\n event.clientEventId === pending.input.clientEventId,\n ) ?? null;\n } catch (cause) {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setError(asError(cause));\n }\n return false;\n }\n if (\n targetKeyRef.current !== ownedTargetKey ||\n targetGeneration.current !== ownedGeneration\n ) {\n return false;\n }\n if (acceptedEvent) {\n if (pending.delivery === \"steer\") {\n keepSteering = true;\n setSteering({\n phase: \"accepted\",\n text: pending.input.text,\n clientEventId: pending.input.clientEventId ?? null,\n triggerEventId: acceptedEvent.id,\n turnId: null,\n });\n }\n settleAccepted(pending);\n return true;\n }\n if (!pending.canRetry) {\n setError(\n new Error(\n \"OpenGeni cannot safely retry this uncertain request after remount; reconcile the session before sending again.\",\n ),\n );\n return false;\n }\n try {\n const result = await deliver(pending);\n if (pending.delivery === \"steer\" && result) {\n keepSteering = true;\n setSteering({\n phase: \"accepted\",\n text: pending.input.text,\n clientEventId: pending.input.clientEventId ?? null,\n triggerEventId: result.accepted.id,\n turnId: result.turn.id,\n stoppingPreviousAttempt:\n result.replay !== true && (result.interruptionCount ?? 0) > 0,\n });\n }\n } catch (cause) {\n if (pending.delivery === \"steer\") keepSteering = true;\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setError(asError(cause));\n }\n return false;\n }\n if (\n targetKeyRef.current !== ownedTargetKey ||\n targetGeneration.current !== ownedGeneration\n ) {\n return false;\n }\n settleAccepted(pending);\n return true;\n }\n\n // Trimming is only an emptiness check. A non-blank prompt is persisted\n // and submitted byte-for-byte, while file-only sends use the same\n // placeholder for both operations so the server content fence cannot\n // reject its own client.\n const sendText = hasText ? rawText : hasAnnotations ? \"\" : FILE_ONLY_MESSAGE_TEXT;\n const currentPayload = currentDraftPayload();\n const payload = currentPayload ? { ...currentPayload, text: sendText } : null;\n if (payload && !(await persistPayload(payload))) return false;\n if (\n targetKeyRef.current !== ownedTargetKey ||\n targetGeneration.current !== ownedGeneration\n ) {\n return false;\n }\n // The wire contract requires non-empty text (z.string().min(1)) and the\n // worker rejects whitespace-only text; a file-only message therefore\n // carries a minimal default so the attachments still get delivered.\n pendingClientEventId.current ??= generateClientEventId();\n const input = composeSendInput(sendText, pendingClientEventId.current, extras, {\n ...(options.effectiveControl?.controlEtag\n ? { controlEtag: options.effectiveControl.controlEtag }\n : {}),\n ...(durableDrafts && draftRef.current\n ? { expectedDraftRevision: draftRef.current.revision }\n : {}),\n resources: mergeResources(restoredResources, extras.resources ?? []),\n annotations: cloneAnnotations(annotationsAtSend),\n });\n const operation: PendingComposerOperation = {\n delivery,\n input,\n draftAtSend,\n resourcesAtSend: [...restoredResources],\n annotationsAtSend: cloneAnnotations(annotationsAtSend),\n newerShadow: {\n text: draftAtSend,\n resources: mergeResources(restoredResources, extras.resources ?? []),\n annotations: cloneAnnotations(annotationsAtSend),\n },\n clearDraftOnAccept: explicit === undefined,\n canRetry: true,\n };\n pendingOperationRef.current = operation;\n rememberPendingComposerOperation(operationKey, operation);\n if (delivery === \"steer\") {\n setSteering({\n phase: \"submitting\",\n text: sendText,\n clientEventId: input.clientEventId ?? null,\n triggerEventId: null,\n turnId: null,\n });\n }\n try {\n const result = await deliver(operation);\n if (delivery === \"steer\" && result) {\n keepSteering = true;\n setSteering({\n phase: \"accepted\",\n text: sendText,\n clientEventId: input.clientEventId ?? null,\n triggerEventId: result.accepted.id,\n turnId: result.turn.id,\n stoppingPreviousAttempt:\n result.replay !== true && (result.interruptionCount ?? 0) > 0,\n });\n }\n } catch (cause) {\n if (!isOutcomeUnknownError(cause)) {\n clearPending();\n } else if (delivery === \"steer\") {\n keepSteering = true;\n }\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setError(asError(cause));\n }\n return false;\n }\n if (\n targetKeyRef.current !== ownedTargetKey ||\n targetGeneration.current !== ownedGeneration\n ) {\n return false;\n }\n settleAccepted(operation);\n return true;\n } finally {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setSending(false);\n if (delivery === \"steer\" && !keepSteering) setSteering(null);\n }\n }\n },\n [\n client,\n currentDraftPayload,\n durableDrafts,\n onSent,\n options.effectiveControl?.controlEtag,\n persistPayload,\n restoredResources,\n annotations,\n sending,\n sessionId,\n targetKey,\n value,\n workspaceId,\n ],\n );\n\n const send = useCallback(\n async (explicit?: string): Promise<boolean> => {\n if (pendingOperationRef.current?.delivery === \"send\") {\n return await dispatch(\"send\", explicit);\n }\n const rawText = explicit ?? valueRef.current;\n const annotationsAtSend = cloneAnnotations(annotationsRef.current);\n const hasText = rawText.trim().length > 0;\n const hasAnnotations = annotationsAtSend.length > 0;\n const annotationsComplete = annotationsAtSend.every(\n (annotation) => annotation.note.trim().length > 0,\n );\n const extras = resolveSendExtras(sendExtrasRef.current);\n const resources = mergeResources(restoredResourcesRef.current, extras.resources ?? []);\n if (\n !sessionId ||\n sending ||\n !annotationsComplete ||\n (!hasText && !hasAnnotations && resources.length === 0) ||\n sendBlockedRef.current?.() === true ||\n targetKeyRef.current !== targetKey\n ) {\n return false;\n }\n const sendText = hasText ? rawText : hasAnnotations ? \"\" : FILE_ONLY_MESSAGE_TEXT;\n const clientEventId = generateClientEventId();\n const input = composeSendInput(sendText, clientEventId, extras, {\n ...(options.effectiveControl?.controlEtag\n ? { controlEtag: options.effectiveControl.controlEtag }\n : {}),\n resources,\n annotations: annotationsAtSend,\n });\n const currentPayload = currentDraftPayload();\n const operation: OptimisticSendOperation = {\n clientEventId,\n text: sendText,\n annotations: annotationsAtSend,\n resources,\n occurredAt: new Date().toISOString(),\n state: \"sending\",\n input,\n draftPayload: currentPayload ? { ...currentPayload, text: sendText } : null,\n newerShadow: {\n text: explicit === undefined ? \"\" : valueRef.current,\n resources: explicit === undefined ? [] : [...restoredResourcesRef.current],\n annotations: explicit === undefined ? [] : cloneAnnotations(annotationsRef.current),\n },\n canRetry: true,\n };\n replaceOptimisticSends((current) => [...current, operation]);\n queueMicrotask(processOptimisticSends);\n setError(null);\n onSubmitted?.(sendText, input);\n if (explicit === undefined) {\n valueRef.current = \"\";\n annotationsRef.current = [];\n restoredResourcesRef.current = [];\n localEditRevision.current += 1;\n setValue(\"\");\n setAnnotations([]);\n setAnnotationReviewTargetId(null);\n setRestoredResources([]);\n }\n return true;\n },\n [\n currentDraftPayload,\n dispatch,\n onSubmitted,\n options.effectiveControl?.controlEtag,\n processOptimisticSends,\n replaceOptimisticSends,\n sending,\n sessionId,\n targetKey,\n ],\n );\n const steer = useCallback(async (text?: string) => await dispatch(\"steer\", text), [dispatch]);\n\n const retryOptimisticMessage = useCallback(\n (clientEventId: string): void => {\n replaceOptimisticSends((current) =>\n current.map((operation) => {\n if (operation.clientEventId !== clientEventId || operation.state !== \"failed\") {\n return operation;\n }\n if (operation.outcomeUnknown) {\n return { ...operation, state: \"sending\", error: undefined };\n }\n const nextClientEventId = generateClientEventId();\n const retryExtras = resolveSendExtras(sendExtrasRef.current);\n const retryInput = composeSendInput(operation.text, nextClientEventId, retryExtras, {\n ...(options.effectiveControl?.controlEtag\n ? { controlEtag: options.effectiveControl.controlEtag }\n : {}),\n resources: operation.resources,\n annotations: operation.annotations,\n });\n return {\n ...operation,\n clientEventId: nextClientEventId,\n input: retryInput,\n draftPayload: operation.draftPayload\n ? {\n ...operation.draftPayload,\n model: retryExtras.model ?? operation.draftPayload.model,\n reasoningEffort:\n retryExtras.reasoningEffort ?? operation.draftPayload.reasoningEffort,\n latencyMode: retryExtras.latencyMode ?? operation.draftPayload.latencyMode,\n }\n : null,\n occurredAt: new Date().toISOString(),\n state: \"sending\",\n error: undefined,\n outcomeUnknown: false,\n canRetry: true,\n };\n }),\n );\n queueMicrotask(processOptimisticSends);\n },\n [options.effectiveControl?.controlEtag, processOptimisticSends, replaceOptimisticSends],\n );\n\n const removeOptimisticMessage = useCallback(\n (clientEventId: string): void => {\n replaceOptimisticSends((current) =>\n current.filter((operation) => operation.clientEventId !== clientEventId),\n );\n },\n [replaceOptimisticSends],\n );\n\n // A send is possible with non-empty text OR with ≥1 attached resource (a\n // file-only message). Resources ride in `sendExtras`, so we resolve them here\n // — keeping useComposer attachment-agnostic while still lighting up the send\n // affordance the moment a file is ready. Attachment hosts bind `sendBlocked`\n // to unresolved uploads so direct send()/steer() calls fail closed too.\n const hasReadyResources =\n restoredResources.length > 0 ||\n (resolveSendExtras(sendExtrasRef.current).resources?.length ?? 0) > 0;\n const hasPendingOperation = pendingOperationRef.current !== null;\n const annotationsComplete = annotations.every((annotation) => annotation.note.trim().length > 0);\n\n const pause = useCallback(\n async (reason?: string): Promise<void> => {\n const ownedTargetKey = targetKey;\n const ownedGeneration = targetGeneration.current;\n if (!sessionId || pausing || targetKeyRef.current !== ownedTargetKey) {\n return;\n }\n setPausing(true);\n setError(null);\n try {\n const result = await client.pauseSession(workspaceId, sessionId, {\n ...(reason !== undefined ? { reason } : {}),\n ...(options.effectiveControl?.controlEtag\n ? { expectedControlEtag: options.effectiveControl.controlEtag }\n : {}),\n });\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setControlStopping(\n result.interruptionCount > 0 &&\n result.effectiveControl.state === \"paused\" &&\n result.effectiveControl.settlement !== null\n ? {\n controlVersion: result.effectiveControl.controlVersion,\n controlEtag: result.effectiveControl.controlEtag,\n }\n : null,\n );\n }\n } catch (cause) {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setError(cause instanceof Error ? cause : new Error(String(cause)));\n }\n } finally {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setPausing(false);\n }\n }\n },\n [client, workspaceId, sessionId, pausing, options.effectiveControl?.controlEtag, targetKey],\n );\n\n const resume = useCallback(\n async (reason?: string): Promise<void> => {\n const ownedTargetKey = targetKey;\n const ownedGeneration = targetGeneration.current;\n if (!sessionId || resuming || targetKeyRef.current !== ownedTargetKey) return;\n setResuming(true);\n setError(null);\n try {\n await client.resumeSession(workspaceId, sessionId, {\n ...(reason !== undefined ? { reason } : {}),\n ...(options.effectiveControl?.controlEtag\n ? { expectedControlEtag: options.effectiveControl.controlEtag }\n : {}),\n });\n } catch (cause) {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setError(cause instanceof Error ? cause : new Error(String(cause)));\n }\n } finally {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setResuming(false);\n }\n }\n },\n [client, workspaceId, sessionId, resuming, options.effectiveControl?.controlEtag, targetKey],\n );\n\n const resumeScope = useCallback(\n async (option: EffectiveControlResumeOption): Promise<void> => {\n const ownedTargetKey = targetKey;\n const ownedGeneration = targetGeneration.current;\n if (!sessionId || resuming || targetKeyRef.current !== ownedTargetKey) return;\n setResuming(true);\n setError(null);\n try {\n if (option.scope === \"workspace\") {\n const workspaceBlocker = options.effectiveControl?.blockers.find(\n (blocker) => blocker.kind === \"workspace\",\n );\n if (!client.setWorkspaceInferenceState) {\n throw new Error(\n \"@opengeni/react: workspace-scoped resume requires setWorkspaceInferenceState.\",\n );\n }\n await client.setWorkspaceInferenceState(workspaceId, {\n action: \"resume\",\n clientEventId: generateClientEventId(),\n ...(workspaceBlocker ? { expectedRevision: workspaceBlocker.revision } : {}),\n });\n } else if (option.scope === \"session\" && option.targetId) {\n const target = await client.getQueue(workspaceId, option.targetId);\n if (\n targetKeyRef.current !== ownedTargetKey ||\n targetGeneration.current !== ownedGeneration\n ) {\n return;\n }\n await client.resumeSession(workspaceId, option.targetId, {\n expectedControlEtag: target.effectiveControl.controlEtag,\n });\n } else {\n await client.resumeSession(workspaceId, sessionId, {\n ...(options.effectiveControl?.controlEtag\n ? { expectedControlEtag: options.effectiveControl.controlEtag }\n : {}),\n });\n }\n } catch (cause) {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setError(asError(cause));\n }\n } finally {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setResuming(false);\n }\n }\n },\n [client, options.effectiveControl, resuming, sessionId, targetKey, workspaceId],\n );\n\n const updateValue = useCallback(\n (next: string) => {\n if (targetKeyRef.current !== targetKey) return;\n localEditRevision.current += 1;\n valueRef.current = next;\n pendingOperationRef.current = updatePendingComposerShadow(\n pendingOperationKey,\n pendingOperationRef.current,\n {\n text: next,\n resources: mergeResources(\n restoredResourcesRef.current,\n resolveSendExtras(sendExtrasRef.current).resources ?? [],\n ),\n annotations: annotationsRef.current,\n },\n );\n setOptimisticDraftShadow({\n text: next,\n resources: mergeResources(\n restoredResourcesRef.current,\n resolveSendExtras(sendExtrasRef.current).resources ?? [],\n ),\n annotations: annotationsRef.current,\n });\n setValue(next);\n },\n [pendingOperationKey, setOptimisticDraftShadow, targetKey],\n );\n\n const updateAnnotations = useCallback(\n (next: DraftTimelineAnnotation[], reviewTargetId: string | null = null) => {\n if (targetKeyRef.current !== targetKey) return;\n localEditRevision.current += 1;\n annotationsRef.current = next;\n pendingOperationRef.current = updatePendingComposerShadow(\n pendingOperationKey,\n pendingOperationRef.current,\n {\n text: valueRef.current,\n resources: mergeResources(\n restoredResourcesRef.current,\n resolveSendExtras(sendExtrasRef.current).resources ?? [],\n ),\n annotations: next,\n },\n );\n setOptimisticDraftShadow({\n text: valueRef.current,\n resources: mergeResources(\n restoredResourcesRef.current,\n resolveSendExtras(sendExtrasRef.current).resources ?? [],\n ),\n annotations: next,\n });\n setAnnotations(next);\n setAnnotationReviewTargetId(reviewTargetId);\n },\n [pendingOperationKey, setOptimisticDraftShadow, targetKey],\n );\n\n const addAnnotation = useCallback(\n (annotation: DraftTimelineAnnotation) => {\n if (annotationsRef.current.length >= 12) {\n setError(new Error(\"A message can include at most 12 timeline annotations.\"));\n return;\n }\n const next = [...annotationsRef.current, annotation];\n updateAnnotations(next, annotation.id);\n },\n [updateAnnotations],\n );\n\n const updateAnnotation = useCallback(\n (id: string, note: string) => {\n updateAnnotations(\n annotationsRef.current.map((annotation) =>\n annotation.id === id ? { ...annotation, note } : annotation,\n ),\n );\n },\n [updateAnnotations],\n );\n\n const removeAnnotation = useCallback(\n (id: string) => {\n updateAnnotations(annotationsRef.current.filter((annotation) => annotation.id !== id));\n },\n [updateAnnotations],\n );\n\n const clearAnnotationReviewTarget = useCallback(() => {\n setAnnotationReviewTargetId(null);\n }, []);\n\n const removeRestoredResource = useCallback(\n (index: number) => {\n if (targetKeyRef.current !== targetKey) return;\n localEditRevision.current += 1;\n const next = restoredResourcesRef.current.filter((_, candidate) => candidate !== index);\n restoredResourcesRef.current = next;\n pendingOperationRef.current = updatePendingComposerShadow(\n pendingOperationKey,\n pendingOperationRef.current,\n {\n text: valueRef.current,\n resources: mergeResources(next, resolveSendExtras(sendExtrasRef.current).resources ?? []),\n annotations: annotationsRef.current,\n },\n );\n setOptimisticDraftShadow({\n text: valueRef.current,\n resources: mergeResources(next, resolveSendExtras(sendExtrasRef.current).resources ?? []),\n annotations: annotationsRef.current,\n });\n setRestoredResources(next);\n },\n [pendingOperationKey, setOptimisticDraftShadow, targetKey],\n );\n\n const hasDraftContent = useCallback((): boolean => {\n const current = draftRef.current;\n const extras = resolveSendExtras(sendExtrasRef.current);\n return (\n valueRef.current.length > 0 ||\n annotationsRef.current.length > 0 ||\n restoredResourcesRef.current.length > 0 ||\n (extras.resources?.length ?? 0) > 0 ||\n (current?.sourceTurnId !== null && current?.sourceTurnId !== undefined)\n );\n }, []);\n\n const resolveDraftConflict = useCallback(\n async (choice: \"keep_mine\" | \"use_remote\"): Promise<void> => {\n const ownedTargetKey = targetKey;\n const ownedGeneration = targetGeneration.current;\n if (!sessionId || !durableDrafts || targetKeyRef.current !== ownedTargetKey) return;\n const remote = await client.getComposerDraft(workspaceId, sessionId);\n if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {\n return;\n }\n if (choice === \"use_remote\") {\n applyDraft(remote);\n setError(null);\n return;\n }\n draftRef.current = remote;\n setDraft(remote);\n setDraftConflict(null);\n setError(null);\n const payload = currentDraftPayload();\n if (payload) await persistPayload({ ...payload, expectedRevision: remote.revision });\n },\n [\n applyDraft,\n client,\n currentDraftPayload,\n durableDrafts,\n persistPayload,\n sessionId,\n targetKey,\n workspaceId,\n ],\n );\n\n const identityMatches = stateTargetKey === targetKey;\n const visibleSteering = identityMatches ? steering : null;\n const reloadDraft = useCallback(async () => await loadDraft(true), [loadDraft]);\n const clearError = useCallback(() => {\n if (targetKeyRef.current !== targetKey) return;\n setError(null);\n setDraftConflict(null);\n }, [targetKey]);\n\n return {\n value: identityMatches ? value : \"\",\n setValue: updateValue,\n annotations: identityMatches ? annotations : [],\n addAnnotation,\n updateAnnotation,\n removeAnnotation,\n annotationReviewTargetId: identityMatches ? annotationReviewTargetId : null,\n clearAnnotationReviewTarget,\n hasDraftContent,\n send,\n optimisticMessages: identityMatches\n ? optimisticSends.map(\n ({ input: _input, draftPayload: _payload, canRetry: _retry, ...item }) => item,\n )\n : [],\n retryOptimisticMessage,\n removeOptimisticMessage,\n steer,\n steering: visibleSteering,\n stoppingAttempt: identityMatches\n ? controlStopping\n ? \"current\"\n : visibleSteering?.phase === \"accepted\" && visibleSteering.stoppingPreviousAttempt === true\n ? \"previous\"\n : null\n : null,\n sending: identityMatches ? sending : false,\n canSend:\n identityMatches &&\n Boolean(sessionId) &&\n !sending &&\n sendBlockedRef.current?.() !== true &&\n annotationsComplete &&\n (hasPendingOperation ||\n value.trim().length > 0 ||\n hasReadyResources ||\n annotations.length > 0),\n pause,\n pausing: identityMatches ? pausing : false,\n resume,\n resumeScope,\n resuming: identityMatches ? resuming : false,\n draft: identityMatches ? draft : null,\n draftRevision: identityMatches ? (draft?.revision ?? 0) : 0,\n draftLoading: identityMatches ? draftLoading : Boolean(sessionId) && durableDrafts,\n draftSaving: identityMatches ? draftSaving : false,\n draftConflict: identityMatches ? draftConflict : null,\n draftPersistence: durableDrafts ? \"durable\" : \"disabled\",\n applyDraft,\n reloadDraft,\n resolveDraftConflict,\n restoredResources: identityMatches ? restoredResources : [],\n removeRestoredResource,\n error: identityMatches ? error : null,\n clearError,\n };\n}\n\n/** Events that can atomically replace or clear this subject's durable draft. */\nexport function isComposerDraftEvent(event: Pick<SessionEvent, \"type\">): boolean {\n return event.type === \"user.message\" || event.type === \"session.queue.changed\";\n}\n\n/**\n * Default text for a resource-only message (attachments present, no typed\n * draft). Kept non-empty so the wire contract (`text: z.string().min(1)`) and\n * the worker's non-whitespace guard accept it. The export name is retained for\n * compatibility now that repositories can ride beside files in `resources`.\n */\nexport const FILE_ONLY_MESSAGE_TEXT = \"(see attached context)\";\n\n/** Resolve possibly-deferred extras to a concrete bag (function evaluated now). */\nexport function resolveSendExtras(\n extras: ComposerSendExtras | (() => ComposerSendExtras) | undefined,\n): ComposerSendExtras {\n return (typeof extras === \"function\" ? extras() : extras) ?? {};\n}\n\n/**\n * Merge the draft text + idempotency key with caller-provided extras. The\n * text and clientEventId always win over extras. Exported for tests.\n */\nexport function composeSendInput(\n text: string,\n clientEventId: string,\n extras: ComposerSendExtras | (() => ComposerSendExtras) | undefined,\n bound: Partial<SendMessageInput> = {},\n): SendMessageInput {\n return { ...resolveSendExtras(extras), ...bound, text, clientEventId };\n}\n\n/** Submit on plain Enter; Shift+Enter inserts a newline. Exported for tests. */\nexport function shouldSubmitOnKey(event: {\n key: string;\n shiftKey: boolean;\n metaKey?: boolean;\n ctrlKey?: boolean;\n nativeEvent?: { isComposing?: boolean };\n}): boolean {\n if (event.key !== \"Enter\" || event.shiftKey) {\n return false;\n }\n return event.nativeEvent?.isComposing !== true;\n}\n\n/** Cmd/Ctrl+Enter steers; ordinary Enter appends to the queue. */\nexport function shouldSteerOnKey(event: { metaKey?: boolean; ctrlKey?: boolean }): boolean {\n return event.metaKey === true || event.ctrlKey === true;\n}\n\nfunction generateClientEventId(): string {\n return globalThis.crypto.randomUUID();\n}\n\nfunction isOutcomeUnknownError(cause: unknown): boolean {\n return (\n typeof cause === \"object\" &&\n cause !== null &&\n (cause as { outcomeUnknown?: unknown }).outcomeUnknown === true\n );\n}\n\nfunction asError(cause: unknown): Error {\n return cause instanceof Error ? cause : new Error(String(cause));\n}\n\nfunction isDraftConflictError(error: Error): boolean {\n const apiError = error as Partial<OpenGeniApiError>;\n if (apiError.status !== 409 || apiError.outcomeUnknown === true) return false;\n // Production queue OCC returns `DRAFT_CHANGED`. Older/SDK-shaped 409s may\n // omit code or use the generic conflict labels — all are recoverable OCC.\n const code = apiError.code;\n if (\n code === undefined ||\n code === \"DRAFT_CHANGED\" ||\n code === \"conflict\" ||\n code === \"idempotency_conflict\"\n ) {\n return true;\n }\n return /draft changed/i.test(error.message);\n}\n\n/**\n * One OCC retry: adopt the server revision and rewrite the same local content.\n * Covers the common \"tab slept through a successful autosave\" case without\n * stranding the operator on a raw 409 toast.\n */\nasync function saveComposerDraftWithStaleRetry(input: {\n client: {\n getComposerDraft: (workspaceId: string, sessionId: string) => Promise<ComposerDraft>;\n saveComposerDraft: (\n workspaceId: string,\n sessionId: string,\n request: SaveComposerDraftRequest,\n ) => Promise<ComposerDraft>;\n };\n workspaceId: string;\n sessionId: string;\n request: SaveComposerDraftRequest;\n onAdoptRemote: (remote: ComposerDraft) => void;\n}): Promise<ComposerDraft> {\n try {\n return await input.client.saveComposerDraft(input.workspaceId, input.sessionId, input.request);\n } catch (cause) {\n const problem = asError(cause);\n if (!isDraftConflictError(problem)) throw problem;\n const remote = await input.client.getComposerDraft(input.workspaceId, input.sessionId);\n input.onAdoptRemote(remote);\n return await input.client.saveComposerDraft(input.workspaceId, input.sessionId, {\n ...input.request,\n expectedRevision: remote.revision,\n });\n }\n}\n\nfunction draftPayload(draft: ComposerDraft): SaveComposerDraftRequest {\n return {\n expectedRevision: draft.revision,\n text: draft.text,\n resources: draft.resources,\n annotations: draft.annotations ?? [],\n model: draft.model,\n reasoningEffort: draft.reasoningEffort,\n latencyMode: draft.latencyMode ?? \"standard\",\n };\n}\n\nfunction composerDraftPayload(\n base: ComposerDraft,\n text: string,\n restoredResources: ResourceRef[],\n annotations: DraftTimelineAnnotation[],\n extras: ComposerSendExtras,\n): SaveComposerDraftRequest {\n return {\n expectedRevision: base.revision,\n text,\n resources: mergeResources(restoredResources, extras.resources ?? []),\n annotations,\n model: extras.model ?? base.model,\n reasoningEffort: extras.reasoningEffort ?? base.reasoningEffort,\n latencyMode: extras.latencyMode ?? base.latencyMode ?? \"standard\",\n };\n}\n\nfunction draftSignature(payload: SaveComposerDraftRequest): string {\n const { expectedRevision: _revision, ...content } = payload;\n return JSON.stringify(content);\n}\n\nfunction mergeResources(base: ResourceRef[], additions: ResourceRef[]): ResourceRef[] {\n const seen = new Set<string>();\n return [...base, ...additions].filter((resource) => {\n // Reconnect reconciliation can restore the canonical server form while\n // the still-mounted upload card supplies the same ready file without its\n // default mount. Treat those two wire shapes as one selected attachment;\n // preserving the first representation keeps custom mounts and ordering\n // intact while preventing the draft and command paths from seeing\n // different duplicate counts after server normalization.\n const key =\n resource.kind === \"file\"\n ? `file:${resource.fileId}\\u0000${resource.mountPath ?? `${DEFAULT_FILE_RESOURCE_MOUNT_ROOT}/${resource.fileId}`}`\n : JSON.stringify(resource);\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n}\n"],"mappings":";;;;;;;;AAAA;AAAA,EACE;AAAA,OAUK;AACP,SAAS,aAAa,WAAW,iBAAiB,QAAQ,gBAAgB;AAgF1E,IAAM,kCAAkC;AACxC,IAAM,iCAAiC;AAMvC,IAAM,4BAA4B,oBAA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