@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.
Files changed (285) hide show
  1. package/dist/_vendor/kortix-shared.js +157 -51
  2. package/dist/_vendor/shared/index.d.ts +1 -0
  3. package/dist/_vendor/shared/space-icon.d.ts +30 -0
  4. package/dist/_vendor/shared/space-slug.d.ts +12 -0
  5. package/dist/access/access/access-dialog.js +2 -2
  6. package/dist/access/share-dialog.d.ts +77 -0
  7. package/dist/access/share-dialog.js +160 -0
  8. package/dist/access/sharing-picker.d.ts +8 -1
  9. package/dist/access/sharing-picker.js +2 -2
  10. package/dist/changes/change-list.js +3 -3
  11. package/dist/customize/connectors/catalog/catalog-paging.d.ts +1 -1
  12. package/dist/customize/connectors/catalog/catalog-paging.js +1 -1
  13. package/dist/customize/providers/provider-sheet.js +17 -7
  14. package/dist/customize/sections/component/manifest-copy-block.js +1 -1
  15. package/dist/customize/sections/component/section-wrapper.d.ts +1 -8
  16. package/dist/customize/sections/component/section-wrapper.js +3 -3
  17. package/dist/customize/sections/llm-provider/model-capability-icons.js +1 -1
  18. package/dist/customize/sections/view/gateway/generation-controls.js +1 -1
  19. package/dist/customize/sections/view/git-view.js +1 -1
  20. package/dist/customize/settings/settings-tabs.js +0 -5
  21. package/dist/customize/settings/tabs/general-tab.js +2 -2
  22. package/dist/customize/shared/capability-page-shell.d.ts +2 -2
  23. package/dist/customize/shared/capability-page-shell.js +7 -5
  24. package/dist/customize/shared/capability-scroll-root.js +1 -2
  25. package/dist/customize/shared/catalog/catalog-card.js +1 -1
  26. package/dist/files/project/components/change-requests-panel.js +2 -2
  27. package/dist/files/project/components/checkpoint-detail-dialog.js +4 -4
  28. package/dist/files/project/components/checkpoints-panel.js +2 -2
  29. package/dist/files/project/components/drive-explorer.js +2 -2
  30. package/dist/files/project/components/file-breadcrumbs.js +1 -1
  31. package/dist/files/project/components/file-history-popover.js +2 -2
  32. package/dist/files/project/components/file-thumbnail.js +1 -1
  33. package/dist/files/project/components/open-change-request-dialog.js +1 -1
  34. package/dist/files/renderers/mermaid/mermaid-diagram.js +2 -2
  35. package/dist/files/renderers/show-content-renderer.js +6 -6
  36. package/dist/files/renderers/sqlite-renderer.js +8 -8
  37. package/dist/files/renderers/zip/zip-renderer.js +2 -2
  38. package/dist/files/viewer/file-content-renderer.js +5 -5
  39. package/dist/files/viewer/json-tree-view.js +3 -3
  40. package/dist/i18n/en.d.ts +133 -8
  41. package/dist/i18n/en.js +170 -45
  42. package/dist/i18n/ui-catalog/remaining-ui-translation-keys.generated.js +0 -3
  43. package/dist/internal/billing/use-cost-explorer.d.ts +9 -2
  44. package/dist/internal/billing/use-cost-explorer.js +22 -0
  45. package/dist/internal/billing/use-session-costs.d.ts +7 -2
  46. package/dist/internal/billing/use-session-costs.js +6 -0
  47. package/dist/internal/chrome/use-chrome-offered.d.ts +3 -3
  48. package/dist/internal/chrome/use-chrome-offered.js +3 -3
  49. package/dist/internal/components/nav-rail.d.ts +1 -20
  50. package/dist/internal/components/nav-rail.js +1 -15
  51. package/dist/internal/layout/project-page-header.d.ts +13 -9
  52. package/dist/internal/layout/project-page-header.js +14 -10
  53. package/dist/internal/lib/browser-noise/evidence.d.ts +2 -0
  54. package/dist/internal/lib/browser-noise/rules/injected-scripts.js +16 -1
  55. package/dist/internal/lib/error-handler.js +0 -9
  56. package/dist/internal/lib/interface-theme-defaults.js +2 -2
  57. package/dist/internal/lib/project-actions.d.ts +4 -5
  58. package/dist/internal/lib/project-actions.js +3 -5
  59. package/dist/internal/lib/project-preamble.d.ts +42 -4
  60. package/dist/internal/lib/project-preamble.js +49 -5
  61. package/dist/internal/lib/web-notifications.js +17 -29
  62. package/dist/internal/outcomes/outcome-vocabulary.js +1 -1
  63. package/dist/internal/stores/session-filter-store.d.ts +1 -1
  64. package/dist/internal/stores/user-preferences-store.d.ts +2 -2
  65. package/dist/internal/stores/workspace-settings-rail-store.d.ts +0 -8
  66. package/dist/internal/stores/workspace-settings-rail-store.js +0 -2
  67. package/dist/lib/routes.d.ts +7 -0
  68. package/dist/lib/routes.js +6 -1
  69. package/dist/markdown/doc-editor/doc-extensions.js +2 -0
  70. package/dist/markdown/doc-editor/doc-paste.d.ts +13 -0
  71. package/dist/markdown/doc-editor/doc-paste.js +67 -0
  72. package/dist/markdown/markdown-frontmatter.js +3 -3
  73. package/dist/markdown/markdown-policy.d.ts +1 -1
  74. package/dist/markdown/ordered-list.js +1 -1
  75. package/dist/primitives/context-menu.d.ts +1 -0
  76. package/dist/primitives/definition-list.js +1 -1
  77. package/dist/primitives/dropdown-menu.d.ts +1 -0
  78. package/dist/primitives/emoji-picker.js +1 -1
  79. package/dist/primitives/expandable-search.d.ts +57 -0
  80. package/dist/primitives/expandable-search.js +58 -0
  81. package/dist/primitives/favicon-avatar.js +1 -1
  82. package/dist/primitives/file-tree.d.ts +1 -1
  83. package/dist/primitives/file-tree.js +1 -1
  84. package/dist/primitives/glyph-picker.js +2 -2
  85. package/dist/primitives/input-group.js +1 -1
  86. package/dist/primitives/menu-base.d.ts +10 -0
  87. package/dist/primitives/menu-base.js +7 -2
  88. package/dist/primitives/phone-input.js +1 -1
  89. package/dist/primitives/profile-hover-card.d.ts +28 -0
  90. package/dist/primitives/profile-hover-card.js +22 -0
  91. package/dist/primitives/settings-section-header.d.ts +5 -5
  92. package/dist/primitives/settings-section-header.js +5 -5
  93. package/dist/primitives/sort-menu.d.ts +23 -0
  94. package/dist/primitives/sort-menu.js +54 -0
  95. package/dist/primitives/tabs.js +1 -1
  96. package/dist/primitives/toast-clearance.d.ts +12 -28
  97. package/dist/primitives/toast-clearance.js +23 -45
  98. package/dist/primitives/user-avatar.js +2 -3
  99. package/dist/session/agents/subagent-dialog-content.js +28 -70
  100. package/dist/session/composer/ComposerCard.d.ts +4 -1
  101. package/dist/session/composer/ComposerCard.js +51 -7
  102. package/dist/session/composer/composer-chat-input.js +3 -1
  103. package/dist/session/composer/composer-toolbar.d.ts +3 -1
  104. package/dist/session/composer/composer-toolbar.js +6 -2
  105. package/dist/session/composer/composer-underbar.d.ts +3 -1
  106. package/dist/session/composer/composer-underbar.js +2 -2
  107. package/dist/session/composer/composer.d.ts +12 -0
  108. package/dist/session/composer/composer.js +112 -6
  109. package/dist/session/composer/draft/composer-draft.d.ts +1 -0
  110. package/dist/session/composer/draft/composer-draft.js +10 -2
  111. package/dist/session/composer/draft/draft-uploads.js +13 -2
  112. package/dist/session/composer/draft/use-composer-draft.d.ts +2 -0
  113. package/dist/session/composer/draft/use-composer-draft.js +41 -6
  114. package/dist/session/composer/drive-mentions.d.ts +34 -0
  115. package/dist/session/composer/drive-mentions.js +98 -0
  116. package/dist/session/composer/editor/composer-editor.d.ts +3 -0
  117. package/dist/session/composer/editor/composer-editor.js +3 -1
  118. package/dist/session/composer/editor/serialize.js +3 -4
  119. package/dist/session/composer/menus/mention-controller.d.ts +3 -0
  120. package/dist/session/composer/menus/mention-controller.js +5 -0
  121. package/dist/session/composer/menus/mention-menu.d.ts +20 -3
  122. package/dist/session/composer/menus/mention-menu.js +33 -6
  123. package/dist/session/composer/menus/menu-items.d.ts +16 -1
  124. package/dist/session/composer/menus/menu-items.js +21 -1
  125. package/dist/session/composer/submit-latch.d.ts +3 -1
  126. package/dist/session/composer/submit-latch.js +5 -1
  127. package/dist/session/composer/types.d.ts +9 -2
  128. package/dist/session/header/session-changes-indicator.js +1 -1
  129. package/dist/session/header/session-site-header.js +2 -2
  130. package/dist/session/media/sandbox-url-detector.js +3 -3
  131. package/dist/session/models/model-connection-gate.d.ts +5 -0
  132. package/dist/session/models/model-connection-gate.js +12 -3
  133. package/dist/session/models/model-connection-layout.d.ts +7 -0
  134. package/dist/session/models/model-connection-layout.js +7 -0
  135. package/dist/session/models/provider-failure-recovery.js +1 -1
  136. package/dist/session/models/subscription-offer.d.ts +6 -5
  137. package/dist/session/models/subscription-offer.js +6 -6
  138. package/dist/session/panel/advanced/advanced-panel.js +1 -1
  139. package/dist/session/panel/session-detail-panel.js +1 -1
  140. package/dist/session/panel/session-diff-viewer.js +1 -1
  141. package/dist/session/panel/session-files-explorer.js +1 -1
  142. package/dist/session/panel/session-files-panel.js +3 -3
  143. package/dist/session/panel/shared/action-navigator.js +1 -1
  144. package/dist/session/status/provisioning-failure.d.ts +4 -4
  145. package/dist/session/status/provisioning-failure.js +4 -4
  146. package/dist/session/status/session-busy-indicator.js +1 -1
  147. package/dist/session/status/session-error-banner.js +6 -1
  148. package/dist/session/thread/mention-chip.d.ts +1 -1
  149. package/dist/session/thread/mention-segments.d.ts +4 -2
  150. package/dist/session/thread/mention-segments.js +28 -1
  151. package/dist/session/thread/message-parsing.d.ts +11 -0
  152. package/dist/session/thread/message-parsing.js +22 -3
  153. package/dist/session/thread/optimistic-turn.d.ts +4 -2
  154. package/dist/session/thread/optimistic-turn.js +13 -11
  155. package/dist/session/thread/session-chat.js +6 -1
  156. package/dist/session/thread/session-context-message-explorer.js +1 -1
  157. package/dist/session/thread/session-older-autoload.d.ts +2 -3
  158. package/dist/session/thread/session-older-autoload.js +2 -3
  159. package/dist/session/thread/transcript.js +8 -10
  160. package/dist/session/tool/shared/error-and-connector.js +1 -1
  161. package/dist/session/tool/shared/file-list.js +2 -2
  162. package/dist/session/tool/shared/infrastructure-parts.js +1 -1
  163. package/dist/session/tool/shared/infrastructure-preview.js +1 -1
  164. package/dist/session/tool/shared/infrastructure-row-header.js +3 -3
  165. package/dist/session/tool/shared/infrastructure-rows.js +2 -2
  166. package/dist/session/tool/shared/output-block.js +4 -4
  167. package/dist/session/tool/shared/session-helpers.js +3 -3
  168. package/dist/session/tool/shared/structured-output.js +3 -3
  169. package/dist/session/tool/shared/todo-helpers.js +1 -1
  170. package/dist/session/tool/tool-error.js +2 -2
  171. package/dist/session/tool/tools/agent-spawn-tool.js +3 -3
  172. package/dist/session/tool/tools/agent-status-tool.js +1 -1
  173. package/dist/session/tool/tools/apply-patch-tool.js +1 -1
  174. package/dist/session/tool/tools/connector-get-tool.js +1 -1
  175. package/dist/session/tool/tools/connector-list-tool.js +1 -1
  176. package/dist/session/tool/tools/connector-tools.js +1 -1
  177. package/dist/session/tool/tools/edit-tool.js +1 -1
  178. package/dist/session/tool/tools/get-mem-tool.js +1 -1
  179. package/dist/session/tool/tools/glob-tool.js +1 -1
  180. package/dist/session/tool/tools/image-search-tool.js +1 -1
  181. package/dist/session/tool/tools/memory-search-tool.js +1 -1
  182. package/dist/session/tool/tools/memory-tool.js +4 -4
  183. package/dist/session/tool/tools/presentation-gen-tool.js +2 -2
  184. package/dist/session/tool/tools/project-delete-tool.js +1 -1
  185. package/dist/session/tool/tools/project-list-tool.js +1 -1
  186. package/dist/session/tool/tools/pty-read-tool.js +1 -1
  187. package/dist/session/tool/tools/pty-spawn-tool.js +1 -1
  188. package/dist/session/tool/tools/pty-write-tool.js +1 -1
  189. package/dist/session/tool/tools/read-tool.js +1 -1
  190. package/dist/session/tool/tools/removed-connector-tool.js +1 -1
  191. package/dist/session/tool/tools/scrape-webpage-tool.js +1 -1
  192. package/dist/session/tool/tools/session-get-tool.js +3 -3
  193. package/dist/session/tool/tools/session-list-background-tool.js +1 -1
  194. package/dist/session/tool/tools/session-read-tool.js +1 -1
  195. package/dist/session/tool/tools/session-search-tool.js +1 -1
  196. package/dist/session/tool/tools/session-spawn-tool.js +1 -1
  197. package/dist/session/tool/tools/skill-tool.js +1 -1
  198. package/dist/session/tool/tools/todo-write-tool.js +1 -1
  199. package/dist/session/tool/tools/web-fetch-tool.js +1 -1
  200. package/dist/session/tool/tools/write-tool.js +1 -1
  201. package/dist/session/turn/activity-file-chips.js +7 -3
  202. package/dist/session/turn/activity-step.js +1 -1
  203. package/dist/session/turn/burst-summary-trigger.js +3 -3
  204. package/dist/session/turn/chain-step-trigger.js +1 -1
  205. package/dist/session/turn/plan-card.js +1 -1
  206. package/dist/session/turn/thought-chain-step.js +1 -1
  207. package/dist/session/turn/turn-work-accordion.js +1 -1
  208. package/dist/session/turn/user-message.js +13 -6
  209. package/dist/session/voice/use-call-card-position.d.ts +30 -0
  210. package/dist/session/voice/use-call-card-position.js +126 -0
  211. package/dist/session/voice/voice-call-card.js +10 -3
  212. package/dist/styles/theme.css +12 -0
  213. package/dist/styles/tokens.css +12 -6
  214. package/dist/styles.css +1 -1
  215. package/dist/terminal/session-terminal-panel.js +1 -1
  216. package/dist/test-utils/intl.d.ts +133 -8
  217. package/dist/workspace/admin/project-admin-dashboard.js +7 -24
  218. package/dist/workspace/calendar/calendar-page.js +1 -1
  219. package/dist/workspace/home/first-chat.d.ts +4 -3
  220. package/dist/workspace/home/first-chat.js +6 -6
  221. package/dist/workspace/home/welcome-body.js +2 -2
  222. package/dist/workspace/index.d.ts +1 -1
  223. package/dist/workspace/index.js +1 -1
  224. package/dist/workspace/layout/project-home.js +11 -4
  225. package/dist/workspace/layout/use-project-home-send.d.ts +3 -1
  226. package/dist/workspace/layout/use-project-home-send.js +6 -2
  227. package/dist/workspace/memory/company-memory-page.js +2 -4
  228. package/dist/workspace/new/github-source.js +0 -1
  229. package/dist/workspace/new/new-workspace-form.d.ts +0 -1
  230. package/dist/workspace/new/new-workspace-form.js +0 -3
  231. package/dist/workspace/new/use-create-workspace.d.ts +1 -1
  232. package/dist/workspace/new/use-create-workspace.js +1 -2
  233. package/dist/workspace/session-spaces/space-detail-page.d.ts +35 -0
  234. package/dist/workspace/session-spaces/space-detail-page.js +307 -0
  235. package/dist/workspace/session-spaces/space-form-modal.d.ts +16 -0
  236. package/dist/workspace/session-spaces/space-form-modal.js +92 -0
  237. package/dist/workspace/session-spaces/space-icon.d.ts +36 -0
  238. package/dist/workspace/session-spaces/space-icon.js +52 -0
  239. package/dist/workspace/session-spaces/space-people.d.ts +51 -0
  240. package/dist/workspace/session-spaces/space-people.js +91 -0
  241. package/dist/workspace/session-spaces/space-picker.d.ts +11 -0
  242. package/dist/workspace/session-spaces/space-picker.js +42 -0
  243. package/dist/workspace/session-spaces/space-share-modal.d.ts +14 -0
  244. package/dist/workspace/session-spaces/space-share-modal.js +93 -0
  245. package/dist/workspace/session-spaces/spaces-page.d.ts +8 -0
  246. package/dist/workspace/session-spaces/spaces-page.js +125 -0
  247. package/dist/workspace/sessions/session-owner-filters.d.ts +2 -0
  248. package/dist/workspace/sessions/session-owner-filters.js +2 -0
  249. package/dist/workspace/setup/setup-banner.d.ts +4 -0
  250. package/dist/workspace/setup/setup-banner.js +57 -0
  251. package/dist/workspace/setup/setup-steps.d.ts +14 -0
  252. package/dist/workspace/setup/setup-steps.js +15 -0
  253. package/dist/workspace/setup/use-setup-steps.d.ts +18 -0
  254. package/dist/workspace/setup/use-setup-steps.js +57 -0
  255. package/dist/workspace/setup/workspace-setup-page.js +8 -41
  256. package/dist/workspace/sidebar/footer/project-artifacts-nav.js +1 -1
  257. package/dist/workspace/sidebar/footer/project-promo-cards.d.ts +7 -2
  258. package/dist/workspace/sidebar/footer/project-promo-cards.js +4 -3
  259. package/dist/workspace/sidebar/footer/project-sandbox-alert.js +1 -1
  260. package/dist/workspace/sidebar/footer/promo-card.d.ts +10 -1
  261. package/dist/workspace/sidebar/footer/promo-card.js +31 -2
  262. package/dist/workspace/sidebar/footer/sandbox-health.js +1 -1
  263. package/dist/workspace/sidebar/modal/session-people-picker.d.ts +13 -0
  264. package/dist/workspace/sidebar/modal/session-people-picker.js +72 -0
  265. package/dist/workspace/sidebar/modal/share-session-modal.js +2 -1
  266. package/dist/workspace/sidebar/project-nav-items.d.ts +1 -3
  267. package/dist/workspace/sidebar/project-nav-items.js +3 -8
  268. package/dist/workspace/sidebar/project-session-list.js +19 -12
  269. package/dist/workspace/sidebar/project-sidebar.js +13 -13
  270. package/dist/workspace/sidebar/project-spaces-nav.js +1 -2
  271. package/dist/workspace/sidebar/session-filter-menu.js +19 -13
  272. package/dist/workspace/sidebar/session-group-sections.d.ts +12 -12
  273. package/dist/workspace/sidebar/session-group-sections.js +56 -75
  274. package/dist/workspace/sidebar/sidebar-more-group.js +1 -1
  275. package/dist/workspace/sidebar/workspace-settings-sidebar-nav.js +2 -2
  276. package/dist/workspace/spaces/space-tabs.d.ts +26 -6
  277. package/dist/workspace/spaces/space-tabs.js +19 -8
  278. package/package.json +27 -31
  279. package/skills/kortix-ui/references/modules.md +2 -2
  280. package/dist/workspace/new/clone-param.d.ts +0 -11
  281. package/dist/workspace/new/clone-param.js +0 -15
  282. package/dist/workspace/new/provision-new-workspace.d.ts +0 -14
  283. package/dist/workspace/new/provision-new-workspace.js +0 -14
  284. package/dist/workspace/sidebar/footer/project-inbox-nav.d.ts +0 -8
  285. 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 (_jsxs("div", { className: "kortix-composer-toolbar flex items-center justify-between gap-1 overflow-visible", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-1 overflow-visible", children: [leading, showModel && (_jsx(ModelSelector, { models: models, modelsLoading: modelsLoading, selectedModel: selectedModel, onSelect: onModelChange, providers: providers, defaultControls: modelDefaultControls, triggerLabelClassName: "max-w-[7rem]", projectId: projectId, offerProviderAccounts: true, open: pickerOpen, onOpenChange: onPickerOpenChange, reasoning: { variants, selectedVariant, onVariantChange } })), !showModel && !noModel && modelPickerEnabled && !pickersInChatInput && _jsx(ReasoningEffortSelector, { variants: variants, selectedVariant: selectedVariant, onVariantChange: onVariantChange, open: reasoningMenuOpen, onOpenChange: onReasoningMenuOpenChange })] }), _jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [rewind && (_jsxs(HoverCard, { openDelay: 0, closeDelay: 0, children: [_jsx(HoverCardTrigger, { asChild: true, children: _jsx("span", { className: "inline-flex", children: _jsxs(Button, { type: "button", variant: "ghost", size: "sm", disabled: rewind.pending || rewind.disabled, onClick: rewind.onRestore, className: "text-muted-foreground hover:text-foreground gap-1.5", children: [rewind.pending ? (_jsx(Loading, { className: "size-3.5 shrink-0" })) : (_jsx(ArrowCounterClockwiseIcon, { className: "size-3.5 shrink-0" })), tI18nComplete.raw('texta76e13b98392')] }) }) }), _jsx(HoverCardContent, { className: "px-3 py-2 text-sm text-balance", children: rewind.disabled && !rewind.pending
26
+ 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 { agentDisplayName, newPastedContentId, splitPastedContent, trimPastedText } from '../../_vendor/kortix-shared.js';
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: handleEditorDocChange,
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', parentClassName), children: [_jsx(ComposerAboveCard, { ...props, ...aboveProps }), _jsx(ComposerCard, { ...props, ...cardProps })] }));
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);
@@ -10,6 +10,7 @@ import type { AttachedFile } from '../types.js';
10
10
  */
11
11
  export type StoredUpload = PromptAttachment & {
12
12
  isImage: boolean;
13
+ drivePath?: string;
13
14
  };
14
15
  /**
15
16
  * What a persisted composer draft is keyed by.
@@ -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 { attachment_id, filename, mime, size, expires_at, isImage: isImage === true };
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: { attachment_id, filename, mime, size, expires_at, isImage: file.isImage },
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 handleDocChange = useCallback((doc, isEmpty) => {
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
- handleDocChange(doc, editor.isEmpty());
128
- }, [quotes, pastes, uploads, uploadsKey, editorReady, editorRef, handleDocChange]);
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
- return { handleDocChange, clearSavedDraft };
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
+ }