@kortix/ui 0.14.19 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (414) hide show
  1. package/README.md +1 -1
  2. package/dist/_vendor/kortix-shared.js +956 -73
  3. package/dist/_vendor/shared/artifact-annotations.d.ts +85 -607
  4. package/dist/_vendor/shared/artifact-comments.d.ts +53 -489
  5. package/dist/_vendor/shared/index.d.ts +0 -1
  6. package/dist/_vendor/shared/peer-message-prompt.d.ts +7 -1
  7. package/dist/_vendor/shared/project-glyphs.d.ts +103 -20
  8. package/dist/_vendor/shared/webhook-signing.d.ts +3 -1
  9. package/dist/access/access/access-dialog-share.d.ts +3 -28
  10. package/dist/access/access/access-dialog-share.js +3 -75
  11. package/dist/artifacts/artifact-frame.js +26 -2
  12. package/dist/artifacts/artifact-session.js +6 -2
  13. package/dist/artifacts/frame-policy.d.ts +2 -9
  14. package/dist/artifacts/frame-policy.js +2 -25
  15. package/dist/customize/agents/agents-page.js +1 -1
  16. package/dist/customize/agents/create-agent-modal.js +1 -1
  17. package/dist/customize/connectors/connector-filter.d.ts +2 -1
  18. package/dist/customize/connectors/connector-filter.js +2 -3
  19. package/dist/customize/connectors/connectors-page.js +15 -24
  20. package/dist/customize/connectors/detail/connector-status.d.ts +3 -24
  21. package/dist/customize/connectors/detail/connector-status.js +2 -42
  22. package/dist/customize/connectors/detail/use-connector-detail.d.ts +2 -6
  23. package/dist/customize/connectors/detail/use-connector-detail.js +3 -13
  24. package/dist/customize/connectors/install/install.d.ts +2 -6
  25. package/dist/customize/connectors/install/install.js +2 -16
  26. package/dist/customize/connectors/provider-label.d.ts +4 -17
  27. package/dist/customize/connectors/provider-label.js +4 -37
  28. package/dist/customize/providers/provider-connect.d.ts +6 -15
  29. package/dist/customize/providers/provider-connect.js +5 -36
  30. package/dist/customize/sections/connector-connection-form.d.ts +3 -7
  31. package/dist/customize/sections/connector-connection-form.js +2 -33
  32. package/dist/customize/sections/connector-oauth2-auto.d.ts +3 -33
  33. package/dist/customize/sections/connector-oauth2-auto.js +2 -64
  34. package/dist/customize/sections/gateway-view.d.ts +6 -5
  35. package/dist/customize/sections/gateway-view.js +31 -13
  36. package/dist/customize/sections/llm-provider/constants.d.ts +1 -2
  37. package/dist/customize/sections/llm-provider/constants.js +1 -2
  38. package/dist/customize/sections/llm-provider/utils.d.ts +1 -41
  39. package/dist/customize/sections/llm-provider/utils.js +1 -52
  40. package/dist/customize/sections/view/account-secret-resources-panel.js +4 -1
  41. package/dist/customize/sections/view/agent-editor-catalog.js +0 -5
  42. package/dist/customize/sections/view/channel-settings-patch.js +1 -1
  43. package/dist/customize/sections/view/channels-view.js +8 -8
  44. package/dist/customize/sections/view/connector-connections.d.ts +5 -85
  45. package/dist/customize/sections/view/connector-connections.js +5 -99
  46. package/dist/customize/sections/view/gateway/gateway-logs.d.ts +42 -3
  47. package/dist/customize/sections/view/gateway/gateway-logs.js +212 -15
  48. package/dist/customize/sections/view/gateway/gateway-overview.js +1 -1
  49. package/dist/customize/sections/view/gateway/gateway-routing.d.ts +3 -3
  50. package/dist/customize/sections/view/gateway/gateway-routing.js +81 -200
  51. package/dist/customize/sections/view/gateway/routing-parts.d.ts +101 -0
  52. package/dist/customize/sections/view/gateway/routing-parts.js +154 -0
  53. package/dist/customize/sections/view/gateway/routing-sentence-layout.d.ts +2 -0
  54. package/dist/customize/sections/view/gateway/routing-sentence-layout.js +82 -0
  55. package/dist/customize/sections/view/review-center-connected.js +17 -15
  56. package/dist/customize/sections/view/review-view.d.ts +7 -0
  57. package/dist/customize/sections/view/review-view.js +11 -0
  58. package/dist/customize/sections/view/secret-delivery.js +1 -1
  59. package/dist/customize/sections/view/secrets-view.js +1 -1
  60. package/dist/customize/sections/view/subscription-usage-tab.d.ts +14 -0
  61. package/dist/customize/sections/view/subscription-usage-tab.js +122 -0
  62. package/dist/customize/sections/view/subscription-usage.d.ts +34 -0
  63. package/dist/customize/sections/view/subscription-usage.js +98 -0
  64. package/dist/customize/settings/tabs/experimental-tab.js +3 -3
  65. package/dist/customize/settings/tabs/general-tab.js +65 -10
  66. package/dist/customize/shared/catalog/catalog-card.d.ts +9 -4
  67. package/dist/customize/shared/catalog/catalog-card.js +3 -3
  68. package/dist/customize/shared/channels-switch-dialog.d.ts +1 -1
  69. package/dist/customize/shared/channels-switch-dialog.js +1 -1
  70. package/dist/customize/shared/feature-gate-screen.js +1 -1
  71. package/dist/customize/triggers/schedule/post-to-field.d.ts +1 -1
  72. package/dist/customize/triggers/schedule/post-to-field.js +2 -2
  73. package/dist/customize/triggers/schedule/trigger-composer-logic.d.ts +1 -1
  74. package/dist/files/drives/conflict-marks.d.ts +28 -0
  75. package/dist/files/drives/conflict-marks.js +39 -0
  76. package/dist/files/drives/session-drives-chip.js +15 -10
  77. package/dist/files/viewer/index.d.ts +1 -1
  78. package/dist/files/viewer/index.js +1 -1
  79. package/dist/i18n/en.d.ts +451 -203
  80. package/dist/i18n/en.js +543 -295
  81. package/dist/index.d.ts +1 -1
  82. package/dist/index.js +1 -1
  83. package/dist/internal/account-hub/sections.d.ts +1 -1
  84. package/dist/internal/capture/use-capture-area.d.ts +5 -1
  85. package/dist/internal/capture/use-capture-area.js +16 -9
  86. package/dist/internal/goals/goal-meta.d.ts +50 -3
  87. package/dist/internal/goals/goal-meta.js +144 -9
  88. package/dist/internal/hooks/connectors/use-add-account.d.ts +3 -9
  89. package/dist/internal/hooks/connectors/use-add-account.js +3 -18
  90. package/dist/internal/hooks/connectors/use-connect-link.d.ts +3 -2
  91. package/dist/internal/hooks/connectors/use-connect-link.js +15 -24
  92. package/dist/internal/hooks/connectors/use-pipedream-connect-project.d.ts +3 -56
  93. package/dist/internal/hooks/connectors/use-pipedream-connect-project.js +3 -87
  94. package/dist/internal/hooks/projects/use-new-project-session.d.ts +3 -2
  95. package/dist/internal/hooks/projects/use-new-project-session.js +4 -3
  96. package/dist/internal/hooks/projects/use-project-can-run.d.ts +7 -0
  97. package/dist/internal/hooks/projects/use-project-can-run.js +12 -5
  98. package/dist/internal/hooks/projects/use-restart-project-session.d.ts +0 -1
  99. package/dist/internal/hooks/projects/use-restart-project-session.js +0 -1
  100. package/dist/internal/layout/project-capability-nav.js +6 -2
  101. package/dist/internal/layout/project-page-header.d.ts +3 -1
  102. package/dist/internal/layout/project-page-header.js +2 -2
  103. package/dist/internal/lib/account-secret-access.d.ts +1 -41
  104. package/dist/internal/lib/account-secret-access.js +3 -46
  105. package/dist/internal/lib/browser-error-noise.d.ts +1 -1
  106. package/dist/internal/lib/browser-error-noise.js +1 -1
  107. package/dist/internal/lib/browser-noise/rules/expected-states.d.ts +2 -15
  108. package/dist/internal/lib/browser-noise/rules/expected-states.js +5 -55
  109. package/dist/internal/lib/capability-tab-routes.d.ts +3 -3
  110. package/dist/internal/lib/capability-tab-routes.js +11 -3
  111. package/dist/internal/lib/llm-providers.d.ts +4 -110
  112. package/dist/internal/lib/llm-providers.js +5 -102
  113. package/dist/internal/lib/navigation/message-link.d.ts +32 -0
  114. package/dist/internal/lib/navigation/message-link.js +51 -0
  115. package/dist/internal/lib/navigation/session-href.d.ts +11 -0
  116. package/dist/internal/lib/navigation/session-href.js +20 -0
  117. package/dist/internal/lib/navigation/session-spawn-urls.d.ts +17 -0
  118. package/dist/internal/lib/navigation/session-spawn-urls.js +26 -0
  119. package/dist/internal/lib/space-scope.d.ts +3 -3
  120. package/dist/internal/lib/space-scope.js +3 -3
  121. package/dist/internal/lib/use-project-feature-flags.js +7 -7
  122. package/dist/internal/lib/web-notifications.d.ts +1 -1
  123. package/dist/internal/lib/web-notifications.js +0 -3
  124. package/dist/internal/notifications/notification-bell.js +1 -3
  125. package/dist/internal/notifications/notification-rows.d.ts +2 -2
  126. package/dist/internal/notifications/notification-rows.js +2 -3
  127. package/dist/internal/session-types/index.d.ts +5 -7
  128. package/dist/internal/session-types/index.js +5 -7
  129. package/dist/internal/stores/active-space-store.d.ts +1 -1
  130. package/dist/internal/stores/active-space-store.js +1 -1
  131. package/dist/internal/stores/kortix-computer-store.d.ts +15 -0
  132. package/dist/internal/stores/kortix-computer-store.js +12 -0
  133. package/dist/lib/routes.d.ts +17 -7
  134. package/dist/lib/routes.js +18 -2
  135. package/dist/markdown/app-link-icons.d.ts +7 -0
  136. package/dist/markdown/app-link-icons.js +20 -0
  137. package/dist/markdown/app-links.d.ts +9 -0
  138. package/dist/markdown/app-links.js +112 -0
  139. package/dist/markdown/doc-editor/doc-attrs.d.ts +28 -0
  140. package/dist/markdown/doc-editor/doc-attrs.js +156 -0
  141. package/dist/markdown/doc-editor/doc-embed.d.ts +6 -0
  142. package/dist/markdown/doc-editor/doc-embed.js +26 -8
  143. package/dist/markdown/doc-editor/doc-extensions.d.ts +10 -0
  144. package/dist/markdown/doc-editor/doc-extensions.js +55 -8
  145. package/dist/markdown/doc-editor/doc-fidelity.d.ts +72 -0
  146. package/dist/markdown/doc-editor/doc-fidelity.js +135 -0
  147. package/dist/markdown/doc-editor/doc-node-view.d.ts +9 -0
  148. package/dist/markdown/doc-editor/doc-node-view.js +29 -0
  149. package/dist/markdown/doc-editor/markdown.d.ts +20 -0
  150. package/dist/markdown/doc-editor/markdown.js +455 -18
  151. package/dist/markdown/unified-markdown.d.ts +1 -1
  152. package/dist/markdown/unified-markdown.js +129 -10
  153. package/dist/primitives/emoji-picker.js +16 -100
  154. package/dist/primitives/emoji-tint.js +12 -12
  155. package/dist/primitives/entity-avatar.js +14 -9
  156. package/dist/primitives/glyph-face.d.ts +19 -12
  157. package/dist/primitives/glyph-face.js +59 -20
  158. package/dist/primitives/glyph-paths-source.d.ts +7 -0
  159. package/dist/primitives/glyph-paths-source.js +14 -6
  160. package/dist/primitives/glyph-paths.generated.d.ts +1 -1
  161. package/dist/primitives/glyph-paths.generated.js +947 -204
  162. package/dist/primitives/glyph-picker.d.ts +6 -10
  163. package/dist/primitives/glyph-picker.js +147 -98
  164. package/dist/primitives/glyph-registry.js +1604 -1
  165. package/dist/primitives/glyph-tint.d.ts +28 -3
  166. package/dist/primitives/glyph-tint.js +41 -83
  167. package/dist/primitives/kortix-glyphs.d.ts +32 -0
  168. package/dist/primitives/kortix-glyphs.js +157 -0
  169. package/dist/primitives/project-icon-picker.d.ts +8 -1
  170. package/dist/primitives/project-icon-picker.js +13 -5
  171. package/dist/primitives/user-avatar.d.ts +8 -1
  172. package/dist/primitives/user-avatar.js +2 -2
  173. package/dist/providers/ui-provider.d.ts +1 -8
  174. package/dist/session/actions/project-session-list-helpers.js +1 -1
  175. package/dist/session/agents/agent-model.js +4 -0
  176. package/dist/session/agents/agent-state-mark.d.ts +12 -7
  177. package/dist/session/agents/agent-state-mark.js +37 -15
  178. package/dist/session/agents/agent-strip.js +8 -2
  179. package/dist/session/agents/agent-surface.d.ts +81 -0
  180. package/dist/session/agents/agent-surface.js +97 -0
  181. package/dist/session/agents/held-messages.js +7 -4
  182. package/dist/session/agents/legacy-subagent-chat.js +1 -1
  183. package/dist/session/agents/session-peek.js +24 -12
  184. package/dist/session/agents/steer-session.d.ts +2 -0
  185. package/dist/session/agents/steer-session.js +3 -2
  186. package/dist/session/agents/subagent-dialog-content.d.ts +30 -1
  187. package/dist/session/agents/subagent-dialog-content.js +147 -33
  188. package/dist/session/agents/subagent-view.d.ts +15 -5
  189. package/dist/session/agents/subagent-view.js +28 -6
  190. package/dist/session/agents/tasks-panel.js +2 -12
  191. package/dist/session/agents/workflow-run-controls.d.ts +3 -1
  192. package/dist/session/agents/workflow-run-controls.js +12 -7
  193. package/dist/session/composer/ComposerCard.d.ts +7 -1
  194. package/dist/session/composer/ComposerCard.js +74 -9
  195. package/dist/session/composer/agent-selector.d.ts +16 -0
  196. package/dist/session/composer/agent-selector.js +19 -11
  197. package/dist/session/composer/chat-input/chat-input-control.d.ts +64 -0
  198. package/dist/session/composer/chat-input/chat-input-control.js +578 -0
  199. package/dist/session/composer/chat-input/chat-input-overrides.d.ts +76 -0
  200. package/dist/session/composer/chat-input/chat-input-overrides.js +40 -0
  201. package/dist/session/composer/chat-input/chat-input-panes.d.ts +56 -0
  202. package/dist/session/composer/chat-input/chat-input-panes.js +148 -0
  203. package/dist/session/composer/chat-input/chat-input-summary.d.ts +67 -0
  204. package/dist/session/composer/chat-input/chat-input-summary.js +67 -0
  205. package/dist/session/composer/chat-queue-lines.d.ts +20 -0
  206. package/dist/session/composer/chat-queue-lines.js +20 -0
  207. package/dist/session/composer/composer-chat-input.d.ts +8 -1
  208. package/dist/session/composer/composer-chat-input.js +12 -4
  209. package/dist/session/composer/composer-focus-context.d.ts +7 -0
  210. package/dist/session/composer/composer-focus-context.js +9 -0
  211. package/dist/session/composer/composer-toolbar.d.ts +3 -1
  212. package/dist/session/composer/composer-toolbar.js +3 -3
  213. package/dist/session/composer/composer-underbar.d.ts +10 -1
  214. package/dist/session/composer/composer-underbar.js +10 -2
  215. package/dist/session/composer/composer.d.ts +12 -0
  216. package/dist/session/composer/composer.js +55 -1
  217. package/dist/session/composer/editor/composer-editor.d.ts +10 -2
  218. package/dist/session/composer/editor/composer-editor.js +22 -6
  219. package/dist/session/composer/editor/first-visual-line.d.ts +2 -0
  220. package/dist/session/composer/editor/first-visual-line.js +9 -0
  221. package/dist/session/composer/editor/mention-node.js +2 -0
  222. package/dist/session/composer/editor/serialize.js +9 -1
  223. package/dist/session/composer/hooks/use-file-search.d.ts +1 -1
  224. package/dist/session/composer/hooks/use-file-search.js +1 -1
  225. package/dist/session/composer/menus/mention-controller.d.ts +3 -11
  226. package/dist/session/composer/menus/mention-controller.js +56 -16
  227. package/dist/session/composer/menus/mention-menu.d.ts +7 -2
  228. package/dist/session/composer/menus/mention-menu.js +17 -9
  229. package/dist/session/composer/menus/menu-items.d.ts +9 -0
  230. package/dist/session/composer/menus/space-mentions.d.ts +48 -0
  231. package/dist/session/composer/menus/space-mentions.js +83 -0
  232. package/dist/session/composer/prompt-history.d.ts +9 -0
  233. package/dist/session/composer/prompt-history.js +45 -0
  234. package/dist/session/composer/queue-projection.d.ts +2 -0
  235. package/dist/session/composer/queue-projection.js +1 -0
  236. package/dist/session/composer/queued-prompt-list.js +53 -4
  237. package/dist/session/composer/reasoning-effort-selector.d.ts +20 -0
  238. package/dist/session/composer/reasoning-effort-selector.js +3 -3
  239. package/dist/session/composer/types.d.ts +2 -1
  240. package/dist/session/header/session-site-header.js +7 -3
  241. package/dist/session/header/subagent-hover-card.d.ts +7 -4
  242. package/dist/session/header/subagent-hover-card.js +62 -11
  243. package/dist/session/list/session-status-mark.d.ts +42 -0
  244. package/dist/{workspace/sidebar → session/list}/session-status-mark.js +37 -2
  245. package/dist/session/models/model-selector.d.ts +7 -2
  246. package/dist/session/models/model-selector.js +39 -31
  247. package/dist/session/overrides/provider-secret-pool-editor.d.ts +11 -0
  248. package/dist/session/overrides/provider-secret-pool-editor.js +17 -0
  249. package/dist/session/overrides/session-overrides-control.d.ts +5 -0
  250. package/dist/session/overrides/session-overrides-toolbar.js +147 -7
  251. package/dist/session/panel/model-switch-event.d.ts +8 -0
  252. package/dist/session/panel/model-switch-event.js +19 -0
  253. package/dist/session/panel/session-audit-panel.js +3 -2
  254. package/dist/session/panel/session-desktop.js +5 -1
  255. package/dist/session/panel/session-panel-provider.js +1 -1
  256. package/dist/session/panel/shared/use-panel-handoffs.d.ts +2 -2
  257. package/dist/session/panel/shared/use-panel-handoffs.js +21 -2
  258. package/dist/session/prompts/ask-deck.d.ts +21 -0
  259. package/dist/session/prompts/ask-deck.js +253 -0
  260. package/dist/session/prompts/session-permission-prompt.d.ts +7 -1
  261. package/dist/session/prompts/session-permission-prompt.js +3 -3
  262. package/dist/session/status/session-load-state.d.ts +0 -1
  263. package/dist/session/status/session-load-state.js +2 -4
  264. package/dist/session/thread/message-parsing.d.ts +0 -1
  265. package/dist/session/thread/message-parsing.js +0 -1
  266. package/dist/session/thread/session-chat.d.ts +3 -1
  267. package/dist/session/thread/session-chat.js +459 -310
  268. package/dist/session/thread/session-context-metrics.d.ts +0 -1
  269. package/dist/session/thread/session-context-metrics.js +1 -1
  270. package/dist/session/thread/session-context-sub-sessions.js +3 -1
  271. package/dist/session/thread/show-work.d.ts +38 -0
  272. package/dist/session/thread/show-work.js +115 -0
  273. package/dist/session/thread/thread-boot-rows.d.ts +2 -1
  274. package/dist/session/thread/thread-boot-rows.js +7 -3
  275. package/dist/session/thread/transcript-rows.d.ts +36 -0
  276. package/dist/session/thread/transcript.d.ts +46 -2
  277. package/dist/session/thread/transcript.js +226 -34
  278. package/dist/session/thread/typing-indicator.d.ts +21 -0
  279. package/dist/session/thread/typing-indicator.js +46 -0
  280. package/dist/session/tool/shared/infrastructure-contexts.d.ts +12 -0
  281. package/dist/session/tool/shared/infrastructure-contexts.js +6 -0
  282. package/dist/session/tool/tool-part-renderer.d.ts +2 -0
  283. package/dist/session/tool/tool-part-renderer.js +16 -2
  284. package/dist/session/tool/tools/kortix-action-tool.js +8 -1
  285. package/dist/session/tool/tools/multi-agent-tool-bodies.d.ts +19 -0
  286. package/dist/session/tool/tools/multi-agent-tool-bodies.js +34 -13
  287. package/dist/session/tool/tools/session-spawn-urls.d.ts +1 -16
  288. package/dist/session/tool/tools/session-spawn-urls.js +4 -26
  289. package/dist/session/tool/tools/task-tool.d.ts +5 -18
  290. package/dist/session/tool/tools/task-tool.js +47 -86
  291. package/dist/session/tool/tools/workflow-progress.d.ts +14 -18
  292. package/dist/session/tool/tools/workflow-progress.js +24 -179
  293. package/dist/session/tool/tools/workflow-result-text.d.ts +15 -0
  294. package/dist/session/tool/tools/workflow-result-text.js +34 -0
  295. package/dist/session/tool/tools/workflow-run-card.d.ts +35 -0
  296. package/dist/session/tool/tools/workflow-run-card.js +157 -0
  297. package/dist/session/tool/tools/workflow-tool.js +45 -58
  298. package/dist/session/turn/activity-burst.d.ts +2 -2
  299. package/dist/session/turn/activity-burst.js +11 -5
  300. package/dist/session/turn/answered-question-step.d.ts +29 -0
  301. package/dist/session/turn/answered-question-step.js +48 -3
  302. package/dist/session/turn/notice-batch-group.d.ts +4 -4
  303. package/dist/session/turn/notice-batch-group.js +5 -8
  304. package/dist/session/turn/peer-message-row.d.ts +15 -0
  305. package/dist/session/turn/peer-message-row.js +38 -47
  306. package/dist/session/turn/subagent-notice-row.d.ts +16 -1
  307. package/dist/session/turn/subagent-notice-row.js +47 -35
  308. package/dist/session/turn/throttled-markdown.js +4 -1
  309. package/dist/session/turn/turn-work-accordion.d.ts +10 -3
  310. package/dist/session/turn/turn-work-accordion.js +18 -11
  311. package/dist/session/turn/user-message.js +16 -42
  312. package/dist/session/turn/voice-turn.d.ts +22 -0
  313. package/dist/session/turn/voice-turn.js +32 -0
  314. package/dist/session/voice/call-ring.d.ts +10 -0
  315. package/dist/session/voice/call-ring.js +52 -0
  316. package/dist/session/voice/use-voice-call.d.ts +4 -4
  317. package/dist/session/voice/use-voice-call.js +6 -9
  318. package/dist/session/voice/voice-call-card.d.ts +6 -0
  319. package/dist/session/voice/voice-call-card.js +113 -0
  320. package/dist/session/voice/voice-call-state.d.ts +3 -0
  321. package/dist/session/voice/voice-call-state.js +2 -1
  322. package/dist/session/voice/voice-call-store.d.ts +16 -6
  323. package/dist/session/voice/voice-call-store.js +5 -5
  324. package/dist/session/voice/voice-call.d.ts +4 -8
  325. package/dist/session/voice/voice-call.js +33 -36
  326. package/dist/styles/components.css +33 -0
  327. package/dist/styles/theme.css +26 -0
  328. package/dist/styles.css +1 -1
  329. package/dist/workspace/admin/project-admin-dashboard.d.ts +1 -1
  330. package/dist/workspace/admin/project-admin-dashboard.js +12 -9
  331. package/dist/workspace/index.d.ts +3 -2
  332. package/dist/workspace/index.js +2 -1
  333. package/dist/workspace/layout/use-project-home-send.d.ts +2 -0
  334. package/dist/workspace/layout/use-project-home-send.js +5 -3
  335. package/dist/workspace/memory/company-memory-page.d.ts +1 -1
  336. package/dist/workspace/memory/company-memory-page.js +1 -1
  337. package/dist/workspace/new/use-creatable-accounts.js +13 -4
  338. package/dist/workspace/projects/modal/project-icon-field.js +49 -34
  339. package/dist/workspace/review/review-center.d.ts +4 -1
  340. package/dist/workspace/review/review-center.js +6 -3
  341. package/dist/workspace/sessions/project-sessions-helpers.js +1 -1
  342. package/dist/workspace/sessions/project-sessions-view.js +1 -1
  343. package/dist/workspace/sessions/session-row.js +6 -4
  344. package/dist/workspace/sessions/sessions-toolbar.d.ts +1 -1
  345. package/dist/workspace/sessions/sessions-toolbar.js +4 -4
  346. package/dist/workspace/sidebar/footer/project-memory-nav.d.ts +1 -1
  347. package/dist/workspace/sidebar/footer/project-memory-nav.js +1 -1
  348. package/dist/workspace/sidebar/project-nav-items.js +2 -5
  349. package/dist/workspace/sidebar/project-session-list.d.ts +7 -1
  350. package/dist/workspace/sidebar/project-session-list.js +63 -24
  351. package/dist/workspace/sidebar/project-sidebar.js +10 -7
  352. package/dist/workspace/sidebar/project-spaces-nav.d.ts +7 -3
  353. package/dist/workspace/sidebar/project-spaces-nav.js +77 -46
  354. package/dist/workspace/sidebar/session-brief-hover-card.d.ts +4 -2
  355. package/dist/workspace/sidebar/session-brief-hover-card.js +47 -28
  356. package/dist/workspace/sidebar/session-group-sections.js +12 -4
  357. package/dist/workspace/sidebar/sidebar-more-group.d.ts +13 -0
  358. package/dist/workspace/sidebar/sidebar-more-group.js +27 -0
  359. package/dist/workspace/space/space-blocks.d.ts +3 -1
  360. package/dist/workspace/space/space-blocks.js +4 -7
  361. package/dist/workspace/space/space-page.d.ts +4 -6
  362. package/dist/workspace/space/space-page.js +10 -24
  363. package/dist/workspace/space/space-tab-panels.d.ts +14 -1
  364. package/dist/workspace/space/space-tab-panels.js +12 -21
  365. package/dist/workspace/space/space-templates.d.ts +4 -5
  366. package/dist/workspace/space/space-templates.js +2 -7
  367. package/dist/workspace/space/use-space-filter.d.ts +1 -1
  368. package/dist/workspace/space/use-space-filter.js +1 -1
  369. package/dist/workspace/spaces/channels-onboarding.d.ts +2 -2
  370. package/dist/workspace/spaces/channels-onboarding.js +4 -3
  371. package/dist/workspace/spaces/create-channel-dialog.js +4 -2
  372. package/dist/workspace/spaces/principal-card.d.ts +71 -0
  373. package/dist/workspace/spaces/principal-card.js +246 -0
  374. package/dist/workspace/spaces/space-auto-open.d.ts +8 -0
  375. package/dist/workspace/spaces/space-auto-open.js +18 -0
  376. package/dist/workspace/spaces/space-avatar.d.ts +44 -0
  377. package/dist/workspace/spaces/space-avatar.js +41 -0
  378. package/dist/workspace/spaces/space-details-panel.d.ts +26 -0
  379. package/dist/workspace/spaces/space-details-panel.js +119 -0
  380. package/dist/workspace/spaces/space-identity.d.ts +49 -0
  381. package/dist/workspace/spaces/space-identity.js +104 -0
  382. package/dist/workspace/spaces/space-members.js +1 -1
  383. package/dist/workspace/spaces/space-mention-source.d.ts +12 -0
  384. package/dist/workspace/spaces/space-mention-source.js +78 -0
  385. package/dist/workspace/spaces/space-people.d.ts +29 -0
  386. package/dist/workspace/spaces/space-people.js +87 -0
  387. package/dist/workspace/spaces/space-roster.d.ts +3 -2
  388. package/dist/workspace/spaces/space-roster.js +7 -4
  389. package/dist/workspace/spaces/space-tab-list.d.ts +37 -0
  390. package/dist/workspace/spaces/space-tab-list.js +82 -0
  391. package/dist/workspace/spaces/space-tabs.d.ts +74 -0
  392. package/dist/workspace/spaces/space-tabs.js +199 -0
  393. package/dist/workspace/spaces/space-threads-tab.js +1 -1
  394. package/dist/workspace/spaces/space-timeline-view.js +126 -17
  395. package/dist/workspace/spaces/space-timeline.d.ts +44 -9
  396. package/dist/workspace/spaces/space-timeline.js +120 -12
  397. package/dist/workspace/spaces/space-view.d.ts +19 -12
  398. package/dist/workspace/spaces/space-view.js +201 -67
  399. package/dist/workspace/spaces/use-personal-space-name.d.ts +2 -0
  400. package/dist/workspace/spaces/use-personal-space-name.js +10 -0
  401. package/package.json +11 -7
  402. package/skills/kortix-ui/SKILL.md +1 -1
  403. package/skills/kortix-ui/references/custom-dashboard.md +2 -3
  404. package/skills/kortix-ui/references/modules.md +4 -4
  405. package/dist/_vendor/shared/room-prompt.d.ts +0 -66
  406. package/dist/session/voice/voice-call-bar.d.ts +0 -4
  407. package/dist/session/voice/voice-call-bar.js +0 -39
  408. package/dist/workspace/sidebar/footer/project-rooms-nav.d.ts +0 -9
  409. package/dist/workspace/sidebar/footer/project-rooms-nav.js +0 -32
  410. package/dist/workspace/sidebar/session-status-mark.d.ts +0 -19
  411. package/dist/workspace/space/space-room.d.ts +0 -20
  412. package/dist/workspace/space/space-room.js +0 -27
  413. /package/dist/{workspace/sidebar → session/list}/session-list-chrome.d.ts +0 -0
  414. /package/dist/{workspace/sidebar → session/list}/session-list-chrome.js +0 -0
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { ModelSwitchHistory } from '../panel/model-switch-event.js';
3
4
  import { uiRoutes } from '../../lib/routes.js';
4
5
  import { isQuestionTool } from '@kortix/sdk';
5
6
  import { SessionApprovalPrompt } from '../prompts/session-approval-prompt.js';
@@ -22,6 +23,8 @@ import { createPortal } from 'react-dom';
22
23
  import { AUTHOR_RETRY_DELAYS_MS, authorForTurn, awaitsAgent, missingAuthorKey, participantAuthor, resolveTranscriptAuthors, rewindableMessageIds, stoppedByName, viewerAuthor, } from '../turn/message-author.js';
23
24
  import { stopRefusalMessage } from '../status/stop-refusal.js';
24
25
  import { QueuedPromptList } from '../composer/queued-prompt-list.js';
26
+ import { ComposerAutoFocusContext } from '../composer/composer-focus-context.js';
27
+ import { ChatQueueLines } from '../composer/chat-queue-lines.js';
25
28
  import { runtimePermissionLocksComposer } from '../composer/send-blockers.js';
26
29
  import { SessionPrintHeader } from '../print/session-print-header.js';
27
30
  import { useSessionPrint } from '../print/use-session-print.js';
@@ -48,12 +51,15 @@ import { sessionSlashFiles } from '../composer/menus/slash-files.js';
48
51
  import { resolveFirstPromptHandover, transcriptCarriesFirstPrompt, } from './first-prompt-handover.js';
49
52
  import { CompactModal } from '../header/compact-modal.js';
50
53
  import { SessionSiteHeader } from '../header/session-site-header.js';
51
- import { VoiceCallSlot } from '../voice/voice-call.js';
52
54
  import { claimFirstTurnRow } from '../composer/inbox-row-claims.js';
53
55
  import { OptimisticTurn } from './optimistic-turn.js';
54
56
  import { inboxHoldsLivePrompt } from '../composer/inbox-live-prompt.js';
55
57
  import { SessionOutcomesProvider } from '../outcomes/session-outcomes-provider.js';
58
+ import { deleteMessageLinkParams, readMessageLinkParams, resolveMessageLinkTurn } from '../../internal/lib/navigation/message-link.js';
59
+ /** How long a message link waits for the transcript's turns to mount before it jumps anyway. */
60
+ const MESSAGE_LINK_MOUNT_WAIT_MS = 8_000;
56
61
  import { SessionOverridesComposer } from '../overrides/session-overrides-composer.js';
62
+ import { inheritedModelFor } from '../composer/chat-input/chat-input-summary.js';
57
63
  import { QuestionPrompt, } from '../prompts/question-prompt.js';
58
64
  import { SESSION_TRANSCRIPT_CLASS, SessionBodyRow } from './session-body.js';
59
65
  import { SessionContextModal } from './session-context-modal.js';
@@ -74,6 +80,7 @@ import { ChatMinimap } from './chat-minimap.js';
74
80
  import { usePlanInChat } from './plan-surface.js';
75
81
  import { SessionStartingLoader } from '../status/session-starting-loader.js';
76
82
  import { ToolActivateContext } from '../tool/tool-renderers.js';
83
+ import { AgentActivateContext } from '../tool/shared/infrastructure-contexts.js';
77
84
  import { ReadOnlySessionContext } from '../tool/shared/infrastructure-contexts.js';
78
85
  import { firstPromptAttachments, retainSentAttachmentPreviews, sentAttachmentsForTurn, } from '../composer/sent-attachment-previews.js';
79
86
  import { buildOptimisticPromptTextWithUploads, promptFileParts, sentAttachmentsOf, } from '../composer/uploaded-file-refs.js';
@@ -95,7 +102,7 @@ import { getRetryInfo } from '../../internal/session-types/index.js';
95
102
  import { useModelPricingLookup } from '../../internal/lib/model-pricing.js';
96
103
  import { isAbortError, latestPromptModel, SESSION_NOTICE, turnEndNotice } from '@kortix/sdk';
97
104
  import { failureShownByTurn, failureSupersededByTurn, persistedFailureText, } from './persisted-turn-failure.js';
98
- import { abandonOptimisticSend, applyOptimisticAbort, ascendingId, awaitAbortSettlement, beginOptimisticSend, classifySendError, clearStartStash, formatModelString, formatPromptModel, markOptimisticSendDispatched, markOptimisticSendInboxBacked, mintSessionWireMessageId, readStartStash, recoverFromSendFailure, rejectQuestion, replyToPermission, replyToQuestion, requestRuntimeReconnect, startSessionWithPrompt, useAbortRuntimeSession, useExecuteRuntimeCommand, useProjectConfig, useRuntimeAgents, useProjectSpaces, useRuntimeBootStalled, useRuntimeCommands, useRuntimeConfig, useRuntimeConnectionStore, useRuntimePendingStore, useRuntimePhase, useRuntimeProviders, useRuntimeReady, useRuntimeSession, useRuntimeSessions, useRuntimeSupports, useSessionModelSelection, useSessionPrompts, useSessionStateStore, useSessionSync, useSessionTurnOutcome, useSessionWorking, useSessionWorkingStore, } from '@kortix/sdk/react';
105
+ import { abandonOptimisticSend, applyOptimisticAbort, ascendingId, awaitAbortSettlement, beginOptimisticSend, classifySendError, clearStartStash, formatModelString, formatPromptModel, markOptimisticSendDispatched, markOptimisticSendInboxBacked, mintSessionWireMessageId, readStartStash, recoverFromSendFailure, rejectQuestion, replyToPermission, replyToQuestion, requestRuntimeReconnect, startSessionWithPrompt, useAbortRuntimeSession, useExecuteRuntimeCommand, useProjectConfig, useRuntimeAgents, useProjectSpaces, useRuntimeBootStalled, useRuntimeCommands, useRuntimeConfig, useRuntimeConnectionStore, useRuntimePendingStore, useRuntimePhase, useRuntimeProviders, useRuntimeReady, useRuntimeSession, useRuntimeSessions, useRuntimeSupports, useSessionModelSelection, useSessionPrompts, useSessionStateStore, useSessionSync, useSessionTurnOutcome, useSessionWorking, useSessionWorkingStore, useAnswerSessionAsk, useSessionNeedsYou, } from '@kortix/sdk/react';
99
106
  import { useStableCallback } from '../../internal/hooks/use-stable-callback.js';
100
107
  import { useReloadForensics } from '../status/reload-forensics.js';
101
108
  import { resolveLastTurnWorking, serverHoldsOpenTurn, sessionComposerReadiness, } from '../composer/session-composer-readiness.js';
@@ -186,10 +193,11 @@ function hostNotice(notice, notices) {
186
193
  const key = Object.keys(SESSION_NOTICE).find((candidate) => SESSION_NOTICE[candidate] === notice);
187
194
  return (key && notices[key]) || notice;
188
195
  }
189
- export function SessionChat({ sessionId, projectSessionId, sessionState, projectId, boundAgentName, headerLeadingAction, hideHeader, readOnly, composerPlaceholder, inputReplacement, initialScrollTop, savedHistoryScope, onContentReady, deferComposerFocus, hostQuote, }) {
196
+ export function SessionChat({ sessionId, projectSessionId, sessionState, projectId, boundAgentName, headerLeadingAction, hideHeader, transparent = false, readOnly, composerPlaceholder, inputReplacement, initialScrollTop, savedHistoryScope, onContentReady, deferComposerFocus, hostQuote, }) {
190
197
  const tHardcodedUi = useTranslations('hardcodedUi');
191
198
  // A channel's thread panel: turns are message rows, full width, end-anchored.
192
199
  const rowsContext = useContext(TranscriptRowsContext);
200
+ const composerAutoFocus = useContext(ComposerAutoFocusContext);
193
201
  const transcriptRows = rowsContext !== null;
194
202
  const isMobile = useIsMobile();
195
203
  const isPhone = useIsPhone();
@@ -229,6 +237,17 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
229
237
  track('panel_opened', { source: 'chat_tool' });
230
238
  }, [sessionId, setSidePanelView, focusToolCall]);
231
239
  const toolActivate = readOnly || disableToolNavigation ? null : handleToolActivate;
240
+ // Clicking an agent (a sub-agent row, its finish notice, a workflow agent, the
241
+ // agents line) opens that agent's session in the side panel, beside the chat.
242
+ const focusAgent = useKortixComputerStore((s) => s.focusAgent);
243
+ const handleAgentActivate = useCallback((agent) => {
244
+ const wasOpen = useKortixComputerStore.getState().isSidePanelOpen;
245
+ setSidePanelView(sessionId, 'actions');
246
+ focusAgent(agent);
247
+ if (!wasOpen)
248
+ track('panel_opened', { source: 'chat_agent' });
249
+ }, [sessionId, setSidePanelView, focusAgent]);
250
+ const agentActivate = readOnly || disableToolNavigation ? null : handleAgentActivate;
232
251
  // ---- Context modal ----
233
252
  const [contextModalOpen, setContextModalOpen] = useState(false);
234
253
  // The composer's `/compact` row opens this instance; the header keeps its
@@ -1363,8 +1382,30 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
1363
1382
  // ---- Pending permissions & questions ----
1364
1383
  const allPermissions = useRuntimePendingStore((s) => s.permissions);
1365
1384
  const allQuestions = useRuntimePendingStore((s) => s.questions);
1366
- const pendingPermissions = useMemo(() => sessionState?.permissions ??
1385
+ const livePermissions = useMemo(() => sessionState?.permissions ??
1367
1386
  Object.values(allPermissions).filter((p) => p.sessionID === sessionId), [sessionState?.permissions, allPermissions, sessionId]);
1387
+ // Asks that parked: nobody answered live, the agent went on, and the ask
1388
+ // waits server-side (Review, "Needs you"). They render with the same cards
1389
+ // and are decided through the asks API, which resumes the session that
1390
+ // asked (a hidden worker's asks show here too). Live asks keep their cards.
1391
+ const parkedAsks = useSessionNeedsYou(projectId ?? '', projectSessionId ?? '', {
1392
+ enabled: Boolean(projectId && projectSessionId),
1393
+ }).asks;
1394
+ const parkedAskIdByRequest = useMemo(() => new Map(parkedAsks.filter((ask) => ask.kind !== 'approval').map((ask) => [ask.request_id, ask.id])), [parkedAsks]);
1395
+ const pendingPermissions = useMemo(() => {
1396
+ const live = new Set(livePermissions.map((p) => p.id));
1397
+ const parked = parkedAsks
1398
+ .filter((ask) => ask.kind === 'permission' && ask.permission && !live.has(ask.request_id))
1399
+ .map((ask) => ({
1400
+ id: ask.request_id,
1401
+ sessionID: sessionId,
1402
+ permission: ask.permission.permission,
1403
+ patterns: ask.permission.patterns,
1404
+ metadata: ask.permission.args && typeof ask.permission.args === 'object' ? ask.permission.args : {},
1405
+ always: ['*'],
1406
+ }));
1407
+ return parked.length ? [...livePermissions, ...parked] : livePermissions;
1408
+ }, [livePermissions, parkedAsks, sessionId]);
1368
1409
  const suppressedQuestionIdsRef = useRef(new Map());
1369
1410
  const suppressQuestionFor = useCallback((requestId, ms = 15000) => {
1370
1411
  suppressedQuestionIdsRef.current.set(requestId, Date.now() + ms);
@@ -1379,8 +1420,15 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
1379
1420
  }
1380
1421
  return true;
1381
1422
  }, []);
1382
- const pendingQuestions = useMemo(() => (sessionState?.questions ??
1423
+ const liveQuestions = useMemo(() => (sessionState?.questions ??
1383
1424
  Object.values(allQuestions).filter((q) => q.sessionID === sessionId)).filter((q) => !isQuestionSuppressed(q.id)), [sessionState?.questions, allQuestions, sessionId, isQuestionSuppressed]);
1425
+ const pendingQuestions = useMemo(() => {
1426
+ const live = new Set(liveQuestions.map((q) => q.id));
1427
+ const parked = parkedAsks
1428
+ .filter((ask) => ask.kind === 'question' && ask.question && !live.has(ask.request_id) && !isQuestionSuppressed(ask.request_id))
1429
+ .map((ask) => ({ id: ask.request_id, sessionID: sessionId, questions: ask.question.questions }));
1430
+ return parked.length ? [...liveQuestions, ...parked] : liveQuestions;
1431
+ }, [liveQuestions, parkedAsks, sessionId, isQuestionSuppressed]);
1384
1432
  /**
1385
1433
  * The runtime is parked on an answer only the user can give.
1386
1434
  *
@@ -1396,7 +1444,8 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
1396
1444
  * come back the instant the agent is running again, not a third of a second
1397
1445
  * later.
1398
1446
  */
1399
- const awaitingUserInput = pendingQuestions.length > 0 || pendingPermissions.length > 0;
1447
+ // Live asks only: a parked ask no longer holds the turn.
1448
+ const awaitingUserInput = liveQuestions.length > 0 || livePermissions.length > 0;
1400
1449
  const QUESTION_PROMPT_ANIMATION_MS = 320;
1401
1450
  const activePendingQuestion = pendingQuestions[0] ?? null;
1402
1451
  // A new question docks over the bottom of the transcript, and answering it
@@ -1954,7 +2003,15 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
1954
2003
  // ---- Permission/question reply handlers ----
1955
2004
  const removePermission = useRuntimePendingStore((s) => s.removePermission);
1956
2005
  const removeQuestion = useRuntimePendingStore((s) => s.removeQuestion);
2006
+ const answerParkedAsk = useAnswerSessionAsk(projectId ?? '');
1957
2007
  const handlePermissionReply = useCallback(async (requestId, reply) => {
2008
+ // A parked ask: the call no longer waits, so the decision goes through
2009
+ // the asks API (it reaches the agent as a message).
2010
+ const parkedAskId = livePermissions.some((p) => p.id === requestId) ? undefined : parkedAskIdByRequest.get(requestId);
2011
+ if (parkedAskId) {
2012
+ await answerParkedAsk.mutateAsync({ askId: parkedAskId, answer: { reply } });
2013
+ return;
2014
+ }
1958
2015
  // No optimistic remove: only drop the card once the runtime accepted the
1959
2016
  // reply — a failed reply must stay answerable. Rethrow so callers
1960
2017
  // (prompt buttons) reset their busy state and surface the error.
@@ -1965,7 +2022,7 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
1965
2022
  await replyToPermission(requestId, reply);
1966
2023
  removePermission(requestId);
1967
2024
  }
1968
- }, [sessionState, removePermission]);
2025
+ }, [sessionState, removePermission, livePermissions, parkedAskIdByRequest, answerParkedAsk]);
1969
2026
  const handleQuestionReply = useCallback(async (requestId, answers) => {
1970
2027
  // Snapshot the question BEFORE removing it so we can cache the
1971
2028
  // answer against the tool part's ID.
@@ -1974,6 +2031,12 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
1974
2031
  suppressQuestionFor(requestId);
1975
2032
  // Optimistically remove the question so the textarea shows immediately
1976
2033
  removeQuestion(requestId);
2034
+ const parkedAskId = liveQuestions.some((q) => q.id === requestId) ? undefined : parkedAskIdByRequest.get(requestId);
2035
+ if (parkedAskId) {
2036
+ // Parked: the answer reaches the agent as a message that quotes the question.
2037
+ answerParkedAsk.mutate({ askId: parkedAskId, answer: { answers } });
2038
+ return;
2039
+ }
1977
2040
  // Save the answers in the optimistic cache keyed by the question call's
1978
2041
  // block id. This cache survives updates that may overwrite the call
1979
2042
  // before the server includes its answers; the transcript's answered
@@ -2000,11 +2063,17 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
2000
2063
  catch {
2001
2064
  // ignore — SSE "question.replied" event will also remove it
2002
2065
  }
2003
- }, [sessionState, removeQuestion, suppressQuestionFor]);
2066
+ }, [sessionState, removeQuestion, suppressQuestionFor, liveQuestions, parkedAskIdByRequest, answerParkedAsk]);
2004
2067
  const handleQuestionReject = useCallback(async (requestId) => {
2005
2068
  suppressQuestionFor(requestId);
2006
2069
  // Optimistically remove the question so the textarea shows immediately
2007
2070
  removeQuestion(requestId);
2071
+ const parkedAskId = liveQuestions.some((q) => q.id === requestId) ? undefined : parkedAskIdByRequest.get(requestId);
2072
+ if (parkedAskId) {
2073
+ // Dismissing a parked question closes it; nothing runs, so nothing is stopped.
2074
+ answerParkedAsk.mutate({ askId: parkedAskId, answer: { dismiss: true } });
2075
+ return;
2076
+ }
2008
2077
  try {
2009
2078
  if (sessionState)
2010
2079
  await sessionState.rejectQuestion(requestId);
@@ -2067,7 +2136,8 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
2067
2136
  useEffect(() => {
2068
2137
  outcomeJumpRef.current = { sessionId, hasOlder, isLoadingOlder, loadOlder };
2069
2138
  }, [sessionId, hasOlder, isLoadingOlder, loadOlder]);
2070
- const handleJumpToOutcome = useCallback(async (resolveTurn, createdAt) => {
2139
+ // `quiet`: a jump the reader did not click (a `?m=` link) fails silently, without the change-request toasts.
2140
+ const handleJumpToOutcome = useCallback(async (resolveTurn, createdAt, quiet = false) => {
2071
2141
  if (jumpingToOutcome)
2072
2142
  return;
2073
2143
  setJumpingToOutcome(true);
@@ -2084,9 +2154,12 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
2084
2154
  settle,
2085
2155
  },
2086
2156
  resolve: () => outcomeJumpRef.current.sessionId === currentSession ? resolveTurn() : undefined,
2087
- loadError: () => errorToast(tChangeRequests('loadError')),
2157
+ loadError: () => {
2158
+ if (!quiet)
2159
+ errorToast(tChangeRequests('loadError'));
2160
+ },
2088
2161
  unavailable: () => {
2089
- if (outcomeJumpRef.current.sessionId === currentSession)
2162
+ if (!quiet && outcomeJumpRef.current.sessionId === currentSession)
2090
2163
  errorToast(tChangeRequests('unavailable'));
2091
2164
  },
2092
2165
  scroll: async (key) => {
@@ -2116,7 +2189,8 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
2116
2189
  });
2117
2190
  }
2118
2191
  catch {
2119
- errorToast(tChangeRequests('loadError'));
2192
+ if (!quiet)
2193
+ errorToast(tChangeRequests('loadError'));
2120
2194
  }
2121
2195
  finally {
2122
2196
  setJumpingToOutcome(false);
@@ -3319,10 +3393,14 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
3319
3393
  // (Claude Code's agent panel). It reads its own lists and never holds the composer.
3320
3394
  const agentsLineCompact = !!transcriptRows && !isPhone;
3321
3395
  const chatUnderbarSlot = useMemo(() => _jsx(AgentsLine, { projectId: projectId, sessionId: projectSessionId, compact: agentsLineCompact }), [projectId, projectSessionId, agentsLineCompact]);
3396
+ // A space's thread lists only the queue's live messages in its card: failed
3397
+ // ones and a Stop hold read as calm lines (`ChatQueueLines`), reports wait behind Resume.
3398
+ const calmRest = useMemo(() => [...queueRows.rows, ...heldCommandRows(heldCommands)].filter((row) => row.state !== 'failed' && !row.synthetic), [queueRows.rows, heldCommands]);
3322
3399
  // The queued messages and the one Resume while a Stop holds the queue: their
3323
- // own full-width card above the composer stack, not inside the strip. A live
3324
- // voice call is the card above them (nothing unless a call is open).
3325
- const chatAboveSlot = useMemo(() => (_jsxs(_Fragment, { children: [_jsx(VoiceCallSlot, { sessionId: projectSessionId }), _jsx(QueuedPromptList, { rows: heldCommands.length > 0 ? [...queueRows.rows, ...heldCommandRows(heldCommands)] : queueRows.rows, heldCount: queueRows.heldCount, resumePending: resumePending, onResume: () => void handleResumeQueue(), onEdit: (id) => {
3400
+ // own full-width card above the composer stack, not inside the strip.
3401
+ const chatAboveSlot = useMemo(() => (_jsx(_Fragment, { children: rowsContext?.messagesOnly ? (
3402
+ // A space's thread: calm lines ("Not sent · Retry", "Stopped · Resume"), the card only for queued messages.
3403
+ _jsx(ChatQueueLines, { rows: queueRows.rows, heldCount: queueRows.heldCount, resumePending: resumePending, onResume: () => void handleResumeQueue(), onRetry: handleRetryQueuedMessage, children: calmRest.length > 0 ? (_jsx(QueuedPromptList, { rows: calmRest, heldCount: 0, resumePending: resumePending, onResume: () => void handleResumeQueue(), onEdit: (id) => {
3326
3404
  queueEdit.takeBack(id);
3327
3405
  }, onRemove: (id) => {
3328
3406
  if (id.startsWith(HELD_COMMAND_ROW_PREFIX)) {
@@ -3331,8 +3409,18 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
3331
3409
  return;
3332
3410
  }
3333
3411
  void handleRemoveQueuedMessage(id);
3334
- }, onRetry: handleRetryQueuedMessage, onStopAndSend: effectiveBusy && canStop ? handleStopAndSendQueuedMessage : undefined, editing: queueEdit.editing, onCancelEdit: queueEdit.cancel })] })), [
3335
- projectSessionId,
3412
+ }, onRetry: handleRetryQueuedMessage, onStopAndSend: effectiveBusy && canStop ? handleStopAndSendQueuedMessage : undefined, editing: queueEdit.editing, onCancelEdit: queueEdit.cancel })) : null })) : (_jsx(QueuedPromptList, { rows: heldCommands.length > 0 ? [...queueRows.rows, ...heldCommandRows(heldCommands)] : queueRows.rows, heldCount: queueRows.heldCount, resumePending: resumePending, onResume: () => void handleResumeQueue(), onEdit: (id) => {
3413
+ queueEdit.takeBack(id);
3414
+ }, onRemove: (id) => {
3415
+ if (id.startsWith(HELD_COMMAND_ROW_PREFIX)) {
3416
+ const heldId = id.slice(HELD_COMMAND_ROW_PREFIX.length);
3417
+ setHeldCommands((held) => held.filter((entry) => entry.id !== heldId));
3418
+ return;
3419
+ }
3420
+ void handleRemoveQueuedMessage(id);
3421
+ }, onRetry: handleRetryQueuedMessage, onStopAndSend: effectiveBusy && canStop ? handleStopAndSendQueuedMessage : undefined, editing: queueEdit.editing, onCancelEdit: queueEdit.cancel })) })), [
3422
+ rowsContext?.messagesOnly,
3423
+ calmRest,
3336
3424
  heldCommands,
3337
3425
  queueEdit.editing,
3338
3426
  queueEdit.cancel,
@@ -3521,6 +3609,65 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
3521
3609
  if (crParam)
3522
3610
  setOpenCrIdState(crParam);
3523
3611
  }, [crParam]);
3612
+ // ---- Message link: `?m=<message_id>&at=<ms>` (the gateway request log's "Open in session") ----
3613
+ // Once per link, after the transcript first paints: page back until the turn
3614
+ // is loaded, scroll to it, flash it, then drop `m`/`at` so a reload stays put.
3615
+ const messageLink = readOnly ? null : readMessageLinkParams(searchParams);
3616
+ const messageLinkKey = messageLink ? `${sessionId}|${messageLink.messageId ?? ''}|${messageLink.at ?? ''}` : null;
3617
+ const linkTurnsRef = useRef(turns);
3618
+ useEffect(() => {
3619
+ linkTurnsRef.current = turns;
3620
+ }, [turns]);
3621
+ const jumpedLinkRef = useRef(null);
3622
+ useEffect(() => {
3623
+ if (!messageLink || !messageLinkKey || isDataLoading || turns.length === 0)
3624
+ return;
3625
+ if (jumpedLinkRef.current === messageLinkKey)
3626
+ return;
3627
+ jumpedLinkRef.current = messageLinkKey;
3628
+ const resolve = () => resolveMessageLinkTurn(linkTurnsRef.current, messageLink);
3629
+ // An in-app navigation has the transcript cached: `turns` exist frames before
3630
+ // their `[data-turn-id]` nodes mount, and the first paint scrolls to the
3631
+ // bottom. Jump only once the turns are in the DOM and that scroll has run,
3632
+ // else the scroll finds no node and the link lands at the bottom.
3633
+ let cancelled = false;
3634
+ let jumped = false;
3635
+ const startedAt = Date.now();
3636
+ const jump = () => {
3637
+ jumped = true;
3638
+ // Already on screen: no history to load. Else `at`, or NaN (load it all) for an id alone.
3639
+ const createdAt = resolve() ? Number.MAX_SAFE_INTEGER : (messageLink.at ?? Number.NaN);
3640
+ void handleJumpToOutcome(resolve, createdAt, true).finally(() => {
3641
+ const params = new URLSearchParams(searchParams?.toString());
3642
+ deleteMessageLinkParams(params);
3643
+ const qs = params.toString();
3644
+ shallowNavigate(qs ? `${pathname}?${qs}` : pathname, { replace: true });
3645
+ });
3646
+ };
3647
+ const waitForTurns = () => {
3648
+ if (cancelled)
3649
+ return;
3650
+ const mounted = !!contentRef.current?.querySelector('[data-turn-id]');
3651
+ if (!mounted && Date.now() - startedAt < MESSAGE_LINK_MOUNT_WAIT_MS) {
3652
+ window.setTimeout(waitForTurns, 100);
3653
+ return;
3654
+ }
3655
+ // Two frames: the first paint's bottom scroll lands before the jump, never after it.
3656
+ requestAnimationFrame(() => requestAnimationFrame(() => {
3657
+ if (!cancelled)
3658
+ jump();
3659
+ }));
3660
+ };
3661
+ waitForTurns();
3662
+ return () => {
3663
+ cancelled = true;
3664
+ // A wait cancelled before it jumped runs again on the next pass; a jump in flight is not repeated.
3665
+ if (!jumped && jumpedLinkRef.current === messageLinkKey)
3666
+ jumpedLinkRef.current = null;
3667
+ };
3668
+ // `messageLinkKey` stands for `messageLink`, which is a new object every render.
3669
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3670
+ }, [messageLinkKey, isDataLoading, turns.length, handleJumpToOutcome, searchParams, pathname, shallowNavigate, contentRef]);
3524
3671
  const handleOpenOutcome = useCallback((outcome) => {
3525
3672
  // Change requests are the only kind a turn produces. `external` exists on
3526
3673
  // the union for `setup-links/setup-link-button.tsx`, which renders this
@@ -3544,304 +3691,306 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
3544
3691
  // an eternal loader. Only with nothing to paint: once any message is on
3545
3692
  // screen, staleness is repaired in the background instead.
3546
3693
  if (transcriptFreshness === 'error' && !hasMessages) {
3547
- return (_jsx("div", { className: "bg-background relative flex h-full flex-col", "data-testid": "session-chat", children: _jsxs("div", { className: "flex flex-1 flex-col items-center justify-center gap-3 p-6", "data-testid": "session-transcript-error", children: [_jsx("p", { className: "text-muted-foreground text-sm", children: tHardcodedUi.raw('i18nComplete.text8d0cef2d3405') }), _jsx(Button, { variant: "outline", size: "sm", onClick: () => retryTranscript(), children: tHardcodedUi.raw('i18nComplete.text942087cc2d41') })] }) }));
3694
+ return (_jsx("div", { className: cn('relative flex h-full flex-col', !transparent && 'bg-background'), "data-testid": "session-chat", children: _jsxs("div", { className: "flex flex-1 flex-col items-center justify-center gap-3 p-6", "data-testid": "session-transcript-error", children: [_jsx("p", { className: "text-muted-foreground text-sm", children: tHardcodedUi.raw('i18nComplete.text8d0cef2d3405') }), _jsx(Button, { variant: "outline", size: "sm", onClick: () => retryTranscript(), children: tHardcodedUi.raw('i18nComplete.text942087cc2d41') })] }) }));
3548
3695
  }
3549
- return (_jsx("div", { className: "bg-background relative flex h-full flex-col", "data-testid": "session-chat", children: _jsx(SessionStartingLoader, { projectId: projectId, sessionId: projectSessionId }) }));
3696
+ return (_jsx("div", { className: cn('relative flex h-full flex-col', !transparent && 'bg-background'), "data-testid": "session-chat", children: _jsx(SessionStartingLoader, { projectId: projectId, sessionId: projectSessionId }) }));
3550
3697
  }
3551
3698
  return (
3552
3699
  // A read-only view (the sub-session modal) offers no fix inside a tool card.
3553
- _jsx(ReadOnlySessionContext.Provider, { value: !!readOnly, children: _jsx(SessionPromptContext.Provider, { value: readOnly ? null : sendSessionPrompt, children: _jsx(ProjectFilesProvider, { value: { projectId: projectId ?? '', ref: outcomesBaseRef, defaultBranch: outcomesBaseRef }, children: _jsxs(ComposerDropZone, { className: cn('relative flex h-full flex-col',
3554
- // Transparent in the welcome state so the root-level full-bleed wallpaper
3555
- // (portaled into SessionLayout) reads through; solid once real content
3556
- // takes over. Same base color either way, so non-welcome is unchanged.
3557
- shouldShowWelcomeOverlay ? 'bg-transparent' : 'bg-background'), "data-testid": "session-chat", children: [isPreparingPrint && (_jsxs("div", { "data-print-hide": true, role: "status", className: "bg-popover text-muted-foreground fixed bottom-6 left-1/2 z-50 flex -translate-x-1/2 items-center gap-2 rounded-lg border px-4 py-2 text-xs shadow-lg", children: [_jsx(Loading, { className: "size-3.5 shrink-0" }), tHardcodedUi.raw('i18nComplete.text7dac2ca010fe')] })), wallpaperLayer
3558
- ? welcomeWallpaper && createPortal(welcomeWallpaper, wallpaperLayer)
3559
- : welcomeWallpaper, !hideHeader && (_jsx(SessionSiteHeader, { sessionId: sessionId, sessionTitle: session?.title || 'Untitled', leadingAction: headerLeadingAction, parent: parentCrumb })), _jsx(SessionContextModal, { open: contextModalOpen, onOpenChange: setContextModalOpen,
3560
- // A chat with no `useSession` source: the raw explorer lists the
3561
- // rows `useSessionSync` read for it.
3562
- detachedRows: sessionState ? undefined : hookMessages, source: sessionState ?? DETACHED_SESSION_MESSAGES, session: session, sessionRow: projectSessionRow, providers: providers, allSessions: allSessions, servedModel: sessionServedModel, billedCost: sessionBilledCost(modelUsage) }), _jsx(CompactModal, { sessionId: sessionId, open: compactModalOpen, onOpenChange: setCompactModalOpen }), _jsx(ChangeRequestDetailDialog, { crId: openCrId, onClose: () => setOpenCrId(null), onOpenChangeRequest: setOpenCrId }), _jsxs(SessionBodyRow, { actionPanel: !hideHeader && !readOnly, children: [isNotFound ? (_jsxs("div", { className: "flex min-h-0 flex-1 flex-col items-center justify-center gap-3 px-6 text-center", children: [_jsx("div", { className: "text-muted-foreground text-sm", children: tHardcodedUi.raw('componentsSessionSessionChat.line5821JsxTextThisSessionIsNotAccessibleRightNow') }), _jsx(Button, { asChild: true, variant: "outline", size: "sm", children: _jsx(Link, { href: "/", prefetch: true, onClick: () => {
3563
- try {
3564
- if (sessionId)
3565
- useTabStore.getState().closeTab?.(sessionId);
3566
- }
3567
- catch { }
3568
- }, children: tHardcodedUi.raw('componentsSessionSessionChat.line5833JsxTextGoToHome') }) })] })) : (_jsxs("div", { ref: chatAreaRef, className: "relative z-10 min-h-0 flex-1", children: [_jsx("div", { ref: scrollContainerCallbackRef, className: cn(
3569
- // overflow-anchor:none — this scroll area does ALL of its own
3570
- // anchoring (useAutoScroll's spacer + RAF follow, the send-path
3571
- // turn anchor, and the history-prepend content-space restore in
3572
- // session-history-scroll.ts). The browser's native scroll
3573
- // anchoring (default `overflow-anchor: auto`) tries to
3574
- // compensate for the SAME prepends independently, and the two
3575
- // corrections stacking is the other half of the scroll-up
3576
- // teleport: ours restores the reader's position, then the
3577
- // native one nudges it again.
3578
- 'scrollbar-hide relative z-10 h-full flex-1 overflow-y-auto [scroll-behavior:auto] [overflow-anchor:none]', shouldShowWelcomeOverlay ? 'bg-transparent' : 'bg-background'), onMouseUp: handleChatMouseUp, onMouseDown: handleChatMouseDown, onScroll: handleChatScroll, children: _jsxs("div", { ref: contentRef, role: "log",
3579
- // Width and gutters live in `SESSION_TRANSCRIPT_CLASS`: the
3580
- // instant shell draws this same column and the two crossfade
3581
- // into each other, so a difference here is a sideways jump on
3582
- // screen, not a style opinion. See session-body.tsx.
3583
- //
3584
- // No bottom padding, there or here: the space under the last
3585
- // message is the auto-scroll spacer's job alone. The `pb-32`
3586
- // that used to sit here stacked 128px of dead space on top of
3587
- // it — the "extra inset at the bottom of the session".
3588
- // Rows run edge to edge: each row owns its gutters and its hover fill.
3589
- className: transcriptRows ? 'w-full min-w-0 pt-4' : SESSION_TRANSCRIPT_CLASS, children: [_jsxs("div", { className: "flex min-w-0 flex-col", children: [_jsx(SessionPrintHeader, { title: session?.title || 'Untitled', agentName: composerAgentName }), (hasOlder || showOlderLoading) && (_jsxs("div", { className: "mb-6 flex flex-col items-center gap-2", children: [hasOlder && (_jsx("div", { ref: olderSentinelRef, "aria-hidden": true, className: "h-px w-full" })), showOlderLoading && (_jsxs("div", { role: "status", className: "text-muted-foreground flex items-center gap-2 py-1 text-xs", children: [_jsx(Loading, { className: "size-3.5 shrink-0" }), tHardcodedUi.raw('i18nComplete.text85bf890776a7')] })), !showOlderLoading &&
3590
- !olderPullFailed &&
3591
- olderAutoloadExhausted({ hasOlder, autoLoadedPages }) && (_jsx(Button, { type: "button", variant: "outline-ghost", size: "sm", onClick: () => void handleLoadOlder(), children: tHardcodedUi.raw('i18nComplete.textf17671d83db0') })), olderPullFailed && !showOlderLoading && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-muted-foreground text-xs", children: tHardcodedUi.raw('i18nComplete.textb03a0041ce33') }), _jsx(Button, { type: "button", variant: "outline-ghost", size: "sm", onClick: () => void handleLoadOlder(), children: tHardcodedUi.raw('i18nComplete.text942087cc2d41') })] }))] })), restoreNotice && !restoreDismissed && (_jsx(RestoreNotice, { notice: restoreNotice, onDismiss: () => dismissRestore(historyKey, restoreNotice.generation) })), _jsx(SessionOutcomesProvider, { projectSessionId: projectSessionId, turnSpans: turnSpans, busy: effectiveBusy, onOpen: handleOpenOutcome, onJump: handleJumpToOutcome, jumping: jumpingToOutcome, children: _jsxs(ToolActivateContext.Provider, { value: toolActivate, children: [showFirstPromptPreview &&
3592
- firstPromptSource &&
3593
- queuedSyntheticMessages.length === 0 &&
3594
- rowsContext && (
3595
- // A channel thread draws the stand-in as rows, the same
3596
- // rows its boot body drew (`ThreadBootRows`).
3597
- _jsx(PendingPromptRows, { text: buildOptimisticPromptTextWithUploads(firstPromptSource.text, firstPromptSource.files), author: rowsContext.owner, sessionId: sessionId, busy: turns.length === 0 && (lastTurnWorking || promptInbox.prompts.some(isFirstPromptRow)) })), showFirstPromptPreview &&
3598
- firstPromptSource &&
3599
- queuedSyntheticMessages.length === 0 &&
3600
- !rowsContext && (_jsx(OptimisticTurn, { text: buildOptimisticPromptTextWithUploads(firstPromptSource.text, firstPromptSource.files),
3601
- // Preserve a real failed-send status through the
3602
- // boot-shell handover without inventing upload progress.
3603
- // A first prompt held on its uploads carries its own.
3604
- uploadStatus: firstPromptSource.uploadStatus ?? firstPromptUploadStatus, agentNames: agentNames, onFileClick: openFileInComputer, sessionId: sessionId,
3605
- // The first item of the conversation, like turn 0, which has no
3606
- // top margin. `first:mt-0` misses here: the list opens with a
3607
- // zero-height <header>, so the stand-in sat 44px lower than turn 0
3608
- // and every swap between the two jumped the bubble (KRTX-2931).
3609
- className: "mt-0",
3610
- // An undelivered first prompt is a turn about to start, as the
3611
- // shell above this chat shows it: busy from the first frame,
3612
- // before the working projection has read the inbox (KRTX-2931).
3613
- busy: turns.length === 0 && (lastTurnWorking || promptInbox.prompts.some(isFirstPromptRow)) })), turns.map((turn, turnIndex) => {
3614
- // Check if this turn is a compaction summary — and
3615
- // whether it actually PRODUCED one. A failed/aborted
3616
- // attempt (compaction-flagged, no content, not the
3617
- // working turn) renders as one slim row, draws no
3618
- // divider, and stacks tight against a neighbouring
3619
- // failed attempt.
3620
- const compaction = turn.compaction;
3621
- const hasCompaction = compaction !== null;
3622
- const isTurnWorking = turn.live;
3623
- // `inFlight` (message state) alongside the projection:
3624
- // classifying by projection alone flipped a streaming
3625
- // compaction to "failed" for the frames where the two
3626
- // disagree, popping the divider in and out — a layout
3627
- // bounce right where the reader is looking.
3628
- const isFailedCompaction = compaction !== null &&
3629
- !compaction.hasContent &&
3630
- !compaction.inFlight &&
3631
- !isTurnWorking;
3632
- // Retries collapse to ONE visible row, GLOBALLY: a
3633
- // failed attempt with ANY later compaction turn (a
3634
- // retry, or the one that finally landed) is history —
3635
- // it keeps its TurnViewport (stable keys, scroll
3636
- // anchors) but renders no content, and an empty
3637
- // TurnViewport costs 0px (turn-viewport.tsx RULE 2).
3638
- // Adjacency was not enough: attempts whose error landed
3639
- // on a plain assistant message used to interleave as
3640
- // unclassified turns, breaking every consecutive run.
3641
- const suppressedFailedCompaction = isFailedCompaction && turnIndex < lastCompactionTurnIndex;
3642
- // Notification-only early-return removed: it rendered the
3643
- // user's pty_* card but skipped the turn's replies,
3644
- // hiding every subsequent assistant response in that turn.
3645
- // Fall through to the normal turn renderer instead.
3646
- const confirmedActive = turnIsConfirmedActive({
3647
- isTurnWorking,
3648
- turnId: turn.id,
3649
- activeTurnId,
3650
- pendingDelivery: !!working.pendingDelivery,
3651
- });
3652
- const pendingPrompt = !confirmedActive && turn.assistant.length === 0
3653
- ? pendingPromptsByMessageId.get(turn.id)
3654
- : undefined;
3655
- // A queued prompt is not in the runtime transcript yet;
3656
- // its author still shows (`authorForTurn`).
3657
- const promptAuthorId = pendingPromptsByMessageId.get(turn.id)?.author_user_id;
3658
- const turnAuthor = authorForTurn(transcriptAuthors, messageAuthors, turn.id, pendingPrompt?.wire_message_id) ??
3659
- participantAuthor(sessionParticipants, promptAuthorId) ??
3660
- (sentHereIds.current.has(turn.id) ||
3661
- sentHereIds.current.has(turnRenderKeys.get(turn.id) ?? '') ||
3662
- (viewerId !== undefined && promptAuthorId === viewerId) ||
3663
- // The first prompt of a session the viewer started,
3664
- // sent from another surface (project home), before
3665
- // the first authors read lands.
3666
- (messageAuthorsLoading &&
3667
- viewerId !== undefined &&
3668
- projectSessionRow?.created_by === viewerId &&
3669
- turn.id === userMessageIds[0])
3670
- ? viewerAsAuthor
3671
- : undefined);
3672
- return (_jsx(TranscriptTurnRow
3673
- // ONE element per prompt: keyed by the id the
3674
- // bubble was FIRST painted under, so the swap to a
3675
- // re-minted echo id re-renders this node instead
3676
- // of mounting a new one (opacity keeps animating,
3677
- // hover state survives, nothing jumps).
3678
- , { turnId: turn.id, modelOptions: modelOptions, suppressed: suppressedFailedCompaction, continuedWith: harnessSwitches.get(turn.id)?.harness, fullTextState: loaded.state[turn.id] ?? 'idle', onLoadFullText: loadFullTexts, showBusyRow: showFallbackBusyRow &&
3679
- fallbackBusyRowTurnId === turn.id,
3680
- // Queued bubbles STACK: a pending turn right after
3681
- // another pending turn sits close to it, like a
3682
- // list of what is waiting — not a turn's width
3683
- // apart as if each had been answered in between.
3684
- // (Failed compaction rows need no stacking rule any
3685
- // more — at most one is visible at a time.)
3686
- viewportClassName: turnIndex === 0 || transcriptRows
3687
- ? ''
3688
- : // A compaction, the work after it and another agent's notice continue the turn above.
3689
- turn.compaction || turn.continues || agentNoticeTurnIds.has(turn.id)
3690
- ? 'mt-6'
3691
- : lastTurnWorking &&
3692
- pendingTurnIds.has(turn.id) &&
3693
- pendingTurnIds.has(turns[turnIndex - 1].id)
3694
- ? 'mt-3'
3695
- : 'mt-12', turn: turn, author: turnAuthor,
3696
- // Reserve the sender row while the authors load,
3697
- // for a queued prompt whose sender is known, and
3698
- // for a live message until its author resolves.
3699
- showAuthor: !!turnAuthor ||
3700
- messageAuthorsLoading ||
3701
- !!promptAuthorId ||
3702
- (loadedUserIds?.sessionId === sessionId &&
3703
- !loadedUserIds.ids.has(turn.id) &&
3704
- authorsGaveUp !== missingAuthors), stoppedBy: stoppedByName(messageAuthors, turn.id, viewerId), servedModel: servedModelOfTurn(modelUsage, turn.id, turns[turnIndex - 1]?.id), turnOutcome: turnOutcome, isLast: turn.id === lastUserMessageId, ownsPlan: turn.id === planAnchorId, sessionId: sessionId, projectId: projectId, projectSessionId: projectSessionId, sessionStatus: sessionStatus, permissions: pendingPermissions, questions: pendingQuestions, agentNames: agentNames, isFirstTurn: turnIndex === 0,
3705
- // Handed over only once the stand-in has stepped
3706
- // aside — while it is up it draws these itself.
3707
- pendingText: turnIndex === 0 ? firstTurnHandover?.text : undefined, pendingAttachments: sentAttachmentsForTurn({
3708
- sentByMessage: sentAttachmentsByMessage,
3709
- messageId: turn.id,
3710
- originId: optimisticOriginOf(sessionId, turn.id),
3711
- isFirstTurn: turnIndex === 0,
3712
- firstTurnHandover: firstTurnHandover?.attachments,
3713
- firstTurnSent: firstPromptAttachments(projectSessionId),
3714
- queuedRowAttachments: inboxRowsByMessageId.get(turn.id)?.attachments,
3715
- }), uploadStatus: heldSendFailures?.[turn.id]
3716
- ? {
3717
- state: 'failed',
3718
- message: heldSendFailures[turn.id].message,
3719
- onRetry: () => retryHeldSend(sessionId, turn.id, resendHeldSend, (error) => classifySessionError(error).message),
3720
- }
3721
- : turnIndex === 0 && firstTurnHandover?.attachments.length
3722
- ? firstPromptUploadStatus
3723
- : undefined, sessionWorking: lastTurnWorking, isWorkingTurn: turn.live, suppressBusyIndicator: suppressWorkingTurnBusy, awaitingUser: awaitingUserInput,
3724
- // An idle send stays in the inbox until delivery,
3725
- // but nothing runs ahead of it: queued only while
3726
- // it waits behind a turn (`turnRendersQueued`).
3727
- // The first turn, with no turn working, has
3728
- // nothing ahead of it: a session's first prompt is
3729
- // starting, not queued, while the computer comes up
3730
- // and before the turn layer marks it queued or live.
3731
- pending: turnIndex === 0 && workingTurn.workingTurnId === null && !confirmedActive
3732
- ? pendingPrompt?.state === 'waiting' || pendingPrompt?.state === 'failed'
3733
- : turnRendersQueued({
3734
- turnId: turn.id,
3735
- resolution: workingTurn,
3736
- sessionWorking: lastTurnWorking,
3737
- confirmedActive,
3738
- inboxPrompt: pendingPrompt,
3739
- }), pendingPrompt: pendingPrompt, onRetryQueued: stableRetryQueued, onRemoveQueued: stableRemoveQueued, queuedPromptViewer: queuedPromptViewer, interruptedBeforeRun: interruptedTurnIds.has(turn.id), isCompaction: hasCompaction, onOpenCompactionSummary: panel ? stableOpenCompactionSummary : undefined, onOpenPastedContent: panel ? stableOpenPastedContent : undefined, providers: providers, commandMessages: commandMessagesRef.current, commands: commands, disableToolNavigation: disableToolNavigation, onPermissionReply: stablePermissionReply, onRewind: stableRewind, editingText: rewindTarget?.messageId === turn.id
3740
- ? rewindTarget.text
3741
- : null, editPending: editSendPending || !!sessionState?.rewindPending, onEditCancel: stableEditCancel, onEditSend: stableEditSend, rewindDisabled: !!readOnly ||
3742
- (rewindable !== null && !rewindable.has(turn.id)) ||
3743
- !runtimeCanRewind ||
3744
- !sessionState ||
3745
- isBusy ||
3746
- sessionState.rewindPending ||
3747
- // The runtime is not idle while queued prompts
3748
- // are still on their way to it — a rewind mid-
3749
- // delivery fails downstream with "Session is
3750
- // busy" (measured); refuse it up front instead.
3751
- promptInbox.prompts.length > 0 }, turnRenderKeys.get(turn.id)));
3752
- })] }) }), isOptimisticCompacting && !hasCompactionTurn && (_jsx("div", { className: turns.length > 0 ? 'mt-12' : 'mt-2', children: _jsx(CompactionMarker, { running: true }) })), [
3753
- ...(turnOutcome.recent_failures ?? []),
3754
- ...(turnOutcome.last_ended?.end_reason === 'failed' &&
3755
- !turnOutcome.recent_failures?.some((failure) => failure.message_id === turnOutcome.last_ended?.message_id)
3756
- ? [turnOutcome.last_ended]
3757
- : []),
3758
- ].filter((failure) => !isAbortError(failure.error) &&
3759
- !failureShownByTurn(failure, turns) &&
3760
- !failureSupersededByTurn(failure, turns) &&
3761
- (!failure.error?.message || failure.error.message !== commandError?.message)).map((failure) => {
3762
- const messageId = failure.message_id ?? 'persisted-turn-failure';
3763
- // Use the SDK's settle window for a cause that may arrive
3764
- // one frame later, including an unnamed failed last turn.
3765
- const notice = turnEndNotice({
3766
- ...turnOutcome,
3767
- recent_failures: [{ ...failure, message_id: messageId, error: failure.error ?? null }],
3768
- }, messageId, { hasError: false, isAbort: false });
3769
- return notice ? (_jsx(TurnErrorDisplay, { errorText: notice.kind === 'unexplained'
3770
- ? tHardcodedUi.raw('i18nComplete.text73112526c03a')
3771
- : persistedFailureText(failure.error), className: "mt-2" }, messageId)) : null;
3772
- }), commandError && (_jsx(TurnErrorDisplay, { error: commandError, isAbort: isAbortError(commandError.cause), modelOptions: modelOptions, className: "mt-2" })), showFallbackBusyRow && fallbackBusyRowTurnId === null && (rowsContext ? (
3773
- // A channel thread waits in the agent's answer row.
3774
- _jsx(AgentBusyRow, { sessionId: sessionId })) : (_jsx(SessionBusyIndicator, { sessionId: sessionId,
3775
- // Matches the stand-in's row spacing under a bubble
3776
- // (`OptimisticTurn`), so the crossfade into the real
3777
- // transcript does not move it. Nothing above it when
3778
- // the transcript is empty, so no margin there.
3779
- className: turns.length === 0 ? undefined : 'mt-6' })))] }), _jsx("div", { ref: spacerElRef, "data-scroll-spacer": true })] }) }), selectionPopup && (_jsx("div", { "data-reply-popup": true, className: "absolute z-50", style: {
3780
- left: `${selectionPopup.x}px`,
3781
- top: `${selectionPopup.y}px`,
3782
- transform: 'translate(-50%, -100%)',
3783
- }, children: _jsxs(Button, { onClick: handleSelectionReply, size: "sm", className: "animate-in fade-in-0 zoom-in-95 duration-normal origin-bottom px-3 text-xs ease-out has-[>svg]:px-3", children: [tHardcodedUi.raw('i18nComplete.textc253f451bdd5'), _jsx(ArrowBendUpLeftIcon, { className: "size-4 shrink-0" })] }) })), transcriptRows ? null : (_jsx(ChatMinimap, { turns: turns, scrollRef: scrollRef, contentRef: contentRef })), _jsx("div", { className: cn('absolute inset-x-0 bottom-4 z-20 flex justify-center', !showScrollButton && 'pointer-events-none'), children: _jsx(Button, { variant: "outline", size: "icon-md", "aria-hidden": !showScrollButton, tabIndex: showScrollButton ? undefined : -1, className: cn('hit-area-2 bg-background hover:bg-muted rounded-full', 'transition-[opacity,scale] ease-[cubic-bezier(0.23,1,0.32,1)] active:scale-[0.96] motion-reduce:scale-100 motion-reduce:transition-opacity', showScrollButton
3784
- ? 'duration-normal scale-100 opacity-100'
3785
- : 'duration-fast scale-[0.97] opacity-0'), onClick: smoothScrollToAbsoluteBottom, children: _jsx(CaretDownIcon, { className: "size-4" }) }) })] })), readOnly && inputReplacement ? (_jsx("div", { className: cn(COMPOSER_SHELL_CLASS, 'pb-4'), children: inputReplacement })) : null, !readOnly && (_jsxs(_Fragment, { children: [_jsx(SessionChatInput
3786
- // `undefined`, not `true`, once released: the composer's own
3787
- // viewport rule (>= 640px) still decides, so this never forces
3788
- // focus onto a phone keyboard.
3789
- , {
3700
+ _jsx(ReadOnlySessionContext.Provider, { value: !!readOnly, children: _jsx(AgentActivateContext.Provider, { value: agentActivate, children: _jsx(SessionPromptContext.Provider, { value: readOnly ? null : sendSessionPrompt, children: _jsx(ProjectFilesProvider, { value: { projectId: projectId ?? '', ref: outcomesBaseRef, defaultBranch: outcomesBaseRef }, children: _jsxs(ComposerDropZone, { className: cn('relative flex h-full flex-col',
3701
+ // Transparent in the welcome state so the root-level full-bleed wallpaper
3702
+ // (portaled into SessionLayout) reads through; solid once real content
3703
+ // takes over. Same base color either way, so non-welcome is unchanged.
3704
+ shouldShowWelcomeOverlay || transparent ? 'bg-transparent' : 'bg-background'), "data-testid": "session-chat", children: [isPreparingPrint && (_jsxs("div", { "data-print-hide": true, role: "status", className: "bg-popover text-muted-foreground fixed bottom-6 left-1/2 z-50 flex -translate-x-1/2 items-center gap-2 rounded-lg border px-4 py-2 text-xs shadow-lg", children: [_jsx(Loading, { className: "size-3.5 shrink-0" }), tHardcodedUi.raw('i18nComplete.text7dac2ca010fe')] })), wallpaperLayer
3705
+ ? welcomeWallpaper && createPortal(welcomeWallpaper, wallpaperLayer)
3706
+ : welcomeWallpaper, !hideHeader && (_jsx(SessionSiteHeader, { sessionId: sessionId, sessionTitle: session?.title || 'Untitled', leadingAction: headerLeadingAction, parent: parentCrumb })), _jsx(ModelSwitchHistory, { history: projectSessionRow?.metadata?.model_switches, current: projectSessionRow?.metadata?.model }), _jsx(SessionContextModal, { open: contextModalOpen, onOpenChange: setContextModalOpen,
3707
+ // A chat with no `useSession` source: the raw explorer lists the
3708
+ // rows `useSessionSync` read for it.
3709
+ detachedRows: sessionState ? undefined : hookMessages, source: sessionState ?? DETACHED_SESSION_MESSAGES, session: session, sessionRow: projectSessionRow, providers: providers, allSessions: allSessions, servedModel: sessionServedModel, billedCost: sessionBilledCost(modelUsage) }), _jsx(CompactModal, { sessionId: sessionId, open: compactModalOpen, onOpenChange: setCompactModalOpen }), _jsx(ChangeRequestDetailDialog, { crId: openCrId, onClose: () => setOpenCrId(null), onOpenChangeRequest: setOpenCrId }), _jsxs(SessionBodyRow, { actionPanel: !hideHeader && !readOnly, children: [isNotFound ? (_jsxs("div", { className: "flex min-h-0 flex-1 flex-col items-center justify-center gap-3 px-6 text-center", children: [_jsx("div", { className: "text-muted-foreground text-sm", children: tHardcodedUi.raw('componentsSessionSessionChat.line5821JsxTextThisSessionIsNotAccessibleRightNow') }), _jsx(Button, { asChild: true, variant: "outline", size: "sm", children: _jsx(Link, { href: "/", prefetch: true, onClick: () => {
3710
+ try {
3711
+ if (sessionId)
3712
+ useTabStore.getState().closeTab?.(sessionId);
3713
+ }
3714
+ catch { }
3715
+ }, children: tHardcodedUi.raw('componentsSessionSessionChat.line5833JsxTextGoToHome') }) })] })) : (_jsxs("div", { ref: chatAreaRef, className: "relative z-10 min-h-0 flex-1", children: [_jsx("div", { ref: scrollContainerCallbackRef, className: cn(
3716
+ // overflow-anchor:none — this scroll area does ALL of its own
3717
+ // anchoring (useAutoScroll's spacer + RAF follow, the send-path
3718
+ // turn anchor, and the history-prepend content-space restore in
3719
+ // session-history-scroll.ts). The browser's native scroll
3720
+ // anchoring (default `overflow-anchor: auto`) tries to
3721
+ // compensate for the SAME prepends independently, and the two
3722
+ // corrections stacking is the other half of the scroll-up
3723
+ // teleport: ours restores the reader's position, then the
3724
+ // native one nudges it again.
3725
+ 'scrollbar-hide relative z-10 h-full flex-1 overflow-y-auto [scroll-behavior:auto] [overflow-anchor:none]', shouldShowWelcomeOverlay || transparent ? 'bg-transparent' : 'bg-background'), onMouseUp: handleChatMouseUp, onMouseDown: handleChatMouseDown, onScroll: handleChatScroll, children: _jsxs("div", { ref: contentRef, role: "log",
3726
+ // Width and gutters live in `SESSION_TRANSCRIPT_CLASS`: the
3727
+ // instant shell draws this same column and the two crossfade
3728
+ // into each other, so a difference here is a sideways jump on
3729
+ // screen, not a style opinion. See session-body.tsx.
3730
+ //
3731
+ // No bottom padding, there or here: the space under the last
3732
+ // message is the auto-scroll spacer's job alone. The `pb-32`
3733
+ // that used to sit here stacked 128px of dead space on top of
3734
+ // it — the "extra inset at the bottom of the session".
3735
+ // Rows run edge to edge: each row owns its gutters and its hover fill.
3736
+ className: transcriptRows ? 'w-full min-w-0 pt-4' : SESSION_TRANSCRIPT_CLASS, children: [_jsxs("div", { className: "flex min-w-0 flex-col", children: [_jsx(SessionPrintHeader, { title: session?.title || 'Untitled', agentName: composerAgentName }), (hasOlder || showOlderLoading) && (_jsxs("div", { className: "mb-6 flex flex-col items-center gap-2", children: [hasOlder && (_jsx("div", { ref: olderSentinelRef, "aria-hidden": true, className: "h-px w-full" })), showOlderLoading && (_jsxs("div", { role: "status", className: "text-muted-foreground flex items-center gap-2 py-1 text-xs", children: [_jsx(Loading, { className: "size-3.5 shrink-0" }), tHardcodedUi.raw('i18nComplete.text85bf890776a7')] })), !showOlderLoading &&
3737
+ !olderPullFailed &&
3738
+ olderAutoloadExhausted({ hasOlder, autoLoadedPages }) && (_jsx(Button, { type: "button", variant: "outline-ghost", size: "sm", onClick: () => void handleLoadOlder(), children: tHardcodedUi.raw('i18nComplete.textf17671d83db0') })), olderPullFailed && !showOlderLoading && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-muted-foreground text-xs", children: tHardcodedUi.raw('i18nComplete.textb03a0041ce33') }), _jsx(Button, { type: "button", variant: "outline-ghost", size: "sm", onClick: () => void handleLoadOlder(), children: tHardcodedUi.raw('i18nComplete.text942087cc2d41') })] }))] })), restoreNotice && !restoreDismissed && (_jsx(RestoreNotice, { notice: restoreNotice, onDismiss: () => dismissRestore(historyKey, restoreNotice.generation) })), _jsx(SessionOutcomesProvider, { projectSessionId: projectSessionId, turnSpans: turnSpans, busy: effectiveBusy, onOpen: handleOpenOutcome, onJump: handleJumpToOutcome, jumping: jumpingToOutcome, children: _jsxs(ToolActivateContext.Provider, { value: toolActivate, children: [showFirstPromptPreview &&
3739
+ firstPromptSource &&
3740
+ queuedSyntheticMessages.length === 0 &&
3741
+ rowsContext && (
3742
+ // A channel thread draws the stand-in as rows, the same
3743
+ // rows its boot body drew (`ThreadBootRows`).
3744
+ _jsx(PendingPromptRows, { text: buildOptimisticPromptTextWithUploads(firstPromptSource.text, firstPromptSource.files), author: rowsContext.owner, sessionId: sessionId, busy: turns.length === 0 && (lastTurnWorking || promptInbox.prompts.some(isFirstPromptRow)) })), showFirstPromptPreview &&
3745
+ firstPromptSource &&
3746
+ queuedSyntheticMessages.length === 0 &&
3747
+ !rowsContext && (_jsx(OptimisticTurn, { text: buildOptimisticPromptTextWithUploads(firstPromptSource.text, firstPromptSource.files),
3748
+ // Preserve a real failed-send status through the
3749
+ // boot-shell handover without inventing upload progress.
3750
+ // A first prompt held on its uploads carries its own.
3751
+ uploadStatus: firstPromptSource.uploadStatus ?? firstPromptUploadStatus, agentNames: agentNames, onFileClick: openFileInComputer, sessionId: sessionId,
3752
+ // The first item of the conversation, like turn 0, which has no
3753
+ // top margin. `first:mt-0` misses here: the list opens with a
3754
+ // zero-height <header>, so the stand-in sat 44px lower than turn 0
3755
+ // and every swap between the two jumped the bubble (KRTX-2931).
3756
+ className: "mt-0",
3757
+ // An undelivered first prompt is a turn about to start, as the
3758
+ // shell above this chat shows it: busy from the first frame,
3759
+ // before the working projection has read the inbox (KRTX-2931).
3760
+ busy: turns.length === 0 && (lastTurnWorking || promptInbox.prompts.some(isFirstPromptRow)) })), turns.map((turn, turnIndex) => {
3761
+ // Check if this turn is a compaction summary — and
3762
+ // whether it actually PRODUCED one. A failed/aborted
3763
+ // attempt (compaction-flagged, no content, not the
3764
+ // working turn) renders as one slim row, draws no
3765
+ // divider, and stacks tight against a neighbouring
3766
+ // failed attempt.
3767
+ const compaction = turn.compaction;
3768
+ const hasCompaction = compaction !== null;
3769
+ const isTurnWorking = turn.live;
3770
+ // `inFlight` (message state) alongside the projection:
3771
+ // classifying by projection alone flipped a streaming
3772
+ // compaction to "failed" for the frames where the two
3773
+ // disagree, popping the divider in and out — a layout
3774
+ // bounce right where the reader is looking.
3775
+ const isFailedCompaction = compaction !== null &&
3776
+ !compaction.hasContent &&
3777
+ !compaction.inFlight &&
3778
+ !isTurnWorking;
3779
+ // Retries collapse to ONE visible row, GLOBALLY: a
3780
+ // failed attempt with ANY later compaction turn (a
3781
+ // retry, or the one that finally landed) is history —
3782
+ // it keeps its TurnViewport (stable keys, scroll
3783
+ // anchors) but renders no content, and an empty
3784
+ // TurnViewport costs 0px (turn-viewport.tsx RULE 2).
3785
+ // Adjacency was not enough: attempts whose error landed
3786
+ // on a plain assistant message used to interleave as
3787
+ // unclassified turns, breaking every consecutive run.
3788
+ const suppressedFailedCompaction = isFailedCompaction && turnIndex < lastCompactionTurnIndex;
3789
+ // Notification-only early-return removed: it rendered the
3790
+ // user's pty_* card but skipped the turn's replies,
3791
+ // hiding every subsequent assistant response in that turn.
3792
+ // Fall through to the normal turn renderer instead.
3793
+ const confirmedActive = turnIsConfirmedActive({
3794
+ isTurnWorking,
3795
+ turnId: turn.id,
3796
+ activeTurnId,
3797
+ pendingDelivery: !!working.pendingDelivery,
3798
+ });
3799
+ const pendingPrompt = !confirmedActive && turn.assistant.length === 0
3800
+ ? pendingPromptsByMessageId.get(turn.id)
3801
+ : undefined;
3802
+ // A queued prompt is not in the runtime transcript yet;
3803
+ // its author still shows (`authorForTurn`).
3804
+ const promptAuthorId = pendingPromptsByMessageId.get(turn.id)?.author_user_id;
3805
+ const turnAuthor = authorForTurn(transcriptAuthors, messageAuthors, turn.id, pendingPrompt?.wire_message_id) ??
3806
+ participantAuthor(sessionParticipants, promptAuthorId) ??
3807
+ (sentHereIds.current.has(turn.id) ||
3808
+ sentHereIds.current.has(turnRenderKeys.get(turn.id) ?? '') ||
3809
+ (viewerId !== undefined && promptAuthorId === viewerId) ||
3810
+ // The first prompt of a session the viewer started,
3811
+ // sent from another surface (project home), before
3812
+ // the first authors read lands.
3813
+ (messageAuthorsLoading &&
3814
+ viewerId !== undefined &&
3815
+ projectSessionRow?.created_by === viewerId &&
3816
+ turn.id === userMessageIds[0])
3817
+ ? viewerAsAuthor
3818
+ : undefined);
3819
+ return (_jsx(TranscriptTurnRow
3820
+ // ONE element per prompt: keyed by the id the
3821
+ // bubble was FIRST painted under, so the swap to a
3822
+ // re-minted echo id re-renders this node instead
3823
+ // of mounting a new one (opacity keeps animating,
3824
+ // hover state survives, nothing jumps).
3825
+ , { turnId: turn.id, modelOptions: modelOptions, suppressed: suppressedFailedCompaction, continuedWith: harnessSwitches.get(turn.id)?.harness, fullTextState: loaded.state[turn.id] ?? 'idle', onLoadFullText: loadFullTexts, showBusyRow: showFallbackBusyRow &&
3826
+ fallbackBusyRowTurnId === turn.id,
3827
+ // Queued bubbles STACK: a pending turn right after
3828
+ // another pending turn sits close to it, like a
3829
+ // list of what is waiting — not a turn's width
3830
+ // apart as if each had been answered in between.
3831
+ // (Failed compaction rows need no stacking rule any
3832
+ // more — at most one is visible at a time.)
3833
+ viewportClassName: turnIndex === 0 || transcriptRows
3834
+ ? ''
3835
+ : // A compaction, the work after it and another agent's notice continue the turn above.
3836
+ turn.compaction || turn.continues || agentNoticeTurnIds.has(turn.id)
3837
+ ? 'mt-6'
3838
+ : lastTurnWorking &&
3839
+ pendingTurnIds.has(turn.id) &&
3840
+ pendingTurnIds.has(turns[turnIndex - 1].id)
3841
+ ? 'mt-3'
3842
+ : 'mt-12', turn: turn, author: turnAuthor,
3843
+ // Reserve the sender row while the authors load,
3844
+ // for a queued prompt whose sender is known, and
3845
+ // for a live message until its author resolves.
3846
+ showAuthor: !!turnAuthor ||
3847
+ messageAuthorsLoading ||
3848
+ !!promptAuthorId ||
3849
+ (loadedUserIds?.sessionId === sessionId &&
3850
+ !loadedUserIds.ids.has(turn.id) &&
3851
+ authorsGaveUp !== missingAuthors), stoppedBy: stoppedByName(messageAuthors, turn.id, viewerId), servedModel: servedModelOfTurn(modelUsage, turn.id, turns[turnIndex - 1]?.id), turnOutcome: turnOutcome, isLast: turn.id === lastUserMessageId, ownsPlan: turn.id === planAnchorId, sessionId: sessionId, projectId: projectId, projectSessionId: projectSessionId, sessionStatus: sessionStatus, permissions: pendingPermissions, questions: pendingQuestions, agentNames: agentNames, isFirstTurn: turnIndex === 0,
3852
+ // Handed over only once the stand-in has stepped
3853
+ // aside — while it is up it draws these itself.
3854
+ pendingText: turnIndex === 0 ? firstTurnHandover?.text : undefined, pendingAttachments: sentAttachmentsForTurn({
3855
+ sentByMessage: sentAttachmentsByMessage,
3856
+ messageId: turn.id,
3857
+ originId: optimisticOriginOf(sessionId, turn.id),
3858
+ isFirstTurn: turnIndex === 0,
3859
+ firstTurnHandover: firstTurnHandover?.attachments,
3860
+ firstTurnSent: firstPromptAttachments(projectSessionId),
3861
+ queuedRowAttachments: inboxRowsByMessageId.get(turn.id)?.attachments,
3862
+ }), uploadStatus: heldSendFailures?.[turn.id]
3863
+ ? {
3864
+ state: 'failed',
3865
+ message: heldSendFailures[turn.id].message,
3866
+ onRetry: () => retryHeldSend(sessionId, turn.id, resendHeldSend, (error) => classifySessionError(error).message),
3867
+ }
3868
+ : turnIndex === 0 && firstTurnHandover?.attachments.length
3869
+ ? firstPromptUploadStatus
3870
+ : undefined, sessionWorking: lastTurnWorking, isWorkingTurn: turn.live, suppressBusyIndicator: suppressWorkingTurnBusy, awaitingUser: awaitingUserInput,
3871
+ // An idle send stays in the inbox until delivery,
3872
+ // but nothing runs ahead of it: queued only while
3873
+ // it waits behind a turn (`turnRendersQueued`).
3874
+ // The first turn, with no turn working, has
3875
+ // nothing ahead of it: a session's first prompt is
3876
+ // starting, not queued, while the computer comes up
3877
+ // and before the turn layer marks it queued or live.
3878
+ pending: turnIndex === 0 && workingTurn.workingTurnId === null && !confirmedActive
3879
+ ? pendingPrompt?.state === 'waiting' || pendingPrompt?.state === 'failed'
3880
+ : turnRendersQueued({
3881
+ turnId: turn.id,
3882
+ resolution: workingTurn,
3883
+ sessionWorking: lastTurnWorking,
3884
+ confirmedActive,
3885
+ inboxPrompt: pendingPrompt,
3886
+ }), pendingPrompt: pendingPrompt, onRetryQueued: stableRetryQueued, onRemoveQueued: stableRemoveQueued, queuedPromptViewer: queuedPromptViewer, interruptedBeforeRun: interruptedTurnIds.has(turn.id), isCompaction: hasCompaction, onOpenCompactionSummary: panel ? stableOpenCompactionSummary : undefined, onOpenPastedContent: panel ? stableOpenPastedContent : undefined, providers: providers, commandMessages: commandMessagesRef.current, commands: commands, disableToolNavigation: disableToolNavigation, onPermissionReply: stablePermissionReply, onRewind: stableRewind, editingText: rewindTarget?.messageId === turn.id
3887
+ ? rewindTarget.text
3888
+ : null, editPending: editSendPending || !!sessionState?.rewindPending, onEditCancel: stableEditCancel, onEditSend: stableEditSend, rewindDisabled: !!readOnly ||
3889
+ (rewindable !== null && !rewindable.has(turn.id)) ||
3890
+ !runtimeCanRewind ||
3891
+ !sessionState ||
3892
+ isBusy ||
3893
+ sessionState.rewindPending ||
3894
+ // The runtime is not idle while queued prompts
3895
+ // are still on their way to it — a rewind mid-
3896
+ // delivery fails downstream with "Session is
3897
+ // busy" (measured); refuse it up front instead.
3898
+ promptInbox.prompts.length > 0 }, turnRenderKeys.get(turn.id)));
3899
+ })] }) }), isOptimisticCompacting && !hasCompactionTurn && (_jsx("div", { className: turns.length > 0 ? 'mt-12' : 'mt-2', children: _jsx(CompactionMarker, { running: true }) })), [
3900
+ ...(turnOutcome.recent_failures ?? []),
3901
+ ...(turnOutcome.last_ended?.end_reason === 'failed' &&
3902
+ !turnOutcome.recent_failures?.some((failure) => failure.message_id === turnOutcome.last_ended?.message_id)
3903
+ ? [turnOutcome.last_ended]
3904
+ : []),
3905
+ ].filter((failure) => !isAbortError(failure.error) &&
3906
+ !failureShownByTurn(failure, turns) &&
3907
+ !failureSupersededByTurn(failure, turns) &&
3908
+ (!failure.error?.message || failure.error.message !== commandError?.message)).map((failure) => {
3909
+ const messageId = failure.message_id ?? 'persisted-turn-failure';
3910
+ // Use the SDK's settle window for a cause that may arrive
3911
+ // one frame later, including an unnamed failed last turn.
3912
+ const notice = turnEndNotice({
3913
+ ...turnOutcome,
3914
+ recent_failures: [{ ...failure, message_id: messageId, error: failure.error ?? null }],
3915
+ }, messageId, { hasError: false, isAbort: false });
3916
+ return notice ? (_jsx(TurnErrorDisplay, { errorText: notice.kind === 'unexplained'
3917
+ ? tHardcodedUi.raw('i18nComplete.text73112526c03a')
3918
+ : persistedFailureText(failure.error), className: "mt-2" }, messageId)) : null;
3919
+ }), commandError && (_jsx(TurnErrorDisplay, { error: commandError, isAbort: isAbortError(commandError.cause), modelOptions: modelOptions, className: "mt-2" })), showFallbackBusyRow && fallbackBusyRowTurnId === null && (rowsContext ? (
3920
+ // A channel thread waits in the agent's answer row.
3921
+ _jsx(AgentBusyRow, { sessionId: sessionId })) : (_jsx(SessionBusyIndicator, { sessionId: sessionId,
3922
+ // Matches the stand-in's row spacing under a bubble
3923
+ // (`OptimisticTurn`), so the crossfade into the real
3924
+ // transcript does not move it. Nothing above it when
3925
+ // the transcript is empty, so no margin there.
3926
+ className: turns.length === 0 ? undefined : 'mt-6' })))] }), _jsx("div", { ref: spacerElRef, "data-scroll-spacer": true })] }) }), selectionPopup && (_jsx("div", { "data-reply-popup": true, className: "absolute z-50", style: {
3927
+ left: `${selectionPopup.x}px`,
3928
+ top: `${selectionPopup.y}px`,
3929
+ transform: 'translate(-50%, -100%)',
3930
+ }, children: _jsxs(Button, { onClick: handleSelectionReply, size: "sm", className: "animate-in fade-in-0 zoom-in-95 duration-normal origin-bottom px-3 text-xs ease-out has-[>svg]:px-3", children: [tHardcodedUi.raw('i18nComplete.textc253f451bdd5'), _jsx(ArrowBendUpLeftIcon, { className: "size-4 shrink-0" })] }) })), transcriptRows ? null : (_jsx(ChatMinimap, { turns: turns, scrollRef: scrollRef, contentRef: contentRef })), _jsx("div", { className: cn('absolute inset-x-0 bottom-4 z-20 flex justify-center', !showScrollButton && 'pointer-events-none'), children: _jsx(Button, { variant: "outline", size: "icon-md", "aria-hidden": !showScrollButton, tabIndex: showScrollButton ? undefined : -1, className: cn('hit-area-2 bg-background hover:bg-muted rounded-full', 'transition-[opacity,scale] ease-[cubic-bezier(0.23,1,0.32,1)] active:scale-[0.96] motion-reduce:scale-100 motion-reduce:transition-opacity', showScrollButton
3931
+ ? 'duration-normal scale-100 opacity-100'
3932
+ : 'duration-fast scale-[0.97] opacity-0'), onClick: smoothScrollToAbsoluteBottom, children: _jsx(CaretDownIcon, { className: "size-4" }) }) })] })), readOnly && inputReplacement ? (_jsx("div", { className: cn(COMPOSER_SHELL_CLASS, 'pb-4'), children: inputReplacement })) : null, !readOnly && (_jsxs(_Fragment, { children: [_jsx(SessionChatInput
3790
3933
  // `undefined`, not `true`, once released: the composer's own
3791
3934
  // viewport rule (>= 640px) still decides, so this never forces
3792
3935
  // focus onto a phone keyboard.
3793
- autoFocus: deferComposerFocus ? false : undefined, onSend: async (text, files, mentions, attachments, placement) => {
3794
- if (await queueEdit.save(text))
3795
- return;
3796
- // Enter while a turn runs steers it (D9.1); Cmd/Ctrl+Enter is Queue List.
3797
- await handleSend(text, files, mentions, attachments, composerSendDelivery(placement ?? 'transcript', isBusyRef.current));
3798
- }, prefill: composerPrefill, onPrefillApplied: (id) => {
3799
- useSessionComposerPrefillStore.getState().clearPrefill(sessionId, id);
3800
- },
3801
- // Up from the first row takes the queue back; the placeholder
3802
- // says so while there is something to take.
3803
- onArrowUpAtStart: () => queueEdit.takeBack(),
3804
- // A host placeholder ("Reply…") is static: the rotating tips would replace it.
3805
- hint: canTakeBackQueue ? tHardcodedUi.raw('i18nComplete.text03a01dd53ffa') : composerPlaceholder,
3806
- // Editing a queued message: the send saves it back into the
3807
- // queue, so the control says Submit, never Stop.
3808
- submitLabel: queueEdit.editing ? tQueue('submitEdit') : null, draftScope: composerDraftScope, draftActive: !deferComposerFocus, attachRequestId: attachRequestId, isBusy: isBusy,
3809
- // The ONE projection, not the 300 ms busy fade: it is what
3810
- // decides whether a `/` command may be dispatched, and a fade
3811
- // timer that has already lapsed would let one abort a live turn.
3812
- // `effectiveBusy` folds in optimistic compaction (not a turn, so
3813
- // not in `working`) and the retrying-turn predicate, so this
3814
- // site reads one value instead of re-OR-ing a term onto it.
3815
- sessionWorking: effectiveBusy,
3816
- // Gates `/` COMMANDS only. A prompt typed at a sleeping box is
3817
- // an inbox row and goes out when the box answers; a command has
3818
- // no row, and `runCommand` swallows it silently until the
3819
- // runtime is switched.
3820
- runtimeReady: runtimeReady, rewind: composerRewind, onStop: handleStop, canStop: canStop, escCount: escCount, agents: local.agent.list, selectedAgent: composerAgentName, onAgentChange: handleAgentChange, noAccessibleAgents: noAccessibleAgents, commands: chatCommands, commandsResolved: agentCommands !== undefined, slashFiles: chatSlashFiles, onOpenPastedContent: panel ? stableOpenPastedContent : undefined, onCommand: handleCommand, onHoldCommand: handleHoldCommand, models: local.model.list, selectedModel: local.model.currentKey ?? null, onModelChange: handleModelChange, modelDefaultControls: chatModelDefaultControls, variants: local.model.variant.list, selectedVariant: local.model.variant.current ?? null, onVariantChange: handleVariantChange, messages: messages, sessionId: sessionId, projectId: projectId, providers: providers, modelRequired: true, modelsLoading: providersLoading, onContextClick: handleContextClick, onCompactClick: runtimeCanCompact ? handleCompactClick : undefined, quoteRequests: quoteRequests, onQuoteRequestsApplied: handleQuoteRequestsApplied,
3821
- // Only lock the input into question-answer mode while the session is
3822
- // actually busy (a live question keeps the run busy). If a question
3823
- // chip is ever showing while the session is idle — e.g. a dead /
3824
- // abandoned question the agent left behind — the input stays unlocked
3825
- // so a typed message is sent to the agent instead of being swallowed
3826
- // as a custom answer.
3827
- lockForQuestion: !!renderedQuestion && isBusy,
3828
- // Same dead-prompt guard as questions: only lock while the agent is
3829
- // actually paused on the decision (isBusy), so a stale card can't
3830
- // swallow the composer on an idle session.
3831
- lockForApproval: runtimePermissionLocksComposer(pendingPermissions.length, isBusy), onCustomAnswer: handleCustomAnswer, questionButtonLabel: renderedQuestion ? questionAction.label : null, questionActive: !!renderedQuestion || approvalDocked, questionCanAct: questionAction.canAct, onQuestionAction: handleQuestionAction, aboveSlot: chatAboveSlot, inputSlot: chatInputSlot, toolbarSlot: chatToolbarSlot, underbarSlot: chatUnderbarSlot,
3832
- // The shell can now render on a cached transcript alone, i.e. before
3833
- // the sandbox answers — so sending has to be gated separately from
3834
- // reading. See sessionComposerReadiness.
3835
- notice: hostNotice(composerReadiness.notice, rowsContext?.notices),
3836
- // Inside the thread panel's bordered box, as the channel composer.
3837
- // A phone keeps the row under the card; a 720px desktop window does not.
3838
- underbarPlacement: transcriptRows && !isPhone ? 'inline' : undefined,
3839
- // The panel's toolbar is narrow: the agent is its tile, the model keeps its name.
3840
- agentPickerCompact: transcriptRows && !isPhone,
3841
- // A thread panel's rows run `px-5`, and the channel composer
3842
- // beside it sits `pb-4` off the window's bottom edge: the same
3843
- // margins, so the two boxes line up.
3844
- parentClassName: transcriptRows ? 'max-w-none px-5 pb-4' : undefined, onNoticeRetry: composerReadiness.notice && composerReadiness.retryable
3845
- ? requestRuntimeReconnect
3846
- : undefined }), _jsx("div", { className: cn(COMPOSER_SHELL_CLASS, 'pb-3 empty:hidden', transcriptRows && 'max-w-none px-5'), children: _jsx(HeldMessages, { projectId: projectId, sessionId: projectSessionId }) })] }))] })] }) }) }) }));
3936
+ // A thread a space's chat opened by itself does not take the focus (`ComposerAutoFocusContext`).
3937
+ , {
3938
+ // `undefined`, not `true`, once released: the composer's own
3939
+ // viewport rule (>= 640px) still decides, so this never forces
3940
+ // focus onto a phone keyboard.
3941
+ // A thread a space's chat opened by itself does not take the focus (`ComposerAutoFocusContext`).
3942
+ autoFocus: deferComposerFocus || !composerAutoFocus ? false : undefined, onSend: async (text, files, mentions, attachments, placement) => {
3943
+ if (await queueEdit.save(text))
3944
+ return;
3945
+ // Enter while a turn runs steers it (D9.1); Cmd/Ctrl+Enter is Queue List.
3946
+ await handleSend(text, files, mentions, attachments, composerSendDelivery(placement ?? 'transcript', isBusyRef.current));
3947
+ }, prefill: composerPrefill, onPrefillApplied: (id) => {
3948
+ useSessionComposerPrefillStore.getState().clearPrefill(sessionId, id);
3949
+ },
3950
+ // Up from the first row takes the queue back; the placeholder
3951
+ // says so while there is something to take.
3952
+ onArrowUpAtStart: () => queueEdit.takeBack(),
3953
+ // A host placeholder ("Reply…") is static: the rotating tips would replace it.
3954
+ hint: canTakeBackQueue ? tHardcodedUi.raw('i18nComplete.text03a01dd53ffa') : composerPlaceholder,
3955
+ // Editing a queued message: the send saves it back into the
3956
+ // queue, so the control says Submit, never Stop.
3957
+ submitLabel: queueEdit.editing ? tQueue('submitEdit') : null, draftScope: composerDraftScope, draftActive: !deferComposerFocus, attachRequestId: attachRequestId, isBusy: isBusy,
3958
+ // The ONE projection, not the 300 ms busy fade: it is what
3959
+ // decides whether a `/` command may be dispatched, and a fade
3960
+ // timer that has already lapsed would let one abort a live turn.
3961
+ // `effectiveBusy` folds in optimistic compaction (not a turn, so
3962
+ // not in `working`) and the retrying-turn predicate, so this
3963
+ // site reads one value instead of re-OR-ing a term onto it.
3964
+ sessionWorking: effectiveBusy,
3965
+ // Gates `/` COMMANDS only. A prompt typed at a sleeping box is
3966
+ // an inbox row and goes out when the box answers; a command has
3967
+ // no row, and `runCommand` swallows it silently until the
3968
+ // runtime is switched.
3969
+ runtimeReady: runtimeReady, rewind: composerRewind, onStop: handleStop, canStop: canStop, escCount: escCount, agents: local.agent.list, selectedAgent: composerAgentName, onAgentChange: handleAgentChange, noAccessibleAgents: noAccessibleAgents, commands: chatCommands, commandsResolved: agentCommands !== undefined, slashFiles: chatSlashFiles, onOpenPastedContent: panel ? stableOpenPastedContent : undefined, onCommand: handleCommand, onHoldCommand: handleHoldCommand, models: local.model.list, selectedModel: local.model.currentKey ?? null, onModelChange: handleModelChange, modelDefaultControls: chatModelDefaultControls, inheritedModel: inheritedModelFor(local.model, composerAgentName), variants: local.model.variant.list, selectedVariant: local.model.variant.current ?? null, onVariantChange: handleVariantChange, messages: messages, sessionId: sessionId, projectId: projectId, providers: providers, modelRequired: true, modelsLoading: providersLoading, onContextClick: handleContextClick, onCompactClick: runtimeCanCompact ? handleCompactClick : undefined, quoteRequests: quoteRequests, onQuoteRequestsApplied: handleQuoteRequestsApplied,
3970
+ // Only lock the input into question-answer mode while the session is
3971
+ // actually busy (a live question keeps the run busy). If a question
3972
+ // chip is ever showing while the session is idle — e.g. a dead /
3973
+ // abandoned question the agent left behind — the input stays unlocked
3974
+ // so a typed message is sent to the agent instead of being swallowed
3975
+ // as a custom answer.
3976
+ lockForQuestion: !!renderedQuestion && isBusy,
3977
+ // Same dead-prompt guard as questions: only lock while the agent is
3978
+ // actually paused on the decision (isBusy), so a stale card can't
3979
+ // swallow the composer on an idle session.
3980
+ lockForApproval: runtimePermissionLocksComposer(livePermissions.length, isBusy), onCustomAnswer: handleCustomAnswer, questionButtonLabel: renderedQuestion ? questionAction.label : null, questionActive: !!renderedQuestion || approvalDocked, questionCanAct: questionAction.canAct, onQuestionAction: handleQuestionAction, aboveSlot: chatAboveSlot, inputSlot: chatInputSlot, toolbarSlot: chatToolbarSlot, underbarSlot: chatUnderbarSlot,
3981
+ // The shell can now render on a cached transcript alone, i.e. before
3982
+ // the sandbox answers — so sending has to be gated separately from
3983
+ // reading. See sessionComposerReadiness.
3984
+ notice: hostNotice(composerReadiness.notice, rowsContext?.notices),
3985
+ // Inside the thread panel's bordered box, as the channel composer.
3986
+ // A phone keeps the row under the card; a 720px desktop window does not.
3987
+ underbarPlacement: transcriptRows && !isPhone ? 'inline' : undefined,
3988
+ // The panel's toolbar is narrow: the agent is its tile, the model keeps its name.
3989
+ agentPickerCompact: transcriptRows && !isPhone,
3990
+ // A thread panel's rows run `px-5`, and the channel composer
3991
+ // beside it sits `pb-4` off the window's bottom edge: the same
3992
+ // margins, so the two boxes line up.
3993
+ parentClassName: transcriptRows ? 'max-w-none px-5 pb-4' : undefined, onNoticeRetry: composerReadiness.notice && composerReadiness.retryable
3994
+ ? requestRuntimeReconnect
3995
+ : undefined }), _jsx("div", { className: cn(COMPOSER_SHELL_CLASS, 'pb-3 empty:hidden', transcriptRows && 'max-w-none px-5'), children: _jsx(HeldMessages, { projectId: projectId, sessionId: projectSessionId }) })] }))] })] }) }) }) }) }));
3847
3996
  }