@kortix/ui 0.15.8 → 0.15.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/dist/_vendor/kortix-shared.js +75 -1
  2. package/dist/_vendor/shared/index.d.ts +1 -0
  3. package/dist/_vendor/shared/session/attachment-tile.d.ts +32 -0
  4. package/dist/_vendor/shared/session/stop-refusal.d.ts +15 -0
  5. package/dist/_vendor/shared/session/tool-row-text.d.ts +58 -0
  6. package/dist/_vendor/shared/session-delivery.d.ts +2 -0
  7. package/dist/access/access/access-dialog-share.js +12 -6
  8. package/dist/access/access/share-selection.d.ts +9 -0
  9. package/dist/access/access/share-selection.js +64 -0
  10. package/dist/customize/connectors/connector-identity.js +3 -3
  11. package/dist/customize/connectors/connectors-page.js +1 -1
  12. package/dist/customize/connectors/detail/app-page.js +2 -2
  13. package/dist/customize/connectors/detail/connector-accounts.d.ts +3 -1
  14. package/dist/customize/connectors/detail/connector-accounts.js +2 -2
  15. package/dist/customize/connectors/detail/connector-notice-view.d.ts +4 -0
  16. package/dist/customize/connectors/detail/connector-notice-view.js +4 -0
  17. package/dist/customize/connectors/detail/connector-notice.d.ts +31 -4
  18. package/dist/customize/connectors/detail/connector-notice.js +23 -4
  19. package/dist/customize/connectors/detail/connector-page.js +35 -10
  20. package/dist/customize/connectors/detail/connector-status.d.ts +12 -1
  21. package/dist/customize/connectors/detail/connector-status.js +11 -0
  22. package/dist/customize/connectors/detail/status-badge.d.ts +3 -3
  23. package/dist/customize/connectors/detail/status-badge.js +2 -1
  24. package/dist/customize/connectors/detail/use-connector-detail.js +10 -2
  25. package/dist/customize/connectors/detail/use-mcp-oauth-sign-in.d.ts +13 -0
  26. package/dist/customize/connectors/detail/use-mcp-oauth-sign-in.js +29 -0
  27. package/dist/customize/connectors/install/use-install.js +1 -1
  28. package/dist/customize/providers/provider-accordion.js +9 -8
  29. package/dist/customize/providers/provider-connect.d.ts +3 -3
  30. package/dist/customize/providers/provider-connect.js +10 -16
  31. package/dist/customize/providers/provider-sheet.js +13 -8
  32. package/dist/customize/sections/component/email-connect-form.js +4 -2
  33. package/dist/customize/sections/connector-connection-form.d.ts +0 -1
  34. package/dist/customize/sections/connector-connection-form.js +0 -9
  35. package/dist/customize/sections/connectors-view.d.ts +4 -1
  36. package/dist/customize/sections/connectors-view.js +42 -7
  37. package/dist/customize/sections/view/account-secret-resources-panel.d.ts +15 -0
  38. package/dist/customize/sections/view/account-secret-resources-panel.js +44 -5
  39. package/dist/customize/sections/view/review-center-connected.js +7 -3
  40. package/dist/customize/sections/view/secret-delivery.d.ts +9 -2
  41. package/dist/customize/sections/view/secret-delivery.js +14 -4
  42. package/dist/customize/sections/view/secrets-view.js +21 -5
  43. package/dist/customize/settings/tabs/workspace-keys.js +53 -11
  44. package/dist/customize/shared/feature-gate-screen.js +1 -1
  45. package/dist/customize/triggers/schedule/event-account-picker.js +1 -1
  46. package/dist/customize/triggers/schedule/schedule-builder.js +1 -1
  47. package/dist/customize/triggers/schedule/schedule-copy.js +4 -0
  48. package/dist/customize/triggers/schedule/schedule-detail-sheet.js +14 -3
  49. package/dist/customize/triggers/schedule/then-fields.d.ts +3 -1
  50. package/dist/customize/triggers/schedule/then-fields.js +8 -4
  51. package/dist/customize/triggers/schedule/trigger-composer.js +1 -1
  52. package/dist/customize/triggers/schedule/trigger-list.d.ts +3 -1
  53. package/dist/customize/triggers/schedule/trigger-list.js +18 -2
  54. package/dist/customize/triggers/schedule/trigger-runs-logic.js +4 -2
  55. package/dist/customize/triggers/schedule/trigger-runs-panel.js +4 -1
  56. package/dist/customize/triggers/schedule/use-event-app-connect.js +2 -1
  57. package/dist/files/renderers/pptx-renderer.js +5 -20
  58. package/dist/files/renderers/presentation/FullScreenPresentationViewer.d.ts +3 -2
  59. package/dist/files/renderers/presentation/FullScreenPresentationViewer.js +23 -304
  60. package/dist/files/renderers/presentation/presentation-export-menu.d.ts +14 -0
  61. package/dist/files/renderers/presentation/presentation-export-menu.js +44 -0
  62. package/dist/files/renderers/presentation/presentation-utils.d.ts +1 -0
  63. package/dist/files/renderers/presentation/presentation-utils.js +4 -0
  64. package/dist/files/renderers/presentation/slide-iframe.d.ts +23 -0
  65. package/dist/files/renderers/presentation/slide-iframe.js +61 -0
  66. package/dist/files/renderers/presentation/use-presentation-metadata.d.ts +39 -0
  67. package/dist/files/renderers/presentation/use-presentation-metadata.js +137 -0
  68. package/dist/files/renderers/presentation/use-slide-navigation.d.ts +17 -0
  69. package/dist/files/renderers/presentation/use-slide-navigation.js +82 -0
  70. package/dist/files/renderers/shared/use-stage-fit-scale.d.ts +19 -0
  71. package/dist/files/renderers/shared/use-stage-fit-scale.js +41 -0
  72. package/dist/files/renderers/show-content-renderer.js +16 -11
  73. package/dist/files/renderers/xlsx/xlsx-renderer.d.ts +4 -13
  74. package/dist/files/renderers/xlsx/xlsx-renderer.js +6 -63
  75. package/dist/files/renderers/xlsx/xlsx-viewer.d.ts +4 -2
  76. package/dist/files/renderers/xlsx/xlsx-viewer.js +28 -34
  77. package/dist/files/viewer/file-content-renderer.js +1 -4
  78. package/dist/files/viewer/use-file-content-state.js +10 -9
  79. package/dist/i18n/en.d.ts +55 -7
  80. package/dist/i18n/en.js +59 -11
  81. package/dist/internal/billing/compute-pricing.d.ts +7 -1
  82. package/dist/internal/billing/compute-pricing.js +7 -1
  83. package/dist/internal/chrome/use-chrome-offered.d.ts +2 -1
  84. package/dist/internal/chrome/use-chrome-offered.js +4 -2
  85. package/dist/internal/hooks/connectors/invalidate-connections.d.ts +10 -0
  86. package/dist/internal/hooks/connectors/invalidate-connections.js +18 -0
  87. package/dist/internal/hooks/connectors/use-finish-sign-in.d.ts +13 -0
  88. package/dist/internal/hooks/connectors/use-finish-sign-in.js +33 -0
  89. package/dist/internal/hooks/connectors/use-pipedream-connect-member.js +6 -1
  90. package/dist/internal/hooks/connectors/use-pipedream-connect-project.js +6 -1
  91. package/dist/internal/hooks/projects/use-new-project-session.d.ts +2 -0
  92. package/dist/internal/hooks/projects/use-new-project-session.js +4 -1
  93. package/dist/internal/hooks/use-review-session-summary.d.ts +1 -1
  94. package/dist/internal/hooks/use-review-session-summary.js +1 -1
  95. package/dist/internal/lib/browser-noise/rules/injected-scripts.js +2 -2
  96. package/dist/internal/lib/error-handler.js +33 -0
  97. package/dist/internal/lib/trigger-clock.d.ts +7 -2
  98. package/dist/internal/lib/trigger-clock.js +17 -3
  99. package/dist/internal/notifications/notification-inbox.d.ts +4 -10
  100. package/dist/internal/notifications/notification-inbox.js +8 -9
  101. package/dist/internal/stores/connector-gate-store.d.ts +3 -1
  102. package/dist/internal/stores/connector-gate-store.js +13 -3
  103. package/dist/internal/stores/upgrade-dialog-store.d.ts +4 -0
  104. package/dist/internal/stores/upgrade-dialog-store.js +2 -0
  105. package/dist/lib/routes.d.ts +4 -11
  106. package/dist/lib/routes.js +3 -5
  107. package/dist/lib/z-stack.d.ts +5 -1
  108. package/dist/lib/z-stack.js +12 -2
  109. package/dist/markdown/unified-markdown-utils.d.ts +7 -0
  110. package/dist/markdown/unified-markdown-utils.js +19 -0
  111. package/dist/markdown/unified-markdown.js +16 -3
  112. package/dist/primitives/alert-dialog.js +1 -1
  113. package/dist/primitives/dialog.js +3 -1
  114. package/dist/primitives/drawer.js +1 -1
  115. package/dist/primitives/modal.js +1 -1
  116. package/dist/primitives/preview-image.js +1 -1
  117. package/dist/primitives/sheet.js +1 -1
  118. package/dist/session/composer/ComposerCard.js +4 -2
  119. package/dist/session/composer/attachment-tile.d.ts +2 -26
  120. package/dist/session/composer/attachment-tile.js +3 -47
  121. package/dist/session/composer/composer-chat-input.d.ts +2 -1
  122. package/dist/session/composer/composer-chat-input.js +2 -2
  123. package/dist/session/composer/composer.d.ts +2 -0
  124. package/dist/session/composer/composer.js +5 -8
  125. package/dist/session/composer/draft/home-composer-focus-handoff.d.ts +7 -0
  126. package/dist/session/composer/draft/home-composer-focus-handoff.js +94 -0
  127. package/dist/session/composer/draft/use-composer-draft.d.ts +3 -1
  128. package/dist/session/composer/draft/use-composer-draft.js +22 -2
  129. package/dist/session/composer/editor/composer-editor.d.ts +4 -2
  130. package/dist/session/composer/editor/composer-editor.js +7 -3
  131. package/dist/session/composer/hooks/use-composer-focus.js +4 -2
  132. package/dist/session/index.d.ts +1 -0
  133. package/dist/session/index.js +1 -0
  134. package/dist/session/models/chatgpt-connection-button.js +5 -9
  135. package/dist/session/models/model-connection-gate.d.ts +2 -1
  136. package/dist/session/models/model-connection-gate.js +21 -5
  137. package/dist/session/models/model-connection-layout.d.ts +2 -0
  138. package/dist/session/models/model-connection-layout.js +4 -0
  139. package/dist/session/models/model-picker-panel.js +6 -2
  140. package/dist/session/models/model-selector.d.ts +1 -1
  141. package/dist/session/models/model-selector.js +9 -6
  142. package/dist/session/models/provider-key-action.d.ts +10 -0
  143. package/dist/session/models/provider-key-action.js +35 -0
  144. package/dist/session/models/provider-key-slot.d.ts +9 -0
  145. package/dist/session/models/provider-key-slot.js +19 -0
  146. package/dist/session/models/subscription-offer.d.ts +4 -0
  147. package/dist/session/models/subscription-offer.js +11 -3
  148. package/dist/session/overrides/session-overrides-toolbar.js +2 -4
  149. package/dist/session/prompts/ask-deck.d.ts +5 -1
  150. package/dist/session/prompts/ask-deck.js +15 -3
  151. package/dist/session/prompts/question-labels.d.ts +16 -0
  152. package/dist/session/prompts/question-labels.js +34 -0
  153. package/dist/session/prompts/question-prompt.js +6 -6
  154. package/dist/session/prompts/session-connect-prompt.d.ts +40 -0
  155. package/dist/session/prompts/session-connect-prompt.js +126 -0
  156. package/dist/session/status/provisioning-failure.d.ts +23 -2
  157. package/dist/session/status/provisioning-failure.js +53 -3
  158. package/dist/session/status/session-error-banner.d.ts +1 -1
  159. package/dist/session/status/session-error-banner.js +12 -4
  160. package/dist/session/status/stop-refusal.d.ts +6 -12
  161. package/dist/session/status/stop-refusal.js +6 -19
  162. package/dist/session/thread/agent-run-props.d.ts +19 -0
  163. package/dist/session/thread/agent-run-props.js +54 -0
  164. package/dist/session/thread/session-chat.js +34 -6
  165. package/dist/session/thread/transcript.d.ts +17 -1
  166. package/dist/session/thread/transcript.js +104 -16
  167. package/dist/session/tool/tools/bash-tool.d.ts +3 -52
  168. package/dist/session/tool/tools/bash-tool.js +3 -86
  169. package/dist/session/turn/answer-streaming.d.ts +21 -0
  170. package/dist/session/turn/answer-streaming.js +34 -0
  171. package/dist/session/turn/queued-prompt-bubbles.d.ts +5 -0
  172. package/dist/session/turn/queued-prompt-bubbles.js +12 -0
  173. package/dist/session/turn/turn-work-accordion.d.ts +3 -1
  174. package/dist/session/turn/turn-work-accordion.js +2 -2
  175. package/dist/styles.css +1 -1
  176. package/dist/test-utils/intl.d.ts +55 -7
  177. package/dist/workspace/home/first-chat.d.ts +7 -1
  178. package/dist/workspace/home/first-chat.js +12 -5
  179. package/dist/workspace/inbox/workspace-inbox.d.ts +6 -16
  180. package/dist/workspace/inbox/workspace-inbox.js +9 -51
  181. package/dist/workspace/layout/project-home.js +5 -11
  182. package/dist/workspace/layout/use-project-home-send.d.ts +2 -0
  183. package/dist/workspace/layout/use-project-home-send.js +29 -15
  184. package/dist/workspace/new/advanced-fields.d.ts +4 -1
  185. package/dist/workspace/new/advanced-fields.js +2 -2
  186. package/dist/workspace/new/workspace-name.d.ts +9 -0
  187. package/dist/workspace/new/workspace-name.js +20 -0
  188. package/dist/workspace/projects/session-starter.d.ts +6 -4
  189. package/dist/workspace/projects/session-starter.js +8 -14
  190. package/dist/workspace/review/review-center.d.ts +6 -2
  191. package/dist/workspace/review/review-center.js +45 -25
  192. package/dist/workspace/sidebar/workspace-menu-model.d.ts +3 -5
  193. package/dist/workspace/sidebar/workspace-menu-model.js +1 -1
  194. package/package.json +3 -7
  195. package/skills/kortix-ui/references/modules.md +1 -1
  196. package/dist/customize/connectors/invalidate-connections.d.ts +0 -2
  197. package/dist/customize/connectors/invalidate-connections.js +0 -4
  198. package/dist/internal/notifications/use-inbox-summary.d.ts +0 -17
  199. package/dist/internal/notifications/use-inbox-summary.js +0 -28
@@ -7,7 +7,7 @@ import { MODEL_SELECTOR_PROVIDER_IDS, ProviderLogo } from '../../internal/lib/pr
7
7
  import { cn } from '../../lib/utils.js';
8
8
  import { TRIGGER_CARET_CLASS, triggerVariants } from '../../primitives/trigger-variants.js';
9
9
  import { useProviderModalStore } from '../../internal/stores/provider-modal-store.js';
10
- import { useFeatureFlag, useModelAccess, useModelStore, } from '@kortix/sdk/react';
10
+ import { useModelAccess, useModelStore, } from '@kortix/sdk/react';
11
11
  import { CheckIcon as Check, CaretDownIcon as ChevronDown, CaretRightIcon as CaretRight, CreditCardIcon as CreditCard, KeyIcon as KeyRound, PlusIcon as Plus, SlidersHorizontalIcon as SlidersHorizontal, StarIcon as Star, } from '@phosphor-icons/react';
12
12
  import { useTranslations } from '../../i18n/index.js';
13
13
  import { useSessionIds } from '../../providers/session-ids.js';
@@ -164,13 +164,12 @@ export function ModelSelector({ models, selectedModel, onSelect, defaultControls
164
164
  const [toggledGroups, setToggledGroups] = useState(new Map());
165
165
  const { canConnectProvider, openConnectProvider, openUpgrade, modal: connectionModal, entitlementsPending, isSelectableModel, showUpgradeOption, } = useModelConnectionGate(models);
166
166
  const projectId = useSessionIds().projectId ?? null;
167
- // Bring your own ChatGPT subscription (pooled provider secrets). Any member
167
+ // Bring your own ChatGPT subscription. Any member
168
168
  // connects their own account from here; Customize is not needed. Hidden when
169
169
  // a manager disabled the ChatGPT provider for the project.
170
170
  const tPooled = useTranslations('pooledSecrets');
171
- const pooledSecrets = useFeatureFlag(projectId, 'pooled_provider_secrets');
172
171
  const { ProviderAccountsModal } = useUiComponents();
173
- const chatGptPossible = !!ProviderAccountsModal && offerProviderAccounts && !!projectId && pooledSecrets.enabled;
172
+ const chatGptPossible = !!ProviderAccountsModal && offerProviderAccounts && !!projectId;
174
173
  const modelAccess = useModelAccess(chatGptPossible ? projectId : null);
175
174
  const chatGptAvailable = chatGptPossible && !(modelAccess.data?.disabledProviders ?? []).includes('codex');
176
175
  const [chatGptOpen, setChatGptOpen] = useState(false);
@@ -189,6 +188,10 @@ export function ModelSelector({ models, selectedModel, onSelect, defaultControls
189
188
  m.modelID === availableSelectedModel?.modelID);
190
189
  // The pill names the model, never its plan suffix: "GPT-6 Luna", not "GPT-6 Luna (ChatGPT)".
191
190
  const displayName = (current && pickerModelName(current)) || unsetLabel || t('noModel');
191
+ const triggerLoading = !current && (modelsLoading || entitlementsPending);
192
+ const triggerLabel = triggerLoading
193
+ ? _jsx("span", { className: "bg-primary/10 inline-block h-3.5 w-20 animate-pulse rounded-md", "aria-hidden": "true" })
194
+ : displayName;
192
195
  // A subscription model names the login that pays for it: the picker grows a
193
196
  // subscription pane under the list (both appearances), so switching the
194
197
  // ChatGPT or Claude plan a turn runs on needs no trip to Customize.
@@ -383,10 +386,10 @@ export function ModelSelector({ models, selectedModel, onSelect, defaultControls
383
386
  // No hairlines in a host pane: the search is a filled field, groups part by space.
384
387
  '[&_[data-slot=command-input-wrapper]]:bg-muted [&_[data-slot=command-input-wrapper]]:mx-2 [&_[data-slot=command-input-wrapper]]:h-8 [&_[data-slot=command-input-wrapper]]:gap-2 [&_[data-slot=command-input-wrapper]]:rounded-md [&_[data-slot=command-input-wrapper]]:border-b-0 [&_[data-slot=command-input-wrapper]]:px-2.5', '[&_[data-slot=command-input]]:h-8 [&_[data-slot=command-input]]:text-sm', '[&_[data-slot=command-separator]]:hidden [&_[data-slot=command-group]]:py-1'), children: listBody }), subscriptionNode] })] }));
385
388
  }
386
- return (_jsxs(_Fragment, { children: [modals, _jsxs(CommandPopover, { open: disabled ? false : open, onOpenChange: (next) => !disabled && setOpen(next), children: [_jsx(CommandPopoverTrigger, { children: appearance === 'field' ? (_jsxs("button", { type: "button", disabled: disabled, className: cn(triggerVariants(), 'h-9 w-full'), children: [_jsx("span", { className: "truncate", children: displayName }), disabled ? null : _jsx(ChevronDown, { className: cn(TRIGGER_CARET_CLASS, 'size-4') })] })) : (_jsxs(Button, { type: "button", variant: triggerVariant, size: "sm",
389
+ return (_jsxs(_Fragment, { children: [modals, _jsxs(CommandPopover, { open: disabled ? false : open, onOpenChange: (next) => !disabled && setOpen(next), children: [_jsx(CommandPopoverTrigger, { children: appearance === 'field' ? (_jsxs("button", { type: "button", disabled: disabled, "aria-label": triggerLoading ? tModel('loading') : undefined, className: cn(triggerVariants(), 'h-9 w-full'), children: [_jsx("span", { className: "truncate", children: triggerLabel }), disabled ? null : _jsx(ChevronDown, { className: cn(TRIGGER_CARET_CLASS, 'size-4') })] })) : (_jsxs(Button, { type: "button", "aria-label": triggerLoading ? tModel('loading') : undefined, variant: triggerVariant, size: "sm",
387
390
  // `min-w-0 shrink`: in a narrow toolbar (a channel's thread panel) the
388
391
  // model name truncates; the controls beside it keep their width.
389
- className: cn('min-w-0 shrink rounded-lg hit-area-y-3', triggerVariant === 'ghost' && 'text-muted-foreground'), children: [_jsx("span", { className: cn('max-w-30 truncate', triggerLabelClassName), children: displayName }), showEffort && (_jsx("span", { className: "shrink-0", children: currentEffort ? effortLabel(currentEffort) : t('auto') })), _jsx(ChevronDown, { className: cn('duration-moderate size-3 transition-transform ease-out', open && 'rotate-180') })] })) }), _jsx(CommandPopoverContent, { side: "top", align: "start", sideOffset: 8, className: showEffort
392
+ className: cn('min-w-0 shrink rounded-lg hit-area-y-3', triggerVariant === 'ghost' && 'text-muted-foreground'), children: [_jsx("span", { className: cn('max-w-30 truncate', triggerLabelClassName), children: triggerLabel }), showEffort && (_jsx("span", { className: "shrink-0", children: currentEffort ? effortLabel(currentEffort) : t('auto') })), _jsx(ChevronDown, { className: cn('duration-moderate size-3 transition-transform ease-out', open && 'rotate-180') })] })) }), _jsx(CommandPopoverContent, { side: "top", align: "start", sideOffset: 8, className: showEffort
390
393
  ? 'w-[min(38rem,calc(100vw-1.5rem))]'
391
394
  : 'w-[min(28rem,calc(100vw-1.5rem))]', children: _jsxs("div", { className: "flex min-w-0 flex-col", children: [_jsx(ModelPickerPanel, { browseModels: browseModels, pickableModels: pickableModels, searchModels: visibleModels, search: search, onSearchChange: setSearch, searchRight: searchRight, selected: availableSelectedModel ?? null, onPick: handleSelect, isFavorite: pickerModelStore.isFavorite, setFavorite: pickerModelStore.setFavorite, loading: modelsLoading || entitlementsPending, emptyState: noModelsState, searchEmpty: searchEmptyState, onConnectChatGpt: chatGptAvailable ? handleOpenChatGpt : undefined, onForeignDialog: closePicker, connectLabel: tPooled('connect'), effort: showEffort
392
395
  ? {
@@ -0,0 +1,10 @@
1
+ import type { GatewayErrorDetails } from '@kortix/sdk';
2
+ /**
3
+ * The provider whose key a failed turn needs fixed in Models → Providers, or
4
+ * null. A resolution error names no provider (`provider: ''`), so the routed
5
+ * model names it. A Kortix-managed model (no provider prefix) never needs a key.
6
+ */
7
+ export declare function providerKeyFix(details: Pick<GatewayErrorDetails, 'code' | 'provider' | 'requestedModel' | 'resolvedModel' | 'upstreamStatus'> | null | undefined): {
8
+ providerId: string;
9
+ code: string;
10
+ } | null;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Gateway codes a person fixes on the provider's account in Models: no key,
3
+ * a key the provider refused, an expired provider login, a provider account
4
+ * with no funds (`providerClientErrorBody`, `resolve-candidates.ts`).
5
+ */
6
+ const FIXED_IN_MODELS = new Set([
7
+ 'provider_not_connected',
8
+ 'provider_key_rejected',
9
+ 'provider_reauth_required',
10
+ 'provider_payment_required',
11
+ ]);
12
+ /** Providers with their own fix: ChatGPT (`chatGptConnectionAction`) and Claude (`claudeConnectionAction`). */
13
+ const OWN_FIX = new Set(['codex', 'openai-codex', 'claude-agent']);
14
+ /** The provider a gateway model id names (`anthropic/claude-x` → `anthropic`), without OpenCode's `kortix/`. */
15
+ function providerOfModel(model) {
16
+ const id = (model ?? '').replace(/^kortix\//, '');
17
+ const slash = id.indexOf('/');
18
+ return slash > 0 ? id.slice(0, slash) : undefined;
19
+ }
20
+ /**
21
+ * The provider whose key a failed turn needs fixed in Models → Providers, or
22
+ * null. A resolution error names no provider (`provider: ''`), so the routed
23
+ * model names it. A Kortix-managed model (no provider prefix) never needs a key.
24
+ */
25
+ export function providerKeyFix(details) {
26
+ if (!details)
27
+ return null;
28
+ const code = details.code ?? (details.upstreamStatus === 401 || details.upstreamStatus === 403 ? 'provider_key_rejected' : undefined);
29
+ if (!code || !FIXED_IN_MODELS.has(code))
30
+ return null;
31
+ const providerId = details.provider || providerOfModel(details.resolvedModel ?? details.requestedModel);
32
+ if (!providerId || OWN_FIX.has(providerId) || providerId === 'kortix')
33
+ return null;
34
+ return { providerId, code };
35
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The fix for a turn that failed on a provider key: Models → Providers, open
3
+ * on that provider, where the key is added, replaced or checked. Renders on a
4
+ * project route only (`useModelConnectionGate`).
5
+ */
6
+ export declare function ProviderKeySlot({ providerId, className }: {
7
+ providerId: string;
8
+ className?: string;
9
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,19 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { PROVIDER_LABELS } from '../../internal/lib/provider-branding.js';
4
+ import { Button } from '../../primitives/button.js';
5
+ import { useTranslations } from '../../i18n/index.js';
6
+ import { useModelConnectionGate } from './use-model-connection-gate.js';
7
+ /**
8
+ * The fix for a turn that failed on a provider key: Models → Providers, open
9
+ * on that provider, where the key is added, replaced or checked. Renders on a
10
+ * project route only (`useModelConnectionGate`).
11
+ */
12
+ export function ProviderKeySlot({ providerId, className = 'mt-2 pl-7' }) {
13
+ const t = useTranslations('pooledSecrets');
14
+ const { canConnectProvider, openConnectProvider, modal } = useModelConnectionGate();
15
+ if (!canConnectProvider)
16
+ return null;
17
+ const name = PROVIDER_LABELS[providerId] ?? providerId;
18
+ return (_jsxs("div", { className: className, children: [modal, _jsx(Button, { size: "sm", className: "active:scale-[0.96]", onClick: () => openConnectProvider('providers', providerId), children: t('openProviderInModels', { provider: name }) })] }));
19
+ }
@@ -8,6 +8,10 @@
8
8
  * arrow under its send button (`pr-3.5`), so the host must place the rows at
9
9
  * the composer card's width.
10
10
  *
11
+ * Above the composer (`ModelConnectionLayoutContext`, first-chat home only)
12
+ * the two plans render as side-by-side bordered tiles, the plan on a second
13
+ * line, so they read as the first step rather than as suggestions.
14
+ *
11
15
  * `dismissible`: hovering a row swaps its arrow for a ✕ in the same slot. The ✕
12
16
  * hides that row for this project in this browser (`localStorage`). Only the
13
17
  * optional offer is dismissible; with no model at all there is nothing else to
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { useWorkspaceModels } from '@kortix/sdk/react';
4
- import { useState } from 'react';
4
+ import { useContext, useState } from 'react';
5
5
  import { useTranslations } from '../../i18n/index.js';
6
6
  import { Close } from '../../icons/close.js';
7
7
  import { SolidRightArrow } from '../../icons/solid-right-arrow.js';
@@ -9,6 +9,7 @@ import { ClaudeCode } from '../../internal/icons/claude-code.js';
9
9
  import { ProviderLogo } from '../../internal/lib/provider-branding.js';
10
10
  import { cn } from '../../internal/lib/utils.js';
11
11
  import { hasRunnableSubscriptionModel, isRunnableModel } from './model-availability.js';
12
+ import { ModelConnectionLayoutContext } from './model-connection-layout.js';
12
13
  import { useModelConnectionGate } from './use-model-connection-gate.js';
13
14
  const PLANS = [
14
15
  { providerId: 'openai', name: 'ChatGPT', labelKey: 'connectChatGpt', planKey: 'chatGptPlan' },
@@ -47,6 +48,10 @@ function writeDismissed(projectId, ids) {
47
48
  * arrow under its send button (`pr-3.5`), so the host must place the rows at
48
49
  * the composer card's width.
49
50
  *
51
+ * Above the composer (`ModelConnectionLayoutContext`, first-chat home only)
52
+ * the two plans render as side-by-side bordered tiles, the plan on a second
53
+ * line, so they read as the first step rather than as suggestions.
54
+ *
50
55
  * `dismissible`: hovering a row swaps its arrow for a ✕ in the same slot. The ✕
51
56
  * hides that row for this project in this browser (`localStorage`). Only the
52
57
  * optional offer is dismissible; with no model at all there is nothing else to
@@ -55,6 +60,7 @@ function writeDismissed(projectId, ids) {
55
60
  * `projectId` omitted: the gate reads the `[id]` route segment.
56
61
  */
57
62
  export function ConnectPlanRows({ projectId, dismissible, className, }) {
63
+ const above = useContext(ModelConnectionLayoutContext) === 'above';
58
64
  const t = useTranslations('sessionUi.modelGate');
59
65
  const { canConnectProvider, openConnectProvider, modal } = useModelConnectionGate(undefined, projectId === undefined ? undefined : { projectId });
60
66
  const [dismissed, setDismissed] = useState(() => dismissible ? readDismissed(projectId) : []);
@@ -65,9 +71,11 @@ export function ConnectPlanRows({ projectId, dismissible, className, }) {
65
71
  if (projectId)
66
72
  writeDismissed(projectId, next);
67
73
  };
68
- return (_jsxs(_Fragment, { children: [modal, canConnectProvider && plans.length > 0 ? (_jsx("div", { role: "group", "aria-label": t('offerTitle'), className: cn('flex flex-col', className), children: plans.map((plan) => (_jsxs("div", { className: "group relative", children: [_jsxs("button", { type: "button", onClick: () => openConnectProvider('providers', plan.providerId), className: "hover:bg-muted/60 focus-visible:ring-kortix-base flex w-full min-w-0 items-center gap-3 rounded-lg py-2 pr-3.5 pl-2.5 text-left transition-colors outline-none focus-visible:ring-[0.6px]", children: [plan.providerId === 'anthropic' ? (
74
+ return (_jsxs(_Fragment, { children: [modal, canConnectProvider && plans.length > 0 ? (_jsx("div", { role: "group", "aria-label": t('offerTitle'), className: cn(above ? 'grid grid-cols-1 gap-2 sm:grid-cols-2' : 'flex flex-col', className), children: plans.map((plan) => (_jsxs("div", { className: "group relative", children: [_jsxs("button", { type: "button", onClick: () => openConnectProvider('providers', plan.providerId), className: cn('hover:bg-muted/60 focus-visible:ring-kortix-base flex w-full min-w-0 items-center gap-3 rounded-lg pr-3.5 text-left transition-colors outline-none focus-visible:ring-[0.6px]',
75
+ // Above the composer: a bordered tile, the plan on a second line.
76
+ above ? 'border-border bg-popover border py-2.5 pl-3' : 'py-2 pl-2.5'), children: [plan.providerId === 'anthropic' ? (
69
77
  // Claude plans run through Claude Code, so the row shows its mark.
70
- _jsx(ClaudeCode, { className: "size-5 shrink-0" })) : (_jsx(ProviderLogo, { providerID: plan.providerId, size: "xs", className: "size-5 [&_img]:size-5" })), _jsx("span", { className: "text-foreground shrink-0 text-sm", children: t(plan.labelKey) }), _jsx("span", { className: "text-muted-foreground truncate text-sm", children: t(plan.planKey) }), _jsx(SolidRightArrow, { className: cn('text-muted-foreground ml-auto size-4 shrink-0 transition-opacity', dismissible && 'group-focus-within:opacity-0 group-hover:opacity-0') })] }), dismissible ? (
78
+ _jsx(ClaudeCode, { className: "size-5 shrink-0" })) : (_jsx(ProviderLogo, { providerID: plan.providerId, size: "xs", className: "size-5 [&_img]:size-5" })), above ? (_jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsx("span", { className: "text-foreground truncate text-sm leading-5", children: t(plan.labelKey) }), _jsx("span", { className: "text-muted-foreground truncate text-xs leading-4", children: t(plan.planKey) })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "text-foreground shrink-0 text-sm", children: t(plan.labelKey) }), _jsx("span", { className: "text-muted-foreground truncate text-sm", children: t(plan.planKey) })] })), _jsx(SolidRightArrow, { className: cn('text-muted-foreground ml-auto size-4 shrink-0 transition-opacity', dismissible && 'group-focus-within:opacity-0 group-hover:opacity-0') })] }), dismissible ? (
71
79
  // A sibling, not a child: a button cannot hold a button. It sits
72
80
  // over the arrow's slot — `w-11` is `pr-3.5` + the arrow +
73
81
  // `pr-3.5` — so the ✕ centres where the arrow was.
@@ -125,12 +125,11 @@ export function SessionOverridesToolbar({ projectId, sessionId, agentName, onCom
125
125
  const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
126
126
  const tPooled = useTranslations('pooledSecrets');
127
127
  const tScope = useTranslations('sessionScope');
128
- const pooledSecretsEnabled = useFeatureFlag(projectId, 'pooled_provider_secrets').enabled;
129
128
  const drivesEnabled = useFeatureFlag(projectId, 'drives').enabled;
130
129
  const tDrives = useTranslations('drives');
131
130
  // Drives mount when the sandbox is created: an unsent session has none.
132
131
  const sessionDrives = useSessionDrives(projectId, drivesEnabled ? sessionId : undefined);
133
- const providerPools = useSessionProviderSecretPools(pooledSecretsEnabled ? projectId : null, sessionId);
132
+ const providerPools = useSessionProviderSecretPools(projectId, sessionId);
134
133
  // `project.secret.read` is a manager-tier leaf. Without it the catalog reads
135
134
  // `unavailable`, and the row only ever said "Secret access is unavailable" —
136
135
  // an axis the viewer can neither see nor change. Drop it on a SETTLED denial;
@@ -291,7 +290,7 @@ export function SessionOverridesToolbar({ projectId, sessionId, agentName, onCom
291
290
  // card it showed. Credentials are not a session-minting decision: the agent
292
291
  // may use every account it is entitled to and names one at call time
293
292
  // (`kortix connectors call --account`, `accounts` to see them).
294
- if (pooledSecretsEnabled && managesSession && (!secretsDenied || (!!sessionId && providerPools.data?.can_edit === true)))
293
+ if (managesSession && (!secretsDenied || (!!sessionId && providerPools.data?.can_edit === true)))
295
294
  list.push(providerKeysRow(projectId, sessionId, providerPoolDraft, providerDrafts, providerPools.isError, providerPools.isLoading, saving, onProviderDraftChange, onProviderSecretPoolsChange, tPooled));
296
295
  list.push(sandboxRow(sandboxSlot, sandbox, tI18nComplete));
297
296
  if (sessionId && drivesEnabled) {
@@ -314,7 +313,6 @@ export function SessionOverridesToolbar({ projectId, sessionId, agentName, onCom
314
313
  controlsDisabled,
315
314
  draft,
316
315
  onChange,
317
- pooledSecretsEnabled,
318
316
  managesSession,
319
317
  providerPoolDraft,
320
318
  providerDrafts,
@@ -23,8 +23,12 @@ import { type ReactNode } from 'react';
23
23
  export declare const DECK_KINDS: ReadonlySet<SessionAsk['kind']>;
24
24
  /** The deck's order: oldest first, skipped asks after the rest. Pure; exported for tests. */
25
25
  export declare function deckOrder(asks: readonly SessionAsk[], skipped: readonly string[], hidden: ReadonlySet<string>): SessionAsk[];
26
- export declare function AskDeck({ projectId, onOpenSession, empty, paused, }: {
26
+ export declare function AskDeck({ projectId, onOpenSession, empty, paused, selectedAskId, onClearSelection, onHiddenAskIdsChange, onCurrentAskChange, }: {
27
27
  projectId: string;
28
+ selectedAskId?: string | null;
29
+ onClearSelection?: () => void;
30
+ onHiddenAskIdsChange?: (ids: ReadonlySet<string>) => void;
31
+ onCurrentAskChange?: (id: string | null) => void;
28
32
  /** The host shows something else over the deck: it draws nothing and its
29
33
  * keys answer nothing, but stays mounted so staged answers keep Undo. */
30
34
  paused?: boolean;
@@ -63,7 +63,7 @@ export function deckOrder(asks, skipped, hidden) {
63
63
  return a.asked_at < b.asked_at ? -1 : a.asked_at > b.asked_at ? 1 : 0;
64
64
  });
65
65
  }
66
- export function AskDeck({ projectId, onOpenSession, empty, paused = false, }) {
66
+ export function AskDeck({ projectId, onOpenSession, empty, paused = false, selectedAskId, onClearSelection, onHiddenAskIdsChange, onCurrentAskChange, }) {
67
67
  const t = useTranslations('hardcodedUi.askDeck');
68
68
  const queryClient = useQueryClient();
69
69
  const { data, isLoading, isError, refetch } = useSessionAsks(projectId);
@@ -71,9 +71,15 @@ export function AskDeck({ projectId, onOpenSession, empty, paused = false, }) {
71
71
  const [skipped, setSkipped] = useState([]);
72
72
  const staged = useRef(new Map());
73
73
  const [hidden, setHidden] = useState(new Set());
74
+ useEffect(() => {
75
+ onHiddenAskIdsChange?.(hidden);
76
+ }, [hidden, onHiddenAskIdsChange]);
74
77
  // Connector approvals keep the full parameter review in the inbox list below.
75
78
  const deck = useMemo(() => deckOrder((data?.asks ?? []).filter((ask) => DECK_KINDS.has(ask.kind)), skipped, hidden), [data, skipped, hidden]);
76
- const current = deck[0] ?? null;
79
+ const current = deck.find((ask) => ask.id === selectedAskId) ?? deck[0] ?? null;
80
+ useEffect(() => {
81
+ onCurrentAskChange?.(paused ? null : current?.id ?? null);
82
+ }, [current?.id, paused, onCurrentAskChange]);
77
83
  const send = useCallback(async (entry) => {
78
84
  staged.current.delete(entry.ask.id);
79
85
  try {
@@ -164,7 +170,13 @@ export function AskDeck({ projectId, onOpenSession, empty, paused = false, }) {
164
170
  return empty;
165
171
  return _jsx(EmptyState, { icon: CheckIcon, title: t('emptyTitle'), description: t('emptyDescription') });
166
172
  }
167
- return (_jsxs("section", { "aria-label": t('label'), className: "flex w-full flex-col gap-3", children: [_jsxs("div", { className: "text-muted-foreground flex items-center justify-between text-xs", children: [_jsx("span", { children: t('remaining', { count: deck.length }) }), _jsxs("span", { className: "hidden items-center gap-2 sm:flex", children: [_jsx(Kbd, { children: "\u2190" }), " ", t('no'), " ", _jsx(Kbd, { children: "\u2192" }), " ", t('yes'), " ", _jsx(Kbd, { children: "S" }), " ", t('skip')] })] }), _jsx(AskCard, { ask: current, onDecide: (verdict, answers) => decide(current, verdict, answers), onSkip: () => skip(current), onOpenSession: onOpenSession }, current.id)] }));
173
+ return (_jsxs("section", { "aria-label": t('label'), className: "flex w-full flex-col gap-3", children: [_jsxs("div", { className: "text-muted-foreground flex items-center justify-between text-xs", children: [_jsx("span", { children: t('remaining', { count: deck.length }) }), _jsxs("span", { className: "hidden items-center gap-2 sm:flex", children: [_jsx(Kbd, { children: "\u2190" }), " ", t('no'), " ", _jsx(Kbd, { children: "\u2192" }), " ", t('yes'), " ", _jsx(Kbd, { children: "S" }), " ", t('skip')] })] }), _jsx(AskCard, { ask: current, onDecide: (verdict, answers) => {
174
+ onClearSelection?.();
175
+ decide(current, verdict, answers);
176
+ }, onSkip: () => {
177
+ onClearSelection?.();
178
+ skip(current);
179
+ }, onOpenSession: onOpenSession }, current.id)] }));
168
180
  }
169
181
  /**
170
182
  * One ask, drawn exactly as the session draws it: the docked strip holds the
@@ -0,0 +1,16 @@
1
+ import type { QuestionInfo } from '../../internal/session-types/index.js';
2
+ /** A question's text as one plain line: the first non-empty line, markdown marks removed. */
3
+ export declare function questionPlainLine(question: string): string;
4
+ /**
5
+ * The label of each row on the Confirm tab, and whether the rows stack.
6
+ *
7
+ * A header labels its row only when no other question in the call shares it.
8
+ * An agent that gives every question the same header (the stage name, "You")
9
+ * would otherwise label every row "You". A row without a distinct header
10
+ * shows its question text instead, and then the rows stack (label above the
11
+ * answer), because a question does not fit the narrow label column.
12
+ */
13
+ export declare function confirmRowLabels(questions: Pick<QuestionInfo, 'header' | 'question'>[]): {
14
+ labels: string[];
15
+ stacked: boolean;
16
+ };
@@ -0,0 +1,34 @@
1
+ /** A question's text as one plain line: the first non-empty line, markdown marks removed. */
2
+ export function questionPlainLine(question) {
3
+ return (question
4
+ .replace(/[*_`#>]/g, '')
5
+ .split('\n')
6
+ .map((line) => line.trim())
7
+ .find(Boolean) ?? '');
8
+ }
9
+ /**
10
+ * The label of each row on the Confirm tab, and whether the rows stack.
11
+ *
12
+ * A header labels its row only when no other question in the call shares it.
13
+ * An agent that gives every question the same header (the stage name, "You")
14
+ * would otherwise label every row "You". A row without a distinct header
15
+ * shows its question text instead, and then the rows stack (label above the
16
+ * answer), because a question does not fit the narrow label column.
17
+ */
18
+ export function confirmRowLabels(questions) {
19
+ const counts = new Map();
20
+ for (const q of questions) {
21
+ const header = q.header?.trim().toLowerCase();
22
+ if (header)
23
+ counts.set(header, (counts.get(header) ?? 0) + 1);
24
+ }
25
+ let stacked = false;
26
+ const labels = questions.map((q) => {
27
+ const header = q.header?.trim() ?? '';
28
+ if (header && counts.get(header.toLowerCase()) === 1)
29
+ return header;
30
+ stacked = true;
31
+ return questionPlainLine(q.question) || header;
32
+ });
33
+ return { labels, stacked };
34
+ }
@@ -16,6 +16,7 @@ import React, { useCallback, useEffect, useImperativeHandle, useState } from 're
16
16
  import ReactMarkdown from 'react-markdown';
17
17
  import remarkGfm from 'remark-gfm';
18
18
  import { Close } from '../../icons/close.js';
19
+ import { confirmRowLabels, questionPlainLine } from './question-labels.js';
19
20
  // ---------------------------------------------------------------------------
20
21
  // Lightweight markdown renderer for question text (no Shiki/KaTeX/Mermaid)
21
22
  // ---------------------------------------------------------------------------
@@ -191,14 +192,13 @@ export const QuestionPrompt = React.forwardRef(function QuestionPrompt({ request
191
192
  : currentQuestion?.header?.trim() || '';
192
193
  const collapsedLabel = isConfirm
193
194
  ? stepLabel
194
- : (currentQuestion?.question ?? '')
195
- .replace(/[*_`#>]/g, '')
196
- .split('\n')[0]
197
- .trim() || stepLabel;
198
- return (_jsxs("div", { className: "relative isolate z-10 w-full", children: [_jsxs("div", { className: "flex w-full items-center gap-2 px-3 py-1 pr-1.5", children: [_jsxs("button", { type: "button", onClick: () => setCollapsed((c) => !c), "aria-expanded": !collapsed, "aria-controls": `${request.id}-panel`, className: "text-muted-foreground hover:text-foreground flex min-h-6 min-w-0 flex-1 cursor-pointer items-center gap-1.5 text-left text-xs transition-colors", children: [!isSingle && (_jsxs("span", { className: "shrink-0 tabular-nums", children: [Math.min(tab + 1, total), " / ", total] })), (collapsed ? collapsedLabel : stepLabel) && (_jsxs("span", { className: cn('min-w-0 truncate', collapsed && 'text-foreground'), children: [!isSingle && (_jsxs("span", { "aria-hidden": "true", className: "text-muted-foreground", children: ["\u00B7", ' '] })), collapsed ? collapsedLabel : stepLabel] })), _jsx(CaretDownIcon, { className: cn('duration-normal size-3 shrink-0 transition-transform ease-out motion-reduce:transition-none', collapsed && '-rotate-90') })] }), !isSingle && !collapsed && (_jsxs("div", { className: "flex shrink-0 items-center", children: [_jsx("button", { type: "button", onClick: () => setTab(tab - 1), disabled: tab === 0, "aria-label": tCommon('back'), className: "text-muted-foreground hover:text-foreground hover:bg-muted hit-area-2 inline-flex size-6 cursor-pointer items-center justify-center rounded-md transition-colors disabled:pointer-events-none disabled:opacity-30", children: _jsx(CaretLeftIcon, { className: "size-3.5" }) }), _jsx("button", { type: "button", onClick: advanceToNext, disabled: isConfirm || currentAnswers.length === 0, "aria-label": tCommon('next'), className: "text-muted-foreground hover:text-foreground hover:bg-muted hit-area-2 inline-flex size-6 cursor-pointer items-center justify-center rounded-md transition-colors disabled:pointer-events-none disabled:opacity-30", children: _jsx(CaretRightIcon, { className: "size-3.5" }) })] })), _jsx("button", { type: "button", onClick: reject, "aria-label": tI18nComplete.raw('text31d11513a187'), className: "text-muted-foreground hover:text-foreground hover:bg-muted hit-area-2 inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md transition-colors", children: _jsx(Close, { className: "size-3" }) })] }), _jsx("div", { className: cn('duration-normal grid transition-[grid-template-rows] ease-out motion-reduce:transition-none', collapsed ? 'grid-rows-[0fr]' : 'grid-rows-[1fr]'), children: _jsx("div", { id: `${request.id}-panel`, "aria-label": isSingle ? undefined : tI18nComplete.raw('text9a72221a2747'), inert: collapsed, className: cn('duration-normal min-h-0 overflow-y-auto px-px transition-opacity ease-out motion-reduce:transition-none', collapsed ? 'pb-0 opacity-0' : 'max-h-[420px] pb-1.5'), children: isConfirm ? (_jsx("div", { className: "flex flex-col", children: questions.map((q, i) => {
195
+ : questionPlainLine(currentQuestion?.question ?? '') || stepLabel;
196
+ const confirmRows = isConfirm ? confirmRowLabels(questions) : null;
197
+ return (_jsxs("div", { className: "relative isolate z-10 w-full", children: [_jsxs("div", { className: "flex w-full items-center gap-2 px-3 py-1 pr-1.5", children: [_jsxs("button", { type: "button", onClick: () => setCollapsed((c) => !c), "aria-expanded": !collapsed, "aria-controls": `${request.id}-panel`, className: "text-muted-foreground hover:text-foreground flex min-h-6 min-w-0 flex-1 cursor-pointer items-center gap-1.5 text-left text-xs transition-colors", children: [!isSingle && (_jsxs("span", { className: "shrink-0 tabular-nums", children: [Math.min(tab + 1, total), " / ", total] })), (collapsed ? collapsedLabel : stepLabel) && (_jsxs("span", { className: cn('min-w-0 truncate', collapsed && 'text-foreground'), children: [!isSingle && (_jsxs("span", { "aria-hidden": "true", className: "text-muted-foreground", children: ["\u00B7", ' '] })), collapsed ? collapsedLabel : stepLabel] })), _jsx(CaretDownIcon, { className: cn('duration-normal size-3 shrink-0 transition-transform ease-out motion-reduce:transition-none', collapsed && '-rotate-90') })] }), !isSingle && !collapsed && (_jsxs("div", { className: "flex shrink-0 items-center", children: [_jsx("button", { type: "button", onClick: () => setTab(tab - 1), disabled: tab === 0, "aria-label": tCommon('back'), className: "text-muted-foreground hover:text-foreground hover:bg-muted hit-area-2 inline-flex size-6 cursor-pointer items-center justify-center rounded-md transition-colors disabled:pointer-events-none disabled:opacity-30", children: _jsx(CaretLeftIcon, { className: "size-3.5" }) }), _jsx("button", { type: "button", onClick: advanceToNext, disabled: isConfirm || currentAnswers.length === 0, "aria-label": tCommon('next'), className: "text-muted-foreground hover:text-foreground hover:bg-muted hit-area-2 inline-flex size-6 cursor-pointer items-center justify-center rounded-md transition-colors disabled:pointer-events-none disabled:opacity-30", children: _jsx(CaretRightIcon, { className: "size-3.5" }) })] })), _jsx("button", { type: "button", onClick: reject, "aria-label": tI18nComplete.raw('text31d11513a187'), className: "text-muted-foreground hover:text-foreground hover:bg-muted hit-area-2 inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md transition-colors", children: _jsx(Close, { className: "size-3" }) })] }), _jsx("div", { className: cn('duration-normal grid transition-[grid-template-rows] ease-out motion-reduce:transition-none', collapsed ? 'grid-rows-[0fr]' : 'grid-rows-[1fr]'), children: _jsx("div", { id: `${request.id}-panel`, "aria-label": isSingle ? undefined : tI18nComplete.raw('text9a72221a2747'), inert: collapsed, className: cn('duration-normal min-h-0 overflow-y-auto px-px transition-opacity ease-out motion-reduce:transition-none', collapsed ? 'pb-0 opacity-0' : 'max-h-[420px] pb-1.5'), children: confirmRows ? (_jsx("div", { className: "flex flex-col", children: questions.map((_, i) => {
199
198
  const ans = answers[i] ?? [];
200
199
  const done = ans.length > 0;
201
- return (_jsxs("button", { type: "button", onClick: () => setTab(i), className: "hover:bg-muted/60 flex w-full cursor-pointer items-baseline gap-4 rounded-lg px-3 py-2 text-left transition-colors", children: [_jsx("span", { className: "text-muted-foreground w-28 shrink-0 truncate text-xs", children: q.header || q.question }), _jsx("span", { className: cn('min-w-0 flex-1 truncate text-sm', done ? 'text-foreground' : 'text-muted-foreground'), children: done ? ans.join(', ') : '—' })] }, i));
200
+ const label = confirmRows.labels[i];
201
+ return (_jsxs("button", { type: "button", onClick: () => setTab(i), className: cn('hover:bg-muted/60 flex w-full cursor-pointer rounded-lg px-3 py-2 text-left transition-colors', confirmRows.stacked ? 'flex-col gap-0.5' : 'items-baseline gap-4'), children: [_jsx("span", { title: label, className: cn('text-muted-foreground truncate text-xs', confirmRows.stacked ? 'w-full' : 'w-28 shrink-0'), children: label }), _jsx("span", { className: cn('min-w-0 flex-1 truncate text-sm', done ? 'text-foreground' : 'text-muted-foreground'), children: done ? ans.join(', ') : '—' })] }, i));
202
202
  }) })) : currentQuestion ? (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("div", { className: "text-foreground max-h-[300px] overflow-y-auto px-3 text-sm leading-relaxed font-medium", children: _jsx(QuestionMarkdown, { content: currentQuestion.question +
203
203
  (isMulti ? tI18nComplete.raw('text79139c621384') : '') }) }), _jsx("div", { className: "flex flex-col", children: options.map((opt, i) => {
204
204
  const isPicked = currentAnswerSet.has(opt.label);
@@ -0,0 +1,40 @@
1
+ /**
2
+ * In-session Connect card, docked above the composer beside
3
+ * `SessionApprovalPrompt` and `SessionAccessPrompt`.
4
+ *
5
+ * An agent runs `kortix connectors connect <app>` and stops: the sign-in it
6
+ * started is a raw provider link, and nothing in Kortix finished the
7
+ * connection when the person came back (2026-11-11). The API records which
8
+ * session asked on the account row (`requesting_session_id`); this card reads
9
+ * those rows (`listSessionConnectRequests`) and finishes each one through
10
+ * `connectionSignInSteps`: the window opens inside the click, the first request
11
+ * records a sign-in that already finished at the provider, and only an
12
+ * unfinished one goes to a new sign-in page. Finalize tells the session that
13
+ * asked, so the agent continues on its own.
14
+ *
15
+ * Shown: every request still to sign in, and each one that connected while
16
+ * this page was open ("Connected as …"). A request that was connected before
17
+ * the page loaded is history and stays hidden.
18
+ */
19
+ import { type SessionConnectRequest } from '@kortix/sdk';
20
+ /** Stable id of one request: its account row, or the connector on an older server. */
21
+ export declare function sessionConnectRequestKey(request: SessionConnectRequest): string;
22
+ /**
23
+ * The requests on screen: every pending one, plus those that connected after
24
+ * `seenPending` first saw them pending. Pure; exported for tests.
25
+ */
26
+ export declare function sessionConnectRequestsOnScreen(requests: readonly SessionConnectRequest[], seenPending: ReadonlySet<string>): SessionConnectRequest[];
27
+ export declare function SessionConnectPrompt({ projectId, sessionId, busy, onDockedChange, }: {
28
+ projectId: string;
29
+ sessionId: string;
30
+ /** The agent is running: poll faster, and read again when it stops. */
31
+ busy: boolean;
32
+ /** True while a card is on screen: the composer docks onto it. */
33
+ onDockedChange?: (docked: boolean) => void;
34
+ }): import("react").JSX.Element | null;
35
+ /** The card itself: one row per request. */
36
+ export declare function SessionConnectNotice({ requests, projectId, onSettled, }: {
37
+ requests: readonly SessionConnectRequest[];
38
+ projectId: string;
39
+ onSettled: () => void;
40
+ }): import("react").JSX.Element;
@@ -0,0 +1,126 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ /**
4
+ * In-session Connect card, docked above the composer beside
5
+ * `SessionApprovalPrompt` and `SessionAccessPrompt`.
6
+ *
7
+ * An agent runs `kortix connectors connect <app>` and stops: the sign-in it
8
+ * started is a raw provider link, and nothing in Kortix finished the
9
+ * connection when the person came back (2026-11-11). The API records which
10
+ * session asked on the account row (`requesting_session_id`); this card reads
11
+ * those rows (`listSessionConnectRequests`) and finishes each one through
12
+ * `connectionSignInSteps`: the window opens inside the click, the first request
13
+ * records a sign-in that already finished at the provider, and only an
14
+ * unfinished one goes to a new sign-in page. Finalize tells the session that
15
+ * asked, so the agent continues on its own.
16
+ *
17
+ * Shown: every request still to sign in, and each one that connected while
18
+ * this page was open ("Connected as …"). A request that was connected before
19
+ * the page loaded is history and stays hidden.
20
+ */
21
+ import { connectionSignInSteps, listSessionConnectRequests, } from '@kortix/sdk';
22
+ import { CheckIcon, PlugsConnectedIcon } from '@phosphor-icons/react';
23
+ import { useQuery } from '@tanstack/react-query';
24
+ import { useEffect, useRef, useState } from 'react';
25
+ import { useTranslations } from '../../i18n/index.js';
26
+ import { cn } from '../../lib/utils.js';
27
+ import { runConnectLinkFlow } from '../../internal/hooks/connectors/use-connect-link.js';
28
+ import { ConnectorAppMark } from '../../markdown/setup-links/connector-handshake.js';
29
+ import { Button } from '../../primitives/button.js';
30
+ import Loading from '../../primitives/loading.js';
31
+ import { errorToast } from '../../primitives/toast.js';
32
+ /** While the agent runs, a new request can land at any moment. */
33
+ const BUSY_POLL_MS = 8_000;
34
+ /** A card whose sign-in the person may finish in another tab. */
35
+ const PENDING_POLL_MS = 10_000;
36
+ /** Stable id of one request: its account row, or the connector on an older server. */
37
+ export function sessionConnectRequestKey(request) {
38
+ return request.connection_id ?? request.slug;
39
+ }
40
+ /**
41
+ * The requests on screen: every pending one, plus those that connected after
42
+ * `seenPending` first saw them pending. Pure; exported for tests.
43
+ */
44
+ export function sessionConnectRequestsOnScreen(requests, seenPending) {
45
+ return requests.filter((request) => !request.connected || seenPending.has(sessionConnectRequestKey(request)));
46
+ }
47
+ export function SessionConnectPrompt({ projectId, sessionId, busy, onDockedChange, }) {
48
+ const seenPending = useRef(new Set());
49
+ const query = useQuery({
50
+ queryKey: ['session-connect-requests', projectId, sessionId],
51
+ queryFn: () => listSessionConnectRequests(projectId, sessionId),
52
+ enabled: Boolean(projectId && sessionId),
53
+ staleTime: 2_000,
54
+ retry: false,
55
+ refetchOnWindowFocus: true,
56
+ refetchInterval: (state) => busy
57
+ ? BUSY_POLL_MS
58
+ : (state.state.data ?? []).some((request) => !request.connected)
59
+ ? PENDING_POLL_MS
60
+ : false,
61
+ });
62
+ const { refetch } = query;
63
+ // The agent stops right after it starts a sign-in: read once more then.
64
+ const wasBusy = useRef(busy);
65
+ useEffect(() => {
66
+ if (wasBusy.current && !busy)
67
+ void refetch();
68
+ wasBusy.current = busy;
69
+ }, [busy, refetch]);
70
+ const requests = query.data ?? [];
71
+ for (const request of requests) {
72
+ if (!request.connected)
73
+ seenPending.current.add(sessionConnectRequestKey(request));
74
+ }
75
+ const shown = sessionConnectRequestsOnScreen(requests, seenPending.current);
76
+ const docked = shown.length > 0;
77
+ useEffect(() => {
78
+ onDockedChange?.(docked);
79
+ }, [docked, onDockedChange]);
80
+ useEffect(() => () => onDockedChange?.(false), [onDockedChange]);
81
+ if (!docked)
82
+ return null;
83
+ return (_jsx(SessionConnectNotice, { requests: shown, projectId: projectId, onSettled: () => void refetch() }));
84
+ }
85
+ /** The card itself: one row per request. */
86
+ export function SessionConnectNotice({ requests, projectId, onSettled, }) {
87
+ const t = useTranslations('connectSignIn');
88
+ const allConnected = requests.every((request) => request.connected);
89
+ return (
90
+ // `w-full`, or the composer's `items-center` strip shrinks this to its content width.
91
+ _jsxs("div", { className: "relative isolate z-10 w-full", "data-testid": "session-connect-prompt", children: [_jsxs("div", { className: "text-muted-foreground flex min-h-6 items-center gap-1.5 px-3 py-1 text-xs", children: [_jsx(PlugsConnectedIcon, { className: cn('size-3.5 shrink-0', allConnected ? 'text-kortix-green' : 'text-kortix-orange') }), _jsx("span", { className: "min-w-0 truncate", children: allConnected ? t('signInFinished') : t('cardHeadline') })] }), _jsx("ul", { className: "flex flex-col gap-1 px-3 pt-0.5 pb-2.5", children: requests.map((request) => (_jsx(SessionConnectRow, { request: request, projectId: projectId, onSettled: onSettled }, sessionConnectRequestKey(request)))) })] }));
92
+ }
93
+ function SessionConnectRow({ request, projectId, onSettled, }) {
94
+ const t = useTranslations('connectSignIn');
95
+ const [phase, setPhase] = useState('idle');
96
+ const name = request.name?.trim() || request.app || request.slug;
97
+ const shared = request.owner_type === 'project';
98
+ const connect = async () => {
99
+ if (!request.connection_id)
100
+ return;
101
+ setPhase('waiting');
102
+ try {
103
+ const steps = connectionSignInSteps(projectId, request.slug, {
104
+ connection_id: request.connection_id,
105
+ owner_type: request.owner_type ?? 'member',
106
+ });
107
+ await runConnectLinkFlow(steps.start, steps.finalize);
108
+ }
109
+ catch (error) {
110
+ errorToast(error instanceof Error && error.message ? error.message : t('cardFailed', { app: name }));
111
+ }
112
+ finally {
113
+ setPhase('idle');
114
+ onSettled();
115
+ }
116
+ };
117
+ return (_jsxs("li", { className: "border-border flex min-w-0 items-center gap-3 rounded-sm border px-3 py-2", "data-testid": "session-connect-row", "data-connected": request.connected || undefined, children: [_jsx(ConnectorAppMark, { name: name, slug: request.slug, iconUrl: `https://logos.composio.dev/api/${encodeURIComponent(request.app || request.slug)}`, size: "md" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("p", { className: "text-foreground truncate text-sm font-medium", children: t('cardTitle', { app: name }) }), _jsx("p", { className: "text-muted-foreground truncate text-xs", children: request.connected
118
+ ? request.connected_as
119
+ ? t('connectedAs', { account: request.connected_as })
120
+ : t('connected')
121
+ : phase === 'waiting'
122
+ ? t('signingIn', { app: name })
123
+ : shared
124
+ ? t('cardShared')
125
+ : t('cardPrivate') })] }), request.connected ? (_jsx(CheckIcon, { weight: "bold", className: "text-kortix-green size-4 shrink-0", "aria-label": t('connected') })) : (_jsxs(Button, { type: "button", size: "sm", className: "shrink-0", disabled: phase === 'waiting' || !request.connection_id, onClick: () => void connect(), children: [phase === 'waiting' ? _jsx(Loading, { className: "size-4 shrink-0" }) : null, t('connect')] }))] }));
126
+ }
@@ -1,5 +1,5 @@
1
1
  import type { UiTranslator } from '../../i18n/index.js';
2
- import type { PendingSessionPrompt } from '@kortix/sdk';
2
+ import type { PendingSessionPrompt, SessionPrompt } from '@kortix/sdk';
3
3
  interface ProvisioningFailurePresentation {
4
4
  title: string;
5
5
  message: string;
@@ -19,6 +19,14 @@ export declare function pendingSessionPromptFromMetadata(metadata: Record<string
19
19
  */
20
20
  export interface RecoveryPrompt extends PendingSessionPrompt {
21
21
  redeliveredOnRestart: boolean;
22
+ /** Set when the prompt is a durable inbox row. The server owns its
23
+ * delivery: a queued row runs once the box is up, and a `failed` row
24
+ * (dead-lettered after the box stayed unreachable) waits for a retry of
25
+ * THAT row. Retry never POSTs it again. */
26
+ inboxPrompt?: {
27
+ promptId: string;
28
+ failed: boolean;
29
+ };
22
30
  }
23
31
  /**
24
32
  * The recovery copy, from the server when it has one and from this tab's start
@@ -33,11 +41,24 @@ export interface RecoveryPrompt extends PendingSessionPrompt {
33
41
  * created has neither: its first prompt is `metadata.initial_prompt`. That
34
42
  * prompt is shown only while `runtimeSessionId` is empty, which is the same
35
43
  * condition under which the restart re-delivers it.
44
+ *
45
+ * `inboxPrompts` is `GET .../prompts`. A session the current API created keeps
46
+ * its first prompt ONLY there, so it answers before the start stash: the stash
47
+ * is a client-delivered copy, and posting it beside the server's own row sent
48
+ * the prompt twice.
36
49
  */
37
- export declare function pendingSessionPromptForRecovery(sessionId: string, metadata: Record<string, unknown> | null | undefined, runtimeSessionId?: string | null): RecoveryPrompt | null;
50
+ export declare function pendingSessionPromptForRecovery(sessionId: string, metadata: Record<string, unknown> | null | undefined, runtimeSessionId?: string | null, inboxPrompts?: readonly SessionPrompt[]): RecoveryPrompt | null;
38
51
  /**
39
52
  * The prompt Retry must POST itself, or null when the restart alone delivers
40
53
  * it. Sending a `redeliveredOnRestart` prompt here would run it twice.
41
54
  */
42
55
  export declare function recoveryPromptToSendOnRetry(prompt: RecoveryPrompt | null): PendingSessionPrompt | null;
56
+ /**
57
+ * The inbox row Retry must re-queue, or null, read when the restarted box is
58
+ * ready. Retry remembers the row id; its state is checked then, not at the
59
+ * click, because a row still queued at the click can dead-letter while the box
60
+ * restarts. A `failed` row is never claimed again on its own. A queued row is
61
+ * delivered by the drain, so re-queueing it would only reorder it.
62
+ */
63
+ export declare function inboxPromptToRequeue(promptId: string | null, prompts: readonly Pick<SessionPrompt, 'prompt_id' | 'state'>[]): string | null;
43
64
  export {};