@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
|
@@ -35,7 +35,7 @@ export interface ComposerChatCall {
|
|
|
35
35
|
* The current selections are handed to `onSend` / `onCommand` as `options`, so
|
|
36
36
|
* callers never need their own `useRuntimeLocal`.
|
|
37
37
|
*/
|
|
38
|
-
export declare function ComposerChatInput({ onSend, onCommand, sessionId, projectId, isBusy, sessionWorking, runtimeReady, stopDisabled, isSending, disabled, autoFocus, placeholder, hint, prefill, onPrefillApplied, aboveSlot, inputSlot, toolbarSlot, underbarPlacement, slashMenuPlacement, cardClassName, parentClassName, boundAgentName, lockAgent, defaultAgentName, channelAgentNames, projectSession, clearOnSend, onAgentSelectionChange, sandboxSlot, draftScope, draftActive, promptAttachments, submitLabel, onArrowUpAtStart, call, }: {
|
|
38
|
+
export declare function ComposerChatInput({ onSend, onCommand, sessionId, projectId, isBusy, sessionWorking, runtimeReady, stopDisabled, isSending, disabled, autoFocus, placeholder, hint, prefill, onPrefillApplied, aboveSlot, inputSlot, toolbarSlot, underbarPlacement, slashMenuPlacement, cardClassName, parentClassName, boundAgentName, lockAgent, defaultAgentName, channelAgentNames, projectSession, clearOnSend, onAgentSelectionChange, sandboxSlot, draftScope, draftHandoffScope, draftActive, promptAttachments, submitLabel, onArrowUpAtStart, call, }: {
|
|
39
39
|
onSend: (text: string, files: AttachedFile[] | undefined, options: ComposerOptions, attachments?: AttachmentSubmission) => void | Promise<void>;
|
|
40
40
|
onCommand?: (command: Command, args: string | undefined, options: ComposerOptions) => void;
|
|
41
41
|
sessionId?: string;
|
|
@@ -67,6 +67,7 @@ export declare function ComposerChatInput({ onSend, onCommand, sessionId, projec
|
|
|
67
67
|
id: number;
|
|
68
68
|
files?: AttachedFile[];
|
|
69
69
|
mode?: 'replace' | 'merge';
|
|
70
|
+
restoreDraft?: boolean;
|
|
70
71
|
options?: SessionPromptOverrides | null;
|
|
71
72
|
submit?: boolean | 'when-ready';
|
|
72
73
|
} | null;
|
|
@@ -103,6 +104,7 @@ export declare function ComposerChatInput({ onSend, onCommand, sessionId, projec
|
|
|
103
104
|
sandboxSlot?: SessionOverrideSlot;
|
|
104
105
|
/** Persist the unsent draft under this scope — see `composer/draft/`. */
|
|
105
106
|
draftScope?: DraftScope | null;
|
|
107
|
+
draftHandoffScope?: import('react').RefObject<DraftScope | null>;
|
|
106
108
|
draftActive?: boolean;
|
|
107
109
|
/** Host-owned upload controller. See `SessionChatInputProps.promptAttachments`. */
|
|
108
110
|
promptAttachments?: SessionChatInputProps['promptAttachments'];
|
|
@@ -17,7 +17,7 @@ import { inheritedModelFor } from './chat-input/chat-input-summary.js';
|
|
|
17
17
|
* The current selections are handed to `onSend` / `onCommand` as `options`, so
|
|
18
18
|
* callers never need their own `useRuntimeLocal`.
|
|
19
19
|
*/
|
|
20
|
-
export function ComposerChatInput({ onSend, onCommand, sessionId, projectId, isBusy, sessionWorking, runtimeReady, stopDisabled, isSending, disabled, autoFocus, placeholder, hint, prefill, onPrefillApplied, aboveSlot, inputSlot, toolbarSlot, underbarPlacement, slashMenuPlacement, cardClassName, parentClassName, boundAgentName, lockAgent = false, defaultAgentName, channelAgentNames, projectSession, clearOnSend, onAgentSelectionChange, sandboxSlot, draftScope, draftActive, promptAttachments, submitLabel, onArrowUpAtStart, call, }) {
|
|
20
|
+
export function ComposerChatInput({ onSend, onCommand, sessionId, projectId, isBusy, sessionWorking, runtimeReady, stopDisabled, isSending, disabled, autoFocus, placeholder, hint, prefill, onPrefillApplied, aboveSlot, inputSlot, toolbarSlot, underbarPlacement, slashMenuPlacement, cardClassName, parentClassName, boundAgentName, lockAgent = false, defaultAgentName, channelAgentNames, projectSession, clearOnSend, onAgentSelectionChange, sandboxSlot, draftScope, draftHandoffScope, draftActive, promptAttachments, submitLabel, onArrowUpAtStart, call, }) {
|
|
21
21
|
const contextAutoFocus = useContext(ComposerAutoFocusContext);
|
|
22
22
|
const { data: rosterAgents } = useRuntimeAgents({ projectId });
|
|
23
23
|
const agents = useMemo(() => withChannelAgents(rosterAgents, channelAgentNames), [rosterAgents, channelAgentNames]);
|
|
@@ -151,7 +151,7 @@ export function ComposerChatInput({ onSend, onCommand, sessionId, projectId, isB
|
|
|
151
151
|
// A thread a space's chat opened by itself does not take the focus (`ComposerAutoFocusContext`).
|
|
152
152
|
autoFocus: autoFocus ?? (contextAutoFocus ? undefined : false), placeholder: placeholder, hint: hint, prefill: deliveredPrefill, onPrefillApplied: onPrefillApplied, aboveSlot: aboveSlot, inputSlot: inputSlot, toolbarSlot: combinedToolbarSlot, underbarPlacement: underbarPlacement, slashMenuPlacement: slashMenuPlacement, cardClassName: cardClassName, parentClassName: parentClassName, sessionId: sessionId, projectId: projectId, providers: providers, agents: local.agent.list, selectedAgent: selectedAgentName, noAccessibleAgents: noAccessibleAgents, agentLocked: agentLocked,
|
|
153
153
|
// A locked agent has nothing to switch to: no handler is the composer's "fixed agent" signal.
|
|
154
|
-
onAgentChange: agentLocked ? undefined : (name) => local.agent.set(name ?? undefined), models: local.model.list, selectedModel: local.model.currentKey ?? null, onModelChange: (m) => local.model.set(m ?? undefined, { recent: true }), inheritedModel: inheritedModelFor(local.model, selectedAgentName), modelRequired: true, modelsLoading: providersLoading, variants: local.model.variant.list, selectedVariant: local.model.variant.current ?? null, onVariantChange: (v) => local.model.variant.set(v ?? undefined), commands: commands || [], commandsResolved: commands !== undefined, draftScope: draftScope, draftActive: draftActive, submitLabel: submitLabel, onArrowUpAtStart: onArrowUpAtStart, call: call && selectedAgentName
|
|
154
|
+
onAgentChange: agentLocked ? undefined : (name) => local.agent.set(name ?? undefined), models: local.model.list, selectedModel: local.model.currentKey ?? null, onModelChange: (m) => local.model.set(m ?? undefined, { recent: true }), inheritedModel: inheritedModelFor(local.model, selectedAgentName), modelRequired: true, modelsLoading: providersLoading, variants: local.model.variant.list, selectedVariant: local.model.variant.current ?? null, onVariantChange: (v) => local.model.variant.set(v ?? undefined), commands: commands || [], commandsResolved: commands !== undefined, draftScope: draftScope, draftHandoffScope: draftHandoffScope, draftActive: draftActive, submitLabel: submitLabel, onArrowUpAtStart: onArrowUpAtStart, call: call && selectedAgentName
|
|
155
155
|
? { inCall: call.inCall, onCall: () => call.onCall({ ...options(), agent: selectedAgentName }) }
|
|
156
156
|
: undefined }));
|
|
157
157
|
}
|
|
@@ -194,6 +194,13 @@ export declare function planPrefillMerge(input: {
|
|
|
194
194
|
/** `editorRef.current.isEmpty()`. */
|
|
195
195
|
currentIsEmpty: boolean;
|
|
196
196
|
}): JSONContent | null;
|
|
197
|
+
/**
|
|
198
|
+
* `doc` with `text` added to the end of its last paragraph (or in a new
|
|
199
|
+
* paragraph when the last block is not one). Keys typed before the editor
|
|
200
|
+
* existed continue the restored draft this way (`prefill.restoreDraft`).
|
|
201
|
+
* `text` must be non-empty: ProseMirror text nodes cannot be empty.
|
|
202
|
+
*/
|
|
203
|
+
export declare function appendTextToDocument(doc: JSONContent, text: string): JSONContent;
|
|
197
204
|
export interface ShouldApplyPrefillInput {
|
|
198
205
|
/** `prefill?.id` — `undefined` means "no prefill at all". */
|
|
199
206
|
prefillId: number | undefined;
|
|
@@ -194,6 +194,24 @@ export function planPrefillMerge(input) {
|
|
|
194
194
|
const merged = mergeFailedSubmissionDocument(input.currentDoc, input.currentIsEmpty, input.prefillDoc, input.prefillIsEmpty);
|
|
195
195
|
return merged === input.currentDoc ? null : merged;
|
|
196
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* `doc` with `text` added to the end of its last paragraph (or in a new
|
|
199
|
+
* paragraph when the last block is not one). Keys typed before the editor
|
|
200
|
+
* existed continue the restored draft this way (`prefill.restoreDraft`).
|
|
201
|
+
* `text` must be non-empty: ProseMirror text nodes cannot be empty.
|
|
202
|
+
*/
|
|
203
|
+
export function appendTextToDocument(doc, text) {
|
|
204
|
+
const content = [...(doc.content ?? [])];
|
|
205
|
+
const last = content[content.length - 1];
|
|
206
|
+
const node = { type: 'text', text };
|
|
207
|
+
if (last?.type === 'paragraph') {
|
|
208
|
+
content[content.length - 1] = { ...last, content: [...(last.content ?? []), node] };
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
content.push({ type: 'paragraph', content: [node] });
|
|
212
|
+
}
|
|
213
|
+
return { ...doc, type: 'doc', content };
|
|
214
|
+
}
|
|
197
215
|
/**
|
|
198
216
|
* Whether a `prefill` prop should be applied right now.
|
|
199
217
|
*
|
|
@@ -4,21 +4,15 @@ import type { AttachedFile } from './session-chat-input.js';
|
|
|
4
4
|
*
|
|
5
5
|
* - `true` — every in-thread composer. It stays mounted, so it resets in
|
|
6
6
|
* place and revokes the local object URLs nobody references any more.
|
|
7
|
-
* - `'text-only'` —
|
|
8
|
-
* message visibly LEAVES the box, but it revokes
|
|
9
|
-
* URLs are what the
|
|
10
|
-
*
|
|
7
|
+
* - `'text-only'` — a space composer (`space-view.tsx`). It clears like any
|
|
8
|
+
* other composer, so the message visibly LEAVES the box, but it revokes
|
|
9
|
+
* nothing: the same local URLs are what the new thread draws its
|
|
10
|
+
* attachment previews from a moment later.
|
|
11
11
|
* - `false` — a composer that must keep the submitted draft on screen
|
|
12
|
-
* untouched. Nothing clears and nothing is revoked.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* for one reason (the URLs), and the text half was the visible cost: Enter left
|
|
17
|
-
* the sentence sitting in a locked box under a spinner for the whole create
|
|
18
|
-
* round trip (measured 1165ms end to end on localhost, `POST .../sessions`
|
|
19
|
-
* alone 908ms; longer over a real network), which reads as a send that did not
|
|
20
|
-
* happen. Splitting them lets the box empty at the keypress, like everywhere
|
|
21
|
-
* else in the app, with the previews still intact when the shell takes over.
|
|
12
|
+
* untouched. Nothing clears and nothing is revoked. Project home is one:
|
|
13
|
+
* the sent message stays in the locked box under the spinner until the
|
|
14
|
+
* session page opens, so the user sees what is being sent and a refused
|
|
15
|
+
* send leaves the text in place.
|
|
22
16
|
*/
|
|
23
17
|
export type ComposerSendReset = boolean | 'text-only';
|
|
24
18
|
/**
|
|
@@ -94,6 +94,8 @@ export interface ComposerToolbarProps {
|
|
|
94
94
|
leading?: React.ReactNode;
|
|
95
95
|
/** The `chat_input` control holds model and effort: this toolbar draws neither. */
|
|
96
96
|
pickersInChatInput?: boolean;
|
|
97
|
+
/** The agent runs a program (`run`), not a model: this toolbar draws neither model nor effort. */
|
|
98
|
+
noModel?: boolean;
|
|
97
99
|
isSending: boolean;
|
|
98
100
|
isBusy: boolean;
|
|
99
101
|
onStop?: () => void;
|
|
@@ -121,4 +123,4 @@ export interface ComposerToolbarProps {
|
|
|
121
123
|
call?: ComposerCall;
|
|
122
124
|
onSubmit: () => void;
|
|
123
125
|
}
|
|
124
|
-
export declare function ComposerToolbar({ models, modelsLoading, selectedModel, onModelChange, modelDefaultControls, providers, modelRequired, modelMenuOpen, onModelMenuOpenChange, reasoningMenuOpen, onReasoningMenuOpenChange, variants, selectedVariant, onVariantChange, projectId, toolbarSlot, rewind, leading, pickersInChatInput, isSending, isBusy, onStop, stopDisabled, canStop, escCount, lockForQuestion, questionButtonLabel, submitLabel, questionCanAct, hasText, canSubmit, submitDisabled, disabled, modelUnavailable, agentUnavailable, attachmentFailed, attachmentUnsupported, call, onSubmit, }: ComposerToolbarProps): import("react").JSX.Element;
|
|
126
|
+
export declare function ComposerToolbar({ models, modelsLoading, selectedModel, onModelChange, modelDefaultControls, providers, modelRequired, modelMenuOpen, onModelMenuOpenChange, reasoningMenuOpen, onReasoningMenuOpenChange, variants, selectedVariant, onVariantChange, projectId, toolbarSlot, rewind, leading, pickersInChatInput, noModel, isSending, isBusy, onStop, stopDisabled, canStop, escCount, lockForQuestion, questionButtonLabel, submitLabel, questionCanAct, hasText, canSubmit, submitDisabled, disabled, modelUnavailable, agentUnavailable, attachmentFailed, attachmentUnsupported, call, onSubmit, }: ComposerToolbarProps): import("react").JSX.Element;
|
|
@@ -9,10 +9,10 @@ import Loading from '../../primitives/loading.js';
|
|
|
9
9
|
import { ModelSelector } from '../models/model-selector.js';
|
|
10
10
|
import { ReasoningEffortSelector } from './reasoning-effort-selector.js';
|
|
11
11
|
import { SendStopControl } from './send-stop-control.js';
|
|
12
|
-
export function ComposerToolbar({ models, modelsLoading, selectedModel, onModelChange, modelDefaultControls, providers, modelRequired, modelMenuOpen, onModelMenuOpenChange, reasoningMenuOpen, onReasoningMenuOpenChange, variants, selectedVariant, onVariantChange, projectId, toolbarSlot, rewind, leading, pickersInChatInput = false, isSending, isBusy, onStop, stopDisabled, canStop, escCount, lockForQuestion, questionButtonLabel, submitLabel, questionCanAct, hasText, canSubmit, submitDisabled, disabled, modelUnavailable, agentUnavailable = false, attachmentFailed = false, attachmentUnsupported = null, call, onSubmit, }) {
|
|
12
|
+
export function ComposerToolbar({ models, modelsLoading, selectedModel, onModelChange, modelDefaultControls, providers, modelRequired, modelMenuOpen, onModelMenuOpenChange, reasoningMenuOpen, onReasoningMenuOpenChange, variants, selectedVariant, onVariantChange, projectId, toolbarSlot, rewind, leading, pickersInChatInput = false, noModel = false, isSending, isBusy, onStop, stopDisabled, canStop, escCount, lockForQuestion, questionButtonLabel, submitLabel, questionCanAct, hasText, canSubmit, submitDisabled, disabled, modelUnavailable, agentUnavailable = false, attachmentFailed = false, attachmentUnsupported = null, call, onSubmit, }) {
|
|
13
13
|
const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
|
|
14
14
|
const { modelPickerEnabled } = useUiHostConfig();
|
|
15
|
-
const showModel = !pickersInChatInput && modelPickerEnabled && (models.length > 0 || modelRequired) && !!onModelChange;
|
|
15
|
+
const showModel = !noModel && !pickersInChatInput && modelPickerEnabled && (models.length > 0 || modelRequired) && !!onModelChange;
|
|
16
16
|
// Either `/` palette row opens the one merged popover.
|
|
17
17
|
const pickerOpen = modelMenuOpen === undefined && reasoningMenuOpen === undefined
|
|
18
18
|
? undefined
|
|
@@ -22,7 +22,7 @@ export function ComposerToolbar({ models, modelsLoading, selectedModel, onModelC
|
|
|
22
22
|
if (!next)
|
|
23
23
|
onReasoningMenuOpenChange?.(false);
|
|
24
24
|
};
|
|
25
|
-
return (_jsxs("div", { className: "kortix-composer-toolbar flex items-center justify-between gap-1 overflow-visible", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-1 overflow-visible", children: [leading, showModel && (_jsx(ModelSelector, { models: models, modelsLoading: modelsLoading, selectedModel: selectedModel, onSelect: onModelChange, providers: providers, defaultControls: modelDefaultControls, triggerLabelClassName: "max-w-[7rem]", projectId: projectId, offerProviderAccounts: true, open: pickerOpen, onOpenChange: onPickerOpenChange, reasoning: { variants, selectedVariant, onVariantChange } })), !showModel && modelPickerEnabled && !pickersInChatInput && _jsx(ReasoningEffortSelector, { variants: variants, selectedVariant: selectedVariant, onVariantChange: onVariantChange, open: reasoningMenuOpen, onOpenChange: onReasoningMenuOpenChange })] }), _jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [rewind && (_jsxs(HoverCard, { openDelay: 0, closeDelay: 0, children: [_jsx(HoverCardTrigger, { asChild: true, children: _jsx("span", { className: "inline-flex", children: _jsxs(Button, { type: "button", variant: "ghost", size: "sm", disabled: rewind.pending || rewind.disabled, onClick: rewind.onRestore, className: "text-muted-foreground hover:text-foreground gap-1.5", children: [rewind.pending ? (_jsx(Loading, { className: "size-3.5 shrink-0" })) : (_jsx(ArrowCounterClockwiseIcon, { className: "size-3.5 shrink-0" })), tI18nComplete.raw('texta76e13b98392')] }) }) }), _jsx(HoverCardContent, { className: "px-3 py-2 text-sm text-balance", children: rewind.disabled && !rewind.pending
|
|
25
|
+
return (_jsxs("div", { className: "kortix-composer-toolbar flex items-center justify-between gap-1 overflow-visible", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-1 overflow-visible", children: [leading, showModel && (_jsx(ModelSelector, { models: models, modelsLoading: modelsLoading, selectedModel: selectedModel, onSelect: onModelChange, providers: providers, defaultControls: modelDefaultControls, triggerLabelClassName: "max-w-[7rem]", projectId: projectId, offerProviderAccounts: true, open: pickerOpen, onOpenChange: onPickerOpenChange, reasoning: { variants, selectedVariant, onVariantChange } })), !showModel && !noModel && modelPickerEnabled && !pickersInChatInput && _jsx(ReasoningEffortSelector, { variants: variants, selectedVariant: selectedVariant, onVariantChange: onVariantChange, open: reasoningMenuOpen, onOpenChange: onReasoningMenuOpenChange })] }), _jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [rewind && (_jsxs(HoverCard, { openDelay: 0, closeDelay: 0, children: [_jsx(HoverCardTrigger, { asChild: true, children: _jsx("span", { className: "inline-flex", children: _jsxs(Button, { type: "button", variant: "ghost", size: "sm", disabled: rewind.pending || rewind.disabled, onClick: rewind.onRestore, className: "text-muted-foreground hover:text-foreground gap-1.5", children: [rewind.pending ? (_jsx(Loading, { className: "size-3.5 shrink-0" })) : (_jsx(ArrowCounterClockwiseIcon, { className: "size-3.5 shrink-0" })), tI18nComplete.raw('texta76e13b98392')] }) }) }), _jsx(HoverCardContent, { className: "px-3 py-2 text-sm text-balance", children: rewind.disabled && !rewind.pending
|
|
26
26
|
? tI18nComplete.raw('text98433e61649a')
|
|
27
27
|
: tI18nComplete.raw('text4c25090df9ea') })] })), toolbarSlot, _jsx(SendStopControl, { isSending: isSending, isBusy: isBusy, onStop: onStop, stopDisabled: stopDisabled, canStop: canStop, escCount: escCount, lockForQuestion: lockForQuestion, questionButtonLabel: questionButtonLabel, submitLabel: submitLabel, questionCanAct: questionCanAct, hasText: hasText, canSubmit: canSubmit, submitDisabled: submitDisabled, disabled: disabled, modelUnavailable: modelUnavailable, agentUnavailable: agentUnavailable, attachmentFailed: attachmentFailed, attachmentUnsupported: attachmentUnsupported, call: call, onSubmit: onSubmit })] })] }));
|
|
28
28
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Agent, Command, FlatModel, ProviderListResponse, UsePromptAttachmentsResult } from '@kortix/sdk/react';
|
|
2
2
|
import { type SessionLogMessage } from '@kortix/sdk';
|
|
3
|
+
import type { RefObject } from 'react';
|
|
3
4
|
import { type ComposerSendReset } from './composer-reset.js';
|
|
4
5
|
import { type ModelDefaultControls } from '../models/model-selector.js';
|
|
5
6
|
import type { DraftScope } from './draft/composer-draft.js';
|
|
@@ -158,6 +159,7 @@ export interface SessionChatInputProps {
|
|
|
158
159
|
* marketing-demo composers rely on.
|
|
159
160
|
*/
|
|
160
161
|
draftScope?: DraftScope | null;
|
|
162
|
+
draftHandoffScope?: RefObject<DraftScope | null>;
|
|
161
163
|
draftActive?: boolean;
|
|
162
164
|
disabled?: boolean;
|
|
163
165
|
/**
|
|
@@ -203,6 +205,13 @@ export interface SessionChatInputProps {
|
|
|
203
205
|
id: number;
|
|
204
206
|
files?: AttachedFile[];
|
|
205
207
|
mode?: 'replace' | 'merge';
|
|
208
|
+
/**
|
|
209
|
+
* Restore the saved draft first, then merge this text after it. Only the
|
|
210
|
+
* home typing buffer sets it (`use-home-typing-buffer.ts`): keys typed
|
|
211
|
+
* while the page loaded continue the draft. Any other prefill still wins
|
|
212
|
+
* over the draft.
|
|
213
|
+
*/
|
|
214
|
+
restoreDraft?: boolean;
|
|
206
215
|
/**
|
|
207
216
|
* Submit the prefill once it has landed, exactly as if the person pressed
|
|
208
217
|
* Enter. For one-click starters (the first chat's "Update memory"): the
|
|
@@ -25,7 +25,7 @@ import { ComposerCard } from './ComposerCard.js';
|
|
|
25
25
|
import { handleBillingError } from '../../internal/lib/error-handler.js';
|
|
26
26
|
import { attachedFileUploadId, attachmentsBlockSend, captureAttachmentSubmission, dispatchLatched, planAttachmentReplacement, refusedFilesToast, runComposerSend, heldTraySizes, splitComposerFiles, stageComposerFiles, takeNewBillingRefusals, } from './attachment-submission.js';
|
|
27
27
|
import { draftWillRunCommand, planCommandAttachments, planUnresolvedCommandChip, readCommandChipLabel, } from './command-attachments.js';
|
|
28
|
-
import { appendComposerQuote, classifyPaste, isUndoKey, popPasteUndo, extractReplyQuotes, nextPastedTextFileName, planDraftSubmission, planFailedSendRecovery, planPrefillMerge, planQuoteRequests, removeComposerQuote, resolveEditorPlaceholder, restoreComposerQuotes, shouldApplyPrefill, shouldSubmitPrefill, shouldSubmitWhenReady, textToDocument, } from './composer-logic.js';
|
|
28
|
+
import { appendComposerQuote, classifyPaste, isUndoKey, popPasteUndo, extractReplyQuotes, nextPastedTextFileName, planDraftSubmission, planFailedSendRecovery, planPrefillMerge, appendTextToDocument, planQuoteRequests, removeComposerQuote, resolveEditorPlaceholder, restoreComposerQuotes, shouldApplyPrefill, shouldSubmitPrefill, shouldSubmitWhenReady, textToDocument, } from './composer-logic.js';
|
|
29
29
|
import { getContextUsage } from './context-ring.js';
|
|
30
30
|
import { useComposerFocus } from './hooks/use-composer-focus.js';
|
|
31
31
|
import { useMenuRevalidation } from './hooks/use-file-search.js';
|
|
@@ -103,18 +103,14 @@ const useNoSlashActions = () => NO_SLASH_ACTIONS;
|
|
|
103
103
|
function setDocumentWithoutStealingFocus(handle, doc) {
|
|
104
104
|
if (!handle)
|
|
105
105
|
return;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
handle.setDocument(doc);
|
|
110
|
-
if (!wasFocused) {
|
|
111
|
-
previouslyFocused?.focus?.();
|
|
112
|
-
}
|
|
106
|
+
// A focus command schedules a later animation frame. Restoring DOM focus
|
|
107
|
+
// immediately after it cannot cancel that scheduled focus.
|
|
108
|
+
handle.setDocument(doc, false);
|
|
113
109
|
}
|
|
114
110
|
function ComposerImpl(props) {
|
|
115
111
|
const { onSend, promptAttachments: hostPromptAttachments, isBusy = false, sessionWorking, runtimeReady = true, onStop, stopDisabled = false, isSending = false, rewind, agents = EMPTY_AGENTS, selectedAgent = null, onAgentChange, noAccessibleAgents = false, commands: runtimeCommands = EMPTY_COMMANDS,
|
|
116
112
|
/** Whether the live command list has EVER resolved — see `planUnresolvedCommandChip`. */
|
|
117
|
-
commandsResolved = false, slashFiles = EMPTY_SLASH_FILES, onCommand, onHoldCommand, models = EMPTY_MODELS, selectedModel = null, onModelChange, modelDefaultControls, variants = EMPTY_VARIANTS, selectedVariant = null, onVariantChange, messages, sessionId, projectId, draftScope = null, draftActive = true, disabled = false, notice = null, onNoticeRetry, clearOnSend = true, modelRequired = false, modelsLoading = false, autoFocus, placeholder = 'Ask anything…', hint, onArrowUpAtStart, prefill = null, onPrefillApplied, attachRequestId = null, providers, onContextClick, onCompactClick, inputSlot, toolbarSlot, underbarPlacement = 'below', slashMenuPlacement = 'above', cardClassName, quoteRequests = NO_QUOTE_REQUESTS, onQuoteRequestsApplied, lockForQuestion = false, lockForApproval = false, onCustomAnswer, questionButtonLabel = null, questionCanAct = true, onQuestionAction, escCount = 0, parentClassName, } = props;
|
|
113
|
+
commandsResolved = false, slashFiles = EMPTY_SLASH_FILES, onCommand, onHoldCommand, models = EMPTY_MODELS, selectedModel = null, onModelChange, modelDefaultControls, variants = EMPTY_VARIANTS, selectedVariant = null, onVariantChange, messages, sessionId, projectId, draftScope = null, draftHandoffScope, draftActive = true, disabled = false, notice = null, onNoticeRetry, clearOnSend = true, modelRequired = false, modelsLoading = false, autoFocus, placeholder = 'Ask anything…', hint, onArrowUpAtStart, prefill = null, onPrefillApplied, attachRequestId = null, providers, onContextClick, onCompactClick, inputSlot, toolbarSlot, underbarPlacement = 'below', slashMenuPlacement = 'above', cardClassName, quoteRequests = NO_QUOTE_REQUESTS, onQuoteRequestsApplied, lockForQuestion = false, lockForApproval = false, onCustomAnswer, questionButtonLabel = null, questionCanAct = true, onQuestionAction, escCount = 0, parentClassName, } = props;
|
|
118
114
|
const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
|
|
119
115
|
const tModelGate = useTranslations('sessionUi.modelGate');
|
|
120
116
|
const tComposerAttachments = useTranslations('hardcodedUi.composerAttachments');
|
|
@@ -307,13 +303,14 @@ function ComposerImpl(props) {
|
|
|
307
303
|
const { handleDocChange, clearSavedDraft } = useComposerDraft({
|
|
308
304
|
active: draftActive,
|
|
309
305
|
scope: draftScope,
|
|
306
|
+
handoffScope: draftHandoffScope,
|
|
310
307
|
editorRef,
|
|
311
308
|
editorReady: editorElement != null,
|
|
312
309
|
attachedFiles,
|
|
313
310
|
quotes: quoteTexts,
|
|
314
311
|
pastes,
|
|
315
312
|
uploads: draftUploads,
|
|
316
|
-
hasPrefill: !!prefill,
|
|
313
|
+
hasPrefill: !!prefill && !prefill.restoreDraft,
|
|
317
314
|
onRestore: handleDraftRestore,
|
|
318
315
|
});
|
|
319
316
|
/**
|
|
@@ -746,11 +743,14 @@ function ComposerImpl(props) {
|
|
|
746
743
|
const prefillText = prefill?.text ?? '';
|
|
747
744
|
const prefillFiles = prefill?.files;
|
|
748
745
|
const prefillMode = prefill?.mode;
|
|
746
|
+
const prefillRestoreDraft = prefill?.restoreDraft === true;
|
|
749
747
|
const prefillSubmit = prefill?.submit === true;
|
|
750
748
|
// `handleSubmit` is declared further down; the prefill effect reaches it
|
|
751
749
|
// through this ref, bound in an effect right after that declaration.
|
|
752
750
|
const handleSubmitRef = useRef(() => undefined);
|
|
753
751
|
const submittedPrefillIdRef = useRef(null);
|
|
752
|
+
// An append is not idempotent: each `restoreDraft` prefill lands once.
|
|
753
|
+
const appendedPrefillIdRef = useRef(null);
|
|
754
754
|
// The prefill id that landed in the editor: `'when-ready'` submits only after it.
|
|
755
755
|
const [landedPrefillId, setLandedPrefillId] = useState(null);
|
|
756
756
|
const onPrefillAppliedRef = useRef(onPrefillApplied);
|
|
@@ -777,7 +777,17 @@ function ComposerImpl(props) {
|
|
|
777
777
|
const quoted = extractReplyQuotes(prefillText);
|
|
778
778
|
const pasted = splitPastedContent(quoted.text);
|
|
779
779
|
const incoming = { quotes: quoted.quotes, text: pasted.text };
|
|
780
|
-
if (
|
|
780
|
+
if (prefillRestoreDraft) {
|
|
781
|
+
// Keys typed while the page loaded continue the restored draft, at its
|
|
782
|
+
// end, where the caret lands (`setDocument` focuses the end). The draft
|
|
783
|
+
// is already in the editor: `useComposerDraft`'s restore effect is
|
|
784
|
+
// declared above this one, so it runs first in the same commit.
|
|
785
|
+
if (incoming.text && appendedPrefillIdRef.current !== prefillId) {
|
|
786
|
+
appendedPrefillIdRef.current = prefillId;
|
|
787
|
+
editorRef.current?.setDocument(appendTextToDocument(editorRef.current?.getDocument() ?? EMPTY_DOCUMENT, incoming.text));
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
else if (prefillMode === 'merge') {
|
|
781
791
|
const merged = planPrefillMerge({
|
|
782
792
|
prefillDoc: textToDocument(incoming.text),
|
|
783
793
|
prefillIsEmpty: incoming.text.length === 0,
|
|
@@ -853,6 +863,7 @@ function ComposerImpl(props) {
|
|
|
853
863
|
prefillText,
|
|
854
864
|
prefillFiles,
|
|
855
865
|
prefillMode,
|
|
866
|
+
prefillRestoreDraft,
|
|
856
867
|
prefillSubmit,
|
|
857
868
|
editorElement,
|
|
858
869
|
addPromptAttachments,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DraftScope } from './composer-draft.js';
|
|
2
|
+
import type { ComposerEditorHandle } from '../editor/composer-editor.js';
|
|
3
|
+
/** Called by the destination's draft lifecycle after restoration, including an empty draft. */
|
|
4
|
+
export declare function completeHomeComposerFocus(scope: DraftScope, editor: ComposerEditorHandle): void;
|
|
5
|
+
export declare function registerHomeComposerEditor(editor: ComposerEditorHandle | null): void;
|
|
6
|
+
/** Own only BODY keyboard input between the home editor and its destination restore. */
|
|
7
|
+
export declare function handoffHomeComposerFocus(sessionId: string, userId: string): void;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { EditorState, TextSelection } from '@tiptap/pm/state';
|
|
2
|
+
import { deleteSelection, joinBackward, selectNodeBackward, splitBlock } from '@tiptap/pm/commands';
|
|
3
|
+
import { readDraft, writeDraft } from './composer-draft-store.js';
|
|
4
|
+
import { serializeDraft } from './composer-draft.js';
|
|
5
|
+
let pending = null;
|
|
6
|
+
/** Called by the destination's draft lifecycle after restoration, including an empty draft. */
|
|
7
|
+
export function completeHomeComposerFocus(scope, editor) {
|
|
8
|
+
if (scope.kind === 'session' && pending?.sessionId === scope.sessionId)
|
|
9
|
+
pending.finish(editor);
|
|
10
|
+
}
|
|
11
|
+
/** The source registers its handle; no global textbox search chooses the destination. */
|
|
12
|
+
let sourceEditor = null;
|
|
13
|
+
export function registerHomeComposerEditor(editor) {
|
|
14
|
+
sourceEditor = editor;
|
|
15
|
+
}
|
|
16
|
+
/** Own only BODY keyboard input between the home editor and its destination restore. */
|
|
17
|
+
export function handoffHomeComposerFocus(sessionId, userId) {
|
|
18
|
+
const original = document.activeElement;
|
|
19
|
+
if (!(original instanceof HTMLElement) || !original.matches('[contenteditable="true"][role="textbox"]'))
|
|
20
|
+
return;
|
|
21
|
+
const schema = sourceEditor?.getEditingState()?.schema;
|
|
22
|
+
if (!schema)
|
|
23
|
+
return;
|
|
24
|
+
let state = null;
|
|
25
|
+
const scope = { kind: 'session', sessionId };
|
|
26
|
+
let timer;
|
|
27
|
+
const stop = () => {
|
|
28
|
+
if (pending?.finish === finish)
|
|
29
|
+
pending = null;
|
|
30
|
+
clearTimeout(timer);
|
|
31
|
+
document.removeEventListener('keydown', onKey, true);
|
|
32
|
+
document.removeEventListener('pointerdown', stop, true);
|
|
33
|
+
document.removeEventListener('focusin', onFocus, true);
|
|
34
|
+
};
|
|
35
|
+
const finish = (editor) => {
|
|
36
|
+
const ownsFocus = document.activeElement === document.body || document.activeElement === editor.getElement();
|
|
37
|
+
stop();
|
|
38
|
+
const element = editor.getElement();
|
|
39
|
+
if (ownsFocus && element) {
|
|
40
|
+
element.focus();
|
|
41
|
+
const range = document.createRange();
|
|
42
|
+
range.selectNodeContents(element);
|
|
43
|
+
range.collapse(false);
|
|
44
|
+
const selection = window.getSelection();
|
|
45
|
+
selection?.removeAllRanges();
|
|
46
|
+
selection?.addRange(range);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const onFocus = (event) => {
|
|
50
|
+
if (event.target !== original && event.target !== document.body && event.target instanceof HTMLElement &&
|
|
51
|
+
!event.target.matches('[contenteditable="true"][role="textbox"]'))
|
|
52
|
+
stop();
|
|
53
|
+
};
|
|
54
|
+
const onKey = (event) => {
|
|
55
|
+
if (document.activeElement !== document.body || event.ctrlKey || event.metaKey || event.altKey)
|
|
56
|
+
return;
|
|
57
|
+
if (event.key.length !== 1 && event.key !== 'Backspace' && event.key !== 'Enter')
|
|
58
|
+
return;
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
const draft = readDraft(scope, userId) ?? serializeDraft({
|
|
61
|
+
doc: { type: 'doc', content: [] }, documentIsEmpty: false, files: [], userId,
|
|
62
|
+
});
|
|
63
|
+
if (!draft)
|
|
64
|
+
return;
|
|
65
|
+
if (!state) {
|
|
66
|
+
const doc = schema.nodeFromJSON(draft.doc);
|
|
67
|
+
state = EditorState.create({ schema, doc, selection: TextSelection.atEnd(doc) });
|
|
68
|
+
}
|
|
69
|
+
const dispatch = (transaction) => {
|
|
70
|
+
state = state.apply(transaction);
|
|
71
|
+
};
|
|
72
|
+
if (event.key === 'Backspace') {
|
|
73
|
+
if (!deleteSelection(state, dispatch)) {
|
|
74
|
+
const before = state.selection.$from.nodeBefore;
|
|
75
|
+
if (before?.isInline) {
|
|
76
|
+
const size = before.isText ? (Array.from(before.text ?? '').at(-1)?.length ?? 1) : before.nodeSize;
|
|
77
|
+
dispatch(state.tr.delete(state.selection.from - size, state.selection.from));
|
|
78
|
+
}
|
|
79
|
+
else if (!joinBackward(state, dispatch))
|
|
80
|
+
selectNodeBackward(state, dispatch);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else if (event.key === 'Enter')
|
|
84
|
+
splitBlock(state, dispatch);
|
|
85
|
+
else
|
|
86
|
+
dispatch(state.tr.insertText(event.key));
|
|
87
|
+
writeDraft(scope, { ...draft, doc: state.doc.toJSON() });
|
|
88
|
+
};
|
|
89
|
+
pending = { sessionId, finish };
|
|
90
|
+
document.addEventListener('keydown', onKey, true);
|
|
91
|
+
document.addEventListener('pointerdown', stop, true);
|
|
92
|
+
document.addEventListener('focusin', onFocus, true);
|
|
93
|
+
timer = window.setTimeout(stop, 30_000);
|
|
94
|
+
}
|
|
@@ -6,6 +6,8 @@ import type { AttachedFile } from '../types.js';
|
|
|
6
6
|
import { type DraftScope, type StoredDraft, type StoredUpload } from './composer-draft.js';
|
|
7
7
|
export interface UseComposerDraftInput {
|
|
8
8
|
active?: boolean;
|
|
9
|
+
/** Move the remaining home draft into the created session on unmount. */
|
|
10
|
+
handoffScope?: RefObject<DraftScope | null>;
|
|
9
11
|
/** Omitted or null → the composer persists nothing (marketing demo, tests). */
|
|
10
12
|
scope: DraftScope | null | undefined;
|
|
11
13
|
editorRef: RefObject<ComposerEditorHandle | null>;
|
|
@@ -46,4 +48,4 @@ export interface UseComposerDraftResult {
|
|
|
46
48
|
* render-silent while typing (`editor/composer-editor.tsx`'s `onEmptyChange`
|
|
47
49
|
* contract) and lifting the document into state would defeat it.
|
|
48
50
|
*/
|
|
49
|
-
export declare function useComposerDraft({ active, scope, editorRef, editorReady, attachedFiles, quotes, pastes, uploads, hasPrefill, onRestore, }: UseComposerDraftInput): UseComposerDraftResult;
|
|
51
|
+
export declare function useComposerDraft({ active, handoffScope, scope, editorRef, editorReady, attachedFiles, quotes, pastes, uploads, hasPrefill, onRestore, }: UseComposerDraftInput): UseComposerDraftResult;
|
|
@@ -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
|
|
@@ -351,6 +354,9 @@ export const ComposerEditor = forwardRef(function ComposerEditor({ placeholder,
|
|
|
351
354
|
role: 'textbox',
|
|
352
355
|
'aria-multiline': 'true',
|
|
353
356
|
'aria-label': t('messageInput'),
|
|
357
|
+
// A locale-free hook for code outside the composer that must know
|
|
358
|
+
// the editor exists (`use-home-typing-buffer.ts` in apps/web).
|
|
359
|
+
'data-composer-editor': '',
|
|
354
360
|
/**
|
|
355
361
|
* `min-h-[3.5em]` — taller than one line by design. History: was
|
|
356
362
|
* `1.5em` (exactly one line) on the reasoning that a taller floor
|
|
@@ -397,10 +403,9 @@ export const ComposerEditor = forwardRef(function ComposerEditor({ placeholder,
|
|
|
397
403
|
* dev.kortix.com: clear at T, phantom write at T+406ms, and the next
|
|
398
404
|
* visit to project home restored "Hi" into the composer.
|
|
399
405
|
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
* debounce away from the same bug.
|
|
406
|
+
* Project home keeps the sent text in the locked box again, so this
|
|
407
|
+
* guard is what keeps the message out of the saved draft. Every composer
|
|
408
|
+
* that flips `disabled` mid-send is one debounce away from the same bug.
|
|
404
409
|
*
|
|
405
410
|
* The view still refreshes — `setOptions` calls `view.updateState`
|
|
406
411
|
* whether or not the event is emitted.
|
|
@@ -447,7 +452,8 @@ export const ComposerEditor = forwardRef(function ComposerEditor({ placeholder,
|
|
|
447
452
|
editor.commands.focus(caret, { scrollIntoView: false });
|
|
448
453
|
},
|
|
449
454
|
getDocument: () => getEditorDocument(editor),
|
|
450
|
-
|
|
455
|
+
getEditingState: () => editor?.state ?? null,
|
|
456
|
+
setDocument: (doc, focus) => setEditorDocument(editor, doc, focus),
|
|
451
457
|
insertAtCursor: (text) => insertTextAtCursor(editor, text),
|
|
452
458
|
clear: () => editor?.commands.setContent(EMPTY_DOC),
|
|
453
459
|
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
|
}
|
|
@@ -7,6 +7,8 @@ interface SessionSiteHeaderProps {
|
|
|
7
7
|
parent?: {
|
|
8
8
|
onOpen: () => void;
|
|
9
9
|
};
|
|
10
|
+
/** The session works now: its child list polls every 5 s instead of every 30 s. */
|
|
11
|
+
live?: boolean;
|
|
10
12
|
}
|
|
11
|
-
export declare function SessionSiteHeader({ sessionId, sessionTitle, isMobileView, leadingAction, parent, }: SessionSiteHeaderProps): import("react").JSX.Element;
|
|
13
|
+
export declare function SessionSiteHeader({ sessionId, sessionTitle, isMobileView, leadingAction, parent, live, }: SessionSiteHeaderProps): import("react").JSX.Element;
|
|
12
14
|
export {};
|
|
@@ -56,7 +56,7 @@ const DEV_TOOLS = [
|
|
|
56
56
|
{ view: 'desktop', label: 'Desktop', Icon: MonitorIcon },
|
|
57
57
|
{ view: 'files', label: 'Files', Icon: FolderSimpleIcon },
|
|
58
58
|
];
|
|
59
|
-
export function SessionSiteHeader({ sessionId, sessionTitle, isMobileView, leadingAction, parent, }) {
|
|
59
|
+
export function SessionSiteHeader({ sessionId, sessionTitle, isMobileView, leadingAction, parent, live = false, }) {
|
|
60
60
|
const tI18nHardcoded = useTranslations('hardcodedUi');
|
|
61
61
|
const tHardcodedUi = useTranslations('hardcodedUi');
|
|
62
62
|
const tPalette = useTranslations('commandPalette');
|
|
@@ -185,7 +185,8 @@ export function SessionSiteHeader({ sessionId, sessionTitle, isMobileView, leadi
|
|
|
185
185
|
const subsessions = projectSession && !parent ? directSubsessions(projectSession) : [];
|
|
186
186
|
const childSessions = useSessionChildren(projectId ?? '', projectSessionId ?? '', {
|
|
187
187
|
enabled: isProjectSession && !parent,
|
|
188
|
-
|
|
188
|
+
// An idle session starts no child: poll every 30 s, every 5 s while it works.
|
|
189
|
+
refetchInterval: live ? 5_000 : 30_000,
|
|
189
190
|
});
|
|
190
191
|
const startRename = () => {
|
|
191
192
|
if (canRename)
|
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';
|