@kortix/ui 0.15.10 → 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 (93) hide show
  1. package/dist/_vendor/kortix-shared.js +396 -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/pasted-content.d.ts +0 -4
  8. package/dist/_vendor/shared/pixel-mark.d.ts +0 -17
  9. package/dist/_vendor/shared/project-glyphs.d.ts +0 -1
  10. package/dist/customize/agents/agent-model-view.d.ts +11 -1
  11. package/dist/customize/agents/agent-model-view.js +12 -1
  12. package/dist/customize/agents/agent-page.js +19 -6
  13. package/dist/customize/agents/agent-tabs.d.ts +2 -0
  14. package/dist/customize/agents/agent-tabs.js +2 -0
  15. package/dist/customize/connectors/detail/connector-triggers.js +1 -1
  16. package/dist/customize/connectors/use-agent-access.d.ts +1 -0
  17. package/dist/customize/sections/component/teams-byo-wizard.js +4 -1
  18. package/dist/customize/triggers/runtime-triggers.js +13 -2
  19. package/dist/customize/triggers/schedule/event-trigger-copy.js +1 -1
  20. package/dist/customize/triggers/schedule/schedule-detail-sheet.js +5 -4
  21. package/dist/customize/triggers/schedule/then-fields.d.ts +5 -1
  22. package/dist/customize/triggers/schedule/then-fields.js +23 -3
  23. package/dist/customize/triggers/schedule/trigger-callouts.js +1 -1
  24. package/dist/customize/triggers/schedule/trigger-composer-logic.d.ts +27 -0
  25. package/dist/customize/triggers/schedule/trigger-composer-logic.js +51 -5
  26. package/dist/customize/triggers/schedule/trigger-composer.js +19 -13
  27. package/dist/customize/triggers/schedule/trigger-edit-logic.js +25 -5
  28. package/dist/customize/triggers/schedule/trigger-filter.d.ts +10 -3
  29. package/dist/customize/triggers/schedule/trigger-filter.js +7 -6
  30. package/dist/customize/triggers/schedule/trigger-readonly.js +1 -1
  31. package/dist/customize/triggers/schedule/trigger-runs-panel.js +1 -1
  32. package/dist/customize/triggers/schedule/when-event.js +1 -1
  33. package/dist/customize/triggers/schedule/when-schedule.d.ts +5 -1
  34. package/dist/customize/triggers/schedule/when-schedule.js +16 -1
  35. package/dist/customize/triggers/schedule-view.js +4 -2
  36. package/dist/i18n/en.d.ts +49 -0
  37. package/dist/i18n/en.js +57 -8
  38. package/dist/internal/layout/project-settings-nav.d.ts +17 -0
  39. package/dist/internal/layout/project-settings-nav.js +24 -0
  40. package/dist/internal/lib/capability-tab-routes.d.ts +8 -0
  41. package/dist/internal/lib/capability-tab-routes.js +11 -0
  42. package/dist/internal/stores/composer-prefill-store.d.ts +7 -0
  43. package/dist/internal/stores/composer-prefill-store.js +1 -0
  44. package/dist/session/actions/session-label.js +2 -2
  45. package/dist/session/agents/agent-strip.d.ts +10 -5
  46. package/dist/session/agents/agent-strip.js +40 -12
  47. package/dist/session/agents/held-messages.d.ts +6 -2
  48. package/dist/session/agents/held-messages.js +6 -3
  49. package/dist/session/composer/ComposerCard.js +4 -1
  50. package/dist/session/composer/agent-selector.d.ts +2 -0
  51. package/dist/session/composer/agent-selector.js +5 -0
  52. package/dist/session/composer/composer-chat-input.d.ts +1 -0
  53. package/dist/session/composer/composer-logic.d.ts +7 -0
  54. package/dist/session/composer/composer-logic.js +18 -0
  55. package/dist/session/composer/composer-reset.d.ts +8 -14
  56. package/dist/session/composer/composer-toolbar.d.ts +3 -1
  57. package/dist/session/composer/composer-toolbar.js +3 -3
  58. package/dist/session/composer/composer.d.ts +7 -0
  59. package/dist/session/composer/composer.js +17 -3
  60. package/dist/session/composer/editor/composer-editor.js +6 -4
  61. package/dist/session/header/session-site-header.d.ts +3 -1
  62. package/dist/session/header/session-site-header.js +3 -2
  63. package/dist/session/models/connect-model-step.d.ts +29 -0
  64. package/dist/session/models/connect-model-step.js +50 -0
  65. package/dist/session/models/use-workspace-model-gate.d.ts +11 -0
  66. package/dist/session/models/use-workspace-model-gate.js +62 -0
  67. package/dist/session/models/workspace-model-gate.d.ts +46 -0
  68. package/dist/session/models/workspace-model-gate.js +66 -0
  69. package/dist/session/prompts/session-connect-card.d.ts +63 -0
  70. package/dist/session/prompts/{session-connect-prompt.js → session-connect-card.js} +53 -42
  71. package/dist/session/thread/session-chat.js +294 -298
  72. package/dist/session/thread/transcript.d.ts +2 -1
  73. package/dist/session/thread/transcript.js +7 -3
  74. package/dist/session/tool/tool-part-renderer.js +7 -2
  75. package/dist/session/tool/tools/kortix-action-tool.js +10 -2
  76. package/dist/session/turn/turn-viewport.d.ts +66 -10
  77. package/dist/session/turn/turn-viewport.js +92 -12
  78. package/dist/session/turn/user-message.js +7 -5
  79. package/dist/styles.css +1 -1
  80. package/dist/test-utils/intl.d.ts +49 -0
  81. package/dist/workspace/admin/project-admin-dashboard.js +2 -4
  82. package/dist/workspace/home/existing-repo-setup-prompt.d.ts +5 -8
  83. package/dist/workspace/home/existing-repo-setup-prompt.js +16 -42
  84. package/dist/workspace/home/no-agent-home.d.ts +3 -1
  85. package/dist/workspace/home/no-agent-home.js +2 -2
  86. package/dist/workspace/layout/project-home.js +16 -9
  87. package/dist/workspace/sidebar/session-grouping.d.ts +1 -1
  88. package/dist/workspace/sidebar/session-grouping.js +1 -1
  89. package/dist/workspace/spaces/space-details-panel.js +2 -2
  90. package/dist/workspace/spaces/space-triggers.js +2 -2
  91. package/dist/workspace/spaces/space-view.js +11 -5
  92. package/package.json +15 -3
  93. 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';
@@ -1500,8 +1500,6 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
1500
1500
  const [approvalDocked, setApprovalDocked] = useState(false);
1501
1501
  // My Kortix asking to give a colleague access docks the same way.
1502
1502
  const [accessDocked, setAccessDocked] = useState(false);
1503
- // A connector sign-in the agent started docks the same way (`SessionConnectPrompt`).
1504
- const [connectDocked, setConnectDocked] = useState(false);
1505
1503
  const questionPromptTimerRef = useRef(null);
1506
1504
  useEffect(() => {
1507
1505
  const nextQuestion = activePendingQuestion;
@@ -3439,7 +3437,7 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
3439
3437
  // The agents this session started, as one line in the composer's under-row
3440
3438
  // (Claude Code's agent panel). It reads its own lists and never holds the composer.
3441
3439
  const agentsLineCompact = !!transcriptRows && !isPhone;
3442
- 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]);
3443
3441
  // A space's thread lists only the queue's live messages in its card: failed
3444
3442
  // ones and a Stop hold read as calm lines (`ChatQueueLines`), reports wait behind Resume.
3445
3443
  const calmRest = useMemo(() => [...queueRows.rows, ...heldCommandRows(heldCommands)].filter((row) => row.state !== 'failed' && !row.synthetic), [queueRows.rows, heldCommands]);
@@ -3481,13 +3479,11 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
3481
3479
  effectiveBusy,
3482
3480
  canStop,
3483
3481
  ]);
3484
- 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
3485
3483
  ? 'duration-slow max-h-130 translate-y-0 opacity-100'
3486
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] })), [
3487
3485
  projectId,
3488
3486
  accessAsks,
3489
- effectiveBusy,
3490
- projectSessionId,
3491
3487
  sessionId,
3492
3488
  sessionScopeAgentName,
3493
3489
  pendingPermissions,
@@ -3748,299 +3744,299 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
3748
3744
  }
3749
3745
  return (
3750
3746
  // A read-only view (the sub-session modal) offers no fix inside a tool card.
3751
- _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
3752
- // Transparent in the welcome state so the root-level full-bleed wallpaper
3753
- // (portaled into SessionLayout) reads through; solid once real content
3754
- // takes over. Same base color either way, so non-welcome is unchanged.
3755
- 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
3756
- ? welcomeWallpaper && createPortal(welcomeWallpaper, wallpaperLayer)
3757
- : 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,
3758
- // A chat with no `useSession` source: the raw explorer lists the
3759
- // rows `useSessionSync` read for it.
3760
- 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: () => {
3761
- try {
3762
- if (sessionId)
3763
- useTabStore.getState().closeTab?.(sessionId);
3764
- }
3765
- catch { }
3766
- }, 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(
3767
- // overflow-anchor:none — this scroll area does ALL of its own
3768
- // anchoring (useAutoScroll's spacer + RAF follow, the send-path
3769
- // turn anchor, and the history-prepend content-space restore in
3770
- // session-history-scroll.ts). The browser's native scroll
3771
- // anchoring (default `overflow-anchor: auto`) tries to
3772
- // compensate for the SAME prepends independently, and the two
3773
- // corrections stacking is the other half of the scroll-up
3774
- // teleport: ours restores the reader's position, then the
3775
- // native one nudges it again.
3776
- '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",
3777
- // Width and gutters live in `SESSION_TRANSCRIPT_CLASS`: the
3778
- // instant shell draws this same column and the two crossfade
3779
- // into each other, so a difference here is a sideways jump on
3780
- // screen, not a style opinion. See session-body.tsx.
3781
- //
3782
- // No bottom padding, there or here: the space under the last
3783
- // message is the auto-scroll spacer's job alone. The `pb-32`
3784
- // that used to sit here stacked 128px of dead space on top of
3785
- // it — the "extra inset at the bottom of the session".
3786
- // Rows run edge to edge: each row owns its gutters and its hover fill.
3787
- 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 &&
3788
- !olderPullFailed &&
3789
- 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 &&
3790
- firstPromptSource &&
3791
- queuedSyntheticMessages.length === 0 &&
3792
- rowsContext && (
3793
- // A channel thread draws the stand-in as rows, the same
3794
- // rows its boot body drew (`ThreadBootRows`).
3795
- _jsx(PendingPromptRows, { text: buildOptimisticPromptTextWithUploads(firstPromptSource.text, firstPromptSource.files), author: rowsContext.owner, sessionId: sessionId, busy: turns.length === 0 && (lastTurnWorking || promptInbox.prompts.some(isFirstPromptRow)) })), showFirstPromptPreview &&
3796
- firstPromptSource &&
3797
- queuedSyntheticMessages.length === 0 &&
3798
- !rowsContext && (_jsx(OptimisticTurn, { text: buildOptimisticPromptTextWithUploads(firstPromptSource.text, firstPromptSource.files),
3799
- // Preserve a real failed-send status through the
3800
- // boot-shell handover without inventing upload progress.
3801
- // A first prompt held on its uploads carries its own.
3802
- uploadStatus: firstPromptSource.uploadStatus ?? firstPromptUploadStatus, agentNames: agentNames, onFileClick: openFileInComputer, sessionId: sessionId,
3803
- // The first item of the conversation, like turn 0, which has no
3804
- // top margin. `first:mt-0` misses here: the list opens with a
3805
- // zero-height <header>, so the stand-in sat 44px lower than turn 0
3806
- // and every swap between the two jumped the bubble (KRTX-2931).
3807
- className: "mt-0",
3808
- // An undelivered first prompt is a turn about to start, as the
3809
- // shell above this chat shows it: busy from the first frame,
3810
- // before the working projection has read the inbox (KRTX-2931).
3811
- busy: turns.length === 0 && (lastTurnWorking || promptInbox.prompts.some(isFirstPromptRow)) })), turns.map((turn, turnIndex) => {
3812
- // Check if this turn is a compaction summary — and
3813
- // whether it actually PRODUCED one. A failed/aborted
3814
- // attempt (compaction-flagged, no content, not the
3815
- // working turn) renders as one slim row, draws no
3816
- // divider, and stacks tight against a neighbouring
3817
- // failed attempt.
3818
- const compaction = turn.compaction;
3819
- const hasCompaction = compaction !== null;
3820
- const isTurnWorking = turn.live;
3821
- // `inFlight` (message state) alongside the projection:
3822
- // classifying by projection alone flipped a streaming
3823
- // compaction to "failed" for the frames where the two
3824
- // disagree, popping the divider in and out — a layout
3825
- // bounce right where the reader is looking.
3826
- const isFailedCompaction = compaction !== null &&
3827
- !compaction.hasContent &&
3828
- !compaction.inFlight &&
3829
- !isTurnWorking;
3830
- // Retries collapse to ONE visible row, GLOBALLY: a
3831
- // failed attempt with ANY later compaction turn (a
3832
- // retry, or the one that finally landed) is history —
3833
- // it keeps its TurnViewport (stable keys, scroll
3834
- // anchors) but renders no content, and an empty
3835
- // TurnViewport costs 0px (turn-viewport.tsx RULE 2).
3836
- // Adjacency was not enough: attempts whose error landed
3837
- // on a plain assistant message used to interleave as
3838
- // unclassified turns, breaking every consecutive run.
3839
- const suppressedFailedCompaction = isFailedCompaction && turnIndex < lastCompactionTurnIndex;
3840
- // Notification-only early-return removed: it rendered the
3841
- // user's pty_* card but skipped the turn's replies,
3842
- // hiding every subsequent assistant response in that turn.
3843
- // Fall through to the normal turn renderer instead.
3844
- const confirmedActive = turnIsConfirmedActive({
3845
- isTurnWorking,
3846
- turnId: turn.id,
3847
- activeTurnId,
3848
- pendingDelivery: !!working.pendingDelivery,
3849
- });
3850
- const pendingPrompt = !confirmedActive && turn.assistant.length === 0
3851
- ? pendingPromptsByMessageId.get(turn.id)
3852
- : undefined;
3853
- // A queued prompt is not in the runtime transcript yet;
3854
- // its author still shows (`authorForTurn`).
3855
- const promptAuthorId = pendingPromptsByMessageId.get(turn.id)?.author_user_id;
3856
- const turnAuthor = authorForTurn(transcriptAuthors, messageAuthors, turn.id, pendingPrompt?.wire_message_id) ??
3857
- participantAuthor(sessionParticipants, promptAuthorId) ??
3858
- (sentHereIds.current.has(turn.id) ||
3859
- sentHereIds.current.has(turnRenderKeys.get(turn.id) ?? '') ||
3860
- (viewerId !== undefined && promptAuthorId === viewerId) ||
3861
- // The first prompt of a session the viewer started,
3862
- // sent from another surface (project home), before
3863
- // the first authors read lands.
3864
- (messageAuthorsLoading &&
3865
- viewerId !== undefined &&
3866
- projectSessionRow?.created_by === viewerId &&
3867
- turn.id === userMessageIds[0])
3868
- ? viewerAsAuthor
3869
- : undefined);
3870
- return (_jsx(TranscriptTurnRow
3871
- // ONE element per prompt: keyed by the id the
3872
- // bubble was FIRST painted under, so the swap to a
3873
- // re-minted echo id re-renders this node instead
3874
- // of mounting a new one (opacity keeps animating,
3875
- // hover state survives, nothing jumps).
3876
- , { turnId: turn.id, modelOptions: modelOptions,
3877
- // An absorbed run turn keeps its viewport (keys, scroll
3878
- // anchors) and draws nothing: its anchor folds it.
3879
- 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 &&
3880
- fallbackBusyRowTurnId === turn.id,
3881
- // Queued bubbles STACK: a pending turn right after
3882
- // another pending turn sits close to it, like a
3883
- // list of what is waiting — not a turn's width
3884
- // apart as if each had been answered in between.
3885
- // (Failed compaction rows need no stacking rule any
3886
- // more — at most one is visible at a time.)
3887
- viewportClassName: turnIndex === 0 || transcriptRows
3888
- ? ''
3889
- : // A compaction, the work after it and another agent's notice continue the turn above.
3890
- turn.compaction || turn.continues || agentNoticeTurnIds.has(turn.id)
3891
- ? 'mt-6'
3892
- : lastTurnWorking &&
3893
- pendingTurnIds.has(turn.id) &&
3894
- pendingTurnIds.has(turns[turnIndex - 1].id)
3895
- ? 'mt-3'
3896
- : 'mt-12', turn: turn, author: turnAuthor,
3897
- // Reserve the sender row while the authors load,
3898
- // for a queued prompt whose sender is known, and
3899
- // for a live message until its author resolves.
3900
- showAuthor: !!turnAuthor ||
3901
- messageAuthorsLoading ||
3902
- !!promptAuthorId ||
3903
- (loadedUserIds?.sessionId === sessionId &&
3904
- !loadedUserIds.ids.has(turn.id) &&
3905
- 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,
3906
- // Handed over only once the stand-in has stepped
3907
- // aside — while it is up it draws these itself.
3908
- pendingText: turnIndex === 0 ? firstTurnHandover?.text : undefined, pendingAttachments: sentAttachmentsForTurn({
3909
- sentByMessage: sentAttachmentsByMessage,
3910
- messageId: turn.id,
3911
- originId: optimisticOriginOf(sessionId, turn.id),
3912
- isFirstTurn: turnIndex === 0,
3913
- firstTurnHandover: firstTurnHandover?.attachments,
3914
- firstTurnSent: firstPromptAttachments(projectSessionId),
3915
- queuedRowAttachments: inboxRowsByMessageId.get(turn.id)?.attachments,
3916
- }), uploadStatus: heldSendFailures?.[turn.id]
3917
- ? {
3918
- state: 'failed',
3919
- message: heldSendFailures[turn.id].message,
3920
- onRetry: () => retryHeldSend(sessionId, turn.id, resendHeldSend, (error) => classifySessionError(error).message),
3921
- }
3922
- : turnIndex === 0 && firstTurnHandover?.attachments.length
3923
- ? firstPromptUploadStatus
3924
- : undefined, sessionWorking: lastTurnWorking, isWorkingTurn: turn.live, suppressBusyIndicator: suppressWorkingTurnBusy, awaitingUser: awaitingUserInput,
3925
- // An idle send stays in the inbox until delivery,
3926
- // but nothing runs ahead of it: queued only while
3927
- // it waits behind a turn (`turnRendersQueued`).
3928
- // The first turn, with no turn working, has
3929
- // nothing ahead of it: a session's first prompt is
3930
- // starting, not queued, while the computer comes up
3931
- // and before the turn layer marks it queued or live.
3932
- pending: turnIndex === 0 && workingTurn.workingTurnId === null && !confirmedActive
3933
- ? pendingPrompt?.state === 'waiting' || pendingPrompt?.state === 'failed'
3934
- : turnRendersQueued({
3935
- turnId: turn.id,
3936
- resolution: workingTurn,
3937
- sessionWorking: lastTurnWorking,
3938
- confirmedActive,
3939
- inboxPrompt: pendingPrompt,
3940
- }), 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
3941
- ? rewindTarget.text
3942
- : null, editPending: editSendPending || !!sessionState?.rewindPending, onEditCancel: stableEditCancel, onEditSend: stableEditSend, rewindDisabled: !!readOnly ||
3943
- (rewindable !== null && !rewindable.has(turn.id)) ||
3944
- !runtimeCanRewind ||
3945
- !sessionState ||
3946
- isBusy ||
3947
- sessionState.rewindPending ||
3948
- // The runtime is not idle while queued prompts
3949
- // are still on their way to it — a rewind mid-
3950
- // delivery fails downstream with "Session is
3951
- // busy" (measured); refuse it up front instead.
3952
- promptInbox.prompts.length > 0 }, turnRenderKeys.get(turn.id)));
3953
- })] }) }), isOptimisticCompacting && !hasCompactionTurn && (_jsx("div", { className: turns.length > 0 ? 'mt-12' : 'mt-2', children: _jsx(CompactionMarker, { running: true }) })), [
3954
- ...(turnOutcome.recent_failures ?? []),
3955
- ...(turnOutcome.last_ended?.end_reason === 'failed' &&
3956
- !turnOutcome.recent_failures?.some((failure) => failure.message_id === turnOutcome.last_ended?.message_id)
3957
- ? [turnOutcome.last_ended]
3958
- : []),
3959
- ].filter((failure) => !isAbortError(failure.error) &&
3960
- !failureShownByTurn(failure, turns) &&
3961
- !failureSupersededByTurn(failure, turns) &&
3962
- (!failure.error?.message || failure.error.message !== commandError?.message)).map((failure) => {
3963
- const messageId = failure.message_id ?? 'persisted-turn-failure';
3964
- // Use the SDK's settle window for a cause that may arrive
3965
- // one frame later, including an unnamed failed last turn.
3966
- const notice = turnEndNotice({
3967
- ...turnOutcome,
3968
- recent_failures: [{ ...failure, message_id: messageId, error: failure.error ?? null }],
3969
- }, messageId, { hasError: false, isAbort: false });
3970
- return notice ? (_jsx(TurnErrorDisplay, { errorText: notice.kind === 'unexplained'
3971
- ? tHardcodedUi.raw('i18nComplete.text73112526c03a')
3972
- : persistedFailureText(failure.error), className: "mt-2" }, messageId)) : null;
3973
- }), commandError && (_jsx(TurnErrorDisplay, { error: commandError, isAbort: isAbortError(commandError.cause), modelOptions: modelOptions, className: "mt-2" })), showFallbackBusyRow && fallbackBusyRowTurnId === null && (rowsContext ? (
3974
- // A channel thread waits in the agent's answer row.
3975
- _jsx(AgentBusyRow, { sessionId: sessionId })) : (_jsx(SessionBusyIndicator, { sessionId: sessionId,
3976
- // Matches the stand-in's row spacing under a bubble
3977
- // (`OptimisticTurn`), so the crossfade into the real
3978
- // transcript does not move it. Nothing above it when
3979
- // the transcript is empty, so no margin there.
3980
- 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: {
3981
- left: `${selectionPopup.x}px`,
3982
- top: `${selectionPopup.y}px`,
3983
- transform: 'translate(-50%, -100%)',
3984
- }, 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
3985
- ? 'duration-normal scale-100 opacity-100'
3986
- : '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
3987
- // `undefined`, not `true`, once released: the composer's own
3988
- // viewport rule (>= 640px) still decides, so this never forces
3989
- // focus onto a phone keyboard.
3990
- // A thread a space's chat opened by itself does not take the focus (`ComposerAutoFocusContext`).
3991
- , {
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
3992
3983
  // `undefined`, not `true`, once released: the composer's own
3993
3984
  // viewport rule (>= 640px) still decides, so this never forces
3994
3985
  // focus onto a phone keyboard.
3995
3986
  // A thread a space's chat opened by itself does not take the focus (`ComposerAutoFocusContext`).
3996
- autoFocus: deferComposerFocus || !composerAutoFocus ? false : undefined, onSend: async (text, files, mentions, attachments, placement) => {
3997
- if (await queueEdit.save(text))
3998
- return;
3999
- // Enter or Cmd/Ctrl+Enter while a turn runs steers it (one delivery mode).
4000
- await handleSend(text, files, mentions, attachments, composerSendDelivery(placement ?? 'transcript', isBusyRef.current));
4001
- }, prefill: composerPrefill, onPrefillApplied: (id) => {
4002
- useSessionComposerPrefillStore.getState().clearPrefill(sessionId, id);
4003
- },
4004
- // Up from the first row takes the queue back; the placeholder
4005
- // says so while there is something to take.
4006
- onArrowUpAtStart: () => queueEdit.takeBack(),
4007
- // A host placeholder ("Reply…") is static: the rotating tips would replace it.
4008
- hint: canTakeBackQueue ? tHardcodedUi.raw('i18nComplete.text03a01dd53ffa') : composerPlaceholder,
4009
- // Editing a queued message: the send saves it back into the
4010
- // queue, so the control says Submit, never Stop.
4011
- submitLabel: queueEdit.editing ? tQueue('submitEdit') : null, draftScope: composerDraftScope, draftActive: !deferComposerFocus, attachRequestId: attachRequestId, isBusy: isBusy,
4012
- // The ONE projection, not the 300 ms busy fade: it is what
4013
- // decides whether a `/` command may be dispatched, and a fade
4014
- // timer that has already lapsed would let one abort a live turn.
4015
- // `effectiveBusy` folds in optimistic compaction (not a turn, so
4016
- // not in `working`) and the retrying-turn predicate, so this
4017
- // site reads one value instead of re-OR-ing a term onto it.
4018
- sessionWorking: effectiveBusy,
4019
- // Gates `/` COMMANDS only. A prompt typed at a sleeping box is
4020
- // an inbox row and goes out when the box answers; a command has
4021
- // no row, and `runCommand` swallows it silently until the
4022
- // runtime is switched.
4023
- 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,
4024
- // Locks while the docked question is answerable — a live
4025
- // question or a parked ask — see `questionLock` above.
4026
- lockForQuestion: questionLock,
4027
- // Same dead-prompt guard as questions: only lock while the agent is
4028
- // actually paused on the decision (isBusy), so a stale card can't
4029
- // swallow the composer on an idle session.
4030
- 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,
4031
- // The shell can now render on a cached transcript alone, i.e. before
4032
- // the sandbox answers — so sending has to be gated separately from
4033
- // reading. See sessionComposerReadiness.
4034
- notice: hostNotice(composerReadiness.notice, rowsContext?.notices),
4035
- // Inside the thread panel's bordered box, as the channel composer.
4036
- // A phone keeps the row under the card; a 720px desktop window does not.
4037
- underbarPlacement: transcriptRows && !isPhone ? 'inline' : undefined,
4038
- // The panel's toolbar is narrow: the agent is its tile, the model keeps its name.
4039
- agentPickerCompact: transcriptRows && !isPhone,
4040
- // A thread panel's rows run `px-5`, and the channel composer
4041
- // beside it sits `pb-4` off the window's bottom edge: the same
4042
- // margins, so the two boxes line up.
4043
- parentClassName: transcriptRows ? 'max-w-none px-5 pb-4' : undefined, call: composerCall, onNoticeRetry: composerReadiness.notice && composerReadiness.retryable
4044
- ? requestRuntimeReconnect
4045
- : 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 }) })] }))] })] }) }) }) }) }) }));
4046
4042
  }