@kortix/ui 0.15.3 → 0.15.4

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 (66) hide show
  1. package/dist/_vendor/kortix-shared.js +87 -29
  2. package/dist/_vendor/shared/markdown-math.d.ts +6 -0
  3. package/dist/customize/agents/agent-drives-section.d.ts +1 -3
  4. package/dist/customize/agents/agent-drives-section.js +3 -4
  5. package/dist/customize/agents/agent-page.js +2 -2
  6. package/dist/customize/agents/agent-tabs.d.ts +1 -1
  7. package/dist/customize/agents/agent-tabs.js +1 -2
  8. package/dist/customize/connectors/connectors-page.d.ts +8 -0
  9. package/dist/customize/connectors/connectors-page.js +34 -1
  10. package/dist/customize/sections/view/agent-editor-access-fields.js +1 -3
  11. package/dist/files/project/components/drive-explorer.js +64 -43
  12. package/dist/files/project/components/drive-upload-tray.d.ts +2 -1
  13. package/dist/files/project/components/drive-upload-tray.js +9 -4
  14. package/dist/files/project/drop-tree.d.ts +16 -0
  15. package/dist/files/project/drop-tree.js +39 -0
  16. package/dist/files/project/upload-batch.d.ts +15 -0
  17. package/dist/files/project/upload-batch.js +12 -0
  18. package/dist/i18n/en.d.ts +13 -6
  19. package/dist/i18n/en.js +19 -12
  20. package/dist/internal/billing/use-cost-explorer.d.ts +19 -1
  21. package/dist/internal/billing/use-cost-explorer.js +27 -1
  22. package/dist/internal/lib/billing/billing-gate-state.d.ts +5 -6
  23. package/dist/internal/lib/billing/billing-gate-state.js +10 -11
  24. package/dist/internal/lib/browser-error-noise.d.ts +1 -1
  25. package/dist/internal/lib/browser-error-noise.js +1 -1
  26. package/dist/internal/lib/browser-noise/rules/injected-scripts.d.ts +5 -1
  27. package/dist/internal/lib/browser-noise/rules/injected-scripts.js +86 -0
  28. package/dist/internal/lib/mermaid-utils.js +2 -24
  29. package/dist/primitives/mermaid-render.js +3 -20
  30. package/dist/session/composer/ComposerCard.d.ts +1 -1
  31. package/dist/session/composer/ComposerCard.js +2 -2
  32. package/dist/session/composer/composer-chat-input.d.ts +14 -1
  33. package/dist/session/composer/composer-chat-input.js +4 -2
  34. package/dist/session/composer/composer-toolbar.d.ts +4 -1
  35. package/dist/session/composer/composer-toolbar.js +2 -2
  36. package/dist/session/composer/composer.d.ts +8 -0
  37. package/dist/session/composer/send-stop-control.d.ts +15 -1
  38. package/dist/session/composer/send-stop-control.js +30 -5
  39. package/dist/session/header/session-embed-menu-item.d.ts +12 -0
  40. package/dist/session/header/session-embed-menu-item.js +30 -0
  41. package/dist/{workspace/sidebar/modal/session-embed-section.d.ts → session/header/session-embed-snippet.d.ts} +2 -11
  42. package/dist/session/header/session-embed-snippet.js +21 -0
  43. package/dist/session/header/session-site-header.js +9 -2
  44. package/dist/session/models/ask-owner-for-credits-button.d.ts +7 -1
  45. package/dist/session/models/ask-owner-for-credits-button.js +3 -2
  46. package/dist/session/thread/session-chat.js +11 -1
  47. package/dist/session/voice/composer-call.d.ts +31 -0
  48. package/dist/session/voice/composer-call.js +46 -0
  49. package/dist/session/voice/voice-call-card.js +2 -0
  50. package/dist/session/voice/voice-call-store.d.ts +8 -0
  51. package/dist/session/voice/voice-call-store.js +5 -0
  52. package/dist/session/voice/voice-call.d.ts +2 -2
  53. package/dist/session/voice/voice-call.js +6 -6
  54. package/dist/test-utils/intl.d.ts +13 -6
  55. package/dist/workspace/home/existing-repo-setup-prompt.js +2 -3
  56. package/dist/workspace/instant-session-shell.js +11 -1
  57. package/dist/workspace/layout/project-home.js +24 -2
  58. package/dist/workspace/layout/use-project-home-call.d.ts +24 -0
  59. package/dist/workspace/layout/use-project-home-call.js +56 -0
  60. package/dist/workspace/new/workspace-name.d.ts +13 -0
  61. package/dist/workspace/new/workspace-name.js +20 -0
  62. package/dist/workspace/sidebar/footer/project-balance-warning.js +9 -6
  63. package/dist/workspace/sidebar/footer/sidebar-alert.d.ts +1 -1
  64. package/dist/workspace/sidebar/modal/share-session-modal.js +2 -3
  65. package/package.json +7 -7
  66. package/dist/workspace/sidebar/modal/session-embed-section.js +0 -71
@@ -24,7 +24,7 @@ export function ComposerCard({ tHardcodedUi, isDragOver, handleDragEnter, handle
24
24
  // Raw props the moved JSX reads; `{...props}` carries the rest. These
25
25
  // defaults mirror `ComposerImpl`'s, because the spread passes the raw
26
26
  // values, not the component's defaulted locals.
27
- agents = EMPTY_AGENTS, commands = EMPTY_COMMANDS, slashFiles = EMPTY_SLASH_FILES, models = EMPTY_MODELS, notice = null, disabled = false, lockForQuestion = false, lockForApproval = false, questionButtonLabel = null, questionActive = false, submitLabel = null, questionCanAct = true, escCount = 0, isBusy = false, isSending = false, onStop, stopDisabled = false, canStop = true, modelsLoading = false, modelRequired = false, onModelChange, modelDefaultControls, inheritedModel, providers, variants = EMPTY_VARIANTS, selectedVariant = null, onVariantChange, projectId, toolbarSlot, underbarSlot, rewind, selectedAgent = null, onAgentChange, noAccessibleAgents = false, agentLocked = false, onContextClick, messages, underbarPlacement = 'below', agentPickerCompact = false, slashMenuPlacement = 'above', cardClassName, }) {
27
+ agents = EMPTY_AGENTS, commands = EMPTY_COMMANDS, slashFiles = EMPTY_SLASH_FILES, models = EMPTY_MODELS, notice = null, disabled = false, lockForQuestion = false, lockForApproval = false, questionButtonLabel = null, questionActive = false, submitLabel = null, questionCanAct = true, escCount = 0, isBusy = false, isSending = false, onStop, stopDisabled = false, canStop = true, modelsLoading = false, modelRequired = false, onModelChange, modelDefaultControls, inheritedModel, providers, variants = EMPTY_VARIANTS, selectedVariant = null, onVariantChange, projectId, toolbarSlot, underbarSlot, rewind, selectedAgent = null, onAgentChange, noAccessibleAgents = false, agentLocked = false, onContextClick, messages, underbarPlacement = 'below', agentPickerCompact = false, slashMenuPlacement = 'above', cardClassName, call, }) {
28
28
  const cardRef = useRef(null);
29
29
  const { attachAccept, modelPickerEnabled } = useUiHostConfig();
30
30
  const inlineUnderbar = underbarPlacement === 'inline';
@@ -124,5 +124,5 @@ agents = EMPTY_AGENTS, commands = EMPTY_COMMANDS, slashFiles = EMPTY_SLASH_FILES
124
124
  toolbarSlot: inlineUnderbar ? toolbarSlot : undefined, rewind: rewind, isSending: isSending, isBusy: isBusy, onStop: onStop, stopDisabled: stopDisabled, canStop: canStop, escCount: escCount, lockForQuestion: lockForQuestion, questionButtonLabel: questionButtonLabel, submitLabel: submitLabel, questionCanAct: questionCanAct, hasText: !isEmpty, canSubmit: canSubmit, submitDisabled: submitDisabled ||
125
125
  attachmentFailed ||
126
126
  modelRejectingImages !== null ||
127
- commandAttachmentPlan.kind === 'refuse', attachmentFailed: attachmentFailed, attachmentUnsupported: imagesUnsupportedReason, disabled: disabled, modelUnavailable: modelUnavailable, agentUnavailable: agentUnavailable, onSubmit: () => handleSubmit() })] })] })] }), _jsx(ImagesUnsupportedBar, { modelName: noModelsConnected ? null : modelRejectingImages }), inlineUnderbar ? null : (_jsx(ComposerUnderbar, { onAttachClick: handleAttachClick, agents: primaryAgents, selectedAgent: selectedAgent, onAgentChange: onAgentChange, agentMenuOpen: agentMenuOpen, onAgentMenuOpenChange: setAgentMenuOpen, noAccessibleAgents: noAccessibleAgents, agentLocked: agentLocked, messages: messages, models: models, selectedModel: availableSelectedModel, onContextClick: onContextClick, toolbarSlot: toolbarSlot, agentsSlot: underbarSlot, chatInput: chatInput })), _jsx(ModelConnectionBar, { show: noModelsConnected }), slashMenuPlacement === 'below' && (_jsx("div", { id: dockId, className: "absolute top-full right-4 left-4 z-99 mt-3.5" }))] }));
127
+ commandAttachmentPlan.kind === 'refuse', attachmentFailed: attachmentFailed, attachmentUnsupported: imagesUnsupportedReason, disabled: disabled, modelUnavailable: modelUnavailable, agentUnavailable: agentUnavailable, call: call, onSubmit: () => handleSubmit() })] })] })] }), _jsx(ImagesUnsupportedBar, { modelName: noModelsConnected ? null : modelRejectingImages }), inlineUnderbar ? null : (_jsx(ComposerUnderbar, { onAttachClick: handleAttachClick, agents: primaryAgents, selectedAgent: selectedAgent, onAgentChange: onAgentChange, agentMenuOpen: agentMenuOpen, onAgentMenuOpenChange: setAgentMenuOpen, noAccessibleAgents: noAccessibleAgents, agentLocked: agentLocked, messages: messages, models: models, selectedModel: availableSelectedModel, onContextClick: onContextClick, toolbarSlot: toolbarSlot, agentsSlot: underbarSlot, chatInput: chatInput })), _jsx(ModelConnectionBar, { show: noModelsConnected }), slashMenuPlacement === 'below' && (_jsx("div", { id: dockId, className: "absolute top-full right-4 left-4 z-99 mt-3.5" }))] }));
128
128
  }
@@ -15,6 +15,17 @@ export interface ComposerOptions {
15
15
  scope?: SessionScopeCommit;
16
16
  providerSecretPools?: Record<string, string[]>;
17
17
  }
18
+ /**
19
+ * The voice call this composer offers in Send's place while nothing is typed
20
+ * (`SessionChatInputProps.call`). `onCall` gets the composer's picks, as a send
21
+ * does, with the agent it shows: the call is offered only once one resolved.
22
+ */
23
+ export interface ComposerChatCall {
24
+ onCall: (options: ComposerOptions & {
25
+ agent: string;
26
+ }) => void;
27
+ inCall: boolean;
28
+ }
18
29
  /**
19
30
  * The canonical "compose a first message" input: {@link SessionChatInput}
20
31
  * pre-wired with the model / agent / variant / command selectors (the
@@ -24,7 +35,7 @@ export interface ComposerOptions {
24
35
  * The current selections are handed to `onSend` / `onCommand` as `options`, so
25
36
  * callers never need their own `useRuntimeLocal`.
26
37
  */
27
- export declare function ComposerChatInput({ onSend, onCommand, sessionId, projectId, isBusy, sessionWorking, runtimeReady, stopDisabled, isSending, disabled, autoFocus, placeholder, hint, prefill, onPrefillApplied, aboveSlot, inputSlot, toolbarSlot, underbarPlacement, slashMenuPlacement, cardClassName, parentClassName, boundAgentName, lockAgent, defaultAgentName, channelAgentNames, projectSession, clearOnSend, onAgentSelectionChange, sandboxSlot, draftScope, draftActive, promptAttachments, submitLabel, onArrowUpAtStart, }: {
38
+ export declare function ComposerChatInput({ onSend, onCommand, sessionId, projectId, isBusy, sessionWorking, runtimeReady, stopDisabled, isSending, disabled, autoFocus, placeholder, hint, prefill, onPrefillApplied, aboveSlot, inputSlot, toolbarSlot, underbarPlacement, slashMenuPlacement, cardClassName, parentClassName, boundAgentName, lockAgent, defaultAgentName, channelAgentNames, projectSession, clearOnSend, onAgentSelectionChange, sandboxSlot, draftScope, draftActive, promptAttachments, submitLabel, onArrowUpAtStart, call, }: {
28
39
  onSend: (text: string, files: AttachedFile[] | undefined, options: ComposerOptions, attachments?: AttachmentSubmission) => void | Promise<void>;
29
40
  onCommand?: (command: Command, args: string | undefined, options: ComposerOptions) => void;
30
41
  sessionId?: string;
@@ -99,4 +110,6 @@ export declare function ComposerChatInput({ onSend, onCommand, sessionId, projec
99
110
  submitLabel?: SessionChatInputProps['submitLabel'];
100
111
  /** Up in an empty composer: open the latest queued message for editing. */
101
112
  onArrowUpAtStart?: SessionChatInputProps['onArrowUpAtStart'];
113
+ /** A voice call in Send's place while nothing is typed. See `ComposerChatCall`. */
114
+ call?: ComposerChatCall;
102
115
  }): import("react").JSX.Element;
@@ -17,7 +17,7 @@ import { inheritedModelFor } from './chat-input/chat-input-summary.js';
17
17
  * The current selections are handed to `onSend` / `onCommand` as `options`, so
18
18
  * callers never need their own `useRuntimeLocal`.
19
19
  */
20
- export function ComposerChatInput({ onSend, onCommand, sessionId, projectId, isBusy, sessionWorking, runtimeReady, stopDisabled, isSending, disabled, autoFocus, placeholder, hint, prefill, onPrefillApplied, aboveSlot, inputSlot, toolbarSlot, underbarPlacement, slashMenuPlacement, cardClassName, parentClassName, boundAgentName, lockAgent = false, defaultAgentName, channelAgentNames, projectSession, clearOnSend, onAgentSelectionChange, sandboxSlot, draftScope, draftActive, promptAttachments, submitLabel, onArrowUpAtStart, }) {
20
+ export function ComposerChatInput({ onSend, onCommand, sessionId, projectId, isBusy, sessionWorking, runtimeReady, stopDisabled, isSending, disabled, autoFocus, placeholder, hint, prefill, onPrefillApplied, aboveSlot, inputSlot, toolbarSlot, underbarPlacement, slashMenuPlacement, cardClassName, parentClassName, boundAgentName, lockAgent = false, defaultAgentName, channelAgentNames, projectSession, clearOnSend, onAgentSelectionChange, sandboxSlot, draftScope, draftActive, promptAttachments, submitLabel, onArrowUpAtStart, call, }) {
21
21
  const contextAutoFocus = useContext(ComposerAutoFocusContext);
22
22
  const { data: rosterAgents } = useRuntimeAgents({ projectId });
23
23
  const agents = useMemo(() => withChannelAgents(rosterAgents, channelAgentNames), [rosterAgents, channelAgentNames]);
@@ -151,5 +151,7 @@ export function ComposerChatInput({ onSend, onCommand, sessionId, projectId, isB
151
151
  // A thread a space's chat opened by itself does not take the focus (`ComposerAutoFocusContext`).
152
152
  autoFocus: autoFocus ?? (contextAutoFocus ? undefined : false), placeholder: placeholder, hint: hint, prefill: deliveredPrefill, onPrefillApplied: onPrefillApplied, aboveSlot: aboveSlot, inputSlot: inputSlot, toolbarSlot: combinedToolbarSlot, underbarPlacement: underbarPlacement, slashMenuPlacement: slashMenuPlacement, cardClassName: cardClassName, parentClassName: parentClassName, sessionId: sessionId, projectId: projectId, providers: providers, agents: local.agent.list, selectedAgent: selectedAgentName, noAccessibleAgents: noAccessibleAgents, agentLocked: agentLocked,
153
153
  // A locked agent has nothing to switch to: no handler is the composer's "fixed agent" signal.
154
- onAgentChange: agentLocked ? undefined : (name) => local.agent.set(name ?? undefined), models: local.model.list, selectedModel: local.model.currentKey ?? null, onModelChange: (m) => local.model.set(m ?? undefined, { recent: true }), inheritedModel: inheritedModelFor(local.model, selectedAgentName), modelRequired: true, modelsLoading: providersLoading, variants: local.model.variant.list, selectedVariant: local.model.variant.current ?? null, onVariantChange: (v) => local.model.variant.set(v ?? undefined), commands: commands || [], commandsResolved: commands !== undefined, draftScope: draftScope, draftActive: draftActive, submitLabel: submitLabel, onArrowUpAtStart: onArrowUpAtStart }));
154
+ onAgentChange: agentLocked ? undefined : (name) => local.agent.set(name ?? undefined), models: local.model.list, selectedModel: local.model.currentKey ?? null, onModelChange: (m) => local.model.set(m ?? undefined, { recent: true }), inheritedModel: inheritedModelFor(local.model, selectedAgentName), modelRequired: true, modelsLoading: providersLoading, variants: local.model.variant.list, selectedVariant: local.model.variant.current ?? null, onVariantChange: (v) => local.model.variant.set(v ?? undefined), commands: commands || [], commandsResolved: commands !== undefined, draftScope: draftScope, draftActive: draftActive, submitLabel: submitLabel, onArrowUpAtStart: onArrowUpAtStart, call: call && selectedAgentName
155
+ ? { inCall: call.inCall, onCall: () => call.onCall({ ...options(), agent: selectedAgentName }) }
156
+ : undefined }));
155
157
  }
@@ -1,5 +1,6 @@
1
1
  import type { FlatModel, ProviderListResponse } from '@kortix/sdk/react';
2
2
  import type { ModelDefaultControls } from '../models/model-selector.js';
3
+ import type { ComposerCall } from '../voice/composer-call.js';
3
4
  /**
4
5
  * The composer's bottom toolbar — the familiar one, scoped to the one control
5
6
  * that describes WHAT will answer.
@@ -116,6 +117,8 @@ export interface ComposerToolbarProps {
116
117
  attachmentFailed?: boolean;
117
118
  /** Why the selected model cannot take the attachments, or null. See `SendStopControl`. */
118
119
  attachmentUnsupported?: string | null;
120
+ /** The host's voice call, offered in Send's place on an empty composer. See `SendStopControl`. */
121
+ call?: ComposerCall;
119
122
  onSubmit: () => void;
120
123
  }
121
- export declare function ComposerToolbar({ models, modelsLoading, selectedModel, onModelChange, modelDefaultControls, providers, modelRequired, modelMenuOpen, onModelMenuOpenChange, reasoningMenuOpen, onReasoningMenuOpenChange, variants, selectedVariant, onVariantChange, projectId, toolbarSlot, rewind, leading, pickersInChatInput, isSending, isBusy, onStop, stopDisabled, canStop, escCount, lockForQuestion, questionButtonLabel, submitLabel, questionCanAct, hasText, canSubmit, submitDisabled, disabled, modelUnavailable, agentUnavailable, attachmentFailed, attachmentUnsupported, onSubmit, }: ComposerToolbarProps): import("react").JSX.Element;
124
+ export declare function ComposerToolbar({ models, modelsLoading, selectedModel, onModelChange, modelDefaultControls, providers, modelRequired, modelMenuOpen, onModelMenuOpenChange, reasoningMenuOpen, onReasoningMenuOpenChange, variants, selectedVariant, onVariantChange, projectId, toolbarSlot, rewind, leading, pickersInChatInput, isSending, isBusy, onStop, stopDisabled, canStop, escCount, lockForQuestion, questionButtonLabel, submitLabel, questionCanAct, hasText, canSubmit, submitDisabled, disabled, modelUnavailable, agentUnavailable, attachmentFailed, attachmentUnsupported, call, onSubmit, }: ComposerToolbarProps): import("react").JSX.Element;
@@ -9,7 +9,7 @@ import Loading from '../../primitives/loading.js';
9
9
  import { ModelSelector } from '../models/model-selector.js';
10
10
  import { ReasoningEffortSelector } from './reasoning-effort-selector.js';
11
11
  import { SendStopControl } from './send-stop-control.js';
12
- export function ComposerToolbar({ models, modelsLoading, selectedModel, onModelChange, modelDefaultControls, providers, modelRequired, modelMenuOpen, onModelMenuOpenChange, reasoningMenuOpen, onReasoningMenuOpenChange, variants, selectedVariant, onVariantChange, projectId, toolbarSlot, rewind, leading, pickersInChatInput = false, isSending, isBusy, onStop, stopDisabled, canStop, escCount, lockForQuestion, questionButtonLabel, submitLabel, questionCanAct, hasText, canSubmit, submitDisabled, disabled, modelUnavailable, agentUnavailable = false, attachmentFailed = false, attachmentUnsupported = null, onSubmit, }) {
12
+ export function ComposerToolbar({ models, modelsLoading, selectedModel, onModelChange, modelDefaultControls, providers, modelRequired, modelMenuOpen, onModelMenuOpenChange, reasoningMenuOpen, onReasoningMenuOpenChange, variants, selectedVariant, onVariantChange, projectId, toolbarSlot, rewind, leading, pickersInChatInput = false, isSending, isBusy, onStop, stopDisabled, canStop, escCount, lockForQuestion, questionButtonLabel, submitLabel, questionCanAct, hasText, canSubmit, submitDisabled, disabled, modelUnavailable, agentUnavailable = false, attachmentFailed = false, attachmentUnsupported = null, call, onSubmit, }) {
13
13
  const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
14
14
  const { modelPickerEnabled } = useUiHostConfig();
15
15
  const showModel = !pickersInChatInput && modelPickerEnabled && (models.length > 0 || modelRequired) && !!onModelChange;
@@ -24,5 +24,5 @@ export function ComposerToolbar({ models, modelsLoading, selectedModel, onModelC
24
24
  };
25
25
  return (_jsxs("div", { className: "kortix-composer-toolbar flex items-center justify-between gap-1 overflow-visible", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-1 overflow-visible", children: [leading, showModel && (_jsx(ModelSelector, { models: models, modelsLoading: modelsLoading, selectedModel: selectedModel, onSelect: onModelChange, providers: providers, defaultControls: modelDefaultControls, triggerLabelClassName: "max-w-[7rem]", projectId: projectId, offerProviderAccounts: true, open: pickerOpen, onOpenChange: onPickerOpenChange, reasoning: { variants, selectedVariant, onVariantChange } })), !showModel && modelPickerEnabled && !pickersInChatInput && _jsx(ReasoningEffortSelector, { variants: variants, selectedVariant: selectedVariant, onVariantChange: onVariantChange, open: reasoningMenuOpen, onOpenChange: onReasoningMenuOpenChange })] }), _jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [rewind && (_jsxs(HoverCard, { openDelay: 0, closeDelay: 0, children: [_jsx(HoverCardTrigger, { asChild: true, children: _jsx("span", { className: "inline-flex", children: _jsxs(Button, { type: "button", variant: "ghost", size: "sm", disabled: rewind.pending || rewind.disabled, onClick: rewind.onRestore, className: "text-muted-foreground hover:text-foreground gap-1.5", children: [rewind.pending ? (_jsx(Loading, { className: "size-3.5 shrink-0" })) : (_jsx(ArrowCounterClockwiseIcon, { className: "size-3.5 shrink-0" })), tI18nComplete.raw('texta76e13b98392')] }) }) }), _jsx(HoverCardContent, { className: "px-3 py-2 text-sm text-balance", children: rewind.disabled && !rewind.pending
26
26
  ? tI18nComplete.raw('text98433e61649a')
27
- : tI18nComplete.raw('text4c25090df9ea') })] })), toolbarSlot, _jsx(SendStopControl, { isSending: isSending, isBusy: isBusy, onStop: onStop, stopDisabled: stopDisabled, canStop: canStop, escCount: escCount, lockForQuestion: lockForQuestion, questionButtonLabel: questionButtonLabel, submitLabel: submitLabel, questionCanAct: questionCanAct, hasText: hasText, canSubmit: canSubmit, submitDisabled: submitDisabled, disabled: disabled, modelUnavailable: modelUnavailable, agentUnavailable: agentUnavailable, attachmentFailed: attachmentFailed, attachmentUnsupported: attachmentUnsupported, onSubmit: onSubmit })] })] }));
27
+ : tI18nComplete.raw('text4c25090df9ea') })] })), toolbarSlot, _jsx(SendStopControl, { isSending: isSending, isBusy: isBusy, onStop: onStop, stopDisabled: stopDisabled, canStop: canStop, escCount: escCount, lockForQuestion: lockForQuestion, questionButtonLabel: questionButtonLabel, submitLabel: submitLabel, questionCanAct: questionCanAct, hasText: hasText, canSubmit: canSubmit, submitDisabled: submitDisabled, disabled: disabled, modelUnavailable: modelUnavailable, agentUnavailable: agentUnavailable, attachmentFailed: attachmentFailed, attachmentUnsupported: attachmentUnsupported, call: call, onSubmit: onSubmit })] })] }));
28
28
  }
@@ -7,6 +7,7 @@ import { type AttachmentSubmission } from './attachment-submission.js';
7
7
  import { type QuoteRequest } from './composer-logic.js';
8
8
  import type { SlashFile } from './menus/slash-files.js';
9
9
  import type { AttachedFile, TrackedMention } from './types.js';
10
+ import type { ComposerCall } from '../voice/composer-call.js';
10
11
  export interface SessionChatInputProps {
11
12
  onSend: (text: string, files?: AttachedFile[], mentions?: TrackedMention[], attachments?: AttachmentSubmission, placement?: 'transcript' | 'composer') => void | Promise<void>;
12
13
  /**
@@ -286,6 +287,13 @@ export interface SessionChatInputProps {
286
287
  */
287
288
  slashMenuPlacement?: 'above' | 'below';
288
289
  cardClassName?: string;
290
+ /**
291
+ * A voice call, offered in the Send button's place while there is nothing to
292
+ * send (flag `voice_call`; `session/voice/composer-call.ts`). Hosts opt in:
293
+ * project home calls a new session, a session page calls its own session.
294
+ * Omitted, Send is the only action, as before.
295
+ */
296
+ call?: ComposerCall;
289
297
  /**
290
298
  * Reply quotes to add — transcript selections the user clicked "Reply" on,
291
299
  * oldest first. Id-keyed like `prefill`: each id appends ONE quote to the
@@ -1,3 +1,11 @@
1
+ import type { ComposerCall } from '../voice/composer-call.js';
2
+ /**
3
+ * Does the Send slot offer the host's voice call? Only on an empty composer
4
+ * (no text, file, quote or paste) that could otherwise send: no question
5
+ * holds it, and nothing refuses a send (no agent, no model, a disabled or
6
+ * busy composer). Every other state keeps the control it had.
7
+ */
8
+ export declare function offersComposerCall({ call, canSubmit, lockForQuestion, disabled, agentUnavailable, modelUnavailable, }: Pick<SendStopControlProps, 'call' | 'canSubmit' | 'lockForQuestion' | 'disabled' | 'agentUnavailable' | 'modelUnavailable'>): boolean;
1
9
  export interface SendStopControlProps {
2
10
  isSending: boolean;
3
11
  isBusy: boolean;
@@ -34,6 +42,12 @@ export interface SendStopControlProps {
34
42
  attachmentFailed?: boolean;
35
43
  /** Why the selected model cannot take the attachments. Send is refused while set. */
36
44
  attachmentUnsupported?: string | null;
45
+ /**
46
+ * The host's voice call (flag `voice_call`). With nothing to send, the Send
47
+ * button calls instead: same place, same shape, a waveform for the arrow
48
+ * (`offersComposerCall`). Absent: Send stays as it was.
49
+ */
50
+ call?: ComposerCall;
37
51
  onSubmit: () => void;
38
52
  }
39
- export declare function SendStopControl({ isSending, isBusy, onStop, stopDisabled, canStop, escCount, lockForQuestion, questionButtonLabel, submitLabel, questionCanAct, hasText, canSubmit, submitDisabled, disabled, modelUnavailable, agentUnavailable, attachmentFailed, attachmentUnsupported, onSubmit, }: SendStopControlProps): import("react").JSX.Element;
53
+ export declare function SendStopControl({ isSending, isBusy, onStop, stopDisabled, canStop, escCount, lockForQuestion, questionButtonLabel, submitLabel, questionCanAct, hasText, canSubmit, submitDisabled, disabled, modelUnavailable, agentUnavailable, attachmentFailed, attachmentUnsupported, call, onSubmit, }: SendStopControlProps): import("react").JSX.Element;
@@ -5,7 +5,7 @@ import Hint from '../../primitives/hint.js';
5
5
  import { Kbd } from '../../primitives/kbd.js';
6
6
  import Loading from '../../primitives/loading.js';
7
7
  import { cn } from '../../lib/utils.js';
8
- import { ArrowUpIcon as ArrowUp, SquareIcon } from '@phosphor-icons/react';
8
+ import { ArrowUpIcon as ArrowUp, SquareIcon, WaveformIcon } from '@phosphor-icons/react';
9
9
  import { AnimatePresence, m } from 'motion/react';
10
10
  import { useTranslations } from '../../i18n/index.js';
11
11
  import { NO_MODEL_AVAILABLE_ACTION_MESSAGE } from '../models/model-availability.js';
@@ -22,9 +22,19 @@ const ICON_SWAP = {
22
22
  exit: { scale: 0.25, opacity: 0, filter: 'blur(4px)' },
23
23
  transition: { type: 'spring', duration: 0.3, bounce: 0 },
24
24
  };
25
- export function SendStopControl({ isSending, isBusy, onStop, stopDisabled, canStop = true, escCount, lockForQuestion, questionButtonLabel, submitLabel = null, questionCanAct, hasText, canSubmit, submitDisabled, disabled, modelUnavailable, agentUnavailable = false, attachmentFailed = false, attachmentUnsupported = null, onSubmit, }) {
25
+ /**
26
+ * Does the Send slot offer the host's voice call? Only on an empty composer
27
+ * (no text, file, quote or paste) that could otherwise send: no question
28
+ * holds it, and nothing refuses a send (no agent, no model, a disabled or
29
+ * busy composer). Every other state keeps the control it had.
30
+ */
31
+ export function offersComposerCall({ call, canSubmit, lockForQuestion, disabled, agentUnavailable, modelUnavailable, }) {
32
+ return !!call && !canSubmit && !lockForQuestion && !disabled && !agentUnavailable && !modelUnavailable;
33
+ }
34
+ export function SendStopControl({ isSending, isBusy, onStop, stopDisabled, canStop = true, escCount, lockForQuestion, questionButtonLabel, submitLabel = null, questionCanAct, hasText, canSubmit, submitDisabled, disabled, modelUnavailable, agentUnavailable = false, attachmentFailed = false, attachmentUnsupported = null, call, onSubmit, }) {
26
35
  const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
27
36
  const t = useTranslations('threads');
37
+ const tCall = useTranslations('voiceCall');
28
38
  const tDesktop = useTranslations('sessionDesktop');
29
39
  const tAttachments = useTranslations('hardcodedUi.composerAttachments');
30
40
  // One line, the same one the agent picker's tooltip carries — the two
@@ -36,9 +46,24 @@ export function SendStopControl({ isSending, isBusy, onStop, stopDisabled, canSt
36
46
  : attachmentFailed
37
47
  ? tAttachments('failedBlocksSend')
38
48
  : attachmentUnsupported;
39
- const sendButton = (_jsx(Hint, { side: "top", label: refusal ?? t('sendMessage'), children: _jsx("span", { className: "inline-flex", children: _jsx(Button, { size: "icon-base", disabled: lockForQuestion
40
- ? (!canSubmit && !questionCanAct) || disabled
41
- : !canSubmit || submitDisabled, onClick: onSubmit, "aria-label": t('sendMessage'), title: refusal ?? undefined, className: ICON_BUTTON, children: _jsx(AnimatePresence, { mode: "popLayout", initial: false, children: _jsx(m.span, { className: "flex items-center", ...ICON_SWAP, children: disabled ? (_jsx(Loading, { className: "size-3.5 shrink-0" })) : (_jsx(ArrowUp, { className: "size-4" })) }, disabled ? 'busy' : 'send') }) }) }) }));
49
+ // One button for both: typing turns the waveform into the arrow and
50
+ // clearing turns it back. That swap is keyboard-driven, so it is instant:
51
+ // both glyphs share the `send` key and only busy ⇄ send cross-fades
52
+ // (kortix-brand motion.md, "Never animate a keyboard-initiated action").
53
+ const callOffered = offersComposerCall({
54
+ call,
55
+ canSubmit,
56
+ lockForQuestion,
57
+ disabled,
58
+ agentUnavailable,
59
+ modelUnavailable,
60
+ });
61
+ const callLabel = call?.inCall ? tCall('inCall') : tCall('start');
62
+ const sendButton = (_jsx(Hint, { side: "top", label: callOffered ? callLabel : (refusal ?? t('sendMessage')), children: _jsx("span", { className: "inline-flex", children: _jsx(Button, { size: "icon-base", disabled: callOffered
63
+ ? !!call?.inCall
64
+ : lockForQuestion
65
+ ? (!canSubmit && !questionCanAct) || disabled
66
+ : !canSubmit || submitDisabled, onClick: callOffered ? () => call?.onCall() : onSubmit, "aria-label": callOffered ? tCall('start') : t('sendMessage'), title: callOffered ? undefined : (refusal ?? undefined), className: ICON_BUTTON, children: _jsx(AnimatePresence, { mode: "popLayout", initial: false, children: _jsx(m.span, { className: "flex items-center", ...ICON_SWAP, children: disabled ? (_jsx(Loading, { className: "size-3.5 shrink-0" })) : callOffered ? (_jsx(WaveformIcon, { weight: "bold", className: "size-4" })) : (_jsx(ArrowUp, { className: "size-4" })) }, disabled ? 'busy' : 'send') }) }) }) }));
42
67
  if (isSending && !lockForQuestion) {
43
68
  return (_jsx(Button, { size: "icon-base", "aria-label": t('sending'), disabled: true, className: ICON_BUTTON, children: _jsx(AnimatePresence, { mode: "popLayout", initial: false, children: _jsx(m.span, { className: "flex items-center", ...ICON_SWAP, children: _jsx(Loading, { className: "size-4" }) }, "pending") }) }));
44
69
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * "Embed" in the session menu: the snippet for framing the actual session
3
+ * page, with its caveat. The entry point left the Session access dialog
4
+ * (KRTX-4639) — a developer affordance does not belong in a permissions
5
+ * dialog — and this submenu is its one home. The caller gates the mount on
6
+ * the same verdicts the dialog's section used: the viewer may manage sharing
7
+ * (`can_manage_sharing`) and the host serves public shares.
8
+ */
9
+ export declare function SessionEmbedMenuItem({ projectId, sessionId }: {
10
+ projectId: string;
11
+ sessionId: string;
12
+ }): import("react").JSX.Element;
@@ -0,0 +1,30 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { DropdownMenuItem, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, } from '../../primitives/dropdown-menu.js';
4
+ import { errorToast, successToast } from '../../primitives/toast.js';
5
+ import { useTranslations } from '../../i18n/index.js';
6
+ import { CodeIcon } from '@phosphor-icons/react';
7
+ import { copyToClipboard } from '../../internal/lib/utils/clipboard.js';
8
+ import { sessionEmbedSnippet } from './session-embed-snippet.js';
9
+ /**
10
+ * "Embed" in the session menu: the snippet for framing the actual session
11
+ * page, with its caveat. The entry point left the Session access dialog
12
+ * (KRTX-4639) — a developer affordance does not belong in a permissions
13
+ * dialog — and this submenu is its one home. The caller gates the mount on
14
+ * the same verdicts the dialog's section used: the viewer may manage sharing
15
+ * (`can_manage_sharing`) and the host serves public shares.
16
+ */
17
+ export function SessionEmbedMenuItem({ projectId, sessionId }) {
18
+ const t = useTranslations('hardcodedUi.sessionEmbed');
19
+ const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
20
+ const copy = async () => {
21
+ const snippet = sessionEmbedSnippet(projectId, sessionId, window.location.origin);
22
+ if (!snippet)
23
+ return;
24
+ if (await copyToClipboard(snippet))
25
+ successToast(t.raw('copied'));
26
+ else
27
+ errorToast(tI18nComplete.raw('text167c96824acb'));
28
+ };
29
+ return (_jsxs(DropdownMenuSub, { children: [_jsxs(DropdownMenuSubTrigger, { className: "cursor-pointer", children: [_jsx(CodeIcon, {}), t.raw('sectionTitle')] }), _jsxs(DropdownMenuSubContent, { className: "w-64", children: [_jsx("p", { className: "text-muted-foreground px-2 py-1.5 text-xs", children: t.raw('sectionDescription') }), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => void copy(), children: [_jsx(CodeIcon, {}), t.raw('copy')] })] })] }));
30
+ }
@@ -7,19 +7,10 @@
7
7
  * the `title` attribute is a fixed string. Never interpolate a session title
8
8
  * into the attribute — an unescaped quote would break out of it on the HOST
9
9
  * page, which does not share this app's CSP.
10
- */
11
- export declare function sessionEmbedSnippet(projectId: string, sessionId: string, origin: string): string | null;
12
- /**
13
- * "Embed" in the Share dialog: one copy button for the iframe snippet above.
10
+ *
14
11
  * Framing the session page is allowed by the CSP `frame-ancestors` rule on
15
12
  * that route (next.config.ts); the viewer inside the frame is the app's own
16
13
  * auth. Same-site embeds require an existing signed-in session; cross-site
17
14
  * embeds cannot sign in inside the frame (SameSite=Lax and /auth's CSP).
18
- *
19
- * Mounted inside `ModalContent`, so `window` is read at render time of an open
20
- * dialog, never during SSR.
21
15
  */
22
- export declare function SessionEmbedSection({ projectId, sessionId, }: {
23
- projectId: string;
24
- sessionId: string;
25
- }): import("react").JSX.Element;
16
+ export declare function sessionEmbedSnippet(projectId: string, sessionId: string, origin: string): string | null;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The iframe snippet a host page pastes: the ACTUAL session page
3
+ * (`/projects/:projectId/sessions/:sessionId`), not a separate widget or
4
+ * viewer. Pure, so the test can pin the exact HTML without a browser.
5
+ *
6
+ * The snippet is static HTML by construction: the URL is built from ids, and
7
+ * the `title` attribute is a fixed string. Never interpolate a session title
8
+ * into the attribute — an unescaped quote would break out of it on the HOST
9
+ * page, which does not share this app's CSP.
10
+ *
11
+ * Framing the session page is allowed by the CSP `frame-ancestors` rule on
12
+ * that route (next.config.ts); the viewer inside the frame is the app's own
13
+ * auth. Same-site embeds require an existing signed-in session; cross-site
14
+ * embeds cannot sign in inside the frame (SameSite=Lax and /auth's CSP).
15
+ */
16
+ export function sessionEmbedSnippet(projectId, sessionId, origin) {
17
+ if (!projectId || !sessionId || !origin)
18
+ return null;
19
+ const src = `${origin}/workspaces/${encodeURIComponent(projectId)}/sessions/${encodeURIComponent(sessionId)}`;
20
+ return `<iframe src="${src}" style="height:640px;width:100%;border:0;border-radius:12px" title="Kortix session" loading="lazy"></iframe>`;
21
+ }
@@ -25,6 +25,7 @@ import { SessionPendingApprovalsIndicator } from './session-pending-approvals-in
25
25
  import { SessionGoalIndicator } from './session-goal-indicator.js';
26
26
  import { SessionRemindersIndicator } from './session-reminders-indicator.js';
27
27
  import { SessionTitleInput } from './session-title-input.js';
28
+ import { SessionEmbedMenuItem } from './session-embed-menu-item.js';
28
29
  import { subagentTitle } from '../agents/agent-model.js';
29
30
  import { SubagentHoverCard } from './subagent-hover-card.js';
30
31
  import { Copy } from '../../icons/copy.js';
@@ -63,7 +64,7 @@ export function SessionSiteHeader({ sessionId, sessionTitle, isMobileView, leadi
63
64
  const tPinArchive = useTranslations('sidebar.pinArchive');
64
65
  const localizedDevTools = useLocalizedUiCatalog(DEV_TOOLS);
65
66
  // A host that cannot reach the pty WebSocket turns the terminal off (`config.terminalEnabled`).
66
- const { terminalEnabled } = useUiHostConfig();
67
+ const { terminalEnabled, publicSharesEnabled } = useUiHostConfig();
67
68
  // A template on a base other than Ubuntu 24.04, or an old image, has no desktop.
68
69
  const hasDesktop = useHasSessionDesktop() === true;
69
70
  const devTools = useMemo(() => localizedDevTools.filter((tool) => (tool.view !== 'terminal' || terminalEnabled) && (tool.view !== 'desktop' || hasDesktop)), [localizedDevTools, terminalEnabled, hasDesktop]);
@@ -243,10 +244,16 @@ export function SessionSiteHeader({ sessionId, sessionTitle, isMobileView, leadi
243
244
  else
244
245
  errorToast(tPalette('copyFailed'));
245
246
  };
247
+ // The embed snippet left the Session access dialog (KRTX-4639): a developer
248
+ // affordance does not belong in a permissions dialog. Its one entry point is
249
+ // the Embed submenu in the session menu below, gated like the dialog's
250
+ // section was: the same `can_manage_sharing` server verdict, and the host
251
+ // serves public shares at all.
252
+ const canEmbed = isProjectSession && canManageSharing && publicSharesEnabled;
246
253
  const sessionActionItems = (_jsxs(_Fragment, { children: [isProjectSession && (_jsxs(_Fragment, { children: [canRename && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "cursor-pointer", onSelect: () => {
247
254
  renameFromMenu.current = true;
248
255
  startRename();
249
- }, children: [_jsx(PencilSimpleIcon, {}), tI18nHardcoded.raw('autoFeaturesSessionHeaderSessionSiteHeaderJsxTextRename41731a53')] }), _jsx(DropdownMenuSeparator, {})] })), canManageLifecycle && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: restartMutation.isPending, onClick: () => restartMutation.mutate(), children: [restartMutation.isPending ? _jsx(Loading, {}) : _jsx(RotateCcw, {}), tI18nHardcoded.raw('i18nComplete.text6b983a81e5e8')] }), _jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: reloadConfig.isPending, onClick: () => reloadConfig.reload(), children: [reloadConfig.isPending ? _jsx(Loading, {}) : _jsx(ArrowsClockwiseIcon, {}), tI18nHardcoded.raw('i18nComplete.textb4b21a20cc58')] }), canStop && (_jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: stopMutation.isPending, onClick: () => stopMutation.mutate(), children: [stopMutation.isPending ? _jsx(Loading, {}) : _jsx(Square, {}), tI18nHardcoded.raw('i18nComplete.textcae7d57bc067')] })), _jsx(DropdownMenuSeparator, {})] }))] })), isProjectSession && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => copyValue(tPalette('copySessionId'), projectSessionId), children: [_jsx(Copy, {}), tPalette('copyAction', { label: tPalette('copySessionId') })] }), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => copyValue(tPalette('copySessionLink'), window.location.href), children: [_jsx(LinkSimpleIcon, {}), tPalette('copyAction', { label: tPalette('copySessionLink') })] }), watching !== undefined && (_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: toggleWatch, children: [watching ? _jsx(BellSlashIcon, {}) : _jsx(BellIcon, {}), watching ? tNotifications('session.mute') : tNotifications('session.unmute')] })), listState && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => void listActions.setPinned(projectSessionId, !listState.pinned), children: [listState.pinned ? _jsx(PushPinSlashIcon, {}) : _jsx(PushPinIcon, {}), tPinArchive(listState.pinned ? 'unpin' : 'pin')] }), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => void listActions.setArchived(projectSessionId, !listState.archived), children: [_jsx(ArchiveIcon, {}), tPinArchive(listState.archived ? 'unarchive' : 'archive')] })] })), canFork && (_jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: forkSession.isPending, onClick: () => forkSession.mutate({ sessionId: projectSessionId }, {
256
+ }, children: [_jsx(PencilSimpleIcon, {}), tI18nHardcoded.raw('autoFeaturesSessionHeaderSessionSiteHeaderJsxTextRename41731a53')] }), _jsx(DropdownMenuSeparator, {})] })), canManageLifecycle && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: restartMutation.isPending, onClick: () => restartMutation.mutate(), children: [restartMutation.isPending ? _jsx(Loading, {}) : _jsx(RotateCcw, {}), tI18nHardcoded.raw('i18nComplete.text6b983a81e5e8')] }), _jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: reloadConfig.isPending, onClick: () => reloadConfig.reload(), children: [reloadConfig.isPending ? _jsx(Loading, {}) : _jsx(ArrowsClockwiseIcon, {}), tI18nHardcoded.raw('i18nComplete.textb4b21a20cc58')] }), canStop && (_jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: stopMutation.isPending, onClick: () => stopMutation.mutate(), children: [stopMutation.isPending ? _jsx(Loading, {}) : _jsx(Square, {}), tI18nHardcoded.raw('i18nComplete.textcae7d57bc067')] })), _jsx(DropdownMenuSeparator, {})] }))] })), isProjectSession && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => copyValue(tPalette('copySessionId'), projectSessionId), children: [_jsx(Copy, {}), tPalette('copyAction', { label: tPalette('copySessionId') })] }), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => copyValue(tPalette('copySessionLink'), window.location.href), children: [_jsx(LinkSimpleIcon, {}), tPalette('copyAction', { label: tPalette('copySessionLink') })] }), canEmbed && projectId && projectSessionId && (_jsx(SessionEmbedMenuItem, { projectId: projectId, sessionId: projectSessionId })), watching !== undefined && (_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: toggleWatch, children: [watching ? _jsx(BellSlashIcon, {}) : _jsx(BellIcon, {}), watching ? tNotifications('session.mute') : tNotifications('session.unmute')] })), listState && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => void listActions.setPinned(projectSessionId, !listState.pinned), children: [listState.pinned ? _jsx(PushPinSlashIcon, {}) : _jsx(PushPinIcon, {}), tPinArchive(listState.pinned ? 'unpin' : 'pin')] }), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => void listActions.setArchived(projectSessionId, !listState.archived), children: [_jsx(ArchiveIcon, {}), tPinArchive(listState.archived ? 'unarchive' : 'archive')] })] })), canFork && (_jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: forkSession.isPending, onClick: () => forkSession.mutate({ sessionId: projectSessionId }, {
250
257
  onSuccess: (fork) => {
251
258
  successToast(tI18nHardcoded.raw('i18nComplete.text95de71e25038'));
252
259
  if (projectId && projectSessionId) {
@@ -1,7 +1,13 @@
1
+ import { type ComponentProps } from 'react';
2
+ import { Button } from '../../primitives/button.js';
1
3
  /**
2
4
  * KRTX-1718: the member's way to tell an owner, from where they are blocked.
3
5
  * Emails every owner; the API takes one request per member a day (429 after).
4
6
  */
5
- export declare function AskOwnerForCreditsButton({ accountId }: {
7
+ export declare function AskOwnerForCreditsButton({ accountId, variant, size, className, }: {
6
8
  accountId: string;
9
+ /** Defaults to the banner's outline `sm`; the out-of-credits modal makes it its primary action. */
10
+ variant?: ComponentProps<typeof Button>['variant'];
11
+ size?: ComponentProps<typeof Button>['size'];
12
+ className?: string;
7
13
  }): import("react").JSX.Element;
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useState } from 'react';
4
4
  import { Button } from '../../primitives/button.js';
5
+ import { cn } from '../../lib/utils.js';
5
6
  import Loading from '../../primitives/loading.js';
6
7
  import { useTranslations } from '../../i18n/index.js';
7
8
  import { requestTopUp } from '@kortix/sdk';
@@ -9,7 +10,7 @@ import { requestTopUp } from '@kortix/sdk';
9
10
  * KRTX-1718: the member's way to tell an owner, from where they are blocked.
10
11
  * Emails every owner; the API takes one request per member a day (429 after).
11
12
  */
12
- export function AskOwnerForCreditsButton({ accountId }) {
13
+ export function AskOwnerForCreditsButton({ accountId, variant = 'outline', size = 'sm', className, }) {
13
14
  const tHardcodedUi = useTranslations('hardcodedUi');
14
15
  const [state, setState] = useState('idle');
15
16
  const label = state === 'asked'
@@ -29,5 +30,5 @@ export function AskOwnerForCreditsButton({ accountId }) {
29
30
  setState(err?.status === 429 ? 'already' : 'failed');
30
31
  }
31
32
  };
32
- return (_jsxs(Button, { variant: "outline", size: "sm", className: "active:scale-[0.96]", disabled: state === 'asking' || state === 'asked' || state === 'already', onClick: () => void ask(), children: [state === 'asking' ? _jsx(Loading, { className: "size-3.5 shrink-0" }) : null, tHardcodedUi.raw(`componentsSessionSessionErrorBanner.${label}`)] }));
33
+ return (_jsxs(Button, { variant: variant, size: size, className: cn('active:scale-[0.96]', className), disabled: state === 'asking' || state === 'asked' || state === 'already', onClick: () => void ask(), children: [state === 'asking' ? _jsx(Loading, { className: "size-3.5 shrink-0" }) : null, tHardcodedUi.raw(`componentsSessionSessionErrorBanner.${label}`)] }));
33
34
  }
@@ -44,6 +44,7 @@ import { ProjectFilesProvider } from '../../files/project/context.js';
44
44
  import { useOptionalSessionPanel } from '../panel/session-panel-provider.js';
45
45
  import { COMPOSER_SHELL_CLASS, Composer as SessionChatInput, } from '../composer/composer.js';
46
46
  import { ComposerDropZone } from '../composer/composer-drop-zone.js';
47
+ import { useSessionComposerCall } from '../voice/composer-call.js';
47
48
  import { AgentsLine } from '../agents/agent-strip.js';
48
49
  import { HeldMessages } from '../agents/held-messages.js';
49
50
  import { SessionPromptContext } from '../agents/session-prompt.js';
@@ -606,6 +607,15 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
606
607
  });
607
608
  const composerAgentName = composerAgent.selected;
608
609
  const noAccessibleAgents = composerAgent.disabled;
610
+ // Nothing typed: the Send button calls this session instead (flag
611
+ // `voice_call`, `voice/composer-call.ts`). Its agent answers here, so the
612
+ // call's turns fill this chat. Not a sub-session: its box binds no relay.
613
+ const composerCall = useSessionComposerCall({
614
+ projectId,
615
+ sessionId: projectSessionId,
616
+ agent: projectSessionRow?.agent_name ?? composerAgentName,
617
+ topLevel: !!projectSessionRow && !projectSessionRow.parent_session_id,
618
+ });
609
619
  // The slash menu lists only the commands the composer's agent may run. The
610
620
  // transcript keeps the full list: a past turn may have run any of them.
611
621
  const { data: agentCommands } = useRuntimeCommands({ agent: composerAgentName ?? undefined });
@@ -4001,7 +4011,7 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
4001
4011
  // A thread panel's rows run `px-5`, and the channel composer
4002
4012
  // beside it sits `pb-4` off the window's bottom edge: the same
4003
4013
  // margins, so the two boxes line up.
4004
- parentClassName: transcriptRows ? 'max-w-none px-5 pb-4' : undefined, onNoticeRetry: composerReadiness.notice && composerReadiness.retryable
4014
+ parentClassName: transcriptRows ? 'max-w-none px-5 pb-4' : undefined, call: composerCall, onNoticeRetry: composerReadiness.notice && composerReadiness.retryable
4005
4015
  ? requestRuntimeReconnect
4006
4016
  : undefined }), _jsx("div", { className: cn(COMPOSER_SHELL_CLASS, 'pb-3 empty:hidden', transcriptRows && 'max-w-none px-5'), children: _jsx(HeldMessages, { projectId: projectId, sessionId: projectSessionId }) })] }))] })] }) }) }) }) }));
4007
4017
  }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The voice call an empty composer offers in Send's place, as a phone's chat app does: with a draft the button sends
3
+ * it, with none it calls. `SendStopControl` draws it; a host that passes none keeps the plain Send. The call itself
4
+ * runs in the call card (voice-call-card.tsx, in the project shell), wherever the person goes in the project.
5
+ */
6
+ export interface ComposerCall {
7
+ /** Places the call. */
8
+ onCall: () => void;
9
+ /** A call is in progress already. One microphone, one call: the button stays, disabled, and says so. */
10
+ inCall: boolean;
11
+ }
12
+ /**
13
+ * Whether this project may place a voice call from here: the project's `voice_call` flag is on, the host mounts a
14
+ * call card to run it (`VoiceCallCard`: apps/web's project shell does, a white-label host may not), and the page is
15
+ * not the desktop shell, whose signed app has no microphone entitlement yet (apps/desktop-electron).
16
+ */
17
+ export declare function useVoiceCallsEnabled(projectId: string | undefined): boolean;
18
+ /**
19
+ * A call with the session `sessionId` from its own composer. The session's agent answers in this same chat: the
20
+ * box's voice relay binds every top-level session under its Kortix session id (packages/voice), so the call's turns
21
+ * are this session's turns. A sub-session (`topLevel: false`) has no relay and gets no call.
22
+ *
23
+ * `agent` names the call card's mark and name; the relay answers as the session's own agent either way.
24
+ */
25
+ export declare function useSessionComposerCall({ projectId, sessionId, agent, topLevel, }: {
26
+ projectId: string | undefined;
27
+ /** The Kortix session id (`project_sessions.session_id`), never a runtime conversation id. */
28
+ sessionId: string | undefined;
29
+ agent: string | null | undefined;
30
+ topLevel?: boolean;
31
+ }): ComposerCall | undefined;
@@ -0,0 +1,46 @@
1
+ 'use client';
2
+ import { platformConfig } from '@kortix/sdk';
3
+ import { useFeatureFlag } from '@kortix/sdk/react';
4
+ import { useMemo } from 'react';
5
+ import { useProjectCanRun } from '../../internal/hooks/projects/use-project-can-run.js';
6
+ import { isDesktop } from '../../internal/lib/desktop-detect.js';
7
+ import { useUpgradeDialogStore } from '../../internal/stores/upgrade-dialog-store.js';
8
+ import { useVoiceCallStore } from './voice-call-store.js';
9
+ /**
10
+ * Whether this project may place a voice call from here: the project's `voice_call` flag is on, the host mounts a
11
+ * call card to run it (`VoiceCallCard`: apps/web's project shell does, a white-label host may not), and the page is
12
+ * not the desktop shell, whose signed app has no microphone entitlement yet (apps/desktop-electron).
13
+ */
14
+ export function useVoiceCallsEnabled(projectId) {
15
+ const { enabled } = useFeatureFlag(projectId ?? null, 'voice_call');
16
+ const runnable = useVoiceCallStore((s) => s.cards > 0);
17
+ return enabled && runnable && !!projectId && !isDesktop();
18
+ }
19
+ /**
20
+ * A call with the session `sessionId` from its own composer. The session's agent answers in this same chat: the
21
+ * box's voice relay binds every top-level session under its Kortix session id (packages/voice), so the call's turns
22
+ * are this session's turns. A sub-session (`topLevel: false`) has no relay and gets no call.
23
+ *
24
+ * `agent` names the call card's mark and name; the relay answers as the session's own agent either way.
25
+ */
26
+ export function useSessionComposerCall({ projectId, sessionId, agent, topLevel = true, }) {
27
+ const enabled = useVoiceCallsEnabled(projectId);
28
+ const inCall = useVoiceCallStore((s) => !!s.call);
29
+ const { canRun, isLoading: billingLoading, accountId } = useProjectCanRun(enabled ? projectId : undefined);
30
+ const openUpgradeDialog = useUpgradeDialogStore((s) => s.openUpgradeDialog);
31
+ return useMemo(() => {
32
+ if (!enabled || !projectId || !sessionId || !agent || !topLevel)
33
+ return undefined;
34
+ return {
35
+ inCall,
36
+ onCall: () => {
37
+ // The gate Start session and the agent page's Call apply: a call runs billed turns.
38
+ if (platformConfig().billingEnabled && !billingLoading && !canRun) {
39
+ openUpgradeDialog({ reason: 'subscription_required', accountId });
40
+ return;
41
+ }
42
+ useVoiceCallStore.getState().place({ projectId, sessionId, agent });
43
+ },
44
+ };
45
+ }, [enabled, projectId, sessionId, agent, topLevel, inCall, billingLoading, canRun, openUpgradeDialog, accountId]);
46
+ }
@@ -29,6 +29,8 @@ const ENDED = {
29
29
  */
30
30
  export function VoiceCallCard() {
31
31
  const call = useVoiceCallStore((s) => s.call);
32
+ // Mounted, this host can run a call: the call controls show (`useVoiceCallsEnabled`).
33
+ useEffect(() => useVoiceCallStore.getState().mountCard(), []);
32
34
  if (!call || isDesktop())
33
35
  return null;
34
36
  return _jsx(PlacedCall, { call: call }, call.sessionId);
@@ -14,9 +14,17 @@ export interface ActiveCall {
14
14
  */
15
15
  interface VoiceCallStore {
16
16
  call: ActiveCall | null;
17
+ /**
18
+ * How many call cards are mounted. A call runs only in a card, and only a host that mounts one (apps/web's project
19
+ * shell) can run it: with none, no control offers a call (`useVoiceCallsEnabled`), so a placed call is never left
20
+ * with nothing to ring it.
21
+ */
22
+ cards: number;
17
23
  place: (call: Omit<ActiveCall, 'placedAt'>) => void;
18
24
  /** Ends the call (only that session's, when one is named). */
19
25
  end: (sessionId?: string) => void;
26
+ /** A call card mounted; the returned function unmounts it. */
27
+ mountCard: () => () => void;
20
28
  }
21
29
  export declare const useVoiceCallStore: import("zustand").UseBoundStore<import("zustand").StoreApi<VoiceCallStore>>;
22
30
  export {};
@@ -2,9 +2,14 @@
2
2
  import { create } from 'zustand';
3
3
  export const useVoiceCallStore = create()((set, get) => ({
4
4
  call: null,
5
+ cards: 0,
5
6
  place: (call) => set({ call: { ...call, placedAt: Date.now() } }),
6
7
  end: (sessionId) => {
7
8
  if (!sessionId || get().call?.sessionId === sessionId)
8
9
  set({ call: null });
9
10
  },
11
+ mountCard: () => {
12
+ set((s) => ({ cards: s.cards + 1 }));
13
+ return () => set((s) => ({ cards: s.cards - 1 }));
14
+ },
10
15
  }));
@@ -2,8 +2,8 @@
2
2
  * The agent page's Call button (Customize → Agents → <agent>). A call is a session of its own on this agent: the
3
3
  * agent answers with its own instructions, tools and memory, and the call's transcript is that session's chat. The
4
4
  * page stays: the session is created here, with no navigation and no toast, and the call card (voice-call-card.tsx)
5
- * rings until its box answers. Only while the project's `voice_call` flag is on, and not in the desktop shell, whose
6
- * signed app has no microphone entitlement yet (apps/desktop-electron).
5
+ * rings until its box answers. Only where `useVoiceCallsEnabled` says so: the project's `voice_call` flag is on, the
6
+ * host mounts the call card, and the page is not the desktop shell (no microphone entitlement yet).
7
7
  */
8
8
  export declare function AgentCallButton({ projectId, agentName }: {
9
9
  projectId: string;