{"version":3,"file":"ComposerPrompt.mjs","names":[],"sources":["../../../../src/web/features/session/ComposerPrompt.tsx"],"sourcesContent":["import { useStore } from '@tanstack/react-store';\nimport { useEffect } from 'react';\n\nimport { toolMessageProps } from '../../lib/toolMessageProps';\nimport type { ComposerPromptClaim } from '../../lib/toolPrompt';\nimport { ToolRendererBoundary } from '../../lib/ToolRendererBoundary';\nimport { answerDialogValue, cancelDialog, sessionStoreFor } from '../../stores/sessionStore';\nimport { markToolPromptFailed } from '../../stores/toolPromptStore';\nimport { usePluginSlotProps } from '../../stores/usePluginSlotProps';\n\n/**\n * Hands the request back after a prompt threw. Rendered rather than called,\n * because the boundary reports the failure during a render and the store may\n * only be written after it, in an effect.\n */\nfunction PromptSurrendered({ dialogId }: { dialogId: string }) {\n  useEffect(() => markToolPromptFailed(dialogId), [dialogId]);\n  return null;\n}\n\n/**\n * The composer's stand-in while a running tool holds the agent's question.\n *\n * The plugin owns everything inside; the host only binds the two ways to\n * settle the request and catches a throw. A renderer that fails gives the\n * request up rather than leaving the reader with the only surface that could\n * answer it showing nothing, and the host's dialog opens on the next frame.\n */\nexport function ComposerPrompt({ claim, sessionId }: { claim: ComposerPromptClaim; sessionId: string | null }) {\n  const statuses = useStore(sessionStoreFor(sessionId), (state) => state.statuses);\n  const slotProps = usePluginSlotProps(sessionId);\n  const actions = {\n    dialog: claim.dialog,\n    answer: (value: string) => answerDialogValue(claim.dialog.id, value, sessionId),\n    cancel: () => cancelDialog(claim.dialog.id, sessionId),\n  };\n  const prompt = claim.entry ? (\n    <claim.prompt.component {...toolMessageProps(slotProps, claim.entry, statuses)} {...actions} />\n  ) : (\n    <claim.prompt.component {...slotProps} {...actions} />\n  );\n  return (\n    <ToolRendererBoundary key={claim.dialog.id} toolName={claim.entry?.name ?? 'dialog'}>\n      {(failed) =>\n        failed ? (\n          <PromptSurrendered dialogId={claim.dialog.id} />\n        ) : (\n          <div data-testid=\"composer-prompt\" data-tool-name={claim.entry?.name} className=\"flex min-h-0 flex-col\">\n            {prompt}\n          </div>\n        )\n      }\n    </ToolRendererBoundary>\n  );\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAS,kBAAkB,EAAE,YAAkC;CAC7D,gBAAgB,qBAAqB,QAAQ,GAAG,CAAC,QAAQ,CAAC;CAC1D,OAAO;AACT;;;;;;;;;AAUA,SAAgB,eAAe,EAAE,OAAO,aAAuE;CAC7G,MAAM,WAAW,SAAS,gBAAgB,SAAS,IAAI,UAAU,MAAM,QAAQ;CAC/E,MAAM,YAAY,mBAAmB,SAAS;CAC9C,MAAM,UAAU;EACd,QAAQ,MAAM;EACd,SAAS,UAAkB,kBAAkB,MAAM,OAAO,IAAI,OAAO,SAAS;EAC9E,cAAc,aAAa,MAAM,OAAO,IAAI,SAAS;CACvD;CACA,MAAM,SAAS,MAAM,QACnB,oBAAC,MAAM,OAAO,WAAd;EAAwB,GAAI,iBAAiB,WAAW,MAAM,OAAO,QAAQ;EAAG,GAAI;CAAU,CAAA,IAE9F,oBAAC,MAAM,OAAO,WAAd;EAAwB,GAAI;EAAW,GAAI;CAAU,CAAA;CAEvD,OACE,oBAAC,sBAAD;EAA4C,UAAU,MAAM,OAAO,QAAQ;EACvE,WAAA,WACA,SACE,oBAAC,mBAAD,EAAmB,UAAU,MAAM,OAAO,GAAK,CAAA,IAE/C,oBAAC,OAAD;GAAK,eAAY;GAAkB,kBAAgB,MAAM,OAAO;GAAM,WAAU;GAC7E,UAAA;EACE,CAAA;CAGW,GAVK,MAAM,OAAO,EAUlB;AAE1B"}