@kortix/ui 0.16.0 → 0.16.2
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 +157 -51
- package/dist/_vendor/shared/index.d.ts +1 -0
- package/dist/_vendor/shared/space-icon.d.ts +30 -0
- package/dist/_vendor/shared/space-slug.d.ts +12 -0
- package/dist/access/access/access-dialog.js +2 -2
- package/dist/access/share-dialog.d.ts +77 -0
- package/dist/access/share-dialog.js +160 -0
- package/dist/access/sharing-picker.d.ts +8 -1
- package/dist/access/sharing-picker.js +2 -2
- package/dist/changes/change-list.js +3 -3
- package/dist/customize/connectors/catalog/catalog-paging.d.ts +1 -1
- package/dist/customize/connectors/catalog/catalog-paging.js +1 -1
- package/dist/customize/providers/provider-sheet.js +17 -7
- package/dist/customize/sections/component/manifest-copy-block.js +1 -1
- package/dist/customize/sections/component/section-wrapper.d.ts +1 -8
- package/dist/customize/sections/component/section-wrapper.js +3 -3
- package/dist/customize/sections/llm-provider/model-capability-icons.js +1 -1
- package/dist/customize/sections/view/gateway/generation-controls.js +1 -1
- package/dist/customize/sections/view/git-view.js +1 -1
- package/dist/customize/settings/settings-tabs.js +0 -5
- package/dist/customize/settings/tabs/general-tab.js +2 -2
- package/dist/customize/shared/capability-page-shell.d.ts +2 -2
- package/dist/customize/shared/capability-page-shell.js +7 -5
- package/dist/customize/shared/capability-scroll-root.js +1 -2
- package/dist/customize/shared/catalog/catalog-card.js +1 -1
- package/dist/files/project/components/change-requests-panel.js +2 -2
- package/dist/files/project/components/checkpoint-detail-dialog.js +4 -4
- package/dist/files/project/components/checkpoints-panel.js +2 -2
- package/dist/files/project/components/drive-explorer.js +2 -2
- package/dist/files/project/components/file-breadcrumbs.js +1 -1
- package/dist/files/project/components/file-history-popover.js +2 -2
- package/dist/files/project/components/file-thumbnail.js +1 -1
- package/dist/files/project/components/open-change-request-dialog.js +1 -1
- package/dist/files/renderers/mermaid/mermaid-diagram.js +2 -2
- package/dist/files/renderers/show-content-renderer.js +6 -6
- package/dist/files/renderers/sqlite-renderer.js +8 -8
- package/dist/files/renderers/zip/zip-renderer.js +2 -2
- package/dist/files/viewer/file-content-renderer.js +5 -5
- package/dist/files/viewer/json-tree-view.js +3 -3
- package/dist/i18n/en.d.ts +133 -8
- package/dist/i18n/en.js +170 -45
- package/dist/i18n/ui-catalog/remaining-ui-translation-keys.generated.js +0 -3
- package/dist/internal/billing/use-cost-explorer.d.ts +9 -2
- package/dist/internal/billing/use-cost-explorer.js +22 -0
- package/dist/internal/billing/use-session-costs.d.ts +7 -2
- package/dist/internal/billing/use-session-costs.js +6 -0
- package/dist/internal/chrome/use-chrome-offered.d.ts +3 -3
- package/dist/internal/chrome/use-chrome-offered.js +3 -3
- package/dist/internal/components/nav-rail.d.ts +1 -20
- package/dist/internal/components/nav-rail.js +1 -15
- package/dist/internal/layout/project-page-header.d.ts +13 -9
- package/dist/internal/layout/project-page-header.js +14 -10
- package/dist/internal/lib/browser-noise/evidence.d.ts +2 -0
- package/dist/internal/lib/browser-noise/rules/injected-scripts.js +16 -1
- package/dist/internal/lib/error-handler.js +0 -9
- package/dist/internal/lib/interface-theme-defaults.js +2 -2
- package/dist/internal/lib/project-actions.d.ts +4 -5
- package/dist/internal/lib/project-actions.js +3 -5
- package/dist/internal/lib/project-preamble.d.ts +42 -4
- package/dist/internal/lib/project-preamble.js +49 -5
- package/dist/internal/lib/web-notifications.js +17 -29
- package/dist/internal/outcomes/outcome-vocabulary.js +1 -1
- package/dist/internal/stores/session-filter-store.d.ts +1 -1
- package/dist/internal/stores/user-preferences-store.d.ts +2 -2
- package/dist/internal/stores/workspace-settings-rail-store.d.ts +0 -8
- package/dist/internal/stores/workspace-settings-rail-store.js +0 -2
- package/dist/lib/routes.d.ts +7 -0
- package/dist/lib/routes.js +6 -1
- package/dist/markdown/doc-editor/doc-extensions.js +2 -0
- package/dist/markdown/doc-editor/doc-paste.d.ts +13 -0
- package/dist/markdown/doc-editor/doc-paste.js +67 -0
- package/dist/markdown/markdown-frontmatter.js +3 -3
- package/dist/markdown/markdown-policy.d.ts +1 -1
- package/dist/markdown/ordered-list.js +1 -1
- package/dist/primitives/context-menu.d.ts +1 -0
- package/dist/primitives/definition-list.js +1 -1
- package/dist/primitives/dropdown-menu.d.ts +1 -0
- package/dist/primitives/emoji-picker.js +1 -1
- package/dist/primitives/expandable-search.d.ts +57 -0
- package/dist/primitives/expandable-search.js +58 -0
- package/dist/primitives/favicon-avatar.js +1 -1
- package/dist/primitives/file-tree.d.ts +1 -1
- package/dist/primitives/file-tree.js +1 -1
- package/dist/primitives/glyph-picker.js +2 -2
- package/dist/primitives/input-group.js +1 -1
- package/dist/primitives/menu-base.d.ts +10 -0
- package/dist/primitives/menu-base.js +7 -2
- package/dist/primitives/phone-input.js +1 -1
- package/dist/primitives/profile-hover-card.d.ts +28 -0
- package/dist/primitives/profile-hover-card.js +22 -0
- package/dist/primitives/settings-section-header.d.ts +5 -5
- package/dist/primitives/settings-section-header.js +5 -5
- package/dist/primitives/sort-menu.d.ts +23 -0
- package/dist/primitives/sort-menu.js +54 -0
- package/dist/primitives/tabs.js +1 -1
- package/dist/primitives/toast-clearance.d.ts +12 -28
- package/dist/primitives/toast-clearance.js +23 -45
- package/dist/primitives/user-avatar.js +2 -3
- package/dist/session/agents/subagent-dialog-content.js +28 -70
- package/dist/session/composer/ComposerCard.d.ts +4 -1
- package/dist/session/composer/ComposerCard.js +51 -7
- package/dist/session/composer/composer-chat-input.js +3 -1
- package/dist/session/composer/composer-toolbar.d.ts +3 -1
- package/dist/session/composer/composer-toolbar.js +6 -2
- package/dist/session/composer/composer-underbar.d.ts +3 -1
- package/dist/session/composer/composer-underbar.js +2 -2
- package/dist/session/composer/composer.d.ts +12 -0
- package/dist/session/composer/composer.js +112 -6
- package/dist/session/composer/draft/composer-draft.d.ts +1 -0
- package/dist/session/composer/draft/composer-draft.js +10 -2
- package/dist/session/composer/draft/draft-uploads.js +13 -2
- package/dist/session/composer/draft/use-composer-draft.d.ts +2 -0
- package/dist/session/composer/draft/use-composer-draft.js +41 -6
- package/dist/session/composer/drive-mentions.d.ts +34 -0
- package/dist/session/composer/drive-mentions.js +98 -0
- package/dist/session/composer/editor/composer-editor.d.ts +3 -0
- package/dist/session/composer/editor/composer-editor.js +3 -1
- package/dist/session/composer/editor/serialize.js +3 -4
- package/dist/session/composer/menus/mention-controller.d.ts +3 -0
- package/dist/session/composer/menus/mention-controller.js +5 -0
- package/dist/session/composer/menus/mention-menu.d.ts +20 -3
- package/dist/session/composer/menus/mention-menu.js +33 -6
- package/dist/session/composer/menus/menu-items.d.ts +16 -1
- package/dist/session/composer/menus/menu-items.js +21 -1
- package/dist/session/composer/submit-latch.d.ts +3 -1
- package/dist/session/composer/submit-latch.js +5 -1
- package/dist/session/composer/types.d.ts +9 -2
- package/dist/session/header/session-changes-indicator.js +1 -1
- package/dist/session/header/session-site-header.js +2 -2
- package/dist/session/media/sandbox-url-detector.js +3 -3
- package/dist/session/models/model-connection-gate.d.ts +5 -0
- package/dist/session/models/model-connection-gate.js +12 -3
- package/dist/session/models/model-connection-layout.d.ts +7 -0
- package/dist/session/models/model-connection-layout.js +7 -0
- package/dist/session/models/provider-failure-recovery.js +1 -1
- package/dist/session/models/subscription-offer.d.ts +6 -5
- package/dist/session/models/subscription-offer.js +6 -6
- package/dist/session/panel/advanced/advanced-panel.js +1 -1
- package/dist/session/panel/session-detail-panel.js +1 -1
- package/dist/session/panel/session-diff-viewer.js +1 -1
- package/dist/session/panel/session-files-explorer.js +1 -1
- package/dist/session/panel/session-files-panel.js +3 -3
- package/dist/session/panel/shared/action-navigator.js +1 -1
- package/dist/session/status/provisioning-failure.d.ts +4 -4
- package/dist/session/status/provisioning-failure.js +4 -4
- package/dist/session/status/session-busy-indicator.js +1 -1
- package/dist/session/status/session-error-banner.js +6 -1
- package/dist/session/thread/mention-chip.d.ts +1 -1
- package/dist/session/thread/mention-segments.d.ts +4 -2
- package/dist/session/thread/mention-segments.js +28 -1
- package/dist/session/thread/message-parsing.d.ts +11 -0
- package/dist/session/thread/message-parsing.js +22 -3
- package/dist/session/thread/optimistic-turn.d.ts +4 -2
- package/dist/session/thread/optimistic-turn.js +13 -11
- package/dist/session/thread/session-chat.js +6 -1
- package/dist/session/thread/session-context-message-explorer.js +1 -1
- package/dist/session/thread/session-older-autoload.d.ts +2 -3
- package/dist/session/thread/session-older-autoload.js +2 -3
- package/dist/session/thread/transcript.js +8 -10
- package/dist/session/tool/shared/error-and-connector.js +1 -1
- package/dist/session/tool/shared/file-list.js +2 -2
- package/dist/session/tool/shared/infrastructure-parts.js +1 -1
- package/dist/session/tool/shared/infrastructure-preview.js +1 -1
- package/dist/session/tool/shared/infrastructure-row-header.js +3 -3
- package/dist/session/tool/shared/infrastructure-rows.js +2 -2
- package/dist/session/tool/shared/output-block.js +4 -4
- package/dist/session/tool/shared/session-helpers.js +3 -3
- package/dist/session/tool/shared/structured-output.js +3 -3
- package/dist/session/tool/shared/todo-helpers.js +1 -1
- package/dist/session/tool/tool-error.js +2 -2
- package/dist/session/tool/tools/agent-spawn-tool.js +3 -3
- package/dist/session/tool/tools/agent-status-tool.js +1 -1
- package/dist/session/tool/tools/apply-patch-tool.js +1 -1
- package/dist/session/tool/tools/connector-get-tool.js +1 -1
- package/dist/session/tool/tools/connector-list-tool.js +1 -1
- package/dist/session/tool/tools/connector-tools.js +1 -1
- package/dist/session/tool/tools/edit-tool.js +1 -1
- package/dist/session/tool/tools/get-mem-tool.js +1 -1
- package/dist/session/tool/tools/glob-tool.js +1 -1
- package/dist/session/tool/tools/image-search-tool.js +1 -1
- package/dist/session/tool/tools/memory-search-tool.js +1 -1
- package/dist/session/tool/tools/memory-tool.js +4 -4
- package/dist/session/tool/tools/presentation-gen-tool.js +2 -2
- package/dist/session/tool/tools/project-delete-tool.js +1 -1
- package/dist/session/tool/tools/project-list-tool.js +1 -1
- package/dist/session/tool/tools/pty-read-tool.js +1 -1
- package/dist/session/tool/tools/pty-spawn-tool.js +1 -1
- package/dist/session/tool/tools/pty-write-tool.js +1 -1
- package/dist/session/tool/tools/read-tool.js +1 -1
- package/dist/session/tool/tools/removed-connector-tool.js +1 -1
- package/dist/session/tool/tools/scrape-webpage-tool.js +1 -1
- package/dist/session/tool/tools/session-get-tool.js +3 -3
- package/dist/session/tool/tools/session-list-background-tool.js +1 -1
- package/dist/session/tool/tools/session-read-tool.js +1 -1
- package/dist/session/tool/tools/session-search-tool.js +1 -1
- package/dist/session/tool/tools/session-spawn-tool.js +1 -1
- package/dist/session/tool/tools/skill-tool.js +1 -1
- package/dist/session/tool/tools/todo-write-tool.js +1 -1
- package/dist/session/tool/tools/web-fetch-tool.js +1 -1
- package/dist/session/tool/tools/write-tool.js +1 -1
- package/dist/session/turn/activity-file-chips.js +7 -3
- package/dist/session/turn/activity-step.js +1 -1
- package/dist/session/turn/burst-summary-trigger.js +3 -3
- package/dist/session/turn/chain-step-trigger.js +1 -1
- package/dist/session/turn/plan-card.js +1 -1
- package/dist/session/turn/thought-chain-step.js +1 -1
- package/dist/session/turn/turn-work-accordion.js +1 -1
- package/dist/session/turn/user-message.js +13 -6
- package/dist/session/voice/use-call-card-position.d.ts +30 -0
- package/dist/session/voice/use-call-card-position.js +126 -0
- package/dist/session/voice/voice-call-card.js +10 -3
- package/dist/styles/theme.css +12 -0
- package/dist/styles/tokens.css +12 -6
- package/dist/styles.css +1 -1
- package/dist/terminal/session-terminal-panel.js +1 -1
- package/dist/test-utils/intl.d.ts +133 -8
- package/dist/workspace/admin/project-admin-dashboard.js +7 -24
- package/dist/workspace/calendar/calendar-page.js +1 -1
- package/dist/workspace/home/first-chat.d.ts +4 -3
- package/dist/workspace/home/first-chat.js +6 -6
- package/dist/workspace/home/welcome-body.js +2 -2
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/layout/project-home.js +11 -4
- package/dist/workspace/layout/use-project-home-send.d.ts +3 -1
- package/dist/workspace/layout/use-project-home-send.js +6 -2
- package/dist/workspace/memory/company-memory-page.js +2 -4
- package/dist/workspace/new/github-source.js +0 -1
- package/dist/workspace/new/new-workspace-form.d.ts +0 -1
- package/dist/workspace/new/new-workspace-form.js +0 -3
- package/dist/workspace/new/use-create-workspace.d.ts +1 -1
- package/dist/workspace/new/use-create-workspace.js +1 -2
- package/dist/workspace/session-spaces/space-detail-page.d.ts +35 -0
- package/dist/workspace/session-spaces/space-detail-page.js +307 -0
- package/dist/workspace/session-spaces/space-form-modal.d.ts +16 -0
- package/dist/workspace/session-spaces/space-form-modal.js +92 -0
- package/dist/workspace/session-spaces/space-icon.d.ts +36 -0
- package/dist/workspace/session-spaces/space-icon.js +52 -0
- package/dist/workspace/session-spaces/space-people.d.ts +51 -0
- package/dist/workspace/session-spaces/space-people.js +91 -0
- package/dist/workspace/session-spaces/space-picker.d.ts +11 -0
- package/dist/workspace/session-spaces/space-picker.js +42 -0
- package/dist/workspace/session-spaces/space-share-modal.d.ts +14 -0
- package/dist/workspace/session-spaces/space-share-modal.js +93 -0
- package/dist/workspace/session-spaces/spaces-page.d.ts +8 -0
- package/dist/workspace/session-spaces/spaces-page.js +125 -0
- package/dist/workspace/sessions/session-owner-filters.d.ts +2 -0
- package/dist/workspace/sessions/session-owner-filters.js +2 -0
- package/dist/workspace/setup/setup-banner.d.ts +4 -0
- package/dist/workspace/setup/setup-banner.js +57 -0
- package/dist/workspace/setup/setup-steps.d.ts +14 -0
- package/dist/workspace/setup/setup-steps.js +15 -0
- package/dist/workspace/setup/use-setup-steps.d.ts +18 -0
- package/dist/workspace/setup/use-setup-steps.js +57 -0
- package/dist/workspace/setup/workspace-setup-page.js +8 -41
- package/dist/workspace/sidebar/footer/project-artifacts-nav.js +1 -1
- package/dist/workspace/sidebar/footer/project-promo-cards.d.ts +7 -2
- package/dist/workspace/sidebar/footer/project-promo-cards.js +4 -3
- package/dist/workspace/sidebar/footer/project-sandbox-alert.js +1 -1
- package/dist/workspace/sidebar/footer/promo-card.d.ts +10 -1
- package/dist/workspace/sidebar/footer/promo-card.js +31 -2
- package/dist/workspace/sidebar/footer/sandbox-health.js +1 -1
- package/dist/workspace/sidebar/modal/session-people-picker.d.ts +13 -0
- package/dist/workspace/sidebar/modal/session-people-picker.js +72 -0
- package/dist/workspace/sidebar/modal/share-session-modal.js +2 -1
- package/dist/workspace/sidebar/project-nav-items.d.ts +1 -3
- package/dist/workspace/sidebar/project-nav-items.js +3 -8
- package/dist/workspace/sidebar/project-session-list.js +19 -12
- package/dist/workspace/sidebar/project-sidebar.js +13 -13
- package/dist/workspace/sidebar/project-spaces-nav.js +1 -2
- package/dist/workspace/sidebar/session-filter-menu.js +19 -13
- package/dist/workspace/sidebar/session-group-sections.d.ts +12 -12
- package/dist/workspace/sidebar/session-group-sections.js +56 -75
- package/dist/workspace/sidebar/sidebar-more-group.js +1 -1
- package/dist/workspace/sidebar/workspace-settings-sidebar-nav.js +2 -2
- package/dist/workspace/spaces/space-tabs.d.ts +26 -6
- package/dist/workspace/spaces/space-tabs.js +19 -8
- package/package.json +27 -31
- package/skills/kortix-ui/references/modules.md +2 -2
- package/dist/workspace/new/clone-param.d.ts +0 -11
- package/dist/workspace/new/clone-param.js +0 -15
- package/dist/workspace/new/provision-new-workspace.d.ts +0 -14
- package/dist/workspace/new/provision-new-workspace.js +0 -14
- package/dist/workspace/sidebar/footer/project-inbox-nav.d.ts +0 -8
- package/dist/workspace/sidebar/footer/project-inbox-nav.js +0 -29
|
@@ -40,6 +40,8 @@ import type { ComposerCall } from '../voice/composer-call.js';
|
|
|
40
40
|
* model choice, moved behind a click.
|
|
41
41
|
*/
|
|
42
42
|
export interface ComposerToolbarProps {
|
|
43
|
+
/** One-row `inline` composer: the two halves become the row's outer columns. */
|
|
44
|
+
collapsed?: boolean;
|
|
43
45
|
models: FlatModel[];
|
|
44
46
|
/** Threaded through to ModelSelector so it can show its loading state —
|
|
45
47
|
* added on main while this toolbar was being extracted. */
|
|
@@ -123,4 +125,4 @@ export interface ComposerToolbarProps {
|
|
|
123
125
|
call?: ComposerCall;
|
|
124
126
|
onSubmit: () => void;
|
|
125
127
|
}
|
|
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;
|
|
128
|
+
export declare function ComposerToolbar({ collapsed, 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;
|
|
@@ -3,13 +3,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useTranslations } from '../../i18n/index.js';
|
|
4
4
|
import { useUiHostConfig } from '../../providers/ui-provider.js';
|
|
5
5
|
import { ArrowCounterClockwiseIcon } from '@phosphor-icons/react';
|
|
6
|
+
import { cn } from '../../lib/utils.js';
|
|
6
7
|
import { Button } from '../../primitives/button.js';
|
|
7
8
|
import { HoverCard, HoverCardContent, HoverCardTrigger } from '../../primitives/hover-card.js';
|
|
8
9
|
import Loading from '../../primitives/loading.js';
|
|
9
10
|
import { ModelSelector } from '../models/model-selector.js';
|
|
10
11
|
import { ReasoningEffortSelector } from './reasoning-effort-selector.js';
|
|
11
12
|
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, 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
|
+
export function ComposerToolbar({ collapsed = false, 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
14
|
const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
|
|
14
15
|
const { modelPickerEnabled } = useUiHostConfig();
|
|
15
16
|
const showModel = !noModel && !pickersInChatInput && modelPickerEnabled && (models.length > 0 || modelRequired) && !!onModelChange;
|
|
@@ -22,7 +23,10 @@ export function ComposerToolbar({ models, modelsLoading, selectedModel, onModelC
|
|
|
22
23
|
if (!next)
|
|
23
24
|
onReasoningMenuOpenChange?.(false);
|
|
24
25
|
};
|
|
25
|
-
return (
|
|
26
|
+
return (
|
|
27
|
+
// Collapsed (`inline` composer, one row): the toolbar dissolves (`contents`) and its two halves
|
|
28
|
+
// become the row's first and last columns, either side of the editor.
|
|
29
|
+
_jsxs("div", { className: cn('kortix-composer-toolbar overflow-visible', collapsed ? 'contents' : 'flex items-center justify-between gap-1'), children: [_jsxs("div", { className: cn('flex min-w-0 items-center gap-1 overflow-visible', collapsed && 'col-start-1 row-start-1'), 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: cn('flex shrink-0 items-center gap-1.5', collapsed && 'col-start-3 row-start-1'), 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
30
|
? tI18nComplete.raw('text98433e61649a')
|
|
27
31
|
: 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
32
|
}
|
|
@@ -18,6 +18,8 @@ import { type ChatInputControlProps } from './chat-input/chat-input-control.js';
|
|
|
18
18
|
*/
|
|
19
19
|
export interface ComposerUnderbarProps {
|
|
20
20
|
onAttachClick: () => void;
|
|
21
|
+
/** No agent control: see `SessionChatInputProps.hideAgentPicker`. */
|
|
22
|
+
hideAgentPicker?: boolean;
|
|
21
23
|
/** Already filtered to non-hidden, non-subagent agents (`primaryAgents` in
|
|
22
24
|
* composer.tsx) — this component does no further filtering. */
|
|
23
25
|
agents: Agent[];
|
|
@@ -64,4 +66,4 @@ export interface ComposerUnderbarProps {
|
|
|
64
66
|
*/
|
|
65
67
|
chatInput?: Omit<ChatInputControlProps, 'agents' | 'selectedAgent' | 'onAgentChange' | 'unavailableHint' | 'agentLocked'>;
|
|
66
68
|
}
|
|
67
|
-
export declare function ComposerUnderbar({ onAttachClick, agents, selectedAgent, agentMenuOpen, onAgentMenuOpenChange, onAgentChange, noAccessibleAgents, agentLocked, messages, models, selectedModel, onContextClick, variant, agentPickerCompact, toolbarSlot, agentsSlot, chatInput, }: ComposerUnderbarProps): import("react").JSX.Element;
|
|
69
|
+
export declare function ComposerUnderbar({ onAttachClick, hideAgentPicker, agents, selectedAgent, agentMenuOpen, onAgentMenuOpenChange, onAgentChange, noAccessibleAgents, agentLocked, messages, models, selectedModel, onContextClick, variant, agentPickerCompact, toolbarSlot, agentsSlot, chatInput, }: ComposerUnderbarProps): import("react").JSX.Element;
|
|
@@ -15,7 +15,7 @@ import { TokenProgress } from './token-progress.js';
|
|
|
15
15
|
const NO_AGENT_SELECT = () => { };
|
|
16
16
|
/** Stable identity so the empty roster doesn't remount the picker per render. */
|
|
17
17
|
const EMPTY_AGENTS = [];
|
|
18
|
-
export function ComposerUnderbar({ onAttachClick, agents, selectedAgent, agentMenuOpen, onAgentMenuOpenChange, onAgentChange, noAccessibleAgents = false, agentLocked = false, messages, models, selectedModel, onContextClick, variant = 'row', agentPickerCompact = false, toolbarSlot, agentsSlot, chatInput, }) {
|
|
18
|
+
export function ComposerUnderbar({ onAttachClick, hideAgentPicker = false, agents, selectedAgent, agentMenuOpen, onAgentMenuOpenChange, onAgentChange, noAccessibleAgents = false, agentLocked = false, messages, models, selectedModel, onContextClick, variant = 'row', agentPickerCompact = false, toolbarSlot, agentsSlot, chatInput, }) {
|
|
19
19
|
const t = useTranslations('threads');
|
|
20
20
|
const { contextMeterEnabled } = useUiHostConfig();
|
|
21
21
|
/*
|
|
@@ -56,7 +56,7 @@ export function ComposerUnderbar({ onAttachClick, agents, selectedAgent, agentMe
|
|
|
56
56
|
: 'kortix-composer-underbar flex items-center justify-between gap-2 px-px pt-1.5 pb-2', children: [_jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [_jsx(Hint, { side: "top", label: t('attachFiles'), children: _jsx(Button, { type: "button", variant: "ghost", size: "icon-base", onClick: onAttachClick, "aria-label": t('attachFiles'),
|
|
57
57
|
// `hit-area-3` — the ≈29px ghost chip clears the 44px mobile tap
|
|
58
58
|
// floor only with the shared pseudo-element extension.
|
|
59
|
-
className: "text-muted-foreground hit-area-3 rounded-lg", children: _jsx(Paperclip, { className: "size-4 shrink-0" }) }) }), chatInput ? (_jsx(ChatInputControl, { ...chatInput, agents: noAccessibleAgents ? EMPTY_AGENTS : agents, selectedAgent: selectedAgent, onAgentChange: agentLocked ? undefined : onAgentChange, agentLocked: agentLocked, unavailableHint: noAccessibleAgents ? NO_AGENT_ACCESS_MESSAGE : undefined })) : (_jsx(AgentSelector, { compact: agentPickerCompact,
|
|
59
|
+
className: "text-muted-foreground hit-area-3 rounded-lg", children: _jsx(Paperclip, { className: "size-4 shrink-0" }) }) }), hideAgentPicker ? null : chatInput ? (_jsx(ChatInputControl, { ...chatInput, agents: noAccessibleAgents ? EMPTY_AGENTS : agents, selectedAgent: selectedAgent, onAgentChange: agentLocked ? undefined : onAgentChange, agentLocked: agentLocked, unavailableHint: noAccessibleAgents ? NO_AGENT_ACCESS_MESSAGE : undefined })) : (_jsx(AgentSelector, { compact: agentPickerCompact,
|
|
60
60
|
// A fixed agent (a DM): the picker lists only it.
|
|
61
61
|
agents: noAccessibleAgents ? EMPTY_AGENTS : agentLocked ? fixedAgentRoster(agents, selectedAgent) : agents, selectedAgent: selectedAgent, open: agentMenuOpen, onOpenChange: onAgentMenuOpenChange, onSelect: onAgentChange ?? NO_AGENT_SELECT, triggerLabelClassName: "max-w-[7rem]", unavailableHint: noAccessibleAgents ? NO_AGENT_ACCESS_MESSAGE : undefined })), agentsSlot] }), _jsxs("div", { className: "flex items-center gap-1", children: [(inline && !messages) || !contextMeterEnabled ? null : (_jsx(TokenProgress, { messages: messages, models: models, selectedModel: selectedModel, onContextClick: onContextClick })), toolbarSlot] })] }));
|
|
62
62
|
}
|
|
@@ -275,6 +275,18 @@ export interface SessionChatInputProps {
|
|
|
275
275
|
* reads as a detached strip, so there the controls belong on the one bar.
|
|
276
276
|
*/
|
|
277
277
|
underbarPlacement?: 'below' | 'inline';
|
|
278
|
+
/**
|
|
279
|
+
* One row (attach, text, send) while the text fits one line, the full card
|
|
280
|
+
* once it wraps or anything is attached; back to one row when emptied. Off
|
|
281
|
+
* by default: only a narrow pane (a sub-agent beside the chat) opts in.
|
|
282
|
+
*/
|
|
283
|
+
inline?: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Draw no agent picker. Only for a box with no agent choice: a message to an
|
|
286
|
+
* existing sub-agent goes to that agent, so a picker there would lie. Every
|
|
287
|
+
* composer that starts or continues a turn keeps it (see `ComposerUnderbar`).
|
|
288
|
+
*/
|
|
289
|
+
hideAgentPicker?: boolean;
|
|
278
290
|
/**
|
|
279
291
|
* The agent picker shows the agent's tile alone, its name in the tooltip
|
|
280
292
|
* and the menu. A narrow inline toolbar (a channel's thread panel) gives
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { errorToast } from '../../primitives/toast.js';
|
|
4
|
-
import { useUiHostConfig } from '../../providers/ui-provider.js';
|
|
4
|
+
import { useUiHostConfig, useUiViewerId } from '../../providers/ui-provider.js';
|
|
5
|
+
import { attachmentMime } from '../../internal/lib/attachment-mime.js';
|
|
5
6
|
import { useTranslations } from '../../i18n/index.js';
|
|
6
7
|
import { cn } from '../../lib/utils.js';
|
|
7
8
|
import { isImageFile } from '../../internal/lib/utils/file-utils.js';
|
|
8
|
-
import { useProjectConfig, usePromptAttachments, useRuntimeSessions } from '@kortix/sdk/react';
|
|
9
|
+
import { projectDriveQueryOptions, useFeatureFlag, useProjectConfig, usePromptAttachments, useRuntimeSessions, } from '@kortix/sdk/react';
|
|
10
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
9
11
|
import { useActiveSpace } from '../../internal/stores/active-space-store.js';
|
|
10
|
-
import {
|
|
12
|
+
import { downloadDriveFile } from '@kortix/sdk';
|
|
13
|
+
import { agentDisplayName, MAX_PROMPT_ATTACHMENT_BYTES, newPastedContentId, splitPastedContent, trimPastedText } from '../../_vendor/kortix-shared.js';
|
|
11
14
|
import { memo, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
|
|
12
15
|
import { extractClipboardFiles } from './clipboard-files.js';
|
|
16
|
+
import { createDriveChipSync, driveUploadName, drivePathsIn, withoutDriveChips } from './drive-mentions.js';
|
|
13
17
|
import { mergeFailedSubmissionFiles } from './composer-draft-recovery.js';
|
|
14
18
|
import { resolveComposerResetOnSend } from './composer-reset.js';
|
|
15
19
|
import { disownSentAttachmentPreviews, revokeUnsentPreview } from './sent-attachment-previews.js';
|
|
@@ -29,6 +33,7 @@ import { appendComposerQuote, classifyPaste, isUndoKey, popPasteUndo, extractRep
|
|
|
29
33
|
import { getContextUsage } from './context-ring.js';
|
|
30
34
|
import { useComposerFocus } from './hooks/use-composer-focus.js';
|
|
31
35
|
import { useMenuRevalidation } from './hooks/use-file-search.js';
|
|
36
|
+
import { useLatestRef } from './hooks/use-latest-ref.js';
|
|
32
37
|
import { controlToOpenFor, hostSlashActions, localizedSlashActions, slashActionShown } from './menus/slash-actions.js';
|
|
33
38
|
import { outsideAgentMentions, SpaceMentionContext } from './menus/space-mentions.js';
|
|
34
39
|
import { promptHistoryEntries, stepPromptHistory } from './prompt-history.js';
|
|
@@ -114,6 +119,8 @@ function ComposerImpl(props) {
|
|
|
114
119
|
const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
|
|
115
120
|
const tModelGate = useTranslations('sessionUi.modelGate');
|
|
116
121
|
const tComposerAttachments = useTranslations('hardcodedUi.composerAttachments');
|
|
122
|
+
/** For the submit latch, created once at the first submit: the toast speaks the current locale. */
|
|
123
|
+
const driveFilePendingMessageRef = useLatestRef(tComposerAttachments('driveFilePending'));
|
|
117
124
|
const tHardcodedUi = useTranslations('hardcodedUi');
|
|
118
125
|
const tThreads = useTranslations('threads');
|
|
119
126
|
const dockId = `composer-slash-dock-${useId().replace(/[^a-zA-Z0-9]/g, '')}`;
|
|
@@ -300,7 +307,7 @@ function ComposerImpl(props) {
|
|
|
300
307
|
restoreQuoteTexts(draft.quotes ?? []);
|
|
301
308
|
restorePastes(draft.pastes ?? []);
|
|
302
309
|
}, [restoreQuoteTexts, restorePastes, tComposerAttachments]);
|
|
303
|
-
const { handleDocChange, clearSavedDraft } = useComposerDraft({
|
|
310
|
+
const { handleDocChange, clearSavedDraft, sendRefused } = useComposerDraft({
|
|
304
311
|
active: draftActive,
|
|
305
312
|
scope: draftScope,
|
|
306
313
|
handoffScope: draftHandoffScope,
|
|
@@ -471,6 +478,92 @@ function ComposerImpl(props) {
|
|
|
471
478
|
if (uploadId)
|
|
472
479
|
void removePromptAttachment(uploadId);
|
|
473
480
|
}, [removePromptAttachment]);
|
|
481
|
+
// ── Drive `@` mentions ────────────────────────────────────────────────
|
|
482
|
+
// A picked Drive file is fetched with the viewer's own access (the server
|
|
483
|
+
// answers 404 for a file they may not read) and staged as an ordinary
|
|
484
|
+
// attachment marked with its Drive path, so it reaches the agent like any
|
|
485
|
+
// upload: no session mount changes, no second file transport.
|
|
486
|
+
const drivesOn = useFeatureFlag(projectId ?? null, 'drives').enabled;
|
|
487
|
+
const viewerId = useUiViewerId();
|
|
488
|
+
const queryClient = useQueryClient();
|
|
489
|
+
/** Drive paths still downloading: a second pick of one attaches nothing, and Send waits. */
|
|
490
|
+
const pendingDrivePathsRef = useRef(new Set());
|
|
491
|
+
// Declared before the question-lock effect below, so it holds the new value when that effect empties the editor.
|
|
492
|
+
const lockForQuestionRef = useLatestRef(lockForQuestion);
|
|
493
|
+
const pickDriveFile = useCallback(async ({ path, name, size }) => {
|
|
494
|
+
const attached = () => attachedFilesRef.current.some((file) => file.kind !== 'remote' && file.drivePath === path);
|
|
495
|
+
// Every other way to attach refuses here too: an answer to a question takes only text.
|
|
496
|
+
if (disabled || lockForQuestionRef.current || pendingDrivePathsRef.current.has(path) || attached())
|
|
497
|
+
return;
|
|
498
|
+
const dropChips = () => {
|
|
499
|
+
const doc = editorRef.current?.getDocument();
|
|
500
|
+
if (doc)
|
|
501
|
+
setDocumentWithoutStealingFocus(editorRef.current, withoutDriveChips(doc, path));
|
|
502
|
+
};
|
|
503
|
+
// Too large for a message: say so before the browser downloads it.
|
|
504
|
+
if (size !== undefined && size > MAX_PROMPT_ATTACHMENT_BYTES) {
|
|
505
|
+
errorToast(tComposerAttachments('refusedTooLarge', { name }));
|
|
506
|
+
dropChips();
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
pendingDrivePathsRef.current.add(path);
|
|
510
|
+
let file;
|
|
511
|
+
try {
|
|
512
|
+
const drive = await queryClient.fetchQuery(projectDriveQueryOptions(projectId ?? undefined, viewerId));
|
|
513
|
+
const blob = await downloadDriveFile(drive.driveId, path);
|
|
514
|
+
const taken = attachedFilesRef.current.map((held) => (held.kind === 'local' ? held.file.name : held.filename));
|
|
515
|
+
// Drive serves every file as `application/octet-stream`: the name says what it is (an image reaches the model as one).
|
|
516
|
+
file = new File([blob], driveUploadName(name, path, taken), {
|
|
517
|
+
type: attachmentMime(blob.type === 'application/octet-stream' ? '' : blob.type, name),
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
catch {
|
|
521
|
+
// Deleted, moved, or no longer shared with the viewer: say so, and take the chip back.
|
|
522
|
+
errorToast(tComposerAttachments('driveFileUnavailable', { name }));
|
|
523
|
+
dropChips();
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
finally {
|
|
527
|
+
pendingDrivePathsRef.current.delete(path);
|
|
528
|
+
}
|
|
529
|
+
// The chip went away while the file downloaded: nothing to attach.
|
|
530
|
+
if (!drivePathsIn(editorRef.current?.getDocument()).has(path))
|
|
531
|
+
return;
|
|
532
|
+
const before = new Set(attachedFilesRef.current);
|
|
533
|
+
appendAttachedFiles([file]);
|
|
534
|
+
const added = attachedFilesRef.current.find((held) => !before.has(held));
|
|
535
|
+
// Refused by the message limits: `appendAttachedFiles` already said why.
|
|
536
|
+
if (!added || added.kind === 'remote')
|
|
537
|
+
return dropChips();
|
|
538
|
+
const next = attachedFilesRef.current.map((held) => (held === added ? { ...added, drivePath: path } : held));
|
|
539
|
+
attachedFilesRef.current = next;
|
|
540
|
+
setAttachedFiles(next);
|
|
541
|
+
}, [appendAttachedFiles, disabled, lockForQuestionRef, projectId, queryClient, tComposerAttachments, viewerId]);
|
|
542
|
+
const pickDriveFileRef = useLatestRef(pickDriveFile);
|
|
543
|
+
const removeAttachedFileRef = useLatestRef(removeAttachedFile);
|
|
544
|
+
const driveChipSyncRef = useRef(null);
|
|
545
|
+
// Lazy-created at the first use (never during render, which the compiler's ref rules forbid).
|
|
546
|
+
const driveChipSync = useCallback(() => (driveChipSyncRef.current ??= createDriveChipSync({
|
|
547
|
+
tray: () => attachedFilesRef.current,
|
|
548
|
+
remove: (index) => removeAttachedFileRef.current(index),
|
|
549
|
+
refetch: (file) => void pickDriveFileRef.current(file),
|
|
550
|
+
paused: () => lockForQuestionRef.current,
|
|
551
|
+
})), [lockForQuestionRef, pickDriveFileRef, removeAttachedFileRef]);
|
|
552
|
+
const handleDocChangeWithDrive = useCallback((doc, isEmpty) => {
|
|
553
|
+
handleEditorDocChange(doc, isEmpty);
|
|
554
|
+
driveChipSync().onDoc(doc, applyingHistoryRef.current);
|
|
555
|
+
}, [driveChipSync, handleEditorDocChange]);
|
|
556
|
+
const driveMentions = useMemo(
|
|
557
|
+
// A host that keeps files in its own store (`takeFiles`) gets no Drive rows.
|
|
558
|
+
() => projectId && drivesOn && !takeFiles
|
|
559
|
+
? {
|
|
560
|
+
projectId,
|
|
561
|
+
onPick: (file) => {
|
|
562
|
+
driveChipSync().trust(file.path);
|
|
563
|
+
void pickDriveFile(file);
|
|
564
|
+
},
|
|
565
|
+
}
|
|
566
|
+
: null, [projectId, drivesOn, takeFiles, driveChipSync, pickDriveFile]);
|
|
474
567
|
const retryAttachedFile = useCallback((id) => {
|
|
475
568
|
try {
|
|
476
569
|
retryPromptAttachment(id);
|
|
@@ -1231,6 +1324,7 @@ function ComposerImpl(props) {
|
|
|
1231
1324
|
// The host refused the send before anything durable happened. Its uploads
|
|
1232
1325
|
// are back in the tray, and the draft returns: a failed file shows its
|
|
1233
1326
|
// Retry; a ready one sends again without re-upload.
|
|
1327
|
+
sendRefused();
|
|
1234
1328
|
const currentDoc = editorRef.current?.getDocument() ?? null;
|
|
1235
1329
|
const currentIsEmpty = editorRef.current?.isEmpty() ?? true;
|
|
1236
1330
|
const sentFiles = filesToSend ?? [];
|
|
@@ -1291,6 +1385,7 @@ function ComposerImpl(props) {
|
|
|
1291
1385
|
onCommand,
|
|
1292
1386
|
onHoldCommand,
|
|
1293
1387
|
clearSavedDraft,
|
|
1388
|
+
sendRefused,
|
|
1294
1389
|
handleDocChange,
|
|
1295
1390
|
setQuoteList,
|
|
1296
1391
|
restoreQuoteTexts,
|
|
@@ -1391,6 +1486,14 @@ function ComposerImpl(props) {
|
|
|
1391
1486
|
attachmentSubmission,
|
|
1392
1487
|
placement: submitPlacementRef.current,
|
|
1393
1488
|
};
|
|
1489
|
+
},
|
|
1490
|
+
// A Drive file still downloading would leave without its bytes (a message), be thrown away (a
|
|
1491
|
+
// command), or lose its chip to a mid-send stash. Every submit waits for it, the stash included.
|
|
1492
|
+
() => {
|
|
1493
|
+
if (pendingDrivePathsRef.current.size === 0)
|
|
1494
|
+
return false;
|
|
1495
|
+
errorToast(driveFilePendingMessageRef.current);
|
|
1496
|
+
return true;
|
|
1394
1497
|
});
|
|
1395
1498
|
return submitLatchRef.current();
|
|
1396
1499
|
// `restoreQuoteTexts`, `setQuoteList`, `restorePastes` and `setPasteList`
|
|
@@ -1492,6 +1595,7 @@ function ComposerImpl(props) {
|
|
|
1492
1595
|
attachedFiles,
|
|
1493
1596
|
promptAttachmentItems,
|
|
1494
1597
|
removeAttachedFile,
|
|
1598
|
+
driveMentions,
|
|
1495
1599
|
retryAttachedFile,
|
|
1496
1600
|
pastes,
|
|
1497
1601
|
removePaste,
|
|
@@ -1506,7 +1610,7 @@ function ComposerImpl(props) {
|
|
|
1506
1610
|
handleArrowDownAtEnd,
|
|
1507
1611
|
historyPosition: historyIndex === null ? null : { index: historyIndex + 1, total: historyEntries.length },
|
|
1508
1612
|
setIsEmpty,
|
|
1509
|
-
handleDocChange:
|
|
1613
|
+
handleDocChange: handleDocChangeWithDrive,
|
|
1510
1614
|
allSessions,
|
|
1511
1615
|
slashActions,
|
|
1512
1616
|
handleSelectAction,
|
|
@@ -1547,6 +1651,8 @@ function ComposerImpl(props) {
|
|
|
1547
1651
|
// (starter suggestions). `twMerge` replaces the shell's `z-10` so
|
|
1548
1652
|
// this stacking context sits above them; the dock's own `z-99` only
|
|
1549
1653
|
// ranks inside this shell and cannot do that job.
|
|
1550
|
-
slashMenuPlacement === 'below' && 'z-50',
|
|
1654
|
+
slashMenuPlacement === 'below' && 'z-50',
|
|
1655
|
+
// `inline` sits in a host that already has its gutter (the sub-agent panel): no second one.
|
|
1656
|
+
props.inline && 'px-0', parentClassName), children: [_jsx(ComposerAboveCard, { ...props, ...aboveProps }), _jsx(ComposerCard, { ...props, ...cardProps })] }));
|
|
1551
1657
|
}
|
|
1552
1658
|
export const Composer = memo(ComposerImpl);
|
|
@@ -113,7 +113,7 @@ export function deserializeDraft(raw, currentUserId) {
|
|
|
113
113
|
/** A stored upload that is whole and not yet expired; anything else is dropped. */
|
|
114
114
|
function storedUpload(value) {
|
|
115
115
|
const candidate = (value ?? {});
|
|
116
|
-
const { attachment_id, filename, mime, size, expires_at, isImage } = candidate;
|
|
116
|
+
const { attachment_id, filename, mime, size, expires_at, isImage, drivePath } = candidate;
|
|
117
117
|
if (typeof attachment_id !== 'string' || !attachment_id)
|
|
118
118
|
return null;
|
|
119
119
|
if (typeof filename !== 'string' || !filename)
|
|
@@ -124,7 +124,15 @@ function storedUpload(value) {
|
|
|
124
124
|
return null;
|
|
125
125
|
if (typeof expires_at !== 'string' || !(Date.parse(expires_at) > Date.now()))
|
|
126
126
|
return null;
|
|
127
|
-
return {
|
|
127
|
+
return {
|
|
128
|
+
attachment_id,
|
|
129
|
+
filename,
|
|
130
|
+
mime,
|
|
131
|
+
size,
|
|
132
|
+
expires_at,
|
|
133
|
+
isImage: isImage === true,
|
|
134
|
+
...(typeof drivePath === 'string' && drivePath ? { drivePath } : {}),
|
|
135
|
+
};
|
|
128
136
|
}
|
|
129
137
|
/** The node type an earlier build of the composer used for in-editor quotes. */
|
|
130
138
|
const LEGACY_QUOTE_NODE = 'replyQuote';
|
|
@@ -11,7 +11,15 @@ export function finishedDraftUploads(files, items) {
|
|
|
11
11
|
return [
|
|
12
12
|
{
|
|
13
13
|
uploadId: file.uploadId,
|
|
14
|
-
upload: {
|
|
14
|
+
upload: {
|
|
15
|
+
attachment_id,
|
|
16
|
+
filename,
|
|
17
|
+
mime,
|
|
18
|
+
size,
|
|
19
|
+
expires_at,
|
|
20
|
+
isImage: file.isImage,
|
|
21
|
+
...(file.drivePath ? { drivePath: file.drivePath } : {}),
|
|
22
|
+
},
|
|
15
23
|
...(file.kind === 'local' ? { file: file.file } : {}),
|
|
16
24
|
},
|
|
17
25
|
];
|
|
@@ -51,7 +59,7 @@ export function takeUnsentUploadFile(attachmentId) {
|
|
|
51
59
|
*/
|
|
52
60
|
export function restoreDraftUploads(uploads, dependencies) {
|
|
53
61
|
const files = uploads.map((upload) => takeUnsentUploadFile(upload.attachment_id));
|
|
54
|
-
const ids = dependencies.restore(uploads.map(({ isImage: _isImage, ...attachment }, index) => ({
|
|
62
|
+
const ids = dependencies.restore(uploads.map(({ isImage: _isImage, drivePath: _drivePath, ...attachment }, index) => ({
|
|
55
63
|
attachment,
|
|
56
64
|
...(files[index] ? { file: files[index] } : {}),
|
|
57
65
|
})));
|
|
@@ -60,6 +68,7 @@ export function restoreDraftUploads(uploads, dependencies) {
|
|
|
60
68
|
if (!uploadId)
|
|
61
69
|
return [];
|
|
62
70
|
const file = files[index];
|
|
71
|
+
const drive = upload.drivePath ? { drivePath: upload.drivePath } : {};
|
|
63
72
|
if (file)
|
|
64
73
|
return [
|
|
65
74
|
{
|
|
@@ -68,6 +77,7 @@ export function restoreDraftUploads(uploads, dependencies) {
|
|
|
68
77
|
file,
|
|
69
78
|
localUrl: dependencies.createObjectURL(file),
|
|
70
79
|
isImage: upload.isImage,
|
|
80
|
+
...drive,
|
|
71
81
|
},
|
|
72
82
|
];
|
|
73
83
|
return [
|
|
@@ -78,6 +88,7 @@ export function restoreDraftUploads(uploads, dependencies) {
|
|
|
78
88
|
mime: upload.mime,
|
|
79
89
|
size: upload.size,
|
|
80
90
|
isImage: false,
|
|
91
|
+
...drive,
|
|
81
92
|
},
|
|
82
93
|
];
|
|
83
94
|
});
|
|
@@ -38,6 +38,8 @@ export interface UseComposerDraftResult {
|
|
|
38
38
|
handleDocChange: (doc: JSONContent, isEmpty: boolean) => void;
|
|
39
39
|
/** Call on a SUCCESSFUL send. Never on a refusal — those keep the text. */
|
|
40
40
|
clearSavedDraft: () => void;
|
|
41
|
+
/** The host refused the send: what is on screen is a draft again. */
|
|
42
|
+
sendRefused: () => void;
|
|
41
43
|
}
|
|
42
44
|
/**
|
|
43
45
|
* Persist and restore the unsent composer draft.
|
|
@@ -14,6 +14,10 @@ const SAVE_DEBOUNCE_MS = 400;
|
|
|
14
14
|
const NO_QUOTES = [];
|
|
15
15
|
const NO_PASTES = [];
|
|
16
16
|
const NO_UPLOADS = [];
|
|
17
|
+
/** A composer's sendable content, compared to tell a sent message from a new draft. */
|
|
18
|
+
function sentKey(doc, quotes, pastes) {
|
|
19
|
+
return JSON.stringify([doc, quotes, pastes]);
|
|
20
|
+
}
|
|
17
21
|
/**
|
|
18
22
|
* Persist and restore the unsent composer draft.
|
|
19
23
|
*
|
|
@@ -48,6 +52,16 @@ export function useComposerDraft({ active = true, handoffScope, scope, editorRef
|
|
|
48
52
|
const timerRef = useRef(null);
|
|
49
53
|
const restoredKeyRef = useRef(null);
|
|
50
54
|
const activeRef = useRef(active);
|
|
55
|
+
/**
|
|
56
|
+
* What the last send left on screen (`clearOnSend={false}`, project home):
|
|
57
|
+
* `sentKey` of its document, quotes and tiles. That is sent, not a draft: an
|
|
58
|
+
* attachment released or finishing after Send must not save it again, or
|
|
59
|
+
* the home handoff carries it into the new session's composer. The first
|
|
60
|
+
* change to any of them (typing, clearing, a new quote) or a refused send
|
|
61
|
+
* ends it.
|
|
62
|
+
*/
|
|
63
|
+
const sentRef = useRef(null);
|
|
64
|
+
const submittedRef = useRef(false);
|
|
51
65
|
/**
|
|
52
66
|
* Write whatever is pending, now.
|
|
53
67
|
*
|
|
@@ -96,14 +110,21 @@ export function useComposerDraft({ active = true, handoffScope, scope, editorRef
|
|
|
96
110
|
activeRef.current = false;
|
|
97
111
|
};
|
|
98
112
|
}, [active, flush, handoffScope, scopeRef, userIdRef]);
|
|
99
|
-
const
|
|
113
|
+
const scheduleSave = useCallback((doc, isEmpty) => {
|
|
100
114
|
if (!activeRef.current || !scopeRef.current || !userIdRef.current)
|
|
101
115
|
return;
|
|
116
|
+
if (sentRef.current === sentKey(doc, quotesRef.current, pastesRef.current))
|
|
117
|
+
return;
|
|
118
|
+
sentRef.current = null;
|
|
102
119
|
pendingRef.current = { doc, isEmpty };
|
|
103
120
|
if (timerRef.current !== null)
|
|
104
121
|
clearTimeout(timerRef.current);
|
|
105
122
|
timerRef.current = setTimeout(flush, SAVE_DEBOUNCE_MS);
|
|
106
123
|
}, [flush, scopeRef, userIdRef]);
|
|
124
|
+
const handleDocChange = useCallback((doc, isEmpty) => {
|
|
125
|
+
submittedRef.current = false;
|
|
126
|
+
scheduleSave(doc, isEmpty);
|
|
127
|
+
}, [scheduleSave]);
|
|
107
128
|
/**
|
|
108
129
|
* A quote list, tile row or finished-upload change is a draft change. The snapshot is the live editor's
|
|
109
130
|
* document, read now, the same pair `handleDocChange` would receive.
|
|
@@ -123,19 +144,29 @@ export function useComposerDraft({ active = true, handoffScope, scope, editorRef
|
|
|
123
144
|
if (!editorReady || !editor)
|
|
124
145
|
return;
|
|
125
146
|
const doc = editor.getDocument();
|
|
126
|
-
if (doc)
|
|
127
|
-
|
|
128
|
-
|
|
147
|
+
if (!doc)
|
|
148
|
+
return;
|
|
149
|
+
if (sentRef.current === sentKey(doc, quotesRef.current, pastesRef.current))
|
|
150
|
+
return;
|
|
151
|
+
// Accessory cleanup must not persist text retained on screen after Send.
|
|
152
|
+
scheduleSave(submittedRef.current ? { type: 'doc', content: [{ type: 'paragraph' }] } : doc, submittedRef.current || editor.isEmpty());
|
|
153
|
+
}, [quotes, pastes, uploads, uploadsKey, editorReady, editorRef, scheduleSave]);
|
|
129
154
|
const clearSavedDraft = useCallback(() => {
|
|
155
|
+
submittedRef.current = true;
|
|
130
156
|
if (timerRef.current !== null) {
|
|
131
157
|
clearTimeout(timerRef.current);
|
|
132
158
|
timerRef.current = null;
|
|
133
159
|
}
|
|
134
160
|
pendingRef.current = null;
|
|
161
|
+
const editor = editorRef.current;
|
|
162
|
+
sentRef.current =
|
|
163
|
+
editor && !editor.isEmpty()
|
|
164
|
+
? sentKey(editor.getDocument(), quotesRef.current, pastesRef.current)
|
|
165
|
+
: null;
|
|
135
166
|
const activeScope = scopeRef.current;
|
|
136
167
|
if (activeRef.current && activeScope)
|
|
137
168
|
clearDraft(activeScope);
|
|
138
|
-
}, [scopeRef]);
|
|
169
|
+
}, [editorRef, scopeRef]);
|
|
139
170
|
/**
|
|
140
171
|
* Flush on every way a page can go away without unmounting cleanly.
|
|
141
172
|
*
|
|
@@ -185,5 +216,9 @@ export function useComposerDraft({ active = true, handoffScope, scope, editorRef
|
|
|
185
216
|
if (editorRef.current)
|
|
186
217
|
completeHomeComposerFocus(scope, editorRef.current);
|
|
187
218
|
}, [active, scope, userId, editorReady, hasPrefill, editorRef, onRestore]);
|
|
188
|
-
|
|
219
|
+
const sendRefused = useCallback(() => {
|
|
220
|
+
submittedRef.current = false;
|
|
221
|
+
sentRef.current = null;
|
|
222
|
+
}, []);
|
|
223
|
+
return { handleDocChange, clearSavedDraft, sendRefused };
|
|
189
224
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { JSONContent } from '@tiptap/core';
|
|
2
|
+
import type { DriveUploadLike } from '../../internal/lib/project-preamble.js';
|
|
3
|
+
import type { AttachedFile } from './types.js';
|
|
4
|
+
/** The document's Drive chips: Drive path → the file's name, first chip of a path wins. */
|
|
5
|
+
export declare function driveChipsIn(doc: JSONContent | null | undefined): Map<string, string>;
|
|
6
|
+
/** The Drive paths the document's chips name. */
|
|
7
|
+
export declare function drivePathsIn(doc: JSONContent | null | undefined): Set<string>;
|
|
8
|
+
/** The document without the chips that name `path` (a file that could not be attached). */
|
|
9
|
+
export declare function withoutDriveChips(doc: JSONContent, path: string): JSONContent;
|
|
10
|
+
/**
|
|
11
|
+
* The upload name for a picked Drive file: its own name, unless the tray
|
|
12
|
+
* already holds that name, then the name with its folder (`logo (brand).png`),
|
|
13
|
+
* so the agent tells two `logo.png` apart.
|
|
14
|
+
*/
|
|
15
|
+
export declare function driveUploadName(name: string, path: string, taken: readonly string[]): string;
|
|
16
|
+
/** The tray's files that came from Drive, as the reference blocks read them. */
|
|
17
|
+
export declare function driveUploadsOf(files: readonly AttachedFile[] | undefined): DriveUploadLike[];
|
|
18
|
+
/** Keeps the tray's Drive files in step with the document's Drive chips (`createDriveChipSync`). */
|
|
19
|
+
export type DriveChipSync = {
|
|
20
|
+
/** A path picked from the menu: a chip of it that comes back without its file fetches the file again. */
|
|
21
|
+
trust: (path: string) => void;
|
|
22
|
+
/** Every document change. `recalling`: a recalled prompt replaces the draft for a moment and the tray keeps its files. */
|
|
23
|
+
onDoc: (doc: JSONContent, recalling: boolean) => void;
|
|
24
|
+
};
|
|
25
|
+
export declare function createDriveChipSync(deps: {
|
|
26
|
+
tray: () => readonly AttachedFile[];
|
|
27
|
+
remove: (index: number) => void;
|
|
28
|
+
refetch: (file: {
|
|
29
|
+
path: string;
|
|
30
|
+
name: string;
|
|
31
|
+
}) => void;
|
|
32
|
+
/** A question lock keeps the tray. */
|
|
33
|
+
paused: () => boolean;
|
|
34
|
+
}): DriveChipSync;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drive `@` mentions in the composer. A Drive chip (`kind: 'drive'`, `value`
|
|
3
|
+
* its Drive path) names a file; the bytes ride as an ordinary attachment the
|
|
4
|
+
* composer staged when the file was picked, marked with the same path
|
|
5
|
+
* (`AttachedFile.drivePath`).
|
|
6
|
+
*/
|
|
7
|
+
const isDriveChip = (node) => node.type === 'mention' && node.attrs?.kind === 'drive';
|
|
8
|
+
/** The document's Drive chips: Drive path → the file's name, first chip of a path wins. */
|
|
9
|
+
export function driveChipsIn(doc) {
|
|
10
|
+
const chips = new Map();
|
|
11
|
+
const walk = (node) => {
|
|
12
|
+
const path = node.attrs?.value;
|
|
13
|
+
if (isDriveChip(node) && typeof path === 'string' && path && !chips.has(path))
|
|
14
|
+
chips.set(path, String(node.attrs?.label ?? ''));
|
|
15
|
+
node.content?.forEach(walk);
|
|
16
|
+
};
|
|
17
|
+
if (doc)
|
|
18
|
+
walk(doc);
|
|
19
|
+
return chips;
|
|
20
|
+
}
|
|
21
|
+
/** The Drive paths the document's chips name. */
|
|
22
|
+
export function drivePathsIn(doc) {
|
|
23
|
+
return new Set(driveChipsIn(doc).keys());
|
|
24
|
+
}
|
|
25
|
+
/** The document without the chips that name `path` (a file that could not be attached). */
|
|
26
|
+
export function withoutDriveChips(doc, path) {
|
|
27
|
+
const prune = (node) => node.content
|
|
28
|
+
? { ...node, content: node.content.filter((child) => !(isDriveChip(child) && child.attrs?.value === path)).map(prune) }
|
|
29
|
+
: node;
|
|
30
|
+
return prune(doc);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The upload name for a picked Drive file: its own name, unless the tray
|
|
34
|
+
* already holds that name, then the name with its folder (`logo (brand).png`),
|
|
35
|
+
* so the agent tells two `logo.png` apart.
|
|
36
|
+
*/
|
|
37
|
+
export function driveUploadName(name, path, taken) {
|
|
38
|
+
if (!taken.includes(name))
|
|
39
|
+
return name;
|
|
40
|
+
const dot = name.lastIndexOf('.');
|
|
41
|
+
const [stem, ext] = dot > 0 ? [name.slice(0, dot), name.slice(dot)] : [name, ''];
|
|
42
|
+
const folder = path.split('/').slice(-2, -1)[0] || 'Drive';
|
|
43
|
+
let candidate = `${stem} (${folder})${ext}`;
|
|
44
|
+
for (let n = 2; taken.includes(candidate); n++)
|
|
45
|
+
candidate = `${stem} (${folder} ${n})${ext}`;
|
|
46
|
+
return candidate;
|
|
47
|
+
}
|
|
48
|
+
/** The tray's files that came from Drive, as the reference blocks read them. */
|
|
49
|
+
export function driveUploadsOf(files) {
|
|
50
|
+
return (files ?? []).flatMap((file) => file.kind !== 'remote' && file.drivePath
|
|
51
|
+
? [{ name: file.kind === 'local' ? file.file.name : file.filename, drivePath: file.drivePath }]
|
|
52
|
+
: []);
|
|
53
|
+
}
|
|
54
|
+
export function createDriveChipSync(deps) {
|
|
55
|
+
const { tray, remove, refetch, paused } = deps;
|
|
56
|
+
/** The Drive paths the document named after its last change: a path that leaves it is a deleted chip. */
|
|
57
|
+
let named = new Set();
|
|
58
|
+
/**
|
|
59
|
+
* The only chips worth fetching a file for again: picked from the menu here, or one whose Drive file the
|
|
60
|
+
* tray held (a restored draft or failed send). A chip that arrives any other way (pasted rich text) is
|
|
61
|
+
* never a request to read a file.
|
|
62
|
+
*/
|
|
63
|
+
const trusted = new Set();
|
|
64
|
+
const held = (path) => tray().findIndex((file) => file.kind !== 'remote' && file.drivePath === path);
|
|
65
|
+
return {
|
|
66
|
+
trust: (path) => void trusted.add(path),
|
|
67
|
+
onDoc(doc, recalling) {
|
|
68
|
+
const chips = driveChipsIn(doc);
|
|
69
|
+
const previous = named;
|
|
70
|
+
named = new Set(chips.keys());
|
|
71
|
+
if (recalling)
|
|
72
|
+
return;
|
|
73
|
+
const removed = [...previous].filter((path) => !chips.has(path));
|
|
74
|
+
const added = [...chips].filter(([path]) => !previous.has(path));
|
|
75
|
+
if (removed.length === 0 && added.length === 0)
|
|
76
|
+
return;
|
|
77
|
+
// Run after the change settles. A send or a command empties the editor and hands its tray off in
|
|
78
|
+
// the same handler, and a restore (draft, failed send, prefill) sets the document and then its
|
|
79
|
+
// files: by then the tray is what the change left.
|
|
80
|
+
queueMicrotask(() => {
|
|
81
|
+
if (paused())
|
|
82
|
+
return;
|
|
83
|
+
// The person deleted the last chip of a path: its file leaves the tray, and an undo may fetch it back.
|
|
84
|
+
for (const path of removed) {
|
|
85
|
+
const index = held(path);
|
|
86
|
+
if (index === -1)
|
|
87
|
+
continue;
|
|
88
|
+
trusted.add(path);
|
|
89
|
+
remove(index);
|
|
90
|
+
}
|
|
91
|
+
// A trusted chip came back without its file (an undo, a redo): fetch it again.
|
|
92
|
+
for (const [path, name] of added)
|
|
93
|
+
if (trusted.has(path) && held(path) === -1)
|
|
94
|
+
refetch({ path, name });
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|