@openscout/scout 0.2.79 → 0.2.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (398) hide show
  1. package/README.md +1 -1
  2. package/bin/scoutd +0 -0
  3. package/dist/build-manifest.json +4 -4
  4. package/dist/client/assets/ActivityScreen-aewI4Ul1.js +1 -0
  5. package/dist/client/assets/{AddProjectForm-BoVtelSP.js → AddProjectForm-Czb5uwou.js} +1 -1
  6. package/dist/client/assets/{AgentAvatar-CufDA4A-.js → AgentAvatar-DMov24_o.js} +1 -1
  7. package/dist/client/assets/AgentConfigurationScreen-BjG6ECjl.js +1 -0
  8. package/dist/client/assets/AgentDefinitionsWorkspace-D4MbSMXp.js +1 -0
  9. package/dist/client/assets/{AgentDetailCard-DxxVkgT1.js → AgentDetailCard-Biq8b2gv.js} +1 -1
  10. package/dist/client/assets/AgentFloorView-h9KDJdw0.js +1 -0
  11. package/dist/client/assets/AgentInfoScreen-SjhK_SBh.js +1 -0
  12. package/dist/client/assets/{AgentLaneCard-DTUvE96I.js → AgentLaneCard-C4DMQR-c.js} +1 -1
  13. package/dist/client/assets/{AgentLaneChrome-BfVygkgL.js → AgentLaneChrome-D1xNNf7A.js} +1 -1
  14. package/dist/client/assets/AgentLaneDetailSheet-DnAKe4e3.js +4 -0
  15. package/dist/client/assets/{AgentLaneSummaryResize-CMgzYvAA.js → AgentLaneSummaryResize-C9loK-st.js} +1 -1
  16. package/dist/client/assets/AgentLanesEmbedScreen-BNOYF16R.js +1 -0
  17. package/dist/client/assets/{AgentLanesPreflight-KWfLcaNB.js → AgentLanesPreflight-M7iDXdP2.js} +1 -1
  18. package/dist/client/assets/{AgentLanesView-CxfbV8Kd.js → AgentLanesView-Ct-Gz5WD.js} +1 -1
  19. package/dist/client/assets/{AgentLiveActions-CZdAInEu.js → AgentLiveActions-0iy8QZ1T.js} +1 -1
  20. package/dist/client/assets/{AgentSessions-Bkr0lyry.js → AgentSessions-CDfSfNiE.js} +2 -2
  21. package/dist/client/assets/{AgentsConsole-WtFVqaPJ.js → AgentsConsole-BVxhBqRa.js} +1 -1
  22. package/dist/client/assets/AgentsScreen-Bww6HgFs.js +1 -0
  23. package/dist/client/assets/AgentsSubnav-CiIuzxnZ.js +1 -0
  24. package/dist/client/assets/{AtopView-_OKDlZ1h.js → AtopView-h_aFoNkP.js} +1 -1
  25. package/dist/client/assets/BackToPicker-BXp5E2ck.js +1 -0
  26. package/dist/client/assets/{BriefingDetailScreen-i54EtZKW.js → BriefingDetailScreen-C83o2YfN.js} +1 -1
  27. package/dist/client/assets/{BriefingsScreen-CBrHojlQ.js → BriefingsScreen-BTsvr5fv.js} +1 -1
  28. package/dist/client/assets/{BrokerMetadataPanel-opTLuZU6.js → BrokerMetadataPanel-jg7odHQp.js} +1 -1
  29. package/dist/client/assets/BrokerScreen-DplF8d_X.js +5 -0
  30. package/dist/client/assets/Canvas-BePL08RR.js +1 -0
  31. package/dist/client/assets/{ChatCollapsedStrip-Dr2vmKXQ.js → ChatCollapsedStrip-BRljIymi.js} +1 -1
  32. package/dist/client/assets/{CodeDiffPane-CLOGjwul.js → CodeDiffPane-86odpBSt.js} +1 -1
  33. package/dist/client/assets/{CodeProjectPicker-DTV8hR6A.js → CodeProjectPicker-8svr_S_A.js} +1 -1
  34. package/dist/client/assets/CodeScreen-CJ2RgB32.js +1 -0
  35. package/dist/client/assets/{ContextMenu-BlBQhpax.js → ContextMenu-CxkmFQcN.js} +1 -1
  36. package/dist/client/assets/ConversationComposer-CWohCCmn.js +1 -0
  37. package/dist/client/assets/ConversationFeedRows-IWh0JSIL.js +1 -0
  38. package/dist/client/assets/ConversationHeader-BxTzXl8e.js +1 -0
  39. package/dist/client/assets/ConversationPanels-D9UCwNkS.js +2 -0
  40. package/dist/client/assets/ConversationScreen-oZSitVtX.js +1 -0
  41. package/dist/client/assets/ConversationScreen-yIKEsm-8.css +1 -0
  42. package/dist/client/assets/{ConversationStatus-DSgdVofa.js → ConversationStatus-B6pAbo2w.js} +1 -1
  43. package/dist/client/assets/{DataTable-0DwuXyvW.js → DataTable-CGw5CECG.js} +1 -1
  44. package/dist/client/assets/{DispatchAftermath-BrreQifA.js → DispatchAftermath-DowTb7uO.js} +1 -1
  45. package/dist/client/assets/{DocumentFocusViewer-DU_9BHsD.js → DocumentFocusViewer-DRKjNG9s.js} +1 -1
  46. package/dist/client/assets/{EmbeddableSurfacesLab-DdaswbfI.js → EmbeddableSurfacesLab-CxfJXS2g.js} +1 -1
  47. package/dist/client/assets/{EmptyState-CoL-QuUO.js → EmptyState-BUvllvA6.js} +1 -1
  48. package/dist/client/assets/{FileViewerPane-C9Ly01Ef.js → FileViewerPane-BM4AD_bo.js} +1 -1
  49. package/dist/client/assets/{FleetSearch-DlWTLl-v.js → FleetSearch-CYeWn85V.js} +1 -1
  50. package/dist/client/assets/FlightObserveScreen-DYJJ3Z2B.js +1 -0
  51. package/dist/client/assets/FollowScreen-DG0osbUp.js +1 -0
  52. package/dist/client/assets/HarnessMark-MztYnrGK.js +1 -0
  53. package/dist/client/assets/HarnessesScreen-BWqirBjK.js +1 -0
  54. package/dist/client/assets/HerdrSession-6sFln7WX.js +4 -0
  55. package/dist/client/assets/{HomeHero-Cfsow7qL.js → HomeHero-BPBArHXa.js} +1 -1
  56. package/dist/client/assets/{KnowledgeSearchInspector-DKashKoH.js → KnowledgeSearchInspector-BOIhFWd2.js} +1 -1
  57. package/dist/client/assets/KnowledgeSearchScreen-BP8tD-Bh.js +1 -0
  58. package/dist/client/assets/{LaneToolHoverCard-BzehBmdi.js → LaneToolHoverCard-CcEiQC6B.js} +1 -1
  59. package/dist/client/assets/LaneTraceDetailSheet-B4i1Ut4R.js +1 -0
  60. package/dist/client/assets/{LaneTraceEventFocus-DYvHfs_3.js → LaneTraceEventFocus-Bl9L0EYb.js} +1 -1
  61. package/dist/client/assets/{MeshCanvas-DIjlrMPU.js → MeshCanvas-ZjIuMiRo.js} +1 -1
  62. package/dist/client/assets/{MeshCanvasMinimap-DEq-PkF0.js → MeshCanvasMinimap-C-LQtiX6.js} +1 -1
  63. package/dist/client/assets/MeshScreen-Bs3soujg.js +1 -0
  64. package/dist/client/assets/{MeshTopologyView-BMHpH5BU.js → MeshTopologyView-C0LUyT3K.js} +2 -2
  65. package/dist/client/assets/{MessageComposerSuggestions-zAUUcLOv.js → MessageComposerSuggestions-Dfc3PH2y.js} +1 -1
  66. package/dist/client/assets/MessagesScreen-TgSL5KMc.js +1 -0
  67. package/dist/client/assets/MissionContextRail-CjGAEGu8.js +1 -0
  68. package/dist/client/assets/MissionControlView-D629w2A8.js +1 -0
  69. package/dist/client/assets/{MissionFocusOverlay-C7cPt6eU.js → MissionFocusOverlay-Bubrr8Gc.js} +1 -1
  70. package/dist/client/assets/{MissionLeftAgentRow-CxlH3dON.js → MissionLeftAgentRow-DokImu4Y.js} +1 -1
  71. package/dist/client/assets/MissionLogPane-Cs0LuIkn.js +1 -0
  72. package/dist/client/assets/{NewAgentModal-DprvD4EK.js → NewAgentModal-D5e0YUAo.js} +1 -1
  73. package/dist/client/assets/NewChatComposer-C5LT7MF7.css +1 -0
  74. package/dist/client/assets/NewChatComposer-S08F6_La.js +19 -0
  75. package/dist/client/assets/{NewChatOrigin--pHWUb4V.js → NewChatOrigin-BEz6jyqf.js} +1 -1
  76. package/dist/client/assets/{ObserveEmbedScreen-CfvrnOiZ.js → ObserveEmbedScreen-CHx2sEAA.js} +2 -2
  77. package/dist/client/assets/ObserveTextFlow-_ApDwRCO.js +2 -0
  78. package/dist/client/assets/{ObservedTopologyPanel-Dv6fbHzW.js → ObservedTopologyPanel-ByW7Ar7p.js} +1 -1
  79. package/dist/client/assets/OpenScoutAppShell-DTmnbG-h.js +88 -0
  80. package/dist/client/assets/OpsAgentsView-DiFuHcJs.js +1 -0
  81. package/dist/client/assets/OpsScreen-CCR3U_9P.js +1 -0
  82. package/dist/client/assets/OpsSubnav-CZs_OL2N.js +1 -0
  83. package/dist/client/assets/{PlanView-DYtt8H37.js → PlanView-C54eAzig.js} +1 -1
  84. package/dist/client/assets/ProjectAgentProfile-BEfYOaxc.js +1 -0
  85. package/dist/client/assets/{ProjectAgentProfileBar-B3IvVbqS.js → ProjectAgentProfileBar-B1VpwzGD.js} +1 -1
  86. package/dist/client/assets/{ProjectAgentProfileHero-D5E8yvDj.js → ProjectAgentProfileHero-B4f_AoCr.js} +1 -1
  87. package/dist/client/assets/ProjectsInbox-DoPZ17FC.js +2 -0
  88. package/dist/client/assets/{ProjectsRail-DEDS-M1c.js → ProjectsRail-CWOkZjsY.js} +1 -1
  89. package/dist/client/assets/ProjectsScreen-Dse0Q6p6.js +1 -0
  90. package/dist/client/assets/ProjectsThreadAside-DMnfyPLE.js +1 -0
  91. package/dist/client/assets/Provider-DKZWuzSR.js +1 -0
  92. package/dist/client/assets/{RailRow-BTlVAnHS.js → RailRow-DIGd3MMM.js} +1 -1
  93. package/dist/client/assets/RawSessionsTable-Zkl4YDvz.js +1 -0
  94. package/dist/client/assets/RealtimeVoiceScreen-B_PMJxY_.js +1 -0
  95. package/dist/client/assets/{RepoDiffEmbedScreen-CtTdlQ2A.js → RepoDiffEmbedScreen-VLg4caej.js} +1 -1
  96. package/dist/client/assets/{RepoDiffPageScreen-BRvaVYoC.js → RepoDiffPageScreen-BelnvgnP.js} +1 -1
  97. package/dist/client/assets/{RepoDiffViewer-Bo0gREMj.js → RepoDiffViewer-VrUJw33u.js} +1 -1
  98. package/dist/client/assets/RepoDiffViewerLazy-BPg_JkYW.js +2 -0
  99. package/dist/client/assets/{ReposScreen-BBkJf8xT.js → ReposScreen-IINK-CFn.js} +2 -2
  100. package/dist/client/assets/ScoutDeckSurface-MbwGp6Ab.js +1 -0
  101. package/dist/client/assets/{ScoutSurface-DEQg_7Io.js → ScoutSurface-x_QbcRyk.js} +1 -1
  102. package/dist/client/assets/ScoutbotBroadcastChip-DAKQKB25.js +2 -0
  103. package/dist/client/assets/{ScoutbotFxLab-BgsuLDjo.js → ScoutbotFxLab-7t9JVvZg.js} +1 -1
  104. package/dist/client/assets/{ScoutbotRealtimeVoiceCall-Bzyl0BCS.js → ScoutbotRealtimeVoiceCall-Br4bYVAx.js} +1 -1
  105. package/dist/client/assets/{SecondaryNav-Bks0CO2h.js → SecondaryNav-Dj30epYF.js} +1 -1
  106. package/dist/client/assets/{SessionEmbedScreen-b0Zgmfx5.js → SessionEmbedScreen-s2mJ5Fg9.js} +1 -1
  107. package/dist/client/assets/{SessionObserve-Dlx5vDaV.js → SessionObserve-DaUrJCMq.js} +1 -1
  108. package/dist/client/assets/{SessionObserveEvidence-ChBD1d4c.js → SessionObserveEvidence-ClUW8jpV.js} +1 -1
  109. package/dist/client/assets/SessionRefScreen-DLZNFZFK.js +1 -0
  110. package/dist/client/assets/SessionsScreen-D-hN1n4k.js +1 -0
  111. package/dist/client/assets/{SettingsDrawer-C587L1i1.js → SettingsDrawer-BFsnww-k.js} +3 -3
  112. package/dist/client/assets/SettingsScreen-Bc3Xtv5V.js +1 -0
  113. package/dist/client/assets/{ShikiPane-I_OTW5NO.js → ShikiPane-Dkwyx--r.js} +1 -1
  114. package/dist/client/assets/{SlidePanel-FCqT1zO3.js → SlidePanel-CuTeirnk.js} +1 -1
  115. package/dist/client/assets/{SpriteAvatar-CQs-jC-v.js → SpriteAvatar-DQ3PTb8L.js} +1 -1
  116. package/dist/client/assets/{StatusPill-CbABggnQ.js → StatusPill-BJ1ierIR.js} +1 -1
  117. package/dist/client/assets/{TailView-C_MXVSum.js → TailView-CufWcrvf.js} +2 -2
  118. package/dist/client/assets/Terminal-D_OmdFmr.js +1 -0
  119. package/dist/client/assets/TerminalEmbedScreen-D21ytNXW.js +1 -0
  120. package/dist/client/assets/TerminalRelay-rvUzI9Ek.js +46 -0
  121. package/dist/client/assets/{TextDocumentSurface-C-9EtYqt.js → TextDocumentSurface-Bc-kHPgG.js} +1 -1
  122. package/dist/client/assets/{TmuxPeek-Dz1gJ2pU.js → TmuxPeek-DLyDkq_D.js} +1 -1
  123. package/dist/client/assets/{VoicePermissionsPanel-MfICy9kk.js → VoicePermissionsPanel-CD903y9K.js} +1 -1
  124. package/dist/client/assets/{WorkDetailScreen-Cs7kdllj.js → WorkDetailScreen-D51oI0dH.js} +2 -2
  125. package/dist/client/assets/{WorkFilesViewer-CF-nhtZ4.js → WorkFilesViewer-BDMNbxE4.js} +1 -1
  126. package/dist/client/assets/{activity-WhBf3FXP.js → activity-BvGruxWG.js} +1 -1
  127. package/dist/client/assets/{addon-fit-q-x_HytU.js → addon-fit-Cfq4Ayjd.js} +1 -1
  128. package/dist/client/assets/{addon-webgl-fhhvEA9h.js → addon-webgl-B8sIf9-s.js} +1 -1
  129. package/dist/client/assets/{agent-essentials-DyJiUGpZ.js → agent-essentials-yb4wIJlX.js} +1 -1
  130. package/dist/client/assets/agent-identity-BxCsXnDp.js +1 -0
  131. package/dist/client/assets/{agent-lane-card-model-BCIwPjEh.js → agent-lane-card-model-q4cwzLX4.js} +1 -1
  132. package/dist/client/assets/agent-lane-detail-BNNm6FNu.js +2 -0
  133. package/dist/client/assets/{agent-lane-preview-BtnfNyFR.js → agent-lane-preview-C33Dwpn7.js} +1 -1
  134. package/dist/client/assets/{agent-lanes-model-Bl6xfviL.js → agent-lanes-model-VYQ5a68i.js} +2 -2
  135. package/dist/client/assets/{arc.es-DPJ0xRV6.js → arc.es-BBTfhvLE.js} +1 -1
  136. package/dist/client/assets/{arrow-left-WjQIN9J6.js → arrow-left-BOht-YQu.js} +1 -1
  137. package/dist/client/assets/{arrow-up-right-CtTDrZJr.js → arrow-up-right-hoR8_oUz.js} +1 -1
  138. package/dist/client/assets/{bot-B_Uzf4_O.js → bot-BUK7dOPS.js} +1 -1
  139. package/dist/client/assets/{check-BbgHJX8u.js → check--esHw52j.js} +1 -1
  140. package/dist/client/assets/{chevron-down-BFai6ZfE.js → chevron-down-NAhBUkFd.js} +1 -1
  141. package/dist/client/assets/{chevron-right-CyUa1zXx.js → chevron-right-C10o7t_X.js} +1 -1
  142. package/dist/client/assets/{chunk-HRAB3GC3-CvwpNg-G.js → chunk-HRAB3GC3-DF8R9rPv.js} +1 -1
  143. package/dist/client/assets/{clock-DviOalxA.js → clock-of01sAB6.js} +1 -1
  144. package/dist/client/assets/{code-xml-05TD3uOC.js → code-xml-CLn3TDWF.js} +1 -1
  145. package/dist/client/assets/content-B-SUUhXj.js +1 -0
  146. package/dist/client/assets/content-BRY2vo1_.js +1 -0
  147. package/dist/client/assets/content-BTm0mVyD.js +1 -0
  148. package/dist/client/assets/content-BTqvyb5E.js +1 -0
  149. package/dist/client/assets/content-BjDaXmSD.js +1 -0
  150. package/dist/client/assets/content-BrR6deGh.js +1 -0
  151. package/dist/client/assets/content-C5yvBEMy.js +1 -0
  152. package/dist/client/assets/content-Cgj5AWqT.js +1 -0
  153. package/dist/client/assets/content-CkhG__-v.js +1 -0
  154. package/dist/client/assets/content-CudIBsiP.js +1 -0
  155. package/dist/client/assets/content-DBb7ppd5.js +1 -0
  156. package/dist/client/assets/content-DEw_kGyK.js +1 -0
  157. package/dist/client/assets/content-DIy0DCzK.js +1 -0
  158. package/dist/client/assets/content-THl9hRAo.js +1 -0
  159. package/dist/client/assets/content-Uqt8AG-s.css +1 -0
  160. package/dist/client/assets/content-vi9FbmV9.js +1 -0
  161. package/dist/client/assets/content-wcgPMGVf.js +1 -0
  162. package/dist/client/assets/{conversation-icons-DohQL6GI.js → conversation-icons-ClBJi21l.js} +1 -1
  163. package/dist/client/assets/conversation-model-CHwHZNw-.js +1 -0
  164. package/dist/client/assets/conversation-motion-features-zU0k3Agz.js +1 -0
  165. package/dist/client/assets/{copy-CwCAivnc.js → copy-Dty8ZYsM.js} +1 -1
  166. package/dist/client/assets/{createLucideIcon-DlxlBfLC.js → createLucideIcon-Bt67PWH-.js} +1 -1
  167. package/dist/client/assets/discover-NDAqNvKt.js +2 -0
  168. package/dist/client/assets/embed-entry-BVR09F6e.js +2 -0
  169. package/dist/client/assets/{external-link-CnjcXf32.js → external-link-Dem738OJ.js} +1 -1
  170. package/dist/client/assets/{eye-So8tNNK6.js → eye-B3lBIwJZ.js} +1 -1
  171. package/dist/client/assets/{file-text-i3xTDUjJ.js → file-text-iF0hyVyU.js} +1 -1
  172. package/dist/client/assets/home-live-action-BkqGLVRY.js +1 -0
  173. package/dist/client/assets/home-moving-signal-C8dTXieA.js +1 -0
  174. package/dist/client/assets/home-now-card-BgvVcE83.js +1 -0
  175. package/dist/client/assets/{home-now-card-nano-CkLHUQ4J.js → home-now-card-nano-hZl9klbP.js} +1 -1
  176. package/dist/client/assets/hooks-DBIezYS2.js +2 -0
  177. package/dist/client/assets/index-BMwKgdz_.js +1 -0
  178. package/dist/client/assets/index-Bu-fckyR.css +1 -0
  179. package/dist/client/assets/index-BxoufAPA.js +1 -0
  180. package/dist/client/assets/index-Cj7NnSxI.js +1 -0
  181. package/dist/client/assets/{index-sUomXsrf.js → index-o4FKpU7Z.js} +2 -2
  182. package/dist/client/assets/{inspector-panel-DhXd-YbT.js → inspector-panel-Dy2cVTCi.js} +2 -2
  183. package/dist/client/assets/keyboard-nav-Chf51dns.js +1 -0
  184. package/dist/client/assets/{lane-observe-DrhKkQ3A.js → lane-observe-BA3g9aVd.js} +1 -1
  185. package/dist/client/assets/{lane-roster-store-NE15Oe6M.js → lane-roster-store-BiIVlYmG.js} +1 -1
  186. package/dist/client/assets/left-BC7p5QbT.js +1 -0
  187. package/dist/client/assets/left-BCSGqccQ.js +1 -0
  188. package/dist/client/assets/left-BSyj8PuJ.js +2 -0
  189. package/dist/client/assets/left-DDnxNUxd.js +1 -0
  190. package/dist/client/assets/left-DLoDKxT5.js +2 -0
  191. package/dist/client/assets/left-O-TBH7JB.js +1 -0
  192. package/dist/client/assets/left-agents-Dk9Y89lb.js +1 -0
  193. package/dist/client/assets/left-default-B3JBRQNJ.js +1 -0
  194. package/dist/client/assets/left-lanes-30Oe_3RM.js +1 -0
  195. package/dist/client/assets/left-mission-DEl4-7xu.js +1 -0
  196. package/dist/client/assets/left-plan-B4qdm4Gn.js +2 -0
  197. package/dist/client/assets/left-rvUOB14X.js +1 -0
  198. package/dist/client/assets/library-DDKSLFJ_.js +1 -0
  199. package/dist/client/assets/{loader-circle-lWOOKezu.js → loader-circle-4LDsy4Ke.js} +1 -1
  200. package/dist/client/assets/{local-agents-C7fDHLVC.js → local-agents-DIi2EacM.js} +1 -1
  201. package/dist/client/assets/{mentions-CY_wPZc5.js → mentions-CvDaviLJ.js} +1 -1
  202. package/dist/client/assets/{mesh-ops-Kn8pCtyJ.js → mesh-ops-JZwGuAPn.js} +1 -1
  203. package/dist/client/assets/{mesh-view-store-D14ihwkF.js → mesh-view-store-Du7VqIT_.js} +1 -1
  204. package/dist/client/assets/{message-circle-C5UZ6fO7.js → message-circle-BM3XgevU.js} +1 -1
  205. package/dist/client/assets/{message-markup-C8Nx04sP.js → message-markup-BcY1lShv.js} +1 -1
  206. package/dist/client/assets/{message-square-BD-4UUdc.js → message-square-ER1_q2pe.js} +1 -1
  207. package/dist/client/assets/mission-control-m3BTDQ9l.css +1 -0
  208. package/dist/client/assets/{mission-control-store-xQHVQdm8.js → mission-control-store-C6w5iVfg.js} +1 -1
  209. package/dist/client/assets/mission-wall-CocIM1cF.js +1 -0
  210. package/dist/client/assets/{observe-uJfIlIUV.js → observe-3-jn4SXb.js} +1 -1
  211. package/dist/client/assets/openAgent-Dbv5wfuL.js +1 -0
  212. package/dist/client/assets/{page-status-BymFEFai.js → page-status-0LPfBC8S.js} +1 -1
  213. package/dist/client/assets/{plus-C9lTjsgd.js → plus-C-2gTcPK.js} +1 -1
  214. package/dist/client/assets/profile-DW80Gn5k.js +1 -0
  215. package/dist/client/assets/{projects-inbox-DfVmGFFk.js → projects-inbox-DCeD3FfV.js} +1 -1
  216. package/dist/client/assets/provider-BvAxRQfE.js +1 -0
  217. package/dist/client/assets/{radio-DedMyP8J.js → radio-v7UAMZGh.js} +1 -1
  218. package/dist/client/assets/{refresh-cw-D8PFyhUa.js → refresh-cw-B5To7b6B.js} +1 -1
  219. package/dist/client/assets/resolve-panes-BDi9Qx4R.js +1 -0
  220. package/dist/client/assets/resolve-sidebar-context-HE-5eZYa.js +1 -0
  221. package/dist/client/assets/right-BDf_yTv6.js +1 -0
  222. package/dist/client/assets/{right-C1sIsSHR.js → right-BvoGOUKH.js} +1 -1
  223. package/dist/client/assets/right-C-bgjYg-.js +1 -0
  224. package/dist/client/assets/right-C3JdEfYQ.js +1 -0
  225. package/dist/client/assets/right-CYIs2tEe.js +1 -0
  226. package/dist/client/assets/right-CyRCv6Up.js +1 -0
  227. package/dist/client/assets/right-DBYGtoRv.js +1 -0
  228. package/dist/client/assets/right-o3LHMiKa.js +1 -0
  229. package/dist/client/assets/right-oPrcx9MX.js +1 -0
  230. package/dist/client/assets/right-sSvBUK-j.js +1 -0
  231. package/dist/client/assets/{rocket-CriBwkHM.js → rocket-BQQQv2L5.js} +1 -1
  232. package/dist/client/assets/router-C65cZYPn.js +1 -0
  233. package/dist/client/assets/{runtime-picker-DOZpZOlt.js → runtime-picker-eDEvx2Mz.js} +1 -1
  234. package/dist/client/assets/{scope-views-BF_RvGKU.js → scope-views-BOOmgmwx.js} +1 -1
  235. package/dist/client/assets/{scout-voice-BZ4KqADJ.js → scout-voice-B7kXlkcl.js} +1 -1
  236. package/dist/client/assets/{scroll-text-BIYf6g6N.js → scroll-text-BuneRiAD.js} +1 -1
  237. package/dist/client/assets/{search-DCT_EvPr.js → search-7_n7CxWl.js} +1 -1
  238. package/dist/client/assets/{secondaryNavConfig-Drb7wPG4.js → secondaryNavConfig-CSFDCQAf.js} +1 -1
  239. package/dist/client/assets/{selection-bridge-CJOTyYQs.js → selection-bridge-SlGsgHw2.js} +1 -1
  240. package/dist/client/assets/{send-horizontal-DDwOgEs3.js → send-horizontal-DP16OOIW.js} +1 -1
  241. package/dist/client/assets/{server-CHZCp3cF.js → server-pYOMFjrT.js} +1 -1
  242. package/dist/client/assets/{session-catalog-XhGxCtP-.js → session-catalog-_QfQ7fhZ.js} +1 -1
  243. package/dist/client/assets/session-table-CYN8e4s3.js +1 -0
  244. package/dist/client/assets/{sliders-horizontal-B9Nj-Y4J.js → sliders-horizontal-D2Z8gz6J.js} +1 -1
  245. package/dist/client/assets/{sparkles-up7pVlX-.js → sparkles-Bth2iK7t.js} +1 -1
  246. package/dist/client/assets/{sse-CVoGDiKW.js → sse-CL6gctHY.js} +1 -1
  247. package/dist/client/assets/synthetic-agent-routing-aduMYO7P.js +1 -0
  248. package/dist/client/assets/system-surfaces-redesign-B7GQhfpw.css +1 -0
  249. package/dist/client/assets/{tail-display-BdyoLvzY.js → tail-display-BRcJltQa.js} +2 -2
  250. package/dist/client/assets/{tail-events-CTipUIli.js → tail-events-NLIWLq27.js} +1 -1
  251. package/dist/client/assets/{terminal-DXQISjZn.js → terminal-By1Lw2i2.js} +1 -1
  252. package/dist/client/assets/{terminal-relay-B5Sma7fK.js → terminal-relay-CjkI5aUy.js} +1 -1
  253. package/dist/client/assets/{terminal-screen-19jAI0Cw.css → terminal-screen-BqVnCwl0.css} +1 -1
  254. package/dist/client/assets/terminal-sessions-AmSgHklm.js +1 -0
  255. package/dist/client/assets/{terminal-takeover-X97KCSJk.js → terminal-takeover-7AvNpnkC.js} +1 -1
  256. package/dist/client/assets/{use-conversation-list-B1T6J_qE.js → use-conversation-list-BCzY032j.js} +1 -1
  257. package/dist/client/assets/{use-fleet-active-asks-DLofGhhK.js → use-fleet-active-asks-CJ6-oj5k.js} +1 -1
  258. package/dist/client/assets/{use-mesh-ops-items-ByGZk8rU.js → use-mesh-ops-items-D5L-CKe_.js} +1 -1
  259. package/dist/client/assets/use-reduced-motion-CqXpVXv-.js +1 -0
  260. package/dist/client/assets/use-scout-dev-flags-BohC8seq.js +1 -0
  261. package/dist/client/assets/{useAgentHoverCard-D5e8Qg1z.js → useAgentHoverCard-RsLUYyeh.js} +1 -1
  262. package/dist/client/assets/useContentSecondaryNav-DOr5yHbT.js +1 -0
  263. package/dist/client/assets/usePersistentState-D3M4m2Ou.js +1 -0
  264. package/dist/client/assets/{usePierreRuntime-DIVunfX0.js → usePierreRuntime-B4hbNWTz.js} +1 -1
  265. package/dist/client/assets/{wrench-pEVd8JnN.js → wrench-M4G7WtYB.js} +1 -1
  266. package/dist/client/assets/{x-0XjXwGqq.js → x-ynOfVadO.js} +1 -1
  267. package/dist/client/assets/{xterm-CRLlV1Xp.js → xterm-DZHyijPp.js} +1 -1
  268. package/dist/client/index.html +2 -2
  269. package/dist/main.mjs +1444 -381
  270. package/dist/node/main.mjs +82 -20
  271. package/dist/openscout-terminal-relay.mjs +16 -4
  272. package/dist/pairing-runtime-controller.mjs +3030 -2948
  273. package/dist/runtime/broker-daemon.mjs +358 -136
  274. package/dist/scout-control-plane-web.mjs +5646 -5184
  275. package/dist/scout-web-server.mjs +5646 -5184
  276. package/package.json +4 -4
  277. package/dist/client/assets/ActivityScreen-DnqqRSlS.js +0 -1
  278. package/dist/client/assets/AgentConfigurationScreen-CJqoMA0J.js +0 -1
  279. package/dist/client/assets/AgentDefinitionsWorkspace-FpEkb-tu.js +0 -1
  280. package/dist/client/assets/AgentFloorView-CycUn0Lv.js +0 -1
  281. package/dist/client/assets/AgentInfoScreen-CAQAxpAK.js +0 -1
  282. package/dist/client/assets/AgentLaneDetailSheet-CWs9wKWk.js +0 -5
  283. package/dist/client/assets/AgentLanesEmbedScreen-BUCW4nUj.js +0 -1
  284. package/dist/client/assets/AgentsScreen-BMXvuiA2.js +0 -1
  285. package/dist/client/assets/AgentsSubnav-BTNjPYoA.js +0 -1
  286. package/dist/client/assets/BackToPicker-CkUmHuuo.js +0 -1
  287. package/dist/client/assets/BrokerScreen-CObCQvoy.js +0 -5
  288. package/dist/client/assets/CodeScreen-BXqi72NK.js +0 -1
  289. package/dist/client/assets/ConversationComposer-BBNPa5S9.js +0 -1
  290. package/dist/client/assets/ConversationFeedRows-BuejHMCY.js +0 -1
  291. package/dist/client/assets/ConversationHeader-DXMT-YXv.js +0 -1
  292. package/dist/client/assets/ConversationPanels-DHCtilQF.js +0 -2
  293. package/dist/client/assets/ConversationScreen-DSxIt9pq.css +0 -1
  294. package/dist/client/assets/ConversationScreen-Dz2d_Z_F.js +0 -1
  295. package/dist/client/assets/FlightObserveScreen-C-9S0nA5.js +0 -1
  296. package/dist/client/assets/FollowScreen--Q04xSSE.js +0 -1
  297. package/dist/client/assets/HarnessMark-Dm_qm1Ku.js +0 -1
  298. package/dist/client/assets/HarnessesScreen-Y54viPX8.js +0 -1
  299. package/dist/client/assets/KnowledgeSearchScreen-DsdDz8wY.js +0 -1
  300. package/dist/client/assets/LaneTraceDetailSheet-CBf_aNZx.js +0 -1
  301. package/dist/client/assets/MeshScreen-TgDtz-1l.js +0 -1
  302. package/dist/client/assets/MessagesScreen-BTQL0UcE.js +0 -1
  303. package/dist/client/assets/MissionControlView-D59SPnAm.js +0 -1
  304. package/dist/client/assets/MissionLogPane-Ye3YlF9s.js +0 -1
  305. package/dist/client/assets/NewChatComposer-B5FnPyzS.js +0 -19
  306. package/dist/client/assets/NewChatComposer-W-t-L4oV.css +0 -1
  307. package/dist/client/assets/ObserveTextFlow-CBitljxi.js +0 -2
  308. package/dist/client/assets/OpenScoutAppShell-BIp0WitK.js +0 -87
  309. package/dist/client/assets/OpsAgentsView-CoBfAigH.js +0 -1
  310. package/dist/client/assets/OpsScreen-Bbo0W64T.js +0 -1
  311. package/dist/client/assets/OpsSubnav-CoN8utF8.js +0 -1
  312. package/dist/client/assets/ProjectAgentProfile-FiiIcB5R.js +0 -1
  313. package/dist/client/assets/ProjectsInbox-BWiXjGi7.js +0 -2
  314. package/dist/client/assets/ProjectsScreen-Cxk4CuYn.js +0 -1
  315. package/dist/client/assets/ProjectsThreadAside-BF66ugT5.js +0 -1
  316. package/dist/client/assets/Provider-tFc3jqZ4.js +0 -1
  317. package/dist/client/assets/RawSessionsTable-BsGVgZB3.js +0 -1
  318. package/dist/client/assets/RealtimeVoiceScreen-B0Bem5Rc.js +0 -1
  319. package/dist/client/assets/RepoDiffViewerLazy-C8UPk4oo.js +0 -2
  320. package/dist/client/assets/ScoutDeckSurface-Bi9ov9Bm.js +0 -1
  321. package/dist/client/assets/ScoutbotBroadcastChip-DJXuyn73.js +0 -2
  322. package/dist/client/assets/SessionRefScreen-D7TfPYPN.js +0 -1
  323. package/dist/client/assets/SessionsScreen-BlknOWAd.js +0 -1
  324. package/dist/client/assets/SettingsScreen-BIlYxv_a.js +0 -1
  325. package/dist/client/assets/Terminal-DwZyo8kA.js +0 -1
  326. package/dist/client/assets/TerminalEmbedScreen-Czp3tQyd.js +0 -1
  327. package/dist/client/assets/agent-chat-Bfjd9y6c.js +0 -1
  328. package/dist/client/assets/agent-identity-xQHedtLl.js +0 -1
  329. package/dist/client/assets/agent-lane-detail-Cw4QVAgH.js +0 -1
  330. package/dist/client/assets/arrow-down-DsD-dYj-.js +0 -1
  331. package/dist/client/assets/chunk-T65CQEWV-DI4NKdNq.js +0 -1
  332. package/dist/client/assets/chunk-YOZR3KYS-BW85tiCr.js +0 -47
  333. package/dist/client/assets/content-2u_eV3fX.js +0 -1
  334. package/dist/client/assets/content-5irOghrY.js +0 -1
  335. package/dist/client/assets/content-8Z_0CwtD.js +0 -1
  336. package/dist/client/assets/content-B38YRDBu.js +0 -1
  337. package/dist/client/assets/content-BE3uK0LB.js +0 -1
  338. package/dist/client/assets/content-BtIxSqVY.js +0 -1
  339. package/dist/client/assets/content-CFsPAihU.js +0 -1
  340. package/dist/client/assets/content-CHU0wwA3.css +0 -1
  341. package/dist/client/assets/content-CKj5g5tu.js +0 -1
  342. package/dist/client/assets/content-CLDWXf9Z.js +0 -1
  343. package/dist/client/assets/content-CRr73E0r.js +0 -1
  344. package/dist/client/assets/content-CVR75_Uj.js +0 -1
  345. package/dist/client/assets/content-Czdp7_JQ.js +0 -1
  346. package/dist/client/assets/content-D0_EJ6nP.js +0 -1
  347. package/dist/client/assets/content-DNmxpNhD.js +0 -1
  348. package/dist/client/assets/content-XpbI9uxd.js +0 -1
  349. package/dist/client/assets/content-cyxWdgKQ.js +0 -1
  350. package/dist/client/assets/conversation-model-C4yb6_FA.js +0 -1
  351. package/dist/client/assets/conversation-motion-features-CifSdJtm.js +0 -1
  352. package/dist/client/assets/discover-DoiAJo4Z.js +0 -2
  353. package/dist/client/assets/embed-entry-D1Or9S4d.js +0 -2
  354. package/dist/client/assets/gestures-CgvAMd6F.js +0 -1
  355. package/dist/client/assets/home-live-action-B22u89j7.js +0 -1
  356. package/dist/client/assets/home-moving-signal-BdkERL6B.js +0 -1
  357. package/dist/client/assets/home-now-card-lLkv6nQs.js +0 -1
  358. package/dist/client/assets/hooks-BPLDD9yu.js +0 -2
  359. package/dist/client/assets/index-DGoLx89y.js +0 -1
  360. package/dist/client/assets/index-DITWsjFb.css +0 -1
  361. package/dist/client/assets/index-m6dFtY5f.js +0 -1
  362. package/dist/client/assets/index-pY8-Mz7y.js +0 -1
  363. package/dist/client/assets/keyboard-nav-BhZZ5HEq.js +0 -1
  364. package/dist/client/assets/left-B6eawimv.js +0 -1
  365. package/dist/client/assets/left-BL2uBHe0.js +0 -2
  366. package/dist/client/assets/left-BNJguPDG.js +0 -1
  367. package/dist/client/assets/left-BvCtvN0f.js +0 -1
  368. package/dist/client/assets/left-CfBb6bxM.js +0 -1
  369. package/dist/client/assets/left-DTrlBF0h.js +0 -2
  370. package/dist/client/assets/left-agents-DsOHgDCY.js +0 -1
  371. package/dist/client/assets/left-d4hlBBxY.js +0 -1
  372. package/dist/client/assets/left-default-BRCwoCJr.js +0 -1
  373. package/dist/client/assets/left-lanes-DNtoRzoV.js +0 -1
  374. package/dist/client/assets/left-mission-DsTu2X5Y.js +0 -1
  375. package/dist/client/assets/left-plan-CtySjsXC.js +0 -2
  376. package/dist/client/assets/library-CLpgWNJO.js +0 -1
  377. package/dist/client/assets/mission-control-D3ikEPND.css +0 -1
  378. package/dist/client/assets/openAgent-Bjt57GdM.js +0 -1
  379. package/dist/client/assets/paperclip-DL9BXPp2.js +0 -1
  380. package/dist/client/assets/profile-BqY5tesX.js +0 -1
  381. package/dist/client/assets/resolve-panes-1xeZMuaw.js +0 -1
  382. package/dist/client/assets/resolve-sidebar-context-PLr32WHN.js +0 -1
  383. package/dist/client/assets/right-1x7HzabC.js +0 -1
  384. package/dist/client/assets/right-CFzPUzlF.js +0 -1
  385. package/dist/client/assets/right-CRKyeJDk.js +0 -1
  386. package/dist/client/assets/right-CagzkLWg.js +0 -1
  387. package/dist/client/assets/right-CsV149pN.js +0 -1
  388. package/dist/client/assets/right-DITNyG2s.js +0 -1
  389. package/dist/client/assets/right-E3nNcLE3.js +0 -1
  390. package/dist/client/assets/right-eUQvSjd7.js +0 -1
  391. package/dist/client/assets/right-ozp4nM44.js +0 -1
  392. package/dist/client/assets/router-Dja9_ygK.js +0 -1
  393. package/dist/client/assets/session-table-sAVe44a4.js +0 -1
  394. package/dist/client/assets/system-surfaces-redesign-CD26LFc0.css +0 -1
  395. package/dist/client/assets/terminal-sessions-D5CIR2OL.js +0 -1
  396. package/dist/client/assets/use-reduced-motion-Cvk-HRKg.js +0 -1
  397. package/dist/client/assets/use-scout-dev-flags-BHvg3G2c.js +0 -1
  398. package/dist/client/assets/useContentSecondaryNav-ZfBNi3d4.js +0 -1
@@ -0,0 +1 @@
1
+ import{j as i,r as o,J as Te,b as et,K as tt,L as nt,C as rt}from"./index-o4FKpU7Z.js";import{u as Pe}from"./provider-BvAxRQfE.js";import{d as ot,as as st}from"./router-C65cZYPn.js";import{a as $}from"./api-h5zurxmi.js";import{u as it}from"./sse-CL6gctHY.js";import{o as at,i as Re}from"./surface-activity-B1rgWB1i.js";import{i as ct}from"./colors-BtO5_zlx.js";import{e as Me,s as lt,i as Ie,r as ut,a as dt,f as ft}from"./scoutbot-BTIErYHo.js";import{C as pt}from"./ContextMenu-CxkmFQcN.js";import{F as ht,a as mt,D as vt}from"./DocumentFocusViewer-DRKjNG9s.js";import{c as Fe,T as Be}from"./TextDocumentSurface-Bc-kHPgG.js";import{C as gt}from"./chevron-right-C10o7t_X.js";import{F as wt}from"./file-text-iF0hyVyU.js";import{c as Ue}from"./createLucideIcon-Bt67PWH-.js";import{C as bt}from"./code-xml-CLn3TDWF.js";import{A as yt}from"./arrow-left-BOht-YQu.js";import{h as St}from"./scout-voice-B7kXlkcl.js";import{i as Ct}from"./keyboard-nav-Chf51dns.js";import{d as pe,b as Ne,i as Oe}from"./MessageComposerSuggestions-Dfc3PH2y.js";import{o as kt,N as Et}from"./NewChatComposer-S08F6_La.js";import{u as xt}from"./chunk-HRAB3GC3-DF8R9rPv.js";function At(e){const t=e instanceof Error?e.message:String(e);return Rt(t)?"Scout server is unreachable":t}function Tt(e){return e==="Scout server is unreachable"}function Rt(e){return/failed to fetch|fetch failed|networkerror|load failed|couldn'?t connect|could not connect|connection refused|econnrefused|server is unreachable/i.test(e)}const It=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Nt=Ue("arrow-right",It);const Ot=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],_t=Ue("chevron-up",Ot),Lt={id:"audio",canHandle:e=>e.kind==="file"&&e.mediaType.startsWith("audio/"),render:({resource:e})=>{const t=e;return i.jsx("div",{className:"s-file-preview-media-wrap",children:i.jsx("div",{className:"s-file-preview-audio-stage",children:i.jsx("audio",{className:"s-file-preview-audio",src:t.rawUrl,controls:!0})})})}},jt={id:"binary",canHandle:()=>!0,render:({resource:e})=>{const t=e;return i.jsxs("div",{className:"s-file-preview-callout",children:[i.jsxs("div",{className:"s-file-preview-callout-title",children:[t.previewReason," — open in OS"]}),i.jsxs("div",{className:"s-file-preview-callout-copy",children:["Scout can resolve this file, but it does not have an inline preview for ",t.mediaType," yet."]})]})}},Dt=new Set(["text/typescript","text/javascript","text/css","text/html","application/json","text/yaml","text/toml","text/x-shellscript","text/plain"]),Pt={id:"code",canHandle:e=>e.kind==="file"&&e.previewable&&Dt.has(e.mediaType),render:({resource:e})=>{const t=e,n=Fe({id:t.realPath,title:t.title,uri:t.realPath,mediaType:t.mediaType,value:t.content,filename:t.title,kind:"code",readOnly:!0});return i.jsx(Be,{document:n,mode:"read",className:"s-doc-focus-document"})}},Mt={id:"directory",canHandle:e=>e.kind==="directory",render:({resource:e,openFilePreview:t})=>{const n=e,r=Ft(n.realPath,n.rootPath);return i.jsxs("div",{className:"s-file-preview-directory",children:[i.jsx("div",{className:"s-file-preview-breadcrumb","aria-label":"Directory breadcrumb",children:r.map((s,a)=>{const c=a===r.length-1;return i.jsxs("div",{className:"s-file-preview-breadcrumb-item",children:[a>0&&i.jsx(gt,{size:12,"aria-hidden":"true"}),c?i.jsx("span",{className:"s-file-preview-breadcrumb-current",children:s.label}):i.jsx("button",{type:"button",className:"s-file-preview-breadcrumb-link",onClick:()=>t(s.path),children:s.label})]},s.path)})}),i.jsxs("div",{className:"s-file-preview-directory-list",role:"list",children:[n.entries.map(s=>i.jsxs("button",{type:"button",className:"s-file-preview-entry",onClick:()=>t(s.path),children:[i.jsx("span",{className:"s-file-preview-entry-icon","aria-hidden":"true",children:s.kind==="directory"?i.jsx(ht,{size:14}):i.jsx(wt,{size:14})}),i.jsx("span",{className:"s-file-preview-entry-name",children:s.name}),i.jsx("span",{className:"s-file-preview-entry-kind",children:s.kind==="directory"?"dir":"file"})]},s.realPath)),n.entries.length===0&&i.jsx("div",{className:"s-file-preview-directory-empty",children:"This directory is empty."})]})]})}};function Ft(e,t){const n=t==="/"?"/":t.replace(/\/+$/u,""),r=e==="/"?"/":e.replace(/\/+$/u,""),s=n.split("/").filter(Boolean),a=r.split("/").filter(Boolean),c=[{label:s[s.length-1]??"/",path:n||"/"}];let p=n||"/";for(let f=s.length;f<a.length;f+=1){const A=a[f];A&&(p=p==="/"?`/${A}`:`${p}/${A}`,c.push({label:A,path:p}))}return c}const Bt={id:"html",canHandle:e=>e.kind==="file"&&e.previewable&&e.mediaType==="text/html",render:({resource:e})=>i.jsx("div",{className:"s-file-preview-html-wrap",children:i.jsx("iframe",{className:"s-file-preview-html-frame",src:e.kind==="file"?e.rawUrl:"",title:e.title,sandbox:"allow-forms allow-popups allow-popups-to-escape-sandbox allow-scripts",referrerPolicy:"no-referrer"})})},Ut={id:"image",canHandle:e=>e.kind==="file"&&e.mediaType.startsWith("image/"),render:({resource:e})=>i.jsx("div",{className:"s-file-preview-image-wrap",children:i.jsx("div",{className:"s-file-preview-image-stage",children:i.jsx("img",{className:"s-file-preview-image",src:e.kind==="file"?e.rawUrl:"",alt:e.title})})})},qt={id:"markdown",canHandle:e=>e.kind==="file"&&e.previewable&&e.mediaType==="text/markdown",render:({resource:e})=>{const t=e,n=Fe({id:t.realPath,title:t.title,uri:t.realPath,mediaType:t.mediaType,value:t.content,filename:t.title,kind:"markdown",readOnly:!0});return i.jsx(Be,{document:n,mode:"preview",className:"s-doc-focus-document"})}},Vt={id:"video",canHandle:e=>e.kind==="file"&&e.mediaType.startsWith("video/"),render:({resource:e})=>{const t=e;return i.jsx("div",{className:"s-file-preview-media-wrap",children:i.jsx("div",{className:"s-file-preview-media-stage",children:i.jsx("video",{className:"s-file-preview-video",src:t.rawUrl,controls:!0})})})}},Ht=[Mt,qt,Bt,Pt,Ut,Vt,Lt,jt];function $t({path:e,onOpenPath:t,onOpenInCode:n,onClose:r}){const[s,a]=o.useState(null),[c,p]=o.useState(null),[f,A]=o.useState(!1),[w,T]=o.useState(null),P=o.useRef(null);o.useEffect(()=>{P.current=w},[w]),o.useEffect(()=>{if(!e){a(null),p(null),A(!1);return}let d=!1;return A(!0),p(null),a(null),$(`/api/file/preview?path=${encodeURIComponent(e)}`).then(h=>{d||(a(h),Jt(h,P.current,T))}).catch(h=>{d||p(h instanceof Error?h.message:"could not load file")}).finally(()=>{d||A(!1)}),()=>{d=!0}},[e]);const{currentIndex:j,prevPath:u,nextPath:g}=o.useMemo(()=>{if(!s||s.kind!=="file"||!w)return{currentIndex:-1,prevPath:null,nextPath:null};const d=w.files.findIndex(h=>h.realPath===s.realPath);return d<0?{currentIndex:-1,prevPath:null,nextPath:null}:{currentIndex:d,prevPath:d>0?w.files[d-1].path:null,nextPath:d<w.files.length-1?w.files[d+1].path:null}},[s,w]);if(o.useEffect(()=>{if(!e)return;const d=h=>{if(h.key==="Escape"){r();return}if(h.target instanceof HTMLElement){const b=h.target.tagName;if(b==="INPUT"||b==="TEXTAREA"||h.target.isContentEditable)return}h.metaKey||h.ctrlKey||h.altKey||(h.key==="ArrowLeft"&&u?(h.preventDefault(),t(u)):h.key==="ArrowRight"&&g?(h.preventDefault(),t(g)):h.key==="Backspace"&&w&&s?.kind==="file"&&(h.preventDefault(),t(w.dirPath)))};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e,r,t,u,g,w,s]),!e)return null;const S=()=>{$("/api/file/reveal",{method:"POST",body:JSON.stringify({path:s?.realPath??e})}).catch(d=>{p(d instanceof Error?d.message:"reveal failed")})},O=s?Ht.find(d=>d.canHandle(s))??null:null,k=!!(s&&s.kind==="file"&&w&&j>=0&&w.files.length>1),E=[];k&&w&&E.push({label:`Folder: ${w.dirTitle}`,icon:i.jsx(_t,{size:12}),onClick:()=>t(w.dirPath),title:`Back to ${w.dirTitle} (Backspace)`}),E.push({label:"Open in Code",icon:i.jsx(bt,{size:12}),onClick:()=>{s?.kind==="file"&&n(s.realPath,s.rootPath)},title:"Continue with this file in Scout’s Code browser",disabled:s?.kind!=="file"}),E.push({label:"Show in folder",icon:i.jsx(mt,{size:12}),onClick:S,title:"Show this file in its operating system folder",hideLabel:!0});const _=s?zt(s):[];k&&_.unshift(`${j+1} / ${w.files.length}`);const I=s&&O?O.render({resource:s,openFilePreview:t}):null;return i.jsx(vt,{open:!0,kind:Kt(s),document:null,title:s?.title??e.split("/").pop()??"File",eyebrow:"File preview",subtitle:s?.realPath??e,meta:_,state:f?"Loading…":null,error:c,body:I?i.jsxs("div",{className:`s-file-preview-shell${k?" s-file-preview-shell-nav":""}`,children:[k&&i.jsx("button",{type:"button",className:"s-file-preview-side-nav s-file-preview-side-nav-left",onClick:()=>u&&t(u),disabled:!u,"aria-label":"Previous file",title:"Previous file (←)",children:i.jsx(yt,{size:18,strokeWidth:1.8,"aria-hidden":"true"})}),i.jsx("div",{className:"s-file-preview-shell-body",children:I}),k&&i.jsx("button",{type:"button",className:"s-file-preview-side-nav s-file-preview-side-nav-right",onClick:()=>g&&t(g),disabled:!g,"aria-label":"Next file",title:"Next file (→)",children:i.jsx(Nt,{size:18,strokeWidth:1.8,"aria-hidden":"true"})})]}):null,actions:E,onClose:r})}function Jt(e,t,n){if(e.kind==="directory"){const s=e.entries.filter(a=>a.kind==="file");n({dirPath:e.path,dirTitle:e.title,files:s});return}if(!t){n(null);return}t.files.some(s=>s.realPath===e.realPath)||n(null)}function Kt(e){return!e||e.kind==="directory"||e.mediaType==="text/markdown"||e.mediaType==="text/plain"?"doc":"code"}function zt(e){return e.kind==="directory"?[`${e.entries.length} ${e.entries.length===1?"entry":"entries"}`]:[...e.previewable&&e.truncated?["truncated"]:[],Gt(e.sizeBytes),e.mediaType]}function Gt(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const qe={activity:"idle",brief:{lastDeliveredAt:null},reminders:{dueCount:0,upcomingCount:0,due:[],next:null},voice:{available:null,setupBlocked:!1,replies:!1},error:null,session:{title:null,lastActivityAt:null},conversation:{messageCount:0,loading:!0}},z=()=>{},Ve={focusScoutbot:z,triggerBrief:z,triggerAskState:z,toggleVoiceReplies:z,openScoutbotSettings:z,startNewChat:z,dismissReminder:z,askReminderStatus:z},we=o.createContext(null);function Wt({children:e}){const[t,n]=o.useState(qe),r=o.useRef(Ve),s=o.useCallback(f=>{n(A=>Qt(A,f)?A:f)},[]),a=o.useCallback(f=>{r.current=f},[]),c=o.useMemo(()=>({focusScoutbot:()=>r.current.focusScoutbot(),triggerBrief:()=>r.current.triggerBrief(),triggerAskState:()=>r.current.triggerAskState(),toggleVoiceReplies:()=>r.current.toggleVoiceReplies(),openScoutbotSettings:()=>r.current.openScoutbotSettings(),startNewChat:()=>r.current.startNewChat(),dismissReminder:f=>r.current.dismissReminder(f),askReminderStatus:f=>r.current.askReminderStatus(f)}),[]),p=o.useMemo(()=>({state:t,actions:c,publishState:s,registerActions:a}),[t,c,s,a]);return i.jsx(we.Provider,{value:p,children:e})}function pr(){const e=o.useContext(we);return e?{state:e.state,actions:e.actions}:{state:qe,actions:Ve}}function hr(){const e=o.useContext(we);return e?{publishState:e.publishState,registerActions:e.registerActions}:null}function Qt(e,t){return e.activity===t.activity&&e.brief.lastDeliveredAt===t.brief.lastDeliveredAt&&e.reminders.dueCount===t.reminders.dueCount&&e.reminders.upcomingCount===t.reminders.upcomingCount&&Xt(e.reminders.due,t.reminders.due)&&He(e.reminders.next,t.reminders.next)&&e.voice.available===t.voice.available&&e.voice.setupBlocked===t.voice.setupBlocked&&e.voice.replies===t.voice.replies&&e.error===t.error&&e.session.title===t.session.title&&e.session.lastActivityAt===t.session.lastActivityAt&&e.conversation.messageCount===t.conversation.messageCount&&e.conversation.loading===t.conversation.loading}function Xt(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!He(e[n],t[n]))return!1;return!0}function He(e,t){return e===t?!0:!e||!t?!1:e.id===t.id&&e.body===t.body&&e.status===t.status&&e.dueAt===t.dueAt}const Yt="/api/voice/realtime/call",$e="/api/voice/realtime/lease",Zt="x-openscout-realtime-voice-lease",Je="surface.realtime-voice",mr="scout:realtime-voice-stop",en={noise_reduction:{type:"far_field"},turn_detection:{type:"server_vad",threshold:.6,prefix_padding_ms:300,silence_duration_ms:500,create_response:!0,interrupt_response:!0}},tn={noise_reduction:{type:"near_field"},turn_detection:{type:"server_vad",threshold:.5,prefix_padding_ms:300,silence_duration_ms:500,create_response:!0,interrupt_response:!0}},nn="/api/scoutbot/chat",rn=25e3;async function on(e={}){if(ie(e.signal),!globalThis.RTCPeerConnection||!navigator.mediaDevices?.getUserMedia)throw new Error("This browser does not support realtime audio calls.");e.onState?.("connecting");const t=new RTCPeerConnection,n=new Audio;n.autoplay=!0;let r=!1,s=null,a=null,c=null,p=0,f=0;const A=(u,g,S="voice")=>{f+=1,e.onTrace?.({id:`voice-${f}`,at:Date.now(),kind:S,label:u,...g?{detail:g}:{}})};let w=null;const T=()=>{if(w)return w;r=!0,e.signal?.removeEventListener("abort",j),c&&clearInterval(c),c=null,s?.getTracks().forEach(g=>g.stop()),n.pause(),n.srcObject=null,t.close();const u=a;return a=null,w=(async()=>{u&&await vn(u),e.onState?.("ended")})(),w},P=()=>{T().catch(u=>{e.onError?.(u instanceof Error?u.message:"Could not release the realtime voice lease."),e.onState?.("error")})},j=()=>{P()};e.signal?.addEventListener("abort",j,{once:!0}),t.ontrack=({streams:u})=>{const g=u[0];if(!g||r)return;const[S]=g.getAudioTracks();S&&S.addEventListener("ended",()=>{r||e.onError?.("Realtime voice audio ended unexpectedly.")}),n.srcObject=g,n.play().catch(()=>{e.onError?.("Browser playback was blocked. Interact with the page, then start the call again.")})},t.onconnectionstatechange=()=>{r||(t.connectionState==="connected"?(e.onState?.("live"),A("Realtime channel connected","Scoutbot bridge is ready")):(t.connectionState==="failed"||t.connectionState==="disconnected")&&(e.onError?.("Realtime voice connection ended unexpectedly."),P()))};try{s=await hn(e.inputDeviceName,e.signal),ie(e.signal);for(const m of s.getTracks())t.addTrack(m,s);const u=t.createDataChannel("oai-events"),g=new Set;let S=Promise.resolve(),O=!1,k=null;const E=[],_=m=>{if(r||u.readyState!=="open")return!1;try{return u.send(JSON.stringify(m)),!0}catch{return e.onError?.("Realtime voice events channel closed unexpectedly."),!1}},I=()=>{if(O||k||E.length===0)return;const m=E.shift();if(m){if(k=m,!_({type:"response.create",response:{instructions:m}})){k=null,E.unshift(m);return}O=!0}},d=m=>{E.push(m),I()};u.addEventListener("open",()=>{if(r)return;const m=pn(e.inputDeviceName);if(!_({type:"session.update",session:{type:"realtime",audio:{input:m}}})){e.onError?.("Could not configure Scout's realtime microphone processing.");return}A("Scoutbot bridge ready","Live fleet context is available"),d("Open with one brief audible greeting: 'Hi, I’m Scoutbot. I can check the fleet and coordinate through Scout. What would you like to work on?'")}),u.addEventListener("error",()=>{r||e.onError?.("Realtime voice events channel closed unexpectedly.")}),u.addEventListener("message",m=>{const L=an(m.data);if(L?.type==="error"){if(Ke(L.message)){k&&(E.unshift(k),k=null),O=!0,A("Scoutbot reply queued","Waiting for the current spoken response to finish","scoutbot");return}e.onError?.(L.message??"OpenAI Realtime reported an error.");return}if(L?.type==="response.created"){O=!0,k=null;return}if(L?.type==="response.done"){O=!1,k=null;for(const D of cn(L))D.name!=="ask_scoutbot"||g.has(D.callId)||(g.add(D.callId),S=S.then(()=>sn({functionCall:D,route:e.getRoute?.()??e.route,uiContext:e.getUiContext?.(),onReply:e.onScoutbotReply,onTrace:A,send:_,requestResponse:d})).catch(V=>{e.onError?.(V instanceof Error?V.message:"Scoutbot could not complete the voice request.")}));I()}});const h=await he(t.createOffer(),e.signal);if(await he(t.setLocalDescription(h),e.signal),!h.sdp)throw new Error("Could not create a WebRTC offer.");const b=await fetch(Yt,{method:"POST",headers:{"content-type":"application/sdp"},body:h.sdp,signal:e.signal});a=b.headers.get(Zt)?.trim()||null;const y=await he(b.text(),e.signal);if(!b.ok)throw new Error(dn(y,b.status));if(!a)throw new Error("Scout started the audio connection without a concurrency lease. Please try again.");return c=setInterval(()=>{if(!a||r)return;const m=a;mn(m).then(L=>{if(!(r||m!==a)){if(L){p=0;return}e.onError?.("Realtime voice lost its server lease. Reconnect to continue safely."),P()}}).catch(()=>{p+=1,!(p<2||r)&&(e.onError?.("Realtime voice could not renew its server lease. Check the connection and try again."),P())})},rn),await he(t.setRemoteDescription({type:"answer",sdp:y}),e.signal),ie(e.signal),{leaseId:a,stop:T}}catch(u){throw await T(),u}}async function sn(e){const t=ln(e.functionCall.arguments);if(!t){e.onTrace("Scoutbot request could not be read",void 0,"error"),ve(e,{ok:!1,error:"The voice request did not include a usable Scoutbot prompt."});return}e.onTrace("Scoutbot is checking the control plane",t,"scoutbot");try{const n=await fetch(nn,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({body:t,route:e.route,uiContext:e.uiContext})}),r=await n.text();if(!n.ok)throw new Error(un(r,n.status));const s=JSON.parse(r),a=typeof s.reply?.body=="string"?s.reply.body.trim():"";if(!a)throw new Error("Scoutbot returned an empty reply.");const c=Me(a).filter(A=>A.type==="ask-agent").length,p=e.onReply?await e.onReply(a):{agentRequests:{requested:c,sent:0,failed:c}},f=lt(a);e.onTrace("Scoutbot reply ready",void 0,"scoutbot"),ve(e,{ok:!0,reply:f,...p.agentRequests.requested>0?{agentRequests:p.agentRequests}:{}})}catch(n){const r=n instanceof Error?n.message:"Scoutbot could not complete the voice request.";e.onTrace("Scoutbot request failed",r,"error"),ve(e,{ok:!1,error:r})}}function ve(e,t){if(!e.send({type:"conversation.item.create",item:{type:"function_call_output",call_id:e.functionCall.callId,output:JSON.stringify(t)}}))return;const r=t.agentRequests;e.requestResponse(t.ok?r&&r.requested>0?r.failed>0?"Answer using the Scoutbot result. Say clearly that Scoutbot tried to send the agent request automatically but delivery failed, and tell the operator to check the activity log. Be concise and do not mention tools, JSON, fences, or implementation details.":"Answer using the Scoutbot result. Say clearly that the agent request was sent automatically. Do not claim the requested work is complete. Be concise and do not mention tools, JSON, fences, or implementation details.":"Answer using the Scoutbot result. Speak the useful answer naturally and concisely. Do not mention tools, JSON, fences, or implementation details.":"Briefly tell the operator that Scoutbot could not complete the live lookup and state the returned error plainly.")}function Ke(e){const t=e?.toLowerCase()??"";return t.includes("active response in progress")||t.includes("conversation already has an active response")||t.includes("response is already in progress")}function an(e){if(typeof e!="string")return null;try{const t=JSON.parse(e);return{...typeof t.type=="string"?{type:t.type}:{},...typeof t.error?.message=="string"?{message:t.error.message}:{},...t.response&&typeof t.response=="object"?{response:t.response}:{}}}catch{return null}}function cn(e){return Array.isArray(e.response?.output)?e.response.output.flatMap(t=>{if(!t||typeof t!="object")return[];const n=t;return n.type!=="function_call"||typeof n.call_id!="string"||typeof n.name!="string"||typeof n.arguments!="string"?[]:[{callId:n.call_id,name:n.name,arguments:n.arguments}]}):[]}function ln(e){try{const t=JSON.parse(e);if(typeof t.request!="string")return null;const n=t.request.trim();return n?n.slice(0,8e3):null}catch{return null}}function un(e,t){try{const n=JSON.parse(e);if(typeof n.error=="string"&&n.error.trim())return n.error}catch{}return`Scoutbot could not complete the live lookup (HTTP ${t}).`}function dn(e,t){try{const n=JSON.parse(e);if(typeof n.error=="string"&&n.error.trim())return n.error}catch{}return`Could not start realtime voice (HTTP ${t}).`}async function he(e,t){return t?(ie(t),new Promise((n,r)=>{const s=()=>r(be(t));t.addEventListener("abort",s,{once:!0}),e.then(a=>{t.removeEventListener("abort",s),n(a)},a=>{t.removeEventListener("abort",s),r(a)})})):e}async function _e(e,t){return t?(ie(t),new Promise((n,r)=>{let s=!1;const a=()=>{s=!0,r(be(t))};t.addEventListener("abort",a,{once:!0}),e.then(c=>{if(t.removeEventListener("abort",a),s||t.aborted){c.getTracks().forEach(p=>p.stop());return}n(c)},c=>{t.removeEventListener("abort",a),s||r(c)})})):e}const Le={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,channelCount:1},fn=/\b(?:airpods?|earbuds?|earphones?|headsets?|headphones?|buds?|hands[- ]?free)\b/iu;function pn(e){return fn.test(e?.trim()??"")?tn:en}async function hn(e,t){const n=await je(e);let r=await _e(navigator.mediaDevices.getUserMedia({audio:{...Le,...n?{deviceId:{exact:n.deviceId}}:{}}}),t);if(!n&&e?.trim()){const s=await je(e),a=r.getAudioTracks?.()[0]?.label?.trim().toLocaleLowerCase()??"";if(s&&s.label.trim().toLocaleLowerCase()!==a)try{const c=await _e(navigator.mediaDevices.getUserMedia({audio:{...Le,deviceId:{exact:s.deviceId}}}),t);r.getTracks().forEach(p=>p.stop()),r=c}catch(c){if(t?.aborted)throw r.getTracks().forEach(p=>p.stop()),c}}for(const s of r.getAudioTracks?.()??[])s.contentHint="speech";return r}async function je(e){const t=e?.trim().toLocaleLowerCase();if(!t||typeof navigator.mediaDevices.enumerateDevices!="function")return null;try{const n=(await navigator.mediaDevices.enumerateDevices()).filter(r=>r.kind==="audioinput"&&r.deviceId&&r.label.trim());return n.find(r=>r.label.trim().toLocaleLowerCase()===t)??n.find(r=>{const s=r.label.trim().toLocaleLowerCase();return s.includes(t)||t.includes(s)})??null}catch{return null}}function ie(e){if(e?.aborted)throw be(e)}function be(e){return e.reason instanceof Error?e.reason:new DOMException("Realtime voice connection was cancelled.","AbortError")}async function mn(e){return(await fetch(`${$e}/${encodeURIComponent(e)}`,{method:"PUT"})).ok}async function vn(e){const t=await fetch(`${$e}/${encodeURIComponent(e)}`,{method:"DELETE",keepalive:!0});if(!t.ok&&t.status!==404)throw new Error(`Could not release realtime voice lease (HTTP ${t.status}).`)}const gn=[{id:"home",label:"Home",description:"Fleet overview, briefings, and recent activity.",route:{view:"inbox"}},{id:"projects",label:"Projects",description:"Projects, agents, and project-scoped work.",route:{view:"agents-v2"},deepActions:["Open a project by projectSlug.","Open an agent by agentId."]},{id:"sessions",label:"Sessions",description:"Active and recent harness sessions.",route:{view:"sessions"},deepActions:["Open a session by sessionId."]},{id:"messages",label:"Messages",description:"Direct conversations and channels.",route:{view:"messages"},deepActions:["Open a conversation by conversationId.","Filter by all, direct messages, or channels."]},{id:"dispatch",label:"Dispatch",description:"Requests, flights, work, and delivery state.",route:{view:"broker"}},{id:"search",label:"Search",description:"Knowledge and indexed workspace search.",route:{view:"search"}},{id:"operations",label:"Operations",description:"Mission Control, live activity, agent lanes, runtime, and mesh health.",route:{view:"ops",mode:"mission"}},{id:"repositories",label:"Repositories",description:"Repository and worktree status, including diffs.",route:{view:"repos"},deepActions:["Open a repository by absolute root."]},{id:"code-browser",label:"Code Browser",description:"Read files in a project or worktree.",route:{view:"code"},deepActions:["Select a project with the project field; it accepts the displayed project name or slug.","Open a file inside it with path and optional wt.","Alternatively use absolute root and file fields.","Focus a line with line and optional endLine.","Deep links: scout://{project}/{path}, scout:///{absolute/path}, or legacy scout://code/{project}/{path}."]},{id:"terminals",label:"Terminals",description:"Observe or take over terminal sessions.",route:{view:"terminal"}},{id:"settings",label:"Settings",description:"Connections, agents, communications, credentials, voice, and devices.",route:{view:"settings"}}],wn=[{id:"comms",label:"Comms",description:"Native conversations and channels.",route:{view:"messages"},deepActions:["Open a conversation by conversationId.","Open a channel by channelId."]},{id:"projects",label:"Projects",description:"Native project and agent browser.",route:{view:"agents-v2"},deepActions:["Filter to a project by projectSlug.","Select an agent by agentId."]},{id:"terminals",label:"Terminals",description:"Native terminal workspace.",route:{view:"terminal"},deepActions:["Select an agent terminal by agentId."]},{id:"tail",label:"Tail",description:"Live agent and harness activity.",route:{view:"ops",mode:"tail"}},{id:"dispatch",label:"Dispatch",description:"Dispatch and coordination overview.",route:{view:"broker"}},{id:"agent-lanes",label:"Agent Lanes",description:"Native lane overview for active agents.",route:{view:"ops",mode:"lanes"}},{id:"repositories",label:"Repositories",description:"Native repository and worktree status.",route:{view:"repos"}},{id:"code-browser",label:"Code Browser",description:"Embedded read-only project browser.",route:{view:"code"},deepActions:["Select a project with the project field; it accepts the displayed project name or slug.","Open a file inside it with path and optional wt.","Alternatively use absolute root and file fields.","Focus a line with line and optional endLine.","Deep links: scout://{project}/{path}, scout:///{absolute/path}, or legacy scout://code/{project}/{path}."]},{id:"settings",label:"Settings",description:"Native app settings; Voice is directly addressable.",route:{view:"settings"},deepActions:["Open Voice settings with section=voice."]}];function bn(e){const t=e==="macos";return{host:e,shellLabel:t?"Scout for macOS":"OpenScout web",destinations:t?wn:gn,rules:["When asked what navigation is available, list only these human labels and short descriptions.","Never expose internal Route.view names, aliases, URL fragments, or implementation vocabulary in the human reply.","Emit only a destination route or deep action explicitly described by this host context.","If the requested destination or deep action is absent, say it is not available in this app instead of approximating it with another page."]}}const yn="scout:scoutbot-realtime-reply",me="scout:scoutbot-session-changed",Sn={enabled:!1,open:!1,state:"idle",leaseId:null,error:null,trace:[],chatState:null,sessionAction:null,setOpen:()=>{},startCall:async()=>{},endCall:async()=>!0,startNewChat:async()=>{},switchChat:async()=>{},updatePreferredModel:async e=>e,clearTrace:()=>{},openVoiceSettings:()=>{}},ze=o.createContext(Sn);function Cn({children:e}){const{route:t,applyScoutbotUiAction:n}=Qe(),r=Pe(Je,!1),[s,a]=o.useState(!1),[c,p]=o.useState("idle"),[f,A]=o.useState(null),[w,T]=o.useState(null),[P,j]=o.useState([]),[u,g]=o.useState(null),[S,O]=o.useState(null),k=o.useRef(null),E=o.useRef(null),_=o.useRef(null),I=o.useRef(0),d=o.useRef(!1),h=o.useRef(!1),b=o.useRef({route:t,applyScoutbotUiAction:n});b.current={route:t,applyScoutbotUiAction:n};const y=o.useCallback((v,C,R="voice")=>{j(M=>[...M,{id:`voice-ui-${Date.now()}-${M.length}`,at:Date.now(),kind:R,label:v,...C?{detail:C}:{}}].slice(-100))},[]),m=o.useCallback(()=>j([]),[]),L=o.useCallback(async()=>{const v=await $("/api/scoutbot/session");return d.current||g(v),v},[]);o.useEffect(()=>{if(!r)return;const v=()=>{L().catch(C=>{d.current||T(C instanceof Error?C.message:"Could not load Scoutbot chats.")})};return v(),window.addEventListener(me,v),()=>window.removeEventListener(me,v)},[r,L]);const D=o.useCallback(async()=>{I.current+=1;const v=_.current;E.current?.abort(),E.current=null;const C=k.current;k.current=null;try{await C?.stop(),await v}catch(R){return d.current||(p("error"),T(R instanceof Error?R.message:"Could not end realtime voice cleanly.")),!1}return d.current||(A(null),p("ended"),y("Live voice ended","Microphone and host lease released","voice")),!0},[y]);o.useEffect(()=>{r||(a(!1),(k.current||c==="connecting"||c==="live")&&D())},[r,D,c]),o.useEffect(()=>(d.current=!1,()=>{d.current=!0,I.current+=1,E.current?.abort(),E.current=null,k.current?.stop().catch(()=>{}),k.current=null}),[]);const V=o.useCallback(async v=>{window.dispatchEvent(new CustomEvent(yn,{detail:{body:v}}));const C=v.replace(/```[\s\S]*?```/gu,"").trim();C&&y("Scoutbot replied",C.slice(0,2e3),"scoutbot");let R=0,M=0,K=0;for(const B of Me(v))if(B.type==="ask-agent")R+=1,await An(B,y,T)?M+=1:K+=1;else if(B.type!=="reminder"){const N=xn(B),U=B.type==="navigate"||B.type==="view-file"?"navigation":"scoutbot";y(En(B),N,U),b.current.applyScoutbotUiAction(B),y(Ie()?"Action sent to Scout for macOS":"Action applied in OpenScout",N,U)}return await L().catch(()=>null),{agentRequests:{requested:R,sent:M,failed:K}}},[y,L]),Y=o.useCallback(()=>{const v={type:"navigate",route:{view:"settings",section:"voice"}};y("Voice settings requested",void 0,"navigation"),b.current.applyScoutbotUiAction(v)},[y]),Z=o.useCallback(async()=>{if(!r){T("Turn on live voice in Settings → Voice before starting a call."),a(!1);return}if(h.current||c==="connecting"||c==="live")return;h.current=!0,E.current?.abort();const v=k.current;k.current=null;try{await v?.stop(),A(null)}catch(N){p("error"),T(N instanceof Error?N.message:"Could not end the previous realtime voice call."),h.current=!1;return}const C=new AbortController;E.current=C;const R=I.current+1;I.current=R;let M=()=>{};const K=new Promise(N=>{M=N});_.current=K;let B=!1;T(null),j([{id:"connecting",at:Date.now(),label:"Connecting secure audio"}]),p("connecting");try{const N=await St().then(({settings:q})=>q.inputDeviceName).catch(()=>null),U=await on({signal:C.signal,inputDeviceName:N,getRoute:()=>b.current.route,getUiContext:()=>bn(Ie()?"macos":"web"),onState:q=>{!d.current&&I.current===R&&p(q)},onError:q=>{if(!(d.current||I.current!==R)){if(Ke(q)){y("Scoutbot reply queued","Waiting for the current spoken response to finish","scoutbot");return}T(q),y("Voice issue",q,"error")}},onTrace:q=>{!d.current&&I.current===R&&j(ae=>[...ae,q].slice(-100))},onScoutbotReply:q=>!d.current&&I.current===R?V(q):{agentRequests:{requested:0,sent:0,failed:0}}});if(d.current||C.signal.aborted||I.current!==R){await U.stop();return}k.current=U,A(U.leaseId),B=!0}catch(N){if(!d.current&&I.current===R&&!kn(N)){p("error");const U=N instanceof Error?N.message:"Could not start realtime voice.";T(U),y("Live voice could not start",U,"error")}}finally{!B&&E.current===C&&(E.current=null),M(),_.current===K&&(_.current=null),h.current=!1}},[y,V,r,c]),ee=o.useCallback(async()=>{if(!S){O("new"),T(null);try{if((k.current||c==="connecting"||c==="live")&&!await D())return;if(u?.session.messages.length===0){j([{id:`voice-chat-${Date.now()}`,at:Date.now(),kind:"scoutbot",label:"New live chat ready"}]);return}const v=await $("/api/scoutbot/session/reset",{method:"POST"});g(v),j([{id:`voice-chat-${Date.now()}`,at:Date.now(),kind:"scoutbot",label:"New live chat ready"}]),window.dispatchEvent(new CustomEvent(me,{detail:{id:v.session.id}}))}catch(v){const C=v instanceof Error?v.message:"Could not start a new Scoutbot chat.";T(C),y("Could not start a new live chat",C,"error")}finally{O(null)}}},[y,u?.session.messages.length,D,S,c]),te=o.useCallback(async v=>{if(!(!v||S||v===u?.session.id)){O(v),T(null);try{if((k.current||c==="connecting"||c==="live")&&!await D())return;const C=await $("/api/scoutbot/session/switch",{method:"POST",body:JSON.stringify({id:v})});g(C),j([{id:`voice-chat-${Date.now()}`,at:Date.now(),kind:"scoutbot",label:"Live chat restored",detail:C.session.title}]),window.dispatchEvent(new CustomEvent(me,{detail:{id:C.session.id}}))}catch(C){const R=C instanceof Error?C.message:"Could not switch Scoutbot chats.";T(R),y("Could not restore the live chat",R,"error")}finally{O(null)}}},[y,u?.session.id,D,S,c]),ne=o.useCallback(async v=>{const C=v.trim();if(!C)throw new Error("Preferred model is required.");const R=await $("/api/scoutbot/config",{method:"POST",body:JSON.stringify({model:C})});return g(M=>M&&{...M,config:{...M.config,...R.config}}),y("Scoutbot preferred model updated",R.config.model,"scoutbot"),R.config.model},[y]),re=o.useMemo(()=>({enabled:r,open:s,state:c,leaseId:f,error:w,trace:P,chatState:u,sessionAction:S,setOpen:a,startCall:Z,endCall:D,startNewChat:ee,switchChat:te,updatePreferredModel:ne,clearTrace:m,openVoiceSettings:Y}),[r,s,c,f,w,P,u,S,Z,D,ee,te,ne,m,Y]);return i.jsx(ze.Provider,{value:re,children:e})}function kn(e){return(e instanceof DOMException||e instanceof Error)&&e.name==="AbortError"}function vr(){return o.useContext(ze)}function En(e){return e.type==="navigate"?"Navigation requested":e.type==="open-scoutbot"?"Scoutbot opened its panel":e.type==="refresh"?"Scoutbot refreshed live state":"Scoutbot opened the requested file"}function xn(e){return e.type==="navigate"?JSON.stringify(e.route):e.type==="view-file"?e.path:e.reason?.trim()||e.type}async function An(e,t,n){t("Scoutbot is coordinating",`Asking ${e.targetLabel}`,"agent");try{const r=await $("/api/scoutbot/actions/ask",{method:"POST",body:JSON.stringify({targetLabel:e.targetLabel,targetAgentId:e.targetAgentId,body:e.body,channel:e.channel})});return t("Scoutbot sent the request",r.flightId?`${r.targetAgentId??r.targetLabel} · run ${r.flightId}`:r.targetAgentId??r.targetLabel,"agent"),!0}catch(r){const s=r instanceof Error?r.message:"Could not send to agent.";return t("Scoutbot could not send the request",s,"error"),n(s),!1}}function ge(e,t){const n=t?.trim();n&&e.add(n)}function Tn(e,t){const n=new Set;return ge(n,e.authorityNodeId),ge(n,e.homeNodeId),n.size===0&&ge(n,t),n}function Ge(e,t,n){return t?Tn(e,n).has(t):!0}function Rn(e,t,n){return t?e.filter(r=>Ge(r,t,n)):e}function gr(e,t,n){return t?new Set(e.filter(r=>Ge(r,t,n)).map(r=>r.id)):null}function G(e,t,n){return!t&&!n||n&&e.authorityNodeId===n?!0:t?e.agentId&&t.has(e.agentId)||e.actorId&&t.has(e.actorId)||e.ownerId&&t.has(e.ownerId)||e.nextMoveOwnerId&&t.has(e.nextMoveOwnerId)?!0:!!e.participantIds?.some(r=>t.has(r)):!1}function In(e,t,n){return G(e,t,n)}function wr(e,t,n){return!t&&!n?e:e.filter(r=>In(r,t,n))}function Nn(e,t){return G(e,t)}function On(e,t){return t?e.filter(n=>Nn(n,t)):e}function De(e,t){return G(e,t)}function br(e,t){if(!e||!t)return e;const n=e.activeAsks.filter(c=>G(c,t)),r=e.recentCompleted.filter(c=>G(c,t)),s=e.needsAttention.filter(c=>G(c,t)),a=On(e.activity,t);return{...e,totals:{active:n.length,recentCompleted:r.length,needsAttention:s.length,activity:a.length},activeAsks:n,recentCompleted:r,needsAttention:s,activity:a}}function yr(e,t){if(!t)return e;const n=e.activeFlights.filter(a=>G(a,t)),r=e.childWork.filter(a=>De(a,t));return De(e,t)||n.length>0||r.length>0?{...e,activeFlights:n,childWork:r}:null}function _n(e){return!!(e&&(e.message.trim().length>0||e.files.length>0||e.forwardContext))}function Ln(e){return[e.name,e.type,e.size,e.lastModified].join(":")}function jn(e,t){const n=new Set;return[...e,...t].filter(r=>{const s=Ln(r);return n.has(s)?!1:(n.add(s),!0)})}function Dn(e,t){const n=t.intent??e?.intent??"new-task",r=n==="route-capture",s=n==="forward-message";return{intent:n,...r&&(t.agentId??e?.agentId)?{agentId:t.agentId??e?.agentId}:{},...r&&(t.conversationId??e?.conversationId)?{conversationId:t.conversationId??e?.conversationId}:{},message:t.message??e?.message??"",files:jn(e?.files??[],t.files??[]),attachmentFeedback:t.attachmentFeedback??e?.attachmentFeedback??null,mode:r?t.preferExistingChat===void 0?e?.mode??"new-session":t.preferExistingChat?"existing-chat":"new-session":"new-session",projectPath:t.projectPath??e?.projectPath??"",projectQuery:e?.projectQuery??"",...s&&(t.forwardContext??e?.forwardContext)?{forwardContext:t.forwardContext??e?.forwardContext}:{},forwardContextMode:s?t.forwardContextMode??e?.forwardContextMode??"selected-message":"selected-message"}}function Pn({request:e,onClose:t,onOpenCapture:n}){const{agents:r,route:s,navigate:a}=Qe(),c=ot(s),p=Rn(r,c),f=kt(s,p),[A,w]=o.useState(0),[T,P]=o.useState(null),[j,u]=o.useState(null),g=o.useRef(0),S=e?Dn(j,e):null,O=o.useCallback((E,_)=>{if(E.length===0)return;const I=!!(f.agentId||f.conversationId);n({intent:I?"route-capture":"new-task",files:E,attachmentFeedback:_,agentId:f.agentId??void 0,conversationId:f.conversationId??void 0,preferExistingChat:f.canUseExistingChat})},[n,f]);o.useEffect(()=>{if(!T)return;const E=window.setTimeout(()=>P(null),5e3);return()=>window.clearTimeout(E)},[T]),o.useEffect(()=>{const E=b=>{pe(b.dataTransfer)&&(b.preventDefault(),g.current+=1,w(g.current))},_=b=>{pe(b.dataTransfer)&&(b.preventDefault(),b.dataTransfer&&(b.dataTransfer.dropEffect="copy"))},I=()=>{g.current!==0&&(g.current=Math.max(0,g.current-1),w(g.current))},d=b=>{if(!pe(b.dataTransfer))return;b.preventDefault();const y=Ne(b.dataTransfer),m=y.filter(Oe),L=y.length-m.length;if(g.current=0,w(0),m.length===0){P(y.length===0?"Scout could not read that file. Try the attachment picker instead.":"That file type is not supported. Drop markdown, code, an image, or a video clip.");return}const D=m.length===1?`Dropped ${m[0]?.name||"1 attachment"}.`:`Dropped ${m.length} attachments.`,V=L>0?`${D} Skipped ${L} unsupported ${L===1?"file":"files"}.`:D;P(null),O(m,V)},h=b=>{if(Ct(b.target)||!pe(b.clipboardData))return;b.preventDefault();const y=Ne(b.clipboardData),m=y.filter(Oe);if(m.length===0){P(y.length===0?"Scout could not read that pasted file. Try the attachment picker instead.":"That pasted file type is not supported. Paste an image or video, or attach markdown or code.");return}O(m,m.length===1?`Pasted ${m[0]?.name||"1 attachment"}.`:`Pasted ${m.length} attachments.`)};return window.addEventListener("dragenter",E),window.addEventListener("dragover",_),window.addEventListener("dragleave",I),window.addEventListener("drop",d),window.addEventListener("paste",h),()=>{window.removeEventListener("dragenter",E),window.removeEventListener("dragover",_),window.removeEventListener("dragleave",I),window.removeEventListener("drop",d),window.removeEventListener("paste",h)}},[O]);const k=A>0&&!e;return i.jsxs(i.Fragment,{children:[k?i.jsx("div",{className:"s-capture-drop",role:"presentation",children:i.jsxs("div",{className:"s-capture-drop-card",children:[i.jsx("div",{className:"s-capture-drop-title",children:"Route capture"}),i.jsx("div",{className:"s-capture-drop-copy",children:"Drop markdown, code, an image, or a video clip to send it to the right agent or chat."})]})}):null,T?i.jsx("div",{className:"s-capture-feedback",role:"alert",children:T}):null,e?i.jsx(Et,{agents:p,route:s,navigate:a,onClose:t,initialAgentId:S?.agentId,initialConversationId:S?.conversationId,initialMessage:S?.message,initialFiles:S?.files,initialAttachmentFeedback:S?.attachmentFeedback??void 0,initialIntent:S?.intent,initialProjectPath:S?.projectPath,initialProjectQuery:S?.projectQuery,initialForwardContext:S?.forwardContext,initialForwardContextMode:S?.forwardContextMode,defaultMode:S?.mode,draftRestored:_n(j),onDraftChange:u,onDraftConsumed:()=>u(null)}):null]})}const We=o.createContext(null),Mn=["hello","node.upserted","actor.registered","agent.registered","agent.endpoint.upserted","invocation.requested","flight.updated","delivery.state.changed","scout.dispatched"],Fn=new Set(Mn),Bn=3e4,Un=250;function qn(e,t){try{return JSON.stringify(e)===JSON.stringify(t)?e:t}catch{return t}}const Vn={"--hud-bg":"oklch(0.132 0.004 260)","--hud-surface":"oklch(0.178 0.005 260)","--hud-ink":"oklch(0.965 0.006 260)","--hud-muted":"oklch(0.72 0.008 260)","--hud-dim":"oklch(0.57 0.007 260)","--hud-border":"oklch(0.965 0.006 260 / 0.04)","--hud-accent":"oklch(0.86 0.17 125)","--hud-accent-soft":"oklch(0.86 0.17 125 / 0.08)","--hud-shadow-soft":"oklch(0.08 0.004 260 / 0.42)","--hud-chrome-border":"oklch(0.965 0.006 260 / 0.012)","--hud-shadow-panel":"0 12px 34px oklch(0.08 0.004 260 / 0.45)","--hud-shadow-panel-hover":"0 14px 38px oklch(0.08 0.004 260 / 0.52)","--hud-shadow-bar":"0 -10px 28px oklch(0.08 0.004 260 / 0.38)","--hud-shadow-nav":"0 8px 24px oklch(0.08 0.004 260 / 0.32)","--hud-shadow-minimap":"0 10px 24px oklch(0.08 0.004 260 / 0.38)","--hud-status-ok":"oklch(0.80 0.15 155)","--hud-status-warn":"oklch(0.82 0.15 85)","--hud-status-error":"oklch(0.72 0.18 25)","--background":"0.132 0.004 260","--foreground":"0.965 0.006 260","--card":"0.178 0.005 260","--card-foreground":"0.965 0.006 260","--popover":"0.178 0.005 260","--popover-foreground":"0.965 0.006 260","--muted-foreground":"0.72 0.008 260","--scrim":"rgba(0, 0, 0, 0.5)","--scrim-soft":"rgba(0, 0, 0, 0.3)","--info":"#62b6ff","--shadow-card":"0 8px 22px rgba(0, 0, 0, 0.22)","--shadow-card-hover":"0 14px 36px rgba(0, 0, 0, 0.30)","--cat-gold":"#d7a978","--cat-purple":"#c58cff","--cat-sky":"#38bdf8","--scout-chrome-ink-strong":"color-mix(in srgb, var(--hud-ink) 92%, transparent)","--scout-chrome-ink":"color-mix(in srgb, var(--hud-ink) 78%, transparent)","--scout-chrome-ink-soft":"color-mix(in srgb, var(--hud-ink) 58%, transparent)","--scout-chrome-ink-faint":"color-mix(in srgb, var(--hud-ink) 55%, transparent)","--scout-chrome-ink-ghost":"color-mix(in srgb, var(--hud-ink) 48%, transparent)","--scout-chrome-hover":"color-mix(in srgb, var(--hud-ink) 4%, transparent)","--scout-chrome-active":"color-mix(in srgb, var(--hud-ink) 8%, transparent)","--scout-chrome-border-soft":"color-mix(in srgb, var(--hud-ink) 4%, transparent)","--scout-chrome-avatar-ink":"#111111","--hud-font-sans":"'Inter', ui-sans-serif, system-ui, sans-serif","--hud-font-mono":"'JetBrains Mono', ui-monospace, Menlo, monospace","--hud-font-serif":"'Spectral', 'Cormorant Garamond', Georgia, serif","--hud-font-accent-title":"'Inter Tight', var(--hud-font-sans)"},Hn={"--hud-bg":"oklch(0.982 0.008 78)","--hud-surface":"oklch(0.994 0.006 78)","--hud-ink":"oklch(0.26 0.018 72)","--hud-muted":"oklch(0.50 0.028 70)","--hud-dim":"oklch(0.64 0.022 72)","--hud-border":"oklch(0.86 0.016 75 / 0.92)","--hud-accent":"oklch(0.72 0.16 125)","--hud-accent-soft":"oklch(0.72 0.16 125 / 0.11)","--hud-shadow-soft":"oklch(0.42 0.02 70 / 0.11)","--hud-status-ok":"oklch(0.64 0.16 155)","--hud-status-warn":"oklch(0.72 0.15 85)","--hud-status-error":"oklch(0.62 0.19 25)","--background":"0.978 0.004 85","--foreground":"0.24 0.01 80","--card":"0.992 0.003 85","--card-foreground":"0.24 0.01 80","--popover":"0.992 0.003 85","--popover-foreground":"0.24 0.01 80","--muted-foreground":"0.56 0.014 80","--scrim":"rgba(28, 24, 20, 0.30)","--scrim-soft":"rgba(28, 24, 20, 0.16)","--info":"#2f7fd6","--shadow-card":"0 8px 22px oklch(0.42 0.02 70 / 0.09)","--shadow-card-hover":"0 14px 36px oklch(0.42 0.02 70 / 0.13)","--cat-gold":"#a9824f","--cat-purple":"#8b5cf6","--cat-sky":"#0ea5e9","--scout-chrome-ink-strong":"color-mix(in srgb, var(--hud-ink) 94%, transparent)","--scout-chrome-ink":"color-mix(in srgb, var(--hud-ink) 78%, transparent)","--scout-chrome-ink-soft":"color-mix(in srgb, var(--hud-ink) 60%, transparent)","--scout-chrome-ink-faint":"color-mix(in srgb, var(--hud-ink) 56%, transparent)","--scout-chrome-ink-ghost":"color-mix(in srgb, var(--hud-ink) 50%, transparent)","--scout-chrome-hover":"color-mix(in srgb, var(--hud-ink) 4%, transparent)","--scout-chrome-active":"color-mix(in srgb, var(--hud-ink) 8%, transparent)","--scout-chrome-border-soft":"color-mix(in srgb, var(--hud-border) 80%, transparent)","--scout-chrome-avatar-ink":"#ffffff","--hud-font-sans":"'Inter', ui-sans-serif, system-ui, sans-serif","--hud-font-mono":"'JetBrains Mono', ui-monospace, Menlo, monospace","--hud-font-serif":"'Spectral', 'Cormorant Garamond', Georgia, serif","--hud-font-accent-title":"'Inter Tight', var(--hud-font-sans)"},$n=new Set(["--hud-bg","--hud-surface","--hud-ink","--hud-muted","--hud-dim","--hud-border","--hud-accent","--hud-accent-soft","--hud-shadow-soft","--hud-chrome-border","--hud-shadow-panel","--hud-shadow-panel-hover","--hud-shadow-bar","--hud-shadow-nav","--hud-shadow-minimap","--hud-status-ok","--hud-status-warn","--hud-status-error"]);function Jn(e){return Object.fromEntries(Object.entries(e==="light"?Hn:Vn).filter(([n])=>!$n.has(n)))}function Qe(){const e=o.useContext(We);if(!e)throw new Error("useScout must be used inside ScoutProvider");return e}function Sr({children:e,initialTheme:t="dark"}){const{route:n,navigate:r,navigateBack:s,canNavigateBack:a}=st(),c=xt(),p=Pe(Je,!1),[f,A]=o.useState([]),[w,T]=o.useState(!1),[P,j]=o.useState({status:"checking",message:null,lastCheckedAt:null}),[u,g]=o.useState(Te),[S,O]=o.useState(null),[k,E]=o.useState(!1),[_,I]=o.useState(null),[d,h]=o.useState(null),[b,y]=o.useState(""),[m,L]=o.useState(null),D=n.view==="settings",V=o.useMemo(()=>n.view!=="broker"||!n.attemptId?null:_?.id===n.attemptId?_:null,[_,n]),Y=o.useMemo(()=>n.view!=="search"||!n.hitId?null:d?.id===n.hitId?d:null,[d,n]),Z=o.useMemo(()=>n.view==="agents-v2"&&n.agentId&&n.sessionId?{agentId:n.agentId,sessionId:n.sessionId}:n.view==="sessions"&&n.sessionId?{agentId:n.agentId??"",sessionId:n.sessionId}:null,[n]),ee=o.useCallback((l,x)=>{if(n.view==="agents-v2"&&n.agentId===l){r({...n,sessionId:x},{replace:!0});return}if(n.view==="sessions"){r({view:"sessions",sessionId:x,agentId:l},{replace:!0});return}r({view:"agents-v2",agentId:l,sessionId:x},{replace:!0})},[r,n]),te=o.useCallback(()=>{r({view:"settings",section:"appearance"})},[r]),ne=o.useCallback(()=>{n.view==="settings"&&r({view:"inbox"})},[r,n.view]),re=o.useCallback(l=>{L(l??{intent:"new-task"})},[]),v=o.useCallback(()=>L(null),[]),C=o.useCallback(l=>{I(l),!(n.view==="broker"&&n.attemptId===l.id)&&r({view:"broker",attemptId:l.id,...n.view==="broker"&&n.filter?{filter:n.filter}:{}},{replace:n.view==="broker"})},[r,n]),R=o.useCallback(()=>{I(null),n.view==="broker"&&n.attemptId&&r({view:"broker",...n.filter?{filter:n.filter}:{}},{replace:!0})},[r,n]),M=o.useCallback((l,x,F)=>{if(h(l),typeof x=="string"&&y(x.trim()),n.view==="search"&&n.hitId===l.id)return;const H=F??(n.view==="search"?n.filters:void 0);r({view:"search",...n.view==="search"&&n.mode?{mode:n.mode}:{},...H?{filters:H}:{},hitId:l.id},{replace:n.view==="search"})},[r,n]),K=o.useCallback(()=>{h(null),y(""),n.view==="search"&&n.hitId&&r({view:"search",...n.mode?{mode:n.mode}:{},...n.filters?{filters:n.filters}:{}},{replace:!0})},[r,n]),B=o.useMemo(()=>et(),[]),N=c?.resolvedTheme??t,U=c?.template??"hudson",q=o.useMemo(()=>({...Jn(N),...B??{}}),[B,N]),ae=o.useCallback(l=>{g(x=>({...x,...l}))},[]);o.useEffect(()=>{tt(N,U,u),nt(u)},[U,u,N]),o.useEffect(()=>{const l=x=>{x.key!==null&&x.key!==rt||g(Te())};return window.addEventListener("storage",l),()=>window.removeEventListener("storage",l)},[]);const ye=o.useMemo(()=>ut(f),[f]),Se=ye?.id??dt(f),Ce=ye?.conversationId??null,ce=o.useRef(null),W=o.useRef(null),le=n.view==="ops"?"/api/agents":"/api/agents?detail=summary",ue=o.useCallback(()=>{j({status:"online",message:null,lastCheckedAt:Date.now()})},[]),de=o.useCallback(l=>{const x=At(l);j({status:Tt(x)?"offline":"degraded",message:x,lastCheckedAt:Date.now()})},[]),J=o.useCallback(async()=>{const l=ce.current;if(l&&(await l.promise,l.url===le))return;const x=(async()=>{try{const F=await $(le);A(H=>qn(H,F)),ue()}catch(F){de(F)}finally{T(!0)}})();ce.current={url:le,promise:x};try{await x}finally{ce.current?.promise===x&&(ce.current=null)}},[le,de,ue]),Q=o.useCallback(async()=>{try{const l=await $("/api/onboarding/state");O(l),ue()}catch(l){de(l),O({hasLocalConfig:!0,hasProjectConfig:!0,hasOperatorName:!0,localConfigPath:null,projectRoot:null,currentDirectory:null,operatorName:null,operatorNameSuggestion:null})}},[de,ue]),ke=o.useCallback(()=>{E(!0),$("/api/onboarding/skip",{method:"POST",body:"{}"}).then(()=>Q()).catch(()=>null)},[Q]);o.useEffect(()=>{J(),Q()},[J,Q]),o.useEffect(()=>{const l=()=>{Re()&&J()},x=window.setInterval(l,Bn),F=at(l);return()=>{window.clearInterval(x),F()}},[J]);const Ee=o.useMemo(()=>f.filter(l=>ct(l.state)).length,[f]),[Xe,xe]=o.useState(null),oe=o.useCallback(l=>{l?.trim()&&xe(l.trim())},[]),se=o.useCallback(()=>xe(null),[]),X=o.useCallback(l=>{if(!ft(l))switch(l.type){case"navigate":r(l.route);break;case"focus-composer":window.dispatchEvent(new CustomEvent("scout:composer-focus"));break;case"open-scoutbot":window.dispatchEvent(new CustomEvent("scout:scoutbot-panel-open",{detail:l}));break;case"refresh":J();break;case"view-file":oe(l.path);break}},[r,oe,J]),Ye=o.useCallback((l,x)=>{const F=l.trim(),H=x.trim();if(!F||!H)return;const Ae=n.view==="conversation"||n.view==="messages"?n.conversationId:window.location.pathname==="/embed/thread"&&new URLSearchParams(window.location.search).get("conversationId")?.trim()||void 0;se(),X({type:"navigate",route:{view:"code",root:H,file:F,...Ae?{returnConversationId:Ae}:{}}})},[X,se,n]),fe=o.useRef({applyScoutbotUiAction:X});fe.current={applyScoutbotUiAction:X},it(l=>{Re()&&Fn.has(l.kind)&&(W.current!==null&&window.clearTimeout(W.current),W.current=window.setTimeout(()=>{W.current=null,J()},Un))}),o.useEffect(()=>()=>{W.current!==null&&window.clearTimeout(W.current)},[]),o.useEffect(()=>{const l=x=>{const F=x.detail,H=F&&typeof F=="object"&&"type"in F?F:null;H&&fe.current.applyScoutbotUiAction(H)};return window.addEventListener("scout:scoutbot-ui-action",l),window.scoutScoutbot={applyUiAction:x=>fe.current.applyScoutbotUiAction(x),navigate:x=>fe.current.applyScoutbotUiAction({type:"navigate",route:x})},()=>{window.removeEventListener("scout:scoutbot-ui-action",l),window.scoutScoutbot?.applyUiAction&&delete window.scoutScoutbot}},[]);const Ze=o.useMemo(()=>({route:n,navigate:r,navigateBack:s,canNavigateBack:a,agents:f,agentsLoaded:w,onlineCount:Ee,apiConnection:P,reload:J,appearanceDetails:u,updateAppearanceDetails:ae,onboarding:S,refreshOnboarding:Q,onboardingSkipped:k,skipOnboarding:ke,settingsOpen:D,openSettings:te,closeSettings:ne,scoutbotAgentId:Se,scoutbotConversationId:Ce,applyScoutbotUiAction:X,selectedBrokerAttempt:V,inspectBrokerAttempt:C,clearBrokerAttempt:R,selectedKnowledgeHit:Y,selectedKnowledgeQuery:b,inspectKnowledgeHit:M,clearKnowledgeHit:K,focusedSession:Z,focusSession:ee,openFilePreview:oe,closeFilePreview:se,openContextCapture:re,closeContextCapture:v}),[n,r,s,a,f,w,Ee,P,J,u,ae,S,Q,k,ke,D,te,ne,Se,Ce,X,V,C,R,Y,b,M,K,Z,ee,oe,se,re,v]);return i.jsx(We.Provider,{value:Ze,children:i.jsx("div",{"data-scout-theme-mode":N,"data-scout-palette":u.palette,"data-scout-contrast":u.contrast,"data-scout-accent":u.accent,"data-scout-shell":u.shell,"data-hudson-theme":N,"data-hudson-template":U,style:{...q},children:i.jsx("div",{"data-scout-theme":N,style:{display:"contents"},children:i.jsx(pt,{children:i.jsxs(Wt,{children:[p?i.jsx(Cn,{children:e}):e,i.jsx($t,{path:Xe,onOpenPath:oe,onOpenInCode:Ye,onClose:se}),i.jsx(Pn,{request:m,onClose:v,onOpenCapture:re})]})})})})})}export{Nt as A,_t as C,Vn as D,Hn as L,We as S,Je as a,vr as b,mr as c,On as d,Rn as e,At as f,wr as g,br as h,Tt as i,pr as j,Sr as k,yr as l,gr as m,hr as n,me as o,yn as p,bn as s,Qe as u};
@@ -1 +1 @@
1
- import{j as r}from"./index-sUomXsrf.js";import{n as x,a as M,s as v,b as S}from"./colors-BtO5_zlx.js";import{A as m}from"./AgentAvatar-CufDA4A-.js";function T({state:n,className:e,style:s}){x(typeof n=="string"?n:n??null);const a=x(typeof n=="string"?n:n??null)!=="blocked"?M(typeof n=="string"?n:n??null)?"working":"available":null;return r.jsx("span",{className:e,style:{background:v(a),...s}})}function F({name:n,meta:e,sub:s,tone:a="neutral",avatarName:c,avatarKind:o="user",leadingIcon:i,caret:l,active:f,selected:g,unread:N,depth:k=0,detail:t,expanded:d,activityLabel:h,worktreeLabel:p,activityTone:y="working",actions:u,pinned:w,onClick:b,onKeyDown:C,onContextMenu:A,onPointerEnter:P,onPointerLeave:B,title:R,tabIndex:$}){const z=l?l==="open":t!==void 0?!!d:void 0,L=["rr-row",k===1&&"rr-row--child",f&&"rr-row--active",g&&"rr-row--selected",N&&"rr-row--unread",d&&"rr-row--expanded",h&&"rr-row--motion",w&&"rr-row--pinned",u&&"rr-row--has-actions"].filter(Boolean).join(" ");return r.jsxs("div",{className:L,children:[r.jsxs("button",{type:"button",className:"rr-row-head",onClick:b,onKeyDown:C,onContextMenu:A,onPointerEnter:P,onPointerLeave:B,title:R,tabIndex:$,"aria-expanded":z,children:[r.jsx(D,{icon:i,tone:a,caret:l,avatarName:c,avatarKind:o}),r.jsxs("span",{className:"rr-row-body",children:[r.jsxs("span",{className:"rr-row-name",children:[w?r.jsx("span",{className:"rr-row-pin-mark","aria-label":"Pinned",title:"Pinned",children:r.jsx(I,{})}):null,n]}),s&&r.jsx("span",{className:"rr-row-sub",children:s}),p&&r.jsx("span",{className:"rr-row-worktree",children:p}),h&&r.jsxs("span",{className:`rr-row-activity rr-row-activity--${y}`,children:[r.jsxs("span",{className:"rr-row-activity-bars","aria-hidden":!0,children:[r.jsx("span",{}),r.jsx("span",{}),r.jsx("span",{}),r.jsx("span",{})]}),r.jsx("span",{className:"rr-row-activity-label",children:h})]})]}),e&&r.jsx("span",{className:"rr-row-meta",children:e})]}),u?r.jsx("div",{className:"rr-row-actions",onClick:E=>E.stopPropagation(),children:u}):null,d&&t&&r.jsx("div",{className:"rr-row-detail",children:t})]})}function D({icon:n,tone:e,caret:s,avatarName:a,avatarKind:c}){if(s)return r.jsx("span",{className:`rr-row-caret rr-row-caret--leading rr-row-caret--${s}`,"aria-hidden":!0,children:r.jsx(G,{open:s==="open"})});if(a){if(c==="channel")return r.jsx(m,{kind:"channel",name:a,channelClassName:"rr-row-hash"});const i=j(e),l=i==="active"||i==="available";return r.jsxs("span",{className:"rr-row-avatar-wrap","aria-hidden":!0,children:[r.jsx(m,{name:a,placement:"roster",className:"rr-row-avatar"}),l&&r.jsx(T,{state:i,className:`rr-row-presence rr-row-presence--${i}`})]})}if(n)return r.jsx("span",{className:"rr-row-icon","aria-hidden":!0,children:n});const o=j(e);return r.jsx("span",{className:`rr-row-dot rr-row-dot--${o}`,style:o==="active"||o==="available"?{background:v(o)}:void 0,"aria-hidden":!0})}function G({open:n}){return r.jsx("svg",{className:`rr-chevron${n?" rr-chevron--open":""}`,viewBox:"0 0 12 12",width:"12",height:"12",fill:"none","aria-hidden":!0,children:r.jsx("path",{d:"M4.25 3L7.75 6L4.25 9",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function j(n){return n==="channel"||n==="dm"||n==="neutral"?n:S(n)}function I(){return r.jsx("svg",{width:"9",height:"9",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":!0,children:r.jsx("path",{d:"M9.8 1.6 14.4 6.2a1 1 0 0 1-.2 1.6l-2.7 1.1-.9 3.4a.7.7 0 0 1-1.2.3L6.3 9.5 2.8 13 1.7 11.9l3.5-3.5L2.1 5.3a.7.7 0 0 1 .3-1.2l3.4-.9 1.1-2.7a1 1 0 0 1 1.6-.2Z"})})}export{F as R};
1
+ import{j as r}from"./index-o4FKpU7Z.js";import{n as x,a as M,s as v,b as S}from"./colors-BtO5_zlx.js";import{A as m}from"./AgentAvatar-DMov24_o.js";function T({state:n,className:e,style:s}){x(typeof n=="string"?n:n??null);const a=x(typeof n=="string"?n:n??null)!=="blocked"?M(typeof n=="string"?n:n??null)?"working":"available":null;return r.jsx("span",{className:e,style:{background:v(a),...s}})}function F({name:n,meta:e,sub:s,tone:a="neutral",avatarName:c,avatarKind:o="user",leadingIcon:i,caret:l,active:f,selected:g,unread:N,depth:k=0,detail:t,expanded:d,activityLabel:h,worktreeLabel:p,activityTone:y="working",actions:u,pinned:w,onClick:b,onKeyDown:C,onContextMenu:A,onPointerEnter:P,onPointerLeave:B,title:R,tabIndex:$}){const z=l?l==="open":t!==void 0?!!d:void 0,L=["rr-row",k===1&&"rr-row--child",f&&"rr-row--active",g&&"rr-row--selected",N&&"rr-row--unread",d&&"rr-row--expanded",h&&"rr-row--motion",w&&"rr-row--pinned",u&&"rr-row--has-actions"].filter(Boolean).join(" ");return r.jsxs("div",{className:L,children:[r.jsxs("button",{type:"button",className:"rr-row-head",onClick:b,onKeyDown:C,onContextMenu:A,onPointerEnter:P,onPointerLeave:B,title:R,tabIndex:$,"aria-expanded":z,children:[r.jsx(D,{icon:i,tone:a,caret:l,avatarName:c,avatarKind:o}),r.jsxs("span",{className:"rr-row-body",children:[r.jsxs("span",{className:"rr-row-name",children:[w?r.jsx("span",{className:"rr-row-pin-mark","aria-label":"Pinned",title:"Pinned",children:r.jsx(I,{})}):null,n]}),s&&r.jsx("span",{className:"rr-row-sub",children:s}),p&&r.jsx("span",{className:"rr-row-worktree",children:p}),h&&r.jsxs("span",{className:`rr-row-activity rr-row-activity--${y}`,children:[r.jsxs("span",{className:"rr-row-activity-bars","aria-hidden":!0,children:[r.jsx("span",{}),r.jsx("span",{}),r.jsx("span",{}),r.jsx("span",{})]}),r.jsx("span",{className:"rr-row-activity-label",children:h})]})]}),e&&r.jsx("span",{className:"rr-row-meta",children:e})]}),u?r.jsx("div",{className:"rr-row-actions",onClick:E=>E.stopPropagation(),children:u}):null,d&&t&&r.jsx("div",{className:"rr-row-detail",children:t})]})}function D({icon:n,tone:e,caret:s,avatarName:a,avatarKind:c}){if(s)return r.jsx("span",{className:`rr-row-caret rr-row-caret--leading rr-row-caret--${s}`,"aria-hidden":!0,children:r.jsx(G,{open:s==="open"})});if(a){if(c==="channel")return r.jsx(m,{kind:"channel",name:a,channelClassName:"rr-row-hash"});const i=j(e),l=i==="active"||i==="available";return r.jsxs("span",{className:"rr-row-avatar-wrap","aria-hidden":!0,children:[r.jsx(m,{name:a,placement:"roster",className:"rr-row-avatar"}),l&&r.jsx(T,{state:i,className:`rr-row-presence rr-row-presence--${i}`})]})}if(n)return r.jsx("span",{className:"rr-row-icon","aria-hidden":!0,children:n});const o=j(e);return r.jsx("span",{className:`rr-row-dot rr-row-dot--${o}`,style:o==="active"||o==="available"?{background:v(o)}:void 0,"aria-hidden":!0})}function G({open:n}){return r.jsx("svg",{className:`rr-chevron${n?" rr-chevron--open":""}`,viewBox:"0 0 12 12",width:"12",height:"12",fill:"none","aria-hidden":!0,children:r.jsx("path",{d:"M4.25 3L7.75 6L4.25 9",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function j(n){return n==="channel"||n==="dm"||n==="neutral"?n:S(n)}function I(){return r.jsx("svg",{width:"9",height:"9",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":!0,children:r.jsx("path",{d:"M9.8 1.6 14.4 6.2a1 1 0 0 1-.2 1.6l-2.7 1.1-.9 3.4a.7.7 0 0 1-1.2.3L6.3 9.5 2.8 13 1.7 11.9l3.5-3.5L2.1 5.3a.7.7 0 0 1 .3-1.2l3.4-.9 1.1-2.7a1 1 0 0 1 1.6-.2Z"})})}export{F as R};
@@ -0,0 +1 @@
1
+ import{r as o,j as n}from"./index-o4FKpU7Z.js";/* empty css */import{D as O}from"./DataTable-CGw5CECG.js";import{p as W,a as L}from"./api-h5zurxmi.js";import{t as U,n as R,f as Y}from"./time-Dhsh_2EG.js";import{u as G}from"./tail-events-NLIWLq27.js";import{o as Q}from"./openContent-C6XO6kr5.js";import{u as X}from"./Provider-DKZWuzSR.js";/* empty css */import"./index-BWHgHrtv.js";import"./provider-BvAxRQfE.js";import"./router-C65cZYPn.js";import"./synthetic-agent-routing-aduMYO7P.js";import"./terminal-sessions-AmSgHklm.js";import"./sse-CL6gctHY.js";import"./surface-activity-B1rgWB1i.js";import"./colors-BtO5_zlx.js";import"./scoutbot-BTIErYHo.js";import"./ContextMenu-CxkmFQcN.js";import"./DocumentFocusViewer-DRKjNG9s.js";import"./createLucideIcon-Bt67PWH-.js";import"./TextDocumentSurface-Bc-kHPgG.js";/* empty css */import"./file-text-iF0hyVyU.js";import"./x-ynOfVadO.js";import"./chevron-right-C10o7t_X.js";import"./code-xml-CLn3TDWF.js";import"./arrow-left-BOht-YQu.js";import"./scout-voice-B7kXlkcl.js";import"./fx-z37u1o2z.js";import"./keyboard-nav-Chf51dns.js";import"./MessageComposerSuggestions-Dfc3PH2y.js";import"./NewChatComposer-S08F6_La.js";import"./runtime-picker-eDEvx2Mz.js";import"./voice-levels-Dcr3jglk.js";import"./loader-circle-4LDsy4Ke.js";import"./index-BMwKgdz_.js";import"./HarnessMark-MztYnrGK.js";import"./conversation-model-CHwHZNw-.js";import"./NewChatOrigin-BEz6jyqf.js";import"./model-Co0zkMIc.js";import"./text-DsBWV_4k.js";import"./chevron-down-NAhBUkFd.js";import"./search-7_n7CxWl.js";import"./chunk-HRAB3GC3-DF8R9rPv.js";const q=1e4,J=500,$=1e3,Z=6e4,D="/api/tail/discover",_=`/api/tail/recent?limit=${J}`,P=3e4,tt=[{key:"status",label:"status",cls:"s-atop-col-status",kind:"text",sortable:!1,defaultWidth:96,minWidth:70,render:t=>n.jsxs("span",{className:`s-atop-status s-atop-status--${t.status}`,children:[n.jsx("span",{className:"s-atop-status-dot","aria-hidden":"true"}),t.statusLabel]})},{key:"session",label:"session",cls:"s-atop-col-agent",kind:"text",sortable:!1,defaultWidth:168,minWidth:110,maxWidth:280,render:t=>n.jsxs("div",{className:"s-atop-agent-cell",title:t.sessionId??t.refId,children:[n.jsx("span",{className:`s-atop-chip s-atop-chip--harness s-atop-chip--harness-${st(t.source)}`,children:t.source}),n.jsx("span",{className:"s-atop-agent-id",children:t.refId.slice(0,8)})]})},{key:"project",label:"project",cls:"s-atop-col-project",kind:"text",sortable:!1,defaultWidth:200,minWidth:96,maxWidth:360,render:t=>n.jsx("span",{title:t.cwd??t.project,children:t.project})},{key:"updated",label:"updated",cls:"s-atop-col-last",kind:"time",sortable:!1,defaultWidth:86,minWidth:64,render:t=>n.jsx("span",{title:Y(t.mtimeMs),children:U(Math.max(R(t.mtimeMs)??0,R(t.lastEvent?.ts)??0))||"-"})},{key:"size",label:"size",cls:"s-atop-col-runtime",kind:"number",sortable:!1,defaultWidth:80,minWidth:64,render:t=>nt(t.size)},{key:"path",label:"path",kind:"text",sortable:!1,defaultWidth:360,minWidth:160,maxWidth:800,render:t=>n.jsx("span",{title:t.transcriptPath,children:t.cwd??t.transcriptPath})}];function z(t){const i=t?.trim();if(!i)return null;const r=F(i);return r.endsWith(".jsonl")?r.slice(0,-6):r}function F(t){const i=t.replace(/[\\/]+$/,"");return i.split(/[\\/]/).filter(Boolean).at(-1)??i}function et(t){const r=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return r.pop(),r.at(-1)??""}function st(t){return t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function nt(t){if(!Number.isFinite(t)||t<0)return"-";if(t<1024)return`${t} B`;const i=t/1024;if(i<1024)return`${i.toFixed(i>=10?0:1)} KiB`;const r=i/1024;return`${r.toFixed(r>=10?0:1)} MiB`}function at(t,i){return i?[t.refId,t.sessionId??"",t.source,t.project,t.cwd??"",t.transcriptPath,t.lastEvent?.summary??"",t.process?.command??""].join(" ").toLowerCase().includes(i.toLowerCase()):!0}function B(t){return`${t.source}\0${t.cwd??""}`}function ot(t){return`${t.source}\0${t.cwd??""}`}function it(t,i,r){if(!t?.transcripts?.length)return[];const d=new Map;for(const s of i){const l=d.get(s.sessionId);(!l||s.ts>l.ts)&&d.set(s.sessionId,s)}const h=new Map;for(const s of t.processes){if(!s.cwd)continue;const l=h.get(B(s));(!l||s.pid<l.pid)&&h.set(B(s),s)}return t.transcripts.map(s=>{const l=z(s.sessionId)??z(s.transcriptPath);if(!l)return null;const u=s.sessionId?d.get(s.sessionId)??null:null,x=h.get(ot(s))??null,m=Math.max(s.mtimeMs,u?.ts??0),j=!!x||r-m<=Z,p=s.project?.trim()||(s.cwd?F(s.cwd):et(s.transcriptPath))||"unknown";return{refId:l,source:s.source||"unknown",project:p,cwd:s.cwd,transcriptPath:s.transcriptPath,sessionId:s.sessionId,mtimeMs:s.mtimeMs,size:s.size,status:j?"run":"idle",statusLabel:j?"active":"idle",lastEvent:u,process:x}}).filter(s=>s!==null).sort((s,l)=>{const u=Math.max(s.mtimeMs,s.lastEvent?.ts??0);return Math.max(l.mtimeMs,l.lastEvent?.ts??0)-u||s.project.localeCompare(l.project)})}function Jt({navigate:t}){const{route:i}=X(),[r]=o.useState(()=>W(D,P)),[d,h]=o.useState(r),[s,l]=o.useState(()=>W(_,P)?.events??[]),[u,x]=o.useState(r===null),[m,j]=o.useState(""),[p,S]=o.useState("all"),[y,k]=o.useState(0),[N,C]=o.useState(null),[T,V]=o.useState(Date.now()),b=o.useRef(null),I=o.useCallback(async()=>{C(null);try{h(await L(D))}catch(e){C(e instanceof Error?e.message:String(e))}finally{x(!1)}},[]);o.useEffect(()=>{I();const e=setInterval(()=>{I()},q);return()=>clearInterval(e)},[I]),o.useEffect(()=>{let e=!1;return(async()=>{try{const a=await L(_);e||l(a.events??[])}catch{}})(),()=>{e=!0}},[]),G(e=>{l(a=>a.length>=$?[...a.slice(a.length-$+1),e]:[...a,e])}),o.useEffect(()=>{const e=setInterval(()=>V(Date.now()),15e3);return()=>clearInterval(e)},[]);const f=o.useMemo(()=>it(d,s,T),[d,s,T]),H=o.useMemo(()=>[...new Set(f.map(e=>e.source))].sort(),[f]),c=o.useMemo(()=>f.filter(e=>(p==="all"||e.source===p)&&at(e,m.trim())),[f,p,m]);o.useEffect(()=>{y>=c.length&&k(Math.max(0,c.length-1))},[c.length,y]);const M=o.useCallback(e=>{e&&Q(t,{view:"sessions",sessionId:e.refId},{returnTo:i})},[t,i]);o.useEffect(()=>{const e=a=>{const E=a.target,A=E instanceof HTMLInputElement||E instanceof HTMLTextAreaElement||(E?.isContentEditable??!1);if(a.key==="/"&&!A){a.preventDefault(),b.current?.focus();return}if(A){a.key==="Escape"&&E===b.current&&(j(""),b.current?.blur());return}if(a.key==="ArrowDown"||a.key==="j"){a.preventDefault(),k(w=>c.length===0?0:Math.min(c.length-1,w+1));return}if(a.key==="ArrowUp"||a.key==="k"){a.preventDefault(),k(w=>Math.max(0,w-1));return}(a.key==="Enter"||a.key==="o")&&(a.preventDefault(),M(c[y]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[c,y,M]);const K=N?[]:c,g=o.useCallback(e=>`${e.source}:${e.transcriptPath}`,[]),v=o.useMemo(()=>new Map(c.map((e,a)=>[g(e),a])),[c,g]);return n.jsxs("div",{className:"s-atop s-atop--sessions",children:[n.jsxs("div",{className:"s-atop-fbar",children:[n.jsxs("label",{className:"s-atop-search",children:[n.jsx("span",{className:"s-atop-search-prompt",children:"/"}),n.jsx("input",{ref:b,className:"s-atop-search-input",placeholder:"filter sessions",value:m,onChange:e=>j(e.target.value)}),n.jsx("kbd",{className:"s-atop-search-kbd",children:"/"})]}),n.jsx("span",{className:"s-atop-fbar-label",children:"source"}),n.jsxs("button",{type:"button",className:`s-atop-pill${p==="all"?" s-atop-pill--on":""}`,onClick:()=>S("all"),children:["all",n.jsx("span",{className:"s-atop-pill-ct",children:f.length})]}),H.map(e=>n.jsxs("button",{type:"button",className:`s-atop-pill${p===e?" s-atop-pill--on":""}`,onClick:()=>S(e),children:[e,n.jsx("span",{className:"s-atop-pill-ct",children:f.filter(a=>a.source===e).length})]},e)),n.jsx("div",{className:"s-atop-fbar-spacer"})]}),n.jsx(O,{rows:K,columns:tt,rowId:g,storageKey:"openscout.sessions.cols",rowBindings:e=>({onMouseEnter:()=>{const a=v.get(e);a!=null&&k(a)},onFocus:()=>{const a=v.get(e);a!=null&&k(a)}}),onRowClick:e=>M(e),rowClassName:e=>v.get(g(e))===y?"s-atop-row--selected":void 0,empty:N?{title:"Discovery failed",body:N}:{title:"No raw sessions",body:m?"No sessions match the current filter.":"No transcript sessions were discovered."},loading:u,density:"compact",className:"s-atop-data-table",ariaLabel:"Raw sessions"}),n.jsxs("div",{className:"s-atop-keys",children:[n.jsxs("span",{children:[n.jsx("kbd",{children:"/"}),"filter"]}),n.jsxs("span",{children:[n.jsx("kbd",{children:"j/k"}),"select"]}),n.jsxs("span",{children:[n.jsx("kbd",{children:"enter"}),"open"]}),n.jsx("span",{className:"s-atop-keys-spacer"}),n.jsxs("span",{className:"s-atop-keys-count",children:[n.jsx("strong",{children:c.length})," sessions"]})]})]})}export{Jt as RawSessionsTable};
@@ -0,0 +1 @@
1
+ import{j as e,r}from"./index-o4FKpU7Z.js";import{u as w}from"./provider-BvAxRQfE.js";import{a as p,b,c as g}from"./Provider-DKZWuzSR.js";import{S as j,a as E}from"./ScoutbotRealtimeVoiceCall-Br4bYVAx.js";import{d as _}from"./types-B0PlfpKc.js";import"./router-C65cZYPn.js";import"./synthetic-agent-routing-aduMYO7P.js";import"./terminal-sessions-AmSgHklm.js";import"./api-h5zurxmi.js";import"./sse-CL6gctHY.js";import"./index-BWHgHrtv.js";import"./surface-activity-B1rgWB1i.js";import"./colors-BtO5_zlx.js";import"./scoutbot-BTIErYHo.js";import"./ContextMenu-CxkmFQcN.js";import"./DocumentFocusViewer-DRKjNG9s.js";import"./createLucideIcon-Bt67PWH-.js";import"./TextDocumentSurface-Bc-kHPgG.js";/* empty css */import"./file-text-iF0hyVyU.js";import"./x-ynOfVadO.js";import"./chevron-right-C10o7t_X.js";import"./code-xml-CLn3TDWF.js";import"./arrow-left-BOht-YQu.js";import"./scout-voice-B7kXlkcl.js";import"./fx-z37u1o2z.js";import"./keyboard-nav-Chf51dns.js";import"./MessageComposerSuggestions-Dfc3PH2y.js";import"./NewChatComposer-S08F6_La.js";import"./runtime-picker-eDEvx2Mz.js";import"./voice-levels-Dcr3jglk.js";import"./loader-circle-4LDsy4Ke.js";import"./index-BMwKgdz_.js";import"./HarnessMark-MztYnrGK.js";import"./conversation-model-CHwHZNw-.js";import"./time-Dhsh_2EG.js";import"./NewChatOrigin-BEz6jyqf.js";import"./model-Co0zkMIc.js";import"./text-DsBWV_4k.js";import"./chevron-down-NAhBUkFd.js";import"./search-7_n7CxWl.js";import"./chunk-HRAB3GC3-DF8R9rPv.js";import"./radio-v7UAMZGh.js";import"./plus-C-2gTcPK.js";function N({dictationActive:t=!1,autoStart:c=!1}){const a=w(p,!1),{enabled:l,state:i,leaseId:u,startCall:f,endCall:x}=b(),h=r.useRef(!1),n=r.useRef(null),[m,S]=r.useState(()=>window.innerWidth>=720&&window.innerHeight>=520?"page":"compact"),s=window.webkit?.messageHandlers?.scoutRealtimeVoice;return r.useEffect(()=>{const o=()=>{S(window.innerWidth>=720&&window.innerHeight>=520?"page":"compact")};return o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),r.useEffect(()=>{s?.postMessage({kind:"session-state",state:i,leaseId:u})},[u,s,i]),r.useEffect(()=>{const o=()=>{if(n.current)return n.current;const d=x().finally(()=>{n.current===d&&(n.current=null)});return n.current=d,d},v=()=>{o()};return window.__scoutRealtimeVoiceStop=o,window.addEventListener(g,v),window.__scoutRealtimeVoiceStopRequested&&o(),()=>{window.removeEventListener(g,v),window.__scoutRealtimeVoiceStop===o&&delete window.__scoutRealtimeVoiceStop}},[x]),r.useEffect(()=>{!c||t||!a||!l||h.current||i!=="idle"&&i!=="ended"&&i!=="error"||(h.current=!0,f())},[c,t,a,l,f,i]),a?l?e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsx(j,{state:i,onMinimize:s?()=>s.postMessage("minimize"):void 0,onExpand:s?()=>s.postMessage(m==="page"?"restore":"expand"):void 0,layout:m}),e.jsx(E,{dictationActive:t,layout:m})]}):e.jsxs("div",{className:"flex h-full flex-col justify-center gap-2 p-4",children:[e.jsx("p",{className:"font-mono text-xs uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:"Live voice is disabled"}),e.jsx("p",{className:"text-sm leading-snug text-[var(--scout-chrome-ink-faint)]",children:"Enable realtime voice in Settings → Voice. The footer Voice control starts and manages calls."})]}):e.jsxs("div",{className:"flex h-full flex-col justify-center gap-2 p-4",children:[e.jsx("p",{className:"font-mono text-xs uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:"Live voice is off"}),e.jsxs("p",{className:"text-sm leading-snug text-[var(--scout-chrome-ink-faint)]",children:["Turn on the ",e.jsx("span",{className:"font-mono",children:p})," flag to hold live conversations with Scoutbot. Calls use the configured OpenAI API account."]})]})}function he(){const t=w(p,!1),{enabled:c,state:a}=b();return!t||!c?e.jsx(N,{}):e.jsxs("main",{className:"flex h-full min-h-0 flex-col overflow-hidden bg-[var(--scout-chrome-bg)]",children:[e.jsxs("div",{className:"border-b border-[var(--scout-chrome-border-soft)] px-6 py-5",children:[e.jsx("p",{className:"font-mono text-xs uppercase tracking-[0.14em] text-[var(--scout-chrome-ink-faint)]",children:"Scoutbot"}),e.jsx("h1",{className:"mt-1 text-3xl font-medium text-[var(--scout-chrome-ink-strong)]",children:"Live voice"}),e.jsx("p",{className:"mt-1 max-w-2xl text-xs leading-relaxed text-[var(--scout-chrome-ink-faint)]",children:"Hold a live conversation, inspect navigation attempts, and audit what Scoutbot tried without leaving the call."})]}),e.jsx("div",{className:"min-h-0 flex-1 p-5",children:e.jsxs("section",{className:"mx-auto flex h-full min-h-[26rem] w-full max-w-5xl flex-col overflow-hidden rounded-xl border border-[color-mix(in_srgb,var(--hud-ink)_11%,transparent)] bg-[color-mix(in_srgb,var(--scout-chrome-bg)_96%,black)] shadow-[0_18px_48px_rgba(0,0,0,0.24)]",children:[e.jsx(j,{state:a,layout:"page"}),e.jsx(E,{dictationActive:!1,layout:"page"})]})})]})}const ve=_({id:"voice",label:"Live voice",route:{view:"voice"},webPath:"/voice",screen:"RealtimeVoiceScreen",embed:{path:"/embed/voice",profile:"macos.voice",rootClassName:"s-voice-embed",chrome:{showSecondaryNav:!1,showPageStatusBar:!1},hosts:{macos:!0},resolveEmbedProps:t=>({dictationActive:t.get("dictationActive")==="1",autoStart:t.get("autoStart")==="1"})}});export{he as RealtimeVoicePage,N as RealtimeVoiceScreen,ve as scoutSurface};
@@ -1 +1 @@
1
- import{j as s}from"./index-sUomXsrf.js";import{R as c}from"./RepoDiffViewerLazy-C8UPk4oo.js";/* empty css */const l=["unstaged","staged","branch"];function o(e){const t=e.getAll("layer").filter(r=>l.includes(r));return t.length>0?t:void 0}function p(){const e=typeof window>"u"?new URLSearchParams:new URLSearchParams(window.location.search),t=e.get("path")?.trim()??"",r=e.getAll("file").map(i=>i.trim()).filter(Boolean),a=e.get("sessionId")?.trim()||void 0,n=e.get("agentId")?.trim()||void 0,d=e.get("include")==="all"||e.get("include")==="touched"?"all":"changed";return t?s.jsx(c,{path:t,layers:o(e),files:r,session:a||n?{sessionId:a,agentId:n,include:d}:null,className:"rd-embed"}):s.jsx("div",{className:"rd-viewer rd-embed","data-scout-theme":!0,children:s.jsx("div",{className:"rd-center",children:s.jsxs("div",{className:"rd-center-card",children:[s.jsx("div",{className:"rd-center-title",children:"No worktree path"}),s.jsxs("div",{className:"rd-center-body",children:["This embed needs a ",s.jsx("code",{children:"?path=<absolute-path>"})," query parameter."]})]})})})}export{p as RepoDiffEmbedScreen,p as default};
1
+ import{j as s}from"./index-o4FKpU7Z.js";import{R as c}from"./RepoDiffViewerLazy-BPg_JkYW.js";/* empty css */const l=["unstaged","staged","branch"];function o(e){const t=e.getAll("layer").filter(r=>l.includes(r));return t.length>0?t:void 0}function p(){const e=typeof window>"u"?new URLSearchParams:new URLSearchParams(window.location.search),t=e.get("path")?.trim()??"",r=e.getAll("file").map(i=>i.trim()).filter(Boolean),a=e.get("sessionId")?.trim()||void 0,n=e.get("agentId")?.trim()||void 0,d=e.get("include")==="all"||e.get("include")==="touched"?"all":"changed";return t?s.jsx(c,{path:t,layers:o(e),files:r,session:a||n?{sessionId:a,agentId:n,include:d}:null,className:"rd-embed"}):s.jsx("div",{className:"rd-viewer rd-embed","data-scout-theme":!0,children:s.jsx("div",{className:"rd-center",children:s.jsxs("div",{className:"rd-center-card",children:[s.jsx("div",{className:"rd-center-title",children:"No worktree path"}),s.jsxs("div",{className:"rd-center-body",children:["This embed needs a ",s.jsx("code",{children:"?path=<absolute-path>"})," query parameter."]})]})})})}export{p as RepoDiffEmbedScreen,p as default};
@@ -1 +1 @@
1
- import{j as e}from"./index-sUomXsrf.js";import{R as l}from"./RepoDiffViewerLazy-C8UPk4oo.js";/* empty css */const f=1;function m(t=typeof performance>"u"?void 0:performance){const r=(t?.getEntriesByType?.("navigation")??[]).find(i=>typeof i.type=="string");return r?r.type==="reload":t?.navigation?.type===f}function u({path:t,layers:n,files:r,sessionId:i,agentId:o,include:s,navigate:c}){const a=t.trim();if(!a)return e.jsx("div",{className:"rd-viewer",children:e.jsx("div",{className:"rd-center",children:e.jsxs("div",{className:"rd-center-card",children:[e.jsx("div",{className:"rd-center-title",children:"No worktree path"}),e.jsxs("div",{className:"rd-center-body",children:["This page needs a ",e.jsx("code",{children:"?path=<absolute-path>"})," query parameter."]})]})})});const d=[a,n?.join(",")??"",r?.join("\0")??"",i??"",o??"",s??""].join(""),p=m();return e.jsx(l,{path:a,layers:n,files:r,session:i||o?{sessionId:i,agentId:o,include:s}:null,forceInitialLoad:p,onClose:()=>c({view:"repos"})},d)}export{u as RepoDiffPageScreen,u as default};
1
+ import{j as e}from"./index-o4FKpU7Z.js";import{R as l}from"./RepoDiffViewerLazy-BPg_JkYW.js";/* empty css */const f=1;function m(t=typeof performance>"u"?void 0:performance){const r=(t?.getEntriesByType?.("navigation")??[]).find(i=>typeof i.type=="string");return r?r.type==="reload":t?.navigation?.type===f}function u({path:t,layers:n,files:r,sessionId:i,agentId:o,include:s,navigate:c}){const a=t.trim();if(!a)return e.jsx("div",{className:"rd-viewer",children:e.jsx("div",{className:"rd-center",children:e.jsxs("div",{className:"rd-center-card",children:[e.jsx("div",{className:"rd-center-title",children:"No worktree path"}),e.jsxs("div",{className:"rd-center-body",children:["This page needs a ",e.jsx("code",{children:"?path=<absolute-path>"})," query parameter."]})]})})});const d=[a,n?.join(",")??"",r?.join("\0")??"",i??"",o??"",s??""].join(""),p=m();return e.jsx(l,{path:a,layers:n,files:r,session:i||o?{sessionId:i,agentId:o,include:s}:null,forceInitialLoad:p,onClose:()=>c({view:"repos"})},d)}export{u as RepoDiffPageScreen,u as default};
@@ -1,4 +1,4 @@
1
- import{r as l,j as n}from"./index-sUomXsrf.js";import{a as X,p as Z}from"./ui-LM8pS8qE.js";/* empty css */import{a as T,s as q,l as ee,L as te,f as K,S as ne,r as se,b as re,c as _,d as ie,u as ae,V as A,C as H,D as le,e as oe}from"./usePierreRuntime-DIVunfX0.js";import{C as ce}from"./chevron-down-BFai6ZfE.js";import{C as de}from"./check-BbgHJX8u.js";import{L as ue}from"./loader-circle-lWOOKezu.js";import{S as fe}from"./send-horizontal-DDwOgEs3.js";import{c as he}from"./createLucideIcon-DlxlBfLC.js";import{C as me}from"./code-xml-05TD3uOC.js";import{X as pe}from"./x-0XjXwGqq.js";import{r as O,a as V,f as Y}from"./cache-Dr0why2k.js";import{M as xe}from"./message-square-BD-4UUdc.js";import{R as ge}from"./refresh-cw-D8PFyhUa.js";import{P as be}from"./plus-C9lTjsgd.js";import{a as B}from"./api-h5zurxmi.js";import"./chunk-HRAB3GC3-CvwpNg-G.js";const ye=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],je=he("file-code-corner",ye);function ke({snapshot:e,selectedFile:t,targets:r,targetId:s,onTargetId:i,draft:c,onDraft:f,contextItems:o,onRemoveContextItem:p,pending:a,status:d,error:g,textareaRef:$,onSubmit:S}){const[u,j]=l.useState(!1),b=l.useRef(null),w=r.find(h=>h.id===s)??null,m=w?.label??"Scout",k=r[0]?.id??null,N=t?T(t):null,I=(c.trim().length>0||o.length>0)&&!a,R=l.useMemo(()=>[...r.map(h=>({id:h.id,label:h.label,suffix:h.id===k?"best context":null})),{id:"scout",label:"Scout",suffix:null}],[k,r]);return l.useEffect(()=>{if(!u)return;const h=C=>{const D=b.current;D&&C.target instanceof Node&&D.contains(C.target)||j(!1)};return document.addEventListener("pointerdown",h),()=>document.removeEventListener("pointerdown",h)},[u]),n.jsxs("div",{className:"rd-comment",children:[o.length>0?n.jsx("div",{className:"rd-comment-context","aria-label":"Included diff context",children:o.map(h=>n.jsx(Ce,{item:h,disabled:a,onRemove:p},h.id))}):null,n.jsxs("div",{className:"rd-comment-main",children:[n.jsxs("div",{className:"rd-target-picker",ref:b,children:[n.jsxs("button",{type:"button",className:"rd-target-button",onClick:()=>j(h=>!h),onKeyDown:h=>{h.stopPropagation(),h.key==="Escape"&&j(!1)},disabled:a,"aria-label":"Diff comment target","aria-haspopup":"listbox","aria-expanded":u,title:"Diff comment target",children:[n.jsx("span",{children:m}),n.jsx(ce,{size:13,strokeWidth:2,"aria-hidden":!0})]}),u?n.jsx("div",{className:"rd-target-menu",role:"listbox","aria-label":"Diff comment target",children:R.map(h=>{const C=h.id===(w?.id??"scout");return n.jsxs("button",{type:"button",className:"rd-target-option",role:"option","aria-selected":C,onClick:()=>{i(h.id),j(!1)},children:[n.jsx("span",{className:"rd-target-option-label",children:h.label}),h.suffix?n.jsx("span",{className:"rd-target-option-suffix",children:h.suffix}):null,n.jsx("span",{className:"rd-target-option-check","aria-hidden":!0,children:C?n.jsx(de,{size:12,strokeWidth:2.2}):null})]},h.id)})}):null]}),n.jsx("textarea",{ref:$,value:c,onChange:h=>f(h.currentTarget.value),onKeyDown:h=>{h.stopPropagation(),(h.metaKey||h.ctrlKey)&&h.key==="Enter"&&(h.preventDefault(),S())},rows:1,disabled:a,placeholder:o.length>0?`Send to ${m} with included context`:"Leave a note on this diff…","aria-label":"Diff comment"}),n.jsxs("button",{type:"button",className:"rd-comment-send",disabled:!I,onClick:S,title:"Send diff comment","aria-label":"Send diff comment",children:[a?n.jsx(ue,{size:13,className:"rd-comment-spin","aria-hidden":!0}):n.jsx(fe,{size:13,"aria-hidden":!0}),n.jsx("span",{children:a?"Sending":"Send"})]})]}),n.jsx("div",{className:"rd-comment-meta",children:g?n.jsx("span",{className:"err",children:g}):d?n.jsx("span",{className:"ok",children:d}):n.jsxs("span",{children:[e.scope?.kind==="session"?"Session diff":"Worktree diff",N?` · ${N}`:""]})})]})}function Ce({item:e,disabled:t,onRemove:r}){const s=e.kind==="file"?je:me;return n.jsxs("div",{className:`rd-context-item ${e.kind}`,children:[n.jsxs("div",{className:"rd-context-head",children:[n.jsx("span",{className:"rd-context-icon","aria-hidden":!0,children:n.jsx(s,{size:12,strokeWidth:2})}),n.jsx("span",{className:"rd-context-label",title:e.label,children:e.label}),n.jsx("span",{className:"rd-context-detail",children:e.detail}),n.jsx("button",{type:"button",className:"rd-context-remove",onClick:()=>r(e.id),disabled:t,title:"Remove included context","aria-label":"Remove included context",children:n.jsx(pe,{size:11,strokeWidth:2.2,"aria-hidden":!0})})]}),e.preview?n.jsx("pre",{className:"rd-context-preview",children:e.preview}):null]})}function $e({heading:e,worktreePath:t,snapshot:r,freshness:s,activeLayer:i,onLayer:c,layout:f,onLayout:o,refreshing:p,onRefresh:a,onFocusComment:d,onClose:g,onOpenAsPage:$}){const{dir:S}=q(t);return n.jsxs("div",{className:"rd-header",children:[n.jsxs("div",{className:"rd-header-id",children:[n.jsxs("div",{className:"rd-header-title",children:[n.jsx("span",{className:"rd-header-name",title:t,children:e}),r.scope?n.jsx(Ne,{snapshot:r}):null,S?n.jsx("span",{className:"rd-header-dir",children:S}):null]}),n.jsx("div",{className:"rd-header-sub",children:n.jsx(ve,{layers:r.layers,activeLayer:i,onLayer:c})}),n.jsx(we,{freshness:s,generatedAt:r.generatedAt})]}),n.jsxs("div",{className:"rd-header-actions",children:[n.jsx("button",{type:"button",className:"rd-close","aria-label":"Comment on diff",title:"Comment on diff",onClick:d,children:n.jsx(xe,{size:14,strokeWidth:2,"aria-hidden":!0})}),n.jsxs("div",{className:"rd-segmented",role:"group","aria-label":"Diff layout",children:[n.jsx("button",{type:"button",className:f==="unified"?"on":"","aria-pressed":f==="unified",onClick:()=>o("unified"),children:"Unified"}),n.jsx("button",{type:"button",className:f==="split"?"on":"","aria-pressed":f==="split",onClick:()=>o("split"),children:"Split"})]}),n.jsx("button",{type:"button",className:`rd-close${p?" spinning":""}`,"aria-label":"Refresh diff",title:"Fetch fresh diff",onClick:a,disabled:p,children:n.jsx(ge,{size:14,strokeWidth:2,"aria-hidden":!0})}),$?n.jsx("button",{type:"button",className:"rd-close","aria-label":"Open diff as page",title:"Open as full page",onClick:$,children:"↗"}):null,g?n.jsx("button",{type:"button",className:"rd-close","aria-label":"Close",onClick:g,children:"✕"}):null]})]})}function Se({snapshot:e}){const t=[];e.coverage.truncatedLayers>0&&t.push({level:"warning",text:`${e.coverage.truncatedLayers} layer${e.coverage.truncatedLayers===1?"":"s"} truncated — the native diff hit a size budget; some files or hunks are omitted.`}),e.coverage.scanBudgetReached&&t.push({level:"warning",text:"Scan budget reached — this diff is partial."});for(const r of e.diagnostics)t.push({level:r.level,text:r.path?`${r.message} (${r.path})`:r.message});return t.length===0?null:n.jsx(n.Fragment,{children:t.map((r,s)=>n.jsxs("div",{className:`rd-banner ${r.level}`,children:[n.jsx("span",{className:"rd-banner-dot","aria-hidden":!0}),n.jsx("span",{children:r.text})]},s))})}function Ne({snapshot:e}){const t=e.scope;if(!t)return null;const r=t.kind==="session"?`Session · ${t.filteredPaths.length} files`:t.filteredPaths.length>0?`Filtered · ${t.filteredPaths.length} files`:"Worktree",s=t.kind==="session"?`${t.label}: path-filtered diff from ${t.changedFiles} changed / ${t.touchedFiles} touched session files`:t.label;return n.jsx("span",{className:`rd-scope-pill ${t.kind}`,title:s,children:r})}function we({freshness:e,generatedAt:t}){const r=e?.fetchedAt??t,s=Math.max(0,Date.now()-r),i=e?.cacheHit?`Prefetched ${O(s)}`:`Updated ${O(s)}`;return n.jsxs("div",{className:"rd-freshness",title:new Date(r).toLocaleString(),children:[n.jsx("span",{children:i}),e?.refreshing?n.jsx("span",{children:"Refreshing…"}):null,e?.refreshError?n.jsx("span",{children:"Refresh failed"}):null]})}function ve({layers:e,activeLayer:t,onLayer:r}){return n.jsx("div",{className:"rd-layers",role:"tablist","aria-label":"Diff layers",children:e.map(s=>{const i=ee(s);return n.jsxs("button",{type:"button",role:"tab","aria-selected":s.kind===t,className:"rd-layer-tab"+(s.kind===t?" on":""),onClick:()=>r(s.kind),title:s.shortstat??void 0,children:[n.jsx("span",{children:te[s.kind]??s.kind}),n.jsx("span",{className:"rd-layer-stat",children:s.files.length===0?"clean":n.jsxs(n.Fragment,{children:[s.files.length,"f"," ",n.jsxs("span",{style:{color:"var(--rd-add)"},children:["+",i.add]})," ",n.jsxs("span",{style:{color:"var(--rd-del)"},children:["−",i.del]}),s.truncated?" ⚠":""]})})]},s.kind)})})}const G="openscout.repo-diff.files-rail-width",U=268,Ie=196,De=520;function Re(e,t){if(e.length<=t)return e;const r=e.lastIndexOf(".");if(r<=0){const p=Math.max(1,Math.floor((t-1)/2)),a=t-p-1;return e.slice(0,p)+"…"+e.slice(-Math.max(1,a))}const s=e.slice(0,r),i=e.slice(r),c=t-i.length-1;if(c<2){const p=Math.max(1,t-i.length-1);return s.slice(0,p)+"…"+i}const f=Math.max(1,Math.floor(c/2)),o=Math.max(1,c-f);return s.slice(0,f)+"…"+s.slice(-o)+i}function Le(e,t){return Math.max(8,Math.floor((e-178-t*14)/6.7))}function W(e){return Math.max(Ie,Math.min(De,Math.round(e)))}function Pe(){if(typeof window>"u")return U;const e=Number(window.localStorage.getItem(G));return Number.isFinite(e)?W(e):U}function Me(e){const t={name:"",path:"",firstIndex:Number.MAX_SAFE_INTEGER,children:new Map,files:[]};for(const r of e){t.firstIndex=Math.min(t.firstIndex,r.index);const s=r.dir?r.dir.split("/").filter(Boolean):[];let i=t;for(const c of s){const f=i.path?`${i.path}/${c}`:c;let o=i.children.get(c);o||(o={name:c,path:f,firstIndex:r.index,children:new Map,files:[]},i.children.set(c,o)),o.firstIndex=Math.min(o.firstIndex,r.index),i=o}i.files.push(r)}return t}function J(e){let t=e.files.length;for(const r of e.children.values())t+=J(r);return t}function Ee({layer:e,selectedFileKey:t,onSelect:r,onIncludeFile:s}){const[i,c]=l.useState(Pe),[f,o]=l.useState(()=>new Set),p=l.useMemo(()=>(e?.files??[]).map((u,j)=>{const b=K(u,j),w=T(u),{name:m,dir:k}=q(w),N=(u.status==="renamed"||u.status==="copied")&&u.oldPath&&u.newPath&&u.oldPath!==u.newPath;return{file:u,index:j,key:b,display:w,name:m,dir:k,renamed:!!N}}),[e]),a=l.useMemo(()=>Me(p),[p]),d=l.useCallback(u=>{o(j=>{const b=new Set(j);return b.has(u)?b.delete(u):b.add(u),b})},[]),g=l.useCallback(u=>{u.preventDefault();const j=u.clientX,b=i,w=k=>{c(W(b+k.clientX-j))},m=()=>{window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",m),c(k=>{const N=W(k);return window.localStorage.setItem(G,String(N)),N})};window.addEventListener("pointermove",w),window.addEventListener("pointerup",m,{once:!0})},[i]),$=(u,j)=>n.jsx(Fe,{entry:u,depth:j,railWidth:i,selected:u.key===t,onSelect:r,onIncludeFile:s},u.key),S=(u,j)=>{const b=[],w=[...u.children.values()].sort((m,k)=>m.firstIndex!==k.firstIndex?m.firstIndex-k.firstIndex:m.name.localeCompare(k.name));for(const m of w){const k=f.has(m.path);b.push(n.jsxs("button",{type:"button",className:"rd-dir-row",style:{paddingLeft:12+j*14},onClick:()=>d(m.path),title:m.path,children:[n.jsx("span",{className:"rd-dir-caret",children:k?"›":"⌄"}),n.jsx("span",{className:"rd-dir-name",children:m.name}),n.jsx("span",{className:"rd-dir-count",children:J(m)})]},`dir:${m.path}`)),k||b.push(...S(m,j+1))}for(const m of u.files)b.push($(m,j));return b};return n.jsxs("div",{className:"rd-rail",style:{width:i},children:[n.jsx("div",{className:"rd-rail-head",children:e?`Changed files · ${e.files.length}`:"Changed files"}),n.jsx("div",{className:"rd-rail-list",children:S(a,0)}),n.jsx("div",{className:"rd-rail-resizer",role:"separator","aria-orientation":"vertical","aria-label":"Resize file navigation",onPointerDown:g})]})}function Fe({entry:e,depth:t,railWidth:r,selected:s,onSelect:i,onIncludeFile:c}){const{file:f,key:o,display:p,name:a,dir:d,renamed:g}=e,$=Le(r,t),S=Re(a,$);return n.jsxs("div",{className:"rd-file-row"+(s?" on":""),title:g?`${f.oldPath} → ${f.newPath}`:p,children:[n.jsxs("button",{type:"button",className:"rd-file-pick",style:{paddingLeft:18+t*14},onClick:()=>i(o),children:[n.jsx("span",{className:`rd-file-glyph ${f.status}`,children:ne[f.status]}),n.jsxs("span",{className:"rd-file-id",children:[n.jsx("span",{className:"rd-file-name",children:S}),n.jsx("span",{className:"rd-file-dir",children:g?`${f.oldPath} → ${d||a}`:d}),n.jsx(Te,{file:f})]})]}),n.jsx("span",{className:"rd-file-churn",children:f.binary?n.jsx("span",{className:"add",style:{color:"var(--muted)"},children:"bin"}):n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"add",children:["+",f.additions??0]}),n.jsxs("span",{className:"del",children:["−",f.deletions??0]})]})}),n.jsx("button",{type:"button",className:"rd-file-include",onClick:u=>{u.stopPropagation(),c(f,o)},"aria-label":`Include ${p} in comment`,title:"Include in comment",children:n.jsx(be,{size:12,strokeWidth:2,"aria-hidden":!0})})]})}function Te({file:e}){const t=[];return e.binary&&t.push("BINARY"),e.truncated&&t.push("TRUNCATED"),e.status==="conflict"&&t.push("CONFLICT"),t.length===0?null:n.jsx("span",{className:"rd-file-tags",children:t.map(r=>n.jsx("span",{className:"rd-file-tag",children:r},r))})}function Ae(e){switch(e?.trim().toLowerCase()){case"active":case"working":case"running":case"in_turn":return 80;case"queued":case"waiting":case"waking":case"in_flight":return 50;case"idle":case"available":return 25;case"offline":case"retired":case"stale":return-40;default:return 0}}function Ke(e){return e.newPath??e.oldPath??"(unknown)"}function Q(e){const t=e.scope?.kind==="session"?e.scope.agentId:null,r=new Map;for(const s of e.scout.hints)s.agentId&&r.set(s.agentId,(r.get(s.agentId)??0)+1);return e.scout.agents.map(s=>({id:s.id,label:X(s),score:Ae(s.state)+(s.id===t?1e3:0)+(r.get(s.id)??0)*10})).sort((s,i)=>{const c=i.score-s.score;return c!==0?c:s.label.localeCompare(i.label)})}function We(e){return Q(e)[0]??null}function ze(e){const t=e.files.reduce((r,s)=>({add:r.add+(s.additions??0),del:r.del+(s.deletions??0)}),{add:0,del:0});return`${e.kind}: ${e.files.length} file${e.files.length===1?"":"s"}, +${t.add} -${t.del}${e.truncated?", truncated":""}`}function z(e){const t=e.binary?"binary":`+${e.additions??0} -${e.deletions??0}`;return`${e.status}: ${Ke(e)} (${t}${e.truncated?", truncated":""})`}function _e(e){const t=e.scope;return t?t.kind==="session"?`session ${t.sessionId??t.refId??"(unknown)"} (${t.changedFiles} changed / ${t.touchedFiles} touched files, ${t.include})`:t.filteredPaths.length>0?`filtered worktree (${t.filteredPaths.length} paths)`:"worktree":"worktree"}function He(e){const{comment:t,includedContext:r=[],snapshot:s,activeLayer:i,selectedFile:c}=e,o=((i?s.layers.find(d=>d.kind===i)??null:null)?.files??s.layers.flatMap(d=>d.files)).slice(0,12).map(z),p=s.scout.agents.map(d=>X(d)).slice(0,8),a=["Operator comment on repo diff:",t,"","Repo Diff context:",`- Worktree: ${s.worktreePath}`,`- Scope: ${_e(s)}`,`- Active layer: ${i??"none"}`];return r.length>0&&a.splice(3,0,"Included diff context:",...r.map(d=>d.trim()).filter(Boolean),""),c&&a.push(`- Selected file: ${z(c)}`),a.push(`- Layers: ${s.layers.map(ze).join("; ")}`),p.length>0&&a.push(`- Attached agents: ${p.join(", ")}`),s.scout.sessions.length>0&&a.push(`- Sessions: ${s.scout.sessions.map(d=>d.id).slice(0,8).join(", ")}`),o.length>0&&a.push(`- Changed files: ${o.join(", ")}`),s.diagnostics.length>0&&a.push(`- Diagnostics: ${s.diagnostics.map(d=>d.message).join("; ")}`),a.join(`
1
+ import{r as l,j as n}from"./index-o4FKpU7Z.js";import{a as X,p as Z}from"./ui-LM8pS8qE.js";/* empty css */import{a as T,s as q,l as ee,L as te,f as K,S as ne,r as se,b as re,c as _,d as ie,u as ae,V as A,C as H,D as le,e as oe}from"./usePierreRuntime-B4hbNWTz.js";import{C as ce}from"./chevron-down-NAhBUkFd.js";import{C as de}from"./check--esHw52j.js";import{L as ue}from"./loader-circle-4LDsy4Ke.js";import{S as fe}from"./send-horizontal-DP16OOIW.js";import{c as he}from"./createLucideIcon-Bt67PWH-.js";import{C as me}from"./code-xml-CLn3TDWF.js";import{X as pe}from"./x-ynOfVadO.js";import{r as O,a as V,f as Y}from"./cache-Dr0why2k.js";import{M as xe}from"./message-square-ER1_q2pe.js";import{R as ge}from"./refresh-cw-B5To7b6B.js";import{P as be}from"./plus-C-2gTcPK.js";import{a as B}from"./api-h5zurxmi.js";import"./chunk-HRAB3GC3-DF8R9rPv.js";const ye=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],je=he("file-code-corner",ye);function ke({snapshot:e,selectedFile:t,targets:r,targetId:s,onTargetId:i,draft:c,onDraft:f,contextItems:o,onRemoveContextItem:p,pending:a,status:d,error:g,textareaRef:$,onSubmit:S}){const[u,j]=l.useState(!1),b=l.useRef(null),w=r.find(h=>h.id===s)??null,m=w?.label??"Scout",k=r[0]?.id??null,N=t?T(t):null,I=(c.trim().length>0||o.length>0)&&!a,R=l.useMemo(()=>[...r.map(h=>({id:h.id,label:h.label,suffix:h.id===k?"best context":null})),{id:"scout",label:"Scout",suffix:null}],[k,r]);return l.useEffect(()=>{if(!u)return;const h=C=>{const D=b.current;D&&C.target instanceof Node&&D.contains(C.target)||j(!1)};return document.addEventListener("pointerdown",h),()=>document.removeEventListener("pointerdown",h)},[u]),n.jsxs("div",{className:"rd-comment",children:[o.length>0?n.jsx("div",{className:"rd-comment-context","aria-label":"Included diff context",children:o.map(h=>n.jsx(Ce,{item:h,disabled:a,onRemove:p},h.id))}):null,n.jsxs("div",{className:"rd-comment-main",children:[n.jsxs("div",{className:"rd-target-picker",ref:b,children:[n.jsxs("button",{type:"button",className:"rd-target-button",onClick:()=>j(h=>!h),onKeyDown:h=>{h.stopPropagation(),h.key==="Escape"&&j(!1)},disabled:a,"aria-label":"Diff comment target","aria-haspopup":"listbox","aria-expanded":u,title:"Diff comment target",children:[n.jsx("span",{children:m}),n.jsx(ce,{size:13,strokeWidth:2,"aria-hidden":!0})]}),u?n.jsx("div",{className:"rd-target-menu",role:"listbox","aria-label":"Diff comment target",children:R.map(h=>{const C=h.id===(w?.id??"scout");return n.jsxs("button",{type:"button",className:"rd-target-option",role:"option","aria-selected":C,onClick:()=>{i(h.id),j(!1)},children:[n.jsx("span",{className:"rd-target-option-label",children:h.label}),h.suffix?n.jsx("span",{className:"rd-target-option-suffix",children:h.suffix}):null,n.jsx("span",{className:"rd-target-option-check","aria-hidden":!0,children:C?n.jsx(de,{size:12,strokeWidth:2.2}):null})]},h.id)})}):null]}),n.jsx("textarea",{ref:$,value:c,onChange:h=>f(h.currentTarget.value),onKeyDown:h=>{h.stopPropagation(),(h.metaKey||h.ctrlKey)&&h.key==="Enter"&&(h.preventDefault(),S())},rows:1,disabled:a,placeholder:o.length>0?`Send to ${m} with included context`:"Leave a note on this diff…","aria-label":"Diff comment"}),n.jsxs("button",{type:"button",className:"rd-comment-send",disabled:!I,onClick:S,title:"Send diff comment","aria-label":"Send diff comment",children:[a?n.jsx(ue,{size:13,className:"rd-comment-spin","aria-hidden":!0}):n.jsx(fe,{size:13,"aria-hidden":!0}),n.jsx("span",{children:a?"Sending":"Send"})]})]}),n.jsx("div",{className:"rd-comment-meta",children:g?n.jsx("span",{className:"err",children:g}):d?n.jsx("span",{className:"ok",children:d}):n.jsxs("span",{children:[e.scope?.kind==="session"?"Session diff":"Worktree diff",N?` · ${N}`:""]})})]})}function Ce({item:e,disabled:t,onRemove:r}){const s=e.kind==="file"?je:me;return n.jsxs("div",{className:`rd-context-item ${e.kind}`,children:[n.jsxs("div",{className:"rd-context-head",children:[n.jsx("span",{className:"rd-context-icon","aria-hidden":!0,children:n.jsx(s,{size:12,strokeWidth:2})}),n.jsx("span",{className:"rd-context-label",title:e.label,children:e.label}),n.jsx("span",{className:"rd-context-detail",children:e.detail}),n.jsx("button",{type:"button",className:"rd-context-remove",onClick:()=>r(e.id),disabled:t,title:"Remove included context","aria-label":"Remove included context",children:n.jsx(pe,{size:11,strokeWidth:2.2,"aria-hidden":!0})})]}),e.preview?n.jsx("pre",{className:"rd-context-preview",children:e.preview}):null]})}function $e({heading:e,worktreePath:t,snapshot:r,freshness:s,activeLayer:i,onLayer:c,layout:f,onLayout:o,refreshing:p,onRefresh:a,onFocusComment:d,onClose:g,onOpenAsPage:$}){const{dir:S}=q(t);return n.jsxs("div",{className:"rd-header",children:[n.jsxs("div",{className:"rd-header-id",children:[n.jsxs("div",{className:"rd-header-title",children:[n.jsx("span",{className:"rd-header-name",title:t,children:e}),r.scope?n.jsx(Ne,{snapshot:r}):null,S?n.jsx("span",{className:"rd-header-dir",children:S}):null]}),n.jsx("div",{className:"rd-header-sub",children:n.jsx(ve,{layers:r.layers,activeLayer:i,onLayer:c})}),n.jsx(we,{freshness:s,generatedAt:r.generatedAt})]}),n.jsxs("div",{className:"rd-header-actions",children:[n.jsx("button",{type:"button",className:"rd-close","aria-label":"Comment on diff",title:"Comment on diff",onClick:d,children:n.jsx(xe,{size:14,strokeWidth:2,"aria-hidden":!0})}),n.jsxs("div",{className:"rd-segmented",role:"group","aria-label":"Diff layout",children:[n.jsx("button",{type:"button",className:f==="unified"?"on":"","aria-pressed":f==="unified",onClick:()=>o("unified"),children:"Unified"}),n.jsx("button",{type:"button",className:f==="split"?"on":"","aria-pressed":f==="split",onClick:()=>o("split"),children:"Split"})]}),n.jsx("button",{type:"button",className:`rd-close${p?" spinning":""}`,"aria-label":"Refresh diff",title:"Fetch fresh diff",onClick:a,disabled:p,children:n.jsx(ge,{size:14,strokeWidth:2,"aria-hidden":!0})}),$?n.jsx("button",{type:"button",className:"rd-close","aria-label":"Open diff as page",title:"Open as full page",onClick:$,children:"↗"}):null,g?n.jsx("button",{type:"button",className:"rd-close","aria-label":"Close",onClick:g,children:"✕"}):null]})]})}function Se({snapshot:e}){const t=[];e.coverage.truncatedLayers>0&&t.push({level:"warning",text:`${e.coverage.truncatedLayers} layer${e.coverage.truncatedLayers===1?"":"s"} truncated — the native diff hit a size budget; some files or hunks are omitted.`}),e.coverage.scanBudgetReached&&t.push({level:"warning",text:"Scan budget reached — this diff is partial."});for(const r of e.diagnostics)t.push({level:r.level,text:r.path?`${r.message} (${r.path})`:r.message});return t.length===0?null:n.jsx(n.Fragment,{children:t.map((r,s)=>n.jsxs("div",{className:`rd-banner ${r.level}`,children:[n.jsx("span",{className:"rd-banner-dot","aria-hidden":!0}),n.jsx("span",{children:r.text})]},s))})}function Ne({snapshot:e}){const t=e.scope;if(!t)return null;const r=t.kind==="session"?`Session · ${t.filteredPaths.length} files`:t.filteredPaths.length>0?`Filtered · ${t.filteredPaths.length} files`:"Worktree",s=t.kind==="session"?`${t.label}: path-filtered diff from ${t.changedFiles} changed / ${t.touchedFiles} touched session files`:t.label;return n.jsx("span",{className:`rd-scope-pill ${t.kind}`,title:s,children:r})}function we({freshness:e,generatedAt:t}){const r=e?.fetchedAt??t,s=Math.max(0,Date.now()-r),i=e?.cacheHit?`Prefetched ${O(s)}`:`Updated ${O(s)}`;return n.jsxs("div",{className:"rd-freshness",title:new Date(r).toLocaleString(),children:[n.jsx("span",{children:i}),e?.refreshing?n.jsx("span",{children:"Refreshing…"}):null,e?.refreshError?n.jsx("span",{children:"Refresh failed"}):null]})}function ve({layers:e,activeLayer:t,onLayer:r}){return n.jsx("div",{className:"rd-layers",role:"tablist","aria-label":"Diff layers",children:e.map(s=>{const i=ee(s);return n.jsxs("button",{type:"button",role:"tab","aria-selected":s.kind===t,className:"rd-layer-tab"+(s.kind===t?" on":""),onClick:()=>r(s.kind),title:s.shortstat??void 0,children:[n.jsx("span",{children:te[s.kind]??s.kind}),n.jsx("span",{className:"rd-layer-stat",children:s.files.length===0?"clean":n.jsxs(n.Fragment,{children:[s.files.length,"f"," ",n.jsxs("span",{style:{color:"var(--rd-add)"},children:["+",i.add]})," ",n.jsxs("span",{style:{color:"var(--rd-del)"},children:["−",i.del]}),s.truncated?" ⚠":""]})})]},s.kind)})})}const G="openscout.repo-diff.files-rail-width",U=268,Ie=196,De=520;function Re(e,t){if(e.length<=t)return e;const r=e.lastIndexOf(".");if(r<=0){const p=Math.max(1,Math.floor((t-1)/2)),a=t-p-1;return e.slice(0,p)+"…"+e.slice(-Math.max(1,a))}const s=e.slice(0,r),i=e.slice(r),c=t-i.length-1;if(c<2){const p=Math.max(1,t-i.length-1);return s.slice(0,p)+"…"+i}const f=Math.max(1,Math.floor(c/2)),o=Math.max(1,c-f);return s.slice(0,f)+"…"+s.slice(-o)+i}function Le(e,t){return Math.max(8,Math.floor((e-178-t*14)/6.7))}function W(e){return Math.max(Ie,Math.min(De,Math.round(e)))}function Pe(){if(typeof window>"u")return U;const e=Number(window.localStorage.getItem(G));return Number.isFinite(e)?W(e):U}function Me(e){const t={name:"",path:"",firstIndex:Number.MAX_SAFE_INTEGER,children:new Map,files:[]};for(const r of e){t.firstIndex=Math.min(t.firstIndex,r.index);const s=r.dir?r.dir.split("/").filter(Boolean):[];let i=t;for(const c of s){const f=i.path?`${i.path}/${c}`:c;let o=i.children.get(c);o||(o={name:c,path:f,firstIndex:r.index,children:new Map,files:[]},i.children.set(c,o)),o.firstIndex=Math.min(o.firstIndex,r.index),i=o}i.files.push(r)}return t}function J(e){let t=e.files.length;for(const r of e.children.values())t+=J(r);return t}function Ee({layer:e,selectedFileKey:t,onSelect:r,onIncludeFile:s}){const[i,c]=l.useState(Pe),[f,o]=l.useState(()=>new Set),p=l.useMemo(()=>(e?.files??[]).map((u,j)=>{const b=K(u,j),w=T(u),{name:m,dir:k}=q(w),N=(u.status==="renamed"||u.status==="copied")&&u.oldPath&&u.newPath&&u.oldPath!==u.newPath;return{file:u,index:j,key:b,display:w,name:m,dir:k,renamed:!!N}}),[e]),a=l.useMemo(()=>Me(p),[p]),d=l.useCallback(u=>{o(j=>{const b=new Set(j);return b.has(u)?b.delete(u):b.add(u),b})},[]),g=l.useCallback(u=>{u.preventDefault();const j=u.clientX,b=i,w=k=>{c(W(b+k.clientX-j))},m=()=>{window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",m),c(k=>{const N=W(k);return window.localStorage.setItem(G,String(N)),N})};window.addEventListener("pointermove",w),window.addEventListener("pointerup",m,{once:!0})},[i]),$=(u,j)=>n.jsx(Fe,{entry:u,depth:j,railWidth:i,selected:u.key===t,onSelect:r,onIncludeFile:s},u.key),S=(u,j)=>{const b=[],w=[...u.children.values()].sort((m,k)=>m.firstIndex!==k.firstIndex?m.firstIndex-k.firstIndex:m.name.localeCompare(k.name));for(const m of w){const k=f.has(m.path);b.push(n.jsxs("button",{type:"button",className:"rd-dir-row",style:{paddingLeft:12+j*14},onClick:()=>d(m.path),title:m.path,children:[n.jsx("span",{className:"rd-dir-caret",children:k?"›":"⌄"}),n.jsx("span",{className:"rd-dir-name",children:m.name}),n.jsx("span",{className:"rd-dir-count",children:J(m)})]},`dir:${m.path}`)),k||b.push(...S(m,j+1))}for(const m of u.files)b.push($(m,j));return b};return n.jsxs("div",{className:"rd-rail",style:{width:i},children:[n.jsx("div",{className:"rd-rail-head",children:e?`Changed files · ${e.files.length}`:"Changed files"}),n.jsx("div",{className:"rd-rail-list",children:S(a,0)}),n.jsx("div",{className:"rd-rail-resizer",role:"separator","aria-orientation":"vertical","aria-label":"Resize file navigation",onPointerDown:g})]})}function Fe({entry:e,depth:t,railWidth:r,selected:s,onSelect:i,onIncludeFile:c}){const{file:f,key:o,display:p,name:a,dir:d,renamed:g}=e,$=Le(r,t),S=Re(a,$);return n.jsxs("div",{className:"rd-file-row"+(s?" on":""),title:g?`${f.oldPath} → ${f.newPath}`:p,children:[n.jsxs("button",{type:"button",className:"rd-file-pick",style:{paddingLeft:18+t*14},onClick:()=>i(o),children:[n.jsx("span",{className:`rd-file-glyph ${f.status}`,children:ne[f.status]}),n.jsxs("span",{className:"rd-file-id",children:[n.jsx("span",{className:"rd-file-name",children:S}),n.jsx("span",{className:"rd-file-dir",children:g?`${f.oldPath} → ${d||a}`:d}),n.jsx(Te,{file:f})]})]}),n.jsx("span",{className:"rd-file-churn",children:f.binary?n.jsx("span",{className:"add",style:{color:"var(--muted)"},children:"bin"}):n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"add",children:["+",f.additions??0]}),n.jsxs("span",{className:"del",children:["−",f.deletions??0]})]})}),n.jsx("button",{type:"button",className:"rd-file-include",onClick:u=>{u.stopPropagation(),c(f,o)},"aria-label":`Include ${p} in comment`,title:"Include in comment",children:n.jsx(be,{size:12,strokeWidth:2,"aria-hidden":!0})})]})}function Te({file:e}){const t=[];return e.binary&&t.push("BINARY"),e.truncated&&t.push("TRUNCATED"),e.status==="conflict"&&t.push("CONFLICT"),t.length===0?null:n.jsx("span",{className:"rd-file-tags",children:t.map(r=>n.jsx("span",{className:"rd-file-tag",children:r},r))})}function Ae(e){switch(e?.trim().toLowerCase()){case"active":case"working":case"running":case"in_turn":return 80;case"queued":case"waiting":case"waking":case"in_flight":return 50;case"idle":case"available":return 25;case"offline":case"retired":case"stale":return-40;default:return 0}}function Ke(e){return e.newPath??e.oldPath??"(unknown)"}function Q(e){const t=e.scope?.kind==="session"?e.scope.agentId:null,r=new Map;for(const s of e.scout.hints)s.agentId&&r.set(s.agentId,(r.get(s.agentId)??0)+1);return e.scout.agents.map(s=>({id:s.id,label:X(s),score:Ae(s.state)+(s.id===t?1e3:0)+(r.get(s.id)??0)*10})).sort((s,i)=>{const c=i.score-s.score;return c!==0?c:s.label.localeCompare(i.label)})}function We(e){return Q(e)[0]??null}function ze(e){const t=e.files.reduce((r,s)=>({add:r.add+(s.additions??0),del:r.del+(s.deletions??0)}),{add:0,del:0});return`${e.kind}: ${e.files.length} file${e.files.length===1?"":"s"}, +${t.add} -${t.del}${e.truncated?", truncated":""}`}function z(e){const t=e.binary?"binary":`+${e.additions??0} -${e.deletions??0}`;return`${e.status}: ${Ke(e)} (${t}${e.truncated?", truncated":""})`}function _e(e){const t=e.scope;return t?t.kind==="session"?`session ${t.sessionId??t.refId??"(unknown)"} (${t.changedFiles} changed / ${t.touchedFiles} touched files, ${t.include})`:t.filteredPaths.length>0?`filtered worktree (${t.filteredPaths.length} paths)`:"worktree":"worktree"}function He(e){const{comment:t,includedContext:r=[],snapshot:s,activeLayer:i,selectedFile:c}=e,o=((i?s.layers.find(d=>d.kind===i)??null:null)?.files??s.layers.flatMap(d=>d.files)).slice(0,12).map(z),p=s.scout.agents.map(d=>X(d)).slice(0,8),a=["Operator comment on repo diff:",t,"","Repo Diff context:",`- Worktree: ${s.worktreePath}`,`- Scope: ${_e(s)}`,`- Active layer: ${i??"none"}`];return r.length>0&&a.splice(3,0,"Included diff context:",...r.map(d=>d.trim()).filter(Boolean),""),c&&a.push(`- Selected file: ${z(c)}`),a.push(`- Layers: ${s.layers.map(ze).join("; ")}`),p.length>0&&a.push(`- Attached agents: ${p.join(", ")}`),s.scout.sessions.length>0&&a.push(`- Sessions: ${s.scout.sessions.map(d=>d.id).slice(0,8).join(", ")}`),o.length>0&&a.push(`- Changed files: ${o.join(", ")}`),s.diagnostics.length>0&&a.push(`- Diagnostics: ${s.diagnostics.map(d=>d.message).join("; ")}`),a.join(`
2
2
  `)}function Oe(e){const{snapshot:t,activeLayer:r,file:s}=e,i=[r??"diff",z(s)];return t.scope?.kind==="session"&&i.push(`session ${t.scope.sessionId??t.scope.refId??"scope"}`),`[Diff context: ${i.join(" · ")}]`}function Be(e,t,r){return!e||!t?null:e.files.find((s,i)=>r(s,i)===t)??null}function Ue(e,t=120){const r=e.replace(/\s+/g," ").trim();return r.length>t?`${r.slice(0,t-3)}...`:r}function Xe(e,t=7){const r=e.trimEnd().split(`
3
3
  `),s=r.slice(0,t),i=r.length-s.length;return i>0?`${s.join(`
4
4
  `)}
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/RepoDiffViewer-VrUJw33u.js","assets/index-o4FKpU7Z.js","assets/index-Bu-fckyR.css","assets/ui-LM8pS8qE.js","assets/usePierreRuntime-B4hbNWTz.js","assets/chunk-HRAB3GC3-DF8R9rPv.js","assets/chevron-down-NAhBUkFd.js","assets/createLucideIcon-Bt67PWH-.js","assets/check--esHw52j.js","assets/loader-circle-4LDsy4Ke.js","assets/send-horizontal-DP16OOIW.js","assets/code-xml-CLn3TDWF.js","assets/x-ynOfVadO.js","assets/cache-Dr0why2k.js","assets/api-h5zurxmi.js","assets/message-square-ER1_q2pe.js","assets/refresh-cw-B5To7b6B.js","assets/plus-C-2gTcPK.js","assets/repo-diff-DyYmQMSA.css"])))=>i.map(i=>d[i]);
2
+ import{j as e,r as i,_ as s}from"./index-o4FKpU7Z.js";/* empty css */const a=i.lazy(()=>s(()=>import("./RepoDiffViewer-VrUJw33u.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])).then(r=>({default:r.RepoDiffViewer})));function t(){return e.jsx("div",{className:"rd-viewer","data-scout-theme":!0,children:e.jsx("div",{className:"rd-center",children:e.jsxs("div",{className:"rd-center-card",children:[e.jsx("div",{className:"rd-spinner","aria-hidden":!0}),e.jsx("div",{className:"rd-center-title",children:"Opening diff viewer…"})]})})})}function c(r){return e.jsx(i.Suspense,{fallback:e.jsx(t,{}),children:e.jsx(a,{...r})})}export{c as R};
@@ -1,6 +1,6 @@
1
- import{r as u,j as e}from"./index-sUomXsrf.js";import{E as se}from"./EmptyState-CoL-QuUO.js";import{u as We}from"./ContextMenu-BlBQhpax.js";import{f as he,b as qe}from"./api-BkjHJfgJ.js";import{a as _e}from"./api-h5zurxmi.js";import{c as te}from"./clipboard-e3fSpeo7.js";import{u as Be}from"./keyboard-nav-BhZZ5HEq.js";/* empty css */import{f as w,c as He,b as Ce,r as Ee,u as Pe,i as ie,w as Ae,k as Ie,l as Ue,m as G,a as X,s as Ke,h as Ve}from"./ui-LM8pS8qE.js";import{B as Me,p as ze,c as Ge}from"./selection-bridge-CJOTyYQs.js";import{S as Xe}from"./SlidePanel-FCqT1zO3.js";import{R as Ye}from"./RepoDiffViewerLazy-C8UPk4oo.js";import{p as Je}from"./cache-Dr0why2k.js";import{u as Qe}from"./Provider-tFc3jqZ4.js";import{R as Ze}from"./refresh-cw-D8PFyhUa.js";import{S as es}from"./sliders-horizontal-B9Nj-Y4J.js";/* empty css */import"./router-Dja9_ygK.js";import"./terminal-sessions-D5CIR2OL.js";import"./sse-CVoGDiKW.js";import"./index-BWHgHrtv.js";import"./surface-activity-B1rgWB1i.js";import"./colors-BtO5_zlx.js";import"./scoutbot-BTIErYHo.js";import"./DocumentFocusViewer-DU_9BHsD.js";import"./createLucideIcon-DlxlBfLC.js";import"./TextDocumentSurface-C-9EtYqt.js";/* empty css */import"./file-text-i3xTDUjJ.js";import"./x-0XjXwGqq.js";import"./chevron-right-CyUa1zXx.js";import"./code-xml-05TD3uOC.js";import"./arrow-left-WjQIN9J6.js";import"./scout-voice-BZ4KqADJ.js";import"./fx-z37u1o2z.js";import"./MessageComposerSuggestions-zAUUcLOv.js";import"./NewChatComposer-B5FnPyzS.js";import"./runtime-picker-DOZpZOlt.js";import"./voice-levels-Dcr3jglk.js";import"./loader-circle-lWOOKezu.js";import"./index-m6dFtY5f.js";import"./HarnessMark-Dm_qm1Ku.js";import"./conversation-model-C4yb6_FA.js";import"./time-Dhsh_2EG.js";import"./NewChatOrigin--pHWUb4V.js";import"./agent-chat-Bfjd9y6c.js";import"./model-Co0zkMIc.js";import"./text-DsBWV_4k.js";import"./chevron-down-BFai6ZfE.js";import"./search-DCT_EvPr.js";import"./chunk-HRAB3GC3-CvwpNg-G.js";const pe=[{value:"claude",label:"Claude"},{value:"codex",label:"Codex"},{value:"pi",label:"Grok"}],ss=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"XHigh"}],ts=[{value:"new",label:"New session",hint:"Start a fresh harness session for this agent"},{value:"existing",label:"Continue session",hint:"Resume this agent’s current harness session"}];function me(s){return`gh pr checkout ${s.number}`}function ns(s){return[`Please review pull request #${s.number}: ${s.title}`,"",`URL: ${s.url}`,`Repo: ${s.repo}`,`Branch: ${s.headRefName||"head"} → ${s.baseRefName||"base"}`,s.path?`Local path: ${s.path}`:null,s.author?`Author: @${s.author}`:null,s.isDraft?"Status: draft":"Status: open","","Read the diff, summarize the change, call out risks or test gaps, and recommend ship / revise / hold."].filter(n=>n!=null).join(`
1
+ import{r as u,j as e}from"./index-o4FKpU7Z.js";import{E as se}from"./EmptyState-BUvllvA6.js";import{u as We}from"./ContextMenu-CxkmFQcN.js";import{f as he,b as qe}from"./api-BkjHJfgJ.js";import{a as _e}from"./api-h5zurxmi.js";import{c as te}from"./clipboard-e3fSpeo7.js";import{u as Be}from"./keyboard-nav-Chf51dns.js";/* empty css */import{f as w,c as He,b as Ce,r as Ee,u as Pe,i as ie,w as Ae,k as Ie,l as Ue,m as G,a as X,s as Ke,h as Ve}from"./ui-LM8pS8qE.js";import{B as Me,p as ze,c as Ge}from"./selection-bridge-SlGsgHw2.js";import{S as Xe}from"./SlidePanel-CuTeirnk.js";import{R as Ye}from"./RepoDiffViewerLazy-BPg_JkYW.js";import{p as Je}from"./cache-Dr0why2k.js";import{u as Qe}from"./Provider-DKZWuzSR.js";import{R as Ze}from"./refresh-cw-B5To7b6B.js";import{S as es}from"./sliders-horizontal-D2Z8gz6J.js";/* empty css */import"./provider-BvAxRQfE.js";import"./router-C65cZYPn.js";import"./synthetic-agent-routing-aduMYO7P.js";import"./terminal-sessions-AmSgHklm.js";import"./sse-CL6gctHY.js";import"./index-BWHgHrtv.js";import"./surface-activity-B1rgWB1i.js";import"./colors-BtO5_zlx.js";import"./scoutbot-BTIErYHo.js";import"./DocumentFocusViewer-DRKjNG9s.js";import"./createLucideIcon-Bt67PWH-.js";import"./TextDocumentSurface-Bc-kHPgG.js";/* empty css */import"./file-text-iF0hyVyU.js";import"./x-ynOfVadO.js";import"./chevron-right-C10o7t_X.js";import"./code-xml-CLn3TDWF.js";import"./arrow-left-BOht-YQu.js";import"./scout-voice-B7kXlkcl.js";import"./fx-z37u1o2z.js";import"./MessageComposerSuggestions-Dfc3PH2y.js";import"./NewChatComposer-S08F6_La.js";import"./runtime-picker-eDEvx2Mz.js";import"./voice-levels-Dcr3jglk.js";import"./loader-circle-4LDsy4Ke.js";import"./index-BMwKgdz_.js";import"./HarnessMark-MztYnrGK.js";import"./conversation-model-CHwHZNw-.js";import"./time-Dhsh_2EG.js";import"./NewChatOrigin-BEz6jyqf.js";import"./model-Co0zkMIc.js";import"./text-DsBWV_4k.js";import"./chevron-down-NAhBUkFd.js";import"./search-7_n7CxWl.js";import"./chunk-HRAB3GC3-DF8R9rPv.js";const pe=[{value:"claude",label:"Claude"},{value:"codex",label:"Codex"},{value:"pi",label:"Grok"}],ss=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"XHigh"}],ts=[{value:"new",label:"New session",hint:"Start a fresh harness session for this agent"},{value:"existing",label:"Continue session",hint:"Resume this agent’s current harness session"}];function me(s){return`gh pr checkout ${s.number}`}function ns(s){return[`Please review pull request #${s.number}: ${s.title}`,"",`URL: ${s.url}`,`Repo: ${s.repo}`,`Branch: ${s.headRefName||"head"} → ${s.baseRefName||"base"}`,s.path?`Local path: ${s.path}`:null,s.author?`Author: @${s.author}`:null,s.isDraft?"Status: draft":"Status: open","","Read the diff, summarize the change, call out risks or test gaps, and recommend ship / revise / hold."].filter(n=>n!=null).join(`
2
2
  `)}function Q(s){return s.handle?.trim()||s.name?.trim()||s.id}function fe(s,n){const t=s?.trim(),r=n?.trim();return!t||!r?!1:t===r||t.startsWith(`${r}/`)||r.startsWith(`${t}/`)}function rs(s){switch(s?.trim().toLowerCase()){case"available":case"idle":case"callable":return 40;case"active":case"working":case"running":case"in_turn":case"in_flight":return 20;case"queued":case"waiting":case"waking":return 10;case"offline":case"retired":case"stale":case"blocked":return-50;default:return 0}}function as(s,n,t){const r=t?.trim()||s.path?.trim()||null,a=s.repo.split("/").pop()?.toLowerCase()??"",i=s.headRefName?.trim()??"";return n.filter(o=>!o.retiredFromFleet).map(o=>{let c=rs(o.state);return(fe(o.projectRoot,r)||fe(o.cwd,r))&&(c+=1e3),a&&o.project?.trim().toLowerCase()===a&&(c+=400),i&&o.branch?.trim()===i&&(c+=200),{agent:o,score:c}}).sort((o,c)=>c.score!==o.score?c.score-o.score:Q(o.agent).localeCompare(Q(c.agent))).map(o=>o.agent)}function ge(s,n){const t=new Map,r=s.path?.trim();if(r){const a=r.split("/").filter(Boolean).at(-1)??r;t.set(r,s.repo||a)}for(const a of n){const i=a.root?.trim();i&&(t.has(i)||t.set(i,a.name?.trim()||i.split("/").filter(Boolean).at(-1)||i))}return[...t.entries()].map(([a,i])=>({path:a,label:i}))}function ne(s,n){return s?.harness?.trim()||n?.trim()||"claude"}function is(s){return s?.model?.trim()||""}function ls(s,n){const t=new Set,r=n?.model?.trim();r&&t.add(r);for(const a of s){const i=a.model?.trim();i&&t.add(i)}return[...t]}function os(s){const n=s.harness?.trim()||void 0,t=s.model?.trim()||void 0,r=s.reasoningEffort?.trim()||void 0;return{...n?{harness:n}:{},...t?{model:t}:{},...r?{reasoningEffort:r}:{}}}async function cs(s,n){const t=ns(s),r=n.projectPath.trim();if(!r)throw new Error("Pick a project path for the review.");const a=os(n),i=n.agent??null,o=i&&n.sessionMode==="existing"?"existing":"new";if(i&&o==="existing"&&!i.harnessSessionId?.trim())throw new Error(`@${Q(i)} has no live harness session to continue. Pick “New session” instead.`);const c=await _e("/api/sessions",{method:"POST",body:JSON.stringify({target:i?{agentId:i.id,projectPath:r}:{projectPath:r},execution:{session:o,...o==="existing"&&i?.harnessSessionId?.trim()?{targetSessionId:i.harnessSessionId.trim()}:{},...a},agent:{persistence:i?"sticky":"one_time",...i?.handle?.trim()?{handle:i.handle.trim()}:{}},seed:{instructions:t}})}),h=c.flightId??c.flight?.id??null,p=c.targetAgentId??c.flight?.targetAgentId??c.agentId??i?.id??null,d=c.targetLabel?.trim()||(i?Q(i):null)||p||"one-time reviewer",m=i?o==="existing"?"continue":"new session":"one-time";return{message:[`Assigned #${s.number} for review → ${d.startsWith("@")?d:`@${d}`}`,`· ${m}`,a.harness?`· ${a.harness}`:null,a.model?`· ${a.model}`:null,a.reasoningEffort?`· ${a.reasoningEffort}`:null,h?`· ${h}`:null].filter(Boolean).join(" "),flightId:h,conversationId:c.conversationId??null,targetAgentId:p,targetLabel:d}}function ds(s){window.open(s.url,"_blank","noopener,noreferrer")}function us(s,n={}){const{matchingWorktree:t,onBeginAssign:r,onSelectWorktreeId:a,onOpenDiff:i,onStatus:o}=n,c=[];return r&&c.push({kind:"action",label:"Assign for review…",onSelect:()=>r(s)}),c.push({kind:"action",label:"Open on GitHub",onSelect:()=>ds(s)}),t&&a&&c.push({kind:"action",label:`Select worktree · ${t.branch}`,onSelect:()=>a(t.id)}),t&&i&&c.push({kind:"action",label:"Open local diff",onSelect:()=>i(t.path)}),c.push({kind:"separator"},{kind:"action",label:"Copy link",onSelect:()=>{te(s.url).then(h=>{o?.(h?`Copied link for #${s.number}`:`Could not copy link for #${s.number}`)})}},{kind:"action",label:"Copy checkout command",onSelect:()=>{te(me(s)).then(h=>{o?.(h?`Copied: ${me(s)}`:`Could not copy checkout command for #${s.number}`)})}},{kind:"action",label:"Copy title",onSelect:()=>{te(`#${s.number} ${s.title}`).then(h=>{o?.(h?`Copied title for #${s.number}`:`Could not copy title for #${s.number}`)})}}),c}function hs(s){return s.startsWith("/Users/")?`~/${s.split("/").slice(3).join("/")}`:s}function ps(s){const n=s.handle?.trim()||s.name?.trim()||s.id,t=[s.harness?.trim(),s.model?.trim(),s.state?.trim(),s.harnessSessionId?.trim()?"session":null].filter(Boolean);return t.length>0?`@${n} · ${t.join(" · ")}`:`@${n}`}function Y(s){const n=s?.trim();return n?n.length>18?`${n.slice(0,10)}…${n.slice(-4)}`:n:null}function ms({pr:s,agents:n,projects:t,pending:r,error:a,onClose:i,onPendingChange:o,onError:c,onAssigned:h}){const p=Be(),d=u.useMemo(()=>ge(s,t),[s,t]),[m,b]=u.useState(()=>d[0]?.path??s.path?.trim()??""),[S,A]=u.useState(""),P=u.useMemo(()=>as(s,n,m),[n,s,m]),f=P.find(l=>l.id===S)??null,x=!!f?.harnessSessionId?.trim(),[C,I]=u.useState(()=>ne(null)),[R,O]=u.useState(""),[j,y]=u.useState("medium"),[N,$]=u.useState("new");u.useEffect(()=>{const v=ge(s,t)[0]?.path??s.path?.trim()??"";b(v),A(""),I(ne(null)),O(""),y("medium"),$("new"),c(null)},[s.id]),u.useEffect(()=>{m&&d.some(l=>l.path===m)||b(d[0]?.path??s.path?.trim()??"")},[s.path,d,m]),u.useEffect(()=>{if(!f){$("new");return}I(ne(f)),O(is(f)),$(f.harnessSessionId?.trim()?"existing":"new")},[f?.id]),u.useEffect(()=>{S&&(P.some(l=>l.id===S)||A(""))},[S,P]),u.useEffect(()=>{N==="existing"&&f&&!x&&$("new")},[x,f,N]);const T=u.useMemo(()=>ls(P,f),[P,f]),D=!!m.trim()&&!r&&!(f&&N==="existing"&&!x),W=async()=>{if(D){o(!0),c(null);try{const l=await cs(s,{projectPath:m.trim(),harness:C,model:R,reasoningEffort:j,agent:f,sessionMode:f?N:"new"});h(l)}catch(l){c(l instanceof Error?l.message:String(l))}finally{o(!1)}}},F=r?"Assigning…":f?N==="existing"?"Continue session · review":"New session · review":"Start review",M=f?N==="existing"?`Continues @${f.handle?.trim()||f.name}'s current session${Y(f.harnessSessionId)?` (${Y(f.harnessSessionId)})`:""}.`:`Starts a fresh harness session for @${f.handle?.trim()||f.name}.`:"Starts a disposable one-time reviewer on the project with the runtime above.";return e.jsx("div",{className:"rw-pr-assign-backdrop",role:"presentation",onMouseDown:l=>{l.target===l.currentTarget&&!r&&i()},children:e.jsxs("div",{ref:p.ref,className:"rw-pr-assign-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rw-pr-assign-title",tabIndex:-1,onKeyDown:l=>{p.onKeyDown(l),l.key==="Escape"&&!r&&(l.stopPropagation(),i())},children:[e.jsxs("div",{className:"rw-pr-assign-head",children:[e.jsxs("div",{children:[e.jsx("div",{className:"rw-pr-assign-eyebrow",children:"Assign for review"}),e.jsxs("h2",{id:"rw-pr-assign-title",className:"rw-pr-assign-title",children:["#",s.number," · launch review"]}),e.jsx("p",{className:"rw-pr-assign-copy",title:s.title,children:s.title}),e.jsxs("p",{className:"rw-pr-assign-meta",children:[s.repo," · ",s.headRefName||"head"," → ",s.baseRefName||"base"]})]}),e.jsx("button",{type:"button",className:"rw-pr-assign-close",onClick:i,disabled:r,children:"Cancel"})]}),e.jsxs("div",{className:"rw-pr-assign-body",children:[e.jsxs("div",{className:"rw-pr-assign-fields",children:[e.jsxs("label",{className:"rw-pr-assign-field",children:[e.jsx("span",{children:"Project"}),e.jsx("select",{value:m,disabled:r||d.length===0,onChange:l=>b(l.target.value),"aria-label":"Project path",children:d.length===0?e.jsx("option",{value:"",children:"No local project"}):d.map(l=>e.jsxs("option",{value:l.path,children:[l.label," · ",hs(l.path)]},l.path))})]}),e.jsxs("label",{className:"rw-pr-assign-field",children:[e.jsx("span",{children:"Harness"}),e.jsxs("select",{value:C,disabled:r,onChange:l=>I(l.target.value),"aria-label":"Harness",children:[pe.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value)),C&&!pe.some(l=>l.value===C)?e.jsx("option",{value:C,children:C}):null]})]}),e.jsxs("label",{className:"rw-pr-assign-field",children:[e.jsx("span",{children:"Model"}),e.jsx("input",{list:"rw-pr-assign-models",value:R,disabled:r,placeholder:"Default for harness",onChange:l=>O(l.target.value),"aria-label":"Model"}),e.jsx("datalist",{id:"rw-pr-assign-models",children:T.map(l=>e.jsx("option",{value:l},l))})]}),e.jsxs("label",{className:"rw-pr-assign-field",children:[e.jsx("span",{children:"Effort"}),e.jsx("select",{value:j,disabled:r,onChange:l=>y(l.target.value),"aria-label":"Reasoning effort",children:ss.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))})]}),e.jsxs("label",{className:"rw-pr-assign-field rw-pr-assign-field--wide",children:[e.jsxs("span",{children:["Agent ",e.jsx("em",{children:"(optional)"})]}),e.jsxs("select",{value:S,disabled:r,onChange:l=>A(l.target.value),"aria-label":"Existing agent (optional)",children:[e.jsx("option",{value:"",children:"New one-time reviewer on project"}),P.map(l=>e.jsx("option",{value:l.id,children:ps(l)},l.id))]})]}),f?e.jsxs("fieldset",{className:"rw-pr-assign-session",disabled:r,children:[e.jsx("legend",{children:"Session"}),e.jsx("div",{className:"rw-pr-assign-session-choices",role:"radiogroup","aria-label":"Session mode",children:ts.map(l=>{const v=l.value==="existing"&&!x,L=N===l.value;return e.jsxs("button",{type:"button",role:"radio","aria-checked":L,className:"rw-pr-assign-session-choice","data-active":L||void 0,disabled:v,title:v?"This agent has no live harness session to continue":l.hint,onClick:()=>$(l.value),children:[e.jsx("span",{className:"rw-pr-assign-session-title",children:l.label}),e.jsx("span",{className:"rw-pr-assign-session-sub",children:v?"No live session on this agent":l.value==="existing"&&Y(f.harnessSessionId)?Y(f.harnessSessionId):l.hint})]},l.value)})})]}):null]}),e.jsx("p",{className:"rw-pr-assign-hint",children:M}),a?e.jsx("div",{className:"rw-pr-assign-error",role:"alert",children:a}):null,e.jsx("div",{className:"rw-pr-assign-actions",children:e.jsx("button",{type:"button",className:"rw-pr-assign-submit",disabled:!D,onClick:()=>{W()},children:F})})]})]})})}const fs=/^Skipped missing repo-watch path:\s*(.+)$/i,gs=4;function js(s){const n=s.trim().replace(/\/+$/,"")||s.trim();if(!n)return"unknown paths";if(n==="~"||n.startsWith("~/"))return"~/*";if(!n.startsWith("/")){const[r]=n.split(/[\\/]/).filter(Boolean);return r?`${r}/*`:n}const t=n.split("/").filter(Boolean);return t[0]==="Users"&&t[1]?`/Users/${t[1]}/*`:t[0]==="Volumes"&&t[1]?`/Volumes/${t[1]}/*`:t.length>=2?`/${t[0]}/${t[1]}/*`:`/${t[0]??""}`}function xs(s,n){const t=[...new Set(s)];if(t.length===1)return{message:`Skipped missing repo-watch path: ${t[0]}`,examples:[],rawCount:1};const r=t.slice(0,gs),a=t.length-r.length;return a>0&&r.push(`+${a} more`),{message:`Skipped ${t.length} missing repo-watch paths under ${n}. These look like stale broker hints.`,examples:r,rawCount:t.length}}function je(s,n){if(s.length===0)return;const t=new Map;for(const r of s){const a=js(r),i=t.get(a);i?i.push(r):t.set(a,[r])}for(const[r,a]of t)n.push(xs(a,r));s.length=0}function bs(s){const n=[],t=[];for(const r of s){const a=fs.exec(r);if(a){t.push(a[1].trim());continue}je(t,n),n.push({message:r,examples:[],rawCount:1})}return je(t,n),n}const xe={attention:"desc",name:"asc",churn:"desc",files:"desc",drift:"desc",attached:"desc"},be="attention";function ws(s){return!s.status.clean||s.branch.ahead>0||s.branch.behind>0||s.agents.some(ie)||s.sessions.length>0||s.error!=null}function vs(s,n){const t=He(s),r=Ce(s),{add:a,del:i,total:o}=Ee(s),c=Pe(s);return{wt:s,project:n,state:Ae(s),add:a,del:i,churn:o,files:r.files+Math.max(t.files,s.status.changedFiles),live:c.filter(ie).length,agentsUnique:c}}function Te(s){return s.status.conflicts>0||s.error!=null}function Ns(s){const n=s.flatMap(i=>i.worktrees.filter(Te).map(o=>{const c=o.branch.name??o.name;return o.status.conflicts>0?`${i.name}/${c}: ${w(o.status.conflicts)} conflict${o.status.conflicts===1?"":"s"}`:`${i.name}/${c}: scan error`})),t="Worktrees blocked by conflicts or scan errors.";if(n.length===0)return t;const r=n.slice(0,8),a=n.length-r.length;return[t,...r,a>0?`+${a} more`:null].filter(i=>!!i).join(`
3
3
  `)}function Ss({snapshot:s,selectedId:n,onSelect:t,onViewDiff:r,scanDepth:a,scanMorePending:i,onScanMore:o,openPullRequestCount:c,openPullRequestTitle:h}){const[p,d]=u.useState(be),[m,b]=u.useState(xe[be]),[S,A]=u.useState(!1),{liveRows:P,cleanRows:f,stats:x,blockedTitle:C}=u.useMemo(()=>{const j=[],y=[];let N=0,$=0,T=0;for(const F of s.projects)for(const M of F.worktrees){const l=vs(M,F);T+=l.files,l.live>0&&N++,Te(M)&&$++,(ws(M)?j:y).push(l)}const D=s.totals,W={repos:D.projects,worktrees:D.worktrees,dirtyWorktrees:D.dirtyWorktrees,changedFiles:T,live:N,blocked:$};return{liveRows:j,cleanRows:y,stats:W,blockedTitle:Ns(s.projects)}},[s.projects,s.totals]),I=u.useMemo(()=>{const j=Ms(P,p,m),y=new Map;for(const N of j){const $=y.get(N.project.id);$?$.push(N):y.set(N.project.id,[N])}return[...y.values()]},[P,p,m]);function R(j){j===p?b(y=>y==="asc"?"desc":"asc"):(d(j),b(xe[j]))}const O=P.length===0&&f.length===0;return e.jsxs("section",{className:"rw-table",children:[e.jsxs("div",{className:"rw-head",children:[e.jsxs("div",{className:"rw-head-top",children:[e.jsx("span",{className:"rw-eyebrow",children:"STATE OF REPOS"}),f.length>0?e.jsxs("button",{type:"button",className:"rw-clean",style:{marginLeft:"auto"},onClick:()=>A(j=>!j),"aria-pressed":S,children:[S?"hide":"show"," clean & idle (",f.length,")"]}):null]}),e.jsxs("div",{className:"stats",children:[e.jsx(U,{v:x.repos,k:"REPOS"}),x.worktrees>x.repos?e.jsx(U,{v:x.worktrees,k:"WORKTREES",title:`${w(x.worktrees)} worktrees across ${w(x.repos)} repos.`}):null,e.jsx(U,{v:x.changedFiles,k:"CHANGED",title:`${w(x.changedFiles)} changed files across ${w(x.dirtyWorktrees)} dirty worktree${x.dirtyWorktrees===1?"":"s"}.`}),x.live>0?e.jsx(U,{v:x.live,k:"WORKING",tone:"mint"}):null,(c??0)>0?e.jsx(U,{v:c??0,k:"OPEN PRS",tone:"amber",title:h??void 0}):null,x.blocked>0?e.jsx(U,{v:x.blocked,k:"BLOCKED",tone:"coral",title:C}):null]})]}),e.jsxs("div",{className:"tbl-wrap",children:[e.jsxs("div",{className:"tbl-head",children:[e.jsx(V,{label:"REPO / BRANCH · WORKTREE",k:"name",sortKey:p,dir:m,onSort:R}),e.jsx(V,{label:"CHURN",k:"churn",sortKey:p,dir:m,onSort:R,align:"r"}),e.jsx(V,{label:"FILES",k:"files",sortKey:p,dir:m,onSort:R,align:"c"}),e.jsx(V,{label:"DRIFT",k:"drift",sortKey:p,dir:m,onSort:R,align:"c"}),e.jsx(V,{label:"ATTACHED",k:"attached",sortKey:p,dir:m,onSort:R})]}),O?e.jsx("div",{className:"rw-empty",children:"No repositories discovered yet."}):I.map(j=>j.length>1?e.jsx(Rs,{group:j,selectedId:n,onSelect:t,onViewDiff:r},j[0].project.id):e.jsx(ae,{row:j[0],top:!0,selected:n===j[0].wt.id,onSelect:()=>t(j[0].wt.id),onViewDiff:r},j[0].wt.id)),S&&f.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"tbl-head",style:{position:"static"},children:e.jsxs("span",{children:["CLEAN & IDLE · ",f.length]})}),f.map(j=>e.jsx(ae,{row:j,top:!0,clean:!0,selected:n===j.wt.id,onSelect:()=>t(j.wt.id),onViewDiff:r},j.wt.id))]}):null,e.jsx(ks,{snapshot:s,scanDepth:a,scanMorePending:i,onScanMore:o})]})]})}function ks({snapshot:s,scanDepth:n,scanMorePending:t,onScanMore:r}){const a=ys(s),i=bs(s.warnings),o=i.reduce((c,h)=>c+h.rawCount,0);return e.jsxs("div",{className:"scan-coverage",children:[e.jsxs("div",{className:"scan-coverage-row",children:[e.jsx("b",{children:"SCAN"}),e.jsx("span",{className:"scan-main",children:a.summary}),a.canScanMore&&n==="standard"?e.jsx("button",{type:"button",onClick:r,disabled:t,children:t?"Scanning":"Scan more"}):e.jsx("span",{className:"scan-chip",children:n==="expanded"?"expanded":"standard"})]}),i.length>0?e.jsxs("details",{className:"scan-details",children:[e.jsxs("summary",{children:[w(i.length)," diagnostic group",i.length===1?"":"s",o!==i.length?` (${w(o)} raw)`:""]}),e.jsx("ul",{children:i.map((c,h)=>e.jsxs("li",{children:[e.jsx("span",{children:c.message}),c.examples.length>0?e.jsx("span",{className:"scan-detail-examples",children:c.examples.join(" · ")}):null]},`${h}:${c.message}`))})]}):null]})}function ys(s){let n=null,t=0,r=0,a=0,i=0,o=0,c=0;for(const p of s.warnings){const d=/limited discovery to (\d+) repositories/i.exec(p);if(d){n=`discovery capped at ${d[1]}`;continue}if(/limited .* to \d+ worktrees/i.test(p)){t++;continue}if(/skipped unreadable worktree/i.test(p)){r++;continue}if(/skipped missing repo-watch path/i.test(p)){a++;continue}if(/scan budget|stopped discovery|stopped scanning/i.test(p)){i++;continue}if(/could not resolve git common directory/i.test(p)){o++;continue}c++}const h=[`${w(s.totals.projects)} repo${s.totals.projects===1?"":"s"}`,`${w(s.totals.worktrees)} worktree${s.totals.worktrees===1?"":"s"}`];return n&&h.push(n),t&&h.push(`${w(t)} repo${t===1?"":"s"} at worktree cap`),r&&h.push(`${w(r)} unreadable worktree${r===1?"":"s"} skipped`),a&&h.push(`${w(a)} missing path${a===1?"":"s"}`),o&&h.push(`${w(o)} unresolved git dir${o===1?"":"s"}`),i&&h.push("scan budget reached"),c&&h.push(`${w(c)} other diagnostic${c===1?"":"s"}`),{summary:h.join(" · "),canScanMore:n!==null||t>0||i>0}}function Rs({group:s,selectedId:n,onSelect:t,onViewDiff:r}){const a=s[0].project,i=s.some(p=>p.state==="error"),o=s.reduce((p,d)=>p+d.add,0),c=s.reduce((p,d)=>p+d.del,0),h=s.reduce((p,d)=>p+(d.live?1:0),0);return e.jsxs("div",{children:[e.jsxs("div",{className:"repo-grp"+(i?" attn":""),children:[e.jsxs("div",{className:"rg-name",children:[e.jsx("span",{className:"rg-tw","aria-hidden":!0,children:e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 11 11",fill:"none",style:{transform:"rotate(90deg)"},children:e.jsx("path",{d:"M3 2l4 3.5L3 9",stroke:"currentColor",strokeWidth:"1.3",fill:"none"})})}),e.jsx("span",{className:"dot "+Is(s)}),e.jsx("span",{className:"rg-nm",children:a.name}),e.jsx("span",{className:"rg-path",children:Ie(a.root,3)}),e.jsxs("span",{className:"rg-badge",children:[a.worktrees.length," worktrees"]})]}),e.jsx("div",{className:"rg-agg",children:o||c?e.jsxs("span",{children:[e.jsxs("span",{style:{color:"var(--mint-dim)"},children:["+",w(o)]})," ",e.jsxs("span",{style:{color:"var(--coral-dim)"},children:["−",w(c)]})]}):"—"}),e.jsx("div",{}),e.jsx("div",{}),e.jsx("div",{className:"rg-agg",style:{textAlign:"left"},children:h?`${h} working`:""})]}),s.map((p,d)=>e.jsx(ae,{row:p,guide:!0,last:d===s.length-1,selected:n===p.wt.id,onSelect:()=>t(p.wt.id),onViewDiff:r},p.wt.id))]})}function ae({row:s,top:n,guide:t,last:r,clean:a,selected:i,onSelect:o,onViewDiff:c}){const{wt:h,project:p}=s,d=h.branch,m=Ce(h),b=!!c&&(s.files>0||m.has||h.branch.ahead>0);return e.jsx(e.Fragment,{children:e.jsxs("div",{className:["wt",i?"sel":"",s.state==="error"?"attn":""].join(" "),style:n&&!a?{borderTop:"1px solid var(--line)"}:void 0,onClick:o,role:"button",tabIndex:0,onKeyDown:o?S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),o())}:void 0,children:[e.jsxs("div",{className:"wt-name",children:[t?e.jsx("span",{className:"tw-guide"+(r?" last":"")}):null,e.jsxs("div",{className:"inner",children:[e.jsx("span",{className:"dot "+s.state}),e.jsxs("span",{className:"br",children:[n&&!t?e.jsxs("span",{className:"lead",children:[p.name,"  "]}):null,e.jsx(Me,{branch:h.branch,fallback:h.name})]}),e.jsx(As,{wt:h})]})]}),e.jsx($s,{add:s.add,del:s.del}),e.jsx("div",{className:"files",children:s.files>0?e.jsxs("span",{children:[s.files,h.status.conflicts>0?e.jsxs("span",{className:"conf",children:[" ⚠",h.status.conflicts]}):null]}):e.jsx("span",{className:"dash",children:"—"})}),e.jsx(Cs,{ahead:d.ahead,behind:d.behind}),e.jsxs("div",{className:"agents-cell",children:[e.jsx(Ps,{row:s}),b?e.jsx("button",{type:"button",className:"wt-diff",title:`View diff · ${s.files} changed file${s.files===1?"":"s"}`,"aria-label":"View diff",onClick:S=>{S.stopPropagation(),c?.(h.path)},children:"diff"}):null]})]})})}function U({v:s,k:n,tone:t,title:r}){return e.jsxs("div",{className:"stat",title:r,"aria-label":r?`${w(s)} ${n}. ${r}`:void 0,children:[e.jsx("span",{className:"v"+(t?" "+t:""),children:w(s)}),e.jsx("span",{className:"k",children:n})]})}function V({label:s,k:n,sortKey:t,dir:r,onSort:a,align:i}){const o=t===n;return e.jsx("div",{className:i==="r"?"r":i==="c"?"c":"",children:e.jsxs("button",{type:"button",className:o?"on":"",onClick:()=>a(n),children:[e.jsx("span",{children:s}),e.jsx("span",{className:"caret","aria-hidden":!0,children:r==="asc"?"▲":"▼"})]})})}function $s({add:s,del:n}){if(!s&&!n)return e.jsx("div",{className:"churn",children:e.jsx("span",{className:"dash",children:"—"})});const t=s+n||1;return e.jsxs("div",{className:"churn",children:[e.jsxs("span",{className:"nums",children:[e.jsxs("span",{className:"add",children:["+",w(s)]}),e.jsx("span",{className:"sl",children:"/"}),e.jsxs("span",{className:"del",children:["−",w(n)]})]}),e.jsxs("span",{className:"cbar",title:`+${w(s)} −${w(n)}`,children:[e.jsx("span",{className:"g",style:{width:s/t*100+"%"}}),e.jsx("span",{className:"r",style:{width:n/t*100+"%"}})]})]})}function Cs({ahead:s,behind:n}){return!s&&!n?e.jsx("div",{className:"drift",children:e.jsx("span",{className:"dash",children:"—"})}):e.jsxs("div",{className:"drift",children:[s?e.jsxs("span",{className:"dp ahead",children:["↑",s]}):null,n?e.jsxs("span",{className:"dp behind",children:["↓",n]}):null]})}const Es=2;function Ps({row:s}){const n=s.agentsUnique,t=s.wt.sessions,r=[...n.map(o=>`${X(o)} (${o.state??"—"})`),...t.map(o=>`session ${Ke(o)}`)].join(`
4
4
  `);if(n.length===0)return e.jsx("div",{className:"agents",title:r,children:t.length>0?e.jsxs("span",{className:"ahandle",children:[t.length," session",t.length===1?"":"s"]}):e.jsx("span",{className:"dash",children:"—"})});const a=n.slice(0,Es),i=n.length-a.length;return e.jsxs("div",{className:"agents",title:r,children:[s.live>0?e.jsxs("span",{className:"alive",children:[e.jsx("span",{className:"d"}),s.live]}):null,e.jsx("span",{className:"ahandle",children:a.map(o=>X(o)).join(" ")}),i>0?e.jsxs("span",{className:"amore",children:["+",i]}):null]})}function As({wt:s}){const n=[];return s.branch.detached?n.push({label:"DETACHED",cls:""}):s.branch.upstream||n.push({label:"LOCAL",cls:""}),s.error!=null&&n.push({label:"SCAN ERR",cls:"err"}),s.isBare&&n.push({label:"BARE",cls:""}),e.jsx(e.Fragment,{children:n.map(t=>e.jsx("span",{className:"tag "+t.cls,children:t.label},t.label))})}const we={error:3,live:2,dirty:1,clean:0};function Is(s){return s.reduce((n,t)=>we[t.state]>we[n]?t.state:n,"clean")}function Ms(s,n,t){const r=t==="asc"?1:-1,a=d=>{switch(n){case"attention":return-G(d.wt.attention);case"churn":return d.churn;case"files":return d.files;case"drift":return d.wt.branch.ahead+d.wt.branch.behind;case"attached":return d.live*1e6+d.agentsUnique.length*1e3+d.wt.sessions.length;default:return 0}},i=new Map;for(const d of s){const m=i.get(d.project.id);m?m.push(d):i.set(d.project.id,[d])}const o=(d,m)=>{if(n==="name")return Ue(d,m,r);const b=(a(d)-a(m))*r;if(b!==0)return b;const S=G(d.wt.attention)-G(m.wt.attention);return S!==0?S:d.wt.path.localeCompare(m.wt.path)},c=d=>d.reduce((m,b)=>Math.max(m,a(b)),-1/0),h=[...i.values()].sort((d,m)=>{if(n==="name")return d[0].project.name.localeCompare(m[0].project.name)*r;const b=(c(d)-c(m))*r;return b!==0?b:d[0].project.name.localeCompare(m[0].project.name)}),p=[];for(const d of h)p.push(...[...d].sort(o));return p}const J=8;function ve(s){if(s.error!=null)return 0;const{ahead:n,behind:t}=s.branch;return n>0&&t>0?1:t>0||n>0?2:3}function Ts(s){const n=(s.name??"").trim();if(n){const a=n.split(/[\s_\-/]+/).filter(Boolean);if(a.length>=2)return(a[0][0]+a[1][0]).toUpperCase();if(a.length===1)return a[0].slice(0,2).toUpperCase()}return(X(s).replace(/^@/,"").replace(/[^a-z0-9]/gi,"").slice(0,2)||"··").toUpperCase()}function Ds({snapshot:s,selectedId:n,onSelect:t}){return e.jsxs("section",{className:"bd",children:[e.jsx("div",{className:"bd-head",children:"BRANCH DRIFT — distance from each worktree's base · behind ← origin → ahead · flags call out what needs a rebase"}),e.jsxs("div",{className:"bd-axis",children:[e.jsx("div",{}),e.jsxs("div",{className:"bd-axis-track",children:[e.jsx("span",{className:"bd-axis-lbl",style:{left:"0%"},children:"−8"}),e.jsx("span",{className:"bd-axis-lbl",style:{left:"25%"},children:"−4"}),e.jsx("span",{className:"bd-axis-lbl bd-origin-lbl",style:{left:"50%"},children:"origin"}),e.jsx("span",{className:"bd-axis-lbl",style:{left:"75%"},children:"+4"}),e.jsx("span",{className:"bd-axis-lbl",style:{left:"100%"},children:"+8"}),e.jsx("span",{className:"bd-axis-cap",children:"COMMITS ←"})]}),e.jsx("div",{}),e.jsx("div",{}),e.jsx("div",{})]}),s.projects.map(r=>e.jsx(Ls,{project:r,selectedId:n,onSelect:t},r.id))]})}function Ls({project:s,selectedId:n,onSelect:t}){const r=[...s.worktrees].sort((a,i)=>ve(a)-ve(i));return e.jsxs("div",{className:"bd-grp",children:[e.jsxs("div",{className:"bd-grp-h",children:[e.jsx("span",{className:"bd-grp-nm",children:s.name}),e.jsx("span",{className:"bd-grp-path",children:Ie(s.root,3)})]}),r.map(a=>e.jsx(Os,{wt:a,selected:n===a.id,onSelect:()=>t(a.id)},a.id))]})}function Os({wt:s,selected:n,onSelect:t}){const r=Ae(s),{ahead:a,behind:i}=s.branch,o=s.error!=null,c=Pe(s);return e.jsxs("div",{className:["bd-row",n?"sel":""].join(" "),role:"button",tabIndex:0,onClick:t,onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),t())},children:[e.jsxs("div",{className:"bd-id",children:[e.jsx("span",{className:"dot "+r}),e.jsx("span",{className:"bd-br",children:e.jsx(Me,{branch:s.branch,fallback:s.name})})]}),e.jsx(Fs,{ahead:a,behind:i,hasError:o}),e.jsx(Ws,{wt:s,hasError:o}),e.jsx(_s,{agents:c}),e.jsx(Bs,{ahead:a,behind:i,hasError:o})]})}function Fs({ahead:s,behind:n,hasError:t}){const r=s===0&&n===0;return e.jsxs("div",{className:"bd-track",children:[e.jsx("span",{className:"bd-tick",style:{left:"0%"}}),e.jsx("span",{className:"bd-tick",style:{left:"25%"}}),e.jsx("span",{className:"bd-tick bd-tick-origin",style:{left:"50%"}}),e.jsx("span",{className:"bd-tick",style:{left:"75%"}}),e.jsx("span",{className:"bd-tick",style:{left:"100%"}}),t||r?e.jsx("span",{className:"bd-origin-ring"}):e.jsxs(e.Fragment,{children:[n>0?e.jsxs("span",{className:"bd-bar bd-behind",style:{right:"50%",width:Math.min(n,J)/J*50+"%"},children:[e.jsx("span",{className:"bd-cap bd-cap-l"}),e.jsxs("span",{className:"bd-lbl bd-lbl-l",children:["↓",n]})]}):null,s>0?e.jsxs("span",{className:"bd-bar bd-ahead",style:{left:"50%",width:Math.min(s,J)/J*50+"%"},children:[e.jsx("span",{className:"bd-cap bd-cap-r"}),e.jsxs("span",{className:"bd-lbl bd-lbl-r",children:["↑",s]})]}):null]})]})}function Ws({wt:s,hasError:n}){const{add:t,del:r,has:a}=Ee(s);if(n||!a)return e.jsx("div",{className:"bd-churn",children:e.jsx("span",{className:"dash",children:"—"})});const i=t+r||1;return e.jsxs("div",{className:"bd-churn",children:[e.jsxs("span",{className:"bd-churn-nums",children:[e.jsxs("span",{className:"add",children:["+",w(t)]}),e.jsx("span",{className:"sl",children:"/"}),e.jsxs("span",{className:"del",children:["−",w(r)]})]}),e.jsxs("span",{className:"bd-cbar",title:`+${w(t)} −${w(r)}`,children:[e.jsx("span",{className:"g",style:{width:t/i*100+"%"}}),e.jsx("span",{className:"r",style:{width:r/i*100+"%"}})]})]})}const qs=2;function _s({agents:s}){if(s.length===0)return e.jsx("div",{className:"bd-agents",children:e.jsx("span",{className:"dash",children:"—"})});const n=s.slice(0,qs),t=s.length-n.length;return e.jsxs("div",{className:"bd-agents",title:s.map(r=>`${X(r)} (${r.state??"—"})`).join(`
5
5
  `),children:[n.map(r=>e.jsx("span",{className:"bd-av"+(ie(r)?" live":""),children:Ts(r)},X(r))),t>0?e.jsxs("span",{className:"bd-av-more",children:["+",t]}):null]})}function Bs({ahead:s,behind:n,hasError:t}){return t?e.jsx("div",{className:"bd-flag err",children:"SCAN ERR"}):s>0&&n>0?e.jsx("div",{className:"bd-flag rebase",children:"DIVERGED ▸"}):n>0?e.jsx("div",{className:"bd-flag rebase",children:"REBASE ▸"}):s>0?e.jsxs("div",{className:"bd-flag ahead",children:["AHEAD ",s]}):e.jsx("div",{className:"bd-flag sync",children:"IN SYNC"})}const Hs=1e4,Us=15e3,Ks=45e3,Vs=45e3,zs="openscout.repos.tone",Ne=["warm","cool","mono"],Gs="openscout.repos.view",Se=["table","drift"],Xs=12;function Ys(s){return s.warnings.some(n=>/scan budget|stopped discovery|stopped scanning/i.test(n))}function Js(s,n){return s.totals.worktrees<n.totals.worktrees||s.totals.projects<n.totals.projects}function Qs(s){return s&&typeof s=="object"&&"name"in s&&s.name==="AbortError"?"Repo Watch scan timed out; keeping the last available snapshot.":s instanceof Error?s.message:String(s)}function ke(s,n,t){const[r,a]=u.useState(()=>{if(typeof window>"u")return t;try{const o=window.localStorage.getItem(s);return o&&n.includes(o)?o:t}catch{return t}}),i=u.useCallback(o=>{a(o);try{window.localStorage.setItem(s,o)}catch{}},[s]);return[r,i]}function ye(s){let n=null,t=-1/0;for(const r of s)for(const a of r.worktrees){const i=a.agents.filter(c=>(c.state??"").toLowerCase()==="active").length,o=(4-G(a.attention))*1e6+i*1e4+a.status.changedFiles;o>t&&(t=o,n=a)}return n}function Zs(s,n){if(!s||!n)return{worktree:null,project:null};for(const t of s.projects)for(const r of t.worktrees)if(r.id===n)return{worktree:r,project:t};return{worktree:null,project:null}}function re(s){if(!s)return 0;const n=/(\d+)\s+files?\s+changed/.exec(s);return n?Number(n[1]):0}function et(s){const n=new Set,t=[];for(const r of s.projects){const a=r.worktrees[0]?.path??r.root;!a||n.has(a)||(n.add(a),t.push(a))}return t}function st(s,n){if(!s)return"updated";const t=Date.parse(s);return Number.isFinite(t)?Ve(t,n):"updated"}function tt(s){const n=s?.pullRequests??[];if(n.length===0)return null;const t=n.slice(0,8).map(a=>`${a.repo}#${a.number}: ${a.title}`),r=n.length-t.length;return["Open pull requests from gh.",...t,r>0?`+${r} more`:null].filter(a=>!!a).join(`
6
- `)}function Re(s,n){return n?s.path===n.root||n.worktrees.some(r=>r.path===s.path)?!0:s.repo.split("/").pop()?.toLowerCase()===n.name.toLowerCase():!1}function $e(s,n){const t=n?.branch.name?.trim();return!!(t&&s.headRefName===t)}function nt(s,n){if(!n)return null;const t=s.headRefName?.trim();if(!t)return null;const r=[];for(const a of n.projects)for(const i of a.worktrees)i.branch.name?.trim()===t&&r.push({id:i.id,path:i.path,branch:t});if(r.length===0)return null;if(s.path){const a=r.find(i=>i.path===s.path);if(a)return a}return r[0]??null}function rt(s,n){const t=[];for(const r of s.projects)for(const a of r.worktrees){const i=a.status.staged+a.status.unstaged+a.status.untracked+a.status.conflicts,o=a.agents.filter(m=>(m.state??"").toLowerCase()==="active").length,c=re(a.diff.branchShortstat),h=Math.max(a.status.changedFiles,re(a.diff.stagedShortstat)+re(a.diff.unstagedShortstat)),p=a.branch.ahead+a.branch.behind,d=o+a.sessions.length;i===0&&d===0&&c===0&&p===0||t.push({path:a.path,score:(a.id===n?1e7:0)+(4-G(a.attention))*1e5+o*1e4+a.sessions.length*5e3+p*1e3+c*250+i*100+h})}return t.sort((r,a)=>a.score-r.score).map(r=>r.path)}function z({children:s}){return e.jsx("div",{className:"s-ops",children:e.jsx("div",{className:"s-ops-body",style:{overflowY:"auto"},children:s})})}function at({error:s}){return e.jsxs("div",{className:"rw-empty-next",children:[e.jsx("p",{className:"rw-empty-copy",children:"Repos is waiting on the local Scout Services layer. Restart the broker from the menu bar app, then rescan."}),e.jsxs("ol",{className:"rw-empty-steps",children:[e.jsxs("li",{children:["Click ",e.jsx("span",{className:"rw-empty-action-name",children:"Restart broker"})," to hand off to the menu bar app."]}),e.jsx("li",{children:"Wait for Scout Services to report the broker online."}),e.jsxs("li",{children:["If nothing opens, run ",e.jsx("code",{children:"scout doctor"})," and follow the repair command it prints."]})]}),s?e.jsx("p",{className:"rw-empty-error",children:s}):null]})}function it({snapshot:s,loading:n,error:t,selectedProject:r,selectedWorktree:a,repoSnapshot:i,onSelectWorktree:o,onOpenDiff:c,navigate:h}){const{agents:p}=Qe(),d=We(),[m,b]=u.useState(null),[S,A]=u.useState(null),[P,f]=u.useState(!1),[x,C]=u.useState(null),I=u.useRef(null),R=u.useCallback(l=>{b(l),I.current!=null&&window.clearTimeout(I.current),l&&(I.current=window.setTimeout(()=>b(null),6e3))},[]);u.useEffect(()=>()=>{I.current!=null&&window.clearTimeout(I.current)},[]);const O=u.useCallback(()=>{P||(A(null),C(null))},[P]),j=u.useMemo(()=>(i?.projects??[]).map(l=>({root:l.root,name:l.name})),[i]),y=s?.pullRequests??[],N=a?.branch.name??null,$=y.filter(l=>Re(l,r)),T=$.filter(l=>$e(l,a)),D=$.filter(l=>!$e(l,a)),W=y.filter(l=>!Re(l,r)),F=[T.length>0?{key:"branch",label:N?`Selected branch · ${N}`:"Selected branch",items:T}:null,D.length>0?{key:"project",label:r?`${r.name} PRs`:"Selected project",items:D}:null,W.length>0?{key:"other",label:$.length>0?"Other open PRs":"Open PRs",items:W}:null].filter(l=>!!l);if(!n&&!t&&y.length===0)return null;const M=(l,v)=>{l.preventDefault(),d(l,us(v,{matchingWorktree:nt(v,i),onBeginAssign:L=>{C(null),A(L)},onSelectWorktreeId:o,onOpenDiff:c,onStatus:R}))};return e.jsxs("section",{className:"rw-open-prs","aria-label":"Open pull requests",children:[e.jsxs("div",{className:"rw-open-prs-head",children:[e.jsxs("div",{children:[e.jsx("div",{className:"rw-open-prs-eyebrow",children:"Open PRs"}),e.jsx("div",{className:"rw-open-prs-title",children:n&&y.length===0?"Checking GitHub":`${y.length} open`}),m?e.jsx("div",{className:"rw-open-prs-status",role:"status",children:m}):null]}),s?e.jsx("span",{className:"rw-open-prs-meta",children:"gh"}):null]}),y.length>0?e.jsx("div",{className:"rw-open-prs-list",children:F.map(l=>e.jsxs("div",{className:"rw-open-pr-group",children:[F.length>1?e.jsx("div",{className:"rw-open-pr-group-label",children:l.label}):null,l.items.map(v=>e.jsxs("button",{type:"button",className:"rw-open-pr",title:`${v.title} — click for actions`,onClick:L=>M(L,v),onContextMenu:L=>M(L,v),children:[e.jsxs("span",{className:"rw-open-pr-main",children:[e.jsxs("span",{className:"rw-open-pr-number",children:["#",v.number]}),e.jsx("span",{className:"rw-open-pr-title",title:v.title,children:v.title})]}),e.jsxs("span",{className:"rw-open-pr-detail",children:[e.jsx("span",{children:v.repo}),e.jsxs("span",{children:[v.headRefName||"head"," → ",v.baseRefName||"base"]}),v.isDraft?e.jsx("span",{children:"draft"}):e.jsx("span",{children:"open"}),v.author?e.jsxs("span",{children:["@",v.author]}):null,e.jsx("span",{children:st(v.updatedAt,s?.generatedAt??Date.now())})]})]},v.id))]},l.key))}):e.jsx("div",{className:"rw-open-prs-empty",children:t??"No open pull requests returned."}),S?e.jsx(ms,{pr:S,agents:p,projects:j,pending:P,error:x,onClose:O,onPendingChange:f,onError:C,onAssigned:l=>{A(null),C(null),R(l.message),(l.flightId||l.conversationId||l.targetAgentId)&&h({view:"follow",...l.flightId?{flightId:l.flightId}:{},...l.conversationId?{conversationId:l.conversationId}:{},...l.targetAgentId?{targetAgentId:l.targetAgentId}:{}})}}):null]})}function rn({navigate:s,focusRoot:n=null}){const[t,r]=u.useState(null),[a,i]=u.useState("loading"),[o,c]=u.useState(null),h=u.useRef(!1),p=u.useRef(0),d=u.useRef(null),m=u.useRef(!1),[b,S]=ke(zs,Ne,"warm"),[A,P]=ke(Gs,Se,"table"),[f,x]=u.useState(null),[C,I]=u.useState("standard"),[R,O]=u.useState(!1),[j,y]=u.useState(null),[N,$]=u.useState(!1),[T,D]=u.useState(!1),[W,F]=u.useState(null),[M,l]=u.useState(null),[v,L]=u.useState(!1),[De,Z]=u.useState(null),[B,K]=u.useState(null),q=u.useCallback(async(g={})=>{if(m.current&&!g.force)return;m.current=!0;const k=g.depth??C;g.scanMore&&$(!0),g.force&&!g.scanMore&&O(!0);try{let E=await he(k,g.force??!1,k==="expanded"?Ks:Us),_=k;if(!h.current&&k==="standard"&&!g.force&&E.projects.length===0)try{const ue=await he("expanded",!0,Vs);ue.projects.length>0&&(E=ue,_="expanded")}catch{}const de=d.current;if(de&&Ys(E)&&(E.projects.length===0||Js(E,de))){c("Scan budget was reached; keeping the last fuller Repo Watch snapshot."),i("ready");return}if(!g.force&&E.projects.length===0&&h.current&&p.current<3){p.current+=1,i("ready");return}p.current=0,h.current=!0,d.current=E,r(E),c(null),i("ready"),(g.scanMore||_!==k)&&I(_),g.force&&!g.scanMore&&y(`Fresh ${new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}`)}catch(E){const _=Qs(E);c(_),h.current||i("error")}finally{g.scanMore&&$(!1),g.force&&!g.scanMore&&O(!1),m.current=!1}},[C]);u.useEffect(()=>{d.current=t},[t]),u.useEffect(()=>{q();const g=setInterval(()=>{q()},Hs);return()=>clearInterval(g)},[q]);const le=u.useRef(null);u.useEffect(()=>{if(!t)return;if(n&&le.current!==n){const k=t.projects.find(E=>E.root===n||E.worktrees.some(_=>_.path===n));if(!k)return;if(le.current=n,!k.worktrees.some(E=>E.id===f)){x(ye([k])?.id??null);return}}t.projects.some(k=>k.worktrees.some(E=>E.id===f))||x(ye(t.projects)?.id??null)},[t,f,n]),u.useEffect(()=>{!t||t.projects.length===0||Je(rt(t,f),void 0,{limit:Xs})},[t,f]);const ee=u.useMemo(()=>t?et(t):[],[t]),Le=ee.join("\0");u.useEffect(()=>{if(ee.length===0){l(null),Z(null),L(!1);return}let g=!1;return L(!0),Z(null),qe(ee).then(k=>{g||l(k)}).catch(k=>{g||Z(k instanceof Error?k.message:String(k))}).finally(()=>{g||L(!1)}),()=>{g=!0}},[Le]);const H=u.useMemo(()=>Zs(t,f),[t,f]),Oe=u.useMemo(()=>tt(M),[M]);u.useEffect(()=>{ze({worktree:H.worktree,project:H.project,generatedAt:t?.generatedAt??0,tone:b})},[H.worktree,H.project,t?.generatedAt,b]),u.useEffect(()=>Ge,[]);const oe=u.useCallback(()=>{q({depth:"expanded",force:!0,scanMore:!0})},[q]),ce=u.useCallback(()=>{q({force:!0})},[q]),Fe=u.useCallback(async()=>{if(!T){D(!0),F(null);try{const g=await fetch("/api/scout-services/restart-link",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({target:"broker"})});if(!g.ok)throw new Error(`Scout Services link failed (${g.status})`);const k=await g.json();if(!k.url?.startsWith("scout://services/restart/"))throw new Error("Scout Services link was not returned.");window.location.assign(k.url)}catch(g){const k=g instanceof Error?g.message:String(g);F(`${k} Run scout doctor if the menu app did not open.`)}finally{D(!1)}}},[T]);return a==="loading"?e.jsx(z,{navigate:s,children:e.jsx("div",{className:"repo-watch-scope",style:{padding:"24px"},children:e.jsx(se,{title:"Scanning repositories…",body:"Reading worktree state from the broker."})})}):a==="error"&&!t?e.jsx(z,{navigate:s,children:e.jsx("div",{className:"repo-watch-scope",style:{padding:"24px"},children:e.jsx(se,{className:"sys-state-card-error",title:"Couldn’t load Repo Watch",body:o??"The broker did not return a snapshot.",action:e.jsx("button",{type:"button",className:"s-btn",onClick:()=>{i("loading"),q()},children:"Retry"})})})}):t&&t.projects.length===0?e.jsx(z,{navigate:s,children:e.jsx("div",{className:"repo-watch-scope",style:{padding:"24px"},children:e.jsx(se,{title:"Scout Services need attention",body:e.jsx(at,{error:W}),action:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"s-btn s-btn-primary",onClick:()=>{Fe()},disabled:T,children:T?"Opening…":"Restart broker"}),e.jsx("button",{type:"button",className:"s-btn",onClick:ce,disabled:R||N,children:R?"Scanning…":"Scan again"}),e.jsx("button",{type:"button",className:"s-btn",onClick:oe,disabled:R||N,children:N?"Scanning…":"Scan more"})]})})})}):t?e.jsx(z,{navigate:s,children:e.jsxs("div",{className:"repo-watch-scope",children:[e.jsx("div",{className:"rw-scope tone-"+b,children:e.jsxs("div",{className:"rw-page-shell",children:[e.jsxs("div",{className:"rw-toolbar",children:[e.jsxs("button",{type:"button",className:"rw-refresh-main",onClick:ce,disabled:R||N,children:[e.jsx(Ze,{size:14,"aria-hidden":"true",className:R?"rw-refresh-spin":void 0}),e.jsx("span",{children:R?"Scanning":"Refresh"})]}),j?e.jsx("span",{className:"rw-refresh-receipt",children:j}):null,e.jsxs("details",{className:"rw-display-menu",children:[e.jsxs("summary",{"aria-label":"Display options",children:[e.jsx(es,{size:14,"aria-hidden":"true"}),e.jsx("span",{children:"Display"})]}),e.jsxs("div",{className:"rw-display-panel",children:[e.jsxs("div",{className:"rw-display-row",children:[e.jsx("span",{className:"rw-display-label",children:"View"}),e.jsx("div",{className:"rw-tone",role:"group","aria-label":"View",children:Se.map(g=>e.jsx("button",{type:"button",className:g===A?"on":"","aria-pressed":g===A,onClick:()=>P(g),children:g},g))})]}),e.jsxs("div",{className:"rw-display-row",children:[e.jsx("span",{className:"rw-display-label",children:"Tone"}),e.jsx("div",{className:"rw-tone",role:"group","aria-label":"Console tone",children:Ne.map(g=>e.jsx("button",{type:"button",className:g===b?"on":"","aria-pressed":g===b,onClick:()=>S(g),children:g},g))})]})]})]})]}),e.jsx("div",{className:"min-w-0",children:A==="drift"?e.jsx(Ds,{snapshot:t,selectedId:f,onSelect:x}):e.jsxs(e.Fragment,{children:[e.jsx(Ss,{snapshot:t,selectedId:f,onSelect:x,onViewDiff:K,scanDepth:C,scanMorePending:N,onScanMore:oe,openPullRequestCount:M?.pullRequests.length??null,openPullRequestTitle:Oe}),e.jsx(it,{snapshot:M,loading:v,error:De,selectedProject:H.project,selectedWorktree:H.worktree,repoSnapshot:t,onSelectWorktree:x,onOpenDiff:K,navigate:s})]})})]})}),e.jsx(Xe,{open:B!=null,onClose:()=>K(null),side:"right",owner:"openscout.repos-diff-viewer",resizable:!0,defaultSize:840,maxSize:1280,minSize:420,ariaLabel:"Worktree diff",children:B!=null?e.jsx(Ye,{path:B,onClose:()=>K(null),onOpenAsPage:()=>{B&&(s({view:"repo-diff",path:B}),K(null))}},B):null})]})}):e.jsx(z,{navigate:s})}export{rn as ReposScreen,rn as default};
6
+ `)}function Re(s,n){return n?s.path===n.root||n.worktrees.some(r=>r.path===s.path)?!0:s.repo.split("/").pop()?.toLowerCase()===n.name.toLowerCase():!1}function $e(s,n){const t=n?.branch.name?.trim();return!!(t&&s.headRefName===t)}function nt(s,n){if(!n)return null;const t=s.headRefName?.trim();if(!t)return null;const r=[];for(const a of n.projects)for(const i of a.worktrees)i.branch.name?.trim()===t&&r.push({id:i.id,path:i.path,branch:t});if(r.length===0)return null;if(s.path){const a=r.find(i=>i.path===s.path);if(a)return a}return r[0]??null}function rt(s,n){const t=[];for(const r of s.projects)for(const a of r.worktrees){const i=a.status.staged+a.status.unstaged+a.status.untracked+a.status.conflicts,o=a.agents.filter(m=>(m.state??"").toLowerCase()==="active").length,c=re(a.diff.branchShortstat),h=Math.max(a.status.changedFiles,re(a.diff.stagedShortstat)+re(a.diff.unstagedShortstat)),p=a.branch.ahead+a.branch.behind,d=o+a.sessions.length;i===0&&d===0&&c===0&&p===0||t.push({path:a.path,score:(a.id===n?1e7:0)+(4-G(a.attention))*1e5+o*1e4+a.sessions.length*5e3+p*1e3+c*250+i*100+h})}return t.sort((r,a)=>a.score-r.score).map(r=>r.path)}function z({children:s}){return e.jsx("div",{className:"s-ops",children:e.jsx("div",{className:"s-ops-body",style:{overflowY:"auto"},children:s})})}function at({error:s}){return e.jsxs("div",{className:"rw-empty-next",children:[e.jsx("p",{className:"rw-empty-copy",children:"Repos is waiting on the local Scout Services layer. Restart the broker from the menu bar app, then rescan."}),e.jsxs("ol",{className:"rw-empty-steps",children:[e.jsxs("li",{children:["Click ",e.jsx("span",{className:"rw-empty-action-name",children:"Restart broker"})," to hand off to the menu bar app."]}),e.jsx("li",{children:"Wait for Scout Services to report the broker online."}),e.jsxs("li",{children:["If nothing opens, run ",e.jsx("code",{children:"scout doctor"})," and follow the repair command it prints."]})]}),s?e.jsx("p",{className:"rw-empty-error",children:s}):null]})}function it({snapshot:s,loading:n,error:t,selectedProject:r,selectedWorktree:a,repoSnapshot:i,onSelectWorktree:o,onOpenDiff:c,navigate:h}){const{agents:p}=Qe(),d=We(),[m,b]=u.useState(null),[S,A]=u.useState(null),[P,f]=u.useState(!1),[x,C]=u.useState(null),I=u.useRef(null),R=u.useCallback(l=>{b(l),I.current!=null&&window.clearTimeout(I.current),l&&(I.current=window.setTimeout(()=>b(null),6e3))},[]);u.useEffect(()=>()=>{I.current!=null&&window.clearTimeout(I.current)},[]);const O=u.useCallback(()=>{P||(A(null),C(null))},[P]),j=u.useMemo(()=>(i?.projects??[]).map(l=>({root:l.root,name:l.name})),[i]),y=s?.pullRequests??[],N=a?.branch.name??null,$=y.filter(l=>Re(l,r)),T=$.filter(l=>$e(l,a)),D=$.filter(l=>!$e(l,a)),W=y.filter(l=>!Re(l,r)),F=[T.length>0?{key:"branch",label:N?`Selected branch · ${N}`:"Selected branch",items:T}:null,D.length>0?{key:"project",label:r?`${r.name} PRs`:"Selected project",items:D}:null,W.length>0?{key:"other",label:$.length>0?"Other open PRs":"Open PRs",items:W}:null].filter(l=>!!l);if(!n&&!t&&y.length===0)return null;const M=(l,v)=>{l.preventDefault(),d(l,us(v,{matchingWorktree:nt(v,i),onBeginAssign:L=>{C(null),A(L)},onSelectWorktreeId:o,onOpenDiff:c,onStatus:R}))};return e.jsxs("section",{className:"rw-open-prs","aria-label":"Open pull requests",children:[e.jsxs("div",{className:"rw-open-prs-head",children:[e.jsxs("div",{children:[e.jsx("div",{className:"rw-open-prs-eyebrow",children:"Open PRs"}),e.jsx("div",{className:"rw-open-prs-title",children:n&&y.length===0?"Checking GitHub":`${y.length} open`}),m?e.jsx("div",{className:"rw-open-prs-status",role:"status",children:m}):null]}),s?e.jsx("span",{className:"rw-open-prs-meta",children:"gh"}):null]}),y.length>0?e.jsx("div",{className:"rw-open-prs-list",children:F.map(l=>e.jsxs("div",{className:"rw-open-pr-group",children:[F.length>1?e.jsx("div",{className:"rw-open-pr-group-label",children:l.label}):null,l.items.map(v=>e.jsxs("button",{type:"button",className:"rw-open-pr",title:`${v.title} — click for actions`,onClick:L=>M(L,v),onContextMenu:L=>M(L,v),children:[e.jsxs("span",{className:"rw-open-pr-main",children:[e.jsxs("span",{className:"rw-open-pr-number",children:["#",v.number]}),e.jsx("span",{className:"rw-open-pr-title",title:v.title,children:v.title})]}),e.jsxs("span",{className:"rw-open-pr-detail",children:[e.jsx("span",{children:v.repo}),e.jsxs("span",{children:[v.headRefName||"head"," → ",v.baseRefName||"base"]}),v.isDraft?e.jsx("span",{children:"draft"}):e.jsx("span",{children:"open"}),v.author?e.jsxs("span",{children:["@",v.author]}):null,e.jsx("span",{children:st(v.updatedAt,s?.generatedAt??Date.now())})]})]},v.id))]},l.key))}):e.jsx("div",{className:"rw-open-prs-empty",children:t??"No open pull requests returned."}),S?e.jsx(ms,{pr:S,agents:p,projects:j,pending:P,error:x,onClose:O,onPendingChange:f,onError:C,onAssigned:l=>{A(null),C(null),R(l.message),(l.flightId||l.conversationId||l.targetAgentId)&&h({view:"follow",...l.flightId?{flightId:l.flightId}:{},...l.conversationId?{conversationId:l.conversationId}:{},...l.targetAgentId?{targetAgentId:l.targetAgentId}:{}})}}):null]})}function an({navigate:s,focusRoot:n=null}){const[t,r]=u.useState(null),[a,i]=u.useState("loading"),[o,c]=u.useState(null),h=u.useRef(!1),p=u.useRef(0),d=u.useRef(null),m=u.useRef(!1),[b,S]=ke(zs,Ne,"warm"),[A,P]=ke(Gs,Se,"table"),[f,x]=u.useState(null),[C,I]=u.useState("standard"),[R,O]=u.useState(!1),[j,y]=u.useState(null),[N,$]=u.useState(!1),[T,D]=u.useState(!1),[W,F]=u.useState(null),[M,l]=u.useState(null),[v,L]=u.useState(!1),[De,Z]=u.useState(null),[B,K]=u.useState(null),q=u.useCallback(async(g={})=>{if(m.current&&!g.force)return;m.current=!0;const k=g.depth??C;g.scanMore&&$(!0),g.force&&!g.scanMore&&O(!0);try{let E=await he(k,g.force??!1,k==="expanded"?Ks:Us),_=k;if(!h.current&&k==="standard"&&!g.force&&E.projects.length===0)try{const ue=await he("expanded",!0,Vs);ue.projects.length>0&&(E=ue,_="expanded")}catch{}const de=d.current;if(de&&Ys(E)&&(E.projects.length===0||Js(E,de))){c("Scan budget was reached; keeping the last fuller Repo Watch snapshot."),i("ready");return}if(!g.force&&E.projects.length===0&&h.current&&p.current<3){p.current+=1,i("ready");return}p.current=0,h.current=!0,d.current=E,r(E),c(null),i("ready"),(g.scanMore||_!==k)&&I(_),g.force&&!g.scanMore&&y(`Fresh ${new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}`)}catch(E){const _=Qs(E);c(_),h.current||i("error")}finally{g.scanMore&&$(!1),g.force&&!g.scanMore&&O(!1),m.current=!1}},[C]);u.useEffect(()=>{d.current=t},[t]),u.useEffect(()=>{q();const g=setInterval(()=>{q()},Hs);return()=>clearInterval(g)},[q]);const le=u.useRef(null);u.useEffect(()=>{if(!t)return;if(n&&le.current!==n){const k=t.projects.find(E=>E.root===n||E.worktrees.some(_=>_.path===n));if(!k)return;if(le.current=n,!k.worktrees.some(E=>E.id===f)){x(ye([k])?.id??null);return}}t.projects.some(k=>k.worktrees.some(E=>E.id===f))||x(ye(t.projects)?.id??null)},[t,f,n]),u.useEffect(()=>{!t||t.projects.length===0||Je(rt(t,f),void 0,{limit:Xs})},[t,f]);const ee=u.useMemo(()=>t?et(t):[],[t]),Le=ee.join("\0");u.useEffect(()=>{if(ee.length===0){l(null),Z(null),L(!1);return}let g=!1;return L(!0),Z(null),qe(ee).then(k=>{g||l(k)}).catch(k=>{g||Z(k instanceof Error?k.message:String(k))}).finally(()=>{g||L(!1)}),()=>{g=!0}},[Le]);const H=u.useMemo(()=>Zs(t,f),[t,f]),Oe=u.useMemo(()=>tt(M),[M]);u.useEffect(()=>{ze({worktree:H.worktree,project:H.project,generatedAt:t?.generatedAt??0,tone:b})},[H.worktree,H.project,t?.generatedAt,b]),u.useEffect(()=>Ge,[]);const oe=u.useCallback(()=>{q({depth:"expanded",force:!0,scanMore:!0})},[q]),ce=u.useCallback(()=>{q({force:!0})},[q]),Fe=u.useCallback(async()=>{if(!T){D(!0),F(null);try{const g=await fetch("/api/scout-services/restart-link",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({target:"broker"})});if(!g.ok)throw new Error(`Scout Services link failed (${g.status})`);const k=await g.json();if(!k.url?.startsWith("scout://services/restart/"))throw new Error("Scout Services link was not returned.");window.location.assign(k.url)}catch(g){const k=g instanceof Error?g.message:String(g);F(`${k} Run scout doctor if the menu app did not open.`)}finally{D(!1)}}},[T]);return a==="loading"?e.jsx(z,{navigate:s,children:e.jsx("div",{className:"repo-watch-scope",style:{padding:"24px"},children:e.jsx(se,{title:"Scanning repositories…",body:"Reading worktree state from the broker."})})}):a==="error"&&!t?e.jsx(z,{navigate:s,children:e.jsx("div",{className:"repo-watch-scope",style:{padding:"24px"},children:e.jsx(se,{className:"sys-state-card-error",title:"Couldn’t load Repo Watch",body:o??"The broker did not return a snapshot.",action:e.jsx("button",{type:"button",className:"s-btn",onClick:()=>{i("loading"),q()},children:"Retry"})})})}):t&&t.projects.length===0?e.jsx(z,{navigate:s,children:e.jsx("div",{className:"repo-watch-scope",style:{padding:"24px"},children:e.jsx(se,{title:"Scout Services need attention",body:e.jsx(at,{error:W}),action:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"s-btn s-btn-primary",onClick:()=>{Fe()},disabled:T,children:T?"Opening…":"Restart broker"}),e.jsx("button",{type:"button",className:"s-btn",onClick:ce,disabled:R||N,children:R?"Scanning…":"Scan again"}),e.jsx("button",{type:"button",className:"s-btn",onClick:oe,disabled:R||N,children:N?"Scanning…":"Scan more"})]})})})}):t?e.jsx(z,{navigate:s,children:e.jsxs("div",{className:"repo-watch-scope",children:[e.jsx("div",{className:"rw-scope tone-"+b,children:e.jsxs("div",{className:"rw-page-shell",children:[e.jsxs("div",{className:"rw-toolbar",children:[e.jsxs("button",{type:"button",className:"rw-refresh-main",onClick:ce,disabled:R||N,children:[e.jsx(Ze,{size:14,"aria-hidden":"true",className:R?"rw-refresh-spin":void 0}),e.jsx("span",{children:R?"Scanning":"Refresh"})]}),j?e.jsx("span",{className:"rw-refresh-receipt",children:j}):null,e.jsxs("details",{className:"rw-display-menu",children:[e.jsxs("summary",{"aria-label":"Display options",children:[e.jsx(es,{size:14,"aria-hidden":"true"}),e.jsx("span",{children:"Display"})]}),e.jsxs("div",{className:"rw-display-panel",children:[e.jsxs("div",{className:"rw-display-row",children:[e.jsx("span",{className:"rw-display-label",children:"View"}),e.jsx("div",{className:"rw-tone",role:"group","aria-label":"View",children:Se.map(g=>e.jsx("button",{type:"button",className:g===A?"on":"","aria-pressed":g===A,onClick:()=>P(g),children:g},g))})]}),e.jsxs("div",{className:"rw-display-row",children:[e.jsx("span",{className:"rw-display-label",children:"Tone"}),e.jsx("div",{className:"rw-tone",role:"group","aria-label":"Console tone",children:Ne.map(g=>e.jsx("button",{type:"button",className:g===b?"on":"","aria-pressed":g===b,onClick:()=>S(g),children:g},g))})]})]})]})]}),e.jsx("div",{className:"min-w-0",children:A==="drift"?e.jsx(Ds,{snapshot:t,selectedId:f,onSelect:x}):e.jsxs(e.Fragment,{children:[e.jsx(Ss,{snapshot:t,selectedId:f,onSelect:x,onViewDiff:K,scanDepth:C,scanMorePending:N,onScanMore:oe,openPullRequestCount:M?.pullRequests.length??null,openPullRequestTitle:Oe}),e.jsx(it,{snapshot:M,loading:v,error:De,selectedProject:H.project,selectedWorktree:H.worktree,repoSnapshot:t,onSelectWorktree:x,onOpenDiff:K,navigate:s})]})})]})}),e.jsx(Xe,{open:B!=null,onClose:()=>K(null),side:"right",owner:"openscout.repos-diff-viewer",resizable:!0,defaultSize:840,maxSize:1280,minSize:420,ariaLabel:"Worktree diff",children:B!=null?e.jsx(Ye,{path:B,onClose:()=>K(null),onOpenAsPage:()=>{B&&(s({view:"repo-diff",path:B}),K(null))}},B):null})]})}):e.jsx(z,{navigate:s})}export{an as ReposScreen,an as default};