@jini-ai/chat 0.7.1 → 0.7.3-next.1

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 (198) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/README.md +3 -3
  3. package/dist/contracts/chat-bubble-style.d.ts +1 -1
  4. package/dist/contracts/chat-bubble-style.js +1 -1
  5. package/dist/core/ag-ui/event-projection.d.ts +125 -0
  6. package/dist/core/ag-ui/event-projection.js +275 -0
  7. package/dist/core/ag-ui/event-reduction.d.ts +39 -0
  8. package/dist/core/ag-ui/event-reduction.js +99 -0
  9. package/dist/core/ag-ui/run-input.d.ts +53 -0
  10. package/dist/core/ag-ui/run-input.js +87 -0
  11. package/dist/core/agentic/chat-capabilities.d.ts +1 -1
  12. package/dist/core/agentic/index.d.ts +2 -4
  13. package/dist/core/agentic/index.js +2 -3
  14. package/dist/core/agents-port.d.ts +50 -0
  15. package/dist/core/agents-port.js +2 -0
  16. package/dist/core/assistant-client/ag-ui-fetch-agent.d.ts +16 -0
  17. package/dist/core/assistant-client/ag-ui-fetch-agent.js +24 -0
  18. package/dist/core/assistant-client/ag-ui-transport.d.ts +15 -1
  19. package/dist/core/assistant-client/ag-ui-transport.js +167 -145
  20. package/dist/core/assistant-client/attachment-liveness.js +13 -11
  21. package/dist/core/assistant-client/durable-run-subscription.d.ts +3 -2
  22. package/dist/core/assistant-client/durable-run-subscription.js +6 -5
  23. package/dist/core/assistant-client/messages.d.ts +7 -4
  24. package/dist/core/assistant-client/messages.js +5 -4
  25. package/dist/core/assistant-client/transport.d.ts +1 -1
  26. package/dist/core/assistant-client/transport.js +4 -4
  27. package/dist/core/index.d.ts +2 -0
  28. package/dist/core/index.js +1 -0
  29. package/dist/core/page-port.d.ts +15 -0
  30. package/dist/core/page-port.js +2 -0
  31. package/dist/core/run-activity.js +1 -1
  32. package/dist/core/run-events/entry.js +1 -0
  33. package/dist/core/user-text-redaction.d.ts +1 -3
  34. package/dist/core/user-text-redaction.js +3 -61
  35. package/dist/embed-widget/browser/agent-inventory.d.ts +37 -0
  36. package/dist/embed-widget/browser/agent-inventory.js +36 -0
  37. package/dist/embed-widget/browser/frontend-session-bridge.d.ts +2 -2
  38. package/dist/embed-widget/browser/frontend-session-bridge.js +17 -14
  39. package/dist/embed-widget/react/dialog.hooks.d.ts +16 -0
  40. package/dist/embed-widget/react/dialog.hooks.js +15 -0
  41. package/dist/embed-widget/react/embed.d.ts +7 -2
  42. package/dist/embed-widget/react/embed.js +6 -16
  43. package/dist/embed-widget/react/header.d.ts +4 -1
  44. package/dist/embed-widget/react/header.js +2 -2
  45. package/dist/embed-widget/vanilla/state.js +2 -2
  46. package/dist/embed-widget/vanilla/style.css +4 -4
  47. package/dist/react/components/A2uiSurfaceCard.d.ts +18 -4
  48. package/dist/react/components/A2uiSurfaceCard.hooks.d.ts +36 -0
  49. package/dist/react/components/A2uiSurfaceCard.hooks.js +174 -0
  50. package/dist/react/components/A2uiSurfaceCard.js +14 -227
  51. package/dist/react/components/A2uiSurfaceCard.rules.d.ts +14 -0
  52. package/dist/react/components/A2uiSurfaceCard.rules.js +24 -0
  53. package/dist/react/components/AttachmentPreviewModal.d.ts +21 -1
  54. package/dist/react/components/AttachmentPreviewModal.hooks.js +1 -3
  55. package/dist/react/components/AttachmentPreviewModal.js +11 -9
  56. package/dist/react/components/AttachmentTray.d.ts +11 -1
  57. package/dist/react/components/AttachmentTray.js +12 -8
  58. package/dist/react/components/ChatFab.d.ts +10 -1
  59. package/dist/react/components/ChatFab.js +2 -2
  60. package/dist/react/components/ChatSettingsDialog.d.ts +4 -3
  61. package/dist/react/components/ChatSettingsDialog.js +9 -6
  62. package/dist/react/components/ChatSettingsSegmented.d.ts +1 -1
  63. package/dist/react/components/ChatSettingsSegmented.js +1 -1
  64. package/dist/react/components/Composer.d.ts +9 -1
  65. package/dist/react/components/Composer.hooks.d.ts +79 -0
  66. package/dist/react/components/Composer.hooks.js +336 -0
  67. package/dist/react/components/Composer.js +40 -341
  68. package/dist/react/components/ComposerDiscovery.js +1 -1
  69. package/dist/react/components/ConversationList.d.ts +34 -1
  70. package/dist/react/components/ConversationList.hooks.d.ts +37 -0
  71. package/dist/react/components/ConversationList.hooks.js +177 -1
  72. package/dist/react/components/ConversationList.js +7 -174
  73. package/dist/react/components/ConversationTitleEditor.d.ts +17 -2
  74. package/dist/react/components/ConversationTitleEditor.hooks.d.ts +15 -0
  75. package/dist/react/components/ConversationTitleEditor.hooks.js +36 -0
  76. package/dist/react/components/ConversationTitleEditor.js +11 -34
  77. package/dist/react/components/CopyMessageButton.d.ts +6 -1
  78. package/dist/react/components/CopyMessageButton.js +4 -4
  79. package/dist/react/components/ExtEventErrorBoundary.d.ts +2 -0
  80. package/dist/react/components/ExtEventErrorBoundary.js +5 -3
  81. package/dist/react/components/FolderChips.d.ts +11 -1
  82. package/dist/react/components/FolderChips.hooks.d.ts +12 -0
  83. package/dist/react/components/FolderChips.hooks.js +10 -0
  84. package/dist/react/components/FolderChips.js +9 -9
  85. package/dist/react/components/Markdown.js +7 -5
  86. package/dist/react/components/McpUiSurfaceCard.d.ts +29 -5
  87. package/dist/react/components/McpUiSurfaceCard.js +29 -16
  88. package/dist/react/components/MessageList.d.ts +10 -1
  89. package/dist/react/components/MessageList.hooks.js +4 -2
  90. package/dist/react/components/MessageList.js +12 -8
  91. package/dist/react/components/MessageRow.d.ts +46 -2
  92. package/dist/react/components/MessageRow.hooks.d.ts +60 -0
  93. package/dist/react/components/MessageRow.hooks.js +94 -0
  94. package/dist/react/components/MessageRow.js +53 -113
  95. package/dist/react/components/MidRunUserMessage.d.ts +6 -1
  96. package/dist/react/components/MidRunUserMessage.js +5 -5
  97. package/dist/react/components/NextStepActions.d.ts +3 -1
  98. package/dist/react/components/NextStepActions.js +3 -3
  99. package/dist/react/components/QuestionForm.answers.hooks.d.ts +26 -0
  100. package/dist/react/components/QuestionForm.answers.hooks.js +89 -0
  101. package/dist/react/components/QuestionForm.d.ts +6 -0
  102. package/dist/react/components/QuestionForm.js +23 -261
  103. package/dist/react/components/QuestionForm.values.d.ts +22 -0
  104. package/dist/react/components/QuestionForm.values.js +58 -0
  105. package/dist/react/components/QuestionFormField.d.ts +17 -0
  106. package/dist/react/components/QuestionFormField.js +114 -0
  107. package/dist/react/components/QuestionsPanel.d.ts +3 -1
  108. package/dist/react/components/QuestionsPanel.js +7 -3
  109. package/dist/react/components/SentAttachment.d.ts +11 -2
  110. package/dist/react/components/SentAttachment.hooks.d.ts +1 -1
  111. package/dist/react/components/SentAttachment.hooks.js +6 -5
  112. package/dist/react/components/SentAttachment.js +5 -3
  113. package/dist/react/components/TodoCard.d.ts +3 -1
  114. package/dist/react/components/TodoCard.js +9 -4
  115. package/dist/react/components/ToolCallGroup.d.ts +11 -1
  116. package/dist/react/components/ToolCallGroup.js +10 -4
  117. package/dist/react/components/ToolCard.d.ts +6 -1
  118. package/dist/react/components/ToolCard.js +79 -69
  119. package/dist/react/components/mcp-ui-question-input.d.ts +1 -1
  120. package/dist/react/components/mcp-ui-question-input.js +3 -3
  121. package/dist/react/components/mcp-ui-surface-state.d.ts +1 -1
  122. package/dist/react/features/chat-pane/agent-tools.d.ts +1 -1
  123. package/dist/react/features/chat-pane/antigravity/model-options.d.ts +2 -0
  124. package/dist/react/features/chat-pane/antigravity/model-options.js +2 -0
  125. package/dist/react/features/chat-pane/claude/model-options.d.ts +2 -0
  126. package/dist/react/features/chat-pane/claude/model-options.js +2 -0
  127. package/dist/react/features/chat-pane/codex/model-options.d.ts +2 -0
  128. package/dist/react/features/chat-pane/codex/model-options.js +2 -0
  129. package/dist/react/features/chat-pane/components/AgentPluginUsage.d.ts +4 -1
  130. package/dist/react/features/chat-pane/components/AgentPluginUsage.js +2 -2
  131. package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +10 -6
  132. package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +18 -132
  133. package/dist/react/features/chat-pane/components/ChatPane.d.ts +24 -2
  134. package/dist/react/features/chat-pane/components/ChatPane.js +45 -297
  135. package/dist/react/features/chat-pane/components/ChatPaneComposerArea.d.ts +33 -0
  136. package/dist/react/features/chat-pane/components/ChatPaneComposerArea.js +119 -0
  137. package/dist/react/features/chat-pane/components/ChatPaneLayout.d.ts +42 -0
  138. package/dist/react/features/chat-pane/components/ChatPaneLayout.js +54 -0
  139. package/dist/react/features/chat-pane/components/ChatPaneStatus.d.ts +27 -0
  140. package/dist/react/features/chat-pane/components/ChatPaneStatus.js +91 -0
  141. package/dist/react/features/chat-pane/components/RuntimeDropUp.d.ts +6 -1
  142. package/dist/react/features/chat-pane/components/RuntimeDropUp.js +20 -19
  143. package/dist/react/features/chat-pane/components/RuntimePickerSections.d.ts +62 -0
  144. package/dist/react/features/chat-pane/components/RuntimePickerSections.js +122 -0
  145. package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.d.ts +1 -1
  146. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +5 -3
  147. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +78 -26
  148. package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.js +6 -6
  149. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.d.ts +5 -1
  150. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.js +7 -7
  151. package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.d.ts +7 -0
  152. package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.js +5 -0
  153. package/dist/react/features/chat-pane/model-options.js +7 -4
  154. package/dist/react/features/chat-pane/styles.d.ts +1 -1
  155. package/dist/react/features/chat-pane/styles.js +14 -14
  156. package/dist/react/features/chat-pane/types.d.ts +29 -1
  157. package/dist/react/hooks/assistant-chats-contracts.d.ts +1 -1
  158. package/dist/react/hooks/attachment-preview-cache.d.ts +1 -1
  159. package/dist/react/hooks/attachment-preview-cache.js +1 -1
  160. package/dist/react/hooks/fab-position.js +16 -18
  161. package/dist/react/hooks/useConversation.d.ts +6 -1
  162. package/dist/react/hooks/useConversation.js +11 -10
  163. package/dist/react/hooks/useRunStream.d.ts +3 -0
  164. package/dist/react/hooks/useRunStream.js +12 -12
  165. package/dist/react/hooks/useSurfaceRecovery.d.ts +1 -1
  166. package/dist/react/hooks/useSurfaceRecovery.js +2 -2
  167. package/dist/react/index.d.ts +6 -3
  168. package/dist/react/index.js +5 -3
  169. package/dist/react/styles/chat-settings.css +9 -9
  170. package/dist/react/surfaces.d.ts +91 -0
  171. package/dist/react/surfaces.js +28 -0
  172. package/dist/server/durable-runs/recover.d.ts +4 -3
  173. package/dist/server/durable-runs/recover.js +4 -3
  174. package/dist/store/legacy/sqlite/conversations.d.ts +1 -2
  175. package/dist/store/legacy/sqlite/conversations.js +1 -1
  176. package/dist/store/legacy/sqlite/messages.d.ts +2 -3
  177. package/dist/store/legacy/sqlite/messages.js +6 -6
  178. package/dist/store/pglite/index.d.ts +7 -7
  179. package/dist/store/pglite/index.js +1 -1
  180. package/dist/store/ports.d.ts +5 -2
  181. package/dist/store/postgres/index.d.ts +7 -7
  182. package/dist/store/postgres/index.js +1 -1
  183. package/dist/store/runtime/chat-expiry-sweep.js +2 -4
  184. package/dist/store/runtime/chat-history-store.js +2 -3
  185. package/dist/store/runtime/durable-run-store.js +16 -2
  186. package/dist/store/runtime/history-tools.js +33 -11
  187. package/dist/store/runtime/kernel.d.ts +3 -2
  188. package/dist/store/runtime/run-ledger.js +2 -2
  189. package/dist/store/sql/boundary.d.ts +5 -5
  190. package/dist/store/sql/maintenance.d.ts +3 -2
  191. package/dist/store/sql/store.d.ts +16 -8
  192. package/dist/store/sql/store.js +31 -14
  193. package/dist/store/sqlite/index.d.ts +11 -12
  194. package/dist/store/sqlite/index.js +5 -5
  195. package/dist/store/sqlite/schema.d.ts +1 -1
  196. package/package.json +46 -24
  197. package/dist/core/ag-ui/entry.d.ts +0 -84
  198. package/dist/core/ag-ui/entry.js +0 -225
@@ -1,5 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { formatErrorForLog } from '@jini-ai/core';
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
2
  /**
4
3
  * @module Composer
5
4
  *
@@ -14,350 +13,43 @@ import { formatErrorForLog } from '@jini-ai/core';
14
13
  * picker" or "session mode" is.
15
14
  */
16
15
  import { FolderChips } from './FolderChips.js';
17
- import { useEffect, useLayoutEffect, useRef, useState, } from 'react';
16
+ import {} from 'react';
18
17
  import { RemixIcon, useAgentHandle } from '@jini-ai/ui';
19
- import { agentHandleProps, agentHandleSegment } from '@jini-ai/agentic';
18
+ import { agentHandleProps, agentHandleSegment } from '@jini-ai/core/agent-handles';
20
19
  import { useT } from '../hooks/context.js';
21
- import { useComposerHistoryKeys } from '../hooks/useComposerHistoryKeys.hooks.js';
22
20
  import { AttachmentTray } from './AttachmentTray.js';
23
21
  import { ComposerDiscoveryMenu, ComposerSlashMenu } from './ComposerDiscovery.js';
24
- import { appendComposerDiscovery, composerDiscoveryMenuPosition, composerSlashMenuPosition, filterComposerDiscovery, parseComposerSlashQuery, replaceComposerSlashTrigger, resolveComposerSlashInvocation, resolveComposerSlashKeyAction, } from './composer-discovery.js';
25
- function reportComposerHostEffectFailure(effectName, error) {
26
- console.error(`[@jini-ai/chat] Composer ${effectName} host effect failed:`, formatErrorForLog({ error }));
27
- }
28
- /**
29
- * Invokes host code synchronously, then observes either its synchronous result or async failure.
30
- *
31
- * @param onResolved - Optional, called with the host's resolved (non-thrown/non-rejected) return
32
- * value — never called after a synchronous throw or an async rejection. Added for
33
- * `onDiscoverySelect`, whose {@link ComposerDiscoveryOutcome} return value the caller applies to
34
- * the draft; the two other host effects this function backs (`plusMenuItems.onSelect`,
35
- * `attachmentPicker.onFiles`) simply omit it, which reproduces their exact prior behavior.
36
- */
37
- function runComposerHostEffect(effectName, effect, onSettled, onResolved) {
38
- let result;
39
- try {
40
- result = effect();
41
- }
42
- catch (error) {
43
- reportComposerHostEffectFailure(effectName, error);
44
- onSettled?.();
45
- return;
46
- }
47
- const asynchronous = result !== undefined;
48
- if (!asynchronous) {
49
- onResolved?.(result);
50
- onSettled?.();
51
- }
52
- void Promise.resolve(result)
53
- .then((resolved) => {
54
- if (asynchronous)
55
- onResolved?.(resolved);
56
- })
57
- .catch((error) => {
58
- reportComposerHostEffectFailure(effectName, error);
59
- })
60
- .finally(() => {
61
- if (asynchronous)
62
- onSettled?.();
63
- });
64
- }
22
+ import { runComposerHostEffect, useComposerView } from './Composer.hooks.js';
65
23
  /**
66
24
  * Renders the controlled message composer and optional attachment picker.
67
25
  *
68
26
  * @complexity Time/space: O(n) in rendered attachments and supplied menu items.
69
27
  * @overallScore 100/100
70
28
  */
71
- export function Composer({ agentHandle, composer, onSend, disabled = false, sendDisabled = false, sendDisabledReason, sendDisabledReasonId, placeholder, slots, attachmentPicker, running = false, onCancel, onInterrupt, workingDirectory, onChangeWorkingDirectory, onPickWorkingDirectory, }) {
72
- const base = useAgentHandle({ agentHandle });
73
- const t = useT();
74
- const attachmentInputRef = useRef(null);
75
- const textareaRef = useRef(null);
76
- const discoveryEffectInFlightRef = useRef(false);
77
- /**
78
- * Mirrors `composer.draft` for the ONE place it must be read outside a render: inside
79
- * `notifyDiscovery`'s `onResolved` callback, which can fire after arbitrarily many re-renders
80
- * (nothing here disables the textarea while a host effect is in flight, so the user is free to
81
- * keep typing). Reassigned every render rather than via an effect — an effect would lag one
82
- * render behind the value it needs to be compared against at the exact moment the outcome
83
- * settles.
84
- */
85
- const draftRef = useRef(composer.draft);
86
- draftRef.current = composer.draft;
87
- const [discoveryMenuOpen, setDiscoveryMenuOpen] = useState(false);
88
- const [slashActiveIndex, setSlashActiveIndex] = useState(0);
89
- const [dismissedSlashDraft, setDismissedSlashDraft] = useState(null);
90
- const [discoveryMenuPosition, setDiscoveryMenuPosition] = useState();
91
- const [slashMenuPosition, setSlashMenuPosition] = useState();
92
- const [workdirOpen, setWorkdirOpen] = useState(false);
93
- const [workdirDraft, setWorkdirDraft] = useState('');
94
- const [workdirPosition, setWorkdirPosition] = useState();
95
- const { discoveryGroups = [], leadingAccessories, footerLeadingAccessory, footerAccessories, plusMenuItems } = slots ?? {};
96
- const hasDiscoveryItems = discoveryGroups.some((group) => group.items.length > 0);
97
- const slash = slashPalette({ draft: composer.draft, groups: discoveryGroups, dismissedSlashDraft });
98
- const slashOpen = slash.open;
99
- const slashActiveOption = Math.min(slashActiveIndex, slash.matches.length - 1);
100
- const popovers = { discoveryMenuOpen, slashOpen, workdirOpen };
101
- const handleHistoryKey = useComposerHistoryKeys({ composer, textareaRef }, {
102
- popupOpen: anyPopoverOpen(popovers) || composer.mention.open,
103
- });
104
- function restoreComposerFocus() {
105
- textareaRef.current?.focus();
106
- }
107
- /**
108
- * Neither popover had any way to dismiss on an outside click — Escape worked (each already wires
109
- * its own keydown), but clicking away left them open with no affordance to close (bug report:
110
- * "no click-outside, owner is stuck once it opens"). `mousedown`, not `click`, so this settles
111
- * before the "+" trigger button's own `onToggle` fires on the SAME click — that click's target is
112
- * inside `.jini-composer-discovery` (the trigger lives there too), so it's correctly treated as
113
- * "inside" and left for `onToggle` to handle, not fought over by two competing handlers.
114
- *
115
- * Scoped by DOM lookup (`closest`/`querySelector`) off `textareaRef`, not new refs threaded
116
- * through `ComposerDiscovery.tsx`'s props — both popovers already carry stable classes/ids this
117
- * component doesn't otherwise need direct handles to.
118
- */
119
- useEffect(() => {
120
- if (!anyPopoverOpen(popovers))
121
- return undefined;
122
- const textarea = textareaRef.current;
123
- const composerRoot = textarea?.closest('.jini-composer');
124
- if (!composerRoot)
125
- return undefined;
126
- function handleOutsideMouseDown(event) {
127
- const target = event.target;
128
- if (!target)
129
- return;
130
- if (discoveryMenuOpen && isOutside(composerRoot, '.jini-composer-discovery', target))
131
- setDiscoveryMenuOpen(false);
132
- if (slashOpen && !textarea.contains(target) && isOutside(composerRoot, '#jini-composer-slash-menu', target))
133
- setDismissedSlashDraft(composer.draft);
134
- if (workdirOpen && isOutside(composerRoot, '.jini-composer-workdir', target))
135
- setWorkdirOpen(false);
136
- }
137
- document.addEventListener('mousedown', handleOutsideMouseDown);
138
- return () => document.removeEventListener('mousedown', handleOutsideMouseDown);
139
- }, [discoveryMenuOpen, slashOpen, workdirOpen, composer.draft]);
140
- /**
141
- * Anchors the "+" menu and slash palette to `.jini-composer`'s live on-screen rect via
142
- * `position: fixed` (see `composerDiscoveryMenuPosition`/`composerSlashMenuPosition`'s own doc
143
- * in `composer-discovery.ts` for the ancestor-clipping bug this fixes). `useLayoutEffect`, not
144
- * `useEffect`, so the measured position lands before the browser paints the just-opened popover
145
- * — otherwise the very first frame would flash at the CSS default (`position: absolute`)
146
- * position before snapping to the fixed one. Recomputed on scroll/resize while either popover is
147
- * open, matching `useAgentRuntimePicker.hooks.ts`'s identical popover-tracking idiom: the
148
- * composer's on-screen position can change under an open popover without it ever unmounting.
149
- */
150
- useLayoutEffect(() => {
151
- if (!anyPopoverOpen(popovers))
152
- return undefined;
153
- const composerRoot = textareaRef.current?.closest('.jini-composer');
154
- if (!composerRoot)
155
- return undefined;
156
- function update() {
157
- const rect = composerRoot.getBoundingClientRect();
158
- if (discoveryMenuOpen)
159
- setDiscoveryMenuPosition(composerDiscoveryMenuPosition({ composerRect: rect }));
160
- if (slashOpen)
161
- setSlashMenuPosition(composerSlashMenuPosition({ composerRect: rect }));
162
- // Shares the discovery menu's own anchor math (same left inset off `.jini-composer`) rather
163
- // than measuring the working-dir button's own rect — one less measurement to keep in sync,
164
- // and the two popovers already never open at once (each is gated on its own trigger).
165
- if (workdirOpen)
166
- setWorkdirPosition(composerDiscoveryMenuPosition({ composerRect: rect }));
167
- }
168
- update();
169
- window.addEventListener('scroll', update, true);
170
- window.addEventListener('resize', update);
171
- return () => {
172
- window.removeEventListener('scroll', update, true);
173
- window.removeEventListener('resize', update);
174
- };
175
- }, [discoveryMenuOpen, slashOpen, workdirOpen]);
176
- /**
177
- * `expectedDraft` is the draft as the user last saw it at the moment of selection — what the
178
- * host's effect was computed against. `argument` is passed only for a resolved `'invoke'` on a
179
- * `command`-bearing item (see `resolveComposerSlashInvocation`); omitted entirely for a plain
180
- * macro item, matching `ComposerDiscoverySelection.argument`'s own "absent means no command
181
- * grammar" contract.
182
- *
183
- * A `ComposerDiscoveryOutcome` the host returns replaces the draft — this is how a command whose
184
- * effect is computed asynchronously (e.g. composing agent-directed instruction text) gets to
185
- * write its result back, since nothing here can guess it in advance the way a plain item's own
186
- * `insertText` can. But nothing disables the textarea while that effect is in flight, so the
187
- * live draft (`draftRef.current`) may have moved on by the time it resolves. The outcome is
188
- * applied only if the live draft still matches `expectedDraft` exactly; otherwise it is
189
- * DISCARDED — silently overwriting keystrokes the user typed in the meantime would be worse than
190
- * dropping a result they can reselect.
191
- */
192
- function notifyDiscovery(item, source, expectedDraft, argument) {
193
- const onDiscoverySelect = slots?.onDiscoverySelect;
194
- if (!onDiscoverySelect || discoveryEffectInFlightRef.current)
195
- return;
196
- discoveryEffectInFlightRef.current = true;
197
- runComposerHostEffect('onDiscoverySelect', () => onDiscoverySelect({ item, source, ...(argument !== undefined ? { argument } : {}) }), () => {
198
- discoveryEffectInFlightRef.current = false;
199
- }, (outcome) => {
200
- if (!outcome || typeof outcome !== 'object')
201
- return;
202
- const draft = outcome.draft;
203
- if (draft === undefined)
204
- return;
205
- if (draftRef.current !== expectedDraft)
206
- return;
207
- composer.setDraft(draft);
208
- });
209
- }
210
- function selectSlashItem(item) {
211
- const resolution = resolveComposerSlashInvocation({ draft: composer.draft, item });
212
- if (!resolution)
213
- return;
214
- if (resolution.type === 'complete') {
215
- // The command word is ambiguous or its argument is still missing — finish the trigger and
216
- // keep the palette open for further typing. No host effect fires: nothing was invoked yet.
217
- composer.setDraft(resolution.draft);
218
- setDismissedSlashDraft(null);
219
- restoreComposerFocus();
220
- return;
221
- }
222
- let expectedDraft = composer.draft;
223
- if (!item.command) {
224
- expectedDraft = replaceComposerSlashTrigger({ draft: composer.draft, insertText: item.insertText ?? item.label });
225
- composer.setDraft(expectedDraft);
226
- }
227
- setDismissedSlashDraft(null);
228
- notifyDiscovery(item, 'slash', expectedDraft, resolution.argument);
229
- restoreComposerFocus();
230
- }
231
- function selectPlusItem(item) {
232
- const expectedDraft = item.insertText ? appendComposerDiscovery({ draft: composer.draft, insertText: item.insertText }) : composer.draft;
233
- if (item.insertText)
234
- composer.setDraft(expectedDraft);
235
- setDiscoveryMenuOpen(false);
236
- notifyDiscovery(item, 'plus', expectedDraft);
237
- restoreComposerFocus();
238
- }
239
- /** Opens the working-directory popover, seeding its draft from the live value so a reopen never
240
- * shows a stale edit from a previously-dismissed attempt. */
241
- function toggleWorkdir() {
242
- if (!workdirOpen)
243
- setWorkdirDraft(workingDirectory ?? '');
244
- setWorkdirOpen((open) => !open);
245
- }
246
- /** Confirms the popover's draft. Blank input is treated as "no change" (closes without calling
247
- * the host) rather than clearing the directory — this lightweight control has no clear
248
- * affordance of its own; `onChangeWorkingDirectory`'s own doc points to the native picker
249
- * (`ChatPaneWorkingDirectoryAccess`) that does support clearing. */
250
- function confirmWorkdir() {
251
- const trimmed = workdirDraft.trim();
252
- if (trimmed)
253
- onChangeWorkingDirectory?.(trimmed);
254
- setWorkdirOpen(false);
255
- }
256
- /** Palette navigation wins over history and Enter while the slash palette is open; true when it consumed the key. */
257
- function handleSlashKey(event) {
258
- if (!slashOpen)
259
- return false;
260
- const action = resolveComposerSlashKeyAction({ key: event.key, shiftKey: event.shiftKey });
261
- if (action.type === 'none')
262
- return false;
263
- event.preventDefault();
264
- if (action.type === 'move') {
265
- setSlashActiveIndex((current) => (current + action.offset + slash.matches.length) % slash.matches.length);
266
- }
267
- else if (action.type === 'select') {
268
- selectSlashItem(slash.matches[slashActiveOption].item);
269
- }
270
- else {
271
- setDismissedSlashDraft(composer.draft);
272
- }
273
- return true;
274
- }
275
- function submitFromEnter(event) {
276
- if (disabled || !composer.canSubmit)
277
- return;
278
- // Cmd/Ctrl+Enter uses the host shortcut; ChatPane routes it through the ordinary send guards.
279
- // `sendDisabled` is deliberately NOT consulted here: hosts can offer a shortcut while a run
280
- // itself blocks ordinary sends. ChatPane queues or delivers live without cancelling the run.
281
- if ((event.metaKey || event.ctrlKey) && onInterrupt) {
282
- onInterrupt();
283
- return;
284
- }
285
- if (!sendDisabled)
286
- onSend();
287
- }
288
- function handleKeyDown(event) {
289
- if (event.nativeEvent.isComposing)
290
- return;
291
- if (handleSlashKey(event))
292
- return;
293
- if (handleHistoryKey(event))
294
- return;
295
- if (event.key !== 'Enter' || event.shiftKey)
296
- return;
297
- event.preventDefault();
298
- submitFromEnter(event);
299
- }
300
- function handleAttachmentChange(event) {
301
- const files = Array.from(event.target.files ?? []);
302
- event.target.value = '';
303
- if (files.length > 0 && attachmentPicker) {
304
- runComposerHostEffect('attachmentPicker.onFiles', () => attachmentPicker.onFiles(files));
305
- }
306
- }
307
- /**
308
- * A screenshot or a Finder-copied video pasted into the textarea previously vanished with no
309
- * feedback: the browser's default paste has nothing to do with a `File` on the clipboard (it only
310
- * inserts `text/plain`, which a file-only clipboard entry never carries), so the keystroke was a
311
- * silent no-op — no chip, no `/api/attachments` call, nothing. This is the paste-side counterpart
312
- * to `handleAttachmentChange` (the file-input path) and `useChatPaneFileDrop` (the drag-and-drop
313
- * path); all three now reach `attachmentPicker.onFiles` the same way.
314
- *
315
- * `preventDefault` only when `files.length > 0` — an ordinary text paste (the overwhelmingly
316
- * common case) is left to the browser's own default handling untouched.
317
- */
318
- function handleAttachmentPaste(event) {
319
- if (!attachmentPicker)
320
- return;
321
- const files = Array.from(event.clipboardData?.files ?? []);
322
- if (files.length === 0)
323
- return;
324
- event.preventDefault();
325
- runComposerHostEffect('attachmentPicker.onFiles', () => attachmentPicker.onFiles(files));
326
- }
327
- return (_jsxs("div", { className: "jini-composer", children: [_jsx(AccessorySlot, { className: "jini-composer-leading", children: leadingAccessories }), _jsxs("div", { className: "jini-composer-attachments", children: [_jsx(AttachmentTray, { agentHandle: base, attachments: composer.attachments, onRemove: composer.removeAttachment, uploading: attachmentPicker?.uploading === true }), _jsx(FolderChips, { agentHandle: base, folders: composer.folders, onRemove: composer.removeFolder })] }), _jsx("textarea", { ...agentHandleProps({}, { base, action: 'draft', role: 'field', label: t('Message draft') }), ref: textareaRef, className: "jini-composer-input", value: composer.draft, placeholder: placeholder ?? t('Send a message…'), disabled: disabled, onChange: (e) => {
29
+ export function Composer({ useAgentHandleHook = useAgentHandle, useTHook = useT, useComposerViewHook = useComposerView, agentHandle, composer, onSend, report, disabled = false, sendDisabled = false, sendDisabledReason, sendDisabledReasonId, placeholder, slots, attachmentPicker, running = false, onCancel, onInterrupt, workingDirectory, onChangeWorkingDirectory, onPickWorkingDirectory, }) {
30
+ const base = useAgentHandleHook({ agentHandle });
31
+ const t = useTHook();
32
+ const view = useComposerViewHook({ composer, slots, attachmentPicker, workingDirectory, onChangeWorkingDirectory, disabled, sendDisabled, onInterrupt, onSend }, { report });
33
+ return (_jsxs("div", { className: "jini-composer", children: [_jsx(AccessorySlot, { className: "jini-composer-leading", children: view.leadingAccessories }), _jsx(ComposerAttachmentRow, { base: base, composer: composer, attachmentPicker: attachmentPicker }), _jsx(ComposerInput, { base: base, composer: composer, disabled: disabled, placeholder: placeholder, view: view, t: t }), _jsxs("div", { className: "jini-composer-footer", children: [_jsx(ComposerFooterLeading, { base: base, attachmentPicker: attachmentPicker, disabled: disabled, view: view, t: t, workingDirectory: workingDirectory, onChangeWorkingDirectory: onChangeWorkingDirectory, onPickWorkingDirectory: onPickWorkingDirectory }), _jsx(ComposerFooterTrailing, { base: base, view: view, t: t, composer: composer, running: running, disabled: disabled, sendDisabled: sendDisabled, onSend: onSend, onCancel: onCancel, report: report, sendDisabledReason: sendDisabledReason, sendDisabledReasonId: sendDisabledReasonId })] })] }));
34
+ }
35
+ function ComposerInput({ base, composer, disabled, placeholder, view, t }) {
36
+ const { textareaRef, setSlashActiveIndex, setDismissedSlashDraft, handleKeyDown, handleAttachmentPaste, slashOpen, slashActiveOption, slash, selectSlashItem, slashMenuPosition } = view;
37
+ return _jsxs(_Fragment, { children: [_jsx("textarea", { ...agentHandleProps({}, { base, action: 'draft', role: 'field', label: t('Message draft') }), ref: textareaRef, className: "jini-composer-input", value: composer.draft, placeholder: placeholder ?? t('Send a message…'), disabled: disabled, onChange: (e) => {
328
38
  composer.setDraft(e.target.value);
329
39
  setSlashActiveIndex(0);
330
40
  setDismissedSlashDraft(null);
331
41
  }, onKeyDown: handleKeyDown,
332
42
  // Draft persistence is debounced (see `DRAFT_PERSIST_DEBOUNCE_MS`); leaving the field is a
333
43
  // natural point to make it durable now.
334
- onBlur: () => composer.flushDraft?.(), onPaste: handleAttachmentPaste, ...slashTextareaAria(slashOpen, slashActiveOption), rows: 3 }), slashOpen ? (_jsx(ComposerSlashMenu, { base: base, matches: slash.matches, activeIndex: slashActiveOption, onSelect: selectSlashItem, showFilterHint: slash.showFilterHint, style: slashMenuPosition, t: t })) : null, _jsxs("div", { className: "jini-composer-footer", children: [_jsx(ComposerAttachButton, { base: base, attachmentPicker: attachmentPicker, hidden: hasDiscoveryItems, disabled: disabled, inputRef: attachmentInputRef, onChange: handleAttachmentChange, t: t }), _jsx(ComposerDiscoveryMenu, { base: base, groups: discoveryGroups, open: discoveryMenuOpen, disabled: disabled, ...(attachmentPicker ? { attachmentPicker } : {}), attachmentInputRef: attachmentInputRef, onToggle: () => setDiscoveryMenuOpen((open) => !open), onClose: () => setDiscoveryMenuOpen(false), onSelect: selectPlusItem, onAttachmentChange: handleAttachmentChange, style: discoveryMenuPosition, t: t }), _jsx(AccessorySlot, { className: "jini-composer-footer-leading", children: footerLeadingAccessory }), _jsx(ComposerWorkdirControl, { base: base, workingDirectory: workingDirectory, onChangeWorkingDirectory: onChangeWorkingDirectory, onPickWorkingDirectory: onPickWorkingDirectory, disabled: disabled, open: workdirOpen, draft: workdirDraft, position: workdirPosition, onToggle: toggleWorkdir, onDraftChange: setWorkdirDraft, onConfirm: confirmWorkdir, onClose: () => setWorkdirOpen(false), t: t }), _jsxs("div", { className: "jini-composer-footer-trailing", children: [_jsx(AccessorySlot, { className: "jini-composer-footer-accessories", children: footerAccessories }), _jsx(ComposerPlusMenu, { base: base, items: plusMenuItems, t: t }), _jsx(ComposerSendGroup, { base: base, running: running, disabled: disabled, sendDisabled: sendDisabled, canSubmit: composer.canSubmit, onSend: onSend, onCancel: onCancel, sendDisabledReason: sendDisabledReason, sendDisabledReasonId: sendDisabledReasonId, t: t })] })] })] }));
335
- }
336
- function anyPopoverOpen({ discoveryMenuOpen, slashOpen, workdirOpen }) {
337
- return discoveryMenuOpen || slashOpen || workdirOpen;
44
+ onBlur: () => composer.flushDraft?.(), onPaste: handleAttachmentPaste, ...slashTextareaAria(slashOpen, slashActiveOption), rows: 3 }), slashOpen ? (_jsx(ComposerSlashMenu, { base: base, matches: slash.matches, activeIndex: slashActiveOption, onSelect: selectSlashItem, showFilterHint: slash.showFilterHint, style: slashMenuPosition, t: t })) : null] });
338
45
  }
339
- /** A missing popover element counts as outside, so a stale open flag still closes. */
340
- function isOutside(composerRoot, selector, target) {
341
- return !composerRoot.querySelector(selector)?.contains(target);
46
+ function ComposerFooterLeading({ base, attachmentPicker, disabled, view, t, workingDirectory, onChangeWorkingDirectory, onPickWorkingDirectory }) {
47
+ const { hasDiscoveryItems, attachmentInputRef, handleAttachmentChange, discoveryGroups, discoveryMenuOpen, setDiscoveryMenuOpen, selectPlusItem, discoveryMenuPosition, footerLeadingAccessory, workdirOpen, workdirDraft, workdirPosition, toggleWorkdir, setWorkdirDraft, confirmWorkdir, setWorkdirOpen } = view;
48
+ return _jsxs(_Fragment, { children: [_jsx(ComposerAttachButton, { base: base, attachmentPicker: attachmentPicker, hidden: hasDiscoveryItems, disabled: disabled, inputRef: attachmentInputRef, onChange: handleAttachmentChange, t: t }), _jsx(ComposerDiscoveryMenu, { base: base, groups: discoveryGroups, open: discoveryMenuOpen, disabled: disabled, ...(attachmentPicker ? { attachmentPicker } : {}), attachmentInputRef: attachmentInputRef, onToggle: () => setDiscoveryMenuOpen((open) => !open), onClose: () => setDiscoveryMenuOpen(false), onSelect: selectPlusItem, onAttachmentChange: handleAttachmentChange, style: discoveryMenuPosition, t: t }), _jsx(AccessorySlot, { className: "jini-composer-footer-leading", children: footerLeadingAccessory }), _jsx(ComposerWorkdirControl, { base: base, workingDirectory: workingDirectory, onChangeWorkingDirectory: onChangeWorkingDirectory, onPickWorkingDirectory: onPickWorkingDirectory, disabled: disabled, open: workdirOpen, draft: workdirDraft, position: workdirPosition, onToggle: toggleWorkdir, onDraftChange: setWorkdirDraft, onConfirm: confirmWorkdir, onClose: () => setWorkdirOpen(false), t: t })] });
342
49
  }
343
- /** Slash palette state derived from the live draft. */
344
- function slashPalette({ draft, groups, dismissedSlashDraft }) {
345
- const query = parseComposerSlashQuery({ draft });
346
- const matches = query === null ? [] : filterComposerDiscovery({ groups, query });
347
- return {
348
- matches,
349
- open: matches.length > 0 && dismissedSlashDraft !== draft,
350
- /**
351
- * A bare "/" intentionally matches every item (`matchesFuzzyCommand`'s own doc) so the palette
352
- * doubles as a browse-everything view — but with nothing typed yet, nothing on screen tells a
353
- * first-time user that continuing to type narrows it, and a fuzzy substring match against full
354
- * descriptions stays broad for the first character or two regardless (owner-reported "it doesn't
355
- * narrow" — narrowing DOES fire on every keystroke, this is the one state where there's no visual
356
- * cue that it will). Shown only here, not once the user has started typing a real query — at that
357
- * point the shrinking list is its own feedback.
358
- */
359
- showFilterHint: query !== null && query.command === '' && query.argument === null,
360
- };
50
+ function ComposerFooterTrailing({ base, view, t, composer, running, disabled, sendDisabled, onSend, onCancel, sendDisabledReason, sendDisabledReasonId, report }) {
51
+ const { footerAccessories, plusMenuItems } = view;
52
+ return _jsxs(_Fragment, { children: [_jsxs("div", { className: "jini-composer-footer-trailing", children: [_jsx(AccessorySlot, { className: "jini-composer-footer-accessories", children: footerAccessories }), _jsx(ComposerPlusMenu, { base: base, items: plusMenuItems, t: t, report: report }), _jsx(ComposerSendGroup, { base: base, running: running, disabled: disabled, sendDisabled: sendDisabled, canSubmit: composer.canSubmit, onSend: onSend, onCancel: onCancel, sendDisabledReason: sendDisabledReason, sendDisabledReasonId: sendDisabledReasonId, t: t })] }), " "] });
361
53
  }
362
54
  function slashTextareaAria(slashOpen, activeOption) {
363
55
  if (!slashOpen)
@@ -367,6 +59,10 @@ function slashTextareaAria(slashOpen, activeOption) {
367
59
  function AccessorySlot({ className, children }) {
368
60
  return children ? _jsx("div", { className: className, children: children }) : null;
369
61
  }
62
+ /** The attached files and folders waiting to go with the next message. */
63
+ function ComposerAttachmentRow({ base, composer, attachmentPicker }) {
64
+ return (_jsxs("div", { className: "jini-composer-attachments", children: [_jsx(AttachmentTray, { agentHandle: base, attachments: composer.attachments, onRemove: composer.removeAttachment, uploading: attachmentPicker?.uploading === true }), _jsx(FolderChips, { agentHandle: base, folders: composer.folders, onRemove: composer.removeFolder })] }));
65
+ }
370
66
  /** The plain paperclip, shown only when there is no "+" discovery menu to carry attaching instead. */
371
67
  function ComposerAttachButton({ base, attachmentPicker, hidden, disabled, inputRef, onChange, t }) {
372
68
  if (!attachmentPicker || hidden)
@@ -380,22 +76,12 @@ function ComposerWorkdirControl({ base, workingDirectory, onChangeWorkingDirecto
380
76
  return null;
381
77
  return (_jsxs("div", { className: "jini-composer-workdir", "data-testid": "composer-workdir", children: [_jsx("button", { type: "button", className: "jini-composer-attach", ...agentHandleProps({}, { base, action: 'workdir', role: 'button', label: t('Set working directory') }), "data-testid": "composer-workdir-trigger", disabled: disabled, onClick: onPickWorkingDirectory ? () => onPickWorkingDirectory() : onToggle, ...(onPickWorkingDirectory ? {} : { 'aria-haspopup': 'dialog', 'aria-expanded': open }), title: workingDirectory ?? t('Set working directory'), "aria-label": workingDirectory
382
78
  ? t('Working directory: {dir}', { dir: workingDirectory })
383
- : t('Set working directory'), children: _jsx(RemixIcon, { name: "folder-line", size: 20 }) }), !onPickWorkingDirectory && open ? (_jsxs("div", { className: "jini-composer-workdir-panel", "data-testid": "composer-workdir-panel", role: "dialog", "aria-label": t('Working directory'), style: position, children: [_jsx("input", { type: "text", className: "jini-composer-workdir-input", ...agentHandleProps({}, { base, action: 'workdir-path', role: 'field', label: t('Working directory path') }), "data-testid": "composer-workdir-input", value: draft, onChange: (e) => onDraftChange(e.target.value), onKeyDown: (e) => {
384
- if (e.key === 'Enter') {
385
- e.preventDefault();
386
- onConfirm();
387
- return;
388
- }
389
- if (e.key === 'Escape') {
390
- e.preventDefault();
391
- onClose();
392
- }
393
- }, placeholder: t('Working directory path'), "aria-label": t('Working directory path'), autoFocus: true }), _jsx("button", { type: "button", className: "jini-composer-workdir-confirm", ...agentHandleProps({}, { base, action: 'workdir-set', role: 'button', label: t('Set working directory') }), "data-testid": "composer-workdir-confirm", onClick: onConfirm, children: t('Set') })] })) : null] }));
79
+ : t('Set working directory'), children: _jsx(RemixIcon, { name: "folder-line", size: 20 }) }), !onPickWorkingDirectory && open ? _jsx(ComposerWorkdirPopover, { base: base, draft: draft, position: position, onDraftChange: onDraftChange, onConfirm: onConfirm, onClose: onClose, t: t }) : null] }));
394
80
  }
395
- function ComposerPlusMenu({ base, items, t }) {
81
+ function ComposerPlusMenu({ base, items, t, report }) {
396
82
  if (!items || items.length === 0)
397
83
  return null;
398
- return (_jsx("div", { className: "jini-composer-plus-menu", children: items.map((item) => (_jsxs("button", { type: "button", ...agentHandleProps({}, { base, action: `extra-${agentHandleSegment({ value: item.id })}`, role: 'button', label: t(item.label) }), className: "jini-composer-plus-item", onClick: () => runComposerHostEffect('plusMenuItems.onSelect', () => item.onSelect()), title: t(item.label), children: [item.icon ?? null, _jsx("span", { children: t(item.label) })] }, item.id))) }));
84
+ return (_jsx("div", { className: "jini-composer-plus-menu", children: items.map((item) => (_jsxs("button", { type: "button", ...agentHandleProps({}, { base, action: `extra-${agentHandleSegment({ value: item.id })}`, role: 'button', label: t(item.label) }), className: "jini-composer-plus-item", onClick: () => runComposerHostEffect({ effectName: 'plusMenuItems.onSelect', effect: () => item.onSelect() }, { report }), title: t(item.label), children: [item.icon ?? null, _jsx("span", { children: t(item.label) })] }, item.id))) }));
399
85
  }
400
86
  function ComposerSendGroup({ base, running, disabled, sendDisabled, canSubmit, onSend, onCancel, sendDisabledReason, sendDisabledReasonId, t }) {
401
87
  const canSend = !disabled && !sendDisabled && canSubmit;
@@ -405,4 +91,17 @@ function ComposerSendGroup({ base, running, disabled, sendDisabled, canSubmit, o
405
91
  // the footer's space-between keeps the two together at the trailing edge.
406
92
  _jsxs("span", { className: "jini-composer-send-group", children: [!running || canSend ? (_jsx("button", { ...agentHandleProps({}, { base, action: 'send', role: 'button', label: t('Send') }), type: "button", className: "jini-composer-send", disabled: !canSend, onClick: onSend, title: sendDisabledReason ?? t('Send'), "aria-label": t('Send'), "aria-describedby": sendDisabledReasonId, children: _jsx(RemixIcon, { name: "send-plane-2-line", size: 16 }) })) : null, running ? (_jsx("button", { ...agentHandleProps({}, { base, action: 'stop', role: 'button', label: t('Stop run') }), type: "button", className: "jini-composer-send jini-composer-send--stop", onClick: onCancel, title: t('Stop run'), "aria-label": t('Stop run'), children: _jsx(RemixIcon, { name: "stop-fill", size: 14 }) })) : null] }));
407
93
  }
94
+ function ComposerWorkdirPopover({ base, draft, position, onDraftChange, onConfirm, onClose, t }) {
95
+ return (_jsxs("div", { className: "jini-composer-workdir-panel", "data-testid": "composer-workdir-panel", role: "dialog", "aria-label": t('Working directory'), style: position, children: [_jsx("input", { type: "text", className: "jini-composer-workdir-input", ...agentHandleProps({}, { base, action: 'workdir-path', role: 'field', label: t('Working directory path') }), "data-testid": "composer-workdir-input", value: draft, onChange: (e) => onDraftChange(e.target.value), onKeyDown: (e) => {
96
+ if (e.key === 'Enter') {
97
+ e.preventDefault();
98
+ onConfirm();
99
+ return;
100
+ }
101
+ if (e.key === 'Escape') {
102
+ e.preventDefault();
103
+ onClose();
104
+ }
105
+ }, placeholder: t('Working directory path'), "aria-label": t('Working directory path'), autoFocus: true }), _jsx("button", { type: "button", className: "jini-composer-workdir-confirm", ...agentHandleProps({}, { base, action: 'workdir-set', role: 'button', label: t('Set working directory') }), "data-testid": "composer-workdir-confirm", onClick: onConfirm, children: t('Set') })] }));
106
+ }
408
107
  //# sourceMappingURL=Composer.js.map
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { RemixIcon } from '@jini-ai/ui';
3
- import { agentHandleProps, agentHandleSegment } from '@jini-ai/agentic';
3
+ import { agentHandleProps, agentHandleSegment } from '@jini-ai/core/agent-handles';
4
4
  /** Generic grouped add-menu; the host owns all inventory labels and items. */
5
5
  export function ComposerDiscoveryMenu(props) {
6
6
  const hasItems = props.groups.some((group) => group.items.length > 0);
@@ -1,3 +1,27 @@
1
+ import type { Logger } from '@jini-ai/core/primitives';
2
+ /**
3
+ * @module ConversationList
4
+ *
5
+ * The conversation switcher: new / select / delete / search / inline rename. Drop it
6
+ * into `ChatPane`'s `leadingAccessory` slot — it needs no changes to `ChatPane` itself.
7
+ *
8
+ * Storage-agnostic by construction. It takes data and callbacks and owns nothing durable, so a
9
+ * host backs it with `@jini-ai/sqlite-chat`'s `ChatHistoryStore`, an HTTP endpoint, or an in-memory
10
+ * array without this file knowing the difference.
11
+ *
12
+ * Search is a **client-side filter by default**, and delegates to `onSearch` when a host provides
13
+ * one. That default is not laziness: a host with no server search still gets a working filter,
14
+ * and one whose list grows past a page swaps in a server query by passing a prop. The rule for
15
+ * when to swap is concrete — a client filter over a *paginated* list silently searches only the
16
+ * loaded page, so the moment a host paginates, it must provide `onSearch`.
17
+ *
18
+ * Rename has an explicit keyboard-accessible action as well as the legacy double-click shortcut.
19
+ *
20
+ * Unstyled semantic markup with `jini-conv-*` class names, matching every other component in this
21
+ * package — a host supplies the CSS.
22
+ */
23
+ import { useT } from '../hooks/context.js';
24
+ import { useConversationListView } from './ConversationList.hooks.js';
1
25
  /** The minimum a row needs to render. Mirrors `@jini-ai/chat/core`'s `ChatConversation`. */
2
26
  export interface ConversationListItem {
3
27
  id: string;
@@ -6,6 +30,7 @@ export interface ConversationListItem {
6
30
  updatedAt?: number;
7
31
  }
8
32
  export interface ConversationListProps {
33
+ report?: Pick<Logger, 'error'> | undefined;
9
34
  conversations: ConversationListItem[];
10
35
  activeConversationId: string | null;
11
36
  onSelect: (id: string) => void;
@@ -36,5 +61,13 @@ export interface ConversationListProps {
36
61
  */
37
62
  nativeTitle?: boolean;
38
63
  }
39
- export declare function ConversationList({ conversations: savedConversations, activeConversationId, onSelect, onCreate, onDelete, onRename, onSearch, confirmDelete, createDisabled, emptyState, triggerLabel, nativeTitle, }: ConversationListProps): import("react").JSX.Element;
64
+ /** Hooks ConversationList calls; defaults to the real ones, a test hands in fakes. */
65
+ export declare const defaultConversationListHooks: {
66
+ useT: typeof useT;
67
+ useConversationListView: typeof useConversationListView;
68
+ };
69
+ export type ConversationListHooks = typeof defaultConversationListHooks;
70
+ export declare function ConversationList({ conversations: savedConversations, activeConversationId, onSelect, onCreate, onDelete, onRename, onSearch, confirmDelete, createDisabled, emptyState, triggerLabel, nativeTitle, hooks, report, }: ConversationListProps & {
71
+ hooks?: ConversationListHooks | undefined;
72
+ }): import("react").JSX.Element;
40
73
  //# sourceMappingURL=ConversationList.d.ts.map
@@ -1,3 +1,6 @@
1
+ import { type Logger } from '@jini-ai/core/primitives';
2
+ import type { ConversationListProps } from './ConversationList.js';
3
+ import type { useT } from '../hooks/context.js';
1
4
  import type { ConversationListItem } from './ConversationList.js';
2
5
  /** Project saved/search titles for presentation without renaming durable conversations.
3
6
  * The switcher has no prompt or title provenance, so keep wording and casing while stripping
@@ -15,4 +18,38 @@ export declare function useConversationListTitles({ conversations, serverResults
15
18
  serverResults: ConversationListItem[] | null;
16
19
  rawTitles: ReadonlyMap<string, string | null>;
17
20
  };
21
+ /** Manage search, selection timing, rename, deletion, and host effects for the switcher. */
22
+ export declare function useConversationListView({ savedConversations, activeConversationId, onSelect, onCreate, onDelete, onRename, onSearch, confirmDelete, emptyState, t }: {
23
+ savedConversations: ConversationListProps['conversations'];
24
+ activeConversationId: ConversationListProps['activeConversationId'];
25
+ onSelect: ConversationListProps['onSelect'];
26
+ onCreate: ConversationListProps['onCreate'];
27
+ onDelete: ConversationListProps['onDelete'];
28
+ onRename: ConversationListProps['onRename'];
29
+ onSearch: ConversationListProps['onSearch'];
30
+ confirmDelete: ConversationListProps['confirmDelete'];
31
+ emptyState: ConversationListProps['emptyState'];
32
+ t: ReturnType<typeof useT>;
33
+ }, { report }?: {
34
+ report?: Pick<Logger, 'error'> | undefined;
35
+ }): {
36
+ open: boolean;
37
+ setOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
38
+ query: string;
39
+ setQuery: import("react").Dispatch<import("react").SetStateAction<string>>;
40
+ conversations: ConversationListItem[];
41
+ rawTitles: ReadonlyMap<string, string | null>;
42
+ editingId: string | null;
43
+ setEditingId: import("react").Dispatch<import("react").SetStateAction<string | null>>;
44
+ rootRef: import("react").RefObject<HTMLDivElement | null>;
45
+ visible: ConversationListItem[];
46
+ now: number;
47
+ commitRename: (id: string, next: string) => void;
48
+ startRename: (id: string) => void;
49
+ requestDelete: (item: ConversationListItem) => void;
50
+ active: ConversationListItem | null;
51
+ emptyLabel: () => string | number | bigint | boolean | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined>;
52
+ scheduleSelect: (id: string) => void;
53
+ createConversation: () => void;
54
+ };
18
55
  //# sourceMappingURL=ConversationList.hooks.d.ts.map