@opengeni/react 0.44.1 → 0.44.3

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.
@@ -352,6 +352,19 @@ function useComposer(sessionId, options = {}) {
352
352
  }
353
353
  void loadDraft(false);
354
354
  }, [durableDrafts, loadDraft, sessionId]);
355
+ useEffect(() => {
356
+ if (!sessionId || !durableDrafts) return;
357
+ const onWake = () => {
358
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
359
+ void loadDraft(false);
360
+ };
361
+ document.addEventListener("visibilitychange", onWake);
362
+ window.addEventListener("pageshow", onWake);
363
+ return () => {
364
+ document.removeEventListener("visibilitychange", onWake);
365
+ window.removeEventListener("pageshow", onWake);
366
+ };
367
+ }, [durableDrafts, loadDraft, sessionId]);
355
368
  useEffect(() => {
356
369
  if (!sessionId || !durableDrafts) return;
357
370
  return registerSessionReconciler(sessionId, "composer", async () => await loadDraft(false));
@@ -452,14 +465,27 @@ function useComposer(sessionId, options = {}) {
452
465
  }
453
466
  setDraftSaving(true);
454
467
  try {
455
- const saved = await client.saveComposerDraft(workspaceId, sessionId, request);
468
+ const saved = await saveComposerDraftWithStaleRetry({
469
+ client,
470
+ workspaceId,
471
+ sessionId,
472
+ request,
473
+ onAdoptRemote: (remote) => {
474
+ draftRef.current = remote;
475
+ setDraft(remote);
476
+ }
477
+ });
456
478
  if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
457
479
  return;
458
480
  }
459
481
  draftRef.current = saved;
460
482
  setDraft(saved);
461
- lastSavedSignature.current = signature;
483
+ lastSavedSignature.current = draftSignature({
484
+ ...request,
485
+ expectedRevision: saved.revision
486
+ });
462
487
  setDraftConflict(null);
488
+ setError(null);
463
489
  success = true;
464
490
  } catch (cause) {
465
491
  if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
@@ -895,11 +921,13 @@ function useComposer(sessionId, options = {}) {
895
921
  }
896
922
  if (choice === "use_remote") {
897
923
  applyDraft(remote);
924
+ setError(null);
898
925
  return;
899
926
  }
900
927
  draftRef.current = remote;
901
928
  setDraft(remote);
902
929
  setDraftConflict(null);
930
+ setError(null);
903
931
  const payload = currentDraftPayload();
904
932
  if (payload) await persistPayload({ ...payload, expectedRevision: remote.revision });
905
933
  },
@@ -980,7 +1008,26 @@ function asError(cause) {
980
1008
  }
981
1009
  function isDraftConflictError(error) {
982
1010
  const apiError = error;
983
- return apiError.status === 409 && apiError.outcomeUnknown === false && (apiError.code === void 0 || apiError.code === "conflict" || apiError.code === "idempotency_conflict");
1011
+ if (apiError.status !== 409 || apiError.outcomeUnknown === true) return false;
1012
+ const code = apiError.code;
1013
+ if (code === void 0 || code === "DRAFT_CHANGED" || code === "conflict" || code === "idempotency_conflict") {
1014
+ return true;
1015
+ }
1016
+ return /draft changed/i.test(error.message);
1017
+ }
1018
+ async function saveComposerDraftWithStaleRetry(input) {
1019
+ try {
1020
+ return await input.client.saveComposerDraft(input.workspaceId, input.sessionId, input.request);
1021
+ } catch (cause) {
1022
+ const problem = asError(cause);
1023
+ if (!isDraftConflictError(problem)) throw problem;
1024
+ const remote = await input.client.getComposerDraft(input.workspaceId, input.sessionId);
1025
+ input.onAdoptRemote(remote);
1026
+ return await input.client.saveComposerDraft(input.workspaceId, input.sessionId, {
1027
+ ...input.request,
1028
+ expectedRevision: remote.revision
1029
+ });
1030
+ }
984
1031
  }
985
1032
  function draftPayload(draft) {
986
1033
  return {
@@ -1023,4 +1070,4 @@ export {
1023
1070
  shouldSubmitOnKey,
1024
1071
  shouldSteerOnKey
1025
1072
  };
1026
- //# sourceMappingURL=chunk-Q2NCKWTK.js.map
1073
+ //# sourceMappingURL=chunk-HFO4ERGQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-composer.ts"],"sourcesContent":["import {\n DEFAULT_FILE_RESOURCE_MOUNT_ROOT,\n type ComposerDraft,\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\">;\n\nexport type UseComposerOptions = EmbeddedSessionClientOverride &\n SessionEventFeedOptions & {\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};\n\ntype PendingComposerOperation = {\n delivery: \"send\" | \"steer\";\n input: SendMessageInput;\n draftAtSend: string;\n resourcesAtSend: ResourceRef[];\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\nconst PENDING_COMPOSER_STORAGE_PREFIX = \"opengeni.pending-composer.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>();\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 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 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 typeof shadowRecord.text !== \"string\" ||\n !resourceList(shadowRecord.resources) ||\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 ) {\n return null;\n }\n return record as StoredPendingComposerOperation;\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 },\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 },\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 = { ...operation, newerShadow: { ...shadow, resources: [...shadow.resources] } };\n rememberPendingComposerOperation(key, next);\n return next;\n}\n\nexport type ComposerState = {\n value: string;\n setValue: (value: string) => void;\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 /** 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 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};\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 initialShadow = initialPendingOperation?.newerShadow;\n const [value, setValue] = useState(() => initialShadow?.text ?? \"\");\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 [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 [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 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 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 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 steeringSettlementEventsRef.current = [];\n pendingClientEventId.current = pendingOperationRef.current?.input.clientEventId ?? null;\n const shadow = pendingOperationRef.current?.newerShadow;\n localEditRevision.current = shadow ? 1 : 0;\n valueRef.current = shadow?.text ?? \"\";\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 setSending(false);\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 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 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 restoredResourcesRef.current = next.resources;\n draftRef.current = null;\n lastSavedSignature.current = null;\n setDraft(null);\n setValue(next.text);\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 },\n );\n setDraftConflict(null);\n return;\n }\n valueRef.current = next.text;\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 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 },\n );\n setDraftConflict(null);\n onDraftAppliedRef.current?.(next);\n },\n [durableDrafts, pendingOperationKey, 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 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 = pendingOperationRef.current?.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 localEditRevision.current ||= 1;\n setValue(shadow.text);\n setRestoredResources(shadow.resources);\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 lastSavedSignature.current = draftSignature(draftPayload(fetched));\n setValue(fetched.text);\n setRestoredResources(fetched.resources);\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 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, extras);\n }, [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 // 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 };\n if (\n pending.newerShadow.text !== shadow.text ||\n JSON.stringify(pending.newerShadow.resources) !== JSON.stringify(shadow.resources)\n ) {\n pendingOperationRef.current = updatePendingComposerShadow(\n pendingOperationKey,\n pending,\n shadow,\n );\n }\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 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 rawText = explicit ?? draftAtSend;\n const hasText = rawText.trim().length > 0;\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 && !hasText && !hasResources) ||\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 previousDraft = draftRef.current;\n if (previousDraft) {\n const cleared = {\n ...previousDraft,\n revision: 0,\n text: \"\",\n resources: [],\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 (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 });\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 : 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 });\n const operation: PendingComposerOperation = {\n delivery,\n input,\n draftAtSend,\n resourcesAtSend: [...restoredResources],\n newerShadow: {\n text: draftAtSend,\n resources: mergeResources(restoredResources, extras.resources ?? []),\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 });\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 sending,\n sessionId,\n targetKey,\n value,\n workspaceId,\n ],\n );\n\n const send = useCallback(async (text?: string) => await dispatch(\"send\", text), [dispatch]);\n const steer = useCallback(async (text?: string) => await dispatch(\"steer\", text), [dispatch]);\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\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 await client.pauseSession(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 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 },\n );\n setValue(next);\n },\n [pendingOperationKey, targetKey],\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 },\n );\n setRestoredResources(next);\n },\n [pendingOperationKey, 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 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 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 hasDraftContent,\n send,\n steer,\n steering: identityMatches ? steering : null,\n sending: identityMatches ? sending : false,\n canSend:\n identityMatches &&\n Boolean(sessionId) &&\n !sending &&\n sendBlockedRef.current?.() !== true &&\n (hasPendingOperation || value.trim().length > 0 || hasReadyResources),\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 file-only message (attachment(s) present, no typed draft).\n * Kept non-empty so the wire contract (`text: z.string().min(1)`) and the\n * worker's non-whitespace guard accept it; the attached files still ride in\n * `resources`. Exported for tests.\n */\nexport const FILE_ONLY_MESSAGE_TEXT = \"(see attached files)\";\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 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 extras: ComposerSendExtras,\n): SaveComposerDraftRequest {\n return {\n expectedRevision: base.revision,\n text,\n resources: mergeResources(restoredResources, extras.resources ?? []),\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"],"m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FO4ERGQ.js";
5
5
  import {
6
6
  groupPickerRowsByBillingClass
7
7
  } from "./chunk-23EJ676W.js";
@@ -4162,4 +4162,4 @@ export {
4162
4162
  Status,
4163
4163
  ComposerTranscriptionControl
4164
4164
  };
4165
- //# sourceMappingURL=chunk-KC27K42G.js.map
4165
+ //# sourceMappingURL=chunk-QQRM3DO3.js.map
@@ -2527,6 +2527,7 @@ import {
2527
2527
  MessagesSquareIcon,
2528
2528
  MessageSquareIcon,
2529
2529
  MousePointer2Icon,
2530
+ PackageSearchIcon,
2530
2531
  PanelsTopLeftIcon,
2531
2532
  PlugIcon,
2532
2533
  SearchIcon,
@@ -3366,6 +3367,169 @@ function SecretSetRenderer({ item }) {
3366
3367
  }
3367
3368
  );
3368
3369
  }
3370
+ function splitToolWireName(name) {
3371
+ const boundary = name.indexOf("__");
3372
+ if (boundary <= 0) {
3373
+ return { name, source: null, leaf: name };
3374
+ }
3375
+ return {
3376
+ name,
3377
+ source: name.slice(0, boundary),
3378
+ leaf: name.slice(boundary + 2)
3379
+ };
3380
+ }
3381
+ function toolSearchQuery(item) {
3382
+ const fromArgs = parseToolArgs(item.arguments);
3383
+ if (typeof fromArgs.query === "string" && fromArgs.query.trim()) {
3384
+ return fromArgs.query.trim();
3385
+ }
3386
+ const raw = item.raw;
3387
+ if (raw && typeof raw === "object") {
3388
+ const rawArgs = raw.arguments;
3389
+ if (typeof rawArgs === "string" && rawArgs.trim()) {
3390
+ const parsed = tryParseJson(rawArgs);
3391
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
3392
+ const query2 = parsed.query;
3393
+ if (typeof query2 === "string" && query2.trim()) {
3394
+ return query2.trim();
3395
+ }
3396
+ }
3397
+ } else if (rawArgs && typeof rawArgs === "object" && !Array.isArray(rawArgs)) {
3398
+ const query2 = rawArgs.query;
3399
+ if (typeof query2 === "string" && query2.trim()) {
3400
+ return query2.trim();
3401
+ }
3402
+ }
3403
+ }
3404
+ return "";
3405
+ }
3406
+ function parseDisclosedTools(output) {
3407
+ if (output && typeof output === "object" && !Array.isArray(output)) {
3408
+ const tools = output.tools;
3409
+ if (Array.isArray(tools)) {
3410
+ return tools.map((tool) => {
3411
+ if (typeof tool === "string" && tool.trim()) {
3412
+ return splitToolWireName(tool.trim());
3413
+ }
3414
+ if (tool && typeof tool === "object" && typeof tool.name === "string") {
3415
+ const name = tool.name.trim();
3416
+ return name ? splitToolWireName(name) : null;
3417
+ }
3418
+ return null;
3419
+ }).filter((tool) => tool != null);
3420
+ }
3421
+ }
3422
+ const { text } = unwrapMcpOutput(output);
3423
+ const trimmed = text.trim();
3424
+ if (!trimmed) {
3425
+ return null;
3426
+ }
3427
+ if (/^no matching tools found\.?$/i.test(trimmed)) {
3428
+ return [];
3429
+ }
3430
+ const disclosed = trimmed.match(/^disclosed tools:\s*(.+)$/i);
3431
+ if (disclosed?.[1]) {
3432
+ return disclosed[1].split(",").map((part) => part.trim()).filter(Boolean).map(splitToolWireName);
3433
+ }
3434
+ const parsed = tryParseJson(trimmed);
3435
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
3436
+ return parseDisclosedTools(parsed);
3437
+ }
3438
+ return null;
3439
+ }
3440
+ function toolSearchPreview(tools, cancelled) {
3441
+ if (cancelled) {
3442
+ return void 0;
3443
+ }
3444
+ if (!tools) {
3445
+ return "Done";
3446
+ }
3447
+ if (tools.length === 0) {
3448
+ return "No matches";
3449
+ }
3450
+ if (tools.length === 1) {
3451
+ return tools[0].leaf;
3452
+ }
3453
+ const head = tools[0].leaf;
3454
+ return `${tools.length} tools \xB7 ${truncatePreview(head, 28)}`;
3455
+ }
3456
+ function ToolSearchRenderer({ item }) {
3457
+ const query2 = toolSearchQuery(item);
3458
+ const icon = /* @__PURE__ */ jsx10(PackageSearchIcon, { className: ICON_SIZE });
3459
+ const running = item.status === "running";
3460
+ const queryPreview = query2 ? truncatePreview(query2, 64) : "";
3461
+ if (running) {
3462
+ return /* @__PURE__ */ jsxs7(
3463
+ ActivityDisclosure,
3464
+ {
3465
+ icon,
3466
+ iconTone: "running",
3467
+ title: "Looking up tools",
3468
+ running: true,
3469
+ preview: queryPreview ? /* @__PURE__ */ jsx10(RunningPreview, { children: queryPreview }) : /* @__PURE__ */ jsx10(RunningPreview, { children: "Matching capabilities\u2026" }),
3470
+ children: [
3471
+ query2 ? /* @__PURE__ */ jsxs7(BodyNote, { children: [
3472
+ "capability query: ",
3473
+ query2
3474
+ ] }) : null,
3475
+ /* @__PURE__ */ jsx10(PayloadBlock, { label: "Arguments", value: redactSecrets(parseToolArgs(item.arguments)) })
3476
+ ]
3477
+ }
3478
+ );
3479
+ }
3480
+ const { text: outText, isError } = unwrapMcpOutput(item.output);
3481
+ if ((isError || item.status === "failed") && item.status !== "cancelled") {
3482
+ return /* @__PURE__ */ jsxs7(
3483
+ ActivityDisclosure,
3484
+ {
3485
+ icon,
3486
+ iconTone: "failed",
3487
+ title: "Tool lookup failed",
3488
+ failed: true,
3489
+ preview: truncatePreview(outText, 80) || queryPreview || "Lookup failed",
3490
+ children: [
3491
+ query2 ? /* @__PURE__ */ jsxs7(BodyNote, { children: [
3492
+ "capability query: ",
3493
+ query2
3494
+ ] }) : null,
3495
+ /* @__PURE__ */ jsx10(PayloadBlock, { label: "Arguments", value: redactSecrets(parseToolArgs(item.arguments)) }),
3496
+ /* @__PURE__ */ jsx10(PayloadBlock, { label: "Error", value: outText, failed: true })
3497
+ ]
3498
+ }
3499
+ );
3500
+ }
3501
+ const tools = parseDisclosedTools(item.output);
3502
+ const preview = toolSearchPreview(tools, item.status === "cancelled");
3503
+ return /* @__PURE__ */ jsxs7(
3504
+ ActivityDisclosure,
3505
+ {
3506
+ icon,
3507
+ iconTone: "muted",
3508
+ title: "Looked up tools",
3509
+ cancelled: item.status === "cancelled",
3510
+ preview,
3511
+ children: [
3512
+ query2 ? /* @__PURE__ */ jsxs7(BodyNote, { children: [
3513
+ "capability query: ",
3514
+ query2
3515
+ ] }) : null,
3516
+ tools && tools.length > 0 ? /* @__PURE__ */ jsxs7("ul", { className: "grid gap-1.5", children: [
3517
+ tools.slice(0, 12).map((tool) => /* @__PURE__ */ jsxs7("li", { className: "flex min-w-0 items-baseline gap-2", children: [
3518
+ tool.source ? /* @__PURE__ */ jsx10("span", { className: "shrink-0 text-og-xs text-og-fg-subtle", children: tool.source }) : null,
3519
+ /* @__PURE__ */ jsx10("span", { className: "truncate font-mono text-og-sm text-og-fg", children: tool.leaf })
3520
+ ] }, tool.name)),
3521
+ tools.length > 12 ? /* @__PURE__ */ jsxs7("li", { className: "text-og-xs text-og-fg-muted", children: [
3522
+ "+",
3523
+ tools.length - 12,
3524
+ " more"
3525
+ ] }) : null
3526
+ ] }) : tools && tools.length === 0 ? /* @__PURE__ */ jsx10(BodyNote, { children: "no deferred tools matched this capability query." }) : null,
3527
+ /* @__PURE__ */ jsx10(PayloadBlock, { label: "Arguments", value: redactSecrets(parseToolArgs(item.arguments)) }),
3528
+ tools == null && outText ? /* @__PURE__ */ jsx10(PayloadBlock, { label: "Result", value: outText }) : null
3529
+ ]
3530
+ }
3531
+ );
3532
+ }
3369
3533
  function DocsSearchRenderer({ item }) {
3370
3534
  const args = parseToolArgs(item.arguments);
3371
3535
  const query2 = typeof args.query === "string" ? args.query.trim() : "";
@@ -3766,7 +3930,7 @@ function truncatePreview(text, max) {
3766
3930
  }
3767
3931
  function GenericToolIcon({ name }) {
3768
3932
  const leaf = mcpToolLeaf(name);
3769
- const Icon = leaf === "request_human_input" ? MessageCircleQuestionIcon2 : leaf.startsWith("goal_") ? TargetIcon : leaf.startsWith("memory_") || leaf === "preference_registry_summary" || leaf === "preference_registry_get" ? BrainCircuitIcon : leaf.startsWith("session_") || leaf === "sessions_list" || leaf === "set_session_title" || leaf === "set_other_session_title" ? MessagesSquareIcon : leaf.startsWith("sandbox") || leaf === "sandboxes_list" || leaf === "run_on" ? ServerIcon : leaf.startsWith("rig_") ? ServerCogIcon : leaf.startsWith("scheduled_") ? CalendarClockIcon : leaf.startsWith("artifacts_") ? PanelsTopLeftIcon : leaf.startsWith("social_") ? Share2Icon : leaf.startsWith("slack_") ? MessageSquareIcon : leaf.startsWith("github_") ? FolderGitIcon : leaf.startsWith("variable_") ? BoxIcon : leaf.startsWith("environment_") ? KeyRoundIcon : leaf.includes("document") || leaf.includes("knowledge") || leaf === "list_document_bases" ? FileSearchIcon : leaf === "tool_search" || leaf === "load_skill" ? PlugIcon : WrenchIcon;
3933
+ const Icon = leaf === "request_human_input" ? MessageCircleQuestionIcon2 : leaf.startsWith("goal_") ? TargetIcon : leaf.startsWith("memory_") || leaf === "preference_registry_summary" || leaf === "preference_registry_get" ? BrainCircuitIcon : leaf.startsWith("session_") || leaf === "sessions_list" || leaf === "set_session_title" || leaf === "set_other_session_title" ? MessagesSquareIcon : leaf.startsWith("sandbox") || leaf === "sandboxes_list" || leaf === "run_on" ? ServerIcon : leaf.startsWith("rig_") ? ServerCogIcon : leaf.startsWith("scheduled_") ? CalendarClockIcon : leaf.startsWith("artifacts_") ? PanelsTopLeftIcon : leaf.startsWith("social_") ? Share2Icon : leaf.startsWith("slack_") ? MessageSquareIcon : leaf.startsWith("github_") ? FolderGitIcon : leaf.startsWith("variable_") ? BoxIcon : leaf.startsWith("environment_") ? KeyRoundIcon : leaf.includes("document") || leaf.includes("knowledge") || leaf === "list_document_bases" ? FileSearchIcon : leaf === "tool_search" ? PackageSearchIcon : leaf === "load_skill" ? PlugIcon : WrenchIcon;
3770
3934
  return /* @__PURE__ */ jsx10(Icon, { className: ICON_SIZE });
3771
3935
  }
3772
3936
  var BASE_ENTRIES = [
@@ -3775,6 +3939,7 @@ var BASE_ENTRIES = [
3775
3939
  { match: "rawType", type: "apply_patch_call", render: ApplyPatchRenderer },
3776
3940
  { match: "rawType", type: "computer_call", render: ComputerCallRenderer },
3777
3941
  { match: "rawType", type: "hosted_tool_call", render: WebSearchRenderer },
3942
+ { match: "rawType", type: "tool_search_call", render: ToolSearchRenderer },
3778
3943
  // First-party sandbox + MCP tools resolve by name (exact or MCP leaf).
3779
3944
  { match: "name", name: "exec_command", render: ExecRenderer },
3780
3945
  { match: "name", name: "request_human_input", render: AskRenderer },
@@ -3793,6 +3958,7 @@ var BASE_ENTRIES = [
3793
3958
  { match: "name", name: "computer_keypress", render: ComputerCallRenderer },
3794
3959
  { match: "name", name: "computer_drag", render: ComputerCallRenderer },
3795
3960
  { match: "name", name: "web_search_call", render: WebSearchRenderer },
3961
+ { match: "name", name: "tool_search", render: ToolSearchRenderer },
3796
3962
  { match: "name", name: "view_image", render: ViewImageRenderer },
3797
3963
  { match: "name", name: "environment_set_variable", render: SecretSetRenderer },
3798
3964
  { match: "name", name: "variable_set_set_variable", render: SecretSetRenderer },
@@ -7631,4 +7797,4 @@ export {
7631
7797
  MessageTimeline,
7632
7798
  TimelineRow
7633
7799
  };
7634
- //# sourceMappingURL=chunk-KG5F2OKE.js.map
7800
+ //# sourceMappingURL=chunk-YNYIAYXQ.js.map