@kortix/ui 0.15.9 → 0.15.10

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 (124) hide show
  1. package/dist/_vendor/kortix-shared.js +72 -1
  2. package/dist/_vendor/shared/index.d.ts +1 -0
  3. package/dist/_vendor/shared/session/attachment-tile.d.ts +32 -0
  4. package/dist/_vendor/shared/session/stop-refusal.d.ts +15 -0
  5. package/dist/_vendor/shared/session/tool-row-text.d.ts +58 -0
  6. package/dist/_vendor/shared/session-delivery.d.ts +2 -0
  7. package/dist/customize/connectors/connectors-page.js +1 -1
  8. package/dist/customize/connectors/detail/connector-page.js +9 -4
  9. package/dist/customize/connectors/install/use-install.js +1 -1
  10. package/dist/customize/providers/provider-accordion.js +5 -5
  11. package/dist/customize/providers/provider-connect.d.ts +3 -3
  12. package/dist/customize/providers/provider-connect.js +8 -16
  13. package/dist/customize/providers/provider-sheet.js +4 -4
  14. package/dist/customize/sections/connector-connection-form.d.ts +0 -1
  15. package/dist/customize/sections/connector-connection-form.js +0 -9
  16. package/dist/customize/sections/view/review-center-connected.js +7 -3
  17. package/dist/customize/settings/tabs/workspace-keys.js +53 -11
  18. package/dist/customize/shared/feature-gate-screen.js +1 -1
  19. package/dist/customize/triggers/schedule/event-account-picker.js +1 -1
  20. package/dist/customize/triggers/schedule/use-event-app-connect.js +2 -1
  21. package/dist/i18n/en.d.ts +7 -7
  22. package/dist/i18n/en.js +8 -8
  23. package/dist/internal/billing/compute-pricing.d.ts +7 -1
  24. package/dist/internal/billing/compute-pricing.js +7 -1
  25. package/dist/internal/hooks/connectors/invalidate-connections.d.ts +10 -0
  26. package/dist/internal/hooks/connectors/invalidate-connections.js +18 -0
  27. package/dist/internal/hooks/connectors/use-finish-sign-in.js +1 -1
  28. package/dist/internal/hooks/connectors/use-pipedream-connect-member.js +1 -1
  29. package/dist/internal/hooks/connectors/use-pipedream-connect-project.js +1 -1
  30. package/dist/internal/hooks/projects/use-new-project-session.d.ts +2 -0
  31. package/dist/internal/hooks/projects/use-new-project-session.js +4 -1
  32. package/dist/internal/hooks/use-review-session-summary.d.ts +1 -1
  33. package/dist/internal/hooks/use-review-session-summary.js +1 -1
  34. package/dist/internal/lib/browser-noise/rules/injected-scripts.js +2 -2
  35. package/dist/internal/notifications/notification-inbox.d.ts +4 -10
  36. package/dist/internal/notifications/notification-inbox.js +8 -9
  37. package/dist/internal/stores/connector-gate-store.d.ts +3 -1
  38. package/dist/internal/stores/connector-gate-store.js +13 -3
  39. package/dist/internal/stores/upgrade-dialog-store.d.ts +4 -0
  40. package/dist/internal/stores/upgrade-dialog-store.js +2 -0
  41. package/dist/lib/routes.d.ts +4 -11
  42. package/dist/lib/routes.js +3 -5
  43. package/dist/markdown/unified-markdown-utils.d.ts +7 -0
  44. package/dist/markdown/unified-markdown-utils.js +19 -0
  45. package/dist/markdown/unified-markdown.js +16 -3
  46. package/dist/primitives/alert-dialog.js +1 -1
  47. package/dist/primitives/dialog.js +3 -1
  48. package/dist/primitives/drawer.js +1 -1
  49. package/dist/primitives/modal.js +1 -1
  50. package/dist/primitives/preview-image.js +1 -1
  51. package/dist/primitives/sheet.js +1 -1
  52. package/dist/session/composer/ComposerCard.js +4 -2
  53. package/dist/session/composer/attachment-tile.d.ts +2 -26
  54. package/dist/session/composer/attachment-tile.js +3 -47
  55. package/dist/session/composer/composer-chat-input.d.ts +2 -1
  56. package/dist/session/composer/composer-chat-input.js +2 -2
  57. package/dist/session/composer/composer.d.ts +2 -0
  58. package/dist/session/composer/composer.js +5 -8
  59. package/dist/session/composer/draft/home-composer-focus-handoff.d.ts +7 -0
  60. package/dist/session/composer/draft/home-composer-focus-handoff.js +94 -0
  61. package/dist/session/composer/draft/use-composer-draft.d.ts +3 -1
  62. package/dist/session/composer/draft/use-composer-draft.js +22 -2
  63. package/dist/session/composer/editor/composer-editor.d.ts +4 -2
  64. package/dist/session/composer/editor/composer-editor.js +7 -3
  65. package/dist/session/composer/hooks/use-composer-focus.js +4 -2
  66. package/dist/session/index.d.ts +1 -0
  67. package/dist/session/index.js +1 -0
  68. package/dist/session/models/chatgpt-connection-button.js +5 -9
  69. package/dist/session/models/model-connection-gate.d.ts +2 -1
  70. package/dist/session/models/model-connection-gate.js +6 -3
  71. package/dist/session/models/model-connection-layout.d.ts +2 -0
  72. package/dist/session/models/model-connection-layout.js +4 -0
  73. package/dist/session/models/model-selector.d.ts +1 -1
  74. package/dist/session/models/model-selector.js +9 -6
  75. package/dist/session/models/subscription-offer.d.ts +4 -0
  76. package/dist/session/models/subscription-offer.js +11 -3
  77. package/dist/session/overrides/session-overrides-toolbar.js +2 -4
  78. package/dist/session/prompts/ask-deck.d.ts +5 -1
  79. package/dist/session/prompts/ask-deck.js +15 -3
  80. package/dist/session/prompts/question-labels.d.ts +16 -0
  81. package/dist/session/prompts/question-labels.js +34 -0
  82. package/dist/session/prompts/question-prompt.js +6 -6
  83. package/dist/session/status/provisioning-failure.d.ts +23 -2
  84. package/dist/session/status/provisioning-failure.js +53 -3
  85. package/dist/session/status/stop-refusal.d.ts +6 -12
  86. package/dist/session/status/stop-refusal.js +6 -19
  87. package/dist/session/thread/agent-run-props.d.ts +19 -0
  88. package/dist/session/thread/agent-run-props.js +54 -0
  89. package/dist/session/thread/session-chat.js +27 -4
  90. package/dist/session/thread/transcript.d.ts +17 -1
  91. package/dist/session/thread/transcript.js +87 -23
  92. package/dist/session/tool/tools/bash-tool.d.ts +3 -52
  93. package/dist/session/tool/tools/bash-tool.js +3 -86
  94. package/dist/session/turn/answer-streaming.d.ts +21 -0
  95. package/dist/session/turn/answer-streaming.js +34 -0
  96. package/dist/session/turn/queued-prompt-bubbles.d.ts +5 -0
  97. package/dist/session/turn/queued-prompt-bubbles.js +12 -0
  98. package/dist/session/turn/turn-work-accordion.d.ts +3 -1
  99. package/dist/session/turn/turn-work-accordion.js +2 -2
  100. package/dist/styles.css +1 -1
  101. package/dist/test-utils/intl.d.ts +7 -7
  102. package/dist/workspace/home/first-chat.d.ts +7 -1
  103. package/dist/workspace/home/first-chat.js +12 -5
  104. package/dist/workspace/inbox/workspace-inbox.d.ts +6 -16
  105. package/dist/workspace/inbox/workspace-inbox.js +9 -51
  106. package/dist/workspace/layout/project-home.js +5 -11
  107. package/dist/workspace/layout/use-project-home-send.d.ts +2 -0
  108. package/dist/workspace/layout/use-project-home-send.js +29 -15
  109. package/dist/workspace/new/advanced-fields.d.ts +4 -1
  110. package/dist/workspace/new/advanced-fields.js +2 -2
  111. package/dist/workspace/new/workspace-name.d.ts +9 -0
  112. package/dist/workspace/new/workspace-name.js +20 -0
  113. package/dist/workspace/projects/session-starter.d.ts +6 -4
  114. package/dist/workspace/projects/session-starter.js +8 -14
  115. package/dist/workspace/review/review-center.d.ts +6 -2
  116. package/dist/workspace/review/review-center.js +45 -25
  117. package/dist/workspace/sidebar/workspace-menu-model.d.ts +3 -5
  118. package/dist/workspace/sidebar/workspace-menu-model.js +1 -1
  119. package/package.json +3 -7
  120. package/skills/kortix-ui/references/modules.md +1 -1
  121. package/dist/customize/connectors/invalidate-connections.d.ts +0 -2
  122. package/dist/customize/connectors/invalidate-connections.js +0 -4
  123. package/dist/internal/notifications/use-inbox-summary.d.ts +0 -17
  124. package/dist/internal/notifications/use-inbox-summary.js +0 -28
@@ -1,4 +1,5 @@
1
- import { readStartStash } from '@kortix/sdk/react';
1
+ import { isOptimisticSessionPrompt, readStartStash } from '@kortix/sdk/react';
2
+ import { isFirstPromptRow } from '../composer/queue-projection.js';
2
3
  /** Build stable error-card copy from API-owned sandbox failure metadata. */
3
4
  export function provisioningFailurePresentation(metadata, sandboxLabel, tI18nComplete) {
4
5
  const resolvedSandboxLabel = sandboxLabel ?? 'session';
@@ -70,6 +71,35 @@ export function pendingSessionPromptFromMetadata(metadata) {
70
71
  attachment_names: attachmentNames,
71
72
  };
72
73
  }
74
+ /**
75
+ * The session's own prompt in its server inbox, oldest first.
76
+ *
77
+ * The create stores the first prompt as a `session_lifecycle_commands` row and
78
+ * strips its text from `metadata.pending_prompt` (`pending-prompt.ts`). When
79
+ * the box never boots, that row is the ONLY copy of the prompt: it stays
80
+ * `queued`, then goes `dead_lettered` (listed as `failed`) once its delivery
81
+ * attempts are spent. The first-prompt row wins; any other person-written row
82
+ * is next. Optimistic rows have no server id to retry, so they never count.
83
+ */
84
+ function inboxPromptForRecovery(prompts) {
85
+ const candidates = prompts.filter((prompt) => !isOptimisticSessionPrompt(prompt) && !prompt.synthetic && !!prompt.prompt_id);
86
+ const row = candidates.find(isFirstPromptRow) ?? candidates[0];
87
+ if (!row)
88
+ return null;
89
+ const text = row.full_text || row.text || '';
90
+ const attachmentNames = (row.attachments ?? []).map((file) => file.filename);
91
+ if (text.trim().length === 0 && attachmentNames.length === 0)
92
+ return null;
93
+ return {
94
+ text,
95
+ agent: null,
96
+ model: null,
97
+ variant: null,
98
+ attachment_names: attachmentNames,
99
+ redeliveredOnRestart: true,
100
+ inboxPrompt: { promptId: row.prompt_id, failed: row.state === 'failed' },
101
+ };
102
+ }
73
103
  /**
74
104
  * The recovery copy, from the server when it has one and from this tab's start
75
105
  * stash otherwise. Never consumes either.
@@ -83,11 +113,19 @@ export function pendingSessionPromptFromMetadata(metadata) {
83
113
  * created has neither: its first prompt is `metadata.initial_prompt`. That
84
114
  * prompt is shown only while `runtimeSessionId` is empty, which is the same
85
115
  * condition under which the restart re-delivers it.
116
+ *
117
+ * `inboxPrompts` is `GET .../prompts`. A session the current API created keeps
118
+ * its first prompt ONLY there, so it answers before the start stash: the stash
119
+ * is a client-delivered copy, and posting it beside the server's own row sent
120
+ * the prompt twice.
86
121
  */
87
- export function pendingSessionPromptForRecovery(sessionId, metadata, runtimeSessionId) {
122
+ export function pendingSessionPromptForRecovery(sessionId, metadata, runtimeSessionId, inboxPrompts = []) {
88
123
  const fromMetadata = pendingSessionPromptFromMetadata(metadata);
89
124
  if (fromMetadata)
90
125
  return { ...fromMetadata, redeliveredOnRestart: false };
126
+ const fromInbox = inboxPromptForRecovery(inboxPrompts);
127
+ if (fromInbox)
128
+ return fromInbox;
91
129
  const stash = readStartStash(sessionId);
92
130
  if (stash && stash.prompt.trim().length > 0) {
93
131
  return {
@@ -119,6 +157,18 @@ export function pendingSessionPromptForRecovery(sessionId, metadata, runtimeSess
119
157
  export function recoveryPromptToSendOnRetry(prompt) {
120
158
  if (!prompt || prompt.redeliveredOnRestart)
121
159
  return null;
122
- const { redeliveredOnRestart: _redeliveredOnRestart, ...toSend } = prompt;
160
+ const { redeliveredOnRestart: _redeliveredOnRestart, inboxPrompt: _inboxPrompt, ...toSend } = prompt;
123
161
  return toSend;
124
162
  }
163
+ /**
164
+ * The inbox row Retry must re-queue, or null, read when the restarted box is
165
+ * ready. Retry remembers the row id; its state is checked then, not at the
166
+ * click, because a row still queued at the click can dead-letter while the box
167
+ * restarts. A `failed` row is never claimed again on its own. A queued row is
168
+ * delivered by the drain, so re-queueing it would only reorder it.
169
+ */
170
+ export function inboxPromptToRequeue(promptId, prompts) {
171
+ if (!promptId)
172
+ return null;
173
+ return prompts.some((row) => row.prompt_id === promptId && row.state === 'failed') ? promptId : null;
174
+ }
@@ -1,14 +1,8 @@
1
1
  /**
2
- * In a shared session only the member who started the running turn, the
3
- * session owner or a project manager may stop it. The composer hides Stop when
4
- * `useSession().canStop` says no, so a refusal only reaches here when that
5
- * answer was stale. The server's own words are what the toast says.
2
+ * The composer hides Stop when `useSession().canStop` says no, so a refusal
3
+ * only reaches here when that answer was stale. The server's own words are
4
+ * what the toast says.
5
+ *
6
+ * The guard lives once in `@kortix/shared/session/stop-refusal`.
6
7
  */
7
- export declare const NOT_TURN_PROMPTER = "not_turn_prompter";
8
- /**
9
- * The server's message when it refused a stop, or null for any other failure.
10
- * A REST stop (the hold, "Stop and send") is an `ApiError` carrying the code.
11
- * The runtime abort answers through the sandbox proxy, whose error keeps the
12
- * status and the message but not the code, so a 403 counts there too.
13
- */
14
- export declare function stopRefusalMessage(error: unknown): string | null;
8
+ export { NOT_TURN_PROMPTER, stopRefusalMessage } from '../../_vendor/shared/session/stop-refusal.js';
@@ -1,21 +1,8 @@
1
1
  /**
2
- * In a shared session only the member who started the running turn, the
3
- * session owner or a project manager may stop it. The composer hides Stop when
4
- * `useSession().canStop` says no, so a refusal only reaches here when that
5
- * answer was stale. The server's own words are what the toast says.
2
+ * The composer hides Stop when `useSession().canStop` says no, so a refusal
3
+ * only reaches here when that answer was stale. The server's own words are
4
+ * what the toast says.
5
+ *
6
+ * The guard lives once in `@kortix/shared/session/stop-refusal`.
6
7
  */
7
- export const NOT_TURN_PROMPTER = 'not_turn_prompter';
8
- /**
9
- * The server's message when it refused a stop, or null for any other failure.
10
- * A REST stop (the hold, "Stop and send") is an `ApiError` carrying the code.
11
- * The runtime abort answers through the sandbox proxy, whose error keeps the
12
- * status and the message but not the code, so a 403 counts there too.
13
- */
14
- export function stopRefusalMessage(error) {
15
- if (!error || typeof error !== 'object')
16
- return null;
17
- const { status, code, message } = error;
18
- if (code !== NOT_TURN_PROMPTER && status !== 403)
19
- return null;
20
- return typeof message === 'string' && message ? message : null;
21
- }
8
+ export { NOT_TURN_PROMPTER, stopRefusalMessage } from '../../_vendor/kortix-shared.js';
@@ -0,0 +1,19 @@
1
+ import { type SessionLogAgentRun, type SessionLogTurn } from '@kortix/sdk';
2
+ /** What one transcript row receives from its agent run (KRTX-4732). */
3
+ export interface AgentRunRowProps {
4
+ agentRun?: SessionLogAgentRun;
5
+ runTurns?: readonly SessionLogTurn[];
6
+ foldStartedWork?: boolean;
7
+ }
8
+ export interface AgentRunLayout {
9
+ /** The turns the transcript draws no row for: they fold into their run's anchor. */
10
+ absorbed: ReadonlySet<string>;
11
+ /** A row's run props; the same object while nothing about the run changed. */
12
+ propsOf: (turnId: string) => AgentRunRowProps;
13
+ }
14
+ /**
15
+ * The agent runs of a transcript (`sessionLogAgentRuns`), as row props. A stream delta remakes
16
+ * the turn list; a row whose run did not change keeps its props object, so its memoized row
17
+ * still bails out. `disabled` (a messages-only thread): no runs.
18
+ */
19
+ export declare function useAgentRunLayout(turns: readonly SessionLogTurn[], disabled: boolean): AgentRunLayout;
@@ -0,0 +1,54 @@
1
+ 'use client';
2
+ import { sessionLogAgentRuns } from '@kortix/sdk';
3
+ import { useMemo, useState } from 'react';
4
+ const NONE = Object.freeze({});
5
+ const EMPTY = { absorbed: new Set(), propsOf: () => NONE };
6
+ const sameRun = (a, b) => a.anchor === b.anchor &&
7
+ a.agents === b.agents &&
8
+ a.started === b.started &&
9
+ a.reported === b.reported &&
10
+ a.durationMs === b.durationMs &&
11
+ a.live === b.live &&
12
+ a.stopped === b.stopped &&
13
+ a.turns.length === b.turns.length &&
14
+ a.turns.every((id, i) => id === b.turns[i]);
15
+ const sameTurns = (a, b) => a === b || (!!a && !!b && a.length === b.length && a.every((turn, i) => turn === b[i]));
16
+ /**
17
+ * The agent runs of a transcript (`sessionLogAgentRuns`), as row props. A stream delta remakes
18
+ * the turn list; a row whose run did not change keeps its props object, so its memoized row
19
+ * still bails out. `disabled` (a messages-only thread): no runs.
20
+ */
21
+ export function useAgentRunLayout(turns, disabled) {
22
+ // The props each row got last time. A cache, not state: writing it never renders.
23
+ const [previous] = useState(() => new Map());
24
+ return useMemo(() => {
25
+ if (disabled)
26
+ return EMPTY;
27
+ const layout = sessionLogAgentRuns(turns);
28
+ if (layout.runs.size === 0 && layout.settledLaunches.size === 0) {
29
+ previous.clear();
30
+ return EMPTY;
31
+ }
32
+ const byId = new Map(turns.map((turn) => [turn.id, turn]));
33
+ const next = new Map();
34
+ const ids = new Set([...layout.runs.keys(), ...layout.settledLaunches]);
35
+ for (const id of ids) {
36
+ const run = layout.runs.get(id);
37
+ const runTurns = run?.turns.slice(0, -1).map((turnId) => byId.get(turnId));
38
+ const fresh = {
39
+ ...(run ? { agentRun: run, runTurns } : {}),
40
+ ...(layout.settledLaunches.has(id) ? { foldStartedWork: true } : {}),
41
+ };
42
+ const old = previous.get(id);
43
+ const unchanged = old &&
44
+ !!old.foldStartedWork === !!fresh.foldStartedWork &&
45
+ (old.agentRun && fresh.agentRun ? sameRun(old.agentRun, fresh.agentRun) : old.agentRun === fresh.agentRun) &&
46
+ sameTurns(old.runTurns, fresh.runTurns);
47
+ next.set(id, unchanged ? old : fresh);
48
+ }
49
+ previous.clear();
50
+ for (const [id, props] of next)
51
+ previous.set(id, props);
52
+ return { absorbed: layout.absorbed, propsOf: (turnId) => next.get(turnId) ?? NONE };
53
+ }, [turns, disabled, previous]);
54
+ }
@@ -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
@@ -1987,6 +1990,10 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
1987
1990
  // Turns whose prompt is another agent's notice: the work continues across
1988
1991
  // them, so they sit a continuation's distance below the turn above.
1989
1992
  const agentNoticeTurnIds = useMemo(() => new Set(turns.filter((turn) => isAgentNoticeTurn(turn)).map((turn) => turn.id)), [turns]);
1993
+ // A person's agents report back as one unit: the reports and work of a run fold into one row
1994
+ // on its last turn, and every answer stays in view under it (KRTX-4732). The main transcript
1995
+ // only: a messages-only thread already hides notices.
1996
+ const agentRunLayout = useAgentRunLayout(turns, transcriptRows);
1990
1997
  const turnRenderKeys = useMemo(() => {
1991
1998
  const keys = new Map();
1992
1999
  const used = new Set();
@@ -2485,8 +2492,11 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
2485
2492
  const inboxRowExists = async () => {
2486
2493
  if (!projectId || !projectSessionId)
2487
2494
  return false;
2488
- const { prompts } = await listSessionPrompts(projectId, projectSessionId);
2489
- return inboxHoldsLivePrompt(prompts, clientMessageId);
2495
+ const { prompts, sent } = await listSessionPrompts(projectId, projectSessionId);
2496
+ // A delivered prompt leaves `prompts` and is listed in `sent` until the
2497
+ // session log holds it, under the wire id this send minted.
2498
+ const delivered = (sent ?? []).some((row) => row.message_id === messageID || row.wire_message_id === messageID);
2499
+ return delivered || inboxHoldsLivePrompt(prompts, clientMessageId);
2490
2500
  };
2491
2501
  const deliver = async (detached) => {
2492
2502
  // A detached send (uploads, or an earlier send of this session still
@@ -2693,6 +2703,16 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
2693
2703
  return { ok: true };
2694
2704
  }
2695
2705
  catch (cause) {
2706
+ // A lost ACK does not refuse a prompt the inbox already holds.
2707
+ // Resolve that verdict before the composer can restore its draft:
2708
+ // recoverFromSendFailure checks asynchronously and returns an error now.
2709
+ if (!keepsPainted && (await inboxRowExists().catch(() => false))) {
2710
+ acceptSendReceipt(messageID);
2711
+ attachments?.release();
2712
+ if (!paintTranscript)
2713
+ useQueuedDraftStore.getState().markPosted(sessionId, clientMessageId);
2714
+ return { ok: true };
2715
+ }
2696
2716
  // A kept send is settled below: its painted message stays.
2697
2717
  if (keepsPainted)
2698
2718
  return { ok: false, cause, error: null };
@@ -3853,7 +3873,10 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
3853
3873
  // re-minted echo id re-renders this node instead
3854
3874
  // of mounting a new one (opacity keeps animating,
3855
3875
  // 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 &&
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 &&
3857
3880
  fallbackBusyRowTurnId === turn.id,
3858
3881
  // Queued bubbles STACK: a pending turn right after
3859
3882
  // another pending turn sits close to it, like a
@@ -1,5 +1,5 @@
1
1
  import { useTranslations } from '../../i18n/index.js';
2
- import { type SessionLogBlock, type SessionLogMessage, type SessionLogSegment, type SessionLogTurn, type SessionMessageAuthor, type SessionPrompt, type SessionPromptViewer, type TextBlock, type ToolCallBlock, type SessionLogReferencedText } from '@kortix/sdk';
2
+ import { type SessionLogBlock, type SessionLogMessage, type SessionLogSegment, type SessionLogAgentRun, type SessionLogTurn, type SessionMessageAuthor, type SessionPrompt, type SessionPromptViewer, type TextBlock, type ToolCallBlock, type SessionLogReferencedText } from '@kortix/sdk';
3
3
  import type { AttachmentUploadStatus, NormalizedAttachment } from '../turn/user-message.js';
4
4
  import type { TurnServedModel } from '../turn/served-model.js';
5
5
  import { type ConversationDensity } from '../../internal/stores/user-preferences-store.js';
@@ -202,6 +202,22 @@ interface SessionTurnProps {
202
202
  onEditCancel?: () => void;
203
203
  /** Commit the edit: rewind the session at `messageId`, send `text` and the `kept` attachments. */
204
204
  onEditSend?: (messageId: string, text: string, kept: NormalizedAttachment[]) => void;
205
+ /**
206
+ * This turn answers an agent run (`sessionLogAgentRuns`, KRTX-4732): its "Worked for" row is
207
+ * the run's row ("Worked for 5m · 3 agents") and folds the run's reports and work. Every answer
208
+ * of the run stays in view under the row, in order: an agent may give the full answer before
209
+ * the last report arrives, so no answer is folded away.
210
+ */
211
+ agentRun?: SessionLogAgentRun;
212
+ /** The run's other turns, in order: the host draws no row for them. Keep its identity stable. */
213
+ runTurns?: readonly SessionLogTurn[];
214
+ /** Every agent this turn started has reported (`settledLaunches`): its agent rows fold too. */
215
+ foldStartedWork?: boolean;
216
+ /**
217
+ * A run's other turn, drawn by its anchor: `work` is its notice and work, inside the run fold;
218
+ * `answer` is its answer and footer, under the run row.
219
+ */
220
+ runMember?: 'work' | 'answer';
205
221
  }
206
222
  /**
207
223
  * The worker-run result row shown above a turn — an entity row in the design
@@ -8,13 +8,14 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
8
8
  // answered-question cards and notification turns. `session-chat.tsx`
9
9
  // re-exports the public names.
10
10
  // ============================================================================
11
+ import { STALE_RUNTIME_DELIVERY_ERROR } from '../../_vendor/kortix-shared.js';
11
12
  import { isQuestionTool } from '@kortix/sdk';
12
13
  import { UnifiedMarkdown } from '../../markdown/unified-markdown.js';
13
14
  import { detectCommandFromText } from './detect-command.js';
14
15
  import { GenuiTelemetryContext } from '../../markdown/genui/block-telemetry.js';
15
16
  import { copyGenuiText } from '../../markdown/genui/to-markdown.js';
16
17
  import { useLocale, useTranslations } from '../../i18n/index.js';
17
- import { isSessionLogRestoreNote, sessionLogActivityText, sessionLogAnsweredQuestionCall, sessionLogBurstSteps, sessionLogOpenCall, sessionLogTurnSegments, sessionPromptActions, splitSessionLogTurnWork, isNoGroupActivityTool, toolCallMetadata, toolKind, } from '@kortix/sdk';
18
+ import { isSessionLogRestoreNote, sessionLogActivityText, sessionLogAnsweredQuestionCall, sessionLogBurstSteps, sessionLogOpenCall, sessionLogTurnSegments, sessionPromptActions, splitSessionLogTurnWork, sessionLogAgentRunLabel, isNoGroupActivityTool, toolCallMetadata, toolKind, } from '@kortix/sdk';
18
19
  import { WarningIcon as AlertTriangle, CheckCircleIcon as CheckCircle, CheckIcon, CaretDownIcon as ChevronDown, ArrowSquareOutIcon as ExternalLink, StopCircleIcon, } from '@phosphor-icons/react';
19
20
  import { AnimatePresence, m } from 'motion/react';
20
21
  import { memo, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from 'react';
@@ -35,7 +36,7 @@ import { CompactionFailedRow, CompactionMarker, compactionReset } from '../turn/
35
36
  import { ExpandableOutput } from '../turn/expandable-output.js';
36
37
  import { isPlanWriteTool } from '../turn/plan-anchor.js';
37
38
  import { TurnFallbackRows } from '../turn/fallback-row.js';
38
- import { QUEUED_BUBBLE_OPACITY_CLASS, queuedBubbleTone, QueuedPromptFailure, QueuedPromptProgress, } from '../turn/queued-prompt-bubbles.js';
39
+ import { QUEUED_BUBBLE_OPACITY_CLASS, queuedBubbleTone, QueuedPromptFailure, QueuedPromptProgress, QueuedPromptRecovery, } from '../turn/queued-prompt-bubbles.js';
39
40
  import { ShowGroupRenderer } from '../tool/show-group-renderer.js';
40
41
  import { statusElapsedFrame } from '../turn/status-elapsed.js';
41
42
  import { ThrottledMarkdown } from '../turn/throttled-markdown.js';
@@ -46,6 +47,7 @@ import { TurnOutcomes } from '../outcomes/turn-outcomes.js';
46
47
  import { SessionRetryDisplay, TurnErrorDisplay } from '../status/session-error-banner.js';
47
48
  import { showTurnBusyIndicator } from '@kortix/sdk';
48
49
  import { SessionBusyIndicator } from '../status/session-busy-indicator.js';
50
+ import { useAnswerStreaming } from '../turn/answer-streaming.js';
49
51
  import { SessionTurnMeta } from './session-turn-meta.js';
50
52
  import { TurnShareButton } from './turn-share.js';
51
53
  import { sessionTurnDurationMs, sessionTurnEndedAt, sessionTurnSpan, } from './session-turn-meta-rows.js';
@@ -236,6 +238,29 @@ export function deriveTurnErrorPresentation(input) {
236
238
  };
237
239
  }
238
240
  }
241
+ /** A `send_message` call: the agent relaying between colleagues. Inside a run it is noise. */
242
+ function isRelayCall(block) {
243
+ return block.type === 'tool_call' && block.name.toLowerCase().replace(/[^a-z]/g, '') === 'sendmessage';
244
+ }
245
+ /** The segments without the relay calls (`isRelayCall`); the same array when there is none. */
246
+ function withoutRelayCalls(segments) {
247
+ let changed = false;
248
+ const kept = segments.flatMap((segment) => {
249
+ if (segment.kind === 'standalone' && isRelayCall(segment.block)) {
250
+ changed = true;
251
+ return [];
252
+ }
253
+ if (segment.kind === 'burst') {
254
+ const blocks = segment.blocks.filter((block) => !isRelayCall(block));
255
+ if (blocks.length !== segment.blocks.length) {
256
+ changed = true;
257
+ return blocks.length ? [{ ...segment, blocks }] : [];
258
+ }
259
+ }
260
+ return [segment];
261
+ });
262
+ return changed ? kept : segments;
263
+ }
239
264
  /**
240
265
  * The worker-run result row shown above a turn — an entity row in the design
241
266
  * system's sense, not a tinted banner: the surface stays neutral and the status
@@ -1049,12 +1074,12 @@ function TurnUserBlock(props) {
1049
1074
  /** The user message bubble — dimmed while the prompt waits in the queue. */
1050
1075
  function TurnUserBubble(props) {
1051
1076
  const { hasVisibleUserContent } = props.userContent;
1052
- const { turn, author, showAuthor, pending, pendingPrompt, interruptedBeforeRun, pendingAttachments, uploadStatus, pendingText, agentNames, commandMessages, commands, sessionId, ownsPlan, onRewind, rewindDisabled, editingText, editPending, onEditCancel, onEditSend, onRetryQueued, onRemoveQueued, queuedPromptViewer, onOpenPastedContent, } = props;
1077
+ const { turn, author, showAuthor, pending, pendingPrompt, interruptedBeforeRun, pendingAttachments, uploadStatus, pendingText, agentNames, commandMessages, commands, sessionId, projectId, ownsPlan, onRewind, rewindDisabled, editingText, editPending, onEditCancel, onEditSend, onRetryQueued, onRemoveQueued, queuedPromptViewer, onOpenPastedContent, } = props;
1053
1078
  const { queueState, queuedStatus } = props.queueTone;
1054
1079
  const promptActions = pendingPrompt && queuedPromptViewer
1055
1080
  ? sessionPromptActions(pendingPrompt, queuedPromptViewer)
1056
1081
  : { own: true, removable: true };
1057
- return (_jsx(_Fragment, { children: hasVisibleUserContent && (_jsx("div", { "data-turn-pending": pending || interruptedBeforeRun || undefined, "data-turn-queue-state": pendingPrompt?.state ?? queueState ?? undefined, "data-pending-prompt-id": pendingPrompt?.prompt_id, "data-queue-tone": queuedBubbleTone(queuedStatus), className: cn((pending || interruptedBeforeRun) && QUEUED_BUBBLE_OPACITY_CLASS), children: _jsx(UserMessage, { message: turn.user, author: author, showAuthor: showAuthor, pendingAttachments: pendingAttachments, uploadStatus: uploadStatus, pendingText: pendingText, agentNames: agentNames, commandInfo: commandMessages?.get(turn.id), commands: commands, sessionId: sessionId, ownsPlan: ownsPlan, onRewind: onRewind, rewindDisabled: rewindDisabled || pending || interruptedBeforeRun, editingText: editingText, editPending: editPending, onEditCancel: onEditCancel, onEditSend: onEditSend, onOpenPastedContent: onOpenPastedContent, deliveryStatus: queuedStatus === 'failed' ? (_jsx(QueuedPromptFailure, { lastError: pendingPrompt?.last_error, onRetry: pendingPrompt && onRetryQueued && promptActions.own
1082
+ return (_jsx(_Fragment, { children: hasVisibleUserContent && (_jsx("div", { "data-turn-pending": pending || interruptedBeforeRun || undefined, "data-turn-queue-state": pendingPrompt?.state ?? queueState ?? undefined, "data-pending-prompt-id": pendingPrompt?.prompt_id, "data-queue-tone": queuedBubbleTone(queuedStatus), className: cn((pending || interruptedBeforeRun) && QUEUED_BUBBLE_OPACITY_CLASS), children: _jsx(UserMessage, { message: turn.user, author: author, showAuthor: showAuthor, pendingAttachments: pendingAttachments, uploadStatus: uploadStatus, pendingText: pendingText, agentNames: agentNames, commandInfo: commandMessages?.get(turn.id), commands: commands, sessionId: sessionId, ownsPlan: ownsPlan, onRewind: onRewind, rewindDisabled: rewindDisabled || pending || interruptedBeforeRun, editingText: editingText, editPending: editPending, onEditCancel: onEditCancel, onEditSend: onEditSend, onOpenPastedContent: onOpenPastedContent, deliveryStatus: pendingPrompt?.last_error === STALE_RUNTIME_DELIVERY_ERROR ? (_jsx(QueuedPromptRecovery, { projectId: projectId, onRemove: onRemoveQueued && promptActions.removable ? () => onRemoveQueued(pendingPrompt.prompt_id) : undefined })) : queuedStatus === 'failed' ? (_jsx(QueuedPromptFailure, { lastError: pendingPrompt?.last_error, onRetry: pendingPrompt && onRetryQueued && promptActions.own
1058
1083
  ? () => onRetryQueued(pendingPrompt.prompt_id)
1059
1084
  : undefined, onRemove: pendingPrompt && onRemoveQueued && promptActions.removable
1060
1085
  ? () => onRemoveQueued(pendingPrompt.prompt_id)
@@ -1065,13 +1090,13 @@ const NO_RECOVERED_CALLS = new Set();
1065
1090
  /** The assistant's part tree: bursts, standalone deliverables, and prose
1066
1091
  * between them, under one live-context provider. */
1067
1092
  function TurnToolBlocks(props) {
1068
- const { turn, sessionId, permissions, onPermissionReply, disableToolNavigation, model, segments, conversationDensity, fold, durationMs, workNotice, } = props;
1093
+ const { turn, sessionId, permissions, onPermissionReply, disableToolNavigation, model, segments, conversationDensity, fold, durationMs, workNotice, runContent, runLabel, foldStartedWork, part, } = props;
1069
1094
  const { working, hasSteps, hasReasoning } = model;
1070
1095
  // Every settled turn folds, live or reloaded (the T3 Code rule): one turn
1071
1096
  // reads one way. A turn the reader touched while it worked (opened or closed
1072
1097
  // a row) settles with its "Worked for" row open, so nothing they were
1073
1098
  // reading disappears under them.
1074
- const split = useMemo(() => (fold && !working ? splitSessionLogTurnWork(segments.filter(segmentRendersSomething), { working }) : null), [fold, segments, working]);
1099
+ const split = useMemo(() => (fold && !working ? splitSessionLogTurnWork(segments.filter(segmentRendersSomething), { working, foldStartedWork }) : null), [fold, segments, working, foldStartedWork]);
1075
1100
  // A settled turn whose prompt is another agent's notice folds the notice
1076
1101
  // row into this work fold with the work it led to (KRTX-4732): the parent's
1077
1102
  // answer below is the only top-level message, and the row stays reachable
@@ -1079,7 +1104,13 @@ function TurnToolBlocks(props) {
1079
1104
  // so the exchange never becomes unreachable. In the inline mode (text plus
1080
1105
  // an answered question, no fold row) the row renders visible above the
1081
1106
  // answer instead — the gate below keeps the block mounted for it.
1082
- const noticeFold = !!workNotice && fold && !working;
1107
+ // The run's other turns fold here too (KRTX-4732); while the turn still works, the run's
1108
+ // row already stands, closed, over the reports that came before.
1109
+ const noticeFold = (!!workNotice || !!runContent) && fold && !working;
1110
+ // A turn whose only work started agents has no steps, but its agent rows are what the
1111
+ // person tracks: they draw (and fold once every agent reported, `foldStartedWork`).
1112
+ const startedWork = useMemo(() => segments.some((segment) => segment.kind === 'standalone' && toolKind(segment.block.name) === 'task'), [segments]);
1113
+ const foldRow = !part && (!!split || noticeFold || (!!runContent && working));
1083
1114
  const workSegments = useMemo(() => new Set(split?.work ?? []), [split]);
1084
1115
  const touchedLive = useRef(false);
1085
1116
  const markTouched = useCallback(() => {
@@ -1128,21 +1159,25 @@ function TurnToolBlocks(props) {
1128
1159
  return null;
1129
1160
  return (_jsx(TurnSegment, { segment: segment, isTrailing: segment === segments[segments.length - 1], working: working, openText: model.openText, hasSteps: hasSteps, sessionId: sessionId, permissions: permissions, onPermissionReply: onPermissionReply, disableNavigation: disableToolNavigation, conversationDensity: conversationDensity }, key));
1130
1161
  };
1131
- return (_jsx(_Fragment, { children: (working || hasSteps || hasReasoning || noticeFold || !!workNotice) && (turn.assistant.length > 0 || !!workNotice) && (
1162
+ return (_jsx(_Fragment, { children: (working || hasSteps || hasReasoning || startedWork || noticeFold || !!workNotice || !!runContent) && (turn.assistant.length > 0 || !!workNotice || !!runContent) && (
1132
1163
  // Every tool row below — the bursts' rows and the standalone ones —
1133
1164
  // reads this to tell a call that has not spoken YET from one that never
1134
1165
  // will. Provided here rather than per-row because `working` is a fact
1135
1166
  // about the TURN, and this block is the turn's whole part tree.
1136
1167
  // See `TurnLiveContext`.
1137
- _jsx(TurnLiveContext.Provider, { value: working, children: _jsx(RecoveredCallsContext.Provider, { value: recovered, children: _jsx(ImageGenPathsContext.Provider, { value: imageGenPaths, children: _jsx(ImageGenDigestsContext.Provider, { value: imageGenDigests, children: _jsx(ImageGenRunsContext.Provider, { value: imageGenRuns, children: _jsx(InTranscriptTurnContext.Provider, { value: true, children: _jsx(WorkTouchContext.Provider, { value: markTouched, children: _jsxs("div", { className: "flex flex-col gap-3", onClickCapture: onClickCapture, children: [(split || noticeFold) && (_jsx(TurnWorkAccordion, { durationMs: durationMs, open: workOpen, onToggle: toggleWork, contentId: workContentId }, "turn-work")), workNotice && (!noticeFold || workMounted) && (_jsx("div", { id: workContentId, hidden: !!(split || noticeFold) && !workOpen, className: "min-w-0", children: _jsx(WorkFoldContext.Provider, { value: !working, children: workNotice }) }, "turn-notice")), segments.map((segment) => {
1168
+ _jsx(TurnLiveContext.Provider, { value: working, children: _jsx(RecoveredCallsContext.Provider, { value: recovered, children: _jsx(ImageGenPathsContext.Provider, { value: imageGenPaths, children: _jsx(ImageGenDigestsContext.Provider, { value: imageGenDigests, children: _jsx(ImageGenRunsContext.Provider, { value: imageGenRuns, children: _jsx(InTranscriptTurnContext.Provider, { value: true, children: _jsx(WorkTouchContext.Provider, { value: markTouched, children: _jsxs("div", { className: "flex flex-col gap-3", onClickCapture: onClickCapture, children: [foldRow && (_jsx(TurnWorkAccordion, { label: runLabel, durationMs: durationMs, open: workOpen, onToggle: toggleWork, contentId: workContentId }, "turn-work")), runContent && workMounted && (_jsx("div", { id: workContentId, hidden: !workOpen, "data-testid": "agent-run-fold", className: "flex min-w-0 flex-col gap-3", children: _jsx(WorkFoldContext.Provider, { value: true, children: runContent }) }, "turn-run")), workNotice && (!noticeFold || workMounted) && (_jsx("div", { id: runContent ? undefined : workContentId, hidden: !!(split || noticeFold) && !workOpen, className: "min-w-0", children: _jsx(WorkFoldContext.Provider, { value: !working, children: workNotice }) }, "turn-notice")), segments.map((segment) => {
1138
1169
  const isWork = workSegments.has(segment);
1139
- if (isWork && !workMounted)
1170
+ if (part === 'answer' && isWork)
1171
+ return null;
1172
+ if (part === 'work' && split && !isWork)
1173
+ return null;
1174
+ if (isWork && !workMounted && !part)
1140
1175
  return null;
1141
1176
  const node = renderSegment(segment);
1142
1177
  if (!node)
1143
1178
  return null;
1144
- const hidden = isWork && !workOpen;
1145
- return (_jsx("div", { id: !workNotice && isWork && segment === split?.work[0] ? workContentId : undefined, hidden: hidden, className: "min-w-0", children: _jsx(WorkFoldContext.Provider, { value: isWork, children: node }) }, node.key));
1179
+ const hidden = !part && isWork && !workOpen;
1180
+ return (_jsx("div", { id: !workNotice && !runContent && isWork && segment === split?.work[0] ? workContentId : undefined, hidden: hidden, className: "min-w-0", children: _jsx(WorkFoldContext.Provider, { value: isWork, children: node }) }, node.key));
1146
1181
  })] }) }) }) }) }) }) }) })) }));
1147
1182
  }
1148
1183
  /** One segment of the turn's steps section: a burst, a show group, a
@@ -1312,7 +1347,7 @@ function TurnFooter(props) {
1312
1347
  const { statusPhrase, statusElapsedLabel } = status;
1313
1348
  const { retryInfo, retryMessage, retrySecondsLeft } = retry;
1314
1349
  const { turnEndedAt, turnDurationMs, costInfo } = meta;
1315
- return (_jsxs(_Fragment, { children: [_jsx(TurnBusyRow, { ...props, working: working, turnError: turnError, tHardcodedUi: tHardcodedUi, hasText: model.response.trim() !== '' }), turnErrorRow.text && !turn.autoRetry?.continued && (
1350
+ return (_jsxs(_Fragment, { children: [_jsx(TurnBusyRow, { ...props, working: working, turnError: turnError, tHardcodedUi: tHardcodedUi, hasText: model.response.trim() !== '', openText: model.openText?.block.text }), turnErrorRow.text && !turn.autoRetry?.continued && (
1316
1351
  // A space's thread (messages only): one calm line with Retry; a stop has its own "Stopped" line.
1317
1352
  props.quietBusy ? (turnErrorRow.isAbort ? null : (_jsx(TurnFailedLine, { projectId: projectId, projectSessionId: projectSessionId, turn: turn, errorText: turnErrorRow.text }))) : (_jsx(TurnErrorDisplay, { errorText: turnErrorRow.text, errorDetails: turnErrorRowDetails, errorRaw: turnErrorRaw, isAbort: turnErrorRow.isAbort, modelOptions: modelOptions }))), turnErrorRow.text && !turnErrorRow.isAbort && !turn.autoRetry?.continued && !!turn.autoRetry?.retries && (_jsx(TurnAutoRetryNote, { count: turn.autoRetry.retries })), !working && !turn.autoRetry?.continued && (stoppedBy || errors.turnErrorIsAbort) && _jsx(TurnStoppedBy, { name: stoppedBy ?? undefined }), !working && _jsx(TurnOutcomes, { turnKey: turn.id }), !working && !props.hideActionBar && hasCopyableResponse(response, answered.inlineContentParts) && (_jsx(TurnActionBar, { response: response, inlineContentParts: answered.inlineContentParts, turnEndedAt: turnEndedAt, turnDurationMs: turnDurationMs, costInfo: costInfo, servedModel: servedModel, tHardcodedUi: tHardcodedUi,
1318
1353
  // A continuation turn's id names a compaction marker, not a user
@@ -1351,7 +1386,10 @@ function TurnBusyRow(props) {
1351
1386
  const tTurn = useTranslations('sessionUi.turn');
1352
1387
  // The thread's computer is not up yet: the wait is a start, not work.
1353
1388
  const runtimeReady = useRuntimeReady();
1354
- return (_jsx(_Fragment, { children: showTurnBusyIndicator({
1389
+ // The words streaming in are the busy signal: no "Gathering thoughts..." row
1390
+ // glued under them. It returns when the block closes or the text goes quiet.
1391
+ const answerStreaming = useAnswerStreaming(props.openText);
1392
+ return (_jsx(_Fragment, { children: !(answerStreaming && !quietBusy && !retryInfo) && showTurnBusyIndicator({
1355
1393
  working: working && !suppressBusyIndicator,
1356
1394
  hasError: !!turnError,
1357
1395
  isRetrying: !!retryInfo,
@@ -1440,16 +1478,18 @@ function SessionTurnImpl(props) {
1440
1478
  // parent's answer is the only top-level message. A settled turn with no
1441
1479
  // answer at all keeps the row at the top level, where it stays reachable;
1442
1480
  // the main transcript only — space threads hide notices already.
1481
+ const noticeRow = userContent.noticeBatch
1482
+ ? _jsx(NoticeBatchGroup, { items: userContent.noticeBatch })
1483
+ : userContent.subagentNotice
1484
+ ? _jsx(SubagentNoticeRow, { notice: userContent.subagentNotice })
1485
+ : userContent.peerMessage
1486
+ ? _jsx(PeerMessageRow, { info: userContent.peerMessage })
1487
+ : undefined;
1488
+ // A run's anchor folds its own notice too, answered or not: the run's row keeps it reachable.
1443
1489
  const workNotice = rows
1444
1490
  ? undefined
1445
- : isAgentNoticeTurn(turn) && (model.working || turn.assistant.length > 0)
1446
- ? userContent.noticeBatch
1447
- ? _jsx(NoticeBatchGroup, { items: userContent.noticeBatch })
1448
- : userContent.subagentNotice
1449
- ? _jsx(SubagentNoticeRow, { notice: userContent.subagentNotice })
1450
- : userContent.peerMessage
1451
- ? _jsx(PeerMessageRow, { info: userContent.peerMessage })
1452
- : undefined
1491
+ : isAgentNoticeTurn(turn) && (model.working || turn.assistant.length > 0 || !!props.agentRun)
1492
+ ? noticeRow
1453
1493
  : undefined;
1454
1494
  const status = useTurnLiveStatus({ turn, blocks: model.blocks, agentWorking: model.agentWorking });
1455
1495
  const retry = useTurnRetryState({ sessionStatus, isWorkingTurn });
@@ -1461,6 +1501,19 @@ function SessionTurnImpl(props) {
1461
1501
  permissions,
1462
1502
  sessionId,
1463
1503
  });
1504
+ // Inside an agent run, the agent's relays between colleagues (`send_message`) are noise:
1505
+ // the reports say what happened (KRTX-4732).
1506
+ const inRun = !!props.agentRun || !!props.runMember;
1507
+ const turnSegments = useMemo(() => (inRun ? withoutRelayCalls(segments) : segments), [inRun, segments]);
1508
+ const { runTurns, agentRun } = props;
1509
+ // The run's other turns, drawn by the anchor, each as a run member: its work in the fold,
1510
+ // its answer under the run row. Each member is a memoized row: a render of the anchor costs a
1511
+ // shallow prop compare per member.
1512
+ const runMembers = (part) => agentRun && runTurns?.length
1513
+ ? runTurns.map((member) => (_jsx(SessionTurn, { ...props, turn: member, runMember: part, agentRun: undefined, runTurns: undefined, foldStartedWork: false, isWorkingTurn: false, pending: false, pendingPrompt: undefined, interruptedBeforeRun: false, isFirstTurn: false, isLast: false, ownsPlan: false }, member.id)))
1514
+ : null;
1515
+ const runContent = runMembers('work');
1516
+ const runAnswers = runMembers('answer');
1464
1517
  // A compaction turn's message-state — `inFlight` (the marker still
1465
1518
  // streams its summary) is the half of "is this compaction running" the
1466
1519
  // working projection cannot see, because it deliberately knows nothing
@@ -1471,6 +1524,17 @@ function SessionTurnImpl(props) {
1471
1524
  const genuiModel = turn.assistant.at(-1)?.model?.model;
1472
1525
  const genuiScope = turn.id;
1473
1526
  const genuiTelemetry = useMemo(() => ({ scope: genuiScope, ...(genuiModel ? { model: genuiModel } : {}) }), [genuiScope, genuiModel]);
1527
+ // A run member (KRTX-4732): its report and the work it led to, in the anchor's fold...
1528
+ if (props.runMember === 'work') {
1529
+ return (_jsxs("div", { "data-testid": "agent-run-member", className: "flex min-w-0 flex-col gap-3", children: [noticeRow, _jsx(GenuiTelemetryContext.Provider, { value: genuiTelemetry, children: _jsx(TurnToolBlocks, { ...props, model: model, segments: turnSegments, conversationDensity: conversationDensity, fold: !answered.shouldUseInlineContent, durationMs: null, part: "work" }) })] }));
1530
+ }
1531
+ // ...and its answer, with its error or stop row and its outcomes, under the run row. A silent
1532
+ // report draws only the outcomes it left (a change request), which hide themselves when none.
1533
+ if (props.runMember === 'answer') {
1534
+ if (!turn.response && !turn.error && turn.status !== 'aborted')
1535
+ return _jsx(TurnOutcomes, { turnKey: turn.id });
1536
+ return (_jsxs("div", { "data-testid": "agent-run-answer", className: "space-y-2.5", children: [_jsxs(GenuiTelemetryContext.Provider, { value: genuiTelemetry, children: [_jsx(TurnToolBlocks, { ...props, model: model, segments: turnSegments, conversationDensity: conversationDensity, fold: !answered.shouldUseInlineContent, durationMs: null, part: "answer" }), _jsx(TurnAssistantBlock, { ...props, model: model, answered: answered, userContent: userContent, tHardcodedUi: tHardcodedUi })] }), _jsx(TurnFooter, { ...props, model: model, errors: errors, answered: answered, status: status, retry: retry, meta: meta, tHardcodedUi: tHardcodedUi, connectProviderOpen: connectProviderOpen, onConnectProviderOpenChange: setConnectProviderOpen })] }));
1537
+ }
1474
1538
  // Shell mode: a synthetic prompt answered by one bare `bash` call.
1475
1539
  if (turn.shell) {
1476
1540
  return (_jsx(TurnShellMode, { ...props, call: sessionLogOpenCall(turn.shell), working: model.working, errors: errors, connectProviderOpen: connectProviderOpen, onConnectProviderOpenChange: setConnectProviderOpen }));
@@ -1553,7 +1617,7 @@ function SessionTurnImpl(props) {
1553
1617
  // The segments are already the message's: nothing is left to fold.
1554
1618
  fold: !messagesOnly && !answered.shouldUseInlineContent, durationMs: meta.turnDurationMs })), _jsx(TurnAssistantBlock, { ...props, model: model, answered: answered, userContent: userContent, tHardcodedUi: tHardcodedUi })] }), messagesOnly && !model.working && errors.turnErrorIsAbort && model.response.trim() === '' && shownSegments.length === 0 ? (_jsx("p", { className: "text-muted-foreground text-sm", children: tTurnRows('stopped') })) : null, _jsx(TurnFooter, { ...props, hideActionBar: true, quietBusy: messagesOnly, model: model, errors: errors, answered: answered, status: status, retry: retry, meta: meta, tHardcodedUi: tHardcodedUi, connectProviderOpen: connectProviderOpen, onConnectProviderOpenChange: setConnectProviderOpen }), messagesOnly && !model.working ? (_jsx(TurnMessageWork, { ...props, model: model, segments: segments, shown: shownSegments, userContent: userContent, conversationDensity: conversationDensity, front: rows.front === true })) : null] }) })) : null] }));
1555
1619
  }
1556
- return (_jsxs("div", { className: "group/turn text-factor-[2] space-y-2.5", children: [_jsx(TurnUserBlock, { ...props, model: model, queueTone: queueTone, userContent: userContent, noticeInWork: !!workNotice }), props.isFirstTurn ? afterFirstPrompt : null, _jsx(TurnFallbackRows, { working: model.working, events: props.servedModel?.fallbacks }), _jsxs(GenuiTelemetryContext.Provider, { value: genuiTelemetry, children: [_jsx(TurnToolBlocks, { ...props, model: model, segments: segments, conversationDensity: conversationDensity, fold: !answered.shouldUseInlineContent, durationMs: meta.turnDurationMs, workNotice: workNotice }), _jsx(TurnAssistantBlock, { ...props, model: model, answered: answered, userContent: userContent, tHardcodedUi: tHardcodedUi })] }), _jsx(TurnFooter, { ...props, model: model, errors: errors, answered: answered, status: status, retry: retry, meta: meta, tHardcodedUi: tHardcodedUi, connectProviderOpen: connectProviderOpen, onConnectProviderOpenChange: setConnectProviderOpen })] }));
1620
+ return (_jsxs("div", { className: "group/turn text-factor-[2] space-y-2.5", children: [_jsx(TurnUserBlock, { ...props, model: model, queueTone: queueTone, userContent: userContent, noticeInWork: !!workNotice }), props.isFirstTurn ? afterFirstPrompt : null, _jsx(TurnFallbackRows, { working: model.working, events: props.servedModel?.fallbacks }), _jsxs(GenuiTelemetryContext.Provider, { value: genuiTelemetry, children: [_jsx(TurnToolBlocks, { ...props, model: model, segments: turnSegments, conversationDensity: conversationDensity, fold: !answered.shouldUseInlineContent, durationMs: meta.turnDurationMs, workNotice: workNotice, runContent: runContent, runLabel: agentRun ? sessionLogAgentRunLabel(agentRun) : undefined, foldStartedWork: props.foldStartedWork }), runAnswers, _jsx(TurnAssistantBlock, { ...props, model: model, answered: answered, userContent: userContent, tHardcodedUi: tHardcodedUi })] }), _jsx(TurnFooter, { ...props, model: model, errors: errors, answered: answered, status: status, retry: retry, meta: meta, tHardcodedUi: tHardcodedUi, connectProviderOpen: connectProviderOpen, onConnectProviderOpenChange: setConnectProviderOpen })] }));
1557
1621
  }
1558
1622
  /**
1559
1623
  * The boundary that stops the transcript re-rendering with the stream.
@@ -1,54 +1,5 @@
1
1
  import type { ToolProps } from '../shared/types.js';
2
- /**
3
- * The words a settled row leads with.
4
- *
5
- * The bash tool's input carries a `description` — the one-line summary the
6
- * model writes for its own call ("Install the workspace dependencies"). The
7
- * SDK already reads it as this tool's subtitle (`core/turns/parts.ts`, case
8
- * `'bash'`), so the row promotes a source it had been dropping rather than
9
- * inventing one. A reader scanning a turn wants to know what a command was
10
- * FOR, and `pnpm -w install --frozen-lockfile` answers that only if they read
11
- * shell.
12
- *
13
- * Three rules, in order:
14
- * - A failure keeps its verdict. "Command failed" is the one thing a friendly
15
- * summary must never soften, so it outranks any description.
16
- * - No description → exactly today's "Ran command". Nothing is ever derived
17
- * from the command text: a classifier answering "Installed dependencies" to
18
- * `npm i` would put a claim in the model's mouth that it never made.
19
- * - Sentence case only lifts a lower-case opener. Lowering the rest would turn
20
- * "Run CI on the release branch" into "Run ci on the release branch".
21
- */
22
- export declare function bashRowTitle(description: unknown, failed: boolean): string;
23
- /**
24
- * The command as the reader should see it: leading indent stripped, blank
25
- * edges dropped.
26
- *
27
- * Commands arrive with incidental leading whitespace — a model quoting a
28
- * command out of indented YAML/JSON sends ` agent-browser open …`. The
29
- * trigger row hides it (a `truncate` span collapses spaces under normal
30
- * white-space), but the card's `whitespace-pre-wrap` pane renders it verbatim,
31
- * so the first line sits two characters deeper than its own wrapped
32
- * continuation and the output below — an inverse hanging indent that reads as
33
- * broken padding.
34
- *
35
- * Two rules, because a one-line command and a script are different documents:
36
- *
37
- * - **One line has no structure to protect**, so every leading blank is noise
38
- * and all of it goes. This is the case a common-indent rule cannot be
39
- * trusted with alone: it only strips what it can MEASURE, and the measure
40
- * used to be `[ \t]` — so a command indented with a non-breaking space (or
41
- * any other Unicode space; agents paste these out of rendered docs and
42
- * spreadsheets) kept its indent and drew exactly the misalignment above.
43
- * - **A script keeps its shape**: the COMMON indent goes, never a per-line
44
- * trim, so nesting survives. Heredocs survive by construction — a non-`<<-`
45
- * heredoc needs its terminator at column 0, which pins the common indent to
46
- * 0 and makes this a no-op exactly where indentation is load-bearing.
47
- *
48
- * `[^\S\r\n]` is "whitespace that is not a line break", so both rules count
49
- * every horizontal space character the Unicode table has, not just the two on
50
- * a US keyboard. The trailing trim also stops a final `\n` from counting as a
51
- * phantom `+1` line in the trigger.
52
- */
53
- export declare function dedentCommand(raw: string): string;
2
+ import { bashRowTitle, dedentCommand } from '../../../_vendor/shared/session/tool-row-text.js';
3
+ /** The row-title and dedent rules live once in `@kortix/shared/session/tool-row-text`. */
4
+ export { bashRowTitle, dedentCommand };
54
5
  export declare function BashTool({ call, defaultOpen, forceOpen, locked }: ToolProps): import("react").JSX.Element;