@kortix/ui 0.15.9 → 0.15.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_vendor/kortix-shared.js +467 -2
- package/dist/_vendor/shared/app-config.d.ts +6 -30
- package/dist/_vendor/shared/channel-descriptors.d.ts +0 -34
- package/dist/_vendor/shared/channel-header.d.ts +2 -1
- package/dist/_vendor/shared/connector-sections.d.ts +0 -25
- package/dist/_vendor/shared/file-tags.d.ts +2 -1
- package/dist/_vendor/shared/index.d.ts +1 -0
- package/dist/_vendor/shared/pasted-content.d.ts +0 -4
- package/dist/_vendor/shared/pixel-mark.d.ts +0 -17
- package/dist/_vendor/shared/project-glyphs.d.ts +0 -1
- package/dist/_vendor/shared/session/attachment-tile.d.ts +32 -0
- package/dist/_vendor/shared/session/stop-refusal.d.ts +15 -0
- package/dist/_vendor/shared/session/tool-row-text.d.ts +58 -0
- package/dist/_vendor/shared/session-delivery.d.ts +2 -0
- package/dist/customize/agents/agent-model-view.d.ts +11 -1
- package/dist/customize/agents/agent-model-view.js +12 -1
- package/dist/customize/agents/agent-page.js +19 -6
- package/dist/customize/agents/agent-tabs.d.ts +2 -0
- package/dist/customize/agents/agent-tabs.js +2 -0
- package/dist/customize/connectors/connectors-page.js +1 -1
- package/dist/customize/connectors/detail/connector-page.js +9 -4
- package/dist/customize/connectors/detail/connector-triggers.js +1 -1
- package/dist/customize/connectors/install/use-install.js +1 -1
- package/dist/customize/connectors/use-agent-access.d.ts +1 -0
- package/dist/customize/providers/provider-accordion.js +5 -5
- package/dist/customize/providers/provider-connect.d.ts +3 -3
- package/dist/customize/providers/provider-connect.js +8 -16
- package/dist/customize/providers/provider-sheet.js +4 -4
- package/dist/customize/sections/component/teams-byo-wizard.js +4 -1
- package/dist/customize/sections/connector-connection-form.d.ts +0 -1
- package/dist/customize/sections/connector-connection-form.js +0 -9
- package/dist/customize/sections/view/review-center-connected.js +7 -3
- package/dist/customize/settings/tabs/workspace-keys.js +53 -11
- package/dist/customize/shared/feature-gate-screen.js +1 -1
- package/dist/customize/triggers/runtime-triggers.js +13 -2
- package/dist/customize/triggers/schedule/event-account-picker.js +1 -1
- package/dist/customize/triggers/schedule/event-trigger-copy.js +1 -1
- package/dist/customize/triggers/schedule/schedule-detail-sheet.js +5 -4
- package/dist/customize/triggers/schedule/then-fields.d.ts +5 -1
- package/dist/customize/triggers/schedule/then-fields.js +23 -3
- package/dist/customize/triggers/schedule/trigger-callouts.js +1 -1
- package/dist/customize/triggers/schedule/trigger-composer-logic.d.ts +27 -0
- package/dist/customize/triggers/schedule/trigger-composer-logic.js +51 -5
- package/dist/customize/triggers/schedule/trigger-composer.js +19 -13
- package/dist/customize/triggers/schedule/trigger-edit-logic.js +25 -5
- package/dist/customize/triggers/schedule/trigger-filter.d.ts +10 -3
- package/dist/customize/triggers/schedule/trigger-filter.js +7 -6
- package/dist/customize/triggers/schedule/trigger-readonly.js +1 -1
- package/dist/customize/triggers/schedule/trigger-runs-panel.js +1 -1
- package/dist/customize/triggers/schedule/use-event-app-connect.js +2 -1
- package/dist/customize/triggers/schedule/when-event.js +1 -1
- package/dist/customize/triggers/schedule/when-schedule.d.ts +5 -1
- package/dist/customize/triggers/schedule/when-schedule.js +16 -1
- package/dist/customize/triggers/schedule-view.js +4 -2
- package/dist/i18n/en.d.ts +56 -7
- package/dist/i18n/en.js +65 -16
- package/dist/internal/billing/compute-pricing.d.ts +7 -1
- package/dist/internal/billing/compute-pricing.js +7 -1
- package/dist/internal/hooks/connectors/invalidate-connections.d.ts +10 -0
- package/dist/internal/hooks/connectors/invalidate-connections.js +18 -0
- package/dist/internal/hooks/connectors/use-finish-sign-in.js +1 -1
- package/dist/internal/hooks/connectors/use-pipedream-connect-member.js +1 -1
- package/dist/internal/hooks/connectors/use-pipedream-connect-project.js +1 -1
- package/dist/internal/hooks/projects/use-new-project-session.d.ts +2 -0
- package/dist/internal/hooks/projects/use-new-project-session.js +4 -1
- package/dist/internal/hooks/use-review-session-summary.d.ts +1 -1
- package/dist/internal/hooks/use-review-session-summary.js +1 -1
- package/dist/internal/layout/project-settings-nav.d.ts +17 -0
- package/dist/internal/layout/project-settings-nav.js +24 -0
- package/dist/internal/lib/browser-noise/rules/injected-scripts.js +2 -2
- package/dist/internal/lib/capability-tab-routes.d.ts +8 -0
- package/dist/internal/lib/capability-tab-routes.js +11 -0
- package/dist/internal/notifications/notification-inbox.d.ts +4 -10
- package/dist/internal/notifications/notification-inbox.js +8 -9
- package/dist/internal/stores/composer-prefill-store.d.ts +7 -0
- package/dist/internal/stores/composer-prefill-store.js +1 -0
- package/dist/internal/stores/connector-gate-store.d.ts +3 -1
- package/dist/internal/stores/connector-gate-store.js +13 -3
- package/dist/internal/stores/upgrade-dialog-store.d.ts +4 -0
- package/dist/internal/stores/upgrade-dialog-store.js +2 -0
- package/dist/lib/routes.d.ts +4 -11
- package/dist/lib/routes.js +3 -5
- package/dist/markdown/unified-markdown-utils.d.ts +7 -0
- package/dist/markdown/unified-markdown-utils.js +19 -0
- package/dist/markdown/unified-markdown.js +16 -3
- package/dist/primitives/alert-dialog.js +1 -1
- package/dist/primitives/dialog.js +3 -1
- package/dist/primitives/drawer.js +1 -1
- package/dist/primitives/modal.js +1 -1
- package/dist/primitives/preview-image.js +1 -1
- package/dist/primitives/sheet.js +1 -1
- package/dist/session/actions/session-label.js +2 -2
- package/dist/session/agents/agent-strip.d.ts +10 -5
- package/dist/session/agents/agent-strip.js +40 -12
- package/dist/session/agents/held-messages.d.ts +6 -2
- package/dist/session/agents/held-messages.js +6 -3
- package/dist/session/composer/ComposerCard.js +8 -3
- package/dist/session/composer/agent-selector.d.ts +2 -0
- package/dist/session/composer/agent-selector.js +5 -0
- package/dist/session/composer/attachment-tile.d.ts +2 -26
- package/dist/session/composer/attachment-tile.js +3 -47
- package/dist/session/composer/composer-chat-input.d.ts +3 -1
- package/dist/session/composer/composer-chat-input.js +2 -2
- package/dist/session/composer/composer-logic.d.ts +7 -0
- package/dist/session/composer/composer-logic.js +18 -0
- package/dist/session/composer/composer-reset.d.ts +8 -14
- package/dist/session/composer/composer-toolbar.d.ts +3 -1
- package/dist/session/composer/composer-toolbar.js +3 -3
- package/dist/session/composer/composer.d.ts +9 -0
- package/dist/session/composer/composer.js +22 -11
- package/dist/session/composer/draft/home-composer-focus-handoff.d.ts +7 -0
- package/dist/session/composer/draft/home-composer-focus-handoff.js +94 -0
- package/dist/session/composer/draft/use-composer-draft.d.ts +3 -1
- package/dist/session/composer/draft/use-composer-draft.js +22 -2
- package/dist/session/composer/editor/composer-editor.d.ts +4 -2
- package/dist/session/composer/editor/composer-editor.js +13 -7
- package/dist/session/composer/hooks/use-composer-focus.js +4 -2
- package/dist/session/header/session-site-header.d.ts +3 -1
- package/dist/session/header/session-site-header.js +3 -2
- package/dist/session/index.d.ts +1 -0
- package/dist/session/index.js +1 -0
- package/dist/session/models/chatgpt-connection-button.js +5 -9
- package/dist/session/models/connect-model-step.d.ts +29 -0
- package/dist/session/models/connect-model-step.js +50 -0
- package/dist/session/models/model-connection-gate.d.ts +2 -1
- package/dist/session/models/model-connection-gate.js +6 -3
- package/dist/session/models/model-connection-layout.d.ts +2 -0
- package/dist/session/models/model-connection-layout.js +4 -0
- package/dist/session/models/model-selector.d.ts +1 -1
- package/dist/session/models/model-selector.js +9 -6
- package/dist/session/models/subscription-offer.d.ts +4 -0
- package/dist/session/models/subscription-offer.js +11 -3
- package/dist/session/models/use-workspace-model-gate.d.ts +11 -0
- package/dist/session/models/use-workspace-model-gate.js +62 -0
- package/dist/session/models/workspace-model-gate.d.ts +46 -0
- package/dist/session/models/workspace-model-gate.js +66 -0
- package/dist/session/overrides/session-overrides-toolbar.js +2 -4
- package/dist/session/prompts/ask-deck.d.ts +5 -1
- package/dist/session/prompts/ask-deck.js +15 -3
- package/dist/session/prompts/question-labels.d.ts +16 -0
- package/dist/session/prompts/question-labels.js +34 -0
- package/dist/session/prompts/question-prompt.js +6 -6
- package/dist/session/prompts/session-connect-card.d.ts +63 -0
- package/dist/session/prompts/{session-connect-prompt.js → session-connect-card.js} +53 -42
- package/dist/session/status/provisioning-failure.d.ts +23 -2
- package/dist/session/status/provisioning-failure.js +53 -3
- package/dist/session/status/stop-refusal.d.ts +6 -12
- package/dist/session/status/stop-refusal.js +6 -19
- package/dist/session/thread/agent-run-props.d.ts +19 -0
- package/dist/session/thread/agent-run-props.js +54 -0
- package/dist/session/thread/session-chat.js +317 -298
- package/dist/session/thread/transcript.d.ts +19 -2
- package/dist/session/thread/transcript.js +93 -25
- package/dist/session/tool/tool-part-renderer.js +7 -2
- package/dist/session/tool/tools/bash-tool.d.ts +3 -52
- package/dist/session/tool/tools/bash-tool.js +3 -86
- package/dist/session/tool/tools/kortix-action-tool.js +10 -2
- package/dist/session/turn/answer-streaming.d.ts +21 -0
- package/dist/session/turn/answer-streaming.js +34 -0
- package/dist/session/turn/queued-prompt-bubbles.d.ts +5 -0
- package/dist/session/turn/queued-prompt-bubbles.js +12 -0
- package/dist/session/turn/turn-viewport.d.ts +66 -10
- package/dist/session/turn/turn-viewport.js +92 -12
- package/dist/session/turn/turn-work-accordion.d.ts +3 -1
- package/dist/session/turn/turn-work-accordion.js +2 -2
- package/dist/session/turn/user-message.js +7 -5
- package/dist/styles.css +1 -1
- package/dist/test-utils/intl.d.ts +56 -7
- package/dist/workspace/admin/project-admin-dashboard.js +2 -4
- package/dist/workspace/home/existing-repo-setup-prompt.d.ts +5 -8
- package/dist/workspace/home/existing-repo-setup-prompt.js +16 -42
- package/dist/workspace/home/first-chat.d.ts +7 -1
- package/dist/workspace/home/first-chat.js +12 -5
- package/dist/workspace/home/no-agent-home.d.ts +3 -1
- package/dist/workspace/home/no-agent-home.js +2 -2
- package/dist/workspace/inbox/workspace-inbox.d.ts +6 -16
- package/dist/workspace/inbox/workspace-inbox.js +9 -51
- package/dist/workspace/layout/project-home.js +17 -16
- package/dist/workspace/layout/use-project-home-send.d.ts +2 -0
- package/dist/workspace/layout/use-project-home-send.js +29 -15
- package/dist/workspace/new/advanced-fields.d.ts +4 -1
- package/dist/workspace/new/advanced-fields.js +2 -2
- package/dist/workspace/new/workspace-name.d.ts +9 -0
- package/dist/workspace/new/workspace-name.js +20 -0
- package/dist/workspace/projects/session-starter.d.ts +6 -4
- package/dist/workspace/projects/session-starter.js +8 -14
- package/dist/workspace/review/review-center.d.ts +6 -2
- package/dist/workspace/review/review-center.js +45 -25
- package/dist/workspace/sidebar/session-grouping.d.ts +1 -1
- package/dist/workspace/sidebar/session-grouping.js +1 -1
- package/dist/workspace/sidebar/workspace-menu-model.d.ts +3 -5
- package/dist/workspace/sidebar/workspace-menu-model.js +1 -1
- package/dist/workspace/spaces/space-details-panel.js +2 -2
- package/dist/workspace/spaces/space-triggers.js +2 -2
- package/dist/workspace/spaces/space-view.js +11 -5
- package/package.json +15 -7
- package/skills/kortix-ui/references/modules.md +1 -1
- package/dist/customize/connectors/invalidate-connections.d.ts +0 -2
- package/dist/customize/connectors/invalidate-connections.js +0 -4
- package/dist/internal/notifications/use-inbox-summary.d.ts +0 -17
- package/dist/internal/notifications/use-inbox-summary.js +0 -28
- package/dist/session/prompts/session-connect-prompt.d.ts +0 -40
|
@@ -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
|
-
|
|
196
|
-
|
|
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
|
-
|
|
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,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Connect card of a connector sign-in the agent started, drawn in the
|
|
3
|
+
* transcript under the call that started it: `kortix connectors connect <app>`
|
|
4
|
+
* in the shell, or the `kortix_connectors` tool's `connect` (the SDK reads
|
|
5
|
+
* both, `connectorSignInCalls`). The SDK keeps that call out of every fold, so
|
|
6
|
+
* the card stays in view the way a pasted `/connect/<token>` link did.
|
|
7
|
+
*
|
|
8
|
+
* #12500 (2026-11-12) docked this card above the composer. A sign-in the
|
|
9
|
+
* person never finished stayed docked for the life of the session: a person
|
|
10
|
+
* who connected the app another way (the native Supabase connector instead of
|
|
11
|
+
* the Composio toolkit the agent picked) kept the card over the input, with
|
|
12
|
+
* nothing to dismiss it (2026-11-13). In the transcript it stays where the
|
|
13
|
+
* agent asked, scrolls away with its turn, and reads "Connected as …" once done.
|
|
14
|
+
*
|
|
15
|
+
* The API records which session asked on the account row
|
|
16
|
+
* (`requesting_session_id`). `SessionConnectRequestsProvider` reads those rows
|
|
17
|
+
* once per session (`listSessionConnectRequests`); each card picks the ones its
|
|
18
|
+
* call names (`connectorSignInRequests`) and finishes each through
|
|
19
|
+
* `connectionSignInSteps`: the window opens inside the click, the first request
|
|
20
|
+
* records a sign-in that already finished at the provider, and only an
|
|
21
|
+
* unfinished one goes to a new sign-in page. Finalize tells the session that
|
|
22
|
+
* asked, so the agent continues on its own.
|
|
23
|
+
*/
|
|
24
|
+
import { type ConnectorSignInCall, type SessionConnectRequest } from '@kortix/sdk';
|
|
25
|
+
import { type ReactNode } from 'react';
|
|
26
|
+
/** Stable id of one request: its account row, or the connector on an older server. */
|
|
27
|
+
export declare function sessionConnectRequestKey(request: SessionConnectRequest): string;
|
|
28
|
+
interface SessionConnectRequests {
|
|
29
|
+
projectId: string;
|
|
30
|
+
requests: readonly SessionConnectRequest[];
|
|
31
|
+
refetch: () => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The session's connect requests, read once for every card in its transcript.
|
|
35
|
+
* Without a project and session (a read-only view) it provides nothing, and no
|
|
36
|
+
* call draws a card.
|
|
37
|
+
*/
|
|
38
|
+
export declare function SessionConnectRequestsProvider({ projectId, sessionId, busy, children, }: {
|
|
39
|
+
projectId: string | null | undefined;
|
|
40
|
+
sessionId: string | null | undefined;
|
|
41
|
+
/** The agent is running: poll faster, and read again when it stops. */
|
|
42
|
+
busy: boolean;
|
|
43
|
+
children: ReactNode;
|
|
44
|
+
}): import("react").JSX.Element;
|
|
45
|
+
/** The session's connect requests, or null outside a session that can finish them. */
|
|
46
|
+
export declare function useSessionConnectRequests(): SessionConnectRequests | null;
|
|
47
|
+
/**
|
|
48
|
+
* The Connect card under a call that started connector sign-ins: one row per
|
|
49
|
+
* request the call names. Nothing when the session holds no such request
|
|
50
|
+
* (another member's private sign-in, an account removed since).
|
|
51
|
+
*/
|
|
52
|
+
export declare function SessionConnectCard({ calls, className, }: {
|
|
53
|
+
calls: readonly ConnectorSignInCall[];
|
|
54
|
+
className?: string;
|
|
55
|
+
}): import("react").JSX.Element | null;
|
|
56
|
+
/** The card itself: a headline, then one row per request. */
|
|
57
|
+
export declare function SessionConnectNotice({ requests, projectId, onSettled, className, }: {
|
|
58
|
+
requests: readonly SessionConnectRequest[];
|
|
59
|
+
projectId: string;
|
|
60
|
+
onSettled: () => void;
|
|
61
|
+
className?: string;
|
|
62
|
+
}): import("react").JSX.Element;
|
|
63
|
+
export {};
|
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* `
|
|
4
|
+
* The Connect card of a connector sign-in the agent started, drawn in the
|
|
5
|
+
* transcript under the call that started it: `kortix connectors connect <app>`
|
|
6
|
+
* in the shell, or the `kortix_connectors` tool's `connect` (the SDK reads
|
|
7
|
+
* both, `connectorSignInCalls`). The SDK keeps that call out of every fold, so
|
|
8
|
+
* the card stays in view the way a pasted `/connect/<token>` link did.
|
|
6
9
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* #12500 (2026-11-12) docked this card above the composer. A sign-in the
|
|
11
|
+
* person never finished stayed docked for the life of the session: a person
|
|
12
|
+
* who connected the app another way (the native Supabase connector instead of
|
|
13
|
+
* the Composio toolkit the agent picked) kept the card over the input, with
|
|
14
|
+
* nothing to dismiss it (2026-11-13). In the transcript it stays where the
|
|
15
|
+
* agent asked, scrolls away with its turn, and reads "Connected as …" once done.
|
|
16
|
+
*
|
|
17
|
+
* The API records which session asked on the account row
|
|
18
|
+
* (`requesting_session_id`). `SessionConnectRequestsProvider` reads those rows
|
|
19
|
+
* once per session (`listSessionConnectRequests`); each card picks the ones its
|
|
20
|
+
* call names (`connectorSignInRequests`) and finishes each through
|
|
12
21
|
* `connectionSignInSteps`: the window opens inside the click, the first request
|
|
13
22
|
* records a sign-in that already finished at the provider, and only an
|
|
14
23
|
* unfinished one goes to a new sign-in page. Finalize tells the session that
|
|
15
24
|
* 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
25
|
*/
|
|
21
|
-
import { connectionSignInSteps, listSessionConnectRequests, } from '@kortix/sdk';
|
|
26
|
+
import { connectionSignInSteps, connectorSignInRequests, listSessionConnectRequests, } from '@kortix/sdk';
|
|
22
27
|
import { CheckIcon, PlugsConnectedIcon } from '@phosphor-icons/react';
|
|
23
28
|
import { useQuery } from '@tanstack/react-query';
|
|
24
|
-
import { useEffect, useRef, useState } from 'react';
|
|
29
|
+
import { createContext, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
25
30
|
import { useTranslations } from '../../i18n/index.js';
|
|
26
31
|
import { cn } from '../../lib/utils.js';
|
|
27
32
|
import { runConnectLinkFlow } from '../../internal/hooks/connectors/use-connect-link.js';
|
|
@@ -33,23 +38,23 @@ import { errorToast } from '../../primitives/toast.js';
|
|
|
33
38
|
const BUSY_POLL_MS = 8_000;
|
|
34
39
|
/** A card whose sign-in the person may finish in another tab. */
|
|
35
40
|
const PENDING_POLL_MS = 10_000;
|
|
41
|
+
const NO_REQUESTS = Object.freeze([]);
|
|
36
42
|
/** Stable id of one request: its account row, or the connector on an older server. */
|
|
37
43
|
export function sessionConnectRequestKey(request) {
|
|
38
44
|
return request.connection_id ?? request.slug;
|
|
39
45
|
}
|
|
46
|
+
const SessionConnectRequestsContext = createContext(null);
|
|
40
47
|
/**
|
|
41
|
-
* The
|
|
42
|
-
*
|
|
48
|
+
* The session's connect requests, read once for every card in its transcript.
|
|
49
|
+
* Without a project and session (a read-only view) it provides nothing, and no
|
|
50
|
+
* call draws a card.
|
|
43
51
|
*/
|
|
44
|
-
export function
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
export function SessionConnectPrompt({ projectId, sessionId, busy, onDockedChange, }) {
|
|
48
|
-
const seenPending = useRef(new Set());
|
|
52
|
+
export function SessionConnectRequestsProvider({ projectId, sessionId, busy, children, }) {
|
|
53
|
+
const enabled = Boolean(projectId && sessionId);
|
|
49
54
|
const query = useQuery({
|
|
50
55
|
queryKey: ['session-connect-requests', projectId, sessionId],
|
|
51
56
|
queryFn: () => listSessionConnectRequests(projectId, sessionId),
|
|
52
|
-
enabled
|
|
57
|
+
enabled,
|
|
53
58
|
staleTime: 2_000,
|
|
54
59
|
retry: false,
|
|
55
60
|
refetchOnWindowFocus: true,
|
|
@@ -59,36 +64,42 @@ export function SessionConnectPrompt({ projectId, sessionId, busy, onDockedChang
|
|
|
59
64
|
? PENDING_POLL_MS
|
|
60
65
|
: false,
|
|
61
66
|
});
|
|
62
|
-
const { refetch } = query;
|
|
67
|
+
const { refetch, data } = query;
|
|
63
68
|
// The agent stops right after it starts a sign-in: read once more then.
|
|
64
69
|
const wasBusy = useRef(busy);
|
|
65
70
|
useEffect(() => {
|
|
66
|
-
if (wasBusy.current && !busy)
|
|
71
|
+
if (enabled && wasBusy.current && !busy)
|
|
67
72
|
void refetch();
|
|
68
73
|
wasBusy.current = busy;
|
|
69
|
-
}, [busy, refetch]);
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
}, [busy, enabled, refetch]);
|
|
75
|
+
const value = useMemo(() => enabled && projectId
|
|
76
|
+
? { projectId, requests: data ?? NO_REQUESTS, refetch: () => void refetch() }
|
|
77
|
+
: null, [enabled, projectId, data, refetch]);
|
|
78
|
+
return _jsx(SessionConnectRequestsContext.Provider, { value: value, children: children });
|
|
79
|
+
}
|
|
80
|
+
/** The session's connect requests, or null outside a session that can finish them. */
|
|
81
|
+
export function useSessionConnectRequests() {
|
|
82
|
+
return useContext(SessionConnectRequestsContext);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The Connect card under a call that started connector sign-ins: one row per
|
|
86
|
+
* request the call names. Nothing when the session holds no such request
|
|
87
|
+
* (another member's private sign-in, an account removed since).
|
|
88
|
+
*/
|
|
89
|
+
export function SessionConnectCard({ calls, className, }) {
|
|
90
|
+
const context = useSessionConnectRequests();
|
|
91
|
+
if (!context || calls.length === 0)
|
|
92
|
+
return null;
|
|
93
|
+
const requests = connectorSignInRequests(context.requests, calls);
|
|
94
|
+
if (requests.length === 0)
|
|
82
95
|
return null;
|
|
83
|
-
return (_jsx(SessionConnectNotice, { requests:
|
|
96
|
+
return (_jsx(SessionConnectNotice, { requests: requests, projectId: context.projectId, onSettled: context.refetch, className: className }));
|
|
84
97
|
}
|
|
85
|
-
/** The card itself: one row per request. */
|
|
86
|
-
export function SessionConnectNotice({ requests, projectId, onSettled, }) {
|
|
98
|
+
/** The card itself: a headline, then one row per request. */
|
|
99
|
+
export function SessionConnectNotice({ requests, projectId, onSettled, className, }) {
|
|
87
100
|
const t = useTranslations('connectSignIn');
|
|
88
101
|
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)))) })] }));
|
|
102
|
+
return (_jsxs("div", { className: cn('w-full', className), "data-testid": "session-connect-card", children: [_jsxs("div", { className: "text-muted-foreground flex min-h-6 items-center gap-1.5 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 pt-0.5", children: requests.map((request) => (_jsx(SessionConnectRow, { request: request, projectId: projectId, onSettled: onSettled }, sessionConnectRequestKey(request)))) })] }));
|
|
92
103
|
}
|
|
93
104
|
function SessionConnectRow({ request, projectId, onSettled, }) {
|
|
94
105
|
const t = useTranslations('connectSignIn');
|
|
@@ -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 {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { readStartStash } from '@kortix/sdk/react';
|
|
1
|
+
import { isOptimisticSessionPrompt, readStartStash } from '@kortix/sdk/react';
|
|
2
|
+
import { isFirstPromptRow } from '../composer/queue-projection.js';
|
|
2
3
|
/** Build stable error-card copy from API-owned sandbox failure metadata. */
|
|
3
4
|
export function provisioningFailurePresentation(metadata, sandboxLabel, tI18nComplete) {
|
|
4
5
|
const resolvedSandboxLabel = sandboxLabel ?? 'session';
|
|
@@ -70,6 +71,35 @@ export function pendingSessionPromptFromMetadata(metadata) {
|
|
|
70
71
|
attachment_names: attachmentNames,
|
|
71
72
|
};
|
|
72
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* The session's own prompt in its server inbox, oldest first.
|
|
76
|
+
*
|
|
77
|
+
* The create stores the first prompt as a `session_lifecycle_commands` row and
|
|
78
|
+
* strips its text from `metadata.pending_prompt` (`pending-prompt.ts`). When
|
|
79
|
+
* the box never boots, that row is the ONLY copy of the prompt: it stays
|
|
80
|
+
* `queued`, then goes `dead_lettered` (listed as `failed`) once its delivery
|
|
81
|
+
* attempts are spent. The first-prompt row wins; any other person-written row
|
|
82
|
+
* is next. Optimistic rows have no server id to retry, so they never count.
|
|
83
|
+
*/
|
|
84
|
+
function inboxPromptForRecovery(prompts) {
|
|
85
|
+
const candidates = prompts.filter((prompt) => !isOptimisticSessionPrompt(prompt) && !prompt.synthetic && !!prompt.prompt_id);
|
|
86
|
+
const row = candidates.find(isFirstPromptRow) ?? candidates[0];
|
|
87
|
+
if (!row)
|
|
88
|
+
return null;
|
|
89
|
+
const text = row.full_text || row.text || '';
|
|
90
|
+
const attachmentNames = (row.attachments ?? []).map((file) => file.filename);
|
|
91
|
+
if (text.trim().length === 0 && attachmentNames.length === 0)
|
|
92
|
+
return null;
|
|
93
|
+
return {
|
|
94
|
+
text,
|
|
95
|
+
agent: null,
|
|
96
|
+
model: null,
|
|
97
|
+
variant: null,
|
|
98
|
+
attachment_names: attachmentNames,
|
|
99
|
+
redeliveredOnRestart: true,
|
|
100
|
+
inboxPrompt: { promptId: row.prompt_id, failed: row.state === 'failed' },
|
|
101
|
+
};
|
|
102
|
+
}
|
|
73
103
|
/**
|
|
74
104
|
* The recovery copy, from the server when it has one and from this tab's start
|
|
75
105
|
* stash otherwise. Never consumes either.
|
|
@@ -83,11 +113,19 @@ export function pendingSessionPromptFromMetadata(metadata) {
|
|
|
83
113
|
* created has neither: its first prompt is `metadata.initial_prompt`. That
|
|
84
114
|
* prompt is shown only while `runtimeSessionId` is empty, which is the same
|
|
85
115
|
* condition under which the restart re-delivers it.
|
|
116
|
+
*
|
|
117
|
+
* `inboxPrompts` is `GET .../prompts`. A session the current API created keeps
|
|
118
|
+
* its first prompt ONLY there, so it answers before the start stash: the stash
|
|
119
|
+
* is a client-delivered copy, and posting it beside the server's own row sent
|
|
120
|
+
* the prompt twice.
|
|
86
121
|
*/
|
|
87
|
-
export function pendingSessionPromptForRecovery(sessionId, metadata, runtimeSessionId) {
|
|
122
|
+
export function pendingSessionPromptForRecovery(sessionId, metadata, runtimeSessionId, inboxPrompts = []) {
|
|
88
123
|
const fromMetadata = pendingSessionPromptFromMetadata(metadata);
|
|
89
124
|
if (fromMetadata)
|
|
90
125
|
return { ...fromMetadata, redeliveredOnRestart: false };
|
|
126
|
+
const fromInbox = inboxPromptForRecovery(inboxPrompts);
|
|
127
|
+
if (fromInbox)
|
|
128
|
+
return fromInbox;
|
|
91
129
|
const stash = readStartStash(sessionId);
|
|
92
130
|
if (stash && stash.prompt.trim().length > 0) {
|
|
93
131
|
return {
|
|
@@ -119,6 +157,18 @@ export function pendingSessionPromptForRecovery(sessionId, metadata, runtimeSess
|
|
|
119
157
|
export function recoveryPromptToSendOnRetry(prompt) {
|
|
120
158
|
if (!prompt || prompt.redeliveredOnRestart)
|
|
121
159
|
return null;
|
|
122
|
-
const { redeliveredOnRestart: _redeliveredOnRestart, ...toSend } = prompt;
|
|
160
|
+
const { redeliveredOnRestart: _redeliveredOnRestart, inboxPrompt: _inboxPrompt, ...toSend } = prompt;
|
|
123
161
|
return toSend;
|
|
124
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* The inbox row Retry must re-queue, or null, read when the restarted box is
|
|
165
|
+
* ready. Retry remembers the row id; its state is checked then, not at the
|
|
166
|
+
* click, because a row still queued at the click can dead-letter while the box
|
|
167
|
+
* restarts. A `failed` row is never claimed again on its own. A queued row is
|
|
168
|
+
* delivered by the drain, so re-queueing it would only reorder it.
|
|
169
|
+
*/
|
|
170
|
+
export function inboxPromptToRequeue(promptId, prompts) {
|
|
171
|
+
if (!promptId)
|
|
172
|
+
return null;
|
|
173
|
+
return prompts.some((row) => row.prompt_id === promptId && row.state === 'failed') ? promptId : null;
|
|
174
|
+
}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* The composer hides Stop when `useSession().canStop` says no, so a refusal
|
|
3
|
+
* only reaches here when that answer was stale. The server's own words are
|
|
4
|
+
* what the toast says.
|
|
5
|
+
*
|
|
6
|
+
* The guard lives once in `@kortix/shared/session/stop-refusal`.
|
|
6
7
|
*/
|
|
7
|
-
export
|
|
8
|
-
/**
|
|
9
|
-
* The server's message when it refused a stop, or null for any other failure.
|
|
10
|
-
* A REST stop (the hold, "Stop and send") is an `ApiError` carrying the code.
|
|
11
|
-
* The runtime abort answers through the sandbox proxy, whose error keeps the
|
|
12
|
-
* status and the message but not the code, so a 403 counts there too.
|
|
13
|
-
*/
|
|
14
|
-
export declare function stopRefusalMessage(error: unknown): string | null;
|
|
8
|
+
export { NOT_TURN_PROMPTER, stopRefusalMessage } from '../../_vendor/shared/session/stop-refusal.js';
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* The composer hides Stop when `useSession().canStop` says no, so a refusal
|
|
3
|
+
* only reaches here when that answer was stale. The server's own words are
|
|
4
|
+
* what the toast says.
|
|
5
|
+
*
|
|
6
|
+
* The guard lives once in `@kortix/shared/session/stop-refusal`.
|
|
6
7
|
*/
|
|
7
|
-
export
|
|
8
|
-
/**
|
|
9
|
-
* The server's message when it refused a stop, or null for any other failure.
|
|
10
|
-
* A REST stop (the hold, "Stop and send") is an `ApiError` carrying the code.
|
|
11
|
-
* The runtime abort answers through the sandbox proxy, whose error keeps the
|
|
12
|
-
* status and the message but not the code, so a 403 counts there too.
|
|
13
|
-
*/
|
|
14
|
-
export function stopRefusalMessage(error) {
|
|
15
|
-
if (!error || typeof error !== 'object')
|
|
16
|
-
return null;
|
|
17
|
-
const { status, code, message } = error;
|
|
18
|
-
if (code !== NOT_TURN_PROMPTER && status !== 403)
|
|
19
|
-
return null;
|
|
20
|
-
return typeof message === 'string' && message ? message : null;
|
|
21
|
-
}
|
|
8
|
+
export { NOT_TURN_PROMPTER, stopRefusalMessage } from '../../_vendor/kortix-shared.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type SessionLogAgentRun, type SessionLogTurn } from '@kortix/sdk';
|
|
2
|
+
/** What one transcript row receives from its agent run (KRTX-4732). */
|
|
3
|
+
export interface AgentRunRowProps {
|
|
4
|
+
agentRun?: SessionLogAgentRun;
|
|
5
|
+
runTurns?: readonly SessionLogTurn[];
|
|
6
|
+
foldStartedWork?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface AgentRunLayout {
|
|
9
|
+
/** The turns the transcript draws no row for: they fold into their run's anchor. */
|
|
10
|
+
absorbed: ReadonlySet<string>;
|
|
11
|
+
/** A row's run props; the same object while nothing about the run changed. */
|
|
12
|
+
propsOf: (turnId: string) => AgentRunRowProps;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The agent runs of a transcript (`sessionLogAgentRuns`), as row props. A stream delta remakes
|
|
16
|
+
* the turn list; a row whose run did not change keeps its props object, so its memoized row
|
|
17
|
+
* still bails out. `disabled` (a messages-only thread): no runs.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useAgentRunLayout(turns: readonly SessionLogTurn[], disabled: boolean): AgentRunLayout;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { sessionLogAgentRuns } from '@kortix/sdk';
|
|
3
|
+
import { useMemo, useState } from 'react';
|
|
4
|
+
const NONE = Object.freeze({});
|
|
5
|
+
const EMPTY = { absorbed: new Set(), propsOf: () => NONE };
|
|
6
|
+
const sameRun = (a, b) => a.anchor === b.anchor &&
|
|
7
|
+
a.agents === b.agents &&
|
|
8
|
+
a.started === b.started &&
|
|
9
|
+
a.reported === b.reported &&
|
|
10
|
+
a.durationMs === b.durationMs &&
|
|
11
|
+
a.live === b.live &&
|
|
12
|
+
a.stopped === b.stopped &&
|
|
13
|
+
a.turns.length === b.turns.length &&
|
|
14
|
+
a.turns.every((id, i) => id === b.turns[i]);
|
|
15
|
+
const sameTurns = (a, b) => a === b || (!!a && !!b && a.length === b.length && a.every((turn, i) => turn === b[i]));
|
|
16
|
+
/**
|
|
17
|
+
* The agent runs of a transcript (`sessionLogAgentRuns`), as row props. A stream delta remakes
|
|
18
|
+
* the turn list; a row whose run did not change keeps its props object, so its memoized row
|
|
19
|
+
* still bails out. `disabled` (a messages-only thread): no runs.
|
|
20
|
+
*/
|
|
21
|
+
export function useAgentRunLayout(turns, disabled) {
|
|
22
|
+
// The props each row got last time. A cache, not state: writing it never renders.
|
|
23
|
+
const [previous] = useState(() => new Map());
|
|
24
|
+
return useMemo(() => {
|
|
25
|
+
if (disabled)
|
|
26
|
+
return EMPTY;
|
|
27
|
+
const layout = sessionLogAgentRuns(turns);
|
|
28
|
+
if (layout.runs.size === 0 && layout.settledLaunches.size === 0) {
|
|
29
|
+
previous.clear();
|
|
30
|
+
return EMPTY;
|
|
31
|
+
}
|
|
32
|
+
const byId = new Map(turns.map((turn) => [turn.id, turn]));
|
|
33
|
+
const next = new Map();
|
|
34
|
+
const ids = new Set([...layout.runs.keys(), ...layout.settledLaunches]);
|
|
35
|
+
for (const id of ids) {
|
|
36
|
+
const run = layout.runs.get(id);
|
|
37
|
+
const runTurns = run?.turns.slice(0, -1).map((turnId) => byId.get(turnId));
|
|
38
|
+
const fresh = {
|
|
39
|
+
...(run ? { agentRun: run, runTurns } : {}),
|
|
40
|
+
...(layout.settledLaunches.has(id) ? { foldStartedWork: true } : {}),
|
|
41
|
+
};
|
|
42
|
+
const old = previous.get(id);
|
|
43
|
+
const unchanged = old &&
|
|
44
|
+
!!old.foldStartedWork === !!fresh.foldStartedWork &&
|
|
45
|
+
(old.agentRun && fresh.agentRun ? sameRun(old.agentRun, fresh.agentRun) : old.agentRun === fresh.agentRun) &&
|
|
46
|
+
sameTurns(old.runTurns, fresh.runTurns);
|
|
47
|
+
next.set(id, unchanged ? old : fresh);
|
|
48
|
+
}
|
|
49
|
+
previous.clear();
|
|
50
|
+
for (const [id, props] of next)
|
|
51
|
+
previous.set(id, props);
|
|
52
|
+
return { absorbed: layout.absorbed, propsOf: (turnId) => next.get(turnId) ?? NONE };
|
|
53
|
+
}, [turns, disabled, previous]);
|
|
54
|
+
}
|