dorkos 0.115.0 → 0.116.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.
- package/dist/bin/cli.js +130 -69
- package/dist/browser/native/package-manifest.json +1 -1
- package/dist/browser/source-manifest.json +1 -1
- package/dist/client/assets/{AboutPage-Cz8ijNrK.js → AboutPage-KW-6Y7Wm.js} +1 -1
- package/dist/client/assets/{ActivityErrorState-BzmfwxSZ.js → ActivityErrorState-C5xbcrFo.js} +1 -1
- package/dist/client/assets/{ActivityPage-BK7T3OiI.js → ActivityPage-DIeicP6l.js} +1 -1
- package/dist/client/assets/{ActivityRow-Ig5atv15.js → ActivityRow-Drxrnyea.js} +1 -1
- package/dist/client/assets/{AdapterIcon-BXPv5J8h.js → AdapterIcon-BEuzKbC6.js} +1 -1
- package/dist/client/assets/{AdapterSetupWizard-BEziztL3.js → AdapterSetupWizard-z_agWfDl.js} +2 -2
- package/dist/client/assets/{AgentOptionRow-BqFQvFeN.js → AgentOptionRow-DEwQwnKr.js} +1 -1
- package/dist/client/assets/{AgentPicker-dCfEIsU-.js → AgentPicker-CmyF25Oi.js} +1 -1
- package/dist/client/assets/{AgentRequestCard-BAhfGJxx.js → AgentRequestCard-BWtE34Nr.js} +3 -3
- package/dist/client/assets/{AppearancePage-7qHhFeEv.js → AppearancePage-BJO-Q3a4.js} +1 -1
- package/dist/client/assets/{ApplyToOverridesDialog-jqOFh0d1.js → ApplyToOverridesDialog-CsmbPbTh.js} +1 -1
- package/dist/client/assets/{AttentionSignalRow-3CgglXkd.js → AttentionSignalRow-2-aDCEdR.js} +1 -1
- package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-BMKtHI0D.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-CL7e4dO8.js} +1 -1
- package/dist/client/assets/{BindingDialog-DSBxRyzA.js → BindingDialog-CirNTa_m.js} +1 -1
- package/dist/client/assets/{BlintzCanvas-CyRuqAJV.js → BlintzCanvas-bfmQpoVE.js} +1 -1
- package/dist/client/assets/{CanvasCsvContent-Bd1c6TGx.js → CanvasCsvContent-x86ueAZo.js} +1 -1
- package/dist/client/assets/{CanvasFileContent-DelYwSH8.js → CanvasFileContent-DIQbKII9.js} +2 -2
- package/dist/client/assets/{CanvasModel3dContent-BExIu4RY.js → CanvasModel3dContent-DTAWG8IS.js} +2 -2
- package/dist/client/assets/{ChatAppsOff-SWemSaUp.js → ChatAppsOff-BQiTfHe3.js} +1 -1
- package/dist/client/assets/{CodeMirrorDiff-0WF4ITRZ.js → CodeMirrorDiff-DhNTAsQl.js} +1 -1
- package/dist/client/assets/{CodeMirrorEditor-Bg7wC_Q8.js → CodeMirrorEditor-BpIF0kLM.js} +1 -1
- package/dist/client/assets/{CommitmentList-CTvEGUV3.js → CommitmentList-B-B3E6yN.js} +1 -1
- package/dist/client/assets/{CommitmentsPage-C68etoLe.js → CommitmentsPage-BNoKIW7z.js} +1 -1
- package/dist/client/assets/ComputerResourceView-NMA65a8a.js +6 -0
- package/dist/client/assets/ComputerViewer-BjU1hfpc.js +1 -0
- package/dist/client/assets/{ConnectionAccessLists-9oeVn_GK.js → ConnectionAccessLists-Iy_T25Rw.js} +1 -1
- package/dist/client/assets/{ConnectionsPage-CJOY4-kp.js → ConnectionsPage-DPfoPshS.js} +2 -2
- package/dist/client/assets/{ConventionPage-DD-f5o6y.js → ConventionPage-CoLB6WVs.js} +1 -1
- package/dist/client/assets/{ExtensionPageRoute-C6fW17AG.js → ExtensionPageRoute-Y_Na63mr.js} +2 -2
- package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-Zccd0fv6.js → FloatingTanStackRouterDevtools-CqogiFob-DCj2Id-d.js} +1 -1
- package/dist/client/assets/HandlePage-WyPrFOtj.js +1 -0
- package/dist/client/assets/{HeartbeatPage-cJM6NuTD.js → HeartbeatPage-zzL8W_zA.js} +1 -1
- package/dist/client/assets/{KeyEntry-K5k_3TfU.js → KeyEntry-DCATqdIG.js} +2 -2
- package/dist/client/assets/{LexicalField-DB5V20zv.js → LexicalField-B7d9UWFk.js} +1 -1
- package/dist/client/assets/{ManagesPage-Cj0-hwfr.js → ManagesPage-CKTb1w3G.js} +1 -1
- package/dist/client/assets/{Marketplace-eWEtLmd9.js → Marketplace-Deq-aTM6.js} +2 -2
- package/dist/client/assets/{MarketplaceSourcesView-B1h70C20.js → MarketplaceSourcesView-B2qLtCVG.js} +1 -1
- package/dist/client/assets/{McpAppFrame-BaJ_r-QR.js → McpAppFrame-BKgYSUH-.js} +1 -1
- package/dist/client/assets/{McpSigninBody-Coaq5Fkf.js → McpSigninBody-Begd1UNn.js} +1 -1
- package/dist/client/assets/{Model3dViewer-cKa-Jnbl.js → Model3dViewer-CK6siI6q.js} +1 -1
- package/dist/client/assets/NamePage-DxDcIFAo.js +1 -0
- package/dist/client/assets/{NewDirectMessageMenu-C4zNIv9x.js → NewDirectMessageMenu-D4ORE1Lo.js} +1 -1
- package/dist/client/assets/{NotificationsPage-gKNClvNU.js → NotificationsPage-CjRyxKXv.js} +1 -1
- package/dist/client/assets/{OpenMeshSwitch-RzB2u6-Q.js → OpenMeshSwitch-C0C-f-dF.js} +2 -2
- package/dist/client/assets/{OperatorIdentityForm-B_78Vqh8.js → OperatorIdentityForm-I9zvI2go.js} +1 -1
- package/dist/client/assets/{PermissionHistory-DrtlA4YM.js → PermissionHistory-C9vTiyw5.js} +1 -1
- package/dist/client/assets/{PermissionsPage-O7kUVaQv.js → PermissionsPage-BR9LM1Bo.js} +1 -1
- package/dist/client/assets/{PersonalityPopover-DiNuuoWu.js → PersonalityPopover-BhFUSfRe.js} +1 -1
- package/dist/client/assets/PhotoPage-C4OhoBR2.js +1 -0
- package/dist/client/assets/{PresetPicker-BUFwg8RS.js → PresetPicker-CpTnkeZt.js} +3 -3
- package/dist/client/assets/{PreviewRefusedNotice-DXZp669C.js → PreviewRefusedNotice-R5LB9PuV.js} +1 -1
- package/dist/client/assets/{ProfileFields-BCfMzNcT.js → ProfileFields-8fFud5gT.js} +1 -1
- package/dist/client/assets/{ProfilePanelContainer-BzC2MGdi.js → ProfilePanelContainer-BJFOrUov.js} +1 -1
- package/dist/client/assets/{ProfileRolePicker-f0FKXLtu.js → ProfileRolePicker-C8hpW08c.js} +1 -1
- package/dist/client/assets/{PromptSuggestionChips-EgeMFibt.js → PromptSuggestionChips-1su17rvx.js} +1 -1
- package/dist/client/assets/{ReportsToPopover-CQ4Xxslu.js → ReportsToPopover-7H3_8Brz.js} +1 -1
- package/dist/client/assets/{RoomSurface-oDbc6jnO.js → RoomSurface-BkoesTVz.js} +5 -5
- package/dist/client/assets/{RoomsPage-D_EbiSZ3.js → RoomsPage-BrMOJQpt.js} +1 -1
- package/dist/client/assets/{RunsOnPopover-LtmmbIsD.js → RunsOnPopover-BB7T1Zln.js} +1 -1
- package/dist/client/assets/{RuntimeConnectFlow-Kv2ytk2m.js → RuntimeConnectFlow-oHwqp_fn.js} +1 -1
- package/dist/client/assets/{RuntimeSetupDialog-CiWxlcPc.js → RuntimeSetupDialog-BTT2-FM8.js} +1 -1
- package/dist/client/assets/{SessionsPage-1rDO0SGV.js → SessionsPage-PpKG9Phd.js} +1 -1
- package/dist/client/assets/{SettingsDialog-_ctp2AfE.js → SettingsDialog-Dxtq0E9R.js} +4 -4
- package/dist/client/assets/{SkillsPage-gPuQHKps.js → SkillsPage-CzzuhGH2.js} +1 -1
- package/dist/client/assets/{TaskDialogWrapper-BPFpCgsN.js → TaskDialogWrapper-DWVo-1P7.js} +1 -1
- package/dist/client/assets/{TasksEmptyState-D0Jlzmed.js → TasksEmptyState-DfR9p54p.js} +2 -2
- package/dist/client/assets/{TasksPage-DvGfg5Bk.js → TasksPage-5_XngIV9.js} +1 -1
- package/dist/client/assets/TeamComputerEntry-BE_gamkp.js +1 -0
- package/dist/client/assets/{ToolsPage-B0qZ85pR.js → ToolsPage-CefworrO.js} +2 -2
- package/dist/client/assets/{TopologyGraph-q1ammgpG.js → TopologyGraph-C1DaL02H.js} +2 -2
- package/dist/client/assets/{TourHost-Dc8qw1Ef.js → TourHost-pT1tIPF7.js} +1 -1
- package/dist/client/assets/{UnlinkDialog-DXdrLsGV.js → UnlinkDialog-oMOr8e6G.js} +1 -1
- package/dist/client/assets/{WidgetErrorCard-ChDNC060.js → WidgetErrorCard-CBFo1SMe.js} +7 -7
- package/dist/client/assets/_shell-BiAMGu0F.js +90 -0
- package/dist/client/assets/{_shell._home-DjGunhLV.js → _shell._home-Cx7ZsoQO.js} +1 -1
- package/dist/client/assets/{_shell._home.activity-B014dET1.js → _shell._home.activity-C3fnNXgc.js} +1 -1
- package/dist/client/assets/{_shell._home.index-DEmtTHZg.js → _shell._home.index-CixksaeD.js} +2 -2
- package/dist/client/assets/{_shell._home.tasks-CnDEbUOd.js → _shell._home.tasks-DZWUHfK_.js} +1 -1
- package/dist/client/assets/{_shell._home.workspaces-AQtMUWuu.js → _shell._home.workspaces-y-DAPB_X.js} +1 -1
- package/dist/client/assets/{_shell.channels-C8NOhmJd.js → _shell.channels-DEErD0f0.js} +4 -4
- package/dist/client/assets/{_shell.connections-Bxe0wxOB.js → _shell.connections-B36f6FWi.js} +1 -1
- package/dist/client/assets/{_shell.feedback-requests-C6ku9F5_.js → _shell.feedback-requests-B0QiSuDC.js} +2 -2
- package/dist/client/assets/_shell.marketplace-CardBSA_.js +1 -0
- package/dist/client/assets/_shell.marketplace_.sources-CVK8YKDA.js +1 -0
- package/dist/client/assets/{_shell.session-Dn0C0mEZ.js → _shell.session-Cl7qfi1Z.js} +3 -3
- package/dist/client/assets/_shell.team-DIdgc_vn.js +28 -0
- package/dist/client/assets/_shell.x._extensionId-BEPW8hvh.js +1 -0
- package/dist/client/assets/_shell.x._extensionId_._-BEPW8hvh.js +1 -0
- package/dist/client/assets/{access-copy-CBGtcTk0.js → access-copy-CE5oc1d9.js} +1 -1
- package/dist/client/assets/{agent-browser-DbcLtsAx.js → agent-browser-DV76U8Ny.js} +1 -1
- package/dist/client/assets/{banner-rPsz3suJ.js → banner-DIVQNO0O.js} +1 -1
- package/dist/client/assets/{card-BqN3lfJn.js → card-DVdPY08b.js} +1 -1
- package/dist/client/assets/{command-ZTLTCj0l.js → command-BhZ8sKG4.js} +1 -1
- package/dist/client/assets/{cpu-D70xMHl2.js → cpu-CtmIFRqs.js} +1 -1
- package/dist/client/assets/{empty-state-yl1dLwLN.js → empty-state-DHuumxZB.js} +1 -1
- package/dist/client/assets/{execution-config-BbBEe6FO.js → execution-config-JdnxoV1P.js} +1 -1
- package/dist/client/assets/{file-CGg2M6ED.js → file-Bc34j1rj.js} +1 -1
- package/dist/client/assets/{file-exclamation-point-DZrVsShR.js → file-exclamation-point-dxJUSR3k.js} +1 -1
- package/dist/client/assets/{file-text-BYq_4IAt.js → file-text-BNSVr0Hh.js} +1 -1
- package/dist/client/assets/{find-latest-widget-fence-CWs9nr10.js → find-latest-widget-fence-oI6Sl7rV.js} +1 -1
- package/dist/client/assets/{form-vPuXuaYT.js → form-FbjLEM3I.js} +1 -1
- package/dist/client/assets/{format-cron-D02Tnupo.js → format-cron-BaE7qyNN.js} +1 -1
- package/dist/client/assets/{git-branch-DbjXDO_F.js → git-branch-BBKObhlk.js} +1 -1
- package/dist/client/assets/{heart-Dblp_miM.js → heart-BdbxexAy.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-CaMXMak-.js → highlighted-body-KPVGNVTW-R3x8mG02.js} +1 -1
- package/dist/client/assets/{index-vRc1D4KI.js → index-0AgY877T.js} +1 -1
- package/dist/client/assets/{index-D16KF-iC.js → index-1-RB7sXm.js} +3 -3
- package/dist/client/assets/{index-BW98owO8.js → index-4irOzx9Q.js} +1 -1
- package/dist/client/assets/{index-P5j6zmcN.js → index-6ZmBCm_d.js} +1 -1
- package/dist/client/assets/{index-DzeYt-GT.js → index-7xf1fyHe.js} +1 -1
- package/dist/client/assets/{index-BxqUb-n7.js → index-BCT0tkN4.js} +1 -1
- package/dist/client/assets/{index-BKuzoeSn.js → index-BFh_VGhh.js} +1 -1
- package/dist/client/assets/{index-B-WvQ24u.js → index-BKnIV8YQ.js} +6 -6
- package/dist/client/assets/{index-D6m2SWHr.js → index-BQgJVNUB.js} +1 -1
- package/dist/client/assets/{index-BiIbMZ6d.js → index-BV0RP90y.js} +1 -1
- package/dist/client/assets/{index-BV0tZnYg.js → index-BWHsw5Qn.js} +1 -1
- package/dist/client/assets/{index-CMWMhbec.js → index-BbUZazTt.js} +1 -1
- package/dist/client/assets/{index-CWNsRK97.js → index-BcPMhqQ_.js} +1 -1
- package/dist/client/assets/{index-DwUdUliR.js → index-BeKz0Z7i.js} +1 -1
- package/dist/client/assets/index-C481yCZ2.js +1 -0
- package/dist/client/assets/{index-Db2EOzA3.js → index-C4vL5hUU.js} +1 -1
- package/dist/client/assets/{index-DDYi817r.js → index-C5n3OkTH.js} +1 -1
- package/dist/client/assets/{index-Z8YcKwIB.js → index-C76UofV4.js} +1 -1
- package/dist/client/assets/index-CB-aY4BF.js +1 -0
- package/dist/client/assets/{index-CN9fywRC.js → index-CDx26Vyr.js} +1 -1
- package/dist/client/assets/{index-Dg_bax15.js → index-CJW9tZhq.js} +5 -5
- package/dist/client/assets/{index-BPwUl0Bz.js → index-CJw16oEF.js} +1 -1
- package/dist/client/assets/{index-CaLw69VE.js → index-C_Pquyu-.js} +1 -1
- package/dist/client/assets/{index-Gq3gqBhY.js → index-CpAdYUxX.js} +1 -1
- package/dist/client/assets/{index-XE46wAj9.js → index-D1bAoT3D.js} +1 -1
- package/dist/client/assets/{index-Bd23EYYT.js → index-D7MytHQN.js} +2 -2
- package/dist/client/assets/index-DKubbEZd.css +1 -0
- package/dist/client/assets/{index-BOL391En.js → index-DShpGK7T.js} +1 -1
- package/dist/client/assets/{index-C88NZagl.js → index-DlWFe9SD.js} +1 -1
- package/dist/client/assets/{index-oWLYcpm4.js → index-DluIa1Dv.js} +1 -1
- package/dist/client/assets/index-Dm1Ngy2r.js +38 -0
- package/dist/client/assets/{index-CdKpQ1hI.js → index-DxTOTFWT.js} +280 -280
- package/dist/client/assets/{index-lNMJBFB0.js → index-DzRQN8yx.js} +1 -1
- package/dist/client/assets/index-Fl8NxGfN.js +119 -0
- package/dist/client/assets/{index-CrK4rKAq.js → index-fe27h49h.js} +1 -1
- package/dist/client/assets/{index-DdbHrvr0.js → index-hIJdyL6m.js} +1 -1
- package/dist/client/assets/{index-BPqkuMIa.js → index-hLWqos0I.js} +1 -1
- package/dist/client/assets/{index-CRZXSh_q.js → index-pKhRsSRA.js} +1 -1
- package/dist/client/assets/{index-CHvi6xUU.js → index-sRPmoNhi.js} +1 -1
- package/dist/client/assets/{index-BdVOtoFr.js → index-tPf4Bia7.js} +1 -1
- package/dist/client/assets/{index-Bi7Um5RU.js → index-vHt--4jg.js} +1 -1
- package/dist/client/assets/{inline-code-Cvn43Gqu.js → inline-code-CrAiSiKW.js} +1 -1
- package/dist/client/assets/{layers-Bmz62WF4.js → layers-QYiauDIw.js} +1 -1
- package/dist/client/assets/{lightbulb-CAd6slmc.js → lightbulb-Dc3wEED9.js} +1 -1
- package/dist/client/assets/{link-2-C0mn8T24.js → link-2-BUnfBMCd.js} +1 -1
- package/dist/client/assets/{list-runtime-types-DxwGcKLx.js → list-runtime-types-H-N7VUS4.js} +1 -1
- package/dist/client/assets/{markdown-content-1-B7PdbY.js → markdown-content-fIydDTfa.js} +1 -1
- package/dist/client/assets/{mention-pill-D_-KXznh.js → mention-pill-CONiQ9Xs.js} +1 -1
- package/dist/client/assets/{message-square-off-Di7kQvfe.js → message-square-off-BMD4bxOr.js} +1 -1
- package/dist/client/assets/{more-details-C6UGVeDE.js → more-details-DMD6Pqb5.js} +1 -1
- package/dist/client/assets/{owner-notice-CudDDBX4.js → owner-notice-BRcpYvJk.js} +1 -1
- package/dist/client/assets/{package-D2eMoFCI.js → package-CGgpgsfC.js} +1 -1
- package/dist/client/assets/{page-container-CDHAACRA.js → page-container-uyGtbP6Z.js} +1 -1
- package/dist/client/assets/{paperclip-p0W24D54.js → paperclip-CUxIVlMU.js} +1 -1
- package/dist/client/assets/{path-input-j04LMj9z.js → path-input-CeMu6ytc.js} +1 -1
- package/dist/client/assets/{primer-trigger-DkCcHf2Q.js → primer-trigger-x8IfRd6U.js} +2 -2
- package/dist/client/assets/{profile-errors-CqflLCzu.js → profile-errors-DyrpY2ry.js} +1 -1
- package/dist/client/assets/{progress-BcuH4Eod.js → progress-2cuTo9I-.js} +1 -1
- package/dist/client/assets/{query-error-state-CEZs7dhg.js → query-error-state-Cq1O4FGq.js} +1 -1
- package/dist/client/assets/{radio-DGWfQ5Rf.js → radio-H5ktIFzD.js} +1 -1
- package/dist/client/assets/registry-DNRE0Em-.js +1 -0
- package/dist/client/assets/{relay-trace-schemas-y0nd8fzi.js → relay-trace-schemas-Crc4Iceb.js} +2 -2
- package/dist/client/assets/{room-files-source-C1TCg4W_.js → room-files-source-thCvGi0E.js} +2 -2
- package/dist/client/assets/{rotate-ccw-clock-DcBojy-0.js → rotate-ccw-clock-DKP7zbQr.js} +1 -1
- package/dist/client/assets/{rotate-cw-D0vUyeR2.js → rotate-cw-Cwv_uaU3.js} +1 -1
- package/dist/client/assets/{scroll-area-CQ9lO56h.js → scroll-area-CaJ1TwhG.js} +1 -1
- package/dist/client/assets/{search-x-EJGj73JB.js → search-x-D-Un20jR.js} +2 -2
- package/dist/client/assets/{shield-check-Bp58y9u7.js → shield-check-CMhrOu-d.js} +1 -1
- package/dist/client/assets/{shield-x-jF_NCCvp.js → shield-x-DlaUufPM.js} +1 -1
- package/dist/client/assets/{soul-file-Cag2i87x.js → soul-file-C5-nKCwV.js} +1 -1
- package/dist/client/assets/{table-D89CWVJX.js → table-C7pi-jkJ.js} +1 -1
- package/dist/client/assets/{terminal-BUhNMZAt.js → terminal-IYkyS2eR.js} +1 -1
- package/dist/client/assets/{trust-posture-15DMDZTA.js → trust-posture-BxFTuKAo.js} +1 -1
- package/dist/client/assets/{unplug-opnrSXAi.js → unplug-Bv5BESa4.js} +1 -1
- package/dist/client/assets/{unverified-catalog-notice-DHM5Coia.js → unverified-catalog-notice-B9dzvyVq.js} +1 -1
- package/dist/client/assets/{use-adapter-catalog-ClMqVelU.js → use-adapter-catalog-DDD8zCQo.js} +1 -1
- package/dist/client/assets/{use-bindings-Ch6UUBvz.js → use-bindings-BXHWfTB2.js} +1 -1
- package/dist/client/assets/{use-composer-prefs-Qn7KRpYe.js → use-composer-prefs-DG8dQD3D.js} +1 -1
- package/dist/client/assets/{use-connector-management-dX_4x0d3.js → use-connector-management-l6Ii6UIU.js} +1 -1
- package/dist/client/assets/{use-deep-link-scroll-BV2fY4gy.js → use-deep-link-scroll-CPgyWLMM.js} +1 -1
- package/dist/client/assets/{use-delete-binding-BklxjB_c.js → use-delete-binding-NPl-TzUw.js} +1 -1
- package/dist/client/assets/{use-dev-links-D4Bqam6F.js → use-dev-links-DYaUSRn0.js} +1 -1
- package/dist/client/assets/{use-external-adapter-catalog-nHiD8BKZ.js → use-external-adapter-catalog-BrmKSNvG.js} +1 -1
- package/dist/client/assets/{use-full-activity-feed-vYU7wQWT.js → use-full-activity-feed-CEvmRK6d.js} +1 -1
- package/dist/client/assets/use-is-below-desktop-Cx2BL1BK.js +1 -0
- package/dist/client/assets/{use-jump-back-in-BVunjzyr.js → use-jump-back-in-BMgpYhK-.js} +2 -2
- package/dist/client/assets/{use-mesh-topology-NaUKSKol.js → use-mesh-topology-D82_pOi9.js} +1 -1
- package/dist/client/assets/{use-mounted-ref-BWpQ8f91.js → use-mounted-ref-Bs5osknq.js} +1 -1
- package/dist/client/assets/{use-notification-prefs-qO1zRRFN.js → use-notification-prefs-Bpzt57w3.js} +1 -1
- package/dist/client/assets/{use-panel-tab-placements-Db6p2vLD.js → use-panel-tab-placements-COBgt4Uh.js} +1 -1
- package/dist/client/assets/use-pending-read-DpJbidPK.js +1 -0
- package/dist/client/assets/{use-personality-commit-DUEKxHt_.js → use-personality-commit-D8Fqsrzc.js} +1 -1
- package/dist/client/assets/{use-promo-activation-CnGaw39P.js → use-promo-activation-sHnkQjl-.js} +2 -2
- package/dist/client/assets/{use-promo-dismissals-bkSHhGhj.js → use-promo-dismissals-BW_429t4.js} +1 -1
- package/dist/client/assets/{use-pulse-freshness-Oc_1gs-Y.js → use-pulse-freshness-BkYMwuUb.js} +1 -1
- package/dist/client/assets/{use-relay-config-Ba-S4wxY.js → use-relay-config-CsB8Q0cK.js} +1 -1
- package/dist/client/assets/{use-room-follow-claim-DqE5b95Z.js → use-room-follow-claim-DqvqzwBA.js} +1 -1
- package/dist/client/assets/{use-roving-tab-list-DnMqliqf.js → use-roving-tab-list-iDj1p8tT.js} +1 -1
- package/dist/client/assets/{use-session-canvas-OdljtBE8.js → use-session-canvas-DrKA7UHs.js} +4 -4
- package/dist/client/assets/{use-session-diagnostics-CtjxsM8_.js → use-session-diagnostics-D6wJVzUG.js} +2 -2
- package/dist/client/assets/{use-unclaimed-chats-5RCD5wIp.js → use-unclaimed-chats-bLDQhIiU.js} +1 -1
- package/dist/client/assets/use-update-config-Dk0MthxZ.js +1 -0
- package/dist/client/assets/{useMutationState-Mjr_y4xX.js → useMutationState-eZMPCch6.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/extension-child.cjs +772 -36
- package/dist/server/index.js +5533 -4697
- package/dist/server/index.js.map +2 -2
- package/package.json +6 -5
- package/dist/client/assets/HandlePage-DOxlquWl.js +0 -1
- package/dist/client/assets/NamePage-W7Frb1yy.js +0 -1
- package/dist/client/assets/PhotoPage-DdBke3yj.js +0 -1
- package/dist/client/assets/_shell-BxPza3Lx.js +0 -88
- package/dist/client/assets/_shell.marketplace-CEnzWFmI.js +0 -1
- package/dist/client/assets/_shell.marketplace_.sources-BZq1d2ih.js +0 -1
- package/dist/client/assets/_shell.team-DoLdOMoC.js +0 -28
- package/dist/client/assets/_shell.x._extensionId-DhE3OYMF.js +0 -1
- package/dist/client/assets/_shell.x._extensionId_._-DhE3OYMF.js +0 -1
- package/dist/client/assets/index-BzczIyv5.js +0 -119
- package/dist/client/assets/index-C6NUjpzQ.js +0 -38
- package/dist/client/assets/index-O_HMols_.js +0 -1
- package/dist/client/assets/index-kktlr1TJ.css +0 -1
- package/dist/client/assets/registry-ChxwU0f4.js +0 -1
- package/dist/client/assets/use-is-below-desktop-G-mTu2Ga.js +0 -1
- package/dist/client/assets/use-pending-read-DUqJZUza.js +0 -1
- package/dist/client/assets/use-update-config-xkznZMHr.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{a2 as ee,r as a,
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CJW9tZhq.js","assets/index-DxTOTFWT.js","assets/index-DKubbEZd.css","assets/room-files-source-thCvGi0E.js","assets/markdown-content-fIydDTfa.js","assets/file-exclamation-point-dxJUSR3k.js","assets/composer-insert-BpyATrmR.js","assets/index-sRPmoNhi.js","assets/file-drag-GDx2qhdk.js","assets/rotate-cw-Cwv_uaU3.js","assets/link-2-BUnfBMCd.js","assets/file-Bc34j1rj.js","assets/git-branch-BBKObhlk.js","assets/more-details-DMD6Pqb5.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a2 as ee,r as a,lL as Gt,j as i,g as Qt,hA as Vt,Q as V,a8 as te,a9 as Yt,bs as K,aa as ye,kn as Ke,b0 as ne,lM as oe,lN as Jt,lO as Xt,aQ as Zt,lP as re,lQ as en,lR as tn,ab as le,lS as nn,lT as ke,lU as Ge,lV as sn,lW as on,lX as rn,la as an,lY as ln,lc as cn,lZ as dn,dG as un,fZ as mn,l_ as fn,l$ as pn,a7 as hn,bE as gn,m0 as xn,m1 as yn,iv as bn,hl as vn,hN as Y,jK as Qe,m2 as lt,bU as Rn,jJ as ue,jO as ct,m3 as kn,jP as dt,ap as wn,bY as ut,hg as mt,B as Te,x as Sn,m4 as Nn,ce as Oe,m5 as In,s as fe,es as jn,j7 as ft,m6 as pt,b3 as Cn,e as ae,m7 as be,gT as ht,jN as gt,m8 as An,m9 as Mn,n as En,q as Ie,jM as Tn,ma as xt,eQ as se,ae as yt,fp as On,mb as _n,mc as Pn,md as Dn,me as $n,l as bt,W as _e,jx as Ln,aq as Fn,mf as Bn,mg as qn,mh as zn,be as Hn,c4 as Un,mi as Wn,mj as Kn,mk as Gn,ml as Qn,bF as je,dO as Vn,jD as Yn,jI as Jn,jB as Xn,mm as Zn,mn as es,mo as ts,mp as ns,eP as ss,jE as os,mq as rs,mr as as,ms as is,ho as ls,X as cs,mt as ds,mu as Ve,mv as us,ak as ms,mw as fs,hM as ps,mx as hs,my as gs,aN as Ye}from"./index-DxTOTFWT.js";import{R as xs,A as ys,u as bs,P as vs,a as Rs}from"./use-jump-back-in-BMgpYhK-.js";import{m as Ce,a as Je,f as Pe,b as De,d as vt,e as Rt,g as kt,E as ks,h as ws,i as Ss,M as Q,F as Ns,D as Is,U as js,C as X,u as Cs,j as As,k as Ms}from"./index-BKnIV8YQ.js";import{a as Es}from"./use-room-follow-claim-DqvqzwBA.js";import"./WidgetErrorCard-CBFo1SMe.js";import{M as Ts}from"./markdown-content-fIydDTfa.js";import{W as Os,a as _s}from"./find-latest-widget-fence-oI6Sl7rV.js";import{f as Ps}from"./format-duration-BCr6uzby.js";import{H as Ds,a as $s,b as Ls}from"./RuntimeSetupDialog-BTT2-FM8.js";import{M as Xe}from"./mention-pill-CONiQ9Xs.js";import{R as Fs}from"./rotate-ccw-clock-DKP7zbQr.js";import{U as Bs}from"./unplug-Bv5BESa4.js";import{M as qs}from"./message-square-off-BMD4bxOr.js";import{i as zs}from"./registry-DNRE0Em-.js";import{f as Hs}from"./use-connector-management-l6Ii6UIU.js";import{A as Us}from"./AgentRequestCard-BWtE34Nr.js";/**
|
|
3
3
|
* @license lucide-react v1.48.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
@@ -39,6 +39,6 @@ import{a2 as ee,r as a,lI as Gt,j as i,g as Qt,hv as Vt,Q as V,a8 as te,a9 as Yt
|
|
|
39
39
|
*
|
|
40
40
|
* This source code is licensed under the ISC license.
|
|
41
41
|
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
-
*/const Mt={name:"user-x",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]};Mt.node;const Js=ee(Mt),Xs=300;function ce({className:e,children:t}){return i.jsx("span",{className:V("bg-muted text-muted-foreground text-2xs inline-flex max-w-full items-center gap-1 truncate rounded-full px-2 py-0.5",e),children:t})}function Et({identity:e,children:t,onViewProfile:s,className:n}){const{kind:o,displayName:r,handle:l,color:c,emoji:h,imageUrl:p,origin:u,agent:d}=e,k=c??"hsl(var(--muted-foreground))",f=typeof u=="object"&&u!==null,g=o==="agent"&&(d==null?void 0:d.working)!=null?d.working:null,[y,x]=a.useState(!1),N=a.useRef(!1),m=a.useRef(null),b=Gt({onLongPress:()=>{N.current&&x(!0)}});return i.jsxs(Ds,{open:y,onOpenChange:x,openDelay:Xs,children:[i.jsx($s,{asChild:!0,ref:m,"data-gesture-priority":"",...b,onPointerDown:E=>{N.current=E.pointerType==="touch"||E.pointerType==="pen",b.onPointerDown(E)},children:t}),i.jsxs(Ls,{"data-slot":"identity-hover-card",align:"start",className:V("flex w-64 flex-col gap-0 overflow-hidden p-0",n),children:[i.jsxs("div",{className:"flex items-center gap-3 p-3",children:[i.jsx(Qt,{"aria-hidden":!0,color:k,emoji:h,imageUrl:p,fallback:Vt(r),kind:o,origin:u,status:g?"working":"idle",size:"md"}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-foreground truncate text-sm font-semibold",children:r}),l&&i.jsxs("p",{className:"text-muted-foreground truncate text-xs font-medium",children:["@",l]})]})]}),i.jsxs("div",{className:"flex flex-wrap gap-1.5 px-3 pb-3 empty:hidden",children:[o==="agent"&&((d==null?void 0:d.runtime)||(d==null?void 0:d.model))&&i.jsx(ce,{children:[d.runtime,d.model].filter(Boolean).join(" · ")}),g&&i.jsxs(ce,{className:"bg-status-success-bg text-status-success-fg",children:["Working · ",Ps(g.forMs)]}),o==="human"&&i.jsx(ce,{children:f?u.platform:"On this machine"}),o==="agent"&&(d==null?void 0:d.managedBy)&&i.jsxs(ce,{children:["Managed by"," ",d.managedBy.handle?`@${d.managedBy.handle}`:d.managedBy.displayName]})]}),s?i.jsx("button",{type:"button","data-slot":"identity-hover-card-profile",onClick:()=>{var E;(E=m.current)==null||E.focus(),s()},className:"border-border hover:bg-accent focus-visible:ring-ring text-brand mt-auto flex w-full items-center border-t px-3 py-2 text-left text-xs font-medium transition-colors focus-visible:ring-2 focus-visible:outline-none",children:"View profile"}):i.jsxs("div",{className:"border-border mt-auto flex items-center justify-between border-t px-3 py-2",children:[i.jsx("span",{className:"text-muted-foreground text-xs font-medium",children:"View profile"}),i.jsx("span",{className:"text-muted-foreground text-3xs tracking-wide uppercase",children:"soon"})]})]})]})}function Ot(e,t={}){const s=te();return Yt({queryKey:K.sessions(e??""),queryFn:()=>s.listRoomSessions(e),enabled:e!==null&&t.enabled===!0})}function Zs(e,t){const s=e??[];return s.some(n=>n.seq===t.seq)?s:s.length===0||s[s.length-1].seq<t.seq?[...s,t]:[...s,t].sort((n,o)=>n.seq-o.seq)}function eo(e,t){const s=e??[],n=s.findIndex(c=>c.id===t.id);if(n===-1)return s;const o=s[n];if(o.seq!==t.seq||o.roomId!==t.roomId||JSON.stringify(o.body)===JSON.stringify(t.body)&&JSON.stringify(o.mentions)===JSON.stringify(t.mentions)&&JSON.stringify(o.mentionSpans)===JSON.stringify(t.mentionSpans))return s;const l=[...s];return l[n]={...o,body:t.body,mentions:t.mentions,mentionSpans:t.mentionSpans},l}function to(e,t){if(t.kind!=="notice"||t.body.notice!=="turn_failed")return;const s=t.body.subjectAuthorId;s!==void 0&&re.getState().clearAuthor(e,s)}function no(e,t){const s=e.getQueryData(K.entries(t));return s&&s.length>0?s[s.length-1].seq:0}function so(e,t){var s;return((s=e.getQueryData(K.detail(t)))==null?void 0:s.viewerAuthorId)??null}const oo=2e3;function ro(){const e=a.useRef(null),t=a.useCallback(()=>{e.current!==null&&(clearTimeout(e.current),e.current=null)},[]),s=a.useCallback(o=>{t(),ne.getState().endRoomCanvasCycle(o)},[t]),n=a.useCallback(o=>{t(),e.current=setTimeout(()=>{e.current=null,ne.getState().endRoomCanvasCycle(o)},oo)},[t]);return a.useEffect(()=>t,[t]),{arm:n,now:s}}function ao(e){const t=Math.min(oe.BACKOFF_CAP_MS,oe.BACKOFF_BASE_MS*2**e);return Math.random()*t}const io=50;function lo(e,t){return new Promise(s=>{if(t.aborted)return s();const n=()=>{clearTimeout(o),t.removeEventListener("abort",n),s()},o=setTimeout(n,e);t.addEventListener("abort",n,{once:!0})})}function co(e,t){const s=te(),n=ye(),[o,r]=a.useState(null),[l,c]=a.useState(null),[h,p]=a.useState(0),u=a.useRef(!1),d=ro(),k=a.useCallback(()=>p(y=>y+1),[]),f=a.useRef(null),g=a.useCallback(()=>{f.current===null&&(f.current=setTimeout(()=>{f.current=null,p(y=>y+1)},io))},[]);return a.useEffect(()=>{if(e===null)return;const y=()=>g();let x=null;const N=()=>{if(document.visibilityState!=="visible"){x=Date.now();return}const E=x===null?0:Date.now()-x;x=null,(u.current||E>=oe.VISIBILITY_GRACE_MS)&&g()};let m=Ke.getListConnectionState();const b=Ke.subscribeListConnectionState(E=>{const O=E==="connected"&&m==="reconnecting";m=E,O&&g()});return window.addEventListener("online",y),document.addEventListener("visibilitychange",N),()=>{window.removeEventListener("online",y),document.removeEventListener("visibilitychange",N),b(),f.current!==null&&(clearTimeout(f.current),f.current=null)}},[e,g]),a.useEffect(()=>(ne.getState().setRoomCanvasLiveRoom(e),()=>ne.getState().setRoomCanvasLiveRoom(null)),[e]),a.useEffect(()=>{if(e===null||!t)return;const y=new AbortController;let x=!0,N;return(async()=>{r(null),c(null),u.current=!1;let m=0,b=!1;const E=()=>{m=0,u.current=!1,b&&(b=!1,r(O=>O===e?null:O))};for(;x&&!y.signal.aborted;){const O=Date.now();u.current=!1,ne.getState().beginRoomCanvasCycle(e),d.arm(e);const D=setTimeout(E,oe.STABILITY_WINDOW_MS);let j;try{if(j=Jt(s,e,no(n,e),y.signal),N=j,!x||y.signal.aborted){j.retire();return}for await(const S of j.stream){if(!x||y.signal.aborted||(E(),!j.current()))return;if(S.type==="canvas_event"||S.type==="canvas_channel_snapshot"){if(j.publish(S),!j.current())return;continue}if(S.type==="signal"){Xt(S)?Zt.getState().observe(e,S):(re.getState().observe(e,S),ne.getState().applyRoomCanvasPresence(e,S));continue}if(S.type==="reaction"){n.setQueryData(K.entries(e),_=>Ce(_,S.entryId,S.reactions));continue}if(S.type==="revision"){if(S.entry.roomId!==e)continue;n.setQueryData(K.entries(e),_=>eo(_,S.entry));continue}if(S.type==="canvas"){ne.getState().applyRoomCanvasFrame(e,S,so(n,e)),S.change!==void 0?d.now(e):d.arm(e);continue}re.getState().clearAuthor(e,S.entry.authorId),to(e,S.entry),en.getState().settle(e,S.entry.id),n.setQueryData(K.entries(e),_=>Zs(_,S.entry))}}catch(S){if(y.signal.aborted)return;if(console.warn("[rooms] live stream dropped",{roomId:e,err:S}),tn(S)){re.getState().clearRoom(e),c(e),r(e),clearTimeout(D);return}}finally{try{j==null||j.retire()}finally{clearTimeout(D)}}if(y.signal.aborted)return;Date.now()-O>=oe.STABILITY_WINDOW_MS&&(m=0),m+=1,u.current=!0,m>=oe.DISCONNECTED_THRESHOLD&&!b&&(re.getState().clearRoom(e),r(e),b=!0),await lo(ao(m),y.signal)}})(),()=>{x=!1;try{N==null||N.retire()}finally{y.abort()}}},[e,t,s,n,h]),{stalled:o!==null&&o===e,unavailable:l!==null&&l===e,retry:k}}function uo(){const e=te();return le({mutationFn:({roomId:t,authorId:s})=>e.haltRoomAgent(t,s),meta:{errorLabel:"Couldn’t stop this agent"}})}function mo(){const e=te();return le({mutationFn:({roomId:t,authorId:s})=>e.promoteHold(t,s),meta:{errorLabel:"Couldn’t ask to be answered first"}})}function fo(){const e=te(),t=ye();return le({onMutate:({roomId:s,entryId:n,emoji:o,viewerAuthorId:r})=>{var u;const l=t.getQueryData(K.entries(s)),c=(u=l==null?void 0:l.find(d=>d.id===n))==null?void 0:u.reactions,{reactions:h,on:p}=Je(c,o,r);return t.setQueryData(K.entries(s),d=>Ce(d,n,h)),{on:p}},mutationFn:({roomId:s,entryId:n,emoji:o,viewerAuthorId:r})=>{var h,p;const l=t.getQueryData(K.entries(s)),c=((p=(h=l==null?void 0:l.find(u=>u.id===n))==null?void 0:h.reactions)==null?void 0:p.some(u=>u.emoji===o&&u.authorIds.includes(r)))??!1;return e.toggleReaction(s,n,{emoji:o,on:c})},onError:(s,{roomId:n,entryId:o,emoji:r,viewerAuthorId:l},c)=>{c!==void 0&&t.setQueryData(K.entries(n),h=>{var d;const p=(d=h==null?void 0:h.find(k=>k.id===o))==null?void 0:d.reactions,{reactions:u}=Je(p,r,l,!c.on);return Ce(h,o,u)})},onSuccess:({frequents:s},{roomId:n})=>{t.setQueryData(K.detail(n),o=>o&&{...o,reactionFrequents:s})},meta:{errorLabel:"Couldn’t add your reaction",errorToastId:"room-reaction"}})}function Z(e){return e.threadRootEntryId??e.parentEntryId}function Tt(e){return Z(e)??e.id}function $e(e,t){return Math.max(t??0,e)}function po(e,t,s){let n=e[0],o=0;for(const r of e)r.seq>n.seq&&(n=r),t!==null&&r.seq>t&&(o+=1);return{count:$e(e.length,s),lastAt:n.createdAt,unread:o}}function ho(e){const t=te(),s=ye(),n=nn(e),o=ke(u=>{var d;return e===null?null:((d=u.paging[e])==null?void 0:d.cursor)??null}),r=le({mutationFn:async u=>{var x;const d=(x=ke.getState().paging[u])==null?void 0:x.cursor;if(d==null)return;const k=await t.listRoomEntries(u,{before:d,limit:Ge}),f=K.entries(u),g=s.getQueryData(f),y=sn(g,k);s.setQueryData(f,y),ke.getState().notePage(u,on(k)??d,rn(k,Ge)||y.length===((g==null?void 0:g.length)??0))},meta:{errorLabel:"Couldn't load older messages"}}),{mutateAsync:l,isPending:c}=r,h=a.useRef(!1),p=a.useCallback(async()=>{if(!(e===null||h.current)){h.current=!0;try{await l(e).catch(()=>{})}finally{h.current=!1}}},[e,l]);return{canLoadOlder:n,isLoadingOlder:c,cursor:o,loadOlder:p}}function go(e){return i.jsx(_s,{code:e.code,isIncomplete:e.isIncomplete})}const xo=[{language:Ts,component:go}],yo={turn_failed:{Icon:hn,tone:"text-status-warning"},agent_busy:{Icon:pn},agent_gone:{Icon:Js,tone:"text-status-warning"},agent_left:{Icon:Ze,tone:"text-status-warning"},room_archived:{Icon:fn},runtime_gone:{Icon:Qs,tone:"text-status-warning"},agent_paused:{Icon:mn},agent_declined:{Icon:Bs},agent_unavailable:{Icon:un},awaiting_approval:{Icon:Ws,tone:"text-status-warning"},halted:{Icon:dn},budget_reached:{Icon:cn},cascade_stopped:{Icon:ln},addressing_changed:{Icon:Gs},bridge_blocked:{Icon:qs,tone:"text-status-warning"},bridge_undelivered:{Icon:an,tone:"text-status-warning"},bridge_rate_limited:{Icon:Ys},bridge_second_agent_refused:{Icon:Ze},bridge_disconnected:{Icon:Ks},bridge_agent_swapped:{Icon:xs},bridge_history_note:{Icon:Fs}},bo={Icon:gn},we=80;function vo(e){const t=e.trim();if(t.length<=we)return t;const s=t.slice(0,we),n=s.lastIndexOf(" ");return`${(n>we/2?s.slice(0,n):s).trimEnd()}…`}function Ro(e,t,s){const n=ko(e,s),o=r=>i.jsx("a",{href:t.href,onClick:t.onOpen,"data-testid":"room-notice-session-link",className:"focus-ring hover:text-foreground rounded py-2 font-medium underline underline-offset-2",children:r});return n===null?i.jsxs(i.Fragment,{children:[e," ",o("Open chat")]}):i.jsxs(i.Fragment,{children:[e.slice(0,n.index),o(n.words),e.slice(n.index+n.words.length)]})}function ko(e,t){if(t!==void 0){const n=xn(t),o=e.lastIndexOf(n);if(o!==-1)return{index:o,words:n}}const s=yn.exec(e);return s===null?null:{index:s.index,words:s[0]}}function wo({entry:e,feedPosition:t,rowId:s,sessionLink:n,subjectName:o}){const{Icon:r,tone:l}=(e.body.notice&&yo[e.body.notice])??bo;return i.jsxs("p",{id:s,"data-slot":"notice-row","data-testid":"room-notice","data-notice":e.body.notice??"unknown",...t&&{role:"article","aria-label":vo(e.body.text)},...Pe(t),className:V("focus-visible:ring-ring flex items-start gap-2 px-[var(--msg-padding-x)] py-2 text-xs outline-none focus-visible:ring-2",l??"text-muted-foreground"),children:[i.jsx(r,{"aria-hidden":!0,className:"mt-px size-3.5 shrink-0"}),i.jsx("span",{children:n?Ro(e.body.text,n,o):e.body.text})]})}const So=Hs.moment;function No({entry:e,moment:t,subject:s,subjectIdentity:n,feedPosition:o,rowId:r}){const l=De(e.createdAt);return i.jsx("div",{id:r,"data-slot":"moment-row","data-testid":"room-moment","data-moment":t.kind,role:"article","aria-label":`Moment: ${e.body.text}`,...Pe(o),className:"focus-visible:ring-ring px-[var(--msg-padding-x)] py-1 outline-none focus-visible:ring-2",children:i.jsxs("div",{className:"border-border/60 bg-muted/40 flex items-center gap-2.5 rounded-lg border px-3 py-2",children:[i.jsx(Et,{identity:{kind:s.kind,displayName:s.displayName,handle:n==null?void 0:n.handle,color:s.color,emoji:s.emoji,imageUrl:s.imageUrl,origin:n==null?void 0:n.origin,agent:n==null?void 0:n.agent},children:i.jsxs("span",{"data-testid":"room-moment-identity",className:"flex shrink-0 items-center",children:[i.jsx(vt,{author:s}),i.jsx("span",{className:"sr-only",children:s.displayName})]})}),i.jsx(So,{"data-testid":"room-moment-mark","aria-hidden":!0,className:"text-muted-foreground size-3.5 shrink-0"}),i.jsx("p",{className:"min-w-0 flex-1 text-sm",children:e.body.text}),l.length>0&&i.jsx("time",{dateTime:e.createdAt,title:Rt(e.createdAt),className:"text-msg-timestamp shrink-0 text-xs",children:l})]})})}function Io({id:e,summary:t,open:s,onOpen:n}){const{capabilities:o}=kt(),{count:r,lastAt:l,unread:c}=t,h=De(l),[p,u]=a.useState({count:r,bumped:!1});p.count!==r&&u({count:r,bumped:!0});const d=p.count===r&&p.bumped;return o.threads?i.jsxs("button",{type:"button",id:e,"data-slot":"thread-reply-row","data-testid":"room-thread-replies","data-unread":c>0?"":void 0,"aria-expanded":s,onClick:n,className:V("focus-ring ml-[calc(var(--msg-padding-x)_+_var(--msg-gutter-width)_+_var(--msg-gap))]","mb-1 w-fit rounded text-left text-xs transition-colors","px-2 py-2 md:px-1 md:py-0.5",c>0?"text-primary hover:text-primary/80 font-medium":"text-muted-foreground hover:text-foreground"),children:[i.jsx("span",{"aria-hidden":!0,className:"mr-1",children:"↳"}),i.jsx("span",{className:V(d&&"motion-safe:animate-count-flip"),"data-testid":"room-thread-reply-count",children:r},r),r===1?" reply":" replies",h.length>0&&i.jsxs(i.Fragment,{children:[" · last ",i.jsx("time",{dateTime:l,title:Rt(l),children:h})]}),c>0&&` · ${c} new`]}):null}function jo(e,t){const s=ue.getState(),n=s.drafts[e]??"",o=n===""||n.endsWith(" ")||n.endsWith(`
|
|
43
|
-
`)?"":" ";s.set(e,`${n}${o}@${t} `)}function Co({roomId:e,entry:t,author:s,viewerAuthorId:n,onViewProfile:o}){const r=Tt(t),l=t.body.text,c=(s==null?void 0:s.id)===n?void 0:(s==null?void 0:s.handle)??void 0,h=s==null?void 0:s.displayName,{copy:p}=bn({toastOnSettle:!0});return a.useMemo(()=>{const u={reply:{id:"reply",label:"Reply in thread",icon:Vs,run:()=>{Y.getState().openThread(e,r,!0),Qe.getState().requestFocus(lt(e,r))}},copy:{id:"copy",label:"Copy text",icon:vn,run:()=>void p(l)}};return o!==void 0&&(u.profile={id:"profile",label:"View profile",icon:Rn,run:o}),c!==void 0&&(u.mention={id:"mention",label:h===void 0?"Mention author":`Mention ${h}`,icon:ys,run:()=>{jo(e,c),Qe.getState().requestFocus(e)}}),ks.map(d=>u[d]).filter(d=>d!==void 0)},[e,r,l,c,h,o,p])}function Ao(e){if(e.kind==="notice")return{kind:"notice"};const t=e.body.moment;return t?{kind:"moment",moment:t}:{kind:"message"}}function Le(e,t=[]){return new Map([...t.map(s=>[s.author.id,{...s.author,origin:s.origin}]),...e.map(s=>[s.author.id,{...s.author,origin:s.origin}])])}function pe(e,t){const s=e.body.subjectAuthorId;return s===void 0||t.has(e.authorId)?e.authorId:s}function J(e,t,s){const n=t.get(e),o=ct({record:{kind:(n==null?void 0:n.kind)??"system",id:e,displayName:(n==null?void 0:n.displayName)??"Unknown",emoji:n==null?void 0:n.emoji,color:n==null?void 0:n.color,imageUrl:n==null?void 0:n.imageUrl},override:(n==null?void 0:n.agentRef)===void 0?null:s==null?void 0:s.get(n.agentRef)});return{kind:o.kind,id:e,displayName:(n==null?void 0:n.displayName)??"Unknown",emoji:o.emoji,imageUrl:o.imageUrl,color:o.color,isExternal:typeof(n==null?void 0:n.origin)=="object"&&(n==null?void 0:n.origin)!==null,...(n==null?void 0:n.retired)===!0?{retired:!0}:{}}}function Mo(e){const t=new Set;for(const r of e)Z(r)===null&&t.add(r.id);const s=[],n=new Map,o=new Set;for(const r of e){const l=Z(r);if(l===null){s.push(r);continue}if(!t.has(l)){s.push(r),o.add(r.id);continue}const c=n.get(l);c?c.push(r):n.set(l,[r])}return{topLevel:s,repliesByRoot:n,orphaned:o}}function _t(e){return`thread-${e}`}function he(e){return`thread-row-${e}`}function Ae(e){return`thread-panel-entry-${e}`}function ge(e){return`room-entry-${e}`}function Fe(e,t){const s=e.find(c=>c.id===t);if(s===void 0)return null;const n=Z(s)??null,o={rowId:t,domId:ge(t)};if(n===null)return o;const r=e.find(c=>c.id===n);return r!==void 0&&(Z(r)??null)===null?{rowId:_t(n),domId:he(n)}:o}function Eo(e,t){if(t===null)return null;const s=e.find(n=>n.seq===t);return s===void 0?null:Fe(e,s.id)}const et=48;function Pt(e,t,s){const n=e.body.answersEntryId;if(n===void 0||n===e.id||t!==void 0&&t.id===n)return null;const o=s(n);if(o===void 0)return null;const r=o.body.text.replace(/\s+/gu," ").trim();return r.length===0?null:{entryId:n,excerpt:r.length>et?`${r.slice(0,et).trimEnd()}…`:r}}function Oo(e,t){const s=new Map;for(const n of e){const o=t[n.projectPath];if(!o)continue;const r=kn({runtime:o.runtime,model:o.model});s.set(dt(n.projectPath),{memberId:n.id,visual:wn(o),runtime:r.label,...r.modelLabel!==null&&{model:r.modelLabel}})}return s}function To(e){const t=new Map;for(const[s,n]of e)t.set(s,n.visual);return t}const _o={info:new Map,faces:new Map},qe=a.createContext(_o);function Dt({known:e,children:t}){return i.jsx(qe.Provider,{value:e,children:t})}function Be(){const e=ut(),t=a.useMemo(()=>{var l;return((l=e.data)==null?void 0:l.agents)??[]},[e.data]),s=a.useMemo(()=>t.map(l=>l.projectPath),[t]),n=mt(s),o=a.useMemo(()=>Oo(t,n.data??{}),[t,n.data]),r=a.useMemo(()=>To(o),[o]);return a.useMemo(()=>({info:o,faces:r}),[o,r])}function Me(e){const t=a.useContext(qe);return e===void 0?void 0:t.info.get(e)}function Po(){return a.useContext(qe).faces}function Do({loading:e,onLoad:t}){return i.jsx("div",{className:"flex justify-center px-4 py-3",children:i.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:e,"data-testid":"room-load-older",className:"text-muted-foreground hover:text-foreground h-7 gap-2 text-xs",children:[e&&i.jsx(Sn,{size:"xs"}),e?"Loading older messages…":"Older messages"]})})}function $o({showAuthorHeader:e,headerId:t,displayName:s,time:n,summary:o,contentId:r,summaryId:l,feedPosition:c}){return{...e?{"aria-labelledby":t}:{"aria-label":n.length>0?`${s}, ${n}`:s},"aria-describedby":o===null?r:l,...Pe(c)}}const me=120,Lo="code block";function Fo(e){if(e.length<=me&&!e.includes("```"))return null;const t=qo(e);return t.length===0?null:t}function qo(e){const t=e.replace(/```[\s\S]*?(?:```|$)/g,` ${Lo} `).replace(/`([^`]*)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^\s{0,3}(?:#{1,6}\s+|>\s?|[-*+]\s+)/gm,"").replace(/^\s{0,3}\|?[\s:|-]*\|[\s:|-]*$/gm," ").replace(/\|/g," ").replace(/[*_~]{1,3}/g,"").replace(/\s+/g," ").trim();if(t.length<=me)return t;const s=Bo(t,me),n=s.lastIndexOf(" ");return`${(n>me/2?s.slice(0,n):s).trimEnd()}…`}function Bo(e,t){if(typeof Intl.Segmenter=="function"){const n=new Intl.Segmenter(void 0,{granularity:"grapheme"});let o="";for(const{segment:r}of n.segment(e)){if(o.length+r.length>t)break;o+=r}return o}let s="";for(const n of e){if(s.length+n.length>t)break;s+=n}return s}function Ho({roomId:e,entry:t,viewerAuthorId:s,reactionFrequents:n,streamStalled:o,isMember:r=!0}){const l=fo(),c=o===!0||!r,h=a.useMemo(()=>t.reactions??[],[t.reactions]),p=a.useMemo(()=>h.filter(k=>ws(k,s)).map(k=>k.emoji),[h,s]),u=a.useCallback(k=>l.mutate({roomId:e,entryId:t.id,emoji:k,viewerAuthorId:s}),[l,e,t.id,s]),d=a.useMemo(()=>({quick:n,mine:p,onToggle:u,disabled:c}),[n,p,u,c]);return{reactions:h,toggle:u,quickRow:d}}function zo({barRef:e,pillsRef:t,hasReactions:s}){return n=>{var r,l;if(n.target!==n.currentTarget)return;const{key:o}=n;if(o==="ArrowDown"&&s){n.preventDefault(),(r=t.current)==null||r.focusFirst();return}o!=="ArrowRight"&&o!=="Enter"||(n.preventDefault(),(l=e.current)==null||l.focusFirst())}}function Uo(e,t){var d,k;const s=t.body.subjectAuthorId,n=t.body.notice,o=t.kind==="notice"&&n!==void 0&&s!==void 0&&Nn.includes(n),r=Ot(e,{enabled:o}),l=Te(),c=ye(),h=te(),p=o?((k=(d=r.data)==null?void 0:d.bindings.find(f=>f.authorId===s))==null?void 0:k.sessionId)??null:null,u=a.useCallback(f=>{f.button!==0||f.metaKey||f.ctrlKey||f.shiftKey||f.altKey||(f.preventDefault(),!(p===null||s===void 0)&&In({queryClient:c,transport:h},e,s).then(g=>{g.kind!=="none"&&l(fe({session:g.kind==="bound"?g.sessionId:p}))}))},[s,l,c,e,p,h]);return a.useMemo(()=>p===null?null:{href:jn({session:p}),onOpen:u},[u,p])}const xe="mention",He="author_id",Wo={[xe]:[He]},Ko=[xe];function Go(e,t){if(!t||t.length===0)return e;const s=Qo(e,t);if(s.length===0)return e;let n=e;for(let o=s.length-1;o>=0;o--){const{offset:r,length:l,authorId:c}=s[o],h=n.slice(0,r),p=n.slice(r,r+l),u=n.slice(r+l);n=`${h}<${xe} ${He}="${c}">${p}</${xe}>${u}`}return n}function Qo(e,t){const s=[...t].sort((r,l)=>r.offset-l.offset),n=[];let o=0;for(const r of s)r.offset<o||r.offset+r.length>e.length||(n.push(r),o=r.offset+r.length);return n}const Vo=new Map,$t=a.createContext(Vo);function Yo({authors:e,children:t}){return i.jsx($t.Provider,{value:e,children:t})}function Jo(e){const t=a.useContext($t);return e===void 0?void 0:t.get(e)}function Xo(e){return typeof e=="string"?e.replace(/^@/,""):""}function Zo({authorId:e,children:t}){const s=Jo(e),n=Me(s==null?void 0:s.agentRef),{open:o}=ft();if(!s)return i.jsx(Xe,{kind:"human",label:Xo(t),resolved:!1});const r=ct({record:s,override:n==null?void 0:n.visual}),l=pt(s,n==null?void 0:n.memberId),c=l===void 0?void 0:()=>o(l),h=c?{role:"button",tabIndex:0,"aria-label":`View ${s.displayName}’s profile`,onClick:c,onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),c())}}:{};return i.jsx(Et,{onViewProfile:c,identity:{kind:s.kind,displayName:s.displayName,handle:s.handle??void 0,color:r.color,emoji:r.emoji,imageUrl:r.imageUrl,origin:s.origin,agent:n&&{runtime:n.runtime,...n.model&&{model:n.model}}},children:i.jsx(Xe,{kind:s.kind,label:s.displayName,handle:s.handle??void 0,color:s.color,origin:s.origin,resolved:!0,interactive:c!==void 0,...h})})}function er(e){return{mention:t=>{const s=t[He],n=typeof s=="string"?s:void 0;return!n||!e.has(n)?i.jsx(i.Fragment,{children:t.children}):i.jsx(Zo,{authorId:n,children:t.children})}}}function tr({entry:e,authors:t}){const s=a.useMemo(()=>Go(e.body.text,e.mentionSpans),[e.body.text,e.mentionSpans]),n=a.useMemo(()=>{var r;return new Set(((r=e.mentionSpans)==null?void 0:r.map(l=>l.authorId))??[])},[e.mentionSpans]),o=a.useMemo(()=>er(n),[n]);return i.jsx(Yo,{authors:t,children:i.jsx(Os,{content:s,className:"msg-prose",allowedTags:Wo,literalTagContent:Ko,components:o,renderers:xo})})}function nr(e){return function(s){return i.jsx(tr,{entry:s,authors:e})}}const Lt="the top folder";function tt(e){return e.slice(e.lastIndexOf("/")+1)}function sr(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function or(e){return e===""?Lt:`${e}/`}function Se(e){return e.target!==void 0?e.target===""?Lt:e.target:or(sr(e.paths[0]??""))}function rr(e,t){const s=e.paths[0]??"",n=e.target;switch(e.kind){case"edit":return`${t} edited ${n??s}`;case"add":return`${t} added ${n??s}`;case"upload":return e.pathCount===1?`${t} uploaded ${tt(s)} to ${Se(e)}`:`${t} uploaded ${e.pathCount} files to ${Se(e)}`;case"rename":{const o=e.from??"";return n!==void 0?`${t} renamed ${o} to ${n}`:o.endsWith("/")?`${t} renamed ${o}`:`${t} renamed ${o} to ${s}`}case"delete":return n!==void 0?`${t} deleted ${n}`:e.pathCount===1?`${t} deleted ${s}`:`${t} deleted ${e.pathCount} files`;case"from-attachment":return`${t} saved ${tt(s)} from the chat to ${Se(e)}`}}const ar=a.lazy(()=>Cn(()=>import("./index-Dg_bax15.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(e=>({default:e.SaveToRoomFilesButton})));function Ft({roomId:e,entry:t,author:s,authorRef:n,authors:o,viewerAuthorId:r,authorNames:l,reactionFrequents:c,streamStalled:h,isMember:p=!0,grouping:u,orphanedReply:d,answers:k,feedPosition:f,rowId:g}){const y=De(t.createdAt),x=a.useMemo(()=>{const G=Fo(t.body.text),Re=Ss(t.attachments??[]);if(Re===null)return G;const We=G??t.body.text.trim();return We.length>0?`${We} ${Re}`:Re},[t.body.text,t.attachments]),N=a.useId(),m=`${N}-author`,b=`${N}-content`,E=`${N}-summary`,O=a.useRef(null),D=a.useRef(null),j=a.useRef(null),{reactions:S,toggle:_,quickRow:I}=Ho({roomId:e,entry:t,viewerAuthorId:r,reactionFrequents:c,streamStalled:h,isMember:p}),L=Me(n==null?void 0:n.agentRef),{open:$}=ft(),T=n===void 0?void 0:pt(n,L==null?void 0:L.memberId),B=a.useCallback(()=>{T!==void 0&&$(T)},[$,T]),F=T===void 0?void 0:B,H=Co({roomId:e,entry:t,author:n,viewerAuthorId:r,onViewProfile:F}),W=zo({barRef:D,pillsRef:j,hasReactions:S.length>0}),q=a.useCallback(()=>{var G;return(G=O.current)==null?void 0:G.focus()},[]),z=a.useMemo(()=>nr(o),[o]),w=a.useCallback(G=>i.jsx(a.Suspense,{fallback:null,children:i.jsx(ar,{roomId:e,attachment:G})}),[e]),v=Po(),P=t.body.subjectAuthorId??t.authorId,M=o.get(P),R=Me(M==null?void 0:M.agentRef),A=Uo(e,t),C=Ao(t);if(C.kind==="notice")return i.jsx(wo,{entry:t,feedPosition:f,rowId:g,sessionLink:A,subjectName:M==null?void 0:M.displayName});if(C.kind==="moment")return i.jsx(No,{entry:t,moment:C.moment,subject:P===t.authorId?s:J(P,o,v),subjectIdentity:{handle:(M==null?void 0:M.handle)??void 0,origin:M==null?void 0:M.origin,agent:R&&{runtime:R.runtime,...R.model&&{model:R.model}}},feedPosition:f,rowId:g});const U=u.position==="first"||u.position==="only";return i.jsxs(Q.Root,{ref:O,id:g,position:u.position,actions:H,reactions:I,"data-testid":"room-entry",tabIndex:0,...$o({showAuthorHeader:U,headerId:m,displayName:s.displayName,time:y,summary:x,contentId:b,summaryId:E,feedPosition:f}),onKeyDown:W,children:[i.jsx(Q.Gutter,{author:s,at:t.createdAt,onViewProfile:F,isSelf:t.authorId===r}),i.jsxs(Q.Body,{children:[i.jsx(Q.Author,{id:m,author:s,at:t.createdAt,origin:n==null?void 0:n.origin}),d===!0&&i.jsx("p",{"data-testid":"room-entry-orphan",className:"text-muted-foreground text-xs italic",children:"Replying to an earlier message"}),k!=null&&i.jsx("p",{"data-testid":"room-entry-answers",className:"text-muted-foreground mb-1 truncate text-xs italic",children:`Answering “${k.excerpt}”`}),i.jsx(Q.Content,{id:b,className:"[&_:not(pre)>code]:wrap-anywhere [&_pre]:overflow-x-auto",children:t.body.fileChange?i.jsx("p",{"data-testid":"room-entry-file-change",className:"wrap-anywhere",children:rr(t.body.fileChange,(M==null?void 0:M.displayName)??"Somebody")}):z(t,{rowId:t.id,isStreaming:!1})}),x!==null&&i.jsx("span",{id:E,className:"hidden",children:x}),i.jsx(Q.Attachments,{items:t.attachments??[],renderAction:p?w:void 0}),i.jsx(Q.Reactions,{ref:j,reactions:S,viewerAuthorId:r,names:l,frequents:c,onToggle:_,disabled:h===!0||!p,onExit:q}),i.jsx(Q.Actions,{actions:H,reactions:I,barRef:D,onExit:q})]})]})}const ir="room-load-older",lr=4;function qt({roomName:e}){return i.jsx(Ns,{label:e===void 0?"Messages":`Messages in ${e}`,busy:!0,className:"flex flex-col gap-4 p-4","data-testid":"room-timeline-loading",children:Array.from({length:lr},(t,s)=>i.jsxs("div",{className:"flex gap-3",children:[i.jsx(ae,{className:"size-7 shrink-0 rounded-full"}),i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[i.jsx(ae,{className:"h-3 w-24"}),i.jsx(ae,{className:"h-3 w-full max-w-md"})]})]},`room-skeleton-${s}`))})}function cr({roomId:e,roomName:t,viewerAuthorId:s,entries:n,members:o,formerAuthors:r,lastReadSeq:l,reactionFrequents:c,streamStalled:h,isLoading:p,error:u,onAddAgents:d,openThreadId:k,onOpenThread:f,resumeRow:g,landOnRow:y,onTopRow:x,canLoadOlder:N=!1,isLoadingOlder:m=!1,onLoadOlder:b,ref:E}){const O=a.useMemo(()=>Le(o,r),[o,r]),D=be(o,s),j=Be(),S=a.useMemo(()=>new Map([...O].map(([v,P])=>[v,P.displayName])),[O]),_=ht(),I=gt(e,null),{topLevel:L,repliesByRoot:$,orphaned:T}=a.useMemo(()=>Mo(n),[n]),B=a.useMemo(()=>new Map(n.map(v=>[v.id,v])),[n]),F=a.useMemo(()=>{const v=An(L,l),P=Mn(L.map(R=>({id:R.id,authorId:R.body.moment?`moment:${R.id}`:R.authorId,timestamp:R.createdAt})),{now:_,lastSeenId:v.lastSeenId,unreadFromStart:v.fromStart}),M=[];N&&!p&&M.push({kind:"load-older",id:ir});for(const R of P){if(R.kind==="day-divider"){M.push({kind:"day-divider",id:R.key,label:R.label});continue}if(R.kind==="unread-divider"){M.push({kind:"unread-divider",id:R.key});continue}const A=L[R.index];M.push({kind:"message",id:A.id,entry:A,grouping:R.grouping,position:R.index+1,answers:Pt(A,L[R.index-1],B.get.bind(B))});const C=$.get(A.id);C&&M.push({kind:"thread-reply",id:_t(A.id),rootId:A.id,replies:C,totalReplies:A.threadReplyCount})}return M},[L,$,B,l,_,N,p]),H=a.useMemo(()=>F.map(v=>v.kind==="load-older"?{kind:"notice",id:v.id,at:"",body:null}:v.kind==="day-divider"?{kind:"day-divider",id:v.id,label:v.label}:v.kind==="unread-divider"?{kind:"unread-divider",id:v.id}:v.kind==="thread-reply"?{kind:"thread-reply",id:v.id,rootId:v.rootId,replyCount:$e(v.replies.length,v.totalReplies),lastAt:v.replies[v.replies.length-1].createdAt}:{kind:"message",id:v.id,payload:v.entry,grouping:v.grouping,author:J(pe(v.entry,O),O,j.faces),at:v.entry.createdAt}),[F,O,j.faces]),W=a.useCallback((v,P)=>{const M=F[P.index];if(M.kind==="load-older")return b===void 0?null:i.jsx(Do,{loading:m,onLoad:b});if(M.kind==="day-divider")return i.jsx(Is,{label:M.label});if(M.kind==="unread-divider")return i.jsx(js,{});if(M.kind==="thread-reply"){if(P.onOpenThread===void 0)return null;const A=P.onOpenThread;return i.jsx(Io,{id:he(M.rootId),summary:po(M.replies,l,M.totalReplies),open:k===M.rootId,onOpen:()=>A(M.rootId)})}const R=pe(M.entry,O);return i.jsx(Ft,{roomId:e,entry:M.entry,author:J(R,O,j.faces),authorRef:O.get(R),authors:O,viewerAuthorId:s,authorNames:S,reactionFrequents:c,streamStalled:h,isMember:D,grouping:M.grouping,orphanedReply:T.has(M.entry.id),answers:M.answers,feedPosition:{index:M.position,total:-1},rowId:ge(M.entry.id)})},[F,e,O,j.faces,s,S,c,h,D,T,l,k,m,b]),q=a.useCallback(v=>{if(v.kind==="message")return ge(v.id);if(v.kind==="thread-reply")return he(v.rootId)},[]);if(u)return i.jsxs("div",{className:"text-muted-foreground flex flex-col items-center gap-2 p-10 text-center text-sm",children:[i.jsx("p",{className:"text-foreground font-medium",children:"Couldn’t load these messages"}),i.jsx("p",{className:"max-w-sm",children:"Nothing was lost. Reload to try again."})]});const z=o.some(v=>v.author.kind==="agent"),w=i.jsxs("div",{className:"text-muted-foreground flex flex-col items-center gap-2 p-10 text-center text-sm",children:[i.jsx(En,{className:"text-muted-foreground/50 size-8","aria-hidden":!0}),i.jsx("p",{className:"text-foreground font-medium",children:"Nothing said here yet"}),i.jsx("p",{className:"max-w-sm",children:z?"Say something to get it going.":"Nothing answers until you add an agent."}),i.jsx(Oe,{type:"button",size:"sm",variant:z?"ghost":"default",onClick:d,className:"mt-1",children:z?"Add more agents":"Add agents"})]});return i.jsx(Dt,{known:j,children:i.jsx(X.Timeline,{ref:E,conversationId:e,label:`Messages in ${t}`,rows:H,renderRow:W,onOpenThread:f,domIdOf:q,...g===void 0?{}:{resumeRow:g},...y===void 0?{}:{landOnRow:y},...x===void 0?{}:{onTopRow:x},pending:I,viewerAuthorId:s,loading:p?i.jsx(qt,{roomName:t}):void 0,empty:w,feedTestId:"room-timeline"})})}const ze={reactions:!0,threads:!0,runWith:!1,attachments:!0,mentions:!0,streamHealth:!0,presence:!0,turnStatus:!1,asks:!0};function dr(e){const t=te(),[s,n]=a.useState([]),o=a.useRef(new Map),r=a.useCallback(f=>{const g=f.map(y=>({id:crypto.randomUUID(),file:y,status:"pending",progress:0}));n(y=>[...y,...g])},[]),l=a.useCallback(f=>{o.current.delete(f),n(g=>g.filter(y=>y.id!==f))},[]),c=a.useCallback(f=>{if(!f){o.current.clear(),n([]);return}const g=new Set(f);for(const y of g)o.current.delete(y);n(y=>y.filter(x=>!g.has(x.id)))},[]),h=a.useCallback(f=>{o.current.delete(f),n(g=>g.map(y=>y.id===f&&y.status==="error"?{...y,status:"pending",progress:0,error:void 0}:y))},[]),p=a.useRef(null),u=le({meta:{suppressErrorToast:!0},mutationFn:async f=>{n(N=>N.map(m=>f.some(b=>b.id===m.id)?{...m,status:"uploading"}:m));const g=N=>{n(m=>m.map(b=>b.status==="uploading"?{...b,progress:N.percentage}:b))},y=new AbortController;p.current=y;const x=f.map(N=>N.file);return t.uploadRoomAttachments(e,x,g,y.signal)},onSettled:()=>{p.current=null},onSuccess:(f,g)=>{g.forEach((y,x)=>{const N=f[x];N&&o.current.set(y.id,N.id)}),n(y=>y.map(x=>g.findIndex(m=>m.id===x.id)===-1?x:{...x,status:"uploaded",progress:100}))},onError:f=>{n(g=>g.map(y=>y.status==="uploading"?{...y,status:"error",error:f.message}:y))}}),d=a.useCallback(()=>{var f;(f=p.current)==null||f.abort()},[]),k=a.useCallback(async()=>{const f=s.filter(y=>y.status==="error");if(f.length>0)throw new Error(f.length===1?`${f[0].file.name} didn’t upload. Try again or remove it.`:`${f.length} files didn’t upload. Try again or remove them.`);const g=s.filter(y=>y.status==="pending");return g.length>0&&await u.mutateAsync(g),s.map(y=>o.current.get(y.id)).filter(y=>y!==void 0)},[s,u]);return{pendingFiles:s,addFiles:r,removeFile:l,retryFile:h,clearFiles:c,cancelUpload:d,uploadAndGetIds:k,hasPendingFiles:s.length>0,hasFailedUpload:s.some(f=>f.status==="error"),isUploading:u.isPending}}function Bt(e){const{room:t,threadRootId:s}=e,n=Cs(),o=As(),r=dr((t==null?void 0:t.id)??""),l=t!==void 0&&be(t.members,t.viewerAuthorId),c=a.useRef({attachments:r,post:n,reply:o,room:t,threadRootId:s});a.useEffect(()=>{c.current={attachments:r,post:n,reply:o,room:t,threadRootId:s}});const h=a.useCallback(m=>c.current.attachments.addFiles(m),[]),p=a.useCallback(m=>c.current.attachments.removeFile(m),[]),u=a.useCallback(m=>c.current.attachments.retryFile(m),[]),d=a.useCallback(()=>c.current.attachments.cancelUpload(),[]),{pendingFiles:k,hasFailedUpload:f,isUploading:g}=r,y=a.useMemo(()=>({staged:k,add:h,remove:p,retry:u,cancel:d,hasFailed:f,isUploading:g,holdsSendWhileUploading:!1}),[k,f,g,h,p,u,d]),x=a.useCallback(async m=>{const{attachments:b,post:E,reply:O,room:D,threadRootId:j}=c.current;if(D===void 0)throw new Error("That room isn’t loaded yet.");if(D.archived)throw new Error("This room is archived.");Ie.getState().recordOpened("room",D.id);const S=On(),_=b.pendingFiles.map(T=>T.file.name),I=b.pendingFiles.map(T=>T.id),L=await b.uploadAndGetIds();b.clearFiles(I);const $=m.parentEntryId??j;if($!==void 0){O.mutate({roomId:D.id,rootEntryId:$,text:m.text,clientId:S,attachmentIds:L,attachmentNames:_});return}E.mutate({roomId:D.id,text:m.text,clientId:S,attachmentIds:L,attachmentNames:_})},[]);return{target:a.useMemo(()=>({kind:"room",id:(t==null?void 0:t.id)??"",placeholder:t===void 0?"Message…":s===void 0?`Message ${se(t)}…`:"Reply in this thread…",canSend:t!==void 0&&!t.archived&&l,...t===void 0?{canSendReason:"Still opening this room…"}:t.archived?{canSendReason:"This room is archived. You can read it, but not add to it."}:l?{}:{canSendReason:xt},send:x,attachments:y}),[t,s,l,y,x]),attachments:r}}function ur(e){const{roomId:t,entrySeq:s,entries:n,historyLoaded:o}=e,r=s===void 0?null:`${t}:${s}`,l=a.useMemo(()=>{if(s===void 0)return null;const g=n.find(m=>m.seq===s);if(g===void 0)return null;const y=Fe(n,g.id);if(y===null)return null;const x=Z(g)??null,N=x!==null&&y.rowId!==g.id;return{roomRowId:y.rowId,threadRootId:N?x:null,entryId:g.id}},[n,s]),c=a.useRef(null),h=(l==null?void 0:l.threadRootId)??null;a.useEffect(()=>{r===null||h===null||c.current!==r&&(c.current=r,Y.getState().openThread(t,h))},[r,t,h]);const p=a.useRef(null);a.useEffect(()=>{r===null||!o||l===null&&p.current!==r&&(p.current=r,yt.info("That message isn’t in the loaded history",{description:"Only recent messages are open. Nothing was lost."}))},[r,o,l]);const u=a.useRef(null),d=a.useCallback(()=>{if(!(r===null||u.current===r))return u.current=r,l==null?void 0:l.roomRowId},[r,l]),k=a.useRef(null),f=a.useCallback(()=>{if(!(r===null||k.current===r))return k.current=r,(l==null?void 0:l.threadRootId)===null||l==null?void 0:l.entryId},[r,l]);return{roomRow:s===void 0?void 0:d,threadRow:s===void 0?void 0:f}}function mr(e,t){const[s,n]=a.useState({roomId:null,seq:null});return s.roomId===e?s.seq:e===null?(n({roomId:null,seq:null}),null):t===null?null:(n({roomId:e,seq:t}),t)}const fr=600;function pr(e){return document.getElementById(he(e))??document.getElementById(ge(e))}function hr(){const e=a.useRef(null);return a.useEffect(()=>()=>{var s;return(s=e.current)==null?void 0:s.call(e)},[]),{arm:a.useCallback(s=>{var c;(c=e.current)==null||c.call(e);let n=0;const o=Date.now()+fr;let r=!1;const l=()=>{if(r)return;const h=document.activeElement;if(h===null||h===document.body||!h.isConnected){const u=pr(s);if(u!==null){u.focus();return}}Date.now()>=o||(n=requestAnimationFrame(l))};n=requestAnimationFrame(l),e.current=()=>{r=!0,cancelAnimationFrame(n)}},[])}}function gr({roomId:e,route:t,urlThreadId:s,openThreadId:n,entries:o,historyLoaded:r}){const l=Tn(),c=a.useRef(null);a.useEffect(()=>{if(e!==null){if(c.current!==e&&(c.current=e,s!==void 0)){Y.getState().openThread(e,s);return}if(r&&n!==void 0){const h=o.find(u=>u.id===n),p=h===void 0?void 0:Tt(h);if(p!==void 0&&p!==n){const u=Y.getState().open[e];Y.getState().openThread(e,p,(u==null?void 0:u.focusComposer)??!1);return}}n!==s&&(l==null||l({to:t,search:h=>({...h,thread:n}),replace:!0}))}},[e,t,n,s,o,r,l])}const xr=6,Ht="jump-back-in-listbox";function Ue(e){return`jump-back-in-item-${e}`}const yr='[role="combobox"]';function ie(e){return e instanceof Element&&e.matches(yr)}function br({value:e,yieldToPalette:t=!1,enabled:s=!0}){const n=Te(),o=_n(),[r,l]=a.useState(!1),[c,h]=a.useState({stamp:"",index:0}),[p,u]=a.useState(!1),[d,k]=a.useState(!1);e.length>0&&!d&&k(!0);const f=a.useRef(!1);a.useEffect(()=>{f.current=!0},[]);const{data:g}=ut({enabled:s}),y=a.useMemo(()=>((g==null?void 0:g.agents)??[]).map(w=>w.projectPath),[g]),{data:x}=mt(y,{enabled:s}),N=a.useMemo(()=>x??{},[x]),m=a.useMemo(()=>Pn(y,N),[y,N]),b=a.useMemo(()=>new Map(y.map(w=>[dt(w),w])),[y]),E=a.useCallback(w=>Dn({room:w,agentsByPath:N,pathByAgentRef:b}),[N,b]),O=a.useMemo(()=>$n(o.muted),[o.muted]),{items:D}=bs({mutedRoomIds:O,enabled:s}),j=a.useMemo(()=>D.slice(0,xr),[D]),S=s&&r&&!p&&!d&&!t&&e.length===0&&j.length>0,_=`${S}:${j.length}`,I=c.stamp===_?c.index:0,L=a.useCallback(w=>{f.current&&ie(w.target)&&(u(!1),k(!1),l(!0))},[]),$=a.useCallback(w=>{ie(w.target)&&l(!0)},[]),T=a.useCallback(w=>{ie(w.target)&&l(!1)},[]),B=a.useCallback(w=>{j.length!==0&&h(v=>{const P=v.stamp===_?v.index:0;return{stamp:_,index:(P+w+j.length)%j.length}})},[j.length,_]),F=a.useCallback(()=>B(1),[B]),H=a.useCallback(()=>B(-1),[B]),W=a.useCallback(()=>{u(!0)},[]),q=a.useCallback(w=>{if(u(!0),w.kind==="session"){w.session.cwd&&Ie.getState().recordOpened("agent",w.session.cwd),n(fe({dir:w.session.cwd??void 0,session:w.session.id}));return}Ie.getState().recordOpened("room",w.room.id),n({...bt.channels(),search:{id:w.room.id}})},[n]),z=a.useCallback(()=>{const w=j[I];!S||!w||q(w)},[S,j,I,q]);return{isOpen:S,hasRows:j.length>0,rows:j,agents:N,displayNames:m,visualOf:E,selectedIndex:I,activeDescendantId:S&&j[I]!==void 0?Ue(I):void 0,listboxId:S?Ht:void 0,handleFocus:L,handleBlur:T,handlePointerDown:$,moveDown:F,moveUp:H,selectHighlighted:z,selectRow:q,dismiss:W}}function zt({mark:e,label:t,title:s,summary:n,lastActivityAt:o,index:r,isSelected:l,now:c,onSelect:h}){const p=a.useMemo(()=>Number.isNaN(Date.parse(o))?null:zn(o),[o,c]);return i.jsxs("div",{id:Ue(r),role:"option","aria-selected":l,"data-selected":l,title:s,onClick:h,className:"data-[selected=true]:bg-accent hover:bg-muted flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 transition-colors duration-100",children:[i.jsx("span",{className:"mt-px flex shrink-0 items-center",children:e}),i.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[i.jsxs("span",{className:"flex w-full items-center gap-1.5",children:[i.jsx("span",{className:"text-foreground min-w-0 flex-1 truncate text-sm",children:t}),p!==null&&i.jsx("span",{className:"text-muted-foreground/60 text-3xs shrink-0",children:p})]}),n!==null&&i.jsx("span",{className:"text-muted-foreground/70 text-2xs truncate",children:n})]})]})}function vr({item:e,agent:t,displayName:s,index:n,isSelected:o,now:r,onSelect:l}){const c=Ln(t,e.session.cwd??s);return i.jsx(zt,{mark:i.jsx(Fn,{color:c.color,emoji:c.emoji,size:"xs"}),label:e.name,title:`${s} · ${e.name}`,summary:e.summary,lastActivityAt:e.lastActivityAt,index:n,isSelected:o,now:r,onSelect:l})}function Rr({item:e,visual:t,index:s,isSelected:n,now:o,onSelect:r}){return i.jsx(zt,{mark:i.jsx(Bn,{room:e.room,participants:e.room.participants,visuals:Hn(t)}),label:i.jsx(qn,{room:e.room}),title:e.summary===null?e.name:`${e.name} · ${e.summary}`,summary:e.summary,lastActivityAt:e.lastActivityAt,index:s,isSelected:n,now:o,onSelect:r})}function kr({rows:e,selectedIndex:t,agents:s={},displayNames:n={},visualOf:o,onSelect:r}){const l=ht(6e4);return a.useEffect(()=>{var c,h;(h=(c=document.getElementById(Ue(t)))==null?void 0:c.scrollIntoView)==null||h.call(c,{block:"nearest"})},[t]),i.jsx(_e.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:c=>c.preventDefault(),children:i.jsx("div",{id:Ht,role:"listbox","aria-label":"Jump back in",className:"max-h-72 overflow-y-auto p-1.5",children:e.map((c,h)=>{var p;return c.kind==="session"?i.jsx(vr,{item:c,agent:c.session.cwd&&s[c.session.cwd]||null,displayName:c.session.cwd&&n[c.session.cwd]||((p=c.session.cwd)==null?void 0:p.split("/").pop())||"Agent",index:h,isSelected:h===t,now:l,onSelect:()=>r(c)},`session-${c.id}`):i.jsx(Rr,{item:c,visual:o(c.room),index:h,isSelected:h===t,now:l,onSelect:()=>r(c)},`room-${c.id}`)})})})}const nt={people:"People",agents:"Agents"},wr=["people","agents"];function Sr(e,t){const s=[];for(const{author:n}of e){if(n.kind==="system"||n.id===t||n.retired)continue;const o=n.handle;s.push({section:n.kind==="agent"?"agents":"people",authorId:n.id,label:n.displayName,...o?{handle:o}:{},...n.emoji?{emoji:n.emoji}:{},...n.color?{color:n.color}:{},disabled:!o,...o?{}:{disabledReason:"No @name"}})}return s}function Nr(e,t,s){const n=t.trim().toLowerCase(),o=e.map((r,l)=>({row:r,position:l,tier:Ir(r,n)})).filter(r=>r.tier!==null).sort((r,l)=>r.tier-l.tier||r.position-l.position);return s.flatMap(r=>o.filter(l=>l.row.section===r).map(({row:l})=>l))}function Ir(e,t){var o;if(t==="")return 0;const s=[(o=e.handle)==null?void 0:o.toLowerCase(),e.label.toLowerCase()].filter(r=>r!==void 0);let n=null;for(const r of s){const l=r===t?0:r.startsWith(t)?1:r.includes(t)?2:null;l!==null&&(n===null||l<n)&&(n=l)}return n}function de(e,t,s){var r;const n=e.length;if(n===0)return 0;let o=(t%n+n)%n;for(let l=0;l<n;l++){if(!((r=e[o])!=null&&r.disabled))return o;o=(o+s+n)%n}return 0}function jr(e,t,s,n){const o=e.slice(0,t),r=e.slice(t+1+s.length),l=`@${n}`,c=r.startsWith(" ")?"":" ";return{value:o+l+c+r,cursorPos:o.length+l.length+1}}const Cr=/(^|\s)@([A-Za-z0-9_.-]*)$/,Ut="mention-palette-listbox";function Ee(e){return`mention-item-${e}`}function Ar({members:e,viewerAuthorId:t,text:s,sectionOrder:n=wr}){var $;const[o,r]=a.useState(!1),[l,c]=a.useState(""),[h,p]=a.useState(-1),u=Un(s),d=a.useRef(!1),k=a.useMemo(()=>Sr(e,t),[e,t]),f=a.useMemo(()=>o?Nr(k,l,n):[],[k,l,o,n]),[g,y]=a.useState(null),x=g!==null&&g.query===l&&g.open===o?g.index:de(f,0,1),N=f[x],m=f.length===0||N!==void 0&&!N.disabled?x:de(f,0,1),b=a.useCallback((T,B)=>{const F=T.slice(0,B).match(Cr);if(!F){r(!1);return}r(!0),c(F[2]),p((F.index??0)+F[1].length)},[]),E=a.useCallback(T=>{u.write(T),d.current=!1},[u]),O=a.useCallback(T=>{d.current||b(u.read(),T)},[b,u]),D=a.useCallback(()=>{y({query:l,open:o,index:de(f,m+1,1)})},[f,m,l,o]),j=a.useCallback(()=>{y({query:l,open:o,index:de(f,m-1,-1)})},[f,m,l,o]),S=a.useCallback(T=>T.disabled||T.handle===void 0?null:(d.current=!0,r(!1),jr(u.read(),h,l,T.handle)),[h,l,u]),_=a.useCallback(()=>{const T=f[m];return T?S(T):(r(!1),null)},[f,m,S]),I=a.useCallback(()=>{d.current=!0,r(!1)},[]),L=f.some(T=>!T.disabled);return{isOpen:o,hasSelectableRows:L,rows:f,selectedIndex:m,activeDescendantId:o&&(($=f[m])==null?void 0:$.disabled)===!1?Ee(m):void 0,listboxId:o?Ut:void 0,noteTextChange:E,handleCursorChange:O,moveDown:D,moveUp:j,selectHighlighted:_,selectRow:S,dismiss:I}}function Mr({rows:e,selectedIndex:t,onSelect:s}){const n=a.useMemo(()=>{const o=[];return e.forEach((r,l)=>{const c=o[o.length-1];c&&c.section===r.section?c.items.push({row:r,index:l}):o.push({section:r.section,items:[{row:r,index:l}]})}),o},[e]);return a.useEffect(()=>{var o;(o=document.getElementById(Ee(t)))==null||o.scrollIntoView({block:"nearest"})},[t]),i.jsx(_e.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:o=>o.preventDefault(),children:i.jsx("div",{id:Ut,role:"listbox","aria-label":"Mentions",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?i.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No one by that name."}):n.map(({section:o,items:r},l)=>i.jsxs("div",{role:"group","aria-label":nt[o],children:[l>0&&i.jsx("div",{className:"bg-border mx-2 my-1.5 h-px"}),i.jsx("div",{"aria-hidden":!0,className:"text-muted-foreground/70 text-2xs px-2 pt-1.5 pb-1 font-medium tracking-wide uppercase",children:nt[o]}),r.map(({row:c,index:h})=>{const p=h===t;return i.jsxs("div",{id:Ee(h),role:"option","aria-selected":p,"aria-disabled":c.disabled,"data-selected":p,"data-disabled":c.disabled,onClick:()=>{c.disabled||s(c)},className:c.disabled?"flex cursor-not-allowed items-center gap-2 rounded-md px-2 py-1.5 opacity-45":"data-[selected=true]:bg-accent hover:bg-muted flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 transition-colors duration-100",children:[i.jsx("span",{"aria-hidden":!0,className:"size-4 shrink-0 text-center text-sm leading-none",children:c.emoji}),i.jsx("span",{className:"text-foreground truncate text-sm font-medium",children:c.label}),c.handle!==void 0&&i.jsxs("span",{className:"text-muted-foreground/70 truncate font-mono text-xs",children:["@",c.handle]}),c.disabledReason!==void 0&&i.jsx("span",{className:"text-muted-foreground/70 text-2xs ml-auto shrink-0",children:c.disabledReason})]},c.authorId)})]},o))})})}function Wt({room:e,threadRootId:t,focusOnMount:s,offerJumpBackIn:n,onFocusChange:o,attachments:r}){const l=t===void 0?e.id:lt(e.id,t),c=Wn(l),{target:h}=kt(),p=Kn(),u=Gn(l),d=a.useRef(null),k=be(e.members,e.viewerAuthorId),f=a.useRef(!1),g=Ar({members:e.members,viewerAuthorId:e.viewerAuthorId,text:c}),y=n===!0,x=br({value:c,yieldToPalette:g.isOpen,enabled:y}),N=a.useRef(u);a.useEffect(()=>{var I;u!==N.current&&(N.current=u,(I=d.current)==null||I.focus())},[u]),a.useEffect(()=>{var I;s===!0&&((I=d.current)==null||I.focusUnlessTouch())},[]);const m=a.useCallback(I=>ue.getState().set(l,I),[l]),[b,E]=a.useState(null);a.useLayoutEffect(()=>{var I;b!==null&&((I=d.current)==null||I.focusAt(b.pos))},[b]);const O=a.useCallback(I=>{I&&(m(I.value),E({pos:I.cursorPos}))},[m]),D=a.useCallback(I=>O(g.selectRow(I)),[g,O]),j=a.useCallback(()=>O(g.selectHighlighted()),[g,O]),S=()=>{if(h===null||!h.canSend||f.current)return;g.dismiss();const I=ue.getState().take(l).trim();if(I==="")return;const L=r.pendingFiles.length>0;L&&(f.current=!0),h.send({text:I}).catch(()=>{const $=ue.getState(),T=$.drafts[l]??"";$.set(l,T===""?I:`${I}
|
|
44
|
-
${T}`)}).finally(()=>{L&&(f.current=!1)})};if(!k)return i.jsxs("div",{className:"flex items-center justify-between gap-3 border-t px-4 py-3",children:[i.jsx("p",{className:"text-muted-foreground text-sm",children:xt}),i.jsx(Oe,{type:"button",size:"sm",variant:"outline",disabled:p.isPending,onClick:()=>p.mutate({roomId:e.id,authorId:e.viewerAuthorId},{onSuccess:()=>yt.success(`You joined ${se(e)}`)}),children:Qn})]});const _=i.jsx(X.Composer,{inputRef:d,value:c,onChange:I=>{m(I),g.noteTextChange(I)},onSubmit:S,head:i.jsx("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:g.isOpen&&g.rows.length===0?"No one by that name.":""}),mentionPicker:i.jsx(je,{children:g.isOpen&&i.jsx(Mr,{rows:g.rows,selectedIndex:g.selectedIndex,onSelect:D})}),overlays:i.jsx(i.Fragment,{children:i.jsx(je,{children:x.isOpen&&i.jsx(kr,{rows:x.rows,selectedIndex:x.selectedIndex,agents:x.agents,displayNames:x.displayNames,visualOf:x.visualOf,onSelect:x.selectRow})})}),input:{onCursorChange:g.handleCursorChange,isStreaming:!1,isPaletteOpen:g.isOpen||x.isOpen,paletteHasResults:x.isOpen?x.hasRows:g.hasSelectableRows,onArrowUp:x.isOpen?x.moveUp:g.moveUp,onArrowDown:x.isOpen?x.moveDown:g.moveDown,onCommandSelect:x.isOpen?x.selectHighlighted:j,onEscape:x.isOpen?x.dismiss:g.dismiss,tabPicks:!x.isOpen,onClear:()=>{m(""),g.dismiss()},activeDescendantId:x.isOpen?x.activeDescendantId:g.activeDescendantId,paletteListboxId:x.isOpen?x.listboxId:g.listboxId,contextKey:l,...r.hasFailedUpload?{canSubmitReason:"A file didn’t upload. Try it again or remove it, then send."}:{}}});return!y&&o===void 0?_:i.jsx("section",{className:"flex flex-col","data-testid":Vn.homeComposer,onFocus:I=>{x.handleFocus(I),ie(I.target)&&(o==null||o(!0))},onBlur:I=>{x.handleBlur(I),ie(I.target)&&(o==null||o(!1))},onPointerDown:x.handlePointerDown,children:_})}function Er(e){return e.kind!=="channel"||e.bridge!=null||e.archived?!1:!e.members.some(t=>t.author.kind==="agent")}function Or({room:e,hasEntries:t,onAddAgents:s}){return!t||!Er(e)?null:i.jsxs("p",{className:"text-muted-foreground shrink-0 px-4 pb-1 text-xs","data-testid":"no-agent-hint",children:["No agent is in this channel to answer."," ",i.jsx("button",{type:"button",onClick:s,className:"text-foreground focus-visible:ring-ring rounded-sm underline underline-offset-2 focus-visible:ring-2 focus-visible:outline-none",children:"Add one"})," ","to get answers here."]})}function Tr({roomId:e}){const{approvals:t}=Yn(),s=Jn(t).filter(n=>n.roomId===e);return s.length===0?null:i.jsx("section",{"data-slot":"room-approvals","aria-label":"Requests waiting on you",className:"shrink-0 px-3 pb-2 md:px-4",children:i.jsx(Xn,{approvals:s})})}function _r({roomId:e}){const{data:t}=zs("pending"),s=(t??[]).filter(n=>n.roomId===e);return s.length===0?null:i.jsx("section",{"data-slot":"room-agent-requests","aria-label":"Apps agents are asking for",className:"shrink-0 space-y-2 px-3 pb-2 md:px-4",children:s.map(n=>i.jsx(Us,{request:n},n.requestId))})}const Pr="An agent",st=64,Ne=3,Dr=new Set;function Kt({room:e,entries:t,scope:s,laneScope:n,stalled:o,unavailable:r=!1,onRetry:l,onScrollToRow:c}){const h=Te(),p=Zn(e.id,s),u=es(e.id,s),d=ts(e.id,s),[k,f]=a.useState(!1),g=Ot(e.id,{enabled:k}),y=ns(),{mutate:x}=uo(),[N,m]=a.useState(Dr),b=a.useCallback(R=>{m(A=>new Set(A).add(R)),x({roomId:e.id,authorId:R},{onSettled:()=>m(A=>{const C=new Set(A);return C.delete(R),C})})},[x,e.id]),E=mo(),[O,D]=a.useState(()=>new Map),j=ss(),S=Be(),_=a.useMemo(()=>Le(e.members,e.formerAuthors),[e.members,e.formerAuthors]),I=a.useCallback(R=>{var A;return((A=_.get(R))==null?void 0:A.displayName)??Pr},[_]),{interactions:L}=os(),$=a.useMemo(()=>L.filter(R=>R.roomId===e.id),[L,e.id]),T=a.useMemo(()=>{var A;const R={};for(const C of $){if(C.roomAuthorId===void 0)continue;const U=(A=_.get(C.roomAuthorId))==null?void 0:A.displayName;U!==void 0&&(R[C.sessionId]=U)}return R},[$,_]),B=a.useMemo(()=>p.map(R=>({authorId:R.authorId,name:I(R.authorId),state:R.state,since:R.since,activity:R.activity??null})),[p,I]),F=a.useMemo(()=>u.map(R=>{var C;const A=(C=j.data)==null?void 0:C.find(U=>U.id===R.behindRoomId);return{authorId:R.authorId,name:I(R.authorId),since:R.since,behind:{roomId:R.behindRoomId,title:A===void 0?null:se(A)},othersWaiting:R.othersWaiting,severalInTheWay:R.severalInTheWay}}),[u,I,j.data]),H=a.useMemo(()=>{const R=new Set;for(const A of u)O.get(A.authorId)===A.entryId&&R.add(A.authorId);return R},[u,O]),W=a.useMemo(()=>d===null?null:{authorId:d.authorId,name:I(d.authorId)},[d,I]),q=a.useMemo(()=>Ms({capabilities:ze,asks:$,agentNames:T,stalled:o,presence:B,held:F,silentFinish:W,turn:null}),[$,T,B,F,W,o]),z=a.useMemo(()=>{var A;const R=new Map;for(const C of((A=g.data)==null?void 0:A.bindings)??[])R.set(C.authorId,C.sessionId);return R},[g.data]),w=a.useCallback(R=>{const A=t.find(U=>U.id===R);if(A===void 0)return null;const C=A.body.text.replace(/\s+/gu," ").trim();return C.length===0?null:C.length>st?`${C.slice(0,st).trimEnd()}…`:C},[t]),v=a.useCallback(R=>{var A;return n==="thread"?Ae(R):((A=Fe(t,R))==null?void 0:A.domId)??null},[t,n]),P=a.useMemo(()=>{const R=p.map(C=>{const U=w(C.entryId),G=v(C.entryId);return{authorId:C.authorId,author:J(C.authorId,_,S.faces),state:C.state,since:C.since,doing:rs(C.activity),replyingTo:U===null||G===null?null:{entryId:C.entryId,excerpt:U,rowId:G},sessionId:z.get(C.authorId)??null}}),A=F.map(C=>({authorId:C.authorId,author:J(C.authorId,_,S.faces),state:"held",since:C.since,doing:null,replyingTo:null,sessionId:null,behind:C.behind,othersWaiting:C.othersWaiting}));return[...R,...A]},[p,F,_,S.faces,w,v,z]),M=a.useMemo(()=>{if(p.length===0)return null;const R=p.slice(0,Ne);return i.jsxs("span",{"aria-hidden":"true",className:"flex shrink-0 -space-x-1",children:[R.map(A=>i.jsx(vt,{author:J(A.authorId,_,S.faces),className:"ring-background size-4 ring-2"},A.authorId)),p.length>Ne&&i.jsx("span",{className:"bg-muted text-muted-foreground ring-background text-3xs flex size-4 items-center justify-center rounded-full ring-2",children:`+${p.length-Ne}`})]})},[p,_,S.faces]);return i.jsx(X.LiveLane,{state:q,scope:n,onRetry:l,unavailable:r,faces:M,onPeekOpenChange:f,askCard:q.kind==="ask"?i.jsx(as,{ask:q.ask,...T[q.ask.sessionId]?{agentName:T[q.ask.sessionId]}:{},onOpenSession:R=>{h(fe({session:R}))},className:"border-l-0"}):void 0,peek:i.jsx(X.LivePeek,{rows:P,onScrollToRow:c,onOpenSession:R=>{h(fe({session:R}))},onOpenRoom:R=>{h({...bt.channels(),search:{id:R}})},onAnswerFirst:R=>{const A=u.find(C=>C.authorId===R);A!==void 0&&D(C=>new Map(C).set(R,A.entryId)),E.mutate({roomId:e.id,authorId:R})},promoted:H,onStopAll:()=>y.mutate({roomId:e.id}),stopping:y.isPending,onStopAgent:b,stoppingAgents:N})})}const ot=3e3;function $r(e,t,s,n=Date.now){const o=a.useRef(null),r=a.useRef(new Map),l=a.useRef(new Map),c=o.current,h=r.current,p=l.current,u=n();for(const d of e){if(p.has(d.id))continue;if(c===null){p.set(d.id,"at-rest");continue}const k=h.get(d.authorId);p.set(d.id,k!==void 0&&u-k<ot?"handed-off":"dropped")}return a.useEffect(()=>{if(!s)return;o.current=new Set(e.map(k=>k.id));const d=n();for(const k of t)r.current.set(k,d);for(const[k,f]of r.current)d-f>ot&&r.current.delete(k);for(const k of l.current.keys())o.current.has(k)||l.current.delete(k)}),p}function Lr({kind:e}){return e==="thread-error"?i.jsxs("div",{"data-slot":"thread-notice","data-testid":"room-thread-error",className:"text-muted-foreground flex flex-col items-center gap-2 px-[var(--msg-padding-x)] py-6 text-center text-sm",children:[i.jsx("p",{className:"text-foreground font-medium",children:"Couldn’t load this thread"}),i.jsx("p",{className:"max-w-sm text-xs",children:"Nothing was lost. Reload to try again."})]}):e==="thread-waiting"?i.jsxs("div",{"data-slot":"thread-notice",className:"flex flex-col gap-2 px-[var(--msg-padding-x)]",children:[i.jsx(ae,{className:"h-3 w-24"}),i.jsx(ae,{className:"h-3 w-full max-w-sm"})]}):i.jsx("p",{"data-slot":"thread-notice","data-testid":"room-thread-orphan",className:"text-muted-foreground border-b px-[var(--msg-padding-x)] pb-3 text-xs italic",children:"This thread’s first message is gone. Its replies remain."})}function Fr({room:e,rootEntryId:t,focusComposer:s,entries:n,reactionFrequents:o,streamStalled:r,streamUnavailable:l,onRetryStream:c,historyLoaded:h,historyFailed:p=!1,landOnRow:u,pushed:d,onClose:k}){const f=a.useMemo(()=>Le(e.members,e.formerAuthors),[e.members,e.formerAuthors]),g=Bt({room:e,threadRootId:t}),y=be(e.members,e.viewerAuthorId),x=Be(),N=a.useMemo(()=>new Map([...f].map(([w,v])=>[w,v.displayName])),[f]),{root:m,replies:b}=a.useMemo(()=>{let w;const v=[];for(const P of n)P.id===t?w=P:Z(P)===t&&v.push(P);return{root:w,replies:v}},[n,t]),E=m==null?void 0:m.threadReplyCount,O=E!==void 0&&E>b.length,D=m===void 0||O?-1:1+b.length,j=$e(b.length,E),S=a.useMemo(()=>new Set(b.map(w=>w.id)),[b]),_=a.useMemo(()=>({replyIds:S,inside:!0}),[S]),I=is(e.id,_),L=gt(e.id,t),$=$r(b,I,h),T=a.useRef(null),B=a.useCallback(w=>{var v;(v=T.current)==null||v.scrollToRow(w)},[]),F=a.useRef(null);a.useEffect(()=>{var w;s||(w=F.current)==null||w.focus()},[t,s]);const H=w=>{w.key!=="Escape"||w.defaultPrevented||(w.stopPropagation(),k())},W=a.useMemo(()=>{const w=[];if(m===void 0){const v=p?"thread-error":h?"thread-orphan":"thread-waiting";w.push({kind:"notice",id:v,at:"",body:null})}else w.push({kind:"message",id:m.id,payload:m,grouping:{position:"only"},author:J(pe(m,f),f,x.faces),at:m.createdAt});for(const v of b)w.push({kind:"message",id:v.id,payload:v,grouping:{position:"only"},author:J(pe(v,f),f,x.faces),at:v.createdAt});return w},[m,b,f,x.faces,p,h]),q=a.useCallback(w=>{if(w.kind==="notice")return i.jsx(Lr,{kind:w.id});if(w.kind!=="message")return null;const v=w.payload,P=m!==void 0&&v.id===m.id,M=b.findIndex(C=>C.id===v.id),R=i.jsx(Ft,{roomId:e.id,entry:v,rowId:Ae(v.id),author:w.author,authorRef:f.get(v.authorId),authors:f,viewerAuthorId:e.viewerAuthorId,authorNames:N,reactionFrequents:o,streamStalled:r,isMember:y,grouping:{position:"only"},answers:Pt(v,M<=0?m:b[M-1],C=>(m==null?void 0:m.id)===C?m:b.find(U=>U.id===C)),feedPosition:{index:P?1:(m===void 0?0:1)+M+1,total:D}});if(P)return j===0?R:i.jsxs(i.Fragment,{children:[R,i.jsxs("div",{"aria-hidden":!0,"data-testid":"room-thread-divider",className:"flex items-center gap-2 px-[var(--msg-padding-x)] pt-1 pb-2",children:[i.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:j===1?"1 reply":`${j} replies`}),i.jsx("span",{className:"bg-border h-px flex-1"})]})]});const A=$.get(v.id)??"at-rest";return i.jsx("div",{className:V(A==="dropped"&&"motion-safe:animate-thread-reply-in",A==="handed-off"&&"motion-safe:animate-reply-settle"),children:R})},[m,b,j,$,e.id,e.viewerAuthorId,f,N,o,r,y,D]),z=a.useCallback(w=>w.kind==="message"?Ae(w.id):void 0,[]);return i.jsx(Dt,{known:x,children:i.jsx(X.Root,{surface:"room",capabilities:ze,target:g.target,anchor:"rail",children:i.jsxs("section",{ref:F,"aria-label":"Thread","data-testid":"room-thread-panel",tabIndex:-1,onKeyDown:H,className:V("bg-card flex min-h-0 flex-col outline-none",d?"h-full w-full":"w-full border-l"),children:[i.jsxs("header",{className:"flex items-center gap-2 border-b px-3 py-2",children:[i.jsx("button",{type:"button",onClick:k,"aria-label":d?`Back to ${se(e)}`:"Close thread",className:V("focus-ring text-muted-foreground hover:text-foreground relative -ml-1 rounded p-1","after:absolute after:-inset-2.5 md:after:hidden"),children:d?i.jsx(ls,{"aria-hidden":!0,className:"size-4"}):i.jsx(cs,{"aria-hidden":!0,className:"size-4"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"text-sm font-medium",children:"Thread"}),i.jsx("p",{className:"text-muted-foreground truncate text-xs",children:se(e)})]})]}),i.jsx(X.Timeline,{ref:T,conversationId:`thread-${t}`,label:`Thread in ${se(e)}`,busy:!h&&!p,rows:W,renderRow:q,domIdOf:z,...u===void 0?{}:{landOnRow:u},pending:L,viewerAuthorId:e.viewerAuthorId,className:"py-3",feedTestId:"room-thread-feed"}),i.jsx(Kt,{room:e,entries:n,scope:_,laneScope:"thread",stalled:d&&r===!0,unavailable:l,onRetry:d?c:void 0,onScrollToRow:B}),i.jsx(Wt,{room:e,threadRootId:t,attachments:g.attachments,focusOnMount:s},t)]})})})}const ve="room-thread-split",qr=320,Br=360,Hr=40,zr=50,Ur=25;function rt(e,t){return t<=0?Ur:Math.min(Math.round(e/t*1e3)/10,zr)}function Wr(e){const t=rt(qr,e),s=Math.round((100-rt(Br,e))*10)/10;return{minPct:t,maxPct:s,defaultPct:Math.min(Math.max(Hr,t),s)}}function Kr(e,t,s){if(e===null||t===null||t<=0)return s.defaultPct;const n=e/t*100;return Math.round(Math.min(Math.max(n,s.minPct),s.maxPct)*10)/10}function Gr(e){try{const t=localStorage.getItem(e),s=t===null?NaN:Number(t);return Number.isFinite(s)&&s>0?s:null}catch{return null}}function Qr(e,t){try{localStorage.setItem(e,String(Math.round(t)))}catch{}}const Vr="react-resizable-panels:room-thread-split";function Yr(){try{localStorage.removeItem(Vr)}catch{}}function Jr(){const[e,t]=a.useState(null),[s,n]=a.useState(null);return{ref:a.useCallback(r=>{if(r===null)return;t(r);const l=()=>n(r.offsetWidth);l();const c=new ResizeObserver(l);return c.observe(r),()=>{c.disconnect(),t(null),n(null)}},[]),element:e,width:s,sizing:Wr(s??0)}}const Xr=`${ve}-room`,at=`${ve}-thread`,it=`${ve}-handle`,Zr=4;function ea({room:e,thread:t,storageKey:s=us.ROOM_THREAD_WIDTH}){const{ref:n,element:o,width:r,sizing:l}=Jr(),[c,h]=a.useState(()=>Gr(s)),[p,u]=a.useState(null),d=a.useRef(null),k=Kr(c,r,l),f=r===null||(l.maxPct-l.minPct)/100*r<Zr,g=t!==!1;a.useEffect(Yr,[]);const y=a.useRef(!1);a.useLayoutEffect(()=>{var b;y.current&&((b=d.current)==null||b.resize(k))},[k,g]);const x=a.useRef(null),N=()=>{var D;const b=(D=d.current)==null?void 0:D.getSize(),E=x.current;if(x.current=null,b===void 0||r===null||r<=0||E===b)return;const O=Math.round(b/100*r);h(O),Qr(s,O)},m=p??k;return a.useLayoutEffect(()=>{const b=o==null?void 0:o.querySelector(`[data-panel-resize-handle-id="${it}"]`);b&&(b.setAttribute("aria-controls",at),b.setAttribute("aria-valuenow",String(Math.round(m))),b.setAttribute("aria-valuemin",String(Math.round(l.minPct))),b.setAttribute("aria-valuemax",String(Math.round(l.maxPct))))}),i.jsx("div",{ref:n,className:"h-full overflow-hidden",children:i.jsxs(ds,{direction:"horizontal",id:ve,onLayout:b=>{y.current=b.length>1,u(y.current?b[1]:null)},children:[i.jsx(Ve,{id:Xr,order:1,className:"flex",children:e}),g&&i.jsxs(i.Fragment,{children:[i.jsx(vs,{id:it,"aria-label":"Resize thread","data-testid":"room-thread-resize-handle",disabled:f,onDragging:b=>{var E;b&&(x.current=((E=d.current)==null?void 0:E.getSize())??null)},onKeyDownCapture:b=>{var E,O;f||(x.current=((E=d.current)==null?void 0:E.getSize())??null,!(b.key!=="Home"&&b.key!=="End")&&(b.preventDefault(),(O=d.current)==null||O.resize(b.key==="Home"?l.minPct:l.maxPct)))},onResizeEnd:N}),i.jsx(Ve,{ref:d,id:at,order:2,defaultSize:k,minSize:l.minPct,maxSize:l.maxPct,className:"flex",children:t})]})]})})}function xa({roomId:e,threadId:t,entrySeq:s,threadRoute:n,aboveTimeline:o,aboveComposer:r,offerJumpBackIn:l,onComposerFocusChange:c}){const h=ms(),p=Rs(),u=fs(e),d=u==null?void 0:u.rootEntryId,k=hr(),f=a.useCallback(()=>{var P;const v=(P=Y.getState().open[e])==null?void 0:P.rootEntryId;Y.getState().closeThread(e),v!==void 0&&k.arm(v)},[e,k]),g=a.useCallback(v=>{Y.getState().openThread(e,v)},[e]),y=ps(e),x=hs(e),N=co(e,x.isSuccess);Es(e);const m=y.data,b=a.useMemo(()=>x.data??[],[x.data]),E=Bt({room:m});gr({roomId:e,route:n,urlThreadId:t,openThreadId:d,entries:b,historyLoaded:x.isSuccess});const O=a.useMemo(()=>{var v;return((v=m==null?void 0:m.members.find(P=>P.author.id===m.viewerAuthorId))==null?void 0:v.lastReadSeq)??null},[m]),D=mr(e,O);gs(m,b);const j=a.useRef(null),S=a.useRef(void 0),_=a.useCallback(v=>{S.current=v},[]),I=a.useCallback(()=>S.current,[]);a.useLayoutEffect(()=>{S.current=void 0},[e]);const L=a.useCallback(v=>{var P;(P=j.current)==null||P.scrollToRow(v)},[]),$=ho(e),{loadOlder:T,cursor:B}=$,F=a.useCallback(()=>{const v=Eo(b,B);T().then(()=>{v!==null&&requestAnimationFrame(()=>{var P;return(P=j.current)==null?void 0:P.scrollToRow(v.domId)})})},[b,B,T]),H=ur({roomId:e,entrySeq:s,entries:b,historyLoaded:x.isSuccess}),W=a.useMemo(()=>d===void 0?void 0:{replyIds:new Set(b.filter(P=>Z(P)===d).map(P=>P.id)),inside:!1},[b,d]);if(y.isLoading)return i.jsx("div",{className:"flex h-full flex-col","aria-busy":!0,children:i.jsx(qt,{})});if(y.isError||!m)return i.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-2 p-10 text-center text-sm",children:[i.jsx("p",{className:"text-foreground font-medium",children:"That channel or DM isn’t here"}),i.jsx("p",{className:"max-w-sm",children:"It may be archived, or the link is old."})]});const q=u!==void 0&&i.jsx(Fr,{room:m,rootEntryId:u.rootEntryId,focusComposer:u.focusComposer,entries:b,reactionFrequents:m.reactionFrequents,streamStalled:N.stalled,streamUnavailable:N.unavailable,onRetryStream:N.retry,historyLoaded:x.isSuccess,historyFailed:x.isError,...H.threadRow===void 0?{}:{landOnRow:H.threadRow},pushed:h,onClose:f},u.rootEntryId),z=i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[o,i.jsx(cr,{ref:j,roomId:m.id,roomName:se(m),viewerAuthorId:m.viewerAuthorId,entries:b,members:m.members,formerAuthors:m.formerAuthors,lastReadSeq:D,reactionFrequents:m.reactionFrequents,streamStalled:N.stalled,isLoading:x.isLoading,error:x.error,onAddAgents:()=>Ye("add",m.id),openThreadId:d,onOpenThread:g,resumeRow:I,...H.roomRow===void 0?{}:{landOnRow:H.roomRow},onTopRow:_,canLoadOlder:$.canLoadOlder,isLoadingOlder:$.isLoadingOlder,onLoadOlder:F}),r,i.jsx(Tr,{roomId:m.id}),i.jsx(_r,{roomId:m.id}),i.jsx(Kt,{room:m,entries:b,scope:W,laneScope:"room",stalled:N.stalled,unavailable:N.unavailable,onRetry:N.retry,onScrollToRow:L}),i.jsx(Or,{room:m,hasEntries:b.length>0,onAddAgents:()=>Ye("add",m.id)}),i.jsx(Wt,{room:m,attachments:E.attachments,offerJumpBackIn:l,onFocusChange:c},m.id)]}),w={surface:"room",capabilities:ze,target:E.target,anchor:"rail"};return h?i.jsx(X.Root,{...w,children:i.jsx(je,{initial:!1,mode:"wait",children:i.jsx(_e.div,{initial:{opacity:0,x:16},animate:{opacity:1,x:0},exit:{opacity:0,x:16},transition:{duration:.15,ease:[0,0,.2,1]},style:{paddingBottom:p},"data-testid":"room-surface",className:"flex h-full flex-col overflow-hidden",children:q===!1?z:q},q?`thread-${d}`:"room")})}):i.jsx(X.Root,{...w,children:i.jsx(ea,{room:z,thread:q})})}export{Et as I,qt as R,Io as T,xa as a,ie as i};
|
|
42
|
+
*/const Mt={name:"user-x",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]};Mt.node;const Js=ee(Mt),Xs=300;function ce({className:e,children:t}){return i.jsx("span",{className:V("bg-muted text-muted-foreground text-2xs inline-flex max-w-full items-center gap-1 truncate rounded-full px-2 py-0.5",e),children:t})}function Et({identity:e,children:t,onViewProfile:s,className:n}){const{kind:o,displayName:r,handle:l,color:c,emoji:h,imageUrl:p,origin:u,agent:d}=e,k=c??"hsl(var(--muted-foreground))",f=typeof u=="object"&&u!==null,g=o==="agent"&&(d==null?void 0:d.working)!=null?d.working:null,[y,x]=a.useState(!1),N=a.useRef(!1),m=a.useRef(null),b=Gt({onLongPress:()=>{N.current&&x(!0)}});return i.jsxs(Ds,{open:y,onOpenChange:x,openDelay:Xs,children:[i.jsx($s,{asChild:!0,ref:m,"data-gesture-priority":"",...b,onPointerDown:E=>{N.current=E.pointerType==="touch"||E.pointerType==="pen",b.onPointerDown(E)},children:t}),i.jsxs(Ls,{"data-slot":"identity-hover-card",align:"start",className:V("flex w-64 flex-col gap-0 overflow-hidden p-0",n),children:[i.jsxs("div",{className:"flex items-center gap-3 p-3",children:[i.jsx(Qt,{"aria-hidden":!0,color:k,emoji:h,imageUrl:p,fallback:Vt(r),kind:o,origin:u,status:g?"working":"idle",size:"md"}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-foreground truncate text-sm font-semibold",children:r}),l&&i.jsxs("p",{className:"text-muted-foreground truncate text-xs font-medium",children:["@",l]})]})]}),i.jsxs("div",{className:"flex flex-wrap gap-1.5 px-3 pb-3 empty:hidden",children:[o==="agent"&&((d==null?void 0:d.runtime)||(d==null?void 0:d.model))&&i.jsx(ce,{children:[d.runtime,d.model].filter(Boolean).join(" · ")}),g&&i.jsxs(ce,{className:"bg-status-success-bg text-status-success-fg",children:["Working · ",Ps(g.forMs)]}),o==="human"&&i.jsx(ce,{children:f?u.platform:"On this machine"}),o==="agent"&&(d==null?void 0:d.managedBy)&&i.jsxs(ce,{children:["Managed by"," ",d.managedBy.handle?`@${d.managedBy.handle}`:d.managedBy.displayName]})]}),s?i.jsx("button",{type:"button","data-slot":"identity-hover-card-profile",onClick:()=>{var E;(E=m.current)==null||E.focus(),s()},className:"border-border hover:bg-accent focus-visible:ring-ring text-brand mt-auto flex w-full items-center border-t px-3 py-2 text-left text-xs font-medium transition-colors focus-visible:ring-2 focus-visible:outline-none",children:"View profile"}):i.jsxs("div",{className:"border-border mt-auto flex items-center justify-between border-t px-3 py-2",children:[i.jsx("span",{className:"text-muted-foreground text-xs font-medium",children:"View profile"}),i.jsx("span",{className:"text-muted-foreground text-3xs tracking-wide uppercase",children:"soon"})]})]})]})}function Tt(e,t={}){const s=te();return Yt({queryKey:K.sessions(e??""),queryFn:()=>s.listRoomSessions(e),enabled:e!==null&&t.enabled===!0})}function Zs(e,t){const s=e??[];return s.some(n=>n.seq===t.seq)?s:s.length===0||s[s.length-1].seq<t.seq?[...s,t]:[...s,t].sort((n,o)=>n.seq-o.seq)}function eo(e,t){const s=e??[],n=s.findIndex(c=>c.id===t.id);if(n===-1)return s;const o=s[n];if(o.seq!==t.seq||o.roomId!==t.roomId||JSON.stringify(o.body)===JSON.stringify(t.body)&&JSON.stringify(o.mentions)===JSON.stringify(t.mentions)&&JSON.stringify(o.mentionSpans)===JSON.stringify(t.mentionSpans))return s;const l=[...s];return l[n]={...o,body:t.body,mentions:t.mentions,mentionSpans:t.mentionSpans},l}function to(e,t){if(t.kind!=="notice"||t.body.notice!=="turn_failed")return;const s=t.body.subjectAuthorId;s!==void 0&&re.getState().clearAuthor(e,s)}function no(e,t){const s=e.getQueryData(K.entries(t));return s&&s.length>0?s[s.length-1].seq:0}function so(e,t){var s;return((s=e.getQueryData(K.detail(t)))==null?void 0:s.viewerAuthorId)??null}const oo=2e3;function ro(){const e=a.useRef(null),t=a.useCallback(()=>{e.current!==null&&(clearTimeout(e.current),e.current=null)},[]),s=a.useCallback(o=>{t(),ne.getState().endRoomCanvasCycle(o)},[t]),n=a.useCallback(o=>{t(),e.current=setTimeout(()=>{e.current=null,ne.getState().endRoomCanvasCycle(o)},oo)},[t]);return a.useEffect(()=>t,[t]),{arm:n,now:s}}function ao(e){const t=Math.min(oe.BACKOFF_CAP_MS,oe.BACKOFF_BASE_MS*2**e);return Math.random()*t}const io=50;function lo(e,t){return new Promise(s=>{if(t.aborted)return s();const n=()=>{clearTimeout(o),t.removeEventListener("abort",n),s()},o=setTimeout(n,e);t.addEventListener("abort",n,{once:!0})})}function co(e,t){const s=te(),n=ye(),[o,r]=a.useState(null),[l,c]=a.useState(null),[h,p]=a.useState(0),u=a.useRef(!1),d=ro(),k=a.useCallback(()=>p(y=>y+1),[]),f=a.useRef(null),g=a.useCallback(()=>{f.current===null&&(f.current=setTimeout(()=>{f.current=null,p(y=>y+1)},io))},[]);return a.useEffect(()=>{if(e===null)return;const y=()=>g();let x=null;const N=()=>{if(document.visibilityState!=="visible"){x=Date.now();return}const E=x===null?0:Date.now()-x;x=null,(u.current||E>=oe.VISIBILITY_GRACE_MS)&&g()};let m=Ke.getListConnectionState();const b=Ke.subscribeListConnectionState(E=>{const T=E==="connected"&&m==="reconnecting";m=E,T&&g()});return window.addEventListener("online",y),document.addEventListener("visibilitychange",N),()=>{window.removeEventListener("online",y),document.removeEventListener("visibilitychange",N),b(),f.current!==null&&(clearTimeout(f.current),f.current=null)}},[e,g]),a.useEffect(()=>(ne.getState().setRoomCanvasLiveRoom(e),()=>ne.getState().setRoomCanvasLiveRoom(null)),[e]),a.useEffect(()=>{if(e===null||!t)return;const y=new AbortController;let x=!0,N;return(async()=>{r(null),c(null),u.current=!1;let m=0,b=!1;const E=()=>{m=0,u.current=!1,b&&(b=!1,r(T=>T===e?null:T))};for(;x&&!y.signal.aborted;){const T=Date.now();u.current=!1,ne.getState().beginRoomCanvasCycle(e),d.arm(e);const D=setTimeout(E,oe.STABILITY_WINDOW_MS);let j;try{if(j=Jt(s,e,no(n,e),y.signal),N=j,!x||y.signal.aborted){j.retire();return}for await(const S of j.stream){if(!x||y.signal.aborted||(E(),!j.current()))return;if(S.type==="canvas_event"||S.type==="canvas_channel_snapshot"){if(j.publish(S),!j.current())return;continue}if(S.type==="signal"){Xt(S)?Zt.getState().observe(e,S):(re.getState().observe(e,S),ne.getState().applyRoomCanvasPresence(e,S));continue}if(S.type==="reaction"){n.setQueryData(K.entries(e),_=>Ce(_,S.entryId,S.reactions));continue}if(S.type==="revision"){if(S.entry.roomId!==e)continue;n.setQueryData(K.entries(e),_=>eo(_,S.entry));continue}if(S.type==="canvas"){ne.getState().applyRoomCanvasFrame(e,S,so(n,e)),S.change!==void 0?d.now(e):d.arm(e);continue}re.getState().clearAuthor(e,S.entry.authorId),to(e,S.entry),en.getState().settle(e,S.entry.id),n.setQueryData(K.entries(e),_=>Zs(_,S.entry))}}catch(S){if(y.signal.aborted)return;if(console.warn("[rooms] live stream dropped",{roomId:e,err:S}),tn(S)){re.getState().clearRoom(e),c(e),r(e),clearTimeout(D);return}}finally{try{j==null||j.retire()}finally{clearTimeout(D)}}if(y.signal.aborted)return;Date.now()-T>=oe.STABILITY_WINDOW_MS&&(m=0),m+=1,u.current=!0,m>=oe.DISCONNECTED_THRESHOLD&&!b&&(re.getState().clearRoom(e),r(e),b=!0),await lo(ao(m),y.signal)}})(),()=>{x=!1;try{N==null||N.retire()}finally{y.abort()}}},[e,t,s,n,h]),{stalled:o!==null&&o===e,unavailable:l!==null&&l===e,retry:k}}function uo(){const e=te();return le({mutationFn:({roomId:t,authorId:s})=>e.haltRoomAgent(t,s),meta:{errorLabel:"Couldn’t stop this agent"}})}function mo(){const e=te();return le({mutationFn:({roomId:t,authorId:s})=>e.promoteHold(t,s),meta:{errorLabel:"Couldn’t ask to be answered first"}})}function fo(){const e=te(),t=ye();return le({onMutate:({roomId:s,entryId:n,emoji:o,viewerAuthorId:r})=>{var u;const l=t.getQueryData(K.entries(s)),c=(u=l==null?void 0:l.find(d=>d.id===n))==null?void 0:u.reactions,{reactions:h,on:p}=Je(c,o,r);return t.setQueryData(K.entries(s),d=>Ce(d,n,h)),{on:p}},mutationFn:({roomId:s,entryId:n,emoji:o,viewerAuthorId:r})=>{var h,p;const l=t.getQueryData(K.entries(s)),c=((p=(h=l==null?void 0:l.find(u=>u.id===n))==null?void 0:h.reactions)==null?void 0:p.some(u=>u.emoji===o&&u.authorIds.includes(r)))??!1;return e.toggleReaction(s,n,{emoji:o,on:c})},onError:(s,{roomId:n,entryId:o,emoji:r,viewerAuthorId:l},c)=>{c!==void 0&&t.setQueryData(K.entries(n),h=>{var d;const p=(d=h==null?void 0:h.find(k=>k.id===o))==null?void 0:d.reactions,{reactions:u}=Je(p,r,l,!c.on);return Ce(h,o,u)})},onSuccess:({frequents:s},{roomId:n})=>{t.setQueryData(K.detail(n),o=>o&&{...o,reactionFrequents:s})},meta:{errorLabel:"Couldn’t add your reaction",errorToastId:"room-reaction"}})}function Z(e){return e.threadRootEntryId??e.parentEntryId}function Ot(e){return Z(e)??e.id}function $e(e,t){return Math.max(t??0,e)}function po(e,t,s){let n=e[0],o=0;for(const r of e)r.seq>n.seq&&(n=r),t!==null&&r.seq>t&&(o+=1);return{count:$e(e.length,s),lastAt:n.createdAt,unread:o}}function ho(e){const t=te(),s=ye(),n=nn(e),o=ke(u=>{var d;return e===null?null:((d=u.paging[e])==null?void 0:d.cursor)??null}),r=le({mutationFn:async u=>{var x;const d=(x=ke.getState().paging[u])==null?void 0:x.cursor;if(d==null)return;const k=await t.listRoomEntries(u,{before:d,limit:Ge}),f=K.entries(u),g=s.getQueryData(f),y=sn(g,k);s.setQueryData(f,y),ke.getState().notePage(u,on(k)??d,rn(k,Ge)||y.length===((g==null?void 0:g.length)??0))},meta:{errorLabel:"Couldn't load older messages"}}),{mutateAsync:l,isPending:c}=r,h=a.useRef(!1),p=a.useCallback(async()=>{if(!(e===null||h.current)){h.current=!0;try{await l(e).catch(()=>{})}finally{h.current=!1}}},[e,l]);return{canLoadOlder:n,isLoadingOlder:c,cursor:o,loadOlder:p}}function go(e){return i.jsx(_s,{code:e.code,isIncomplete:e.isIncomplete})}const xo=[{language:Os,component:go}],yo={turn_failed:{Icon:hn,tone:"text-status-warning"},agent_busy:{Icon:pn},agent_gone:{Icon:Js,tone:"text-status-warning"},agent_left:{Icon:Ze,tone:"text-status-warning"},room_archived:{Icon:fn},runtime_gone:{Icon:Qs,tone:"text-status-warning"},agent_paused:{Icon:mn},agent_declined:{Icon:qs},agent_unavailable:{Icon:un},awaiting_approval:{Icon:Ws,tone:"text-status-warning"},halted:{Icon:dn},budget_reached:{Icon:cn},cascade_stopped:{Icon:ln},addressing_changed:{Icon:Gs},bridge_blocked:{Icon:Bs,tone:"text-status-warning"},bridge_undelivered:{Icon:an,tone:"text-status-warning"},bridge_rate_limited:{Icon:Ys},bridge_second_agent_refused:{Icon:Ze},bridge_disconnected:{Icon:Ks},bridge_agent_swapped:{Icon:xs},bridge_history_note:{Icon:Fs}},bo={Icon:gn},we=80;function vo(e){const t=e.trim();if(t.length<=we)return t;const s=t.slice(0,we),n=s.lastIndexOf(" ");return`${(n>we/2?s.slice(0,n):s).trimEnd()}…`}function Ro(e,t,s){const n=ko(e,s),o=r=>i.jsx("a",{href:t.href,onClick:t.onOpen,"data-testid":"room-notice-session-link",className:"focus-ring hover:text-foreground rounded py-2 font-medium underline underline-offset-2",children:r});return n===null?i.jsxs(i.Fragment,{children:[e," ",o("Open chat")]}):i.jsxs(i.Fragment,{children:[e.slice(0,n.index),o(n.words),e.slice(n.index+n.words.length)]})}function ko(e,t){if(t!==void 0){const n=xn(t),o=e.lastIndexOf(n);if(o!==-1)return{index:o,words:n}}const s=yn.exec(e);return s===null?null:{index:s.index,words:s[0]}}function wo({entry:e,feedPosition:t,rowId:s,sessionLink:n,subjectName:o}){const{Icon:r,tone:l}=(e.body.notice&&yo[e.body.notice])??bo;return i.jsxs("p",{id:s,"data-slot":"notice-row","data-testid":"room-notice","data-notice":e.body.notice??"unknown",...t&&{role:"article","aria-label":vo(e.body.text)},...Pe(t),className:V("focus-visible:ring-ring flex items-start gap-2 px-[var(--msg-padding-x)] py-2 text-xs outline-none focus-visible:ring-2",l??"text-muted-foreground"),children:[i.jsx(r,{"aria-hidden":!0,className:"mt-px size-3.5 shrink-0"}),i.jsx("span",{children:n?Ro(e.body.text,n,o):e.body.text})]})}const So=zs.moment;function No({entry:e,moment:t,subject:s,subjectIdentity:n,feedPosition:o,rowId:r}){const l=De(e.createdAt);return i.jsx("div",{id:r,"data-slot":"moment-row","data-testid":"room-moment","data-moment":t.kind,role:"article","aria-label":`Moment: ${e.body.text}`,...Pe(o),className:"focus-visible:ring-ring px-[var(--msg-padding-x)] py-1 outline-none focus-visible:ring-2",children:i.jsxs("div",{className:"border-border/60 bg-muted/40 flex items-center gap-2.5 rounded-lg border px-3 py-2",children:[i.jsx(Et,{identity:{kind:s.kind,displayName:s.displayName,handle:n==null?void 0:n.handle,color:s.color,emoji:s.emoji,imageUrl:s.imageUrl,origin:n==null?void 0:n.origin,agent:n==null?void 0:n.agent},children:i.jsxs("span",{"data-testid":"room-moment-identity",className:"flex shrink-0 items-center",children:[i.jsx(vt,{author:s}),i.jsx("span",{className:"sr-only",children:s.displayName})]})}),i.jsx(So,{"data-testid":"room-moment-mark","aria-hidden":!0,className:"text-muted-foreground size-3.5 shrink-0"}),i.jsx("p",{className:"min-w-0 flex-1 text-sm",children:e.body.text}),l.length>0&&i.jsx("time",{dateTime:e.createdAt,title:Rt(e.createdAt),className:"text-msg-timestamp shrink-0 text-xs",children:l})]})})}function Io({id:e,summary:t,open:s,onOpen:n}){const{capabilities:o}=kt(),{count:r,lastAt:l,unread:c}=t,h=De(l),[p,u]=a.useState({count:r,bumped:!1});p.count!==r&&u({count:r,bumped:!0});const d=p.count===r&&p.bumped;return o.threads?i.jsxs("button",{type:"button",id:e,"data-slot":"thread-reply-row","data-testid":"room-thread-replies","data-unread":c>0?"":void 0,"aria-expanded":s,onClick:n,className:V("focus-ring ml-[calc(var(--msg-padding-x)_+_var(--msg-gutter-width)_+_var(--msg-gap))]","mb-1 w-fit rounded text-left text-xs transition-colors","px-2 py-2 md:px-1 md:py-0.5",c>0?"text-primary hover:text-primary/80 font-medium":"text-muted-foreground hover:text-foreground"),children:[i.jsx("span",{"aria-hidden":!0,className:"mr-1",children:"↳"}),i.jsx("span",{className:V(d&&"motion-safe:animate-count-flip"),"data-testid":"room-thread-reply-count",children:r},r),r===1?" reply":" replies",h.length>0&&i.jsxs(i.Fragment,{children:[" · last ",i.jsx("time",{dateTime:l,title:Rt(l),children:h})]}),c>0&&` · ${c} new`]}):null}function jo(e,t){const s=ue.getState(),n=s.drafts[e]??"",o=n===""||n.endsWith(" ")||n.endsWith(`
|
|
43
|
+
`)?"":" ";s.set(e,`${n}${o}@${t} `)}function Co({roomId:e,entry:t,author:s,viewerAuthorId:n,onViewProfile:o}){const r=Ot(t),l=t.body.text,c=(s==null?void 0:s.id)===n?void 0:(s==null?void 0:s.handle)??void 0,h=s==null?void 0:s.displayName,{copy:p}=bn({toastOnSettle:!0});return a.useMemo(()=>{const u={reply:{id:"reply",label:"Reply in thread",icon:Vs,run:()=>{Y.getState().openThread(e,r,!0),Qe.getState().requestFocus(lt(e,r))}},copy:{id:"copy",label:"Copy text",icon:vn,run:()=>void p(l)}};return o!==void 0&&(u.profile={id:"profile",label:"View profile",icon:Rn,run:o}),c!==void 0&&(u.mention={id:"mention",label:h===void 0?"Mention author":`Mention ${h}`,icon:ys,run:()=>{jo(e,c),Qe.getState().requestFocus(e)}}),ks.map(d=>u[d]).filter(d=>d!==void 0)},[e,r,l,c,h,o,p])}function Ao(e){if(e.kind==="notice")return{kind:"notice"};const t=e.body.moment;return t?{kind:"moment",moment:t}:{kind:"message"}}function Le(e,t=[]){return new Map([...t.map(s=>[s.author.id,{...s.author,origin:s.origin}]),...e.map(s=>[s.author.id,{...s.author,origin:s.origin}])])}function pe(e,t){const s=e.body.subjectAuthorId;return s===void 0||t.has(e.authorId)?e.authorId:s}function J(e,t,s){const n=t.get(e),o=ct({record:{kind:(n==null?void 0:n.kind)??"system",id:e,displayName:(n==null?void 0:n.displayName)??"Unknown",emoji:n==null?void 0:n.emoji,color:n==null?void 0:n.color,imageUrl:n==null?void 0:n.imageUrl},override:(n==null?void 0:n.agentRef)===void 0?null:s==null?void 0:s.get(n.agentRef)});return{kind:o.kind,id:e,displayName:(n==null?void 0:n.displayName)??"Unknown",emoji:o.emoji,imageUrl:o.imageUrl,color:o.color,isExternal:typeof(n==null?void 0:n.origin)=="object"&&(n==null?void 0:n.origin)!==null,...(n==null?void 0:n.retired)===!0?{retired:!0}:{}}}function Mo(e){const t=new Set;for(const r of e)Z(r)===null&&t.add(r.id);const s=[],n=new Map,o=new Set;for(const r of e){const l=Z(r);if(l===null){s.push(r);continue}if(!t.has(l)){s.push(r),o.add(r.id);continue}const c=n.get(l);c?c.push(r):n.set(l,[r])}return{topLevel:s,repliesByRoot:n,orphaned:o}}function _t(e){return`thread-${e}`}function he(e){return`thread-row-${e}`}function Ae(e){return`thread-panel-entry-${e}`}function ge(e){return`room-entry-${e}`}function Fe(e,t){const s=e.find(c=>c.id===t);if(s===void 0)return null;const n=Z(s)??null,o={rowId:t,domId:ge(t)};if(n===null)return o;const r=e.find(c=>c.id===n);return r!==void 0&&(Z(r)??null)===null?{rowId:_t(n),domId:he(n)}:o}function Eo(e,t){if(t===null)return null;const s=e.find(n=>n.seq===t);return s===void 0?null:Fe(e,s.id)}const et=48;function Pt(e,t,s){const n=e.body.answersEntryId;if(n===void 0||n===e.id||t!==void 0&&t.id===n)return null;const o=s(n);if(o===void 0)return null;const r=o.body.text.replace(/\s+/gu," ").trim();return r.length===0?null:{entryId:n,excerpt:r.length>et?`${r.slice(0,et).trimEnd()}…`:r}}function To(e,t){const s=new Map;for(const n of e){const o=t[n.projectPath];if(!o)continue;const r=kn({runtime:o.runtime,model:o.model});s.set(dt(n.projectPath),{memberId:n.id,visual:wn(o),runtime:r.label,...r.modelLabel!==null&&{model:r.modelLabel}})}return s}function Oo(e){const t=new Map;for(const[s,n]of e)t.set(s,n.visual);return t}const _o={info:new Map,faces:new Map},Be=a.createContext(_o);function Dt({known:e,children:t}){return i.jsx(Be.Provider,{value:e,children:t})}function qe(){const e=ut(),t=a.useMemo(()=>{var l;return((l=e.data)==null?void 0:l.agents)??[]},[e.data]),s=a.useMemo(()=>t.map(l=>l.projectPath),[t]),n=mt(s),o=a.useMemo(()=>To(t,n.data??{}),[t,n.data]),r=a.useMemo(()=>Oo(o),[o]);return a.useMemo(()=>({info:o,faces:r}),[o,r])}function Me(e){const t=a.useContext(Be);return e===void 0?void 0:t.info.get(e)}function Po(){return a.useContext(Be).faces}function Do({loading:e,onLoad:t}){return i.jsx("div",{className:"flex justify-center px-4 py-3",children:i.jsxs(Te,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:e,"data-testid":"room-load-older",className:"text-muted-foreground hover:text-foreground h-7 gap-2 text-xs",children:[e&&i.jsx(Sn,{size:"xs"}),e?"Loading older messages…":"Older messages"]})})}function $o({showAuthorHeader:e,headerId:t,displayName:s,time:n,summary:o,contentId:r,summaryId:l,feedPosition:c}){return{...e?{"aria-labelledby":t}:{"aria-label":n.length>0?`${s}, ${n}`:s},"aria-describedby":o===null?r:l,...Pe(c)}}const me=120,Lo="code block";function Fo(e){if(e.length<=me&&!e.includes("```"))return null;const t=Bo(e);return t.length===0?null:t}function Bo(e){const t=e.replace(/```[\s\S]*?(?:```|$)/g,` ${Lo} `).replace(/`([^`]*)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^\s{0,3}(?:#{1,6}\s+|>\s?|[-*+]\s+)/gm,"").replace(/^\s{0,3}\|?[\s:|-]*\|[\s:|-]*$/gm," ").replace(/\|/g," ").replace(/[*_~]{1,3}/g,"").replace(/\s+/g," ").trim();if(t.length<=me)return t;const s=qo(t,me),n=s.lastIndexOf(" ");return`${(n>me/2?s.slice(0,n):s).trimEnd()}…`}function qo(e,t){if(typeof Intl.Segmenter=="function"){const n=new Intl.Segmenter(void 0,{granularity:"grapheme"});let o="";for(const{segment:r}of n.segment(e)){if(o.length+r.length>t)break;o+=r}return o}let s="";for(const n of e){if(s.length+n.length>t)break;s+=n}return s}function zo({roomId:e,entry:t,viewerAuthorId:s,reactionFrequents:n,streamStalled:o,isMember:r=!0}){const l=fo(),c=o===!0||!r,h=a.useMemo(()=>t.reactions??[],[t.reactions]),p=a.useMemo(()=>h.filter(k=>ws(k,s)).map(k=>k.emoji),[h,s]),u=a.useCallback(k=>l.mutate({roomId:e,entryId:t.id,emoji:k,viewerAuthorId:s}),[l,e,t.id,s]),d=a.useMemo(()=>({quick:n,mine:p,onToggle:u,disabled:c}),[n,p,u,c]);return{reactions:h,toggle:u,quickRow:d}}function Ho({barRef:e,pillsRef:t,hasReactions:s}){return n=>{var r,l;if(n.target!==n.currentTarget)return;const{key:o}=n;if(o==="ArrowDown"&&s){n.preventDefault(),(r=t.current)==null||r.focusFirst();return}o!=="ArrowRight"&&o!=="Enter"||(n.preventDefault(),(l=e.current)==null||l.focusFirst())}}function Uo(e,t){var d,k;const s=t.body.subjectAuthorId,n=t.body.notice,o=t.kind==="notice"&&n!==void 0&&s!==void 0&&Nn.includes(n),r=Tt(e,{enabled:o}),l=Oe(),c=ye(),h=te(),p=o?((k=(d=r.data)==null?void 0:d.bindings.find(f=>f.authorId===s))==null?void 0:k.sessionId)??null:null,u=a.useCallback(f=>{f.button!==0||f.metaKey||f.ctrlKey||f.shiftKey||f.altKey||(f.preventDefault(),!(p===null||s===void 0)&&In({queryClient:c,transport:h},e,s).then(g=>{g.kind!=="none"&&l(fe({session:g.kind==="bound"?g.sessionId:p}))}))},[s,l,c,e,p,h]);return a.useMemo(()=>p===null?null:{href:jn({session:p}),onOpen:u},[u,p])}const xe="mention",ze="author_id",Wo={[xe]:[ze]},Ko=[xe];function Go(e,t){if(!t||t.length===0)return e;const s=Qo(e,t);if(s.length===0)return e;let n=e;for(let o=s.length-1;o>=0;o--){const{offset:r,length:l,authorId:c}=s[o],h=n.slice(0,r),p=n.slice(r,r+l),u=n.slice(r+l);n=`${h}<${xe} ${ze}="${c}">${p}</${xe}>${u}`}return n}function Qo(e,t){const s=[...t].sort((r,l)=>r.offset-l.offset),n=[];let o=0;for(const r of s)r.offset<o||r.offset+r.length>e.length||(n.push(r),o=r.offset+r.length);return n}const Vo=new Map,$t=a.createContext(Vo);function Yo({authors:e,children:t}){return i.jsx($t.Provider,{value:e,children:t})}function Jo(e){const t=a.useContext($t);return e===void 0?void 0:t.get(e)}function Xo(e){return typeof e=="string"?e.replace(/^@/,""):""}function Zo({authorId:e,children:t}){const s=Jo(e),n=Me(s==null?void 0:s.agentRef),{open:o}=ft();if(!s)return i.jsx(Xe,{kind:"human",label:Xo(t),resolved:!1});const r=ct({record:s,override:n==null?void 0:n.visual}),l=pt(s,n==null?void 0:n.memberId),c=l===void 0?void 0:()=>o(l),h=c?{role:"button",tabIndex:0,"aria-label":`View ${s.displayName}’s profile`,onClick:c,onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),c())}}:{};return i.jsx(Et,{onViewProfile:c,identity:{kind:s.kind,displayName:s.displayName,handle:s.handle??void 0,color:r.color,emoji:r.emoji,imageUrl:r.imageUrl,origin:s.origin,agent:n&&{runtime:n.runtime,...n.model&&{model:n.model}}},children:i.jsx(Xe,{kind:s.kind,label:s.displayName,handle:s.handle??void 0,color:s.color,origin:s.origin,resolved:!0,interactive:c!==void 0,...h})})}function er(e){return{mention:t=>{const s=t[ze],n=typeof s=="string"?s:void 0;return!n||!e.has(n)?i.jsx(i.Fragment,{children:t.children}):i.jsx(Zo,{authorId:n,children:t.children})}}}function tr({entry:e,authors:t}){const s=a.useMemo(()=>Go(e.body.text,e.mentionSpans),[e.body.text,e.mentionSpans]),n=a.useMemo(()=>{var r;return new Set(((r=e.mentionSpans)==null?void 0:r.map(l=>l.authorId))??[])},[e.mentionSpans]),o=a.useMemo(()=>er(n),[n]);return i.jsx(Yo,{authors:t,children:i.jsx(Ts,{content:s,className:"msg-prose",allowedTags:Wo,literalTagContent:Ko,components:o,renderers:xo})})}function nr(e){return function(s){return i.jsx(tr,{entry:s,authors:e})}}const Lt="the top folder";function tt(e){return e.slice(e.lastIndexOf("/")+1)}function sr(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function or(e){return e===""?Lt:`${e}/`}function Se(e){return e.target!==void 0?e.target===""?Lt:e.target:or(sr(e.paths[0]??""))}function rr(e,t){const s=e.paths[0]??"",n=e.target;switch(e.kind){case"edit":return`${t} edited ${n??s}`;case"add":return`${t} added ${n??s}`;case"upload":return e.pathCount===1?`${t} uploaded ${tt(s)} to ${Se(e)}`:`${t} uploaded ${e.pathCount} files to ${Se(e)}`;case"rename":{const o=e.from??"";return n!==void 0?`${t} renamed ${o} to ${n}`:o.endsWith("/")?`${t} renamed ${o}`:`${t} renamed ${o} to ${s}`}case"delete":return n!==void 0?`${t} deleted ${n}`:e.pathCount===1?`${t} deleted ${s}`:`${t} deleted ${e.pathCount} files`;case"from-attachment":return`${t} saved ${tt(s)} from the chat to ${Se(e)}`}}const ar=a.lazy(()=>Cn(()=>import("./index-CJW9tZhq.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(e=>({default:e.SaveToRoomFilesButton})));function Ft({roomId:e,entry:t,author:s,authorRef:n,authors:o,viewerAuthorId:r,authorNames:l,reactionFrequents:c,streamStalled:h,isMember:p=!0,grouping:u,orphanedReply:d,answers:k,feedPosition:f,rowId:g}){const y=De(t.createdAt),x=a.useMemo(()=>{const G=Fo(t.body.text),Re=Ss(t.attachments??[]);if(Re===null)return G;const We=G??t.body.text.trim();return We.length>0?`${We} ${Re}`:Re},[t.body.text,t.attachments]),N=a.useId(),m=`${N}-author`,b=`${N}-content`,E=`${N}-summary`,T=a.useRef(null),D=a.useRef(null),j=a.useRef(null),{reactions:S,toggle:_,quickRow:I}=zo({roomId:e,entry:t,viewerAuthorId:r,reactionFrequents:c,streamStalled:h,isMember:p}),L=Me(n==null?void 0:n.agentRef),{open:$}=ft(),O=n===void 0?void 0:pt(n,L==null?void 0:L.memberId),q=a.useCallback(()=>{O!==void 0&&$(O)},[$,O]),F=O===void 0?void 0:q,z=Co({roomId:e,entry:t,author:n,viewerAuthorId:r,onViewProfile:F}),W=Ho({barRef:D,pillsRef:j,hasReactions:S.length>0}),B=a.useCallback(()=>{var G;return(G=T.current)==null?void 0:G.focus()},[]),H=a.useMemo(()=>nr(o),[o]),w=a.useCallback(G=>i.jsx(a.Suspense,{fallback:null,children:i.jsx(ar,{roomId:e,attachment:G})}),[e]),v=Po(),P=t.body.subjectAuthorId??t.authorId,M=o.get(P),R=Me(M==null?void 0:M.agentRef),A=Uo(e,t),C=Ao(t);if(C.kind==="notice")return i.jsx(wo,{entry:t,feedPosition:f,rowId:g,sessionLink:A,subjectName:M==null?void 0:M.displayName});if(C.kind==="moment")return i.jsx(No,{entry:t,moment:C.moment,subject:P===t.authorId?s:J(P,o,v),subjectIdentity:{handle:(M==null?void 0:M.handle)??void 0,origin:M==null?void 0:M.origin,agent:R&&{runtime:R.runtime,...R.model&&{model:R.model}}},feedPosition:f,rowId:g});const U=u.position==="first"||u.position==="only";return i.jsxs(Q.Root,{ref:T,id:g,position:u.position,actions:z,reactions:I,"data-testid":"room-entry",tabIndex:0,...$o({showAuthorHeader:U,headerId:m,displayName:s.displayName,time:y,summary:x,contentId:b,summaryId:E,feedPosition:f}),onKeyDown:W,children:[i.jsx(Q.Gutter,{author:s,at:t.createdAt,onViewProfile:F,isSelf:t.authorId===r}),i.jsxs(Q.Body,{children:[i.jsx(Q.Author,{id:m,author:s,at:t.createdAt,origin:n==null?void 0:n.origin}),d===!0&&i.jsx("p",{"data-testid":"room-entry-orphan",className:"text-muted-foreground text-xs italic",children:"Replying to an earlier message"}),k!=null&&i.jsx("p",{"data-testid":"room-entry-answers",className:"text-muted-foreground mb-1 truncate text-xs italic",children:`Answering “${k.excerpt}”`}),i.jsx(Q.Content,{id:b,className:"[&_:not(pre)>code]:wrap-anywhere [&_pre]:overflow-x-auto",children:t.body.fileChange?i.jsx("p",{"data-testid":"room-entry-file-change",className:"wrap-anywhere",children:rr(t.body.fileChange,(M==null?void 0:M.displayName)??"Somebody")}):H(t,{rowId:t.id,isStreaming:!1})}),x!==null&&i.jsx("span",{id:E,className:"hidden",children:x}),i.jsx(Q.Attachments,{items:t.attachments??[],renderAction:p?w:void 0}),i.jsx(Q.Reactions,{ref:j,reactions:S,viewerAuthorId:r,names:l,frequents:c,onToggle:_,disabled:h===!0||!p,onExit:B}),i.jsx(Q.Actions,{actions:z,reactions:I,barRef:D,onExit:B})]})]})}const ir="room-load-older",lr=4;function Bt({roomName:e}){return i.jsx(Ns,{label:e===void 0?"Messages":`Messages in ${e}`,busy:!0,className:"flex flex-col gap-4 p-4","data-testid":"room-timeline-loading",children:Array.from({length:lr},(t,s)=>i.jsxs("div",{className:"flex gap-3",children:[i.jsx(ae,{className:"size-7 shrink-0 rounded-full"}),i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[i.jsx(ae,{className:"h-3 w-24"}),i.jsx(ae,{className:"h-3 w-full max-w-md"})]})]},`room-skeleton-${s}`))})}function cr({roomId:e,roomName:t,viewerAuthorId:s,entries:n,members:o,formerAuthors:r,lastReadSeq:l,reactionFrequents:c,streamStalled:h,isLoading:p,error:u,onAddAgents:d,openThreadId:k,onOpenThread:f,resumeRow:g,landOnRow:y,onTopRow:x,canLoadOlder:N=!1,isLoadingOlder:m=!1,onLoadOlder:b,ref:E}){const T=a.useMemo(()=>Le(o,r),[o,r]),D=be(o,s),j=qe(),S=a.useMemo(()=>new Map([...T].map(([v,P])=>[v,P.displayName])),[T]),_=ht(),I=gt(e,null),{topLevel:L,repliesByRoot:$,orphaned:O}=a.useMemo(()=>Mo(n),[n]),q=a.useMemo(()=>new Map(n.map(v=>[v.id,v])),[n]),F=a.useMemo(()=>{const v=An(L,l),P=Mn(L.map(R=>({id:R.id,authorId:R.body.moment?`moment:${R.id}`:R.authorId,timestamp:R.createdAt})),{now:_,lastSeenId:v.lastSeenId,unreadFromStart:v.fromStart}),M=[];N&&!p&&M.push({kind:"load-older",id:ir});for(const R of P){if(R.kind==="day-divider"){M.push({kind:"day-divider",id:R.key,label:R.label});continue}if(R.kind==="unread-divider"){M.push({kind:"unread-divider",id:R.key});continue}const A=L[R.index];M.push({kind:"message",id:A.id,entry:A,grouping:R.grouping,position:R.index+1,answers:Pt(A,L[R.index-1],q.get.bind(q))});const C=$.get(A.id);C&&M.push({kind:"thread-reply",id:_t(A.id),rootId:A.id,replies:C,totalReplies:A.threadReplyCount})}return M},[L,$,q,l,_,N,p]),z=a.useMemo(()=>F.map(v=>v.kind==="load-older"?{kind:"notice",id:v.id,at:"",body:null}:v.kind==="day-divider"?{kind:"day-divider",id:v.id,label:v.label}:v.kind==="unread-divider"?{kind:"unread-divider",id:v.id}:v.kind==="thread-reply"?{kind:"thread-reply",id:v.id,rootId:v.rootId,replyCount:$e(v.replies.length,v.totalReplies),lastAt:v.replies[v.replies.length-1].createdAt}:{kind:"message",id:v.id,payload:v.entry,grouping:v.grouping,author:J(pe(v.entry,T),T,j.faces),at:v.entry.createdAt}),[F,T,j.faces]),W=a.useCallback((v,P)=>{const M=F[P.index];if(M.kind==="load-older")return b===void 0?null:i.jsx(Do,{loading:m,onLoad:b});if(M.kind==="day-divider")return i.jsx(Is,{label:M.label});if(M.kind==="unread-divider")return i.jsx(js,{});if(M.kind==="thread-reply"){if(P.onOpenThread===void 0)return null;const A=P.onOpenThread;return i.jsx(Io,{id:he(M.rootId),summary:po(M.replies,l,M.totalReplies),open:k===M.rootId,onOpen:()=>A(M.rootId)})}const R=pe(M.entry,T);return i.jsx(Ft,{roomId:e,entry:M.entry,author:J(R,T,j.faces),authorRef:T.get(R),authors:T,viewerAuthorId:s,authorNames:S,reactionFrequents:c,streamStalled:h,isMember:D,grouping:M.grouping,orphanedReply:O.has(M.entry.id),answers:M.answers,feedPosition:{index:M.position,total:-1},rowId:ge(M.entry.id)})},[F,e,T,j.faces,s,S,c,h,D,O,l,k,m,b]),B=a.useCallback(v=>{if(v.kind==="message")return ge(v.id);if(v.kind==="thread-reply")return he(v.rootId)},[]);if(u)return i.jsxs("div",{className:"text-muted-foreground flex flex-col items-center gap-2 p-10 text-center text-sm",children:[i.jsx("p",{className:"text-foreground font-medium",children:"Couldn’t load these messages"}),i.jsx("p",{className:"max-w-sm",children:"Nothing was lost. Reload to try again."})]});const H=o.some(v=>v.author.kind==="agent"),w=i.jsxs("div",{className:"text-muted-foreground flex flex-col items-center gap-2 p-10 text-center text-sm",children:[i.jsx(En,{className:"text-muted-foreground/50 size-8","aria-hidden":!0}),i.jsx("p",{className:"text-foreground font-medium",children:"Nothing said here yet"}),i.jsx("p",{className:"max-w-sm",children:H?"Say something to get it going.":"Nothing answers until you add an agent."}),i.jsx(Te,{type:"button",size:"sm",variant:H?"ghost":"default",onClick:d,className:"mt-1",children:H?"Add more agents":"Add agents"})]});return i.jsx(Dt,{known:j,children:i.jsx(X.Timeline,{ref:E,conversationId:e,label:`Messages in ${t}`,rows:z,renderRow:W,onOpenThread:f,domIdOf:B,...g===void 0?{}:{resumeRow:g},...y===void 0?{}:{landOnRow:y},...x===void 0?{}:{onTopRow:x},pending:I,viewerAuthorId:s,loading:p?i.jsx(Bt,{roomName:t}):void 0,empty:w,feedTestId:"room-timeline"})})}const He={reactions:!0,threads:!0,runWith:!1,attachments:!0,mentions:!0,streamHealth:!0,presence:!0,turnStatus:!1,asks:!0};function dr(e){const t=te(),[s,n]=a.useState([]),o=a.useRef(new Map),r=a.useCallback(f=>{const g=f.map(y=>({id:crypto.randomUUID(),file:y,status:"pending",progress:0}));n(y=>[...y,...g])},[]),l=a.useCallback(f=>{o.current.delete(f),n(g=>g.filter(y=>y.id!==f))},[]),c=a.useCallback(f=>{if(!f){o.current.clear(),n([]);return}const g=new Set(f);for(const y of g)o.current.delete(y);n(y=>y.filter(x=>!g.has(x.id)))},[]),h=a.useCallback(f=>{o.current.delete(f),n(g=>g.map(y=>y.id===f&&y.status==="error"?{...y,status:"pending",progress:0,error:void 0}:y))},[]),p=a.useRef(null),u=le({meta:{suppressErrorToast:!0},mutationFn:async f=>{n(N=>N.map(m=>f.some(b=>b.id===m.id)?{...m,status:"uploading"}:m));const g=N=>{n(m=>m.map(b=>b.status==="uploading"?{...b,progress:N.percentage}:b))},y=new AbortController;p.current=y;const x=f.map(N=>N.file);return t.uploadRoomAttachments(e,x,g,y.signal)},onSettled:()=>{p.current=null},onSuccess:(f,g)=>{g.forEach((y,x)=>{const N=f[x];N&&o.current.set(y.id,N.id)}),n(y=>y.map(x=>g.findIndex(m=>m.id===x.id)===-1?x:{...x,status:"uploaded",progress:100}))},onError:f=>{n(g=>g.map(y=>y.status==="uploading"?{...y,status:"error",error:f.message}:y))}}),d=a.useCallback(()=>{var f;(f=p.current)==null||f.abort()},[]),k=a.useCallback(async()=>{const f=s.filter(y=>y.status==="error");if(f.length>0)throw new Error(f.length===1?`${f[0].file.name} didn’t upload. Try again or remove it.`:`${f.length} files didn’t upload. Try again or remove them.`);const g=s.filter(y=>y.status==="pending");return g.length>0&&await u.mutateAsync(g),s.map(y=>o.current.get(y.id)).filter(y=>y!==void 0)},[s,u]);return{pendingFiles:s,addFiles:r,removeFile:l,retryFile:h,clearFiles:c,cancelUpload:d,uploadAndGetIds:k,hasPendingFiles:s.length>0,hasFailedUpload:s.some(f=>f.status==="error"),isUploading:u.isPending}}function qt(e){const{room:t,threadRootId:s}=e,n=Cs(),o=As(),r=dr((t==null?void 0:t.id)??""),l=t!==void 0&&be(t.members,t.viewerAuthorId),c=a.useRef({attachments:r,post:n,reply:o,room:t,threadRootId:s});a.useEffect(()=>{c.current={attachments:r,post:n,reply:o,room:t,threadRootId:s}});const h=a.useCallback(m=>c.current.attachments.addFiles(m),[]),p=a.useCallback(m=>c.current.attachments.removeFile(m),[]),u=a.useCallback(m=>c.current.attachments.retryFile(m),[]),d=a.useCallback(()=>c.current.attachments.cancelUpload(),[]),{pendingFiles:k,hasFailedUpload:f,isUploading:g}=r,y=a.useMemo(()=>({staged:k,add:h,remove:p,retry:u,cancel:d,hasFailed:f,isUploading:g,holdsSendWhileUploading:!1}),[k,f,g,h,p,u,d]),x=a.useCallback(async m=>{const{attachments:b,post:E,reply:T,room:D,threadRootId:j}=c.current;if(D===void 0)throw new Error("That room isn’t loaded yet.");if(D.archived)throw new Error("This room is archived.");Ie.getState().recordOpened("room",D.id);const S=Tn(),_=b.pendingFiles.map(O=>O.file.name),I=b.pendingFiles.map(O=>O.id),L=await b.uploadAndGetIds();b.clearFiles(I);const $=m.parentEntryId??j;if($!==void 0){T.mutate({roomId:D.id,rootEntryId:$,text:m.text,clientId:S,attachmentIds:L,attachmentNames:_});return}E.mutate({roomId:D.id,text:m.text,clientId:S,attachmentIds:L,attachmentNames:_})},[]);return{target:a.useMemo(()=>({kind:"room",id:(t==null?void 0:t.id)??"",placeholder:t===void 0?"Message…":s===void 0?`Message ${se(t)}…`:"Reply in this thread…",canSend:t!==void 0&&!t.archived&&l,...t===void 0?{canSendReason:"Still opening this room…"}:t.archived?{canSendReason:"This room is archived. You can read it, but not add to it."}:l?{}:{canSendReason:xt},send:x,attachments:y}),[t,s,l,y,x]),attachments:r}}function ur(e){const{roomId:t,entrySeq:s,entries:n,historyLoaded:o}=e,r=s===void 0?null:`${t}:${s}`,l=a.useMemo(()=>{if(s===void 0)return null;const g=n.find(m=>m.seq===s);if(g===void 0)return null;const y=Fe(n,g.id);if(y===null)return null;const x=Z(g)??null,N=x!==null&&y.rowId!==g.id;return{roomRowId:y.rowId,threadRootId:N?x:null,entryId:g.id}},[n,s]),c=a.useRef(null),h=(l==null?void 0:l.threadRootId)??null;a.useEffect(()=>{r===null||h===null||c.current!==r&&(c.current=r,Y.getState().openThread(t,h))},[r,t,h]);const p=a.useRef(null);a.useEffect(()=>{r===null||!o||l===null&&p.current!==r&&(p.current=r,yt.info("That message isn’t in the loaded history",{description:"Only recent messages are open. Nothing was lost."}))},[r,o,l]);const u=a.useRef(null),d=a.useCallback(()=>{if(!(r===null||u.current===r))return u.current=r,l==null?void 0:l.roomRowId},[r,l]),k=a.useRef(null),f=a.useCallback(()=>{if(!(r===null||k.current===r))return k.current=r,(l==null?void 0:l.threadRootId)===null||l==null?void 0:l.entryId},[r,l]);return{roomRow:s===void 0?void 0:d,threadRow:s===void 0?void 0:f}}function mr(e,t){const[s,n]=a.useState({roomId:null,seq:null});return s.roomId===e?s.seq:e===null?(n({roomId:null,seq:null}),null):t===null?null:(n({roomId:e,seq:t}),t)}const fr=600;function pr(e){return document.getElementById(he(e))??document.getElementById(ge(e))}function hr(){const e=a.useRef(null);return a.useEffect(()=>()=>{var s;return(s=e.current)==null?void 0:s.call(e)},[]),{arm:a.useCallback(s=>{var c;(c=e.current)==null||c.call(e);let n=0;const o=Date.now()+fr;let r=!1;const l=()=>{if(r)return;const h=document.activeElement;if(h===null||h===document.body||!h.isConnected){const u=pr(s);if(u!==null){u.focus();return}}Date.now()>=o||(n=requestAnimationFrame(l))};n=requestAnimationFrame(l),e.current=()=>{r=!0,cancelAnimationFrame(n)}},[])}}function gr({roomId:e,route:t,urlThreadId:s,openThreadId:n,entries:o,historyLoaded:r}){const l=On(),c=a.useRef(null);a.useEffect(()=>{if(e!==null){if(c.current!==e&&(c.current=e,s!==void 0)){Y.getState().openThread(e,s);return}if(r&&n!==void 0){const h=o.find(u=>u.id===n),p=h===void 0?void 0:Ot(h);if(p!==void 0&&p!==n){const u=Y.getState().open[e];Y.getState().openThread(e,p,(u==null?void 0:u.focusComposer)??!1);return}}n!==s&&(l==null||l({to:t,search:h=>({...h,thread:n}),replace:!0}))}},[e,t,n,s,o,r,l])}const xr=6,zt="jump-back-in-listbox";function Ue(e){return`jump-back-in-item-${e}`}const yr='[role="combobox"]';function ie(e){return e instanceof Element&&e.matches(yr)}function br({value:e,yieldToPalette:t=!1,enabled:s=!0}){const n=Oe(),o=_n(),[r,l]=a.useState(!1),[c,h]=a.useState({stamp:"",index:0}),[p,u]=a.useState(!1),[d,k]=a.useState(!1);e.length>0&&!d&&k(!0);const f=a.useRef(!1);a.useEffect(()=>{f.current=!0},[]);const{data:g}=ut({enabled:s}),y=a.useMemo(()=>((g==null?void 0:g.agents)??[]).map(w=>w.projectPath),[g]),{data:x}=mt(y,{enabled:s}),N=a.useMemo(()=>x??{},[x]),m=a.useMemo(()=>Pn(y,N),[y,N]),b=a.useMemo(()=>new Map(y.map(w=>[dt(w),w])),[y]),E=a.useCallback(w=>Dn({room:w,agentsByPath:N,pathByAgentRef:b}),[N,b]),T=a.useMemo(()=>$n(o.muted),[o.muted]),{items:D}=bs({mutedRoomIds:T,enabled:s}),j=a.useMemo(()=>D.slice(0,xr),[D]),S=s&&r&&!p&&!d&&!t&&e.length===0&&j.length>0,_=`${S}:${j.length}`,I=c.stamp===_?c.index:0,L=a.useCallback(w=>{f.current&&ie(w.target)&&(u(!1),k(!1),l(!0))},[]),$=a.useCallback(w=>{ie(w.target)&&l(!0)},[]),O=a.useCallback(w=>{ie(w.target)&&l(!1)},[]),q=a.useCallback(w=>{j.length!==0&&h(v=>{const P=v.stamp===_?v.index:0;return{stamp:_,index:(P+w+j.length)%j.length}})},[j.length,_]),F=a.useCallback(()=>q(1),[q]),z=a.useCallback(()=>q(-1),[q]),W=a.useCallback(()=>{u(!0)},[]),B=a.useCallback(w=>{if(u(!0),w.kind==="session"){w.session.cwd&&Ie.getState().recordOpened("agent",w.session.cwd),n(fe({dir:w.session.cwd??void 0,session:w.session.id}));return}Ie.getState().recordOpened("room",w.room.id),n({...bt.channels(),search:{id:w.room.id}})},[n]),H=a.useCallback(()=>{const w=j[I];!S||!w||B(w)},[S,j,I,B]);return{isOpen:S,hasRows:j.length>0,rows:j,agents:N,displayNames:m,visualOf:E,selectedIndex:I,activeDescendantId:S&&j[I]!==void 0?Ue(I):void 0,listboxId:S?zt:void 0,handleFocus:L,handleBlur:O,handlePointerDown:$,moveDown:F,moveUp:z,selectHighlighted:H,selectRow:B,dismiss:W}}function Ht({mark:e,label:t,title:s,summary:n,lastActivityAt:o,index:r,isSelected:l,now:c,onSelect:h}){const p=a.useMemo(()=>Number.isNaN(Date.parse(o))?null:Hn(o),[o,c]);return i.jsxs("div",{id:Ue(r),role:"option","aria-selected":l,"data-selected":l,title:s,onClick:h,className:"data-[selected=true]:bg-accent hover:bg-muted flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 transition-colors duration-100",children:[i.jsx("span",{className:"mt-px flex shrink-0 items-center",children:e}),i.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[i.jsxs("span",{className:"flex w-full items-center gap-1.5",children:[i.jsx("span",{className:"text-foreground min-w-0 flex-1 truncate text-sm",children:t}),p!==null&&i.jsx("span",{className:"text-muted-foreground/60 text-3xs shrink-0",children:p})]}),n!==null&&i.jsx("span",{className:"text-muted-foreground/70 text-2xs truncate",children:n})]})]})}function vr({item:e,agent:t,displayName:s,index:n,isSelected:o,now:r,onSelect:l}){const c=Ln(t,e.session.cwd??s);return i.jsx(Ht,{mark:i.jsx(Fn,{color:c.color,emoji:c.emoji,size:"xs"}),label:e.name,title:`${s} · ${e.name}`,summary:e.summary,lastActivityAt:e.lastActivityAt,index:n,isSelected:o,now:r,onSelect:l})}function Rr({item:e,visual:t,index:s,isSelected:n,now:o,onSelect:r}){return i.jsx(Ht,{mark:i.jsx(qn,{room:e.room,participants:e.room.participants,visuals:zn(t)}),label:i.jsx(Bn,{room:e.room}),title:e.summary===null?e.name:`${e.name} · ${e.summary}`,summary:e.summary,lastActivityAt:e.lastActivityAt,index:s,isSelected:n,now:o,onSelect:r})}function kr({rows:e,selectedIndex:t,agents:s={},displayNames:n={},visualOf:o,onSelect:r}){const l=ht(6e4);return a.useEffect(()=>{var c,h;(h=(c=document.getElementById(Ue(t)))==null?void 0:c.scrollIntoView)==null||h.call(c,{block:"nearest"})},[t]),i.jsx(_e.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:c=>c.preventDefault(),children:i.jsx("div",{id:zt,role:"listbox","aria-label":"Jump back in",className:"max-h-72 overflow-y-auto p-1.5",children:e.map((c,h)=>{var p;return c.kind==="session"?i.jsx(vr,{item:c,agent:c.session.cwd&&s[c.session.cwd]||null,displayName:c.session.cwd&&n[c.session.cwd]||((p=c.session.cwd)==null?void 0:p.split("/").pop())||"Agent",index:h,isSelected:h===t,now:l,onSelect:()=>r(c)},`session-${c.id}`):i.jsx(Rr,{item:c,visual:o(c.room),index:h,isSelected:h===t,now:l,onSelect:()=>r(c)},`room-${c.id}`)})})})}const nt={people:"People",agents:"Agents"},wr=["people","agents"];function Sr(e,t){const s=[];for(const{author:n}of e){if(n.kind==="system"||n.id===t||n.retired)continue;const o=n.handle;s.push({section:n.kind==="agent"?"agents":"people",authorId:n.id,label:n.displayName,...o?{handle:o}:{},...n.emoji?{emoji:n.emoji}:{},...n.color?{color:n.color}:{},disabled:!o,...o?{}:{disabledReason:"No @name"}})}return s}function Nr(e,t,s){const n=t.trim().toLowerCase(),o=e.map((r,l)=>({row:r,position:l,tier:Ir(r,n)})).filter(r=>r.tier!==null).sort((r,l)=>r.tier-l.tier||r.position-l.position);return s.flatMap(r=>o.filter(l=>l.row.section===r).map(({row:l})=>l))}function Ir(e,t){var o;if(t==="")return 0;const s=[(o=e.handle)==null?void 0:o.toLowerCase(),e.label.toLowerCase()].filter(r=>r!==void 0);let n=null;for(const r of s){const l=r===t?0:r.startsWith(t)?1:r.includes(t)?2:null;l!==null&&(n===null||l<n)&&(n=l)}return n}function de(e,t,s){var r;const n=e.length;if(n===0)return 0;let o=(t%n+n)%n;for(let l=0;l<n;l++){if(!((r=e[o])!=null&&r.disabled))return o;o=(o+s+n)%n}return 0}function jr(e,t,s,n){const o=e.slice(0,t),r=e.slice(t+1+s.length),l=`@${n}`,c=r.startsWith(" ")?"":" ";return{value:o+l+c+r,cursorPos:o.length+l.length+1}}const Cr=/(^|\s)@([A-Za-z0-9_.-]*)$/,Ut="mention-palette-listbox";function Ee(e){return`mention-item-${e}`}function Ar({members:e,viewerAuthorId:t,text:s,sectionOrder:n=wr}){var $;const[o,r]=a.useState(!1),[l,c]=a.useState(""),[h,p]=a.useState(-1),u=Un(s),d=a.useRef(!1),k=a.useMemo(()=>Sr(e,t),[e,t]),f=a.useMemo(()=>o?Nr(k,l,n):[],[k,l,o,n]),[g,y]=a.useState(null),x=g!==null&&g.query===l&&g.open===o?g.index:de(f,0,1),N=f[x],m=f.length===0||N!==void 0&&!N.disabled?x:de(f,0,1),b=a.useCallback((O,q)=>{const F=O.slice(0,q).match(Cr);if(!F){r(!1);return}r(!0),c(F[2]),p((F.index??0)+F[1].length)},[]),E=a.useCallback(O=>{u.write(O),d.current=!1},[u]),T=a.useCallback(O=>{d.current||b(u.read(),O)},[b,u]),D=a.useCallback(()=>{y({query:l,open:o,index:de(f,m+1,1)})},[f,m,l,o]),j=a.useCallback(()=>{y({query:l,open:o,index:de(f,m-1,-1)})},[f,m,l,o]),S=a.useCallback(O=>O.disabled||O.handle===void 0?null:(d.current=!0,r(!1),jr(u.read(),h,l,O.handle)),[h,l,u]),_=a.useCallback(()=>{const O=f[m];return O?S(O):(r(!1),null)},[f,m,S]),I=a.useCallback(()=>{d.current=!0,r(!1)},[]),L=f.some(O=>!O.disabled);return{isOpen:o,hasSelectableRows:L,rows:f,selectedIndex:m,activeDescendantId:o&&(($=f[m])==null?void 0:$.disabled)===!1?Ee(m):void 0,listboxId:o?Ut:void 0,noteTextChange:E,handleCursorChange:T,moveDown:D,moveUp:j,selectHighlighted:_,selectRow:S,dismiss:I}}function Mr({rows:e,selectedIndex:t,onSelect:s}){const n=a.useMemo(()=>{const o=[];return e.forEach((r,l)=>{const c=o[o.length-1];c&&c.section===r.section?c.items.push({row:r,index:l}):o.push({section:r.section,items:[{row:r,index:l}]})}),o},[e]);return a.useEffect(()=>{var o;(o=document.getElementById(Ee(t)))==null||o.scrollIntoView({block:"nearest"})},[t]),i.jsx(_e.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:o=>o.preventDefault(),children:i.jsx("div",{id:Ut,role:"listbox","aria-label":"Mentions",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?i.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No one by that name."}):n.map(({section:o,items:r},l)=>i.jsxs("div",{role:"group","aria-label":nt[o],children:[l>0&&i.jsx("div",{className:"bg-border mx-2 my-1.5 h-px"}),i.jsx("div",{"aria-hidden":!0,className:"text-muted-foreground/70 text-2xs px-2 pt-1.5 pb-1 font-medium tracking-wide uppercase",children:nt[o]}),r.map(({row:c,index:h})=>{const p=h===t;return i.jsxs("div",{id:Ee(h),role:"option","aria-selected":p,"aria-disabled":c.disabled,"data-selected":p,"data-disabled":c.disabled,onClick:()=>{c.disabled||s(c)},className:c.disabled?"flex cursor-not-allowed items-center gap-2 rounded-md px-2 py-1.5 opacity-45":"data-[selected=true]:bg-accent hover:bg-muted flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 transition-colors duration-100",children:[i.jsx("span",{"aria-hidden":!0,className:"size-4 shrink-0 text-center text-sm leading-none",children:c.emoji}),i.jsx("span",{className:"text-foreground truncate text-sm font-medium",children:c.label}),c.handle!==void 0&&i.jsxs("span",{className:"text-muted-foreground/70 truncate font-mono text-xs",children:["@",c.handle]}),c.disabledReason!==void 0&&i.jsx("span",{className:"text-muted-foreground/70 text-2xs ml-auto shrink-0",children:c.disabledReason})]},c.authorId)})]},o))})})}function Wt({room:e,threadRootId:t,focusOnMount:s,offerJumpBackIn:n,onFocusChange:o,attachments:r}){const l=t===void 0?e.id:lt(e.id,t),c=Wn(l),{target:h}=kt(),p=Kn(),u=Gn(l),d=a.useRef(null),k=be(e.members,e.viewerAuthorId),f=a.useRef(!1),g=Ar({members:e.members,viewerAuthorId:e.viewerAuthorId,text:c}),y=n===!0,x=br({value:c,yieldToPalette:g.isOpen,enabled:y}),N=a.useRef(u);a.useEffect(()=>{var I;u!==N.current&&(N.current=u,(I=d.current)==null||I.focus())},[u]),a.useEffect(()=>{var I;s===!0&&((I=d.current)==null||I.focusUnlessTouch())},[]);const m=a.useCallback(I=>ue.getState().set(l,I),[l]),[b,E]=a.useState(null);a.useLayoutEffect(()=>{var I;b!==null&&((I=d.current)==null||I.focusAt(b.pos))},[b]);const T=a.useCallback(I=>{I&&(m(I.value),E({pos:I.cursorPos}))},[m]),D=a.useCallback(I=>T(g.selectRow(I)),[g,T]),j=a.useCallback(()=>T(g.selectHighlighted()),[g,T]),S=()=>{if(h===null||!h.canSend||f.current)return;g.dismiss();const I=ue.getState().take(l).trim();if(I==="")return;const L=r.pendingFiles.length>0;L&&(f.current=!0),h.send({text:I}).catch(()=>{const $=ue.getState(),O=$.drafts[l]??"";$.set(l,O===""?I:`${I}
|
|
44
|
+
${O}`)}).finally(()=>{L&&(f.current=!1)})};if(!k)return i.jsxs("div",{className:"flex items-center justify-between gap-3 border-t px-4 py-3",children:[i.jsx("p",{className:"text-muted-foreground text-sm",children:xt}),i.jsx(Te,{type:"button",size:"sm",variant:"outline",disabled:p.isPending,onClick:()=>p.mutate({roomId:e.id,authorId:e.viewerAuthorId},{onSuccess:()=>yt.success(`You joined ${se(e)}`)}),children:Qn})]});const _=i.jsx(X.Composer,{inputRef:d,value:c,onChange:I=>{m(I),g.noteTextChange(I)},onSubmit:S,head:i.jsx("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:g.isOpen&&g.rows.length===0?"No one by that name.":""}),mentionPicker:i.jsx(je,{children:g.isOpen&&i.jsx(Mr,{rows:g.rows,selectedIndex:g.selectedIndex,onSelect:D})}),overlays:i.jsx(i.Fragment,{children:i.jsx(je,{children:x.isOpen&&i.jsx(kr,{rows:x.rows,selectedIndex:x.selectedIndex,agents:x.agents,displayNames:x.displayNames,visualOf:x.visualOf,onSelect:x.selectRow})})}),input:{onCursorChange:g.handleCursorChange,isStreaming:!1,isPaletteOpen:g.isOpen||x.isOpen,paletteHasResults:x.isOpen?x.hasRows:g.hasSelectableRows,onArrowUp:x.isOpen?x.moveUp:g.moveUp,onArrowDown:x.isOpen?x.moveDown:g.moveDown,onCommandSelect:x.isOpen?x.selectHighlighted:j,onEscape:x.isOpen?x.dismiss:g.dismiss,tabPicks:!x.isOpen,onClear:()=>{m(""),g.dismiss()},activeDescendantId:x.isOpen?x.activeDescendantId:g.activeDescendantId,paletteListboxId:x.isOpen?x.listboxId:g.listboxId,contextKey:l,...r.hasFailedUpload?{canSubmitReason:"A file didn’t upload. Try it again or remove it, then send."}:{}}});return!y&&o===void 0?_:i.jsx("section",{className:"flex flex-col","data-testid":Vn.homeComposer,onFocus:I=>{x.handleFocus(I),ie(I.target)&&(o==null||o(!0))},onBlur:I=>{x.handleBlur(I),ie(I.target)&&(o==null||o(!1))},onPointerDown:x.handlePointerDown,children:_})}function Er(e){return e.kind!=="channel"||e.bridge!=null||e.archived?!1:!e.members.some(t=>t.author.kind==="agent")}function Tr({room:e,hasEntries:t,onAddAgents:s}){return!t||!Er(e)?null:i.jsxs("p",{className:"text-muted-foreground shrink-0 px-4 pb-1 text-xs","data-testid":"no-agent-hint",children:["No agent is in this channel to answer."," ",i.jsx("button",{type:"button",onClick:s,className:"text-foreground focus-visible:ring-ring rounded-sm underline underline-offset-2 focus-visible:ring-2 focus-visible:outline-none",children:"Add one"})," ","to get answers here."]})}function Or({roomId:e}){const{approvals:t}=Yn(),s=Jn(t).filter(n=>n.roomId===e);return s.length===0?null:i.jsx("section",{"data-slot":"room-approvals","aria-label":"Requests waiting on you",className:"shrink-0 px-3 pb-2 md:px-4",children:i.jsx(Xn,{approvals:s})})}function _r({roomId:e}){const{data:t}=Hs("pending"),s=(t??[]).filter(n=>n.roomId===e);return s.length===0?null:i.jsx("section",{"data-slot":"room-agent-requests","aria-label":"Apps agents are asking for",className:"shrink-0 space-y-2 px-3 pb-2 md:px-4",children:s.map(n=>i.jsx(Us,{request:n},n.requestId))})}const Pr="An agent",st=64,Ne=3,Dr=new Set;function Kt({room:e,entries:t,scope:s,laneScope:n,stalled:o,unavailable:r=!1,onRetry:l,onScrollToRow:c}){const h=Oe(),p=Zn(e.id,s),u=es(e.id,s),d=ts(e.id,s),[k,f]=a.useState(!1),g=Tt(e.id,{enabled:k}),y=ns(),{mutate:x}=uo(),[N,m]=a.useState(Dr),b=a.useCallback(R=>{m(A=>new Set(A).add(R)),x({roomId:e.id,authorId:R},{onSettled:()=>m(A=>{const C=new Set(A);return C.delete(R),C})})},[x,e.id]),E=mo(),[T,D]=a.useState(()=>new Map),j=ss(),S=qe(),_=a.useMemo(()=>Le(e.members,e.formerAuthors),[e.members,e.formerAuthors]),I=a.useCallback(R=>{var A;return((A=_.get(R))==null?void 0:A.displayName)??Pr},[_]),{interactions:L}=os(),$=a.useMemo(()=>L.filter(R=>R.roomId===e.id),[L,e.id]),O=a.useMemo(()=>{var A;const R={};for(const C of $){if(C.roomAuthorId===void 0)continue;const U=(A=_.get(C.roomAuthorId))==null?void 0:A.displayName;U!==void 0&&(R[C.sessionId]=U)}return R},[$,_]),q=a.useMemo(()=>p.map(R=>({authorId:R.authorId,name:I(R.authorId),state:R.state,since:R.since,activity:R.activity??null})),[p,I]),F=a.useMemo(()=>u.map(R=>{var C;const A=(C=j.data)==null?void 0:C.find(U=>U.id===R.behindRoomId);return{authorId:R.authorId,name:I(R.authorId),since:R.since,behind:{roomId:R.behindRoomId,title:A===void 0?null:se(A)},othersWaiting:R.othersWaiting,severalInTheWay:R.severalInTheWay}}),[u,I,j.data]),z=a.useMemo(()=>{const R=new Set;for(const A of u)T.get(A.authorId)===A.entryId&&R.add(A.authorId);return R},[u,T]),W=a.useMemo(()=>d===null?null:{authorId:d.authorId,name:I(d.authorId)},[d,I]),B=a.useMemo(()=>Ms({capabilities:He,asks:$,agentNames:O,stalled:o,presence:q,held:F,silentFinish:W,turn:null}),[$,O,q,F,W,o]),H=a.useMemo(()=>{var A;const R=new Map;for(const C of((A=g.data)==null?void 0:A.bindings)??[])R.set(C.authorId,C.sessionId);return R},[g.data]),w=a.useCallback(R=>{const A=t.find(U=>U.id===R);if(A===void 0)return null;const C=A.body.text.replace(/\s+/gu," ").trim();return C.length===0?null:C.length>st?`${C.slice(0,st).trimEnd()}…`:C},[t]),v=a.useCallback(R=>{var A;return n==="thread"?Ae(R):((A=Fe(t,R))==null?void 0:A.domId)??null},[t,n]),P=a.useMemo(()=>{const R=p.map(C=>{const U=w(C.entryId),G=v(C.entryId);return{authorId:C.authorId,author:J(C.authorId,_,S.faces),state:C.state,since:C.since,doing:rs(C.activity),replyingTo:U===null||G===null?null:{entryId:C.entryId,excerpt:U,rowId:G},sessionId:H.get(C.authorId)??null}}),A=F.map(C=>({authorId:C.authorId,author:J(C.authorId,_,S.faces),state:"held",since:C.since,doing:null,replyingTo:null,sessionId:null,behind:C.behind,othersWaiting:C.othersWaiting}));return[...R,...A]},[p,F,_,S.faces,w,v,H]),M=a.useMemo(()=>{if(p.length===0)return null;const R=p.slice(0,Ne);return i.jsxs("span",{"aria-hidden":"true",className:"flex shrink-0 -space-x-1",children:[R.map(A=>i.jsx(vt,{author:J(A.authorId,_,S.faces),className:"ring-background size-4 ring-2"},A.authorId)),p.length>Ne&&i.jsx("span",{className:"bg-muted text-muted-foreground ring-background text-3xs flex size-4 items-center justify-center rounded-full ring-2",children:`+${p.length-Ne}`})]})},[p,_,S.faces]);return i.jsx(X.LiveLane,{state:B,scope:n,onRetry:l,unavailable:r,faces:M,onPeekOpenChange:f,askCard:B.kind==="ask"?i.jsx(as,{ask:B.ask,...O[B.ask.sessionId]?{agentName:O[B.ask.sessionId]}:{},onOpenSession:R=>{h(fe({session:R}))},className:"border-l-0"}):void 0,peek:i.jsx(X.LivePeek,{rows:P,onScrollToRow:c,onOpenSession:R=>{h(fe({session:R}))},onOpenRoom:R=>{h({...bt.channels(),search:{id:R}})},onAnswerFirst:R=>{const A=u.find(C=>C.authorId===R);A!==void 0&&D(C=>new Map(C).set(R,A.entryId)),E.mutate({roomId:e.id,authorId:R})},promoted:z,onStopAll:()=>y.mutate({roomId:e.id}),stopping:y.isPending,onStopAgent:b,stoppingAgents:N})})}const ot=3e3;function $r(e,t,s,n=Date.now){const o=a.useRef(null),r=a.useRef(new Map),l=a.useRef(new Map),c=o.current,h=r.current,p=l.current,u=n();for(const d of e){if(p.has(d.id))continue;if(c===null){p.set(d.id,"at-rest");continue}const k=h.get(d.authorId);p.set(d.id,k!==void 0&&u-k<ot?"handed-off":"dropped")}return a.useEffect(()=>{if(!s)return;o.current=new Set(e.map(k=>k.id));const d=n();for(const k of t)r.current.set(k,d);for(const[k,f]of r.current)d-f>ot&&r.current.delete(k);for(const k of l.current.keys())o.current.has(k)||l.current.delete(k)}),p}function Lr({kind:e}){return e==="thread-error"?i.jsxs("div",{"data-slot":"thread-notice","data-testid":"room-thread-error",className:"text-muted-foreground flex flex-col items-center gap-2 px-[var(--msg-padding-x)] py-6 text-center text-sm",children:[i.jsx("p",{className:"text-foreground font-medium",children:"Couldn’t load this thread"}),i.jsx("p",{className:"max-w-sm text-xs",children:"Nothing was lost. Reload to try again."})]}):e==="thread-waiting"?i.jsxs("div",{"data-slot":"thread-notice",className:"flex flex-col gap-2 px-[var(--msg-padding-x)]",children:[i.jsx(ae,{className:"h-3 w-24"}),i.jsx(ae,{className:"h-3 w-full max-w-sm"})]}):i.jsx("p",{"data-slot":"thread-notice","data-testid":"room-thread-orphan",className:"text-muted-foreground border-b px-[var(--msg-padding-x)] pb-3 text-xs italic",children:"This thread’s first message is gone. Its replies remain."})}function Fr({room:e,rootEntryId:t,focusComposer:s,entries:n,reactionFrequents:o,streamStalled:r,streamUnavailable:l,onRetryStream:c,historyLoaded:h,historyFailed:p=!1,landOnRow:u,pushed:d,onClose:k}){const f=a.useMemo(()=>Le(e.members,e.formerAuthors),[e.members,e.formerAuthors]),g=qt({room:e,threadRootId:t}),y=be(e.members,e.viewerAuthorId),x=qe(),N=a.useMemo(()=>new Map([...f].map(([w,v])=>[w,v.displayName])),[f]),{root:m,replies:b}=a.useMemo(()=>{let w;const v=[];for(const P of n)P.id===t?w=P:Z(P)===t&&v.push(P);return{root:w,replies:v}},[n,t]),E=m==null?void 0:m.threadReplyCount,T=E!==void 0&&E>b.length,D=m===void 0||T?-1:1+b.length,j=$e(b.length,E),S=a.useMemo(()=>new Set(b.map(w=>w.id)),[b]),_=a.useMemo(()=>({replyIds:S,inside:!0}),[S]),I=is(e.id,_),L=gt(e.id,t),$=$r(b,I,h),O=a.useRef(null),q=a.useCallback(w=>{var v;(v=O.current)==null||v.scrollToRow(w)},[]),F=a.useRef(null);a.useEffect(()=>{var w;s||(w=F.current)==null||w.focus()},[t,s]);const z=w=>{w.key!=="Escape"||w.defaultPrevented||(w.stopPropagation(),k())},W=a.useMemo(()=>{const w=[];if(m===void 0){const v=p?"thread-error":h?"thread-orphan":"thread-waiting";w.push({kind:"notice",id:v,at:"",body:null})}else w.push({kind:"message",id:m.id,payload:m,grouping:{position:"only"},author:J(pe(m,f),f,x.faces),at:m.createdAt});for(const v of b)w.push({kind:"message",id:v.id,payload:v,grouping:{position:"only"},author:J(pe(v,f),f,x.faces),at:v.createdAt});return w},[m,b,f,x.faces,p,h]),B=a.useCallback(w=>{if(w.kind==="notice")return i.jsx(Lr,{kind:w.id});if(w.kind!=="message")return null;const v=w.payload,P=m!==void 0&&v.id===m.id,M=b.findIndex(C=>C.id===v.id),R=i.jsx(Ft,{roomId:e.id,entry:v,rowId:Ae(v.id),author:w.author,authorRef:f.get(v.authorId),authors:f,viewerAuthorId:e.viewerAuthorId,authorNames:N,reactionFrequents:o,streamStalled:r,isMember:y,grouping:{position:"only"},answers:Pt(v,M<=0?m:b[M-1],C=>(m==null?void 0:m.id)===C?m:b.find(U=>U.id===C)),feedPosition:{index:P?1:(m===void 0?0:1)+M+1,total:D}});if(P)return j===0?R:i.jsxs(i.Fragment,{children:[R,i.jsxs("div",{"aria-hidden":!0,"data-testid":"room-thread-divider",className:"flex items-center gap-2 px-[var(--msg-padding-x)] pt-1 pb-2",children:[i.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:j===1?"1 reply":`${j} replies`}),i.jsx("span",{className:"bg-border h-px flex-1"})]})]});const A=$.get(v.id)??"at-rest";return i.jsx("div",{className:V(A==="dropped"&&"motion-safe:animate-thread-reply-in",A==="handed-off"&&"motion-safe:animate-reply-settle"),children:R})},[m,b,j,$,e.id,e.viewerAuthorId,f,N,o,r,y,D]),H=a.useCallback(w=>w.kind==="message"?Ae(w.id):void 0,[]);return i.jsx(Dt,{known:x,children:i.jsx(X.Root,{surface:"room",capabilities:He,target:g.target,anchor:"rail",children:i.jsxs("section",{ref:F,"aria-label":"Thread","data-testid":"room-thread-panel",tabIndex:-1,onKeyDown:z,className:V("bg-card flex min-h-0 flex-col outline-none",d?"h-full w-full":"w-full border-l"),children:[i.jsxs("header",{className:"flex items-center gap-2 border-b px-3 py-2",children:[i.jsx("button",{type:"button",onClick:k,"aria-label":d?`Back to ${se(e)}`:"Close thread",className:V("focus-ring text-muted-foreground hover:text-foreground relative -ml-1 rounded p-1","after:absolute after:-inset-2.5 md:after:hidden"),children:d?i.jsx(ls,{"aria-hidden":!0,className:"size-4"}):i.jsx(cs,{"aria-hidden":!0,className:"size-4"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"text-sm font-medium",children:"Thread"}),i.jsx("p",{className:"text-muted-foreground truncate text-xs",children:se(e)})]})]}),i.jsx(X.Timeline,{ref:O,conversationId:`thread-${t}`,label:`Thread in ${se(e)}`,busy:!h&&!p,rows:W,renderRow:B,domIdOf:H,...u===void 0?{}:{landOnRow:u},pending:L,viewerAuthorId:e.viewerAuthorId,className:"py-3",feedTestId:"room-thread-feed"}),i.jsx(Kt,{room:e,entries:n,scope:_,laneScope:"thread",stalled:d&&r===!0,unavailable:l,onRetry:d?c:void 0,onScrollToRow:q}),i.jsx(Wt,{room:e,threadRootId:t,attachments:g.attachments,focusOnMount:s},t)]})})})}const ve="room-thread-split",Br=320,qr=360,zr=40,Hr=50,Ur=25;function rt(e,t){return t<=0?Ur:Math.min(Math.round(e/t*1e3)/10,Hr)}function Wr(e){const t=rt(Br,e),s=Math.round((100-rt(qr,e))*10)/10;return{minPct:t,maxPct:s,defaultPct:Math.min(Math.max(zr,t),s)}}function Kr(e,t,s){if(e===null||t===null||t<=0)return s.defaultPct;const n=e/t*100;return Math.round(Math.min(Math.max(n,s.minPct),s.maxPct)*10)/10}function Gr(e){try{const t=localStorage.getItem(e),s=t===null?NaN:Number(t);return Number.isFinite(s)&&s>0?s:null}catch{return null}}function Qr(e,t){try{localStorage.setItem(e,String(Math.round(t)))}catch{}}const Vr="react-resizable-panels:room-thread-split";function Yr(){try{localStorage.removeItem(Vr)}catch{}}function Jr(){const[e,t]=a.useState(null),[s,n]=a.useState(null);return{ref:a.useCallback(r=>{if(r===null)return;t(r);const l=()=>n(r.offsetWidth);l();const c=new ResizeObserver(l);return c.observe(r),()=>{c.disconnect(),t(null),n(null)}},[]),element:e,width:s,sizing:Wr(s??0)}}const Xr=`${ve}-room`,at=`${ve}-thread`,it=`${ve}-handle`,Zr=4;function ea({room:e,thread:t,storageKey:s=us.ROOM_THREAD_WIDTH}){const{ref:n,element:o,width:r,sizing:l}=Jr(),[c,h]=a.useState(()=>Gr(s)),[p,u]=a.useState(null),d=a.useRef(null),k=Kr(c,r,l),f=r===null||(l.maxPct-l.minPct)/100*r<Zr,g=t!==!1;a.useEffect(Yr,[]);const y=a.useRef(!1);a.useLayoutEffect(()=>{var b;y.current&&((b=d.current)==null||b.resize(k))},[k,g]);const x=a.useRef(null),N=()=>{var D;const b=(D=d.current)==null?void 0:D.getSize(),E=x.current;if(x.current=null,b===void 0||r===null||r<=0||E===b)return;const T=Math.round(b/100*r);h(T),Qr(s,T)},m=p??k;return a.useLayoutEffect(()=>{const b=o==null?void 0:o.querySelector(`[data-panel-resize-handle-id="${it}"]`);b&&(b.setAttribute("aria-controls",at),b.setAttribute("aria-valuenow",String(Math.round(m))),b.setAttribute("aria-valuemin",String(Math.round(l.minPct))),b.setAttribute("aria-valuemax",String(Math.round(l.maxPct))))}),i.jsx("div",{ref:n,className:"h-full overflow-hidden",children:i.jsxs(ds,{direction:"horizontal",id:ve,onLayout:b=>{y.current=b.length>1,u(y.current?b[1]:null)},children:[i.jsx(Ve,{id:Xr,order:1,className:"flex",children:e}),g&&i.jsxs(i.Fragment,{children:[i.jsx(vs,{id:it,"aria-label":"Resize thread","data-testid":"room-thread-resize-handle",disabled:f,onDragging:b=>{var E;b&&(x.current=((E=d.current)==null?void 0:E.getSize())??null)},onKeyDownCapture:b=>{var E,T;f||(x.current=((E=d.current)==null?void 0:E.getSize())??null,!(b.key!=="Home"&&b.key!=="End")&&(b.preventDefault(),(T=d.current)==null||T.resize(b.key==="Home"?l.minPct:l.maxPct)))},onResizeEnd:N}),i.jsx(Ve,{ref:d,id:at,order:2,defaultSize:k,minSize:l.minPct,maxSize:l.maxPct,className:"flex",children:t})]})]})})}function xa({roomId:e,threadId:t,entrySeq:s,threadRoute:n,aboveTimeline:o,aboveComposer:r,offerJumpBackIn:l,onComposerFocusChange:c}){const h=ms(),p=Rs(),u=fs(e),d=u==null?void 0:u.rootEntryId,k=hr(),f=a.useCallback(()=>{var P;const v=(P=Y.getState().open[e])==null?void 0:P.rootEntryId;Y.getState().closeThread(e),v!==void 0&&k.arm(v)},[e,k]),g=a.useCallback(v=>{Y.getState().openThread(e,v)},[e]),y=ps(e),x=hs(e),N=co(e,x.isSuccess);Es(e);const m=y.data,b=a.useMemo(()=>x.data??[],[x.data]),E=qt({room:m});gr({roomId:e,route:n,urlThreadId:t,openThreadId:d,entries:b,historyLoaded:x.isSuccess});const T=a.useMemo(()=>{var v;return((v=m==null?void 0:m.members.find(P=>P.author.id===m.viewerAuthorId))==null?void 0:v.lastReadSeq)??null},[m]),D=mr(e,T);gs(m,b);const j=a.useRef(null),S=a.useRef(void 0),_=a.useCallback(v=>{S.current=v},[]),I=a.useCallback(()=>S.current,[]);a.useLayoutEffect(()=>{S.current=void 0},[e]);const L=a.useCallback(v=>{var P;(P=j.current)==null||P.scrollToRow(v)},[]),$=ho(e),{loadOlder:O,cursor:q}=$,F=a.useCallback(()=>{const v=Eo(b,q);O().then(()=>{v!==null&&requestAnimationFrame(()=>{var P;return(P=j.current)==null?void 0:P.scrollToRow(v.domId)})})},[b,q,O]),z=ur({roomId:e,entrySeq:s,entries:b,historyLoaded:x.isSuccess}),W=a.useMemo(()=>d===void 0?void 0:{replyIds:new Set(b.filter(P=>Z(P)===d).map(P=>P.id)),inside:!1},[b,d]);if(y.isLoading)return i.jsx("div",{className:"flex h-full flex-col","aria-busy":!0,children:i.jsx(Bt,{})});if(y.isError||!m)return i.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-2 p-10 text-center text-sm",children:[i.jsx("p",{className:"text-foreground font-medium",children:"That channel or DM isn’t here"}),i.jsx("p",{className:"max-w-sm",children:"It may be archived, or the link is old."})]});const B=u!==void 0&&i.jsx(Fr,{room:m,rootEntryId:u.rootEntryId,focusComposer:u.focusComposer,entries:b,reactionFrequents:m.reactionFrequents,streamStalled:N.stalled,streamUnavailable:N.unavailable,onRetryStream:N.retry,historyLoaded:x.isSuccess,historyFailed:x.isError,...z.threadRow===void 0?{}:{landOnRow:z.threadRow},pushed:h,onClose:f},u.rootEntryId),H=i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[o,i.jsx(cr,{ref:j,roomId:m.id,roomName:se(m),viewerAuthorId:m.viewerAuthorId,entries:b,members:m.members,formerAuthors:m.formerAuthors,lastReadSeq:D,reactionFrequents:m.reactionFrequents,streamStalled:N.stalled,isLoading:x.isLoading,error:x.error,onAddAgents:()=>Ye("add",m.id),openThreadId:d,onOpenThread:g,resumeRow:I,...z.roomRow===void 0?{}:{landOnRow:z.roomRow},onTopRow:_,canLoadOlder:$.canLoadOlder,isLoadingOlder:$.isLoadingOlder,onLoadOlder:F}),r,i.jsx(Or,{roomId:m.id}),i.jsx(_r,{roomId:m.id}),i.jsx(Kt,{room:m,entries:b,scope:W,laneScope:"room",stalled:N.stalled,unavailable:N.unavailable,onRetry:N.retry,onScrollToRow:L}),i.jsx(Tr,{room:m,hasEntries:b.length>0,onAddAgents:()=>Ye("add",m.id)}),i.jsx(Wt,{room:m,attachments:E.attachments,offerJumpBackIn:l,onFocusChange:c},m.id)]}),w={surface:"room",capabilities:He,target:E.target,anchor:"rail"};return h?i.jsx(X.Root,{...w,children:i.jsx(je,{initial:!1,mode:"wait",children:i.jsx(_e.div,{initial:{opacity:0,x:16},animate:{opacity:1,x:0},exit:{opacity:0,x:16},transition:{duration:.15,ease:[0,0,.2,1]},style:{paddingBottom:p},"data-testid":"room-surface",className:"flex h-full flex-col overflow-hidden",children:B===!1?H:B},B?`thread-${d}`:"room")})}):i.jsx(X.Root,{...w,children:i.jsx(ea,{room:H,thread:B})})}export{Et as I,Bt as R,Io as T,xa as a,ie as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as d,i as l,j as e,e as m,k as u,C as c,l as x,n as h,H as f}from"./index-
|
|
1
|
+
import{h as d,i as l,j as e,e as m,k as u,C as c,l as x,n as h,H as f}from"./index-DxTOTFWT.js";function g({kind:s}){const r="text-muted-foreground size-3.5 shrink-0";return s==="dm"?e.jsx(h,{"aria-hidden":!0,className:r}):e.jsx(f,{"aria-hidden":!0,className:r})}function p(s){return s===1?"1 member":`${s} members`}function N({member:s}){var i;const r=d(),n=l(s.id);if(n.isPending)return e.jsx(m,{className:"h-16 w-full"});if(n.isError)return e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t read this member’s rooms."});const a=((i=n.data)==null?void 0:i.rooms)??[];return a.length===0?e.jsxs("p",{className:"text-muted-foreground text-sm",children:[s.isSelf?"You aren’t":`${s.displayName} isn’t`," in any rooms yet."]}):e.jsx("div",{className:"flex flex-col",children:a.map(t=>{const o=e.jsxs(e.Fragment,{children:[e.jsx(g,{kind:t.kind}),e.jsx("span",{className:"min-w-0 truncate text-sm",children:u({kind:t.kind,slug:t.slug,title:t.name})}),e.jsx("span",{className:"text-muted-foreground ml-auto shrink-0 text-xs",children:p(t.memberCount)})]});return r?e.jsxs("button",{type:"button","data-slot":"profile-room-row",onClick:()=>void r({...x.channels(),search:{id:t.id}}),className:"focus-ring hover:bg-muted/50 flex h-9 items-center gap-2 rounded-md px-2 text-left transition-colors",children:[o,e.jsx(c,{"aria-hidden":!0,className:"text-muted-foreground/70 size-3.5 shrink-0"})]},t.id):e.jsx("div",{"data-slot":"profile-room-row",className:"flex h-9 items-center gap-2 rounded-md px-2",children:o},t.id)})})}export{N as RoomsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as I,j as e,a7 as ye,bF as Ee,W as we,Q as N,dP as ie,bG as ue,bH as fe,bI as me,bK as xe,dQ as Te,a8 as ke,aa as Ae,ab as Ie,ak as pe,ay as Le,dz as he,dR as Oe,dS as De,dT as Pe,af as j,dU as _e,dC as H,dV as Ue,at as be,B as $e,$ as Re,b as He,e as Me,dW as Be,dX as Ke,dY as ze,dZ as Qe,d_ as Ve,d$ as We}from"./index-CdKpQ1hI.js";import{C as ce}from"./runtime-connect-Dn0T5YWv.js";import{a as qe,d as Fe,k as Xe,e as A}from"./execution-config-BbBEe6FO.js";import{U as Ye}from"./unverified-catalog-notice-DHM5Coia.js";import{s as Ge}from"./settings-for-runtime-BoOa-ZFG.js";const Ze={duration:.12,ease:"easeOut"},Je={type:"spring",stiffness:320,damping:28};function ve({isSetHere:a,serverDefault:l,onUseServerDefault:i,warning:r,className:s,"data-testid":d}){const[u,f]=I.useState(!1),o=a?"Set here":`Server default · ${l??"none"}`,n=a&&!!i,x=e.jsxs("span",{className:N("text-3xs inline-flex h-5 items-center gap-1 rounded-full px-2 leading-none whitespace-nowrap",r?ie.warning:ie.neutral,n&&"hover:bg-accent hover:text-accent-foreground transition-colors",s),"data-testid":d,children:[r&&e.jsx(ye,{className:"size-2.5 shrink-0","aria-hidden":!0}),e.jsx(Ee,{mode:"wait",initial:!1,children:e.jsx(we.span,{initial:{opacity:0,y:2},animate:{opacity:1,y:0,transition:Je},exit:{opacity:0},transition:Ze,children:o},o)})]});return n?e.jsxs(ue,{open:u,onOpenChange:f,children:[e.jsx(fe,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`Set here${r?`: ${r}`:""}`,children:x})}),e.jsxs(me,{className:"w-64 p-2",align:"start",children:[e.jsx(xe,{children:"Where this value comes from"}),r&&e.jsx("p",{className:N("px-2 pt-1 text-xs",Te.warning),children:r}),e.jsxs("button",{type:"button",onClick:()=>{i(),f(!1)},className:"hover:bg-accent mt-1 w-full rounded-md px-2 py-1.5 text-left text-sm transition-colors","data-testid":d?`${d}-reset`:void 0,children:["Use server default",l?e.jsxs("span",{className:"text-muted-foreground block text-xs",children:["Currently ",l]}):e.jsx("span",{className:"text-muted-foreground block text-xs",children:"Not set. Uses the built-in default."})]})]})]}):r?e.jsx("span",{title:r,"aria-label":`${o}: ${r}`,children:x}):x}const et=["agents"];function tt(a){const l=ke(),i=Ae();return Ie({...a!=null&&a.errorLabel?{meta:{errorLabel:a.errorLabel}}:{},mutationFn:r=>l.updateMeshAgent(r.id,r.updates),onSuccess:()=>{i.invalidateQueries({queryKey:["mesh","agents"]})},onSettled:()=>{i.invalidateQueries({queryKey:et})}})}const ge="text-muted-foreground text-3xs font-medium tracking-wider uppercase";function $({label:a,valueLabel:l,options:i,selected:r,isSetHere:s,serverDefault:d,warning:u,onSelect:f,onInherit:o,testId:n,showHeader:x=!0,className:C,describedBy:m,inheritText:L}){const w=pe(),[S,h]=I.useState(!1);return e.jsxs("div",{className:N("space-y-1",C),children:[x&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:ge,children:a}),!w&&e.jsx(ve,{isSetHere:s,serverDefault:d,warning:u,onUseServerDefault:o,"data-testid":`${n}-chip`})]}),e.jsxs(ue,{open:S,onOpenChange:h,children:[e.jsx(fe,{asChild:!0,children:e.jsxs("button",{type:"button",className:"border-input hover:bg-accent flex h-8 w-full items-center gap-1 rounded-md border px-2 text-sm transition-colors",...m?{"aria-describedby":m}:{},"data-testid":n,children:[e.jsx("span",{className:N("truncate",u?"text-status-warning-fg":s?"md:text-foreground text-status-warning-fg":"md:text-foreground text-status-success-fg"),children:l}),e.jsx(Re,{className:"text-muted-foreground ml-auto size-3.5 shrink-0"})]})}),e.jsxs(me,{className:"w-64 p-1",align:"start",children:[e.jsx(xe,{children:a}),e.jsx("div",{className:"max-h-72 overflow-y-auto",children:i.map(c=>e.jsxs("button",{type:"button","data-testid":`${n}-option-${c.value}`,onClick:()=>{f(c.value),h(!1)},className:N("hover:bg-accent w-full rounded-md px-2 py-1.5 text-left text-sm transition-colors",c.value===r&&"bg-accent"),children:[c.label,c.hint&&e.jsx("span",{className:"text-muted-foreground block text-xs",children:c.hint})]},c.value))}),e.jsx("button",{type:"button",onClick:()=>{o(),h(!1)},className:"hover:bg-accent border-border text-muted-foreground mt-1 w-full border-t px-2 py-2 text-left text-xs transition-colors","data-testid":`${n}-inherit`,children:L??(d?`Use server default: ${d}`:"Use server default")})]})]})]})}function st({agent:a,onUpdate:l,className:i}){var ee,te,se,ae,ne,le,oe,re,de;const r=pe(),{data:s}=Le(),{data:d,isPending:u}=he(),f=((ee=s==null?void 0:s.executionDefaults)==null?void 0:ee.runtime)??"claude-code",o=a.runtime??f,n=(te=s==null?void 0:s.executionDefaults)==null?void 0:te.perRuntime.find(t=>t.runtime===o),{data:x}=Oe(),C=qe(a,{defaultRuntime:f,runtimeDeclaresCredits:t=>{var b;return((b=d==null?void 0:d.capabilities[t])==null?void 0:b.credits)!==void 0},credits:(se=s==null?void 0:s.claudeCode)==null?void 0:se.credits,runtimeDefaultsToCredits:t=>{var b,k;return((k=(b=x==null?void 0:x.defaults)==null?void 0:b[t])==null?void 0:k.runsOn)==="credits"}}),{data:m,isError:L}=De({runtime:o,...C?{account:j}:{}}),w=a.model!=null,S=a.effort!=null,h=(n==null?void 0:n.model)??null,c=C&&(m??[]).some(t=>t.paidFromCredits),y=c?(m??[]).find(t=>t.isDefault):void 0,T=a.model??h??(y==null?void 0:y.value)??null,M=o==="doe"&&c&&!w&&!h,p=T?(m??[]).find(t=>t.value===T):void 0,O=(n==null?void 0:n.supportsEffort)??((ae=Ge(d,o))==null?void 0:ae.supportsEffort),B=O===void 0&&u,K=O!==!1,z=p?p.supportsEffort??!1:void 0,Q=(ne=s==null?void 0:s.claudeCode)==null?void 0:ne.accounts,{nameFor:V,creditsEntry:je,resolvedAccount:W}=Pe(),q=je??(a.account===j&&((le=s==null?void 0:s.claudeCode)!=null&&le.credits)?{path:s.claudeCode.credits.path}:null),v=Q&&[...Q.flatMap(t=>t.id===null?[]:[{id:t.id,label:V(t.path),path:t.path}]),...q?[{id:j,label:_e,path:q.path}]:[]],g=a.account??null,F=g!==null,X=o==="claude-code"&&g===j&&((oe=s==null?void 0:s.claudeCode)==null?void 0:oe.credits)!==void 0&&!s.claudeCode.credits.allowedAgents.includes(a.id),D=s!=null&&s.claudeCode&&W?V(W):null,P=tt({errorLabel:"Couldn’t change this agent’s account"}),_=I.useCallback(t=>{P.mutate({id:a.id,updates:{account:t}})},[a.id,P]),Ne=Fe({agent:{runtime:a.runtime,model:a.model,effort:a.effort,account:a.account},defaultRuntime:f,serverDefaultModel:h,knownModels:Xe(m),knownAccounts:v,accountsUnavailable:(re=s==null?void 0:s.claudeCode)==null?void 0:re.accountsUnavailable,modelSupportsEffort:z,runtimeSupportsEffort:O,runtimeLabel:t=>H(t).label}),E=t=>{var b;return((b=Ne.breakages.find(k=>t.includes(k.kind)))==null?void 0:b.message)??null},U=!B&&K&&z!==!1,Y=a.effort??(n==null?void 0:n.effort)??null,G=H(o).label,Ce=o==="claude-code"&&v!==void 0&&(v.length>1||F),Se=E(["account-unregistered"]),Z=(m??[]).some(t=>t.unverified),J=I.useId();return e.jsxs("div",{className:N("grid grid-cols-2 gap-3",i),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx($,{label:"Model",valueLabel:M?ce:(p==null?void 0:p.displayName)??T??(c?"Default":"Automatic"),options:[...(m??[]).map(t=>({value:t.value,label:t.displayName,hint:t.description}))],selected:T,isSetHere:w,serverDefault:(n==null?void 0:n.model)??null,warning:E(["model-unavailable"]),onSelect:t=>l({model:t}),onInherit:()=>l({model:null}),testId:"agent-model-row",describedBy:Z?J:void 0,inheritText:M?ce:c&&!h?y?`Use the suggested model: ${y.displayName}`:"Use the default model":void 0}),Z&&e.jsx(Ye,{id:J}),c&&(m??[]).some(t=>t.creditsListOutOfDate)&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"agent-credits-models-out-of-date",children:"The models your DorkOS credits cover may be out of date."}),C&&L&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"agent-credits-models-unavailable",children:"Couldn’t load the models DorkOS credits cover. Try again in a moment."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:ge,children:"Effort"}),(!r||!U)&&(S||U)&&e.jsx(ve,{isSetHere:S,serverDefault:n!=null&&n.effort?A(n.effort):null,warning:E(["effort-unsupported-runtime","effort-unsupported-model"]),onUseServerDefault:()=>l({effort:null}),"data-testid":"agent-effort-row-chip"})]}),B?e.jsx(R,{testId:"agent-effort-pending",text:`Checking what ${G} supports`,warning:null}):K?U?e.jsx($,{label:"Effort",valueLabel:A(Y),options:Ue.filter(t=>!(p!=null&&p.supportedEffortLevels)||p.supportedEffortLevels.includes(t)).map(t=>({value:t,label:A(t)})),selected:Y,isSetHere:S,serverDefault:n!=null&&n.effort?A(n.effort):null,warning:null,showHeader:!1,onSelect:t=>l({effort:t}),onInherit:()=>l({effort:null}),testId:"agent-effort-row"}):e.jsx(R,{testId:"agent-effort-unsupported-model",text:"This model doesn’t take an effort setting",warning:E(["effort-unsupported-model"])}):e.jsx(R,{testId:"agent-effort-unsupported-runtime",text:`Not supported by ${G}`,warning:E(["effort-unsupported-runtime"])})]}),Ce&&e.jsx($,{label:"Account",valueLabel:X?D??"Default":g!==null?((de=v==null?void 0:v.find(t=>t.id===g))==null?void 0:de.label)??g:D??"Default",options:(v??[]).map(t=>({value:t.id,label:t.label,hint:t.id===j?"Paid from your DorkOS account":be(t.path)})),selected:g,isSetHere:F,serverDefault:D,warning:Se,onSelect:t=>_(t),onInherit:()=>_(null),testId:"agent-account-row",className:"col-span-full"}),X&&e.jsxs("div",{className:"text-muted-foreground col-span-full flex flex-wrap items-center gap-2 text-xs","data-testid":"agent-credits-not-allowed",children:[e.jsx("span",{children:"This agent’s settings name DorkOS credits. It uses your default until you allow it."}),e.jsx($e,{size:"sm",variant:"outline",className:"h-6 px-2 text-xs",disabled:P.isPending,onClick:()=>_(j),children:"Allow"})]})]})}function R({text:a,warning:l,testId:i}){return e.jsxs("div",{className:"flex h-8 flex-col justify-center","data-testid":i,children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:a}),l&&e.jsx("p",{className:"text-status-warning-fg text-xs",children:l})]})}const at="text-muted-foreground text-3xs font-medium tracking-wider uppercase";function it({member:a}){const{agent:l,projectPath:i,isPending:r,update:s}=He(a),{data:d}=he();if(r)return e.jsx(Me,{className:"h-24 w-full"});if(!l)return e.jsx("p",{className:"text-muted-foreground p-1 text-sm",children:"Couldn’t read this agent’s settings."});const u=d?Object.keys(d.capabilities):[l.runtime],f=u.includes(l.runtime)?u:[l.runtime,...u];return e.jsxs("div",{className:"space-y-3 p-1","data-slot":"profile-runs-on",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:at,children:"Runs on"}),e.jsxs(Be,{value:l.runtime??"claude-code",onValueChange:o=>s({runtime:o}),children:[e.jsx(Ke,{className:"h-8 text-sm",responsive:!1,children:e.jsx(ze,{})}),e.jsx(Qe,{children:f.map(o=>e.jsx(Ve,{value:o,responsive:!1,children:H(o).label},o))})]})]}),e.jsx(st,{agent:l,onUpdate:s,className:"grid-cols-1"}),i&&e.jsxs("div",{className:"text-muted-foreground flex min-w-0 items-center gap-1.5",children:[e.jsx(We,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate font-mono text-xs",children:be(i)})]})]})}export{it as RunsOnPopover};
|
|
1
|
+
import{r as I,j as e,a7 as Ee,bF as ye,W as we,Q as N,dR as ie,bG as ue,bH as fe,bI as me,bK as xe,dS as Te,a8 as ke,aa as Ae,ab as Ie,ak as pe,ay as Le,dB as he,dT as Oe,dU as De,dV as _e,af as j,dW as Pe,dE as H,dX as Ue,at as be,B as $e,$ as Re,b as He,e as Me,dY as Be,dZ as Ke,d_ as ze,d$ as Qe,e0 as Ve,e1 as We}from"./index-DxTOTFWT.js";import{C as ce}from"./runtime-connect-Dn0T5YWv.js";import{a as qe,d as Fe,k as Xe,e as A}from"./execution-config-JdnxoV1P.js";import{U as Ye}from"./unverified-catalog-notice-B9dzvyVq.js";import{s as Ge}from"./settings-for-runtime-BoOa-ZFG.js";const Ze={duration:.12,ease:"easeOut"},Je={type:"spring",stiffness:320,damping:28};function ve({isSetHere:a,serverDefault:l,onUseServerDefault:i,warning:r,className:s,"data-testid":d}){const[u,f]=I.useState(!1),o=a?"Set here":`Server default · ${l??"none"}`,n=a&&!!i,x=e.jsxs("span",{className:N("text-3xs inline-flex h-5 items-center gap-1 rounded-full px-2 leading-none whitespace-nowrap",r?ie.warning:ie.neutral,n&&"hover:bg-accent hover:text-accent-foreground transition-colors",s),"data-testid":d,children:[r&&e.jsx(Ee,{className:"size-2.5 shrink-0","aria-hidden":!0}),e.jsx(ye,{mode:"wait",initial:!1,children:e.jsx(we.span,{initial:{opacity:0,y:2},animate:{opacity:1,y:0,transition:Je},exit:{opacity:0},transition:Ze,children:o},o)})]});return n?e.jsxs(ue,{open:u,onOpenChange:f,children:[e.jsx(fe,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`Set here${r?`: ${r}`:""}`,children:x})}),e.jsxs(me,{className:"w-64 p-2",align:"start",children:[e.jsx(xe,{children:"Where this value comes from"}),r&&e.jsx("p",{className:N("px-2 pt-1 text-xs",Te.warning),children:r}),e.jsxs("button",{type:"button",onClick:()=>{i(),f(!1)},className:"hover:bg-accent mt-1 w-full rounded-md px-2 py-1.5 text-left text-sm transition-colors","data-testid":d?`${d}-reset`:void 0,children:["Use server default",l?e.jsxs("span",{className:"text-muted-foreground block text-xs",children:["Currently ",l]}):e.jsx("span",{className:"text-muted-foreground block text-xs",children:"Not set. Uses the built-in default."})]})]})]}):r?e.jsx("span",{title:r,"aria-label":`${o}: ${r}`,children:x}):x}const et=["agents"];function tt(a){const l=ke(),i=Ae();return Ie({...a!=null&&a.errorLabel?{meta:{errorLabel:a.errorLabel}}:{},mutationFn:r=>l.updateMeshAgent(r.id,r.updates),onSuccess:()=>{i.invalidateQueries({queryKey:["mesh","agents"]})},onSettled:()=>{i.invalidateQueries({queryKey:et})}})}const ge="text-muted-foreground text-3xs font-medium tracking-wider uppercase";function $({label:a,valueLabel:l,options:i,selected:r,isSetHere:s,serverDefault:d,warning:u,onSelect:f,onInherit:o,testId:n,showHeader:x=!0,className:C,describedBy:m,inheritText:L}){const w=pe(),[S,h]=I.useState(!1);return e.jsxs("div",{className:N("space-y-1",C),children:[x&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:ge,children:a}),!w&&e.jsx(ve,{isSetHere:s,serverDefault:d,warning:u,onUseServerDefault:o,"data-testid":`${n}-chip`})]}),e.jsxs(ue,{open:S,onOpenChange:h,children:[e.jsx(fe,{asChild:!0,children:e.jsxs("button",{type:"button",className:"border-input hover:bg-accent flex h-8 w-full items-center gap-1 rounded-md border px-2 text-sm transition-colors",...m?{"aria-describedby":m}:{},"data-testid":n,children:[e.jsx("span",{className:N("truncate",u?"text-status-warning-fg":s?"md:text-foreground text-status-warning-fg":"md:text-foreground text-status-success-fg"),children:l}),e.jsx(Re,{className:"text-muted-foreground ml-auto size-3.5 shrink-0"})]})}),e.jsxs(me,{className:"w-64 p-1",align:"start",children:[e.jsx(xe,{children:a}),e.jsx("div",{className:"max-h-72 overflow-y-auto",children:i.map(c=>e.jsxs("button",{type:"button","data-testid":`${n}-option-${c.value}`,onClick:()=>{f(c.value),h(!1)},className:N("hover:bg-accent w-full rounded-md px-2 py-1.5 text-left text-sm transition-colors",c.value===r&&"bg-accent"),children:[c.label,c.hint&&e.jsx("span",{className:"text-muted-foreground block text-xs",children:c.hint})]},c.value))}),e.jsx("button",{type:"button",onClick:()=>{o(),h(!1)},className:"hover:bg-accent border-border text-muted-foreground mt-1 w-full border-t px-2 py-2 text-left text-xs transition-colors","data-testid":`${n}-inherit`,children:L??(d?`Use server default: ${d}`:"Use server default")})]})]})]})}function st({agent:a,onUpdate:l,className:i}){var ee,te,se,ae,ne,le,oe,re,de;const r=pe(),{data:s}=Le(),{data:d,isPending:u}=he(),f=((ee=s==null?void 0:s.executionDefaults)==null?void 0:ee.runtime)??"claude-code",o=a.runtime??f,n=(te=s==null?void 0:s.executionDefaults)==null?void 0:te.perRuntime.find(t=>t.runtime===o),{data:x}=Oe(),C=qe(a,{defaultRuntime:f,runtimeDeclaresCredits:t=>{var b;return((b=d==null?void 0:d.capabilities[t])==null?void 0:b.credits)!==void 0},credits:(se=s==null?void 0:s.claudeCode)==null?void 0:se.credits,runtimeDefaultsToCredits:t=>{var b,k;return((k=(b=x==null?void 0:x.defaults)==null?void 0:b[t])==null?void 0:k.runsOn)==="credits"}}),{data:m,isError:L}=De({runtime:o,...C?{account:j}:{}}),w=a.model!=null,S=a.effort!=null,h=(n==null?void 0:n.model)??null,c=C&&(m??[]).some(t=>t.paidFromCredits),E=c?(m??[]).find(t=>t.isDefault):void 0,T=a.model??h??(E==null?void 0:E.value)??null,M=o==="doe"&&c&&!w&&!h,p=T?(m??[]).find(t=>t.value===T):void 0,O=(n==null?void 0:n.supportsEffort)??((ae=Ge(d,o))==null?void 0:ae.supportsEffort),B=O===void 0&&u,K=O!==!1,z=p?p.supportsEffort??!1:void 0,Q=(ne=s==null?void 0:s.claudeCode)==null?void 0:ne.accounts,{nameFor:V,creditsEntry:je,resolvedAccount:W}=_e(),q=je??(a.account===j&&((le=s==null?void 0:s.claudeCode)!=null&&le.credits)?{path:s.claudeCode.credits.path}:null),v=Q&&[...Q.flatMap(t=>t.id===null?[]:[{id:t.id,label:V(t.path),path:t.path}]),...q?[{id:j,label:Pe,path:q.path}]:[]],g=a.account??null,F=g!==null,X=o==="claude-code"&&g===j&&((oe=s==null?void 0:s.claudeCode)==null?void 0:oe.credits)!==void 0&&!s.claudeCode.credits.allowedAgents.includes(a.id),D=s!=null&&s.claudeCode&&W?V(W):null,_=tt({errorLabel:"Couldn’t change this agent’s account"}),P=I.useCallback(t=>{_.mutate({id:a.id,updates:{account:t}})},[a.id,_]),Ne=Fe({agent:{runtime:a.runtime,model:a.model,effort:a.effort,account:a.account},defaultRuntime:f,serverDefaultModel:h,knownModels:Xe(m),knownAccounts:v,accountsUnavailable:(re=s==null?void 0:s.claudeCode)==null?void 0:re.accountsUnavailable,modelSupportsEffort:z,runtimeSupportsEffort:O,runtimeLabel:t=>H(t).label}),y=t=>{var b;return((b=Ne.breakages.find(k=>t.includes(k.kind)))==null?void 0:b.message)??null},U=!B&&K&&z!==!1,Y=a.effort??(n==null?void 0:n.effort)??null,G=H(o).label,Ce=o==="claude-code"&&v!==void 0&&(v.length>1||F),Se=y(["account-unregistered"]),Z=(m??[]).some(t=>t.unverified),J=I.useId();return e.jsxs("div",{className:N("grid grid-cols-2 gap-3",i),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx($,{label:"Model",valueLabel:M?ce:(p==null?void 0:p.displayName)??T??(c?"Default":"Automatic"),options:[...(m??[]).map(t=>({value:t.value,label:t.displayName,hint:t.description}))],selected:T,isSetHere:w,serverDefault:(n==null?void 0:n.model)??null,warning:y(["model-unavailable"]),onSelect:t=>l({model:t}),onInherit:()=>l({model:null}),testId:"agent-model-row",describedBy:Z?J:void 0,inheritText:M?ce:c&&!h?E?`Use the suggested model: ${E.displayName}`:"Use the default model":void 0}),Z&&e.jsx(Ye,{id:J}),c&&(m??[]).some(t=>t.creditsListOutOfDate)&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"agent-credits-models-out-of-date",children:"The models your DorkOS credits cover may be out of date."}),C&&L&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"agent-credits-models-unavailable",children:"Couldn’t load the models DorkOS credits cover. Try again in a moment."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:ge,children:"Effort"}),(!r||!U)&&(S||U)&&e.jsx(ve,{isSetHere:S,serverDefault:n!=null&&n.effort?A(n.effort):null,warning:y(["effort-unsupported-runtime","effort-unsupported-model"]),onUseServerDefault:()=>l({effort:null}),"data-testid":"agent-effort-row-chip"})]}),B?e.jsx(R,{testId:"agent-effort-pending",text:`Checking what ${G} supports`,warning:null}):K?U?e.jsx($,{label:"Effort",valueLabel:A(Y),options:Ue.filter(t=>!(p!=null&&p.supportedEffortLevels)||p.supportedEffortLevels.includes(t)).map(t=>({value:t,label:A(t)})),selected:Y,isSetHere:S,serverDefault:n!=null&&n.effort?A(n.effort):null,warning:null,showHeader:!1,onSelect:t=>l({effort:t}),onInherit:()=>l({effort:null}),testId:"agent-effort-row"}):e.jsx(R,{testId:"agent-effort-unsupported-model",text:"This model doesn’t take an effort setting",warning:y(["effort-unsupported-model"])}):e.jsx(R,{testId:"agent-effort-unsupported-runtime",text:`Not supported by ${G}`,warning:y(["effort-unsupported-runtime"])})]}),Ce&&e.jsx($,{label:"Account",valueLabel:X?D??"Default":g!==null?((de=v==null?void 0:v.find(t=>t.id===g))==null?void 0:de.label)??g:D??"Default",options:(v??[]).map(t=>({value:t.id,label:t.label,hint:t.id===j?"Paid from your DorkOS account":be(t.path)})),selected:g,isSetHere:F,serverDefault:D,warning:Se,onSelect:t=>P(t),onInherit:()=>P(null),testId:"agent-account-row",className:"col-span-full"}),X&&e.jsxs("div",{className:"text-muted-foreground col-span-full flex flex-wrap items-center gap-2 text-xs","data-testid":"agent-credits-not-allowed",children:[e.jsx("span",{children:"This agent’s settings name DorkOS credits. It uses your default until you allow it."}),e.jsx($e,{size:"sm",variant:"outline",className:"h-6 px-2 text-xs",disabled:_.isPending,onClick:()=>P(j),children:"Allow"})]})]})}function R({text:a,warning:l,testId:i}){return e.jsxs("div",{className:"flex h-8 flex-col justify-center","data-testid":i,children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:a}),l&&e.jsx("p",{className:"text-status-warning-fg text-xs",children:l})]})}const at="text-muted-foreground text-3xs font-medium tracking-wider uppercase";function it({member:a}){const{agent:l,projectPath:i,isPending:r,update:s}=He(a),{data:d}=he();if(r)return e.jsx(Me,{className:"h-24 w-full"});if(!l)return e.jsx("p",{className:"text-muted-foreground p-1 text-sm",children:"Couldn’t read this agent’s settings."});const u=d?Object.keys(d.capabilities):[l.runtime],f=u.includes(l.runtime)?u:[l.runtime,...u];return e.jsxs("div",{className:"space-y-3 p-1","data-slot":"profile-runs-on",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:at,children:"Runs on"}),e.jsxs(Be,{value:l.runtime??"claude-code",onValueChange:o=>s({runtime:o}),children:[e.jsx(Ke,{className:"h-8 text-sm",responsive:!1,children:e.jsx(ze,{})}),e.jsx(Qe,{children:f.map(o=>e.jsx(Ve,{value:o,responsive:!1,children:H(o).label},o))})]})]}),e.jsx(st,{agent:l,onUpdate:s,className:"grid-cols-1"}),i&&e.jsxs("div",{className:"text-muted-foreground flex min-w-0 items-center gap-1.5",children:[e.jsx(We,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate font-mono text-xs",children:be(i)})]})]})}export{it as RunsOnPopover};
|