@kortix/ui 0.14.17 → 0.14.19

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 (116) hide show
  1. package/README.md +2 -2
  2. package/dist/_vendor/kortix-shared.js +38 -2
  3. package/dist/_vendor/shared/channel-descriptors.d.ts +20 -1
  4. package/dist/_vendor/shared/channel-message.d.ts +1 -1
  5. package/dist/_vendor/shared/my-kortix-agent.d.ts +1 -1
  6. package/dist/_vendor/shared/space-slug.d.ts +3 -4
  7. package/dist/_vendor/shared/utils/ambiguous-write.d.ts +3 -3
  8. package/dist/customize/agents/agent-instructions.d.ts +8 -0
  9. package/dist/customize/agents/agent-instructions.js +38 -12
  10. package/dist/customize/agents/agent-overview.d.ts +6 -3
  11. package/dist/customize/agents/agent-overview.js +8 -2
  12. package/dist/customize/agents/agent-page-chrome.d.ts +45 -27
  13. package/dist/customize/agents/agent-page-chrome.js +60 -37
  14. package/dist/customize/agents/agent-page.js +88 -99
  15. package/dist/customize/agents/agent-tabs.d.ts +15 -14
  16. package/dist/customize/agents/agent-tabs.js +19 -16
  17. package/dist/customize/agents/agents-page.js +8 -6
  18. package/dist/customize/connectors/detail/account-info.js +1 -1
  19. package/dist/customize/project-settings/project-admin-sections.d.ts +6 -2
  20. package/dist/customize/project-settings/project-admin-sections.js +5 -3
  21. package/dist/customize/project-settings/project-settings-sections.js +1 -1
  22. package/dist/customize/sections/component/channel-access-panel.js +16 -0
  23. package/dist/customize/sections/component/channel-mocks.d.ts +5 -0
  24. package/dist/customize/sections/component/channel-mocks.js +14 -2
  25. package/dist/customize/sections/component/discord-channel-row.d.ts +6 -0
  26. package/dist/customize/sections/component/discord-channel-row.js +48 -0
  27. package/dist/customize/sections/gateway-access-tab.js +1 -1
  28. package/dist/customize/sections/view/channels-view.js +18 -1
  29. package/dist/customize/sections/view/git-view.js +2 -2
  30. package/dist/customize/sections/view/secret-delivery.js +1 -1
  31. package/dist/customize/sections/view/secrets-view.js +1 -1
  32. package/dist/customize/settings/rail.js +2 -2
  33. package/dist/customize/settings/tabs/experimental-tab.d.ts +2 -2
  34. package/dist/customize/settings/tabs/experimental-tab.js +2 -2
  35. package/dist/customize/settings/tabs/general-tab.js +5 -4
  36. package/dist/customize/shared/capability-library.js +19 -22
  37. package/dist/customize/shared/customize-tab-bar.d.ts +1 -2
  38. package/dist/customize/shared/customize-tab-bar.js +10 -11
  39. package/dist/files/project/components/drive-create-dialog.js +3 -3
  40. package/dist/i18n/en.d.ts +51 -4
  41. package/dist/i18n/en.js +66 -19
  42. package/dist/i18n/ui-catalog/remaining-ui-translation-keys.generated.js +1 -1
  43. package/dist/internal/branding/branding-provider.d.ts +15 -4
  44. package/dist/internal/branding/branding-provider.js +12 -7
  45. package/dist/internal/connector-logo/connector-logo.js +2 -0
  46. package/dist/internal/connector-logo/connector-mark-files.js +1 -0
  47. package/dist/internal/hooks/channels/use-channels-installations.d.ts +7 -2
  48. package/dist/internal/hooks/channels/use-channels-installations.js +31 -1
  49. package/dist/internal/hooks/projects/use-new-project-session.d.ts +6 -14
  50. package/dist/internal/hooks/projects/use-new-project-session.js +12 -97
  51. package/dist/internal/hooks/use-notification-center.d.ts +11 -8
  52. package/dist/internal/hooks/use-notification-center.js +22 -10
  53. package/dist/internal/icons/discord.d.ts +9 -0
  54. package/dist/internal/icons/discord.js +9 -0
  55. package/dist/internal/layout/connect-mcp-modal.js +1 -1
  56. package/dist/internal/lib/browser-noise/rules/expected-states.js +1 -1
  57. package/dist/internal/lib/error-handler.js +1 -1
  58. package/dist/internal/lib/use-project-feature-flags.js +5 -3
  59. package/dist/markdown/markdown-frontmatter.d.ts +0 -3
  60. package/dist/markdown/markdown-frontmatter.js +45 -5
  61. package/dist/session/actions/project-session-list-helpers.d.ts +4 -14
  62. package/dist/session/actions/project-session-list-helpers.js +5 -16
  63. package/dist/session/actions/session-label.d.ts +5 -9
  64. package/dist/session/actions/session-label.js +6 -10
  65. package/dist/session/participants/session-participants.d.ts +7 -5
  66. package/dist/session/participants/session-participants.js +11 -7
  67. package/dist/session/status/provisioning-failure.d.ts +4 -5
  68. package/dist/session/status/provisioning-failure.js +4 -5
  69. package/dist/session/thread/optimistic-turn.js +11 -2
  70. package/dist/session/thread/session-chat.js +73 -25
  71. package/dist/session/thread/transcript.d.ts +9 -0
  72. package/dist/session/thread/transcript.js +44 -5
  73. package/dist/session/tool/tools/channel-send-card.js +1 -0
  74. package/dist/session/turn/channel-brand.js +4 -0
  75. package/dist/session/turn/message-author.d.ts +13 -8
  76. package/dist/session/turn/message-author.js +34 -16
  77. package/dist/session/turn/peer-message-row.js +24 -6
  78. package/dist/session/turn/user-message.js +1 -1
  79. package/dist/session/voice/call-audio.d.ts +32 -0
  80. package/dist/session/voice/call-audio.js +146 -0
  81. package/dist/session/voice/screen-share.d.ts +24 -0
  82. package/dist/session/voice/screen-share.js +75 -0
  83. package/dist/session/voice/use-voice-call.d.ts +15 -0
  84. package/dist/session/voice/use-voice-call.js +220 -0
  85. package/dist/session/voice/voice-call-bar.d.ts +4 -0
  86. package/dist/session/voice/voice-call-bar.js +39 -0
  87. package/dist/session/voice/voice-call-state.d.ts +96 -0
  88. package/dist/session/voice/voice-call-state.js +103 -0
  89. package/dist/session/voice/voice-call-store.d.ts +12 -0
  90. package/dist/session/voice/voice-call-store.js +10 -0
  91. package/dist/session/voice/voice-call-url.d.ts +24 -0
  92. package/dist/session/voice/voice-call-url.js +33 -0
  93. package/dist/session/voice/voice-call.d.ts +15 -0
  94. package/dist/session/voice/voice-call.js +54 -0
  95. package/dist/styles.css +1 -1
  96. package/dist/workspace/admin/project-admin-dashboard.js +9 -4
  97. package/dist/workspace/layout/project-home.js +13 -14
  98. package/dist/workspace/sidebar/footer/project-manifest-issues-alert.d.ts +1 -1
  99. package/dist/workspace/sidebar/footer/project-manifest-issues-alert.js +4 -3
  100. package/dist/workspace/sidebar/project-session-list.js +1 -0
  101. package/dist/workspace/sidebar/session-filter-menu.js +1 -0
  102. package/dist/workspace/sidebar/session-grouping.d.ts +4 -0
  103. package/dist/workspace/sidebar/session-grouping.js +2 -0
  104. package/dist/workspace/sidebar/session-source-icons.js +2 -0
  105. package/dist/workspace/space/space-page.js +2 -2
  106. package/package.json +9 -9
  107. package/skills/kortix-ui/SKILL.md +2 -2
  108. package/skills/kortix-ui/references/custom-dashboard.md +1 -1
  109. package/dist/customize/agents/agent-section-rail.d.ts +0 -21
  110. package/dist/customize/agents/agent-section-rail.js +0 -23
  111. package/dist/internal/hooks/projects/use-warm-project-session.d.ts +0 -270
  112. package/dist/internal/hooks/projects/use-warm-project-session.js +0 -362
  113. package/dist/internal/hooks/projects/warm-session-seed.d.ts +0 -66
  114. package/dist/internal/hooks/projects/warm-session-seed.js +0 -80
  115. package/dist/internal/hooks/projects/warm-session-taken-registry.d.ts +0 -61
  116. package/dist/internal/hooks/projects/warm-session-taken-registry.js +0 -141
@@ -11,13 +11,15 @@ type AvatarPerson = Pick<SessionParticipant, 'name' | 'email'> & {
11
11
  */
12
12
  export declare function participantLabel(person: AvatarPerson): string;
13
13
  /**
14
- * A message in a shared session: its member author's avatar above the
15
- * bubble, on the right edge, your own included. A message with no recorded
16
- * author, or any message in a single-user session, renders alone. The author
17
- * comes from `.../message-authors`.
14
+ * A member's message: its author's avatar above the bubble, on the right
15
+ * edge, your own included, in every session. A message with no recorded
16
+ * author renders alone. `reserve` keeps the avatar's space empty while the
17
+ * author loads, so the bubble does not move when it arrives. The author comes
18
+ * from `.../message-authors`.
18
19
  */
19
- export declare function MessageSenderAbove({ sender, children, }: {
20
+ export declare function MessageSenderAbove({ sender, reserve, children, }: {
20
21
  sender: AvatarPerson | null | undefined;
22
+ reserve?: boolean;
21
23
  children: ReactNode;
22
24
  }): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
23
25
  /** Who can open the session beyond the listed rows: the route lists 20, `total` counts everyone. */
@@ -24,15 +24,19 @@ function ParticipantAvatar({ person, size }) {
24
24
  return (_jsx(UserAvatar, { size: size, name: person.name, email: person.email ?? '', avatarUrl: person.avatar_url ?? null }));
25
25
  }
26
26
  /**
27
- * A message in a shared session: its member author's avatar above the
28
- * bubble, on the right edge, your own included. A message with no recorded
29
- * author, or any message in a single-user session, renders alone. The author
30
- * comes from `.../message-authors`.
27
+ * A member's message: its author's avatar above the bubble, on the right
28
+ * edge, your own included, in every session. A message with no recorded
29
+ * author renders alone. `reserve` keeps the avatar's space empty while the
30
+ * author loads, so the bubble does not move when it arrives. The author comes
31
+ * from `.../message-authors`.
31
32
  */
32
- export function MessageSenderAbove({ sender, children, }) {
33
+ export function MessageSenderAbove({ sender, reserve = false, children, }) {
33
34
  const t = useTranslations('sessionParticipants');
34
- if (!sender)
35
- return children;
35
+ if (!sender) {
36
+ if (!reserve)
37
+ return children;
38
+ return (_jsxs("div", { className: "flex max-w-full flex-col items-end gap-1.5", children: [_jsx("span", { "aria-hidden": true, className: "size-6 shrink-0" }), _jsx("div", { className: "flex max-w-full min-w-0", children: children })] }));
39
+ }
36
40
  const name = participantLabel(sender);
37
41
  return (_jsxs("div", { className: "flex max-w-full flex-col items-end gap-1.5", children: [_jsx("span", { className: "sr-only", children: t('sentBy', { name }) }), _jsx(Hint, { label: sender.email ?? name, side: "top", delayDuration: 300, children: _jsx("span", { "aria-hidden": true, className: "flex shrink-0", children: _jsx(ParticipantAvatar, { person: sender, size: "sm" }) }) }), _jsx("div", { className: "flex max-w-full min-w-0", children: children })] }));
38
42
  }
@@ -24,11 +24,10 @@ export interface RecoveryPrompt extends PendingSessionPrompt {
24
24
  * The recovery copy, from the server when it has one and from this tab's start
25
25
  * stash otherwise. Never consumes either.
26
26
  *
27
- * `metadata.pending_prompt` is written by the session CREATE, so it exists only
28
- * when the send created the session. A send that reused a WARM session created
29
- * nothing, so its prompt lives only in the start stash the composer wrote before
30
- * navigating. Reading both is what keeps the failure card's "copy your prompt"
31
- * and Retry working identically on either path.
27
+ * `metadata.pending_prompt` is written by the session CREATE. The start stash
28
+ * the composer wrote before navigating is the fallback while that row is not
29
+ * read yet. Reading both keeps the failure card's "copy your prompt" and Retry
30
+ * working before and after the session row loads.
32
31
  *
33
32
  * A session that an agent, a trigger, a channel, MCP or a marketplace install
34
33
  * created has neither: its first prompt is `metadata.initial_prompt`. That
@@ -74,11 +74,10 @@ export function pendingSessionPromptFromMetadata(metadata) {
74
74
  * The recovery copy, from the server when it has one and from this tab's start
75
75
  * stash otherwise. Never consumes either.
76
76
  *
77
- * `metadata.pending_prompt` is written by the session CREATE, so it exists only
78
- * when the send created the session. A send that reused a WARM session created
79
- * nothing, so its prompt lives only in the start stash the composer wrote before
80
- * navigating. Reading both is what keeps the failure card's "copy your prompt"
81
- * and Retry working identically on either path.
77
+ * `metadata.pending_prompt` is written by the session CREATE. The start stash
78
+ * the composer wrote before navigating is the fallback while that row is not
79
+ * read yet. Reading both keeps the failure card's "copy your prompt" and Retry
80
+ * working before and after the session row loads.
82
81
  *
83
82
  * A session that an agent, a trigger, a channel, MCP or a marketplace install
84
83
  * created has neither: its first prompt is `metadata.initial_prompt`. That
@@ -12,7 +12,9 @@ import { useProjectSessionHref } from '../../internal/lib/navigation/session-hre
12
12
  import { cn } from '../../lib/utils.js';
13
13
  import { getFilename } from '../../internal/lib/utils/file-utils.js';
14
14
  import { openTabAndNavigate } from '../../internal/stores/tab-store.js';
15
- import { useUiShallowNavigate } from '../../providers/ui-provider.js';
15
+ import { useUiShallowNavigate, useUiViewer } from '../../providers/ui-provider.js';
16
+ import { MessageSenderAbove } from '../participants/session-participants.js';
17
+ import { viewerAuthor } from '../turn/message-author.js';
16
18
  // `BUBBLE_SURFACE` / `BUBBLE_TEXT` are imported from `turn/user-message.tsx`,
17
19
  // not redeclared here. A local copy drifted twice already — first the dark
18
20
  // fill (`dark:bg-sidebar-accent-foreground/9` vs `dark:bg-muted`, fixed), then
@@ -129,7 +131,14 @@ function OptimisticUserBubble({ text, agentNames, onFileClick, deferPreview, sta
129
131
  }));
130
132
  return [...pastes.map(pastedAttachment), ...fromText, ...fromStaged];
131
133
  }, [pastes, files, deferPreview, staged]);
132
- return (_jsxs("div", { className: "ml-auto flex w-full max-w-[80%] flex-col items-end gap-2 self-end", children: [attachments.length > 0 && (_jsx(MessageAttachments, { attachments: attachments, status: uploadStatus })), (cleanText || quotedPieces) && (_jsx("div", { className: cn(BUBBLE_SURFACE, 'w-fit overflow-hidden'), children: quotedPieces ? (_jsx(QuotedMessageBody, { pieces: quotedPieces, renderText: (runText) => (_jsx(HighlightMentions, { text: runText, sessions: sessions, agentNames: agentNames, onFileClick: onFileClick })) })) : (_jsx("p", { className: BUBBLE_TEXT, children: _jsx(HighlightMentions, { text: cleanText, sessions: sessions, agentNames: agentNames, onFileClick: onFileClick }) })) })), _jsx(UserMessageActions, { timestamp: null, copyText: expandPastedContent(text), deliveryStatus: deliveryStatus })] }));
134
+ // This tab sent the prompt: the viewer's avatar sits above it, as on the
135
+ // server turn that replaces it (`MessageSenderAbove`).
136
+ const viewer = useUiViewer();
137
+ const sender = useMemo(() => {
138
+ const author = viewerAuthor(viewer);
139
+ return author?.kind === 'member' ? author : null;
140
+ }, [viewer]);
141
+ return (_jsxs("div", { className: "ml-auto flex w-full max-w-[80%] flex-col items-end gap-2 self-end", children: [attachments.length > 0 && (_jsx(MessageAttachments, { attachments: attachments, status: uploadStatus })), (cleanText || quotedPieces) && (_jsx(MessageSenderAbove, { sender: sender, reserve: true, children: _jsx("div", { className: cn(BUBBLE_SURFACE, 'w-fit overflow-hidden rounded-tr-[calc(var(--radius)-6px)]'), children: quotedPieces ? (_jsx(QuotedMessageBody, { pieces: quotedPieces, renderText: (runText) => (_jsx(HighlightMentions, { text: runText, sessions: sessions, agentNames: agentNames, onFileClick: onFileClick })) })) : (_jsx("p", { className: BUBBLE_TEXT, children: _jsx(HighlightMentions, { text: cleanText, sessions: sessions, agentNames: agentNames, onFileClick: onFileClick }) })) }) })), _jsx(UserMessageActions, { timestamp: null, copyText: expandPastedContent(text), deliveryStatus: deliveryStatus })] }));
133
142
  }
134
143
  /**
135
144
  * Highlight @mentions in plain text (for optimistic & user messages).
@@ -10,16 +10,16 @@ import { useTranslations } from '../../i18n/index.js';
10
10
  import { errorMessageOf, isDeliveredButDisconnected } from '../../internal/lib/delivered-but-disconnected.js';
11
11
  import { useQueuedDraftStore, useQueuedDrafts } from '../composer/stores/queued-draft-store.js';
12
12
  import { SESSION_LOG_MINOR, SESSION_LOG_SCHEMA, listSessionPrompts, sessionLogOfV1Rows, sessionLogPromptMessage, sessionLogRetrying, sessionLogTurns, fetchSessionAttachment, sessionLogFullTextPlan, sessionLogHarnessSwitches, sessionLogRestoreNotice, sessionLogWithFullTexts, } from '@kortix/sdk';
13
- import { useProjectSession, useSessionLogOlder, useSessionLogRecord, useSessionLogThread, useSessionMessageAuthors, useSessionModelUsage, useSessionParticipants, } from '@kortix/sdk/react';
13
+ import { useProjectSession, useSessionLogOlder, useSessionLogRecord, useSessionLogThread, useSessionMessageAuthors, useSessionParticipants, useSessionModelUsage, } from '@kortix/sdk/react';
14
14
  import { ArrowBendUpLeftIcon, CaretDownIcon, StackIcon as Layers, } from '@phosphor-icons/react';
15
15
  import { jumpToOutcome } from '../outcomes/jump-to-outcome.js';
16
16
  import { useIsMobile, useIsPhone } from '../../hooks/use-mobile.js';
17
- import { useUiLink, useUiPathname, useUiRouter, useUiShallowNavigate, useUiSearchParams, useUiViewerId, } from '../../providers/ui-provider.js';
17
+ import { useUiLink, useUiPathname, useUiRouter, useUiShallowNavigate, useUiSearchParams, useUiViewer, useUiViewerId, } from '../../providers/ui-provider.js';
18
18
  import { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
19
19
  import { TranscriptRowsContext } from './transcript-rows.js';
20
20
  import { AgentBusyRow, PendingPromptRows } from './thread-boot-rows.js';
21
21
  import { createPortal } from 'react-dom';
22
- import { AUTHOR_RETRY_DELAYS_MS, authorForTurn, awaitsAgent, missingAuthorKey, resolveTranscriptAuthors, rewindableMessageIds, showAuthorName, stoppedByName, } from '../turn/message-author.js';
22
+ import { AUTHOR_RETRY_DELAYS_MS, authorForTurn, awaitsAgent, missingAuthorKey, participantAuthor, resolveTranscriptAuthors, rewindableMessageIds, stoppedByName, viewerAuthor, } from '../turn/message-author.js';
23
23
  import { stopRefusalMessage } from '../status/stop-refusal.js';
24
24
  import { QueuedPromptList } from '../composer/queued-prompt-list.js';
25
25
  import { runtimePermissionLocksComposer } from '../composer/send-blockers.js';
@@ -48,6 +48,7 @@ import { sessionSlashFiles } from '../composer/menus/slash-files.js';
48
48
  import { resolveFirstPromptHandover, transcriptCarriesFirstPrompt, } from './first-prompt-handover.js';
49
49
  import { CompactModal } from '../header/compact-modal.js';
50
50
  import { SessionSiteHeader } from '../header/session-site-header.js';
51
+ import { VoiceCallSlot } from '../voice/voice-call.js';
51
52
  import { claimFirstTurnRow } from '../composer/inbox-row-claims.js';
52
53
  import { OptimisticTurn } from './optimistic-turn.js';
53
54
  import { inboxHoldsLivePrompt } from '../composer/inbox-live-prompt.js';
@@ -106,7 +107,7 @@ import { HELD_COMMAND_ROW_PREFIX, canReleaseHeldCommand, heldCommandRows, } from
106
107
  import { useSessionHistoryViewStore } from '../../internal/stores/session-history-view-store.js';
107
108
  import { downloadBlob } from '../../internal/lib/utils/download.js';
108
109
  import { RestoreNotice, hasOutOfContext } from './session-history.js';
109
- import { TranscriptTurnRow, strandedPromptIds, optimisticAnswersCache, promptTexts, resolveTurnError, } from './transcript.js';
110
+ import { TranscriptTurnRow, isAgentNoticeTurn, strandedPromptIds, optimisticAnswersCache, promptTexts, resolveTurnError, } from './transcript.js';
110
111
  export { SessionReportCard, deriveTurnErrorAbortState, deriveTurnErrorPresentation } from './transcript.js';
111
112
  // ============================================================================
112
113
  // Sub-Session Breadcrumb
@@ -412,8 +413,15 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
412
413
  threadRef.current = thread;
413
414
  }, [thread]);
414
415
  const messagesLoading = syncMessagesLoading;
415
- // Who wrote each user message. A one-person session stays unlabelled.
416
+ // Who wrote each user message: every member message shows its sender's
417
+ // avatar from the first frame, one-person session included, so nothing
418
+ // moves when a second person joins.
416
419
  const viewerId = useUiViewerId();
420
+ const viewer = useUiViewer();
421
+ const viewerAsAuthor = useMemo(() => viewerAuthor(viewer), [viewer]);
422
+ // Wire ids this tab sent. Their recorded author arrives a moment after the
423
+ // bubble paints, so the viewer's avatar stands in until then.
424
+ const sentHereIds = useRef(new Set());
417
425
  const Link = useUiLink();
418
426
  // Only a user message adds an author, so only user messages key the refetch.
419
427
  const userMessageIds = useMemo(() => (messages ?? []).filter((m) => m.role === 'user').map((m) => m.message_id), [messages]);
@@ -422,12 +430,18 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
422
430
  const turnOutcome = useSessionTurnOutcome(projectId ?? '', projectSessionId ?? '');
423
431
  // A stop adds no message but does add a name ("Stopped by"): the turn that
424
432
  // ended keys the read too, so the stopper shows when that turn ends.
425
- const { data: messageAuthors, refetch: refetchMessageAuthors } = useSessionMessageAuthors(projectId, projectSessionId, `${newestUserMessageId}|${turnOutcome.last_ended?.turn_token ?? ''}`);
433
+ const { data: messageAuthors, isLoading: messageAuthorsLoading, refetch: refetchMessageAuthors, } = useSessionMessageAuthors(projectId, projectSessionId, `${newestUserMessageId}|${turnOutcome.last_ended?.turn_token ?? ''}`);
426
434
  const transcriptAuthors = useMemo(() => resolveTranscriptAuthors(userMessageIds, messageAuthors), [userMessageIds, messageAuthors]);
427
- // A session two or more people can open reads as a group chat from its first
428
- // prompt: every author shows, the viewer included. Same cache as the header.
435
+ // The user messages on screen when this session's first authors read
436
+ // landed. A message after them arrived live: the drain may re-mint its id
437
+ // and the ledger records it a moment later, so its avatar slot is held.
438
+ const [loadedUserIds, setLoadedUserIds] = useState(null);
439
+ if (messageAuthors && loadedUserIds?.sessionId !== sessionId) {
440
+ setLoadedUserIds({ sessionId, ids: new Set(userMessageIds) });
441
+ }
442
+ // Names a queued prompt's sender before the authors read lists it. Same
443
+ // cache as the header.
429
444
  const { data: sessionParticipants } = useSessionParticipants(projectId, projectSessionId);
430
- const groupChat = transcriptAuthors.multiAuthor || !!sessionParticipants?.multi_user;
431
445
  // Project sessions use the server-side project agent roster. A sub-agent's
432
446
  // chat has no projectId, but runs inside the parent scope's project: its
433
447
  // roster is that project's. Only a chat with neither falls back to the
@@ -460,14 +474,19 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
460
474
  ...promptInbox.prompts.flatMap((prompt) => [prompt.message_id, prompt.wire_message_id ?? '']),
461
475
  ]);
462
476
  const authorRetry = useRef({ key: '', count: 0 });
477
+ // The missing set the retries gave up on: a live message still unattributed
478
+ // then stops holding its avatar slot.
479
+ const [authorsGaveUp, setAuthorsGaveUp] = useState('');
463
480
  useEffect(() => {
464
481
  if (!missingAuthors)
465
482
  return;
466
483
  if (authorRetry.current.key !== missingAuthors)
467
484
  authorRetry.current = { key: missingAuthors, count: 0 };
468
485
  const delay = AUTHOR_RETRY_DELAYS_MS[authorRetry.current.count];
469
- if (delay === undefined)
486
+ if (delay === undefined) {
487
+ setAuthorsGaveUp(missingAuthors);
470
488
  return;
489
+ }
471
490
  const timer = setTimeout(() => {
472
491
  authorRetry.current.count += 1;
473
492
  void refetchMessageAuthors();
@@ -1867,6 +1886,9 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
1867
1886
  * 1.5k "two children with the same key" errors in one churn). The origin
1868
1887
  * key goes to the FIRST claimant; any other turn falls back to its own id.
1869
1888
  */
1889
+ // Turns whose prompt is another agent's notice: the work continues across
1890
+ // them, so they sit a continuation's distance below the turn above.
1891
+ const agentNoticeTurnIds = useMemo(() => new Set(turns.filter((turn) => isAgentNoticeTurn(turn)).map((turn) => turn.id)), [turns]);
1870
1892
  const turnRenderKeys = useMemo(() => {
1871
1893
  const keys = new Map();
1872
1894
  const used = new Set();
@@ -2182,6 +2204,7 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
2182
2204
  const clientMessageId = overrides?.clientMessageId ?? ascendingId('msg');
2183
2205
  const sentAtMs = Date.now();
2184
2206
  const messageID = mintSessionWireMessageId(sessionId, clientMessageId);
2207
+ sentHereIds.current.add(messageID);
2185
2208
  // Generate part IDs upfront so the optimistic message and the server
2186
2209
  // request use the SAME IDs. When the server echoes parts via
2187
2210
  // message.part.updated, the sync store's upsertPart will UPDATE
@@ -3297,17 +3320,19 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
3297
3320
  const agentsLineCompact = !!transcriptRows && !isPhone;
3298
3321
  const chatUnderbarSlot = useMemo(() => _jsx(AgentsLine, { projectId: projectId, sessionId: projectSessionId, compact: agentsLineCompact }), [projectId, projectSessionId, agentsLineCompact]);
3299
3322
  // The queued messages and the one Resume while a Stop holds the queue: their
3300
- // own full-width card above the composer stack, not inside the strip.
3301
- const chatAboveSlot = useMemo(() => (_jsx(QueuedPromptList, { rows: heldCommands.length > 0 ? [...queueRows.rows, ...heldCommandRows(heldCommands)] : queueRows.rows, heldCount: queueRows.heldCount, resumePending: resumePending, onResume: () => void handleResumeQueue(), onEdit: (id) => {
3302
- queueEdit.takeBack(id);
3303
- }, onRemove: (id) => {
3304
- if (id.startsWith(HELD_COMMAND_ROW_PREFIX)) {
3305
- const heldId = id.slice(HELD_COMMAND_ROW_PREFIX.length);
3306
- setHeldCommands((held) => held.filter((entry) => entry.id !== heldId));
3307
- return;
3308
- }
3309
- void handleRemoveQueuedMessage(id);
3310
- }, onRetry: handleRetryQueuedMessage, onStopAndSend: effectiveBusy && canStop ? handleStopAndSendQueuedMessage : undefined, editing: queueEdit.editing, onCancelEdit: queueEdit.cancel })), [
3323
+ // own full-width card above the composer stack, not inside the strip. A live
3324
+ // voice call is the card above them (nothing unless a call is open).
3325
+ const chatAboveSlot = useMemo(() => (_jsxs(_Fragment, { children: [_jsx(VoiceCallSlot, { sessionId: projectSessionId }), _jsx(QueuedPromptList, { rows: heldCommands.length > 0 ? [...queueRows.rows, ...heldCommandRows(heldCommands)] : queueRows.rows, heldCount: queueRows.heldCount, resumePending: resumePending, onResume: () => void handleResumeQueue(), onEdit: (id) => {
3326
+ queueEdit.takeBack(id);
3327
+ }, onRemove: (id) => {
3328
+ if (id.startsWith(HELD_COMMAND_ROW_PREFIX)) {
3329
+ const heldId = id.slice(HELD_COMMAND_ROW_PREFIX.length);
3330
+ setHeldCommands((held) => held.filter((entry) => entry.id !== heldId));
3331
+ return;
3332
+ }
3333
+ void handleRemoveQueuedMessage(id);
3334
+ }, onRetry: handleRetryQueuedMessage, onStopAndSend: effectiveBusy && canStop ? handleStopAndSendQueuedMessage : undefined, editing: queueEdit.editing, onCancelEdit: queueEdit.cancel })] })), [
3335
+ projectSessionId,
3311
3336
  heldCommands,
3312
3337
  queueEdit.editing,
3313
3338
  queueEdit.cancel,
@@ -3629,7 +3654,21 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
3629
3654
  : undefined;
3630
3655
  // A queued prompt is not in the runtime transcript yet;
3631
3656
  // its author still shows (`authorForTurn`).
3632
- const turnAuthor = authorForTurn(transcriptAuthors, messageAuthors, turn.id, pendingPrompt?.wire_message_id);
3657
+ const promptAuthorId = pendingPromptsByMessageId.get(turn.id)?.author_user_id;
3658
+ const turnAuthor = authorForTurn(transcriptAuthors, messageAuthors, turn.id, pendingPrompt?.wire_message_id) ??
3659
+ participantAuthor(sessionParticipants, promptAuthorId) ??
3660
+ (sentHereIds.current.has(turn.id) ||
3661
+ sentHereIds.current.has(turnRenderKeys.get(turn.id) ?? '') ||
3662
+ (viewerId !== undefined && promptAuthorId === viewerId) ||
3663
+ // The first prompt of a session the viewer started,
3664
+ // sent from another surface (project home), before
3665
+ // the first authors read lands.
3666
+ (messageAuthorsLoading &&
3667
+ viewerId !== undefined &&
3668
+ projectSessionRow?.created_by === viewerId &&
3669
+ turn.id === userMessageIds[0])
3670
+ ? viewerAsAuthor
3671
+ : undefined);
3633
3672
  return (_jsx(TranscriptTurnRow
3634
3673
  // ONE element per prompt: keyed by the id the
3635
3674
  // bubble was FIRST painted under, so the swap to a
@@ -3646,14 +3685,23 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
3646
3685
  // more — at most one is visible at a time.)
3647
3686
  viewportClassName: turnIndex === 0 || transcriptRows
3648
3687
  ? ''
3649
- : // A compaction and the work after it continue the turn above.
3650
- turn.compaction || turn.continues
3688
+ : // A compaction, the work after it and another agent's notice continue the turn above.
3689
+ turn.compaction || turn.continues || agentNoticeTurnIds.has(turn.id)
3651
3690
  ? 'mt-6'
3652
3691
  : lastTurnWorking &&
3653
3692
  pendingTurnIds.has(turn.id) &&
3654
3693
  pendingTurnIds.has(turns[turnIndex - 1].id)
3655
3694
  ? 'mt-3'
3656
- : 'mt-12', turn: turn, author: turnAuthor, showAuthor: showAuthorName(turnAuthor, groupChat, viewerId), 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,
3695
+ : 'mt-12', turn: turn, author: turnAuthor,
3696
+ // Reserve the sender row while the authors load,
3697
+ // for a queued prompt whose sender is known, and
3698
+ // for a live message until its author resolves.
3699
+ showAuthor: !!turnAuthor ||
3700
+ messageAuthorsLoading ||
3701
+ !!promptAuthorId ||
3702
+ (loadedUserIds?.sessionId === sessionId &&
3703
+ !loadedUserIds.ids.has(turn.id) &&
3704
+ authorsGaveUp !== missingAuthors), stoppedBy: stoppedByName(messageAuthors, turn.id, viewerId), servedModel: servedModelOfTurn(modelUsage, turn.id, turns[turnIndex - 1]?.id), turnOutcome: turnOutcome, isLast: turn.id === lastUserMessageId, ownsPlan: turn.id === planAnchorId, sessionId: sessionId, projectId: projectId, projectSessionId: projectSessionId, sessionStatus: sessionStatus, permissions: pendingPermissions, questions: pendingQuestions, agentNames: agentNames, isFirstTurn: turnIndex === 0,
3657
3705
  // Handed over only once the stand-in has stepped
3658
3706
  // aside — while it is up it draws these itself.
3659
3707
  pendingText: turnIndex === 0 ? firstTurnHandover?.text : undefined, pendingAttachments: sentAttachmentsForTurn({
@@ -3,6 +3,7 @@ import { type SessionLogBlock, type SessionLogMessage, type SessionLogTurn, type
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 NoticeBatchItem, type SubagentNotice } from '../turn/subagent-notice.js';
6
+ import { type PeerMessagePromptInfo } from '../../_vendor/shared/index.js';
6
7
  import { type SentAttachment } from '../composer/sent-attachment-previews.js';
7
8
  import { type KortixSystemMessage, type SessionReport } from '../../internal/lib/utils/kortix-system-tags.js';
8
9
  import { type Command, type PermissionRequest, type QuestionRequest } from '../../internal/session-types/index.js';
@@ -285,6 +286,13 @@ type PromptText = {
285
286
  * A user message's text as its v1 text parts held it: a text block, or an
286
287
  * `ignored` text (a model-invisible `harness` block whose data is the part).
287
288
  */
289
+ /**
290
+ * Whether a turn's prompt is a notice from another agent, not something a
291
+ * person wrote: a peer message (`send_message`), a subagent or teammate that
292
+ * finished, or a batch of those. The agent's work continues across it, so the
293
+ * thread spaces it like a continuation, not like a new prompt.
294
+ */
295
+ export declare function isAgentNoticeTurn(turn: Pick<SessionLogTurn, 'user'>): boolean;
288
296
  export declare function promptTexts(message: SessionLogMessage): PromptText[];
289
297
  /** The user side of the turn: the worker-run report, the system pills, the
290
298
  * bubble's visibility, and the command pill. */
@@ -292,6 +300,7 @@ declare function useTurnUserContent({ turn, commandMessages, commands, }: Pick<S
292
300
  sessionReport: SessionReport | null;
293
301
  noticeBatch: NoticeBatchItem[] | null;
294
302
  subagentNotice: SubagentNotice | null;
303
+ peerMessage: PeerMessagePromptInfo | null;
295
304
  systemMessages: KortixSystemMessage[];
296
305
  hasVisibleUserContent: boolean;
297
306
  userMessageText: string;
@@ -54,6 +54,8 @@ import { SubagentDialog } from '../agents/subagent-view.js';
54
54
  import { parseNoticeBatch, parseSubagentNotice } from '../turn/subagent-notice.js';
55
55
  import { SubagentNoticeRow } from '../turn/subagent-notice-row.js';
56
56
  import { NoticeBatchGroup } from '../turn/notice-batch-group.js';
57
+ import { PeerMessageRow } from '../turn/peer-message-row.js';
58
+ import { parsePeerMessagePrompt } from '../../_vendor/kortix-shared.js';
57
59
  import { ToolPartRenderer, TurnLiveContext } from '../tool/tool-renderers.js';
58
60
  import { ImageGenDigestsContext, ImageGenPathsContext, ImageGenRunsContext, InTranscriptTurnContext, RecoveredCallsContext, } from '../tool/shared/infrastructure.js';
59
61
  import { imageDigestsShownByImageGen, imagePathsShownByImageGen, sessionLogImageGenRuns, showDrawnByImageGen } from '@kortix/sdk';
@@ -589,6 +591,22 @@ function useAnsweredQuestionState({ turn, questions, sessionId, blocks, hasSteps
589
591
  * A user message's text as its v1 text parts held it: a text block, or an
590
592
  * `ignored` text (a model-invisible `harness` block whose data is the part).
591
593
  */
594
+ /**
595
+ * Whether a turn's prompt is a notice from another agent, not something a
596
+ * person wrote: a peer message (`send_message`), a subagent or teammate that
597
+ * finished, or a batch of those. The agent's work continues across it, so the
598
+ * thread spaces it like a continuation, not like a new prompt.
599
+ */
600
+ export function isAgentNoticeTurn(turn) {
601
+ // A stream delta remakes the turns, not the prompt: read each prompt once.
602
+ const known = agentNoticeOf.get(turn.user);
603
+ if (known !== undefined)
604
+ return known;
605
+ const notice = promptTexts(turn.user).some((t) => !!parsePeerMessagePrompt(t.text) || !!parseSubagentNotice(t.text) || (parseNoticeBatch(t.text)?.length ?? 0) > 1);
606
+ agentNoticeOf.set(turn.user, notice);
607
+ return notice;
608
+ }
609
+ const agentNoticeOf = new WeakMap();
592
610
  export function promptTexts(message) {
593
611
  return message.blocks.flatMap((b) => {
594
612
  if (b.type === 'text')
@@ -637,6 +655,21 @@ function useTurnUserContent({ turn, commandMessages, commands, }) {
637
655
  }
638
656
  return null;
639
657
  }, [texts, sessionReport, noticeBatch]);
658
+ // A message from another Kortix session (`send_message`). The API delivers it as
659
+ // harness context (`synthetic`), so the bubble, which draws only what a person
660
+ // typed, never shows it: its row is drawn here. A typed one stays the bubble's.
661
+ const peerMessage = useMemo(() => {
662
+ if (sessionReport || noticeBatch)
663
+ return null;
664
+ for (const t of texts) {
665
+ if (!t.synthetic)
666
+ continue;
667
+ const info = parsePeerMessagePrompt(t.text);
668
+ if (info)
669
+ return info;
670
+ }
671
+ return null;
672
+ }, [texts, sessionReport, noticeBatch]);
640
673
  // Extract kortix_system messages for inline rendering (goal continuations, etc.)
641
674
  const systemMessages = useMemo(() => {
642
675
  const msgs = [];
@@ -699,7 +732,7 @@ function useTurnUserContent({ turn, commandMessages, commands, }) {
699
732
  const source = Array.isArray(commands) ? commands.find((c) => c.name === commandForTurn.name)?.source : undefined;
700
733
  return source === 'skill' ? undefined : commandForTurn;
701
734
  }, [commandForTurn, commands]);
702
- return { sessionReport, noticeBatch, subagentNotice, systemMessages, hasVisibleUserContent, userMessageText, commandForTurn, commandOutput };
735
+ return { sessionReport, noticeBatch, subagentNotice, peerMessage, systemMessages, hasVisibleUserContent, userMessageText, commandForTurn, commandOutput };
703
736
  }
704
737
  /** The throttled working status of the working turn: one status change per
705
738
  * 2.5 s, keyed on the turn's parts. */
@@ -982,11 +1015,11 @@ function TurnSessionReport({ report }) {
982
1015
  * user bubble (hidden for notification-only turns). */
983
1016
  function TurnUserBlock(props) {
984
1017
  const { userContent } = props;
985
- const { sessionReport, noticeBatch, subagentNotice, systemMessages, hasVisibleUserContent } = userContent;
1018
+ const { sessionReport, noticeBatch, subagentNotice, peerMessage, systemMessages, hasVisibleUserContent } = userContent;
986
1019
  // P5.6: the note a partial restore left for the agent is a notice, not a person's prompt.
987
1020
  if (isSessionLogRestoreNote(props.turn.user))
988
1021
  return _jsx(RestoreNoteMarker, {});
989
- return (_jsxs(_Fragment, { children: [noticeBatch ? (_jsx(NoticeBatchGroup, { items: noticeBatch })) : subagentNotice ? (_jsx(SubagentNoticeRow, { notice: subagentNotice })) : (sessionReport && _jsx(TurnSessionReport, { report: sessionReport })), !hasVisibleUserContent && !sessionReport && !noticeBatch && systemMessages.length > 0 && (_jsx(SystemMessageIndicator, { messages: systemMessages })), hasVisibleUserContent && _jsx(TurnUserBubble, { ...props })] }));
1022
+ return (_jsxs(_Fragment, { children: [noticeBatch ? (_jsx(NoticeBatchGroup, { items: noticeBatch })) : subagentNotice ? (_jsx(SubagentNoticeRow, { notice: subagentNotice })) : peerMessage ? (_jsx(PeerMessageRow, { info: peerMessage })) : (sessionReport && _jsx(TurnSessionReport, { report: sessionReport })), !hasVisibleUserContent && !sessionReport && !noticeBatch && !peerMessage && systemMessages.length > 0 && (_jsx(SystemMessageIndicator, { messages: systemMessages })), hasVisibleUserContent && _jsx(TurnUserBubble, { ...props })] }));
990
1023
  }
991
1024
  /** The user message bubble — dimmed while the prompt waits in the queue. */
992
1025
  function TurnUserBubble(props) {
@@ -1160,7 +1193,7 @@ function TurnFooter(props) {
1160
1193
  const { statusPhrase, statusElapsedLabel } = status;
1161
1194
  const { retryInfo, retryMessage, retrySecondsLeft } = retry;
1162
1195
  const { turnEndedAt, turnDurationMs, costInfo } = meta;
1163
- return (_jsxs(_Fragment, { children: [_jsx(TurnBusyRow, { ...props, working: working, turnError: turnError, tHardcodedUi: tHardcodedUi }), turnErrorRow.text && !turn.autoRetry?.continued && (_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 && (_jsx(TurnActionBar, { response: response, inlineContentParts: answered.inlineContentParts, turnEndedAt: turnEndedAt, turnDurationMs: turnDurationMs, costInfo: costInfo, servedModel: servedModel, tHardcodedUi: tHardcodedUi,
1196
+ return (_jsxs(_Fragment, { children: [_jsx(TurnBusyRow, { ...props, working: working, turnError: turnError, tHardcodedUi: tHardcodedUi }), turnErrorRow.text && !turn.autoRetry?.continued && (_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,
1164
1197
  // A continuation turn's id names a compaction marker, not a user
1165
1198
  // message, so it has no response of its own to share.
1166
1199
  share: turn.continues
@@ -1187,6 +1220,12 @@ function TurnBusyRow(props) {
1187
1220
  }
1188
1221
  /** Copy + the turn's settled meta row — the hover-revealed bar at the end of
1189
1222
  * a settled turn. Owns the copy state: it is the only consumer. */
1223
+ /** Whether the turn wrote any text: the response, or a text item of its inline content. */
1224
+ function hasCopyableResponse(response, inlineContentParts) {
1225
+ if (response.trim())
1226
+ return true;
1227
+ return !!inlineContentParts?.some((item) => item.type === 'text' && item.block.text.trim());
1228
+ }
1190
1229
  function TurnActionBar({ response, inlineContentParts, turnEndedAt, turnDurationMs, costInfo, servedModel, tHardcodedUi, inToolbar = false, share, }) {
1191
1230
  const [copied, setCopied] = useState(false);
1192
1231
  // ---- Copy response ----
@@ -1289,7 +1328,7 @@ function SessionTurnImpl(props) {
1289
1328
  : rows.owner;
1290
1329
  const personName = person ? participantLabel(person) : '';
1291
1330
  const showAnswer = turn.assistant.length > 0 || model.working || !!errors.turnErrorRow.text;
1292
- return (_jsxs("div", { className: "text-factor-[2]", children: [userContent.hasVisibleUserContent || userContent.sessionReport || userContent.noticeBatch || userContent.systemMessages.length > 0 ? (_jsx(MessageRow
1331
+ return (_jsxs("div", { className: "text-factor-[2]", children: [userContent.hasVisibleUserContent || userContent.sessionReport || userContent.noticeBatch || userContent.peerMessage || userContent.systemMessages.length > 0 ? (_jsx(MessageRow
1293
1332
  // The first message's turn clips its toolbar's overhang: it sits inside the row.
1294
1333
  , {
1295
1334
  // The first message's turn clips its toolbar's overhang: it sits inside the row.
@@ -12,6 +12,7 @@ const REPLIED_IN_KEY = {
12
12
  Teams: 'text72b5b0c53de9',
13
13
  Slack: 'textfc73e9ad2dae',
14
14
  Telegram: 'text8faf56a14a8d',
15
+ Discord: 'text3416de570ab5',
15
16
  };
16
17
  /** "Replied in Microsoft Teams" — the row title for a channel send. */
17
18
  export function channelSendTitle(platform, tI18nComplete) {
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { ChatCircleIcon } from '@phosphor-icons/react';
4
+ import { Discord, DISCORD_BLURPLE } from '../../internal/icons/discord.js';
4
5
  import { Email } from '../../internal/icons/email.js';
5
6
  import { MicrosoftTeams } from '../../internal/icons/microsoft-teams.js';
6
7
  import { Slack } from '../../internal/icons/slack.js';
@@ -22,6 +23,7 @@ export const CHANNEL_BRAND_COLOR = {
22
23
  Slack: undefined,
23
24
  Teams: '#5B5FC7',
24
25
  Email: undefined,
26
+ Discord: DISCORD_BLURPLE,
25
27
  };
26
28
  const TELEGRAM_PATH = 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm4.64 6.8c-.15 1.58-.8 5.42-1.13 7.19-.14.75-.42 1-.68 1.03-.58.05-1.02-.38-1.58-.75-.88-.58-1.38-.94-2.23-1.5-.99-.65-.35-1.01.22-1.59.15-.15 2.71-2.48 2.76-2.69a.2.2 0 00-.05-.18c-.06-.05-.14-.03-.21-.02-.09.02-1.49.95-4.22 2.79-.4.27-.76.41-1.08.4-.36-.01-1.04-.2-1.55-.37-.63-.2-1.12-.31-1.08-.66.02-.18.27-.36.74-.55 2.92-1.27 4.86-2.11 5.83-2.51 2.78-1.16 3.35-1.36 3.73-1.36.08 0 .27.02.39.12.1.08.13.19.14.27-.01.06.01.24 0 .38z';
27
29
  /**
@@ -36,6 +38,8 @@ export function ChannelBrandMark({ platform, className = 'size-3.5 shrink-0', })
36
38
  return _jsx(Slack, { className: className });
37
39
  if (platform === 'Email')
38
40
  return _jsx(Email, { className: className });
41
+ if (platform === 'Discord')
42
+ return _jsx(Discord, { className: className });
39
43
  if (platform !== 'Telegram')
40
44
  return _jsx(ChatCircleIcon, { className: className, "aria-hidden": "true" });
41
45
  return (_jsx("svg", { className: className, viewBox: "0 0 24 24", fill: CHANNEL_BRAND_COLOR.Telegram, "aria-hidden": "true", children: _jsx("path", { d: TELEGRAM_PATH }) }));
@@ -1,9 +1,8 @@
1
- import type { SessionMessageAuthor, SessionMessageAuthors } from '@kortix/sdk';
1
+ import type { SessionMessageAuthor, SessionMessageAuthors, SessionParticipants } from '@kortix/sdk';
2
+ import type { UiViewer } from '../../providers/ui-provider.js';
2
3
  interface TranscriptAuthors {
3
4
  /** The author of each user message that has one, by runtime message id. */
4
5
  byMessage: Map<string, SessionMessageAuthor>;
5
- /** True when the transcript reads as a group chat: 2+ distinct authors. */
6
- multiAuthor: boolean;
7
6
  }
8
7
  /**
9
8
  * Pairs each user message with its author. A spawned session's first message
@@ -27,12 +26,18 @@ export declare function missingAuthorKey(data: SessionMessageAuthors | undefined
27
26
  */
28
27
  export declare function authorForTurn(resolved: TranscriptAuthors, data: SessionMessageAuthors | undefined, messageId: string, wireMessageId?: string): SessionMessageAuthor | undefined;
29
28
  /**
30
- * Whether a bubble names its author. A one-person session draws no name. A
31
- * group chat names every author, and so does a session you read that someone
32
- * else wrote in. With no viewer id (the host passes no `useViewerId`, or auth
33
- * is still loading) a one-person session draws no name either.
29
+ * The signed-in viewer as a message author. A prompt sent from this tab has no
30
+ * recorded author until the ledger writes it, a moment after the bubble
31
+ * paints: the viewer's own avatar stands in, so the bubble does not move when
32
+ * the recorded author arrives. Undefined with no viewer.
34
33
  */
35
- export declare function showAuthorName(author: SessionMessageAuthor | undefined, multiAuthor: boolean, viewerId: string | undefined): boolean;
34
+ export declare function viewerAuthor(viewer: UiViewer | undefined): SessionMessageAuthor | undefined;
35
+ /**
36
+ * A queued prompt's sender, from the people who can open the session: the
37
+ * prompt row names its `author_user_id` before the authors read lists it.
38
+ * Undefined when that person is not in the listed rows (the route lists 20).
39
+ */
40
+ export declare function participantAuthor(participants: SessionParticipants | undefined, userId: string | null | undefined): SessionMessageAuthor | undefined;
36
41
  /**
37
42
  * Who to name under a turn someone ELSE stopped: "Stopped by <name>". Null
38
43
  * when nobody is recorded, when the stop came from an agent session, and when
@@ -1,7 +1,3 @@
1
- /** One author, one key: two members never share it, nor do two sessions. */
2
- function authorKey(author) {
3
- return author.kind === 'member' ? `member:${author.user_id}` : `session:${author.session_id}`;
4
- }
5
1
  /**
6
2
  * Pairs each user message with its author. A spawned session's first message
7
3
  * has no prompt record of its own, so `initial_author` goes to the first user
@@ -18,8 +14,7 @@ export function resolveTranscriptAuthors(userMessageIds, data) {
18
14
  initial = null;
19
15
  byMessage.set(id, author);
20
16
  }
21
- const distinct = new Set([...byMessage.values()].map(authorKey));
22
- return { byMessage, multiAuthor: distinct.size >= 2 };
17
+ return { byMessage };
23
18
  }
24
19
  /** When to ask again for an author that is not recorded yet: 2 s, 5 s, 12 s. */
25
20
  export const AUTHOR_RETRY_DELAYS_MS = [2000, 5000, 12000];
@@ -45,17 +40,40 @@ export function authorForTurn(resolved, data, messageId, wireMessageId) {
45
40
  (wireMessageId ? data?.authors[wireMessageId] : undefined));
46
41
  }
47
42
  /**
48
- * Whether a bubble names its author. A one-person session draws no name. A
49
- * group chat names every author, and so does a session you read that someone
50
- * else wrote in. With no viewer id (the host passes no `useViewerId`, or auth
51
- * is still loading) a one-person session draws no name either.
43
+ * The signed-in viewer as a message author. A prompt sent from this tab has no
44
+ * recorded author until the ledger writes it, a moment after the bubble
45
+ * paints: the viewer's own avatar stands in, so the bubble does not move when
46
+ * the recorded author arrives. Undefined with no viewer.
47
+ */
48
+ export function viewerAuthor(viewer) {
49
+ if (!viewer)
50
+ return undefined;
51
+ const name = viewer.metadata?.full_name ?? viewer.metadata?.name;
52
+ const avatar = viewer.metadata?.avatar_url;
53
+ return {
54
+ kind: 'member',
55
+ user_id: viewer.id,
56
+ name: typeof name === 'string' ? name : '',
57
+ email: viewer.email ?? null,
58
+ avatar_url: typeof avatar === 'string' ? avatar : null,
59
+ };
60
+ }
61
+ /**
62
+ * A queued prompt's sender, from the people who can open the session: the
63
+ * prompt row names its `author_user_id` before the authors read lists it.
64
+ * Undefined when that person is not in the listed rows (the route lists 20).
52
65
  */
53
- export function showAuthorName(author, multiAuthor, viewerId) {
54
- if (!author)
55
- return false;
56
- if (multiAuthor)
57
- return true;
58
- return author.kind === 'session' || (viewerId !== undefined && author.user_id !== viewerId);
66
+ export function participantAuthor(participants, userId) {
67
+ const person = userId ? participants?.participants.find((p) => p.user_id === userId) : undefined;
68
+ if (!person)
69
+ return undefined;
70
+ return {
71
+ kind: 'member',
72
+ user_id: person.user_id,
73
+ name: person.name ?? '',
74
+ email: person.email,
75
+ avatar_url: person.avatar_url,
76
+ };
59
77
  }
60
78
  /**
61
79
  * Who to name under a turn someone ELSE stopped: "Stopped by <name>". Null