@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
|
@@ -6,6 +6,8 @@ export const useUpgradeDialogStore = create((set) => ({
|
|
|
6
6
|
accountId: undefined,
|
|
7
7
|
hasSubscription: undefined,
|
|
8
8
|
billingState: undefined,
|
|
9
|
+
pickedMonthlyUsd: undefined,
|
|
10
|
+
setPickedMonthlyUsd: (monthlyUsd) => set({ pickedMonthlyUsd: monthlyUsd }),
|
|
9
11
|
openUpgradeDialog: (opts) => set({
|
|
10
12
|
isOpen: true,
|
|
11
13
|
reason: opts.reason ?? 'subscription_required',
|
package/dist/lib/routes.d.ts
CHANGED
|
@@ -52,19 +52,12 @@ export interface UiRoutes {
|
|
|
52
52
|
/** The project's Company memory (`chat` flag); a page is `?page=<page_id>`. */
|
|
53
53
|
memory: (projectId: string) => string | null;
|
|
54
54
|
/**
|
|
55
|
-
* Review:
|
|
56
|
-
*
|
|
57
|
-
*
|
|
55
|
+
* Review: the workspace's Review queue, beside the app sidebar. Since
|
|
56
|
+
* KRTX-4799 it lives at the workspace Inbox address; the person's
|
|
57
|
+
* notifications are not a view of it (they span every workspace). Absent:
|
|
58
|
+
* the host serves Review only inside its `customize` route.
|
|
58
59
|
*/
|
|
59
60
|
review?: (projectId: string) => string | null;
|
|
60
|
-
/**
|
|
61
|
-
* The Inbox: the signed-in person's notifications from every project, as a
|
|
62
|
-
* page beside the project sidebar (KRTX-1742). Absent or null: the host
|
|
63
|
-
* serves no Inbox page and the sidebar has no Inbox row. It is new
|
|
64
|
-
* (2026-11-06), so a host that maps any route (its own router) gets no
|
|
65
|
-
* Inbox row until it routes `inbox` too: no host gets a link it does not serve.
|
|
66
|
-
*/
|
|
67
|
-
inbox?: (projectId: string) => string | null;
|
|
68
61
|
}
|
|
69
62
|
export declare const defaultUiRoutes: UiRoutes;
|
|
70
63
|
/**
|
package/dist/lib/routes.js
CHANGED
|
@@ -15,9 +15,9 @@ const DEFAULT_ROUTES = {
|
|
|
15
15
|
channel: (p, slug) => `/workspaces/${p}/c/${slug}`,
|
|
16
16
|
dm: (p, agentName) => `/workspaces/${p}/dm/${encodeURIComponent(agentName)}`,
|
|
17
17
|
memory: (p) => `/workspaces/${p}/memory`,
|
|
18
|
-
//
|
|
18
|
+
// The workspace Inbox page IS the Review queue (KRTX-4799); the old
|
|
19
|
+
// `/workspaces/<id>/review` route redirects here.
|
|
19
20
|
review: (p) => `/workspaces/${p}/inbox?view=review`,
|
|
20
|
-
inbox: (p) => `/workspaces/${p}/inbox`,
|
|
21
21
|
};
|
|
22
22
|
export const defaultUiRoutes = DEFAULT_ROUTES;
|
|
23
23
|
let routes = DEFAULT_ROUTES;
|
|
@@ -31,9 +31,7 @@ export function setUiRoutes(overrides) {
|
|
|
31
31
|
const admin = overrides.admin ?? overrides.customize;
|
|
32
32
|
// A host that routes its own customize pages serves Review there unless it also routes `review`.
|
|
33
33
|
const review = overrides.review ?? (overrides.customize ? undefined : DEFAULT_ROUTES.review);
|
|
34
|
-
|
|
35
|
-
const inbox = overrides.inbox ?? (Object.keys(overrides).length === 0 ? DEFAULT_ROUTES.inbox : undefined);
|
|
36
|
-
routes = { ...DEFAULT_ROUTES, ...overrides, ...(admin ? { admin } : {}), review, inbox };
|
|
34
|
+
routes = { ...DEFAULT_ROUTES, ...overrides, ...(admin ? { admin } : {}), review };
|
|
37
35
|
}
|
|
38
36
|
export function uiRoutes() {
|
|
39
37
|
return routes;
|
|
@@ -59,6 +59,13 @@ export declare function remoteImageHost(src: string, proxiedSrc?: string): strin
|
|
|
59
59
|
* back to a plain `<a>` and never feed garbage to `next/link`.
|
|
60
60
|
*/
|
|
61
61
|
export declare function isLinkSafeHref(href: string | undefined): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The app path of an absolute URL on this page's own origin
|
|
64
|
+
* (`https://kortix.com/workspaces/…` on kortix.com → `/workspaces/…`), or
|
|
65
|
+
* `null` for any other href. Agents write full URLs; a click on one is an
|
|
66
|
+
* in-app navigation, not a page load.
|
|
67
|
+
*/
|
|
68
|
+
export declare function sameOriginAppPath(href: string | undefined): string | null;
|
|
62
69
|
/** Route only trusted app paths through Next.js Link and its prefetcher. */
|
|
63
70
|
export declare function shouldUseNextLink(href: string | undefined): boolean;
|
|
64
71
|
export { LANGUAGE_ALIASES, normalizeLanguage, languageLabel } from '../_vendor/shared/code-language.js';
|
|
@@ -122,6 +122,25 @@ export function isLinkSafeHref(href) {
|
|
|
122
122
|
// `new URL(..., window.location.href)` always succeeds for them.
|
|
123
123
|
return true;
|
|
124
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* The app path of an absolute URL on this page's own origin
|
|
127
|
+
* (`https://kortix.com/workspaces/…` on kortix.com → `/workspaces/…`), or
|
|
128
|
+
* `null` for any other href. Agents write full URLs; a click on one is an
|
|
129
|
+
* in-app navigation, not a page load.
|
|
130
|
+
*/
|
|
131
|
+
export function sameOriginAppPath(href) {
|
|
132
|
+
if (!href || typeof window === 'undefined' || !/^https?:\/\//i.test(href))
|
|
133
|
+
return null;
|
|
134
|
+
try {
|
|
135
|
+
const url = new URL(href);
|
|
136
|
+
if (url.origin !== window.location.origin)
|
|
137
|
+
return null;
|
|
138
|
+
return url.pathname + url.search + url.hash;
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
125
144
|
/** Route only trusted app paths through Next.js Link and its prefetcher. */
|
|
126
145
|
export function shouldUseNextLink(href) {
|
|
127
146
|
return isInternalUrl(href) && isLinkSafeHref(href);
|
|
@@ -14,7 +14,7 @@ import { InsideLinkContext } from './code/inside-link-context.js';
|
|
|
14
14
|
import { isKatexClassName, katexRehypePlugins, katexRehypePluginsNoRaw, katexRemarkPlugins, normalizeClassName, } from './katex-markdown.js';
|
|
15
15
|
import { markdownPolicy, } from './markdown-policy.js';
|
|
16
16
|
import { MarkdownOrderedList } from './ordered-list.js';
|
|
17
|
-
import { hasLinkReferenceDefinition, isInternalUrl, isStreamingLinkPlaceholder, prepareMarkdownSource, remoteImageHost, shouldUseNextLink, } from './unified-markdown-utils.js';
|
|
17
|
+
import { hasLinkReferenceDefinition, isInternalUrl, isStreamingLinkPlaceholder, prepareMarkdownSource, remoteImageHost, sameOriginAppPath, shouldUseNextLink, } from './unified-markdown-utils.js';
|
|
18
18
|
import { remarkSetupLinkBlocks } from './setup-link-blocks.js';
|
|
19
19
|
import { rehypeStreamWords, STREAM_WORD_CLASS, StreamFadeGateContext, StreamWord, createStreamFadeGate, } from './stream-words.js';
|
|
20
20
|
import { SetupLinkButton, SetupLinkInlineContext } from './setup-links/setup-link-button.js';
|
|
@@ -25,7 +25,7 @@ import { useSandboxProxy } from '../internal/hooks/use-sandbox-proxy.js';
|
|
|
25
25
|
import { useOpenPreviewLink } from '../internal/hooks/use-open-preview-link.js';
|
|
26
26
|
import { cn } from '../lib/utils.js';
|
|
27
27
|
import { ImageIcon } from '@phosphor-icons/react';
|
|
28
|
-
import { useUiLink } from '../providers/ui-provider.js';
|
|
28
|
+
import { useUiLink, useUiRouter } from '../providers/ui-provider.js';
|
|
29
29
|
import React, { useCallback, useContext, useMemo, useState } from 'react';
|
|
30
30
|
import { parseMarkdownIntoBlocks, Streamdown } from 'streamdown';
|
|
31
31
|
function SlackMark({ className }) {
|
|
@@ -119,6 +119,7 @@ function bareLinkText(children) {
|
|
|
119
119
|
export function MarkdownLink({ href, children, }) {
|
|
120
120
|
const tAppLink = useTranslations('markdownAppLinks');
|
|
121
121
|
const Link = useUiLink();
|
|
122
|
+
const router = useUiRouter();
|
|
122
123
|
const { proxy, policy, variant } = useContext(MarkdownRenderContext);
|
|
123
124
|
const openPreview = useOpenPreviewLink();
|
|
124
125
|
// Only agent content may turn a setup link into the in-app card. From any
|
|
@@ -201,8 +202,20 @@ export function MarkdownLink({ href, children, }) {
|
|
|
201
202
|
// treats those as app routes and prefetches them, including typos such
|
|
202
203
|
// as `/legal/terms.`. Only trusted root-relative/hash paths belong in
|
|
203
204
|
// the app router; every other href stays a plain anchor.
|
|
205
|
+
// An absolute URL on this app's own origin (an agent writes
|
|
206
|
+
// `https://kortix.com/workspaces/…`) navigates in place through the app
|
|
207
|
+
// router on a plain click. Decided at click time, so the server markup and
|
|
208
|
+
// the prefetcher never see it; a modified click keeps the native new tab.
|
|
204
209
|
if (!shouldUseNextLink(resolvedHref)) {
|
|
205
|
-
return (_jsx("a", { href: resolvedHref, className: anchorClass, title: presentation ? resolvedHref : undefined, ...(isExternal && !isHash ? { target: '_blank', rel: 'noopener noreferrer' } : {}),
|
|
210
|
+
return (_jsx("a", { href: resolvedHref, className: anchorClass, title: presentation ? resolvedHref : undefined, ...(isExternal && !isHash ? { target: '_blank', rel: 'noopener noreferrer' } : {}), onClick: (e) => {
|
|
211
|
+
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)
|
|
212
|
+
return;
|
|
213
|
+
const appPath = sameOriginAppPath(resolvedHref);
|
|
214
|
+
if (!appPath)
|
|
215
|
+
return;
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
router.push(appPath);
|
|
218
|
+
}, children: _jsx(InsideLinkContext.Provider, { value: true, children: linkContent }) }));
|
|
206
219
|
}
|
|
207
220
|
return (_jsx(Link, { href: resolvedHref, onClick: isHash ? (e) => handleHashClick(e, resolvedHref) : undefined, className: anchorClass, title: presentation ? resolvedHref : undefined, ...(isExternal && !isHash ? { target: '_blank', rel: 'noopener noreferrer' } : {}), children: _jsx(InsideLinkContext.Provider, { value: true, children: linkContent }) }));
|
|
208
221
|
}
|
|
@@ -28,7 +28,7 @@ function AlertDialogPortal({ container, forceMount, children, }) {
|
|
|
28
28
|
}
|
|
29
29
|
function AlertDialogOverlay({ className, style, ...props }) {
|
|
30
30
|
const depth = useDialogDepth();
|
|
31
|
-
return (_jsx(AlertDialogPrimitive.Backdrop, { "data-slot": "alert-dialog-overlay", className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 bg-black/65 backdrop-blur-xs', className), style: { zIndex: dialogOverlayZ(depth), ...style }, render: stateRender('div', openState), ...props }));
|
|
31
|
+
return (_jsx(AlertDialogPrimitive.Backdrop, { forceRender: true, "data-slot": "alert-dialog-overlay", className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 bg-black/65 backdrop-blur-xs', className), style: { zIndex: dialogOverlayZ(depth), ...style }, render: stateRender('div', openState), ...props }));
|
|
32
32
|
}
|
|
33
33
|
function AlertDialogContent({ className, style, overlayClassName, asChild, forceMount, children, onEscapeKeyDown, onOpenAutoFocus, onCloseAutoFocus, ...props }) {
|
|
34
34
|
const depth = useDialogDepth();
|
|
@@ -34,7 +34,9 @@ const DialogClose = React.forwardRef(({ asChild, children, ...props }, ref) => {
|
|
|
34
34
|
DialogClose.displayName = 'DialogClose';
|
|
35
35
|
const DialogOverlay = React.forwardRef(({ className, style, ...props }, ref) => {
|
|
36
36
|
const depth = useDialogDepth();
|
|
37
|
-
return (_jsx(DialogPrimitive.Backdrop, { ref: ref,
|
|
37
|
+
return (_jsx(DialogPrimitive.Backdrop, { ref: ref,
|
|
38
|
+
// Base UI skips a nested backdrop by default; Radix dimmed the parent dialog.
|
|
39
|
+
forceRender: true, className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-moderate fixed inset-0 bg-black/65 backdrop-blur-xs', className), style: { zIndex: dialogOverlayZ(depth), ...style }, render: stateRender('div', openState), ...props }));
|
|
38
40
|
});
|
|
39
41
|
DialogOverlay.displayName = 'DialogOverlay';
|
|
40
42
|
const DialogVariants = cva(cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 border p-5 shadow-lg duration-moderate sm:max-w-lg sm:rounded-lg'), {
|
|
@@ -30,7 +30,7 @@ function DrawerClose({ asChild, children, ...props }) {
|
|
|
30
30
|
return (_jsx(DrawerPrimitive.Close, { "data-slot": "drawer-close", ...props, ref: composeRefs(props.ref, native.ref), render: slot.render, nativeButton: native.nativeButton, children: slot.children }));
|
|
31
31
|
}
|
|
32
32
|
function DrawerOverlay({ className, ...props }) {
|
|
33
|
-
return (_jsx(DrawerPrimitive.Backdrop, { "data-slot": "drawer-overlay", className: cn('duration-moderate fixed inset-0 z-50 bg-black/50 opacity-[calc(1-var(--drawer-swipe-progress,0))] transition-opacity ease-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-swiping:duration-0', className), render: stateRender('div', openState), ...props }));
|
|
33
|
+
return (_jsx(DrawerPrimitive.Backdrop, { forceRender: true, "data-slot": "drawer-overlay", className: cn('duration-moderate fixed inset-0 z-50 bg-black/50 opacity-[calc(1-var(--drawer-swipe-progress,0))] transition-opacity ease-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-swiping:duration-0', className), render: stateRender('div', openState), ...props }));
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Slide-in per edge. The swipe offset Base UI writes while the drawer is
|
package/dist/primitives/modal.js
CHANGED
|
@@ -62,7 +62,7 @@ const overlayAnimationClasses = {
|
|
|
62
62
|
};
|
|
63
63
|
const ModalOverlay = React.forwardRef(({ className, style, animation = 'default', ...props }, ref) => {
|
|
64
64
|
const depth = useDialogDepth();
|
|
65
|
-
return (_jsx(DialogPrimitive.Backdrop, { render: stateRender('div', openState), className: cn('fixed inset-0 bg-black/65 backdrop-blur-xs', overlayAnimationClasses[animation], className), style: { zIndex: dialogOverlayZ(depth), ...style }, ...props, ref: ref }));
|
|
65
|
+
return (_jsx(DialogPrimitive.Backdrop, { forceRender: true, render: stateRender('div', openState), className: cn('fixed inset-0 bg-black/65 backdrop-blur-xs', overlayAnimationClasses[animation], className), style: { zIndex: dialogOverlayZ(depth), ...style }, ...props, ref: ref }));
|
|
66
66
|
});
|
|
67
67
|
ModalOverlay.displayName = 'ModalOverlay';
|
|
68
68
|
const ModalVariants = cva(cn('fixed gap-0 border p-0 shadow-lg overflow-y-auto', 'lg:top-[50%] lg:left-[50%] lg:grid lg:w-full lg:max-w-lg lg:-translate-x-1/2 lg:-translate-y-1/2 lg:rounded-xl', 'lg:flex lg:h-full lg:flex-col space-y-4'), {
|
|
@@ -14,7 +14,7 @@ function PreviewImage({ open, defaultOpen, onOpenChange, modal, children, }) {
|
|
|
14
14
|
const PreviewImageTrigger = DialogTrigger;
|
|
15
15
|
const PreviewImagePortal = DialogPortal;
|
|
16
16
|
const PreviewImageClose = DialogClose;
|
|
17
|
-
const PreviewImageOverlay = React.forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Backdrop, { ref: ref, className: cn('fixed inset-0 z-50 bg-black/40', className), ...props })));
|
|
17
|
+
const PreviewImageOverlay = React.forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Backdrop, { ref: ref, forceRender: true, className: cn('fixed inset-0 z-50 bg-black/40', className), ...props })));
|
|
18
18
|
PreviewImageOverlay.displayName = 'PreviewImageOverlay';
|
|
19
19
|
const MIN_ZOOM = 0.7;
|
|
20
20
|
const DEFAULT_ZOOM = 1;
|
package/dist/primitives/sheet.js
CHANGED
|
@@ -18,7 +18,7 @@ const SheetClose = DialogClose;
|
|
|
18
18
|
const SheetPortal = DialogPortal;
|
|
19
19
|
const SheetOverlay = React.forwardRef(({ className, style, ...props }, ref) => {
|
|
20
20
|
const depth = useDialogDepth();
|
|
21
|
-
return (_jsx(SheetPrimitive.Backdrop, { className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 bg-black/80', className), style: { zIndex: dialogOverlayZ(depth), ...style }, render: stateRender('div', openState), ...props, ref: ref }));
|
|
21
|
+
return (_jsx(SheetPrimitive.Backdrop, { forceRender: true, className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 bg-black/80', className), style: { zIndex: dialogOverlayZ(depth), ...style }, render: stateRender('div', openState), ...props, ref: ref }));
|
|
22
22
|
});
|
|
23
23
|
SheetOverlay.displayName = 'SheetOverlay';
|
|
24
24
|
const sheetVariants = cva('fixed flex min-h-0 flex-col gap-4 overflow-hidden bg-sidebar p-4 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out h-[calc(100vh-1.4rem)]', {
|
|
@@ -5,6 +5,7 @@ import { WarningIcon } from '@phosphor-icons/react';
|
|
|
5
5
|
import { lazy, Suspense, useContext, useMemo, useRef } from 'react';
|
|
6
6
|
import { SpaceMentionContext } from './menus/space-mentions.js';
|
|
7
7
|
import { useFeatureFlag } from '@kortix/sdk/react';
|
|
8
|
+
import { ModelConnectionLayoutContext } from '../models/model-connection-layout.js';
|
|
8
9
|
import { ImagesUnsupportedBar, ModelConnectionBar } from '../models/model-connection-gate.js';
|
|
9
10
|
import { AnimatedComposerPlaceholder } from './animated-placeholder.js';
|
|
10
11
|
import { AttachmentTiles } from './attachment-tiles.js';
|
|
@@ -25,6 +26,7 @@ export function ComposerCard({ tHardcodedUi, isDragOver, handleDragEnter, handle
|
|
|
25
26
|
// defaults mirror `ComposerImpl`'s, because the spread passes the raw
|
|
26
27
|
// values, not the component's defaulted locals.
|
|
27
28
|
agents = EMPTY_AGENTS, commands = EMPTY_COMMANDS, slashFiles = EMPTY_SLASH_FILES, models = EMPTY_MODELS, notice = null, disabled = false, lockForQuestion = false, lockForApproval = false, questionButtonLabel = null, questionActive = false, submitLabel = null, questionCanAct = true, escCount = 0, isBusy = false, isSending = false, onStop, stopDisabled = false, canStop = true, modelsLoading = false, modelRequired = false, onModelChange, modelDefaultControls, inheritedModel, providers, variants = EMPTY_VARIANTS, selectedVariant = null, onVariantChange, projectId, toolbarSlot, underbarSlot, rewind, selectedAgent = null, onAgentChange, noAccessibleAgents = false, agentLocked = false, onContextClick, messages, underbarPlacement = 'below', agentPickerCompact = false, slashMenuPlacement = 'above', cardClassName, call, }) {
|
|
29
|
+
const connectionsAbove = useContext(ModelConnectionLayoutContext) === 'above';
|
|
28
30
|
const cardRef = useRef(null);
|
|
29
31
|
const { attachAccept, modelPickerEnabled } = useUiHostConfig();
|
|
30
32
|
const inlineUnderbar = underbarPlacement === 'inline';
|
|
@@ -90,7 +92,7 @@ agents = EMPTY_AGENTS, commands = EMPTY_COMMANDS, slashFiles = EMPTY_SLASH_FILES
|
|
|
90
92
|
selectedVariant,
|
|
91
93
|
onVariantChange,
|
|
92
94
|
]);
|
|
93
|
-
return (_jsxs(ChatInputOverridesProvider, { enabled: chatInputEnabled, children: [_jsxs("div", { ref: cardRef, onDragEnter: handleDragEnter, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDropFiles, className: cn(
|
|
95
|
+
return (_jsxs(ChatInputOverridesProvider, { enabled: chatInputEnabled, children: [connectionsAbove ? _jsx(ModelConnectionBar, { show: noModelsConnected }) : null, _jsxs("div", { ref: cardRef, onDragEnter: handleDragEnter, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDropFiles, className: cn(
|
|
94
96
|
// One shadow, from the ladder. `shadow-card` is defined nowhere in
|
|
95
97
|
// `globals.css` and `shadow-xl` was dead — twMerge dropped it for the
|
|
96
98
|
// arbitrary `shadow-[…oklch…]` that followed, which was the only
|
|
@@ -124,5 +126,5 @@ agents = EMPTY_AGENTS, commands = EMPTY_COMMANDS, slashFiles = EMPTY_SLASH_FILES
|
|
|
124
126
|
toolbarSlot: inlineUnderbar ? toolbarSlot : undefined, rewind: rewind, isSending: isSending, isBusy: isBusy, onStop: onStop, stopDisabled: stopDisabled, canStop: canStop, escCount: escCount, lockForQuestion: lockForQuestion, questionButtonLabel: questionButtonLabel, submitLabel: submitLabel, questionCanAct: questionCanAct, hasText: !isEmpty, canSubmit: canSubmit, submitDisabled: submitDisabled ||
|
|
125
127
|
attachmentFailed ||
|
|
126
128
|
modelRejectingImages !== null ||
|
|
127
|
-
commandAttachmentPlan.kind === 'refuse', attachmentFailed: attachmentFailed, attachmentUnsupported: imagesUnsupportedReason, disabled: disabled, modelUnavailable: modelUnavailable, agentUnavailable: agentUnavailable, call: call, onSubmit: () => handleSubmit() })] })] })] }), _jsx(ImagesUnsupportedBar, { modelName: noModelsConnected ? null : modelRejectingImages }), inlineUnderbar ? null : (_jsx(ComposerUnderbar, { onAttachClick: handleAttachClick, agents: primaryAgents, selectedAgent: selectedAgent, onAgentChange: onAgentChange, agentMenuOpen: agentMenuOpen, onAgentMenuOpenChange: setAgentMenuOpen, noAccessibleAgents: noAccessibleAgents, agentLocked: agentLocked, messages: messages, models: models, selectedModel: availableSelectedModel, onContextClick: onContextClick, toolbarSlot: toolbarSlot, agentsSlot: underbarSlot, chatInput: chatInput })), _jsx(ModelConnectionBar, { show: noModelsConnected }), slashMenuPlacement === 'below' && (_jsx("div", { id: dockId, className: "absolute top-full right-4 left-4 z-99 mt-3.5" }))] }));
|
|
129
|
+
commandAttachmentPlan.kind === 'refuse', attachmentFailed: attachmentFailed, attachmentUnsupported: imagesUnsupportedReason, disabled: disabled, modelUnavailable: modelUnavailable, agentUnavailable: agentUnavailable, call: call, onSubmit: () => handleSubmit() })] })] })] }), _jsx(ImagesUnsupportedBar, { modelName: noModelsConnected ? null : modelRejectingImages }), inlineUnderbar ? null : (_jsx(ComposerUnderbar, { onAttachClick: handleAttachClick, agents: primaryAgents, selectedAgent: selectedAgent, onAgentChange: onAgentChange, agentMenuOpen: agentMenuOpen, onAgentMenuOpenChange: setAgentMenuOpen, noAccessibleAgents: noAccessibleAgents, agentLocked: agentLocked, messages: messages, models: models, selectedModel: availableSelectedModel, onContextClick: onContextClick, toolbarSlot: toolbarSlot, agentsSlot: underbarSlot, chatInput: chatInput })), connectionsAbove ? null : _jsx(ModelConnectionBar, { show: noModelsConnected }), slashMenuPlacement === 'below' && (_jsx("div", { id: dockId, className: "absolute top-full right-4 left-4 z-99 mt-3.5" }))] }));
|
|
128
130
|
}
|
|
@@ -25,32 +25,8 @@ export declare const TILE_SURFACE = "border-border bg-popover relative block siz
|
|
|
25
25
|
* the file, opens the lightbox). A tile with no handler carries no promise.
|
|
26
26
|
*/
|
|
27
27
|
export declare const TILE_INTERACTIVE = "hover:bg-accent cursor-pointer transition-colors duration-fast active:scale-[0.96]";
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
* that happens to draw — a logo file on a tile is a black blob at 100px, and
|
|
31
|
-
* its name is what tells it from the next logo file (Jay, 2026-09-06). It
|
|
32
|
-
* gets the named treatment, badge and all.
|
|
33
|
-
*/
|
|
34
|
-
export declare function isPreviewableImage(filename: string, mime?: string): boolean;
|
|
35
|
-
/** What the tile prints in the file's corner. Lowercase, from the name first
|
|
36
|
-
* and the MIME subtype second; empty when neither says anything. */
|
|
37
|
-
export declare function attachmentExtension(filename: string, mime?: string): string;
|
|
38
|
-
/**
|
|
39
|
-
* How a name is laid out on the tile.
|
|
40
|
-
*
|
|
41
|
-
* A short name wraps over two lines as the browser sees fit. A long one is
|
|
42
|
-
* split: the first line is the head, ellipsized by CSS at the tile's edge, and
|
|
43
|
-
* the second line is the last ten characters verbatim — the part that carries
|
|
44
|
-
* the extension and tells `…-chatux.md` from `…-ux.md`. A single middle
|
|
45
|
-
* ellipsis in one string wrapped wherever the browser chose, and left a
|
|
46
|
-
* dangling hyphen at the end of line one (2026-09-06).
|
|
47
|
-
*/
|
|
48
|
-
export declare const LONG_NAME_THRESHOLD = 24;
|
|
49
|
-
export declare const NAME_TAIL_CHARS = 10;
|
|
50
|
-
export declare function splitFilenameForTile(name: string): {
|
|
51
|
-
head: string;
|
|
52
|
-
tail: string;
|
|
53
|
-
} | null;
|
|
28
|
+
/** The five tile rules live once in `@kortix/shared/session/attachment-tile`. */
|
|
29
|
+
export { LONG_NAME_THRESHOLD, NAME_TAIL_CHARS, attachmentExtension, isPreviewableImage, splitFilenameForTile, } from '../../_vendor/shared/session/attachment-tile.js';
|
|
54
30
|
/** A tile previews the head of the paste only: the clamp shows four lines, and the DOM need not hold 100 kB. */
|
|
55
31
|
export declare const PASTE_PREVIEW_CHARS = 400;
|
|
56
32
|
export interface AttachmentTileProps {
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { Badge } from '../../primitives/badge.js';
|
|
4
4
|
import { Close } from '../../icons/close.js';
|
|
5
5
|
import { cn } from '../../lib/utils.js';
|
|
6
|
+
import { attachmentExtension, isPreviewableImage, splitFilenameForTile, } from '../../_vendor/kortix-shared.js';
|
|
6
7
|
/** The square every attachment is. `size-28` (~103px on the 0.23rem scale) —
|
|
7
8
|
* Jay's call, 2026-09-06: the 88px square read as cramped beside the name. */
|
|
8
9
|
export const TILE_SURFACE = 'border-border bg-popover relative block size-28 shrink-0 overflow-hidden rounded-md border text-left';
|
|
@@ -11,53 +12,8 @@ export const TILE_SURFACE = 'border-border bg-popover relative block size-28 shr
|
|
|
11
12
|
* the file, opens the lightbox). A tile with no handler carries no promise.
|
|
12
13
|
*/
|
|
13
14
|
export const TILE_INTERACTIVE = 'hover:bg-accent cursor-pointer transition-colors duration-fast active:scale-[0.96]';
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
* that happens to draw — a logo file on a tile is a black blob at 100px, and
|
|
17
|
-
* its name is what tells it from the next logo file (Jay, 2026-09-06). It
|
|
18
|
-
* gets the named treatment, badge and all.
|
|
19
|
-
*/
|
|
20
|
-
export function isPreviewableImage(filename, mime) {
|
|
21
|
-
const ext = attachmentExtension(filename, mime);
|
|
22
|
-
if (ext === 'svg')
|
|
23
|
-
return false;
|
|
24
|
-
return (mime ?? '').toLowerCase().startsWith('image/');
|
|
25
|
-
}
|
|
26
|
-
/** What the tile prints in the file's corner. Lowercase, from the name first
|
|
27
|
-
* and the MIME subtype second; empty when neither says anything. */
|
|
28
|
-
export function attachmentExtension(filename, mime) {
|
|
29
|
-
const dot = filename.lastIndexOf('.');
|
|
30
|
-
if (dot > 0 && dot < filename.length - 1) {
|
|
31
|
-
const ext = filename
|
|
32
|
-
.slice(dot + 1)
|
|
33
|
-
.trim()
|
|
34
|
-
.toLowerCase();
|
|
35
|
-
if (ext.length > 0 && ext.length <= 8 && !/\s/.test(ext))
|
|
36
|
-
return ext;
|
|
37
|
-
}
|
|
38
|
-
const subtype = (mime ?? '').split('/')[1]?.split(';')[0]?.trim().toLowerCase() ?? '';
|
|
39
|
-
if (!subtype)
|
|
40
|
-
return '';
|
|
41
|
-
// `svg+xml` → `svg`, `x-icon` → `icon`, `vnd.ms-excel` → `excel`.
|
|
42
|
-
return subtype.split('+')[0].replace(/^x-/, '').split('.').pop() ?? '';
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* How a name is laid out on the tile.
|
|
46
|
-
*
|
|
47
|
-
* A short name wraps over two lines as the browser sees fit. A long one is
|
|
48
|
-
* split: the first line is the head, ellipsized by CSS at the tile's edge, and
|
|
49
|
-
* the second line is the last ten characters verbatim — the part that carries
|
|
50
|
-
* the extension and tells `…-chatux.md` from `…-ux.md`. A single middle
|
|
51
|
-
* ellipsis in one string wrapped wherever the browser chose, and left a
|
|
52
|
-
* dangling hyphen at the end of line one (2026-09-06).
|
|
53
|
-
*/
|
|
54
|
-
export const LONG_NAME_THRESHOLD = 24;
|
|
55
|
-
export const NAME_TAIL_CHARS = 10;
|
|
56
|
-
export function splitFilenameForTile(name) {
|
|
57
|
-
if (name.length <= LONG_NAME_THRESHOLD)
|
|
58
|
-
return null;
|
|
59
|
-
return { head: name.slice(0, -NAME_TAIL_CHARS), tail: name.slice(-NAME_TAIL_CHARS) };
|
|
60
|
-
}
|
|
15
|
+
/** The five tile rules live once in `@kortix/shared/session/attachment-tile`. */
|
|
16
|
+
export { LONG_NAME_THRESHOLD, NAME_TAIL_CHARS, attachmentExtension, isPreviewableImage, splitFilenameForTile, } from '../../_vendor/kortix-shared.js';
|
|
61
17
|
/** A tile previews the head of the paste only: the clamp shows four lines, and the DOM need not hold 100 kB. */
|
|
62
18
|
export const PASTE_PREVIEW_CHARS = 400;
|
|
63
19
|
/**
|
|
@@ -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;
|
|
@@ -103,6 +103,7 @@ export declare function ComposerChatInput({ onSend, onCommand, sessionId, projec
|
|
|
103
103
|
sandboxSlot?: SessionOverrideSlot;
|
|
104
104
|
/** Persist the unsent draft under this scope — see `composer/draft/`. */
|
|
105
105
|
draftScope?: DraftScope | null;
|
|
106
|
+
draftHandoffScope?: import('react').RefObject<DraftScope | null>;
|
|
106
107
|
draftActive?: boolean;
|
|
107
108
|
/** Host-owned upload controller. See `SessionChatInputProps.promptAttachments`. */
|
|
108
109
|
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
|
}
|
|
@@ -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
|
/**
|
|
@@ -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,6 +303,7 @@ 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,
|
|
@@ -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;
|