@kortix/ui 0.15.9 → 0.15.11

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 (202) hide show
  1. package/dist/_vendor/kortix-shared.js +467 -2
  2. package/dist/_vendor/shared/app-config.d.ts +6 -30
  3. package/dist/_vendor/shared/channel-descriptors.d.ts +0 -34
  4. package/dist/_vendor/shared/channel-header.d.ts +2 -1
  5. package/dist/_vendor/shared/connector-sections.d.ts +0 -25
  6. package/dist/_vendor/shared/file-tags.d.ts +2 -1
  7. package/dist/_vendor/shared/index.d.ts +1 -0
  8. package/dist/_vendor/shared/pasted-content.d.ts +0 -4
  9. package/dist/_vendor/shared/pixel-mark.d.ts +0 -17
  10. package/dist/_vendor/shared/project-glyphs.d.ts +0 -1
  11. package/dist/_vendor/shared/session/attachment-tile.d.ts +32 -0
  12. package/dist/_vendor/shared/session/stop-refusal.d.ts +15 -0
  13. package/dist/_vendor/shared/session/tool-row-text.d.ts +58 -0
  14. package/dist/_vendor/shared/session-delivery.d.ts +2 -0
  15. package/dist/customize/agents/agent-model-view.d.ts +11 -1
  16. package/dist/customize/agents/agent-model-view.js +12 -1
  17. package/dist/customize/agents/agent-page.js +19 -6
  18. package/dist/customize/agents/agent-tabs.d.ts +2 -0
  19. package/dist/customize/agents/agent-tabs.js +2 -0
  20. package/dist/customize/connectors/connectors-page.js +1 -1
  21. package/dist/customize/connectors/detail/connector-page.js +9 -4
  22. package/dist/customize/connectors/detail/connector-triggers.js +1 -1
  23. package/dist/customize/connectors/install/use-install.js +1 -1
  24. package/dist/customize/connectors/use-agent-access.d.ts +1 -0
  25. package/dist/customize/providers/provider-accordion.js +5 -5
  26. package/dist/customize/providers/provider-connect.d.ts +3 -3
  27. package/dist/customize/providers/provider-connect.js +8 -16
  28. package/dist/customize/providers/provider-sheet.js +4 -4
  29. package/dist/customize/sections/component/teams-byo-wizard.js +4 -1
  30. package/dist/customize/sections/connector-connection-form.d.ts +0 -1
  31. package/dist/customize/sections/connector-connection-form.js +0 -9
  32. package/dist/customize/sections/view/review-center-connected.js +7 -3
  33. package/dist/customize/settings/tabs/workspace-keys.js +53 -11
  34. package/dist/customize/shared/feature-gate-screen.js +1 -1
  35. package/dist/customize/triggers/runtime-triggers.js +13 -2
  36. package/dist/customize/triggers/schedule/event-account-picker.js +1 -1
  37. package/dist/customize/triggers/schedule/event-trigger-copy.js +1 -1
  38. package/dist/customize/triggers/schedule/schedule-detail-sheet.js +5 -4
  39. package/dist/customize/triggers/schedule/then-fields.d.ts +5 -1
  40. package/dist/customize/triggers/schedule/then-fields.js +23 -3
  41. package/dist/customize/triggers/schedule/trigger-callouts.js +1 -1
  42. package/dist/customize/triggers/schedule/trigger-composer-logic.d.ts +27 -0
  43. package/dist/customize/triggers/schedule/trigger-composer-logic.js +51 -5
  44. package/dist/customize/triggers/schedule/trigger-composer.js +19 -13
  45. package/dist/customize/triggers/schedule/trigger-edit-logic.js +25 -5
  46. package/dist/customize/triggers/schedule/trigger-filter.d.ts +10 -3
  47. package/dist/customize/triggers/schedule/trigger-filter.js +7 -6
  48. package/dist/customize/triggers/schedule/trigger-readonly.js +1 -1
  49. package/dist/customize/triggers/schedule/trigger-runs-panel.js +1 -1
  50. package/dist/customize/triggers/schedule/use-event-app-connect.js +2 -1
  51. package/dist/customize/triggers/schedule/when-event.js +1 -1
  52. package/dist/customize/triggers/schedule/when-schedule.d.ts +5 -1
  53. package/dist/customize/triggers/schedule/when-schedule.js +16 -1
  54. package/dist/customize/triggers/schedule-view.js +4 -2
  55. package/dist/i18n/en.d.ts +56 -7
  56. package/dist/i18n/en.js +65 -16
  57. package/dist/internal/billing/compute-pricing.d.ts +7 -1
  58. package/dist/internal/billing/compute-pricing.js +7 -1
  59. package/dist/internal/hooks/connectors/invalidate-connections.d.ts +10 -0
  60. package/dist/internal/hooks/connectors/invalidate-connections.js +18 -0
  61. package/dist/internal/hooks/connectors/use-finish-sign-in.js +1 -1
  62. package/dist/internal/hooks/connectors/use-pipedream-connect-member.js +1 -1
  63. package/dist/internal/hooks/connectors/use-pipedream-connect-project.js +1 -1
  64. package/dist/internal/hooks/projects/use-new-project-session.d.ts +2 -0
  65. package/dist/internal/hooks/projects/use-new-project-session.js +4 -1
  66. package/dist/internal/hooks/use-review-session-summary.d.ts +1 -1
  67. package/dist/internal/hooks/use-review-session-summary.js +1 -1
  68. package/dist/internal/layout/project-settings-nav.d.ts +17 -0
  69. package/dist/internal/layout/project-settings-nav.js +24 -0
  70. package/dist/internal/lib/browser-noise/rules/injected-scripts.js +2 -2
  71. package/dist/internal/lib/capability-tab-routes.d.ts +8 -0
  72. package/dist/internal/lib/capability-tab-routes.js +11 -0
  73. package/dist/internal/notifications/notification-inbox.d.ts +4 -10
  74. package/dist/internal/notifications/notification-inbox.js +8 -9
  75. package/dist/internal/stores/composer-prefill-store.d.ts +7 -0
  76. package/dist/internal/stores/composer-prefill-store.js +1 -0
  77. package/dist/internal/stores/connector-gate-store.d.ts +3 -1
  78. package/dist/internal/stores/connector-gate-store.js +13 -3
  79. package/dist/internal/stores/upgrade-dialog-store.d.ts +4 -0
  80. package/dist/internal/stores/upgrade-dialog-store.js +2 -0
  81. package/dist/lib/routes.d.ts +4 -11
  82. package/dist/lib/routes.js +3 -5
  83. package/dist/markdown/unified-markdown-utils.d.ts +7 -0
  84. package/dist/markdown/unified-markdown-utils.js +19 -0
  85. package/dist/markdown/unified-markdown.js +16 -3
  86. package/dist/primitives/alert-dialog.js +1 -1
  87. package/dist/primitives/dialog.js +3 -1
  88. package/dist/primitives/drawer.js +1 -1
  89. package/dist/primitives/modal.js +1 -1
  90. package/dist/primitives/preview-image.js +1 -1
  91. package/dist/primitives/sheet.js +1 -1
  92. package/dist/session/actions/session-label.js +2 -2
  93. package/dist/session/agents/agent-strip.d.ts +10 -5
  94. package/dist/session/agents/agent-strip.js +40 -12
  95. package/dist/session/agents/held-messages.d.ts +6 -2
  96. package/dist/session/agents/held-messages.js +6 -3
  97. package/dist/session/composer/ComposerCard.js +8 -3
  98. package/dist/session/composer/agent-selector.d.ts +2 -0
  99. package/dist/session/composer/agent-selector.js +5 -0
  100. package/dist/session/composer/attachment-tile.d.ts +2 -26
  101. package/dist/session/composer/attachment-tile.js +3 -47
  102. package/dist/session/composer/composer-chat-input.d.ts +3 -1
  103. package/dist/session/composer/composer-chat-input.js +2 -2
  104. package/dist/session/composer/composer-logic.d.ts +7 -0
  105. package/dist/session/composer/composer-logic.js +18 -0
  106. package/dist/session/composer/composer-reset.d.ts +8 -14
  107. package/dist/session/composer/composer-toolbar.d.ts +3 -1
  108. package/dist/session/composer/composer-toolbar.js +3 -3
  109. package/dist/session/composer/composer.d.ts +9 -0
  110. package/dist/session/composer/composer.js +22 -11
  111. package/dist/session/composer/draft/home-composer-focus-handoff.d.ts +7 -0
  112. package/dist/session/composer/draft/home-composer-focus-handoff.js +94 -0
  113. package/dist/session/composer/draft/use-composer-draft.d.ts +3 -1
  114. package/dist/session/composer/draft/use-composer-draft.js +22 -2
  115. package/dist/session/composer/editor/composer-editor.d.ts +4 -2
  116. package/dist/session/composer/editor/composer-editor.js +13 -7
  117. package/dist/session/composer/hooks/use-composer-focus.js +4 -2
  118. package/dist/session/header/session-site-header.d.ts +3 -1
  119. package/dist/session/header/session-site-header.js +3 -2
  120. package/dist/session/index.d.ts +1 -0
  121. package/dist/session/index.js +1 -0
  122. package/dist/session/models/chatgpt-connection-button.js +5 -9
  123. package/dist/session/models/connect-model-step.d.ts +29 -0
  124. package/dist/session/models/connect-model-step.js +50 -0
  125. package/dist/session/models/model-connection-gate.d.ts +2 -1
  126. package/dist/session/models/model-connection-gate.js +6 -3
  127. package/dist/session/models/model-connection-layout.d.ts +2 -0
  128. package/dist/session/models/model-connection-layout.js +4 -0
  129. package/dist/session/models/model-selector.d.ts +1 -1
  130. package/dist/session/models/model-selector.js +9 -6
  131. package/dist/session/models/subscription-offer.d.ts +4 -0
  132. package/dist/session/models/subscription-offer.js +11 -3
  133. package/dist/session/models/use-workspace-model-gate.d.ts +11 -0
  134. package/dist/session/models/use-workspace-model-gate.js +62 -0
  135. package/dist/session/models/workspace-model-gate.d.ts +46 -0
  136. package/dist/session/models/workspace-model-gate.js +66 -0
  137. package/dist/session/overrides/session-overrides-toolbar.js +2 -4
  138. package/dist/session/prompts/ask-deck.d.ts +5 -1
  139. package/dist/session/prompts/ask-deck.js +15 -3
  140. package/dist/session/prompts/question-labels.d.ts +16 -0
  141. package/dist/session/prompts/question-labels.js +34 -0
  142. package/dist/session/prompts/question-prompt.js +6 -6
  143. package/dist/session/prompts/session-connect-card.d.ts +63 -0
  144. package/dist/session/prompts/{session-connect-prompt.js → session-connect-card.js} +53 -42
  145. package/dist/session/status/provisioning-failure.d.ts +23 -2
  146. package/dist/session/status/provisioning-failure.js +53 -3
  147. package/dist/session/status/stop-refusal.d.ts +6 -12
  148. package/dist/session/status/stop-refusal.js +6 -19
  149. package/dist/session/thread/agent-run-props.d.ts +19 -0
  150. package/dist/session/thread/agent-run-props.js +54 -0
  151. package/dist/session/thread/session-chat.js +317 -298
  152. package/dist/session/thread/transcript.d.ts +19 -2
  153. package/dist/session/thread/transcript.js +93 -25
  154. package/dist/session/tool/tool-part-renderer.js +7 -2
  155. package/dist/session/tool/tools/bash-tool.d.ts +3 -52
  156. package/dist/session/tool/tools/bash-tool.js +3 -86
  157. package/dist/session/tool/tools/kortix-action-tool.js +10 -2
  158. package/dist/session/turn/answer-streaming.d.ts +21 -0
  159. package/dist/session/turn/answer-streaming.js +34 -0
  160. package/dist/session/turn/queued-prompt-bubbles.d.ts +5 -0
  161. package/dist/session/turn/queued-prompt-bubbles.js +12 -0
  162. package/dist/session/turn/turn-viewport.d.ts +66 -10
  163. package/dist/session/turn/turn-viewport.js +92 -12
  164. package/dist/session/turn/turn-work-accordion.d.ts +3 -1
  165. package/dist/session/turn/turn-work-accordion.js +2 -2
  166. package/dist/session/turn/user-message.js +7 -5
  167. package/dist/styles.css +1 -1
  168. package/dist/test-utils/intl.d.ts +56 -7
  169. package/dist/workspace/admin/project-admin-dashboard.js +2 -4
  170. package/dist/workspace/home/existing-repo-setup-prompt.d.ts +5 -8
  171. package/dist/workspace/home/existing-repo-setup-prompt.js +16 -42
  172. package/dist/workspace/home/first-chat.d.ts +7 -1
  173. package/dist/workspace/home/first-chat.js +12 -5
  174. package/dist/workspace/home/no-agent-home.d.ts +3 -1
  175. package/dist/workspace/home/no-agent-home.js +2 -2
  176. package/dist/workspace/inbox/workspace-inbox.d.ts +6 -16
  177. package/dist/workspace/inbox/workspace-inbox.js +9 -51
  178. package/dist/workspace/layout/project-home.js +17 -16
  179. package/dist/workspace/layout/use-project-home-send.d.ts +2 -0
  180. package/dist/workspace/layout/use-project-home-send.js +29 -15
  181. package/dist/workspace/new/advanced-fields.d.ts +4 -1
  182. package/dist/workspace/new/advanced-fields.js +2 -2
  183. package/dist/workspace/new/workspace-name.d.ts +9 -0
  184. package/dist/workspace/new/workspace-name.js +20 -0
  185. package/dist/workspace/projects/session-starter.d.ts +6 -4
  186. package/dist/workspace/projects/session-starter.js +8 -14
  187. package/dist/workspace/review/review-center.d.ts +6 -2
  188. package/dist/workspace/review/review-center.js +45 -25
  189. package/dist/workspace/sidebar/session-grouping.d.ts +1 -1
  190. package/dist/workspace/sidebar/session-grouping.js +1 -1
  191. package/dist/workspace/sidebar/workspace-menu-model.d.ts +3 -5
  192. package/dist/workspace/sidebar/workspace-menu-model.js +1 -1
  193. package/dist/workspace/spaces/space-details-panel.js +2 -2
  194. package/dist/workspace/spaces/space-triggers.js +2 -2
  195. package/dist/workspace/spaces/space-view.js +11 -5
  196. package/package.json +15 -7
  197. package/skills/kortix-ui/references/modules.md +1 -1
  198. package/dist/customize/connectors/invalidate-connections.d.ts +0 -2
  199. package/dist/customize/connectors/invalidate-connections.js +0 -4
  200. package/dist/internal/notifications/use-inbox-summary.d.ts +0 -17
  201. package/dist/internal/notifications/use-inbox-summary.js +0 -28
  202. package/dist/session/prompts/session-connect-prompt.d.ts +0 -40
@@ -5,7 +5,7 @@ import { uiRoutes } from '../../lib/routes.js';
5
5
  import { isQuestionTool } from '@kortix/sdk';
6
6
  import { SessionAccessPrompt } from '../prompts/session-access-prompt.js';
7
7
  import { SessionApprovalPrompt } from '../prompts/session-approval-prompt.js';
8
- import { SessionConnectPrompt } from '../prompts/session-connect-prompt.js';
8
+ import { SessionConnectRequestsProvider } from '../prompts/session-connect-card.js';
9
9
  import { childSessionHref } from '../tool/tools/session-spawn-urls.js';
10
10
  import { SessionPermissionPrompt } from '../prompts/session-permission-prompt.js';
11
11
  import { useSessionWallpaperLayer } from '../panel/session-wallpaper-layer.js';
@@ -118,6 +118,7 @@ import { HELD_COMMAND_ROW_PREFIX, canReleaseHeldCommand, heldCommandRows, } from
118
118
  import { useSessionHistoryViewStore } from '../../internal/stores/session-history-view-store.js';
119
119
  import { downloadBlob } from '../../internal/lib/utils/download.js';
120
120
  import { RestoreNotice, hasOutOfContext } from './session-history.js';
121
+ import { useAgentRunLayout } from './agent-run-props.js';
121
122
  import { TranscriptTurnRow, isAgentNoticeTurn, strandedPromptIds, optimisticAnswersCache, promptTexts, resolveTurnError, } from './transcript.js';
122
123
  export { SessionReportCard, deriveTurnErrorAbortState, deriveTurnErrorPresentation } from './transcript.js';
123
124
  // ============================================================================
@@ -1257,7 +1258,9 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
1257
1258
  const messageCount = messages?.length ?? 0;
1258
1259
  const { scrollRef, contentRef, spacerElRef, showScrollButton, scrollToBottom, smoothScrollToAbsoluteBottom, anchorTurn, startAtTop, } = useAutoScroll({
1259
1260
  hasContent: messageCount > 0,
1260
- room: !transcriptRows,
1261
+ // Pin the newest prompt while it runs. Settled history needs only the
1262
+ // bottom gap, so short conversations reveal their earlier turns.
1263
+ room: !transcriptRows && effectiveBusy,
1261
1264
  });
1262
1265
  // Cmd/Ctrl+P prints the WHOLE conversation. The shortcut is intercepted
1263
1266
  // because neither half of what printing needs can be done in CSS: the
@@ -1497,8 +1500,6 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
1497
1500
  const [approvalDocked, setApprovalDocked] = useState(false);
1498
1501
  // My Kortix asking to give a colleague access docks the same way.
1499
1502
  const [accessDocked, setAccessDocked] = useState(false);
1500
- // A connector sign-in the agent started docks the same way (`SessionConnectPrompt`).
1501
- const [connectDocked, setConnectDocked] = useState(false);
1502
1503
  const questionPromptTimerRef = useRef(null);
1503
1504
  useEffect(() => {
1504
1505
  const nextQuestion = activePendingQuestion;
@@ -1987,6 +1988,10 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
1987
1988
  // Turns whose prompt is another agent's notice: the work continues across
1988
1989
  // them, so they sit a continuation's distance below the turn above.
1989
1990
  const agentNoticeTurnIds = useMemo(() => new Set(turns.filter((turn) => isAgentNoticeTurn(turn)).map((turn) => turn.id)), [turns]);
1991
+ // A person's agents report back as one unit: the reports and work of a run fold into one row
1992
+ // on its last turn, and every answer stays in view under it (KRTX-4732). The main transcript
1993
+ // only: a messages-only thread already hides notices.
1994
+ const agentRunLayout = useAgentRunLayout(turns, transcriptRows);
1990
1995
  const turnRenderKeys = useMemo(() => {
1991
1996
  const keys = new Map();
1992
1997
  const used = new Set();
@@ -2485,8 +2490,11 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
2485
2490
  const inboxRowExists = async () => {
2486
2491
  if (!projectId || !projectSessionId)
2487
2492
  return false;
2488
- const { prompts } = await listSessionPrompts(projectId, projectSessionId);
2489
- return inboxHoldsLivePrompt(prompts, clientMessageId);
2493
+ const { prompts, sent } = await listSessionPrompts(projectId, projectSessionId);
2494
+ // A delivered prompt leaves `prompts` and is listed in `sent` until the
2495
+ // session log holds it, under the wire id this send minted.
2496
+ const delivered = (sent ?? []).some((row) => row.message_id === messageID || row.wire_message_id === messageID);
2497
+ return delivered || inboxHoldsLivePrompt(prompts, clientMessageId);
2490
2498
  };
2491
2499
  const deliver = async (detached) => {
2492
2500
  // A detached send (uploads, or an earlier send of this session still
@@ -2693,6 +2701,16 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
2693
2701
  return { ok: true };
2694
2702
  }
2695
2703
  catch (cause) {
2704
+ // A lost ACK does not refuse a prompt the inbox already holds.
2705
+ // Resolve that verdict before the composer can restore its draft:
2706
+ // recoverFromSendFailure checks asynchronously and returns an error now.
2707
+ if (!keepsPainted && (await inboxRowExists().catch(() => false))) {
2708
+ acceptSendReceipt(messageID);
2709
+ attachments?.release();
2710
+ if (!paintTranscript)
2711
+ useQueuedDraftStore.getState().markPosted(sessionId, clientMessageId);
2712
+ return { ok: true };
2713
+ }
2696
2714
  // A kept send is settled below: its painted message stays.
2697
2715
  if (keepsPainted)
2698
2716
  return { ok: false, cause, error: null };
@@ -3419,7 +3437,7 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
3419
3437
  // The agents this session started, as one line in the composer's under-row
3420
3438
  // (Claude Code's agent panel). It reads its own lists and never holds the composer.
3421
3439
  const agentsLineCompact = !!transcriptRows && !isPhone;
3422
- const chatUnderbarSlot = useMemo(() => _jsx(AgentsLine, { projectId: projectId, sessionId: projectSessionId, compact: agentsLineCompact }), [projectId, projectSessionId, agentsLineCompact]);
3440
+ const chatUnderbarSlot = useMemo(() => (_jsx(AgentsLine, { projectId: projectId, sessionId: projectSessionId, compact: agentsLineCompact, live: isServerBusy })), [projectId, projectSessionId, agentsLineCompact, isServerBusy]);
3423
3441
  // A space's thread lists only the queue's live messages in its card: failed
3424
3442
  // ones and a Stop hold read as calm lines (`ChatQueueLines`), reports wait behind Resume.
3425
3443
  const calmRest = useMemo(() => [...queueRows.rows, ...heldCommandRows(heldCommands)].filter((row) => row.state !== 'failed' && !row.synthetic), [queueRows.rows, heldCommands]);
@@ -3461,13 +3479,11 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
3461
3479
  effectiveBusy,
3462
3480
  canStop,
3463
3481
  ]);
3464
- const chatInputSlot = useMemo(() => (_jsxs(_Fragment, { children: [_jsx(SessionApprovalPrompt, { onDockedChange: setApprovalDocked }), _jsx(SessionAccessPrompt, { projectId: projectId ?? '', asks: accessAsks, onDockedChange: setAccessDocked }), projectId && projectSessionId ? (_jsx(SessionConnectPrompt, { projectId: projectId, sessionId: projectSessionId, busy: effectiveBusy, onDockedChange: setConnectDocked })) : null, _jsx(SessionPermissionPrompt, { sessionId: sessionId, agentName: sessionScopeAgentName, permissions: pendingPermissions, onReply: handlePermissionReply }), renderedQuestion ? (_jsx("div", { className: cn('w-full overflow-hidden transition-[max-height,opacity,transform] ease-in-out', questionPromptVisible
3482
+ const chatInputSlot = useMemo(() => (_jsxs(_Fragment, { children: [_jsx(SessionApprovalPrompt, { onDockedChange: setApprovalDocked }), _jsx(SessionAccessPrompt, { projectId: projectId ?? '', asks: accessAsks, onDockedChange: setAccessDocked }), _jsx(SessionPermissionPrompt, { sessionId: sessionId, agentName: sessionScopeAgentName, permissions: pendingPermissions, onReply: handlePermissionReply }), renderedQuestion ? (_jsx("div", { className: cn('w-full overflow-hidden transition-[max-height,opacity,transform] ease-in-out', questionPromptVisible
3465
3483
  ? 'duration-slow max-h-130 translate-y-0 opacity-100'
3466
3484
  : 'duration-slow pointer-events-none max-h-0 -translate-y-1 opacity-0'), children: _jsx(QuestionPrompt, { ref: questionPromptRef, request: renderedQuestion, onReply: handleQuestionReply, onReject: handleQuestionReject, onActionChange: handleQuestionActionChange }, renderedQuestion.id) })) : null] })), [
3467
3485
  projectId,
3468
3486
  accessAsks,
3469
- effectiveBusy,
3470
- projectSessionId,
3471
3487
  sessionId,
3472
3488
  sessionScopeAgentName,
3473
3489
  pendingPermissions,
@@ -3728,296 +3744,299 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
3728
3744
  }
3729
3745
  return (
3730
3746
  // A read-only view (the sub-session modal) offers no fix inside a tool card.
3731
- _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', 'pb-[env(safe-area-inset-bottom)]', // audit:allow device safe-area inset, not a spacing step — the composer column lifts above the home indicator in the installed PWA; desktop reports a 0px inset
3732
- // Transparent in the welcome state so the root-level full-bleed wallpaper
3733
- // (portaled into SessionLayout) reads through; solid once real content
3734
- // takes over. Same base color either way, so non-welcome is unchanged.
3735
- 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
3736
- ? welcomeWallpaper && createPortal(welcomeWallpaper, wallpaperLayer)
3737
- : 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,
3738
- // A chat with no `useSession` source: the raw explorer lists the
3739
- // rows `useSessionSync` read for it.
3740
- 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: () => {
3741
- try {
3742
- if (sessionId)
3743
- useTabStore.getState().closeTab?.(sessionId);
3744
- }
3745
- catch { }
3746
- }, 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(
3747
- // overflow-anchor:none — this scroll area does ALL of its own
3748
- // anchoring (useAutoScroll's spacer + RAF follow, the send-path
3749
- // turn anchor, and the history-prepend content-space restore in
3750
- // session-history-scroll.ts). The browser's native scroll
3751
- // anchoring (default `overflow-anchor: auto`) tries to
3752
- // compensate for the SAME prepends independently, and the two
3753
- // corrections stacking is the other half of the scroll-up
3754
- // teleport: ours restores the reader's position, then the
3755
- // native one nudges it again.
3756
- '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",
3757
- // Width and gutters live in `SESSION_TRANSCRIPT_CLASS`: the
3758
- // instant shell draws this same column and the two crossfade
3759
- // into each other, so a difference here is a sideways jump on
3760
- // screen, not a style opinion. See session-body.tsx.
3761
- //
3762
- // No bottom padding, there or here: the space under the last
3763
- // message is the auto-scroll spacer's job alone. The `pb-32`
3764
- // that used to sit here stacked 128px of dead space on top of
3765
- // it — the "extra inset at the bottom of the session".
3766
- // Rows run edge to edge: each row owns its gutters and its hover fill.
3767
- 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 &&
3768
- !olderPullFailed &&
3769
- 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 &&
3770
- firstPromptSource &&
3771
- queuedSyntheticMessages.length === 0 &&
3772
- rowsContext && (
3773
- // A channel thread draws the stand-in as rows, the same
3774
- // rows its boot body drew (`ThreadBootRows`).
3775
- _jsx(PendingPromptRows, { text: buildOptimisticPromptTextWithUploads(firstPromptSource.text, firstPromptSource.files), author: rowsContext.owner, sessionId: sessionId, busy: turns.length === 0 && (lastTurnWorking || promptInbox.prompts.some(isFirstPromptRow)) })), showFirstPromptPreview &&
3776
- firstPromptSource &&
3777
- queuedSyntheticMessages.length === 0 &&
3778
- !rowsContext && (_jsx(OptimisticTurn, { text: buildOptimisticPromptTextWithUploads(firstPromptSource.text, firstPromptSource.files),
3779
- // Preserve a real failed-send status through the
3780
- // boot-shell handover without inventing upload progress.
3781
- // A first prompt held on its uploads carries its own.
3782
- uploadStatus: firstPromptSource.uploadStatus ?? firstPromptUploadStatus, agentNames: agentNames, onFileClick: openFileInComputer, sessionId: sessionId,
3783
- // The first item of the conversation, like turn 0, which has no
3784
- // top margin. `first:mt-0` misses here: the list opens with a
3785
- // zero-height <header>, so the stand-in sat 44px lower than turn 0
3786
- // and every swap between the two jumped the bubble (KRTX-2931).
3787
- className: "mt-0",
3788
- // An undelivered first prompt is a turn about to start, as the
3789
- // shell above this chat shows it: busy from the first frame,
3790
- // before the working projection has read the inbox (KRTX-2931).
3791
- busy: turns.length === 0 && (lastTurnWorking || promptInbox.prompts.some(isFirstPromptRow)) })), turns.map((turn, turnIndex) => {
3792
- // Check if this turn is a compaction summary — and
3793
- // whether it actually PRODUCED one. A failed/aborted
3794
- // attempt (compaction-flagged, no content, not the
3795
- // working turn) renders as one slim row, draws no
3796
- // divider, and stacks tight against a neighbouring
3797
- // failed attempt.
3798
- const compaction = turn.compaction;
3799
- const hasCompaction = compaction !== null;
3800
- const isTurnWorking = turn.live;
3801
- // `inFlight` (message state) alongside the projection:
3802
- // classifying by projection alone flipped a streaming
3803
- // compaction to "failed" for the frames where the two
3804
- // disagree, popping the divider in and out — a layout
3805
- // bounce right where the reader is looking.
3806
- const isFailedCompaction = compaction !== null &&
3807
- !compaction.hasContent &&
3808
- !compaction.inFlight &&
3809
- !isTurnWorking;
3810
- // Retries collapse to ONE visible row, GLOBALLY: a
3811
- // failed attempt with ANY later compaction turn (a
3812
- // retry, or the one that finally landed) is history —
3813
- // it keeps its TurnViewport (stable keys, scroll
3814
- // anchors) but renders no content, and an empty
3815
- // TurnViewport costs 0px (turn-viewport.tsx RULE 2).
3816
- // Adjacency was not enough: attempts whose error landed
3817
- // on a plain assistant message used to interleave as
3818
- // unclassified turns, breaking every consecutive run.
3819
- const suppressedFailedCompaction = isFailedCompaction && turnIndex < lastCompactionTurnIndex;
3820
- // Notification-only early-return removed: it rendered the
3821
- // user's pty_* card but skipped the turn's replies,
3822
- // hiding every subsequent assistant response in that turn.
3823
- // Fall through to the normal turn renderer instead.
3824
- const confirmedActive = turnIsConfirmedActive({
3825
- isTurnWorking,
3826
- turnId: turn.id,
3827
- activeTurnId,
3828
- pendingDelivery: !!working.pendingDelivery,
3829
- });
3830
- const pendingPrompt = !confirmedActive && turn.assistant.length === 0
3831
- ? pendingPromptsByMessageId.get(turn.id)
3832
- : undefined;
3833
- // A queued prompt is not in the runtime transcript yet;
3834
- // its author still shows (`authorForTurn`).
3835
- const promptAuthorId = pendingPromptsByMessageId.get(turn.id)?.author_user_id;
3836
- const turnAuthor = authorForTurn(transcriptAuthors, messageAuthors, turn.id, pendingPrompt?.wire_message_id) ??
3837
- participantAuthor(sessionParticipants, promptAuthorId) ??
3838
- (sentHereIds.current.has(turn.id) ||
3839
- sentHereIds.current.has(turnRenderKeys.get(turn.id) ?? '') ||
3840
- (viewerId !== undefined && promptAuthorId === viewerId) ||
3841
- // The first prompt of a session the viewer started,
3842
- // sent from another surface (project home), before
3843
- // the first authors read lands.
3844
- (messageAuthorsLoading &&
3845
- viewerId !== undefined &&
3846
- projectSessionRow?.created_by === viewerId &&
3847
- turn.id === userMessageIds[0])
3848
- ? viewerAsAuthor
3849
- : undefined);
3850
- return (_jsx(TranscriptTurnRow
3851
- // ONE element per prompt: keyed by the id the
3852
- // bubble was FIRST painted under, so the swap to a
3853
- // re-minted echo id re-renders this node instead
3854
- // of mounting a new one (opacity keeps animating,
3855
- // hover state survives, nothing jumps).
3856
- , { turnId: turn.id, modelOptions: modelOptions, suppressed: suppressedFailedCompaction, continuedWith: harnessSwitches.get(turn.id)?.harness, fullTextState: loaded.state[turn.id] ?? 'idle', onLoadFullText: loadFullTexts, showBusyRow: showFallbackBusyRow &&
3857
- fallbackBusyRowTurnId === turn.id,
3858
- // Queued bubbles STACK: a pending turn right after
3859
- // another pending turn sits close to it, like a
3860
- // list of what is waiting — not a turn's width
3861
- // apart as if each had been answered in between.
3862
- // (Failed compaction rows need no stacking rule any
3863
- // more — at most one is visible at a time.)
3864
- viewportClassName: turnIndex === 0 || transcriptRows
3865
- ? ''
3866
- : // A compaction, the work after it and another agent's notice continue the turn above.
3867
- turn.compaction || turn.continues || agentNoticeTurnIds.has(turn.id)
3868
- ? 'mt-6'
3869
- : lastTurnWorking &&
3870
- pendingTurnIds.has(turn.id) &&
3871
- pendingTurnIds.has(turns[turnIndex - 1].id)
3872
- ? 'mt-3'
3873
- : 'mt-12', turn: turn, author: turnAuthor,
3874
- // Reserve the sender row while the authors load,
3875
- // for a queued prompt whose sender is known, and
3876
- // for a live message until its author resolves.
3877
- showAuthor: !!turnAuthor ||
3878
- messageAuthorsLoading ||
3879
- !!promptAuthorId ||
3880
- (loadedUserIds?.sessionId === sessionId &&
3881
- !loadedUserIds.ids.has(turn.id) &&
3882
- 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,
3883
- // Handed over only once the stand-in has stepped
3884
- // aside — while it is up it draws these itself.
3885
- pendingText: turnIndex === 0 ? firstTurnHandover?.text : undefined, pendingAttachments: sentAttachmentsForTurn({
3886
- sentByMessage: sentAttachmentsByMessage,
3887
- messageId: turn.id,
3888
- originId: optimisticOriginOf(sessionId, turn.id),
3889
- isFirstTurn: turnIndex === 0,
3890
- firstTurnHandover: firstTurnHandover?.attachments,
3891
- firstTurnSent: firstPromptAttachments(projectSessionId),
3892
- queuedRowAttachments: inboxRowsByMessageId.get(turn.id)?.attachments,
3893
- }), uploadStatus: heldSendFailures?.[turn.id]
3894
- ? {
3895
- state: 'failed',
3896
- message: heldSendFailures[turn.id].message,
3897
- onRetry: () => retryHeldSend(sessionId, turn.id, resendHeldSend, (error) => classifySessionError(error).message),
3898
- }
3899
- : turnIndex === 0 && firstTurnHandover?.attachments.length
3900
- ? firstPromptUploadStatus
3901
- : undefined, sessionWorking: lastTurnWorking, isWorkingTurn: turn.live, suppressBusyIndicator: suppressWorkingTurnBusy, awaitingUser: awaitingUserInput,
3902
- // An idle send stays in the inbox until delivery,
3903
- // but nothing runs ahead of it: queued only while
3904
- // it waits behind a turn (`turnRendersQueued`).
3905
- // The first turn, with no turn working, has
3906
- // nothing ahead of it: a session's first prompt is
3907
- // starting, not queued, while the computer comes up
3908
- // and before the turn layer marks it queued or live.
3909
- pending: turnIndex === 0 && workingTurn.workingTurnId === null && !confirmedActive
3910
- ? pendingPrompt?.state === 'waiting' || pendingPrompt?.state === 'failed'
3911
- : turnRendersQueued({
3912
- turnId: turn.id,
3913
- resolution: workingTurn,
3914
- sessionWorking: lastTurnWorking,
3915
- confirmedActive,
3916
- inboxPrompt: pendingPrompt,
3917
- }), 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
3918
- ? rewindTarget.text
3919
- : null, editPending: editSendPending || !!sessionState?.rewindPending, onEditCancel: stableEditCancel, onEditSend: stableEditSend, rewindDisabled: !!readOnly ||
3920
- (rewindable !== null && !rewindable.has(turn.id)) ||
3921
- !runtimeCanRewind ||
3922
- !sessionState ||
3923
- isBusy ||
3924
- sessionState.rewindPending ||
3925
- // The runtime is not idle while queued prompts
3926
- // are still on their way to it — a rewind mid-
3927
- // delivery fails downstream with "Session is
3928
- // busy" (measured); refuse it up front instead.
3929
- promptInbox.prompts.length > 0 }, turnRenderKeys.get(turn.id)));
3930
- })] }) }), isOptimisticCompacting && !hasCompactionTurn && (_jsx("div", { className: turns.length > 0 ? 'mt-12' : 'mt-2', children: _jsx(CompactionMarker, { running: true }) })), [
3931
- ...(turnOutcome.recent_failures ?? []),
3932
- ...(turnOutcome.last_ended?.end_reason === 'failed' &&
3933
- !turnOutcome.recent_failures?.some((failure) => failure.message_id === turnOutcome.last_ended?.message_id)
3934
- ? [turnOutcome.last_ended]
3935
- : []),
3936
- ].filter((failure) => !isAbortError(failure.error) &&
3937
- !failureShownByTurn(failure, turns) &&
3938
- !failureSupersededByTurn(failure, turns) &&
3939
- (!failure.error?.message || failure.error.message !== commandError?.message)).map((failure) => {
3940
- const messageId = failure.message_id ?? 'persisted-turn-failure';
3941
- // Use the SDK's settle window for a cause that may arrive
3942
- // one frame later, including an unnamed failed last turn.
3943
- const notice = turnEndNotice({
3944
- ...turnOutcome,
3945
- recent_failures: [{ ...failure, message_id: messageId, error: failure.error ?? null }],
3946
- }, messageId, { hasError: false, isAbort: false });
3947
- return notice ? (_jsx(TurnErrorDisplay, { errorText: notice.kind === 'unexplained'
3948
- ? tHardcodedUi.raw('i18nComplete.text73112526c03a')
3949
- : persistedFailureText(failure.error), className: "mt-2" }, messageId)) : null;
3950
- }), commandError && (_jsx(TurnErrorDisplay, { error: commandError, isAbort: isAbortError(commandError.cause), modelOptions: modelOptions, className: "mt-2" })), showFallbackBusyRow && fallbackBusyRowTurnId === null && (rowsContext ? (
3951
- // A channel thread waits in the agent's answer row.
3952
- _jsx(AgentBusyRow, { sessionId: sessionId })) : (_jsx(SessionBusyIndicator, { sessionId: sessionId,
3953
- // Matches the stand-in's row spacing under a bubble
3954
- // (`OptimisticTurn`), so the crossfade into the real
3955
- // transcript does not move it. Nothing above it when
3956
- // the transcript is empty, so no margin there.
3957
- 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: {
3958
- left: `${selectionPopup.x}px`,
3959
- top: `${selectionPopup.y}px`,
3960
- transform: 'translate(-50%, -100%)',
3961
- }, 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
3962
- ? 'duration-normal scale-100 opacity-100'
3963
- : '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
3964
- // `undefined`, not `true`, once released: the composer's own
3965
- // viewport rule (>= 640px) still decides, so this never forces
3966
- // focus onto a phone keyboard.
3967
- // A thread a space's chat opened by itself does not take the focus (`ComposerAutoFocusContext`).
3968
- , {
3747
+ _jsx(ReadOnlySessionContext.Provider, { value: !!readOnly, children: _jsx(SessionConnectRequestsProvider, { projectId: readOnly ? null : projectId, sessionId: projectSessionId, busy: effectiveBusy, 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', 'pb-[env(safe-area-inset-bottom)]', // audit:allow device safe-area inset, not a spacing step — the composer column lifts above the home indicator in the installed PWA; desktop reports a 0px inset
3748
+ // Transparent in the welcome state so the root-level full-bleed wallpaper
3749
+ // (portaled into SessionLayout) reads through; solid once real content
3750
+ // takes over. Same base color either way, so non-welcome is unchanged.
3751
+ 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
3752
+ ? welcomeWallpaper && createPortal(welcomeWallpaper, wallpaperLayer)
3753
+ : welcomeWallpaper, !hideHeader && (_jsx(SessionSiteHeader, { sessionId: sessionId, sessionTitle: session?.title || 'Untitled', leadingAction: headerLeadingAction, parent: parentCrumb, live: isServerBusy })), _jsx(ModelSwitchHistory, { history: projectSessionRow?.metadata?.model_switches, current: projectSessionRow?.metadata?.model }), _jsx(SessionContextModal, { open: contextModalOpen, onOpenChange: setContextModalOpen,
3754
+ // A chat with no `useSession` source: the raw explorer lists the
3755
+ // rows `useSessionSync` read for it.
3756
+ 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: () => {
3757
+ try {
3758
+ if (sessionId)
3759
+ useTabStore.getState().closeTab?.(sessionId);
3760
+ }
3761
+ catch { }
3762
+ }, 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(
3763
+ // overflow-anchor:none — this scroll area does ALL of its own
3764
+ // anchoring (useAutoScroll's spacer + RAF follow, the send-path
3765
+ // turn anchor, and the history-prepend content-space restore in
3766
+ // session-history-scroll.ts). The browser's native scroll
3767
+ // anchoring (default `overflow-anchor: auto`) tries to
3768
+ // compensate for the SAME prepends independently, and the two
3769
+ // corrections stacking is the other half of the scroll-up
3770
+ // teleport: ours restores the reader's position, then the
3771
+ // native one nudges it again.
3772
+ '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",
3773
+ // Width and gutters live in `SESSION_TRANSCRIPT_CLASS`: the
3774
+ // instant shell draws this same column and the two crossfade
3775
+ // into each other, so a difference here is a sideways jump on
3776
+ // screen, not a style opinion. See session-body.tsx.
3777
+ //
3778
+ // No bottom padding, there or here: the space under the last
3779
+ // message is the auto-scroll spacer's job alone. The `pb-32`
3780
+ // that used to sit here stacked 128px of dead space on top of
3781
+ // it — the "extra inset at the bottom of the session".
3782
+ // Rows run edge to edge: each row owns its gutters and its hover fill.
3783
+ 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 &&
3784
+ !olderPullFailed &&
3785
+ 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 &&
3786
+ firstPromptSource &&
3787
+ queuedSyntheticMessages.length === 0 &&
3788
+ rowsContext && (
3789
+ // A channel thread draws the stand-in as rows, the same
3790
+ // rows its boot body drew (`ThreadBootRows`).
3791
+ _jsx(PendingPromptRows, { text: buildOptimisticPromptTextWithUploads(firstPromptSource.text, firstPromptSource.files), author: rowsContext.owner, sessionId: sessionId, busy: turns.length === 0 && (lastTurnWorking || promptInbox.prompts.some(isFirstPromptRow)) })), showFirstPromptPreview &&
3792
+ firstPromptSource &&
3793
+ queuedSyntheticMessages.length === 0 &&
3794
+ !rowsContext && (_jsx(OptimisticTurn, { text: buildOptimisticPromptTextWithUploads(firstPromptSource.text, firstPromptSource.files),
3795
+ // Preserve a real failed-send status through the
3796
+ // boot-shell handover without inventing upload progress.
3797
+ // A first prompt held on its uploads carries its own.
3798
+ uploadStatus: firstPromptSource.uploadStatus ?? firstPromptUploadStatus, agentNames: agentNames, onFileClick: openFileInComputer, sessionId: sessionId,
3799
+ // The first item of the conversation, like turn 0, which has no
3800
+ // top margin. `first:mt-0` misses here: the list opens with a
3801
+ // zero-height <header>, so the stand-in sat 44px lower than turn 0
3802
+ // and every swap between the two jumped the bubble (KRTX-2931).
3803
+ className: "mt-0",
3804
+ // An undelivered first prompt is a turn about to start, as the
3805
+ // shell above this chat shows it: busy from the first frame,
3806
+ // before the working projection has read the inbox (KRTX-2931).
3807
+ busy: turns.length === 0 && (lastTurnWorking || promptInbox.prompts.some(isFirstPromptRow)) })), turns.map((turn, turnIndex) => {
3808
+ // Check if this turn is a compaction summary — and
3809
+ // whether it actually PRODUCED one. A failed/aborted
3810
+ // attempt (compaction-flagged, no content, not the
3811
+ // working turn) renders as one slim row, draws no
3812
+ // divider, and stacks tight against a neighbouring
3813
+ // failed attempt.
3814
+ const compaction = turn.compaction;
3815
+ const hasCompaction = compaction !== null;
3816
+ const isTurnWorking = turn.live;
3817
+ // `inFlight` (message state) alongside the projection:
3818
+ // classifying by projection alone flipped a streaming
3819
+ // compaction to "failed" for the frames where the two
3820
+ // disagree, popping the divider in and out — a layout
3821
+ // bounce right where the reader is looking.
3822
+ const isFailedCompaction = compaction !== null &&
3823
+ !compaction.hasContent &&
3824
+ !compaction.inFlight &&
3825
+ !isTurnWorking;
3826
+ // Retries collapse to ONE visible row, GLOBALLY: a
3827
+ // failed attempt with ANY later compaction turn (a
3828
+ // retry, or the one that finally landed) is history —
3829
+ // it keeps its TurnViewport (stable keys, scroll
3830
+ // anchors) but renders no content, and an empty
3831
+ // TurnViewport costs 0px (turn-viewport.tsx RULE 2).
3832
+ // Adjacency was not enough: attempts whose error landed
3833
+ // on a plain assistant message used to interleave as
3834
+ // unclassified turns, breaking every consecutive run.
3835
+ const suppressedFailedCompaction = isFailedCompaction && turnIndex < lastCompactionTurnIndex;
3836
+ // Notification-only early-return removed: it rendered the
3837
+ // user's pty_* card but skipped the turn's replies,
3838
+ // hiding every subsequent assistant response in that turn.
3839
+ // Fall through to the normal turn renderer instead.
3840
+ const confirmedActive = turnIsConfirmedActive({
3841
+ isTurnWorking,
3842
+ turnId: turn.id,
3843
+ activeTurnId,
3844
+ pendingDelivery: !!working.pendingDelivery,
3845
+ });
3846
+ const pendingPrompt = !confirmedActive && turn.assistant.length === 0
3847
+ ? pendingPromptsByMessageId.get(turn.id)
3848
+ : undefined;
3849
+ // A queued prompt is not in the runtime transcript yet;
3850
+ // its author still shows (`authorForTurn`).
3851
+ const promptAuthorId = pendingPromptsByMessageId.get(turn.id)?.author_user_id;
3852
+ const turnAuthor = authorForTurn(transcriptAuthors, messageAuthors, turn.id, pendingPrompt?.wire_message_id) ??
3853
+ participantAuthor(sessionParticipants, promptAuthorId) ??
3854
+ (sentHereIds.current.has(turn.id) ||
3855
+ sentHereIds.current.has(turnRenderKeys.get(turn.id) ?? '') ||
3856
+ (viewerId !== undefined && promptAuthorId === viewerId) ||
3857
+ // The first prompt of a session the viewer started,
3858
+ // sent from another surface (project home), before
3859
+ // the first authors read lands.
3860
+ (messageAuthorsLoading &&
3861
+ viewerId !== undefined &&
3862
+ projectSessionRow?.created_by === viewerId &&
3863
+ turn.id === userMessageIds[0])
3864
+ ? viewerAsAuthor
3865
+ : undefined);
3866
+ return (_jsx(TranscriptTurnRow
3867
+ // ONE element per prompt: keyed by the id the
3868
+ // bubble was FIRST painted under, so the swap to a
3869
+ // re-minted echo id re-renders this node instead
3870
+ // of mounting a new one (opacity keeps animating,
3871
+ // hover state survives, nothing jumps).
3872
+ , { turnId: turn.id, modelOptions: modelOptions,
3873
+ // An absorbed run turn keeps its viewport (keys, scroll
3874
+ // anchors) and draws nothing: its anchor folds it.
3875
+ suppressed: suppressedFailedCompaction || agentRunLayout.absorbed.has(turn.id), ...agentRunLayout.propsOf(turn.id), continuedWith: harnessSwitches.get(turn.id)?.harness, fullTextState: loaded.state[turn.id] ?? 'idle', onLoadFullText: loadFullTexts, showBusyRow: showFallbackBusyRow &&
3876
+ fallbackBusyRowTurnId === turn.id,
3877
+ // Queued bubbles STACK: a pending turn right after
3878
+ // another pending turn sits close to it, like a
3879
+ // list of what is waiting — not a turn's width
3880
+ // apart as if each had been answered in between.
3881
+ // (Failed compaction rows need no stacking rule any
3882
+ // more — at most one is visible at a time.)
3883
+ viewportClassName: turnIndex === 0 || transcriptRows
3884
+ ? ''
3885
+ : // A compaction, the work after it and another agent's notice continue the turn above.
3886
+ turn.compaction || turn.continues || agentNoticeTurnIds.has(turn.id)
3887
+ ? 'mt-6'
3888
+ : lastTurnWorking &&
3889
+ pendingTurnIds.has(turn.id) &&
3890
+ pendingTurnIds.has(turns[turnIndex - 1].id)
3891
+ ? 'mt-3'
3892
+ : 'mt-12', turn: turn, author: turnAuthor,
3893
+ // Reserve the sender row while the authors load,
3894
+ // for a queued prompt whose sender is known, and
3895
+ // for a live message until its author resolves.
3896
+ showAuthor: !!turnAuthor ||
3897
+ messageAuthorsLoading ||
3898
+ !!promptAuthorId ||
3899
+ (loadedUserIds?.sessionId === sessionId &&
3900
+ !loadedUserIds.ids.has(turn.id) &&
3901
+ 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,
3902
+ // Handed over only once the stand-in has stepped
3903
+ // aside — while it is up it draws these itself.
3904
+ pendingText: turnIndex === 0 ? firstTurnHandover?.text : undefined, pendingAttachments: sentAttachmentsForTurn({
3905
+ sentByMessage: sentAttachmentsByMessage,
3906
+ messageId: turn.id,
3907
+ originId: optimisticOriginOf(sessionId, turn.id),
3908
+ isFirstTurn: turnIndex === 0,
3909
+ firstTurnHandover: firstTurnHandover?.attachments,
3910
+ firstTurnSent: firstPromptAttachments(projectSessionId),
3911
+ queuedRowAttachments: inboxRowsByMessageId.get(turn.id)?.attachments,
3912
+ }), uploadStatus: heldSendFailures?.[turn.id]
3913
+ ? {
3914
+ state: 'failed',
3915
+ message: heldSendFailures[turn.id].message,
3916
+ onRetry: () => retryHeldSend(sessionId, turn.id, resendHeldSend, (error) => classifySessionError(error).message),
3917
+ }
3918
+ : turnIndex === 0 && firstTurnHandover?.attachments.length
3919
+ ? firstPromptUploadStatus
3920
+ : undefined, sessionWorking: lastTurnWorking, isWorkingTurn: turn.live, suppressBusyIndicator: suppressWorkingTurnBusy, awaitingUser: awaitingUserInput,
3921
+ // An idle send stays in the inbox until delivery,
3922
+ // but nothing runs ahead of it: queued only while
3923
+ // it waits behind a turn (`turnRendersQueued`).
3924
+ // The first turn, with no turn working, has
3925
+ // nothing ahead of it: a session's first prompt is
3926
+ // starting, not queued, while the computer comes up
3927
+ // and before the turn layer marks it queued or live.
3928
+ pending: turnIndex === 0 && workingTurn.workingTurnId === null && !confirmedActive
3929
+ ? pendingPrompt?.state === 'waiting' || pendingPrompt?.state === 'failed'
3930
+ : turnRendersQueued({
3931
+ turnId: turn.id,
3932
+ resolution: workingTurn,
3933
+ sessionWorking: lastTurnWorking,
3934
+ confirmedActive,
3935
+ inboxPrompt: pendingPrompt,
3936
+ }), 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
3937
+ ? rewindTarget.text
3938
+ : null, editPending: editSendPending || !!sessionState?.rewindPending, onEditCancel: stableEditCancel, onEditSend: stableEditSend, rewindDisabled: !!readOnly ||
3939
+ (rewindable !== null && !rewindable.has(turn.id)) ||
3940
+ !runtimeCanRewind ||
3941
+ !sessionState ||
3942
+ isBusy ||
3943
+ sessionState.rewindPending ||
3944
+ // The runtime is not idle while queued prompts
3945
+ // are still on their way to it — a rewind mid-
3946
+ // delivery fails downstream with "Session is
3947
+ // busy" (measured); refuse it up front instead.
3948
+ promptInbox.prompts.length > 0 }, turnRenderKeys.get(turn.id)));
3949
+ })] }) }), isOptimisticCompacting && !hasCompactionTurn && (_jsx("div", { className: turns.length > 0 ? 'mt-12' : 'mt-2', children: _jsx(CompactionMarker, { running: true }) })), [
3950
+ ...(turnOutcome.recent_failures ?? []),
3951
+ ...(turnOutcome.last_ended?.end_reason === 'failed' &&
3952
+ !turnOutcome.recent_failures?.some((failure) => failure.message_id === turnOutcome.last_ended?.message_id)
3953
+ ? [turnOutcome.last_ended]
3954
+ : []),
3955
+ ].filter((failure) => !isAbortError(failure.error) &&
3956
+ !failureShownByTurn(failure, turns) &&
3957
+ !failureSupersededByTurn(failure, turns) &&
3958
+ (!failure.error?.message || failure.error.message !== commandError?.message)).map((failure) => {
3959
+ const messageId = failure.message_id ?? 'persisted-turn-failure';
3960
+ // Use the SDK's settle window for a cause that may arrive
3961
+ // one frame later, including an unnamed failed last turn.
3962
+ const notice = turnEndNotice({
3963
+ ...turnOutcome,
3964
+ recent_failures: [{ ...failure, message_id: messageId, error: failure.error ?? null }],
3965
+ }, messageId, { hasError: false, isAbort: false });
3966
+ return notice ? (_jsx(TurnErrorDisplay, { errorText: notice.kind === 'unexplained'
3967
+ ? tHardcodedUi.raw('i18nComplete.text73112526c03a')
3968
+ : persistedFailureText(failure.error), className: "mt-2" }, messageId)) : null;
3969
+ }), commandError && (_jsx(TurnErrorDisplay, { error: commandError, isAbort: isAbortError(commandError.cause), modelOptions: modelOptions, className: "mt-2" })), showFallbackBusyRow && fallbackBusyRowTurnId === null && (rowsContext ? (
3970
+ // A channel thread waits in the agent's answer row.
3971
+ _jsx(AgentBusyRow, { sessionId: sessionId })) : (_jsx(SessionBusyIndicator, { sessionId: sessionId,
3972
+ // Matches the stand-in's row spacing under a bubble
3973
+ // (`OptimisticTurn`), so the crossfade into the real
3974
+ // transcript does not move it. Nothing above it when
3975
+ // the transcript is empty, so no margin there.
3976
+ 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: {
3977
+ left: `${selectionPopup.x}px`,
3978
+ top: `${selectionPopup.y}px`,
3979
+ transform: 'translate(-50%, -100%)',
3980
+ }, 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
3981
+ ? 'duration-normal scale-100 opacity-100'
3982
+ : '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
3969
3983
  // `undefined`, not `true`, once released: the composer's own
3970
3984
  // viewport rule (>= 640px) still decides, so this never forces
3971
3985
  // focus onto a phone keyboard.
3972
3986
  // A thread a space's chat opened by itself does not take the focus (`ComposerAutoFocusContext`).
3973
- autoFocus: deferComposerFocus || !composerAutoFocus ? false : undefined, onSend: async (text, files, mentions, attachments, placement) => {
3974
- if (await queueEdit.save(text))
3975
- return;
3976
- // Enter or Cmd/Ctrl+Enter while a turn runs steers it (one delivery mode).
3977
- await handleSend(text, files, mentions, attachments, composerSendDelivery(placement ?? 'transcript', isBusyRef.current));
3978
- }, prefill: composerPrefill, onPrefillApplied: (id) => {
3979
- useSessionComposerPrefillStore.getState().clearPrefill(sessionId, id);
3980
- },
3981
- // Up from the first row takes the queue back; the placeholder
3982
- // says so while there is something to take.
3983
- onArrowUpAtStart: () => queueEdit.takeBack(),
3984
- // A host placeholder ("Reply…") is static: the rotating tips would replace it.
3985
- hint: canTakeBackQueue ? tHardcodedUi.raw('i18nComplete.text03a01dd53ffa') : composerPlaceholder,
3986
- // Editing a queued message: the send saves it back into the
3987
- // queue, so the control says Submit, never Stop.
3988
- submitLabel: queueEdit.editing ? tQueue('submitEdit') : null, draftScope: composerDraftScope, draftActive: !deferComposerFocus, attachRequestId: attachRequestId, isBusy: isBusy,
3989
- // The ONE projection, not the 300 ms busy fade: it is what
3990
- // decides whether a `/` command may be dispatched, and a fade
3991
- // timer that has already lapsed would let one abort a live turn.
3992
- // `effectiveBusy` folds in optimistic compaction (not a turn, so
3993
- // not in `working`) and the retrying-turn predicate, so this
3994
- // site reads one value instead of re-OR-ing a term onto it.
3995
- sessionWorking: effectiveBusy,
3996
- // Gates `/` COMMANDS only. A prompt typed at a sleeping box is
3997
- // an inbox row and goes out when the box answers; a command has
3998
- // no row, and `runCommand` swallows it silently until the
3999
- // runtime is switched.
4000
- 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,
4001
- // Locks while the docked question is answerable — a live
4002
- // question or a parked ask — see `questionLock` above.
4003
- lockForQuestion: questionLock,
4004
- // Same dead-prompt guard as questions: only lock while the agent is
4005
- // actually paused on the decision (isBusy), so a stale card can't
4006
- // swallow the composer on an idle session.
4007
- lockForApproval: runtimePermissionLocksComposer(livePermissions.length, isBusy), onCustomAnswer: handleCustomAnswer, questionButtonLabel: renderedQuestion ? questionAction.label : null, questionActive: !!renderedQuestion || approvalDocked || accessDocked || connectDocked, questionCanAct: questionAction.canAct, onQuestionAction: handleQuestionAction, aboveSlot: chatAboveSlot, inputSlot: chatInputSlot, toolbarSlot: chatToolbarSlot, underbarSlot: chatUnderbarSlot,
4008
- // The shell can now render on a cached transcript alone, i.e. before
4009
- // the sandbox answers — so sending has to be gated separately from
4010
- // reading. See sessionComposerReadiness.
4011
- notice: hostNotice(composerReadiness.notice, rowsContext?.notices),
4012
- // Inside the thread panel's bordered box, as the channel composer.
4013
- // A phone keeps the row under the card; a 720px desktop window does not.
4014
- underbarPlacement: transcriptRows && !isPhone ? 'inline' : undefined,
4015
- // The panel's toolbar is narrow: the agent is its tile, the model keeps its name.
4016
- agentPickerCompact: transcriptRows && !isPhone,
4017
- // A thread panel's rows run `px-5`, and the channel composer
4018
- // beside it sits `pb-4` off the window's bottom edge: the same
4019
- // margins, so the two boxes line up.
4020
- parentClassName: transcriptRows ? 'max-w-none px-5 pb-4' : undefined, call: composerCall, onNoticeRetry: composerReadiness.notice && composerReadiness.retryable
4021
- ? requestRuntimeReconnect
4022
- : 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 }) })] }))] })] }) }) }) }) }));
3987
+ , {
3988
+ // `undefined`, not `true`, once released: the composer's own
3989
+ // viewport rule (>= 640px) still decides, so this never forces
3990
+ // focus onto a phone keyboard.
3991
+ // A thread a space's chat opened by itself does not take the focus (`ComposerAutoFocusContext`).
3992
+ autoFocus: deferComposerFocus || !composerAutoFocus ? false : undefined, onSend: async (text, files, mentions, attachments, placement) => {
3993
+ if (await queueEdit.save(text))
3994
+ return;
3995
+ // Enter or Cmd/Ctrl+Enter while a turn runs steers it (one delivery mode).
3996
+ await handleSend(text, files, mentions, attachments, composerSendDelivery(placement ?? 'transcript', isBusyRef.current));
3997
+ }, prefill: composerPrefill, onPrefillApplied: (id) => {
3998
+ useSessionComposerPrefillStore.getState().clearPrefill(sessionId, id);
3999
+ },
4000
+ // Up from the first row takes the queue back; the placeholder
4001
+ // says so while there is something to take.
4002
+ onArrowUpAtStart: () => queueEdit.takeBack(),
4003
+ // A host placeholder ("Reply…") is static: the rotating tips would replace it.
4004
+ hint: canTakeBackQueue ? tHardcodedUi.raw('i18nComplete.text03a01dd53ffa') : composerPlaceholder,
4005
+ // Editing a queued message: the send saves it back into the
4006
+ // queue, so the control says Submit, never Stop.
4007
+ submitLabel: queueEdit.editing ? tQueue('submitEdit') : null, draftScope: composerDraftScope, draftActive: !deferComposerFocus, attachRequestId: attachRequestId, isBusy: isBusy,
4008
+ // The ONE projection, not the 300 ms busy fade: it is what
4009
+ // decides whether a `/` command may be dispatched, and a fade
4010
+ // timer that has already lapsed would let one abort a live turn.
4011
+ // `effectiveBusy` folds in optimistic compaction (not a turn, so
4012
+ // not in `working`) and the retrying-turn predicate, so this
4013
+ // site reads one value instead of re-OR-ing a term onto it.
4014
+ sessionWorking: effectiveBusy,
4015
+ // Gates `/` COMMANDS only. A prompt typed at a sleeping box is
4016
+ // an inbox row and goes out when the box answers; a command has
4017
+ // no row, and `runCommand` swallows it silently until the
4018
+ // runtime is switched.
4019
+ 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,
4020
+ // Locks while the docked question is answerable — a live
4021
+ // question or a parked ask — see `questionLock` above.
4022
+ lockForQuestion: questionLock,
4023
+ // Same dead-prompt guard as questions: only lock while the agent is
4024
+ // actually paused on the decision (isBusy), so a stale card can't
4025
+ // swallow the composer on an idle session.
4026
+ lockForApproval: runtimePermissionLocksComposer(livePermissions.length, isBusy), onCustomAnswer: handleCustomAnswer, questionButtonLabel: renderedQuestion ? questionAction.label : null, questionActive: !!renderedQuestion || approvalDocked || accessDocked, questionCanAct: questionAction.canAct, onQuestionAction: handleQuestionAction, aboveSlot: chatAboveSlot, inputSlot: chatInputSlot, toolbarSlot: chatToolbarSlot, underbarSlot: chatUnderbarSlot,
4027
+ // The shell can now render on a cached transcript alone, i.e. before
4028
+ // the sandbox answers — so sending has to be gated separately from
4029
+ // reading. See sessionComposerReadiness.
4030
+ notice: hostNotice(composerReadiness.notice, rowsContext?.notices),
4031
+ // Inside the thread panel's bordered box, as the channel composer.
4032
+ // A phone keeps the row under the card; a 720px desktop window does not.
4033
+ underbarPlacement: transcriptRows && !isPhone ? 'inline' : undefined,
4034
+ // The panel's toolbar is narrow: the agent is its tile, the model keeps its name.
4035
+ agentPickerCompact: transcriptRows && !isPhone,
4036
+ // A thread panel's rows run `px-5`, and the channel composer
4037
+ // beside it sits `pb-4` off the window's bottom edge: the same
4038
+ // margins, so the two boxes line up.
4039
+ parentClassName: transcriptRows ? 'max-w-none px-5 pb-4' : undefined, call: composerCall, onNoticeRetry: composerReadiness.notice && composerReadiness.retryable
4040
+ ? requestRuntimeReconnect
4041
+ : 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, live: isServerBusy }) })] }))] })] }) }) }) }) }) }));
4023
4042
  }