@kortix/ui 0.15.9 → 0.15.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_vendor/kortix-shared.js +72 -1
- package/dist/_vendor/shared/index.d.ts +1 -0
- 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/connectors/connectors-page.js +1 -1
- package/dist/customize/connectors/detail/connector-page.js +9 -4
- package/dist/customize/connectors/install/use-install.js +1 -1
- 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/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/schedule/event-account-picker.js +1 -1
- package/dist/customize/triggers/schedule/use-event-app-connect.js +2 -1
- package/dist/i18n/en.d.ts +7 -7
- package/dist/i18n/en.js +8 -8
- 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/lib/browser-noise/rules/injected-scripts.js +2 -2
- package/dist/internal/notifications/notification-inbox.d.ts +4 -10
- package/dist/internal/notifications/notification-inbox.js +8 -9
- 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/composer/ComposerCard.js +4 -2
- 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 +2 -1
- package/dist/session/composer/composer-chat-input.js +2 -2
- package/dist/session/composer/composer.d.ts +2 -0
- package/dist/session/composer/composer.js +5 -8
- 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 +7 -3
- package/dist/session/composer/hooks/use-composer-focus.js +4 -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/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/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/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 +27 -4
- package/dist/session/thread/transcript.d.ts +17 -1
- package/dist/session/thread/transcript.js +87 -23
- package/dist/session/tool/tools/bash-tool.d.ts +3 -52
- package/dist/session/tool/tools/bash-tool.js +3 -86
- 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-work-accordion.d.ts +3 -1
- package/dist/session/turn/turn-work-accordion.js +2 -2
- package/dist/styles.css +1 -1
- package/dist/test-utils/intl.d.ts +7 -7
- package/dist/workspace/home/first-chat.d.ts +7 -1
- package/dist/workspace/home/first-chat.js +12 -5
- 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 +5 -11
- 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/workspace-menu-model.d.ts +3 -5
- package/dist/workspace/sidebar/workspace-menu-model.js +1 -1
- package/package.json +3 -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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { completeHomeComposerFocus, registerHomeComposerEditor } from './home-composer-focus-handoff.js';
|
|
2
3
|
import { useCallback, useEffect, useLayoutEffect, useRef } from 'react';
|
|
3
4
|
import { useUiViewerId } from '../../../providers/ui-provider.js';
|
|
4
5
|
import { useLatestRef } from '../hooks/use-latest-ref.js';
|
|
@@ -22,7 +23,13 @@ const NO_UPLOADS = [];
|
|
|
22
23
|
* render-silent while typing (`editor/composer-editor.tsx`'s `onEmptyChange`
|
|
23
24
|
* contract) and lifting the document into state would defeat it.
|
|
24
25
|
*/
|
|
25
|
-
export function useComposerDraft({ active = true, scope, editorRef, editorReady, attachedFiles, quotes = NO_QUOTES, pastes = NO_PASTES, uploads = NO_UPLOADS, hasPrefill, onRestore, }) {
|
|
26
|
+
export function useComposerDraft({ active = true, handoffScope, scope, editorRef, editorReady, attachedFiles, quotes = NO_QUOTES, pastes = NO_PASTES, uploads = NO_UPLOADS, hasPrefill, onRestore, }) {
|
|
27
|
+
useLayoutEffect(() => {
|
|
28
|
+
if (scope?.kind !== 'project' || !editorReady)
|
|
29
|
+
return;
|
|
30
|
+
registerHomeComposerEditor(editorRef.current);
|
|
31
|
+
return () => registerHomeComposerEditor(null);
|
|
32
|
+
}, [scope, editorReady, editorRef]);
|
|
26
33
|
const viewerId = useUiViewerId();
|
|
27
34
|
const userId = viewerId ?? '';
|
|
28
35
|
const enabled = !!scope && !!userId;
|
|
@@ -75,11 +82,20 @@ export function useComposerDraft({ active = true, scope, editorRef, editorReady,
|
|
|
75
82
|
activeRef.current = active;
|
|
76
83
|
if (!active)
|
|
77
84
|
flush();
|
|
85
|
+
const source = scopeRef.current;
|
|
86
|
+
const ownerId = userIdRef.current;
|
|
78
87
|
return () => {
|
|
79
88
|
flush();
|
|
89
|
+
const target = handoffScope?.current;
|
|
90
|
+
if (target && source && ownerId) {
|
|
91
|
+
const draft = readDraft(source, ownerId);
|
|
92
|
+
if (draft)
|
|
93
|
+
writeDraft(target, draft);
|
|
94
|
+
clearDraft(source);
|
|
95
|
+
}
|
|
80
96
|
activeRef.current = false;
|
|
81
97
|
};
|
|
82
|
-
}, [active, flush]);
|
|
98
|
+
}, [active, flush, handoffScope, scopeRef, userIdRef]);
|
|
83
99
|
const handleDocChange = useCallback((doc, isEmpty) => {
|
|
84
100
|
if (!activeRef.current || !scopeRef.current || !userIdRef.current)
|
|
85
101
|
return;
|
|
@@ -158,12 +174,16 @@ export function useComposerDraft({ active = true, scope, editorRef, editorReady,
|
|
|
158
174
|
hasPrefill,
|
|
159
175
|
alreadyRestored: restoredKeyRef.current === key,
|
|
160
176
|
})) {
|
|
177
|
+
if (active && editorReady && editorRef.current)
|
|
178
|
+
completeHomeComposerFocus(scope, editorRef.current);
|
|
161
179
|
return;
|
|
162
180
|
}
|
|
163
181
|
restoredKeyRef.current = key;
|
|
164
182
|
const stored = readDraft(scope, userId);
|
|
165
183
|
if (stored)
|
|
166
184
|
onRestore(stored);
|
|
185
|
+
if (editorRef.current)
|
|
186
|
+
completeHomeComposerFocus(scope, editorRef.current);
|
|
167
187
|
}, [active, scope, userId, editorReady, hasPrefill, editorRef, onRestore]);
|
|
168
188
|
return { handleDocChange, clearSavedDraft };
|
|
169
189
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EditorState } from '@tiptap/pm/state';
|
|
1
2
|
import type { Agent, Command, Session } from '@kortix/sdk/react';
|
|
2
3
|
import type { Editor, JSONContent } from '@tiptap/core';
|
|
3
4
|
import type { EditorView } from '@tiptap/pm/view';
|
|
@@ -54,6 +55,7 @@ export interface ComposerEditorHandle {
|
|
|
54
55
|
* blocks (built from the STRUCTURED `mentions` array, not the text) would
|
|
55
56
|
* then be missing entirely.
|
|
56
57
|
*/
|
|
58
|
+
getEditingState(): EditorState | null;
|
|
57
59
|
getDocument(): JSONContent;
|
|
58
60
|
/**
|
|
59
61
|
* Always replaces the whole document, same as `setContent`. A `mode`
|
|
@@ -65,7 +67,7 @@ export interface ComposerEditorHandle {
|
|
|
65
67
|
* merge, unlike `setContent`'s `textToParagraphs`, which only ever knows
|
|
66
68
|
* how to build plain text) and written back through this method.
|
|
67
69
|
*/
|
|
68
|
-
setDocument(doc: JSONContent): void;
|
|
70
|
+
setDocument(doc: JSONContent, focus?: boolean): void;
|
|
69
71
|
/**
|
|
70
72
|
* Insert literal text at the CURRENT cursor/selection — Task 13. The old
|
|
71
73
|
* plain `<textarea>` gave this for free via `setRangeText`; nothing here
|
|
@@ -259,7 +261,7 @@ onArrowDownAtEnd?: () => boolean): (view: EditorView, event: KeyboardEvent) => b
|
|
|
259
261
|
* are exercised directly in `composer-editor.test.ts`.
|
|
260
262
|
*/
|
|
261
263
|
export declare function getEditorDocument(editor: Editor | null): JSONContent;
|
|
262
|
-
export declare function setEditorDocument(editor: Editor | null, doc: JSONContent): void;
|
|
264
|
+
export declare function setEditorDocument(editor: Editor | null, doc: JSONContent, focus?: boolean): void;
|
|
263
265
|
/**
|
|
264
266
|
* Task 13, fix round 1, Important 2's specific regression guard: this must
|
|
265
267
|
* insert INLINE at the current selection (`editor.commands.insertContent`
|
|
@@ -140,7 +140,7 @@ const EMPTY_DOC = { type: 'doc', content: textToParagraphs('') };
|
|
|
140
140
|
export function getEditorDocument(editor) {
|
|
141
141
|
return editor ? editor.getJSON() : EMPTY_DOC;
|
|
142
142
|
}
|
|
143
|
-
export function setEditorDocument(editor, doc) {
|
|
143
|
+
export function setEditorDocument(editor, doc, focus = true) {
|
|
144
144
|
if (!editor)
|
|
145
145
|
return;
|
|
146
146
|
const content = doc.content ?? [];
|
|
@@ -148,7 +148,10 @@ export function setEditorDocument(editor, doc) {
|
|
|
148
148
|
// `scrollIntoView: false` — see the note on the `setContent` handle below.
|
|
149
149
|
// This is the same programmatic whole-document replace, so it wants the same
|
|
150
150
|
// treatment: put the caret at the end, move nothing.
|
|
151
|
-
|
|
151
|
+
if (focus)
|
|
152
|
+
editor.commands.focus('end', { scrollIntoView: false });
|
|
153
|
+
else
|
|
154
|
+
editor.commands.setTextSelection(editor.state.doc.content.size);
|
|
152
155
|
}
|
|
153
156
|
/**
|
|
154
157
|
* Task 13, fix round 1, Important 2's specific regression guard: this must
|
|
@@ -447,7 +450,8 @@ export const ComposerEditor = forwardRef(function ComposerEditor({ placeholder,
|
|
|
447
450
|
editor.commands.focus(caret, { scrollIntoView: false });
|
|
448
451
|
},
|
|
449
452
|
getDocument: () => getEditorDocument(editor),
|
|
450
|
-
|
|
453
|
+
getEditingState: () => editor?.state ?? null,
|
|
454
|
+
setDocument: (doc, focus) => setEditorDocument(editor, doc, focus),
|
|
451
455
|
insertAtCursor: (text) => insertTextAtCursor(editor, text),
|
|
452
456
|
clear: () => editor?.commands.setContent(EMPTY_DOC),
|
|
453
457
|
focus: () => editor?.commands.focus('end'),
|
|
@@ -80,14 +80,16 @@ export function useComposerFocus({ ref, autoFocus, disabled = false, onTypeAhead
|
|
|
80
80
|
const el = ref.current;
|
|
81
81
|
if (!el)
|
|
82
82
|
return;
|
|
83
|
+
const canTakeFocus = () => !hasOpenFocusOverlay() &&
|
|
84
|
+
(document.activeElement === el || !isEditableField(document.activeElement));
|
|
83
85
|
if (isVisible(el)) {
|
|
84
|
-
if (
|
|
86
|
+
if (canTakeFocus())
|
|
85
87
|
el.focus();
|
|
86
88
|
return;
|
|
87
89
|
}
|
|
88
90
|
const observer = new IntersectionObserver((entries) => {
|
|
89
91
|
if (entries[0]?.isIntersecting) {
|
|
90
|
-
if (
|
|
92
|
+
if (canTakeFocus())
|
|
91
93
|
ref.current?.focus();
|
|
92
94
|
observer.disconnect();
|
|
93
95
|
}
|
package/dist/session/index.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export { SessionConnectingBanner } from './status/session-starting-loader.js';
|
|
|
53
53
|
export { ChatMinimap } from './thread/chat-minimap.js';
|
|
54
54
|
export { SessionChat } from './thread/session-chat.js';
|
|
55
55
|
export { SessionTurn, TranscriptTurnRow, TurnAssistantBlock } from './thread/transcript.js';
|
|
56
|
+
export { useAgentRunLayout, type AgentRunLayout, type AgentRunRowProps } from './thread/agent-run-props.js';
|
|
56
57
|
export { ToolSurfaceContext, partOutcome } from './tool/shared/infrastructure.js';
|
|
57
58
|
export { ToolOutcomeContext } from './tool/shared/infrastructure-contexts.js';
|
|
58
59
|
export { ToolOutputFallback } from './tool/shared/infrastructure-output.js';
|
package/dist/session/index.js
CHANGED
|
@@ -51,6 +51,7 @@ export { SessionConnectingBanner } from './status/session-starting-loader.js';
|
|
|
51
51
|
export { ChatMinimap } from './thread/chat-minimap.js';
|
|
52
52
|
export { SessionChat } from './thread/session-chat.js';
|
|
53
53
|
export { SessionTurn, TranscriptTurnRow, TurnAssistantBlock } from './thread/transcript.js';
|
|
54
|
+
export { useAgentRunLayout } from './thread/agent-run-props.js';
|
|
54
55
|
export { ToolSurfaceContext, partOutcome } from './tool/shared/infrastructure.js';
|
|
55
56
|
export { ToolOutcomeContext } from './tool/shared/infrastructure-contexts.js';
|
|
56
57
|
export { ToolOutputFallback } from './tool/shared/infrastructure-output.js';
|
|
@@ -5,7 +5,7 @@ import { Button } from '../../primitives/button.js';
|
|
|
5
5
|
import { cn } from '../../lib/utils.js';
|
|
6
6
|
import { useSessionIds } from '../../providers/session-ids.js';
|
|
7
7
|
import { useUiComponents, useUiViewerId } from '../../providers/ui-provider.js';
|
|
8
|
-
import {
|
|
8
|
+
import { useModelAccess, useProjectSession, useSessionProviderSecretPools, } from '@kortix/sdk/react';
|
|
9
9
|
import { useState } from 'react';
|
|
10
10
|
import { chatGptActionApplies } from './chatgpt-connection-action.js';
|
|
11
11
|
import { sessionPersonalUser } from '../overrides/provider-pool-draft.js';
|
|
@@ -23,22 +23,18 @@ export function ChatGptConnectionSlot({ action, className = 'mt-2 pl-7', }) {
|
|
|
23
23
|
return _jsx(ChatGptConnectionButton, { action: action, projectId: projectId, sessionId: sessionId, className: className });
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Opens the ChatGPT accounts dialog
|
|
27
|
-
* secrets and the LLM gateway on. Shown only where connecting or
|
|
26
|
+
* Opens the ChatGPT accounts dialog. Shown only where connecting or
|
|
28
27
|
* reconnecting an account can fix this session (`chatGptActionApplies`).
|
|
29
28
|
*/
|
|
30
29
|
function ChatGptConnectionButton({ action, projectId, sessionId, className, }) {
|
|
31
30
|
const t = useTranslations('pooledSecrets');
|
|
32
31
|
const viewerId = useUiViewerId();
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const session = useProjectSession(projectId, sessionId, { enabled });
|
|
37
|
-
const pools = useSessionProviderSecretPools(enabled ? projectId : null, sessionId);
|
|
32
|
+
const access = useModelAccess(projectId);
|
|
33
|
+
const session = useProjectSession(projectId, sessionId);
|
|
34
|
+
const pools = useSessionProviderSecretPools(projectId, sessionId);
|
|
38
35
|
const [open, setOpen] = useState(false);
|
|
39
36
|
const { ProviderAccountsModal } = useUiComponents();
|
|
40
37
|
const applies = !!ProviderAccountsModal &&
|
|
41
|
-
enabled &&
|
|
42
38
|
!(access.data?.disabledProviders ?? []).includes('codex') &&
|
|
43
39
|
chatGptActionApplies({
|
|
44
40
|
action,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* No model can run: the composer shows the same "Connect ChatGPT" and "Connect
|
|
3
3
|
* Claude" rows the project home offers (`ConnectPlanRows`), a gap below the
|
|
4
|
-
* composer,
|
|
4
|
+
* composer by default, and above it on first-chat home. The rows are not
|
|
5
|
+
* dismissible. Sending is already disabled by `modelUnavailable`.
|
|
5
6
|
*
|
|
6
7
|
* It used to be a heading ("Connect a model to start"), two bordered tiles,
|
|
7
8
|
* "Use an API key" and "Upgrade". On the project home it stacked on top of the
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { CreditCardIcon, ImageBrokenIcon, KeyIcon } from '@phosphor-icons/react';
|
|
4
4
|
import { AnimatePresence, m, useReducedMotion } from 'motion/react';
|
|
5
|
-
import { useState } from 'react';
|
|
5
|
+
import { useContext, useState } from 'react';
|
|
6
6
|
import { useTranslations } from '../../i18n/index.js';
|
|
7
7
|
import { Button } from '../../primitives/button.js';
|
|
8
|
+
import { ModelConnectionLayoutContext } from './model-connection-layout.js';
|
|
8
9
|
import { ConnectPlanRows } from './subscription-offer.js';
|
|
9
10
|
import { useModelConnectionGate } from './use-model-connection-gate.js';
|
|
10
11
|
// Enter waits a beat (delay) so the composer paints first, then the bar slides
|
|
@@ -16,7 +17,8 @@ const BAR_EXIT = { type: 'spring', duration: 0.35, bounce: 0 };
|
|
|
16
17
|
/**
|
|
17
18
|
* No model can run: the composer shows the same "Connect ChatGPT" and "Connect
|
|
18
19
|
* Claude" rows the project home offers (`ConnectPlanRows`), a gap below the
|
|
19
|
-
* composer,
|
|
20
|
+
* composer by default, and above it on first-chat home. The rows are not
|
|
21
|
+
* dismissible. Sending is already disabled by `modelUnavailable`.
|
|
20
22
|
*
|
|
21
23
|
* It used to be a heading ("Connect a model to start"), two bordered tiles,
|
|
22
24
|
* "Use an API key" and "Upgrade". On the project home it stacked on top of the
|
|
@@ -26,7 +28,8 @@ const BAR_EXIT = { type: 'spring', duration: 0.35, bounce: 0 };
|
|
|
26
28
|
* `show` must only flip on settled data (see `entitlementsPending`).
|
|
27
29
|
*/
|
|
28
30
|
export function ModelConnectionBar({ show }) {
|
|
29
|
-
|
|
31
|
+
const above = useContext(ModelConnectionLayoutContext) === 'above';
|
|
32
|
+
return show ? (_jsxs("div", { className: above ? 'mb-4 flex flex-col gap-2' : 'mt-4 flex flex-col gap-1', children: [_jsx(NoModelReason, {}), _jsx(ConnectPlanRows, { dismissible: false })] })) : null;
|
|
30
33
|
}
|
|
31
34
|
/**
|
|
32
35
|
* Why Send is disabled, and the two ways out. A Free account sees no Kortix
|
|
@@ -82,7 +82,7 @@ export interface ModelSelectorProps {
|
|
|
82
82
|
appearance?: 'chip' | 'field' | 'inline';
|
|
83
83
|
projectId?: string;
|
|
84
84
|
/**
|
|
85
|
-
* Offer the member's own ChatGPT subscription
|
|
85
|
+
* Offer the member's own ChatGPT subscription at
|
|
86
86
|
* the end of the list. Only an interactive session can use a personal
|
|
87
87
|
* account; a scheduled or background run cannot, so its pickers leave this off.
|
|
88
88
|
*/
|
|
@@ -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 {
|
|
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
|
|
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
|
|
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:
|
|
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:
|
|
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
|
? {
|
|
@@ -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:
|
|
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(
|
|
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 (
|
|
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) =>
|
|
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
|
-
|
|
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);
|
|
@@ -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 {};
|