@parallelworks/ui 0.18.0 → 0.19.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.
- package/README.md +86 -6
- package/dist/ai/adapter/memoryStore.d.ts +8 -0
- package/dist/ai/adapter/memoryStore.js +152 -0
- package/dist/ai/adapter/mock/index.d.ts +2 -0
- package/dist/ai/adapter/mock/index.js +3 -0
- package/dist/ai/adapter/mock/mockAdapter.d.ts +4 -0
- package/dist/ai/adapter/mock/mockAdapter.js +81 -0
- package/dist/ai/adapter/openai/createOpenAIStream.d.ts +9 -0
- package/dist/ai/adapter/openai/createOpenAIStream.js +33 -0
- package/dist/ai/adapter/openai/errors.d.ts +3 -0
- package/dist/ai/adapter/openai/errors.js +37 -0
- package/dist/ai/adapter/openai/index.d.ts +6 -0
- package/dist/ai/adapter/openai/index.js +6 -0
- package/dist/ai/adapter/openai/openaiAdapter.d.ts +9 -0
- package/dist/ai/adapter/openai/openaiAdapter.js +54 -0
- package/dist/ai/adapter/openai/responses.d.ts +4 -0
- package/dist/ai/adapter/openai/responses.js +108 -0
- package/dist/ai/adapter/openai/sse.d.ts +24 -0
- package/dist/ai/adapter/openai/sse.js +112 -0
- package/dist/ai/adapter/openai/wire.d.ts +40 -0
- package/dist/ai/adapter/types.d.ts +131 -0
- package/dist/ai/adapter/types.js +11 -0
- package/dist/ai/agent/classifier.d.ts +2 -0
- package/dist/ai/agent/classifier.js +12 -0
- package/dist/ai/agent/diff.d.ts +35 -0
- package/dist/ai/agent/diff.js +223 -0
- package/dist/ai/agent/diffHighlight.d.ts +6 -0
- package/dist/ai/agent/diffHighlight.js +101 -0
- package/dist/ai/agent/index.d.ts +6 -0
- package/dist/ai/agent/permissions.d.ts +11 -0
- package/dist/ai/agent/permissions.js +29 -0
- package/dist/ai/agent/toolfmt.d.ts +18 -0
- package/dist/ai/agent/toolfmt.js +383 -0
- package/dist/ai/agent/transcript.d.ts +38 -0
- package/dist/ai/agent/transcript.js +127 -0
- package/dist/ai/ai.css +325 -0
- package/dist/ai/components/AllocationSelector.d.ts +4 -0
- package/dist/ai/components/AllocationSelector.js +56 -0
- package/dist/ai/components/AttachmentManager.d.ts +1 -0
- package/dist/ai/components/AttachmentManager.js +144 -0
- package/dist/ai/components/AttachmentUpload.d.ts +24 -0
- package/dist/ai/components/AttachmentUpload.js +179 -0
- package/dist/ai/components/BlockedGroupBanner.d.ts +1 -0
- package/dist/ai/components/BlockedGroupBanner.js +29 -0
- package/dist/ai/components/BranchNavigator.d.ts +8 -0
- package/dist/ai/components/BranchNavigator.js +57 -0
- package/dist/ai/components/ChatEmptyState.d.ts +3 -0
- package/dist/ai/components/ChatEmptyState.js +171 -0
- package/dist/ai/components/ChatInput.d.ts +45 -0
- package/dist/ai/components/ChatInput.js +265 -0
- package/dist/ai/components/ChatLayout.d.ts +5 -0
- package/dist/ai/components/ChatLayout.js +15 -0
- package/dist/ai/components/ChatMessage.d.ts +24 -0
- package/dist/ai/components/ChatMessage.js +338 -0
- package/dist/ai/components/ChatMessageList.d.ts +35 -0
- package/dist/ai/components/ChatMessageList.js +301 -0
- package/dist/ai/components/ChatSidebar.d.ts +5 -0
- package/dist/ai/components/ChatSidebar.js +345 -0
- package/dist/ai/components/ChatThread.d.ts +3 -0
- package/dist/ai/components/ChatThread.js +198 -0
- package/dist/ai/components/ComposerChrome.d.ts +18 -0
- package/dist/ai/components/ComposerChrome.js +50 -0
- package/dist/ai/components/ComposerFrame.d.ts +16 -0
- package/dist/ai/components/ComposerFrame.js +33 -0
- package/dist/ai/components/DragOverlay.d.ts +5 -0
- package/dist/ai/components/DragOverlay.js +20 -0
- package/dist/ai/components/ModelSelector.d.ts +6 -0
- package/dist/ai/components/ModelSelector.js +343 -0
- package/dist/ai/components/ShareDialog.d.ts +11 -0
- package/dist/ai/components/ShareDialog.js +260 -0
- package/dist/ai/components/SlashMenu.d.ts +28 -0
- package/dist/ai/components/SlashMenu.js +91 -0
- package/dist/ai/components/agent/ActivityLine.d.ts +21 -0
- package/dist/ai/components/agent/ActivityLine.js +151 -0
- package/dist/ai/components/agent/AgentMessageParts.d.ts +54 -0
- package/dist/ai/components/agent/AgentMessageParts.js +721 -0
- package/dist/ai/components/agent/PermissionPicker.d.ts +11 -0
- package/dist/ai/components/agent/PermissionPicker.js +38 -0
- package/dist/ai/components/attachmentKeys.d.ts +4 -0
- package/dist/ai/components/attachmentKeys.js +10 -0
- package/dist/ai/core/ChatProvider.d.ts +66 -0
- package/dist/ai/core/ChatProvider.js +848 -0
- package/dist/ai/core/KeyboardShortcutsProvider.d.ts +5 -0
- package/dist/ai/core/KeyboardShortcutsProvider.js +9 -0
- package/dist/ai/core/chatReducer.d.ts +114 -0
- package/dist/ai/core/chatReducer.js +223 -0
- package/dist/ai/core/config.d.ts +47 -0
- package/dist/ai/core/config.js +45 -0
- package/dist/ai/core/events.d.ts +1 -0
- package/dist/ai/core/events.js +4 -0
- package/dist/ai/core/exportConversation.d.ts +4 -0
- package/dist/ai/core/exportConversation.js +42 -0
- package/dist/ai/core/greeting.d.ts +3 -0
- package/dist/ai/core/greeting.js +38 -0
- package/dist/ai/core/parts.d.ts +11 -0
- package/dist/ai/core/parts.js +84 -0
- package/dist/ai/core/useDragDrop.d.ts +14 -0
- package/dist/ai/core/useDragDrop.js +36 -0
- package/dist/ai/core/useKeyboardShortcuts.d.ts +12 -0
- package/dist/ai/core/useKeyboardShortcuts.js +77 -0
- package/dist/ai/core/useSSEStream.d.ts +34 -0
- package/dist/ai/core/useSSEStream.js +98 -0
- package/dist/ai/index.d.ts +40 -0
- package/dist/ai/index.js +44 -0
- package/dist/ai/strings.d.ts +167 -0
- package/dist/ai/strings.js +175 -0
- package/dist/ai/types.d.ts +236 -0
- package/dist/ai/ui/Avatar.d.ts +8 -0
- package/dist/ai/ui/Avatar.js +35 -0
- package/dist/ai/ui/Dropdown.d.ts +31 -0
- package/dist/ai/ui/Dropdown.js +110 -0
- package/dist/ai/ui/Markdown.d.ts +8 -0
- package/dist/ai/ui/Markdown.js +79 -0
- package/dist/ai/ui/Notice.d.ts +21 -0
- package/dist/ai/ui/Notice.js +77 -0
- package/dist/ai/ui/buttons.d.ts +1 -0
- package/dist/ai/ui/codeBreaks.d.ts +16 -0
- package/dist/ai/ui/codeBreaks.js +36 -0
- package/dist/ai/ui/prose.d.ts +1 -0
- package/dist/ai/ui/prose.js +13 -0
- package/dist/ai/ui/sidebar.d.ts +81 -0
- package/dist/ai/ui/sidebar.js +148 -0
- package/dist/ai/utils.d.ts +4 -0
- package/dist/ai/utils.js +23 -0
- package/dist/assets/{editor.worker-CuBRIwi-.js → editor.worker-BmHUIVG4.js} +194 -163
- package/dist/assets/{json.worker-8ytS02vz.js → json.worker-D8bJ92nw.js} +384 -338
- package/dist/assets/{yaml.worker-DJC-VUcv.js → yaml.worker-C4gyGAko.js} +15657 -13823
- package/dist/components/AddMenu.js +46 -0
- package/dist/components/Avatar.d.ts +1 -1
- package/dist/components/Avatar.js +46 -0
- package/dist/{chunks/BareModal-BtRiQezg.js → components/BareModal.js} +1 -1
- package/dist/components/Breadcrumbs.d.ts +1 -1
- package/dist/components/Breadcrumbs.js +83 -0
- package/dist/components/Button.js +83 -0
- package/dist/components/Callout.js +23 -0
- package/dist/components/Card.js +31 -0
- package/dist/components/CollapsiblePanel.js +77 -0
- package/dist/components/ConfirmModal.js +74 -0
- package/dist/components/CopyToClipboard.js +81 -0
- package/dist/{chunks/CreateModal-BY6DLmur.js → components/CreateModal.js} +10 -189
- package/dist/components/DescriptionList.js +42 -0
- package/dist/components/Dropdown.d.ts +1 -1
- package/dist/components/Dropdown.js +349 -0
- package/dist/components/EmptyState.d.ts +1 -1
- package/dist/components/EmptyState.js +27 -0
- package/dist/components/Filter.js +32 -0
- package/dist/components/FilterPill.js +13 -0
- package/dist/components/IconButton.js +34 -0
- package/dist/components/Indicator.d.ts +2 -2
- package/dist/{chunks/Indicator-hBSIxOPK.js → components/Indicator.js} +1 -1
- package/dist/components/Input.d.ts +1 -1
- package/dist/components/Input.js +88 -0
- package/dist/components/LetterBadge.d.ts +1 -1
- package/dist/components/LetterBadge.js +13 -0
- package/dist/components/Listbox.js +123 -0
- package/dist/{chunks/Loader-BXoXTZGc.js → components/Loader.js} +1 -1
- package/dist/components/Markdown.js +15 -0
- package/dist/components/MarkdownImpl.d.ts +1 -1
- package/dist/components/MultiSelect.js +171 -0
- package/dist/components/Overview.js +39 -0
- package/dist/components/PageHeader.js +194 -0
- package/dist/components/Pagination.js +35 -0
- package/dist/components/Provider.d.ts +16 -65
- package/dist/{chunks/Provider-Ghua9PkN.js → components/Provider.js} +54 -20
- package/dist/{chunks/RequiredMark-DfLdYbYZ.js → components/RequiredMark.js} +1 -1
- package/dist/components/SectionHeader.js +11 -0
- package/dist/components/SettingModeOption.js +30 -0
- package/dist/components/SettingRow.d.ts +1 -1
- package/dist/components/SettingRow.js +35 -0
- package/dist/components/SettingsCard.js +31 -0
- package/dist/components/SettingsGroup.d.ts +1 -1
- package/dist/components/SettingsGroup.js +17 -0
- package/dist/components/Sort.js +42 -0
- package/dist/components/StatusBadge.js +63 -0
- package/dist/components/SwitchToggle.js +59 -0
- package/dist/{chunks/SwitchToggleSmall-FcsaYSTs.js → components/SwitchToggleSmall.js} +1 -1
- package/dist/{chunks/Table-4OHjdKdO.js → components/Table.js} +7 -5
- package/dist/components/Toggle.js +20 -0
- package/dist/{chunks/Tooltip-Crxo_eU_.js → components/Tooltip.js} +6 -4
- package/dist/{chunks/StatusBadge-C1Blx_cW.js → components/dropdownUtils.js} +2 -63
- package/dist/components/focus.d.ts +2 -0
- package/dist/components/focus.js +7 -0
- package/dist/components/ghostButton.js +7 -0
- package/dist/components/inputClasses.js +4 -0
- package/dist/components/keys.d.ts +12 -0
- package/dist/components/keys.js +27 -0
- package/dist/components/relativeTime.js +32 -0
- package/dist/{chunks/useCssIsDark-DHr05dG2.js → components/useCssIsDark.js} +1 -1
- package/dist/duration.d.ts +3 -0
- package/dist/duration.js +17 -0
- package/dist/editor/Editor.js +13 -0
- package/dist/editor/EditorField.js +53 -0
- package/dist/editor/FormCodePanel.js +173 -0
- package/dist/editor/Monaco.d.ts +1 -20
- package/dist/editor/Monaco.js +112 -0
- package/dist/editor/index.d.ts +2 -1
- package/dist/editor/index.js +7 -2
- package/dist/editor/themes.js +91 -0
- package/dist/editor/workers.js +29 -0
- package/dist/editor/yaml.d.ts +5 -0
- package/dist/editor/yaml.js +15 -0
- package/dist/engine.d.ts +98 -0
- package/dist/file-explorer/FileExplorer.d.ts +11 -2
- package/dist/file-explorer/FileExplorer.js +1402 -0
- package/dist/file-explorer/FileExplorerContext.d.ts +1 -1
- package/dist/file-explorer/FileExplorerContext.js +370 -0
- package/dist/file-explorer/FilePreview/CodePreviewEditor.d.ts +1 -1
- package/dist/{chunks/CodePreviewEditor-4lx3kE-w.js → file-explorer/FilePreview/CodePreviewEditor.js} +3 -2
- package/dist/file-explorer/FilePreview/Inline.js +45 -0
- package/dist/file-explorer/FilePreview/StreamedBadge.js +16 -0
- package/dist/file-explorer/FilePreview/Viewer.js +526 -0
- package/dist/file-explorer/FilePreview/index.js +266 -0
- package/dist/file-explorer/FilePreview/parse.js +63 -0
- package/dist/file-explorer/FilePreview/previewCache.js +98 -0
- package/dist/file-explorer/FilePreview/previewType.d.ts +1 -1
- package/dist/file-explorer/FilePreview/previewType.js +151 -0
- package/dist/file-explorer/FilePreview/readCappedBytes.js +196 -0
- package/dist/file-explorer/FilePreview/useObjectBlobUrl.js +95 -0
- package/dist/file-explorer/FilePreview/useObjectText.js +109 -0
- package/dist/file-explorer/FilePreview/usePresignedUrl.js +73 -0
- package/dist/file-explorer/FileRow.d.ts +1 -1
- package/dist/file-explorer/FileRow.js +165 -0
- package/dist/file-explorer/FileRowsWindow.js +92 -0
- package/dist/file-explorer/FileTable.js +172 -0
- package/dist/file-explorer/FileTableHeaders.js +49 -0
- package/dist/file-explorer/LoadMoreRow.js +46 -0
- package/dist/file-explorer/TreeView.js +376 -0
- package/dist/file-explorer/helpers.d.ts +4 -4
- package/dist/file-explorer/helpers.js +537 -0
- package/dist/file-explorer/index.d.ts +3 -3
- package/dist/file-explorer/index.js +7 -5705
- package/dist/file-explorer/lib/batch.js +39 -0
- package/dist/file-explorer/lib/errors.js +9 -0
- package/dist/file-explorer/lib/paging.js +124 -0
- package/dist/file-explorer/lib/types.d.ts +6 -1
- package/dist/file-explorer/lib/utils.d.ts +1 -3
- package/dist/file-explorer/lib/utils.js +322 -0
- package/dist/file-explorer/toasts.js +400 -0
- package/dist/file-explorer/treeRows.js +73 -0
- package/dist/file-explorer/useNearEnd.d.ts +1 -1
- package/dist/file-explorer/useNearEnd.js +27 -0
- package/dist/form/FieldWrapper.d.ts +2 -2
- package/dist/form/FieldWrapper.js +54 -0
- package/dist/form/Fields/BooleanField.js +51 -0
- package/dist/form/Fields/CheckboxGroupField.js +72 -0
- package/dist/form/Fields/ColorField.js +33 -0
- package/dist/form/Fields/DropdownField.js +49 -0
- package/dist/form/Fields/DurationField.js +130 -0
- package/dist/form/Fields/LabelField.js +19 -0
- package/dist/form/Fields/MultiDropdownField.js +40 -0
- package/dist/form/Fields/NumberField.js +51 -0
- package/dist/form/Fields/ObjectField.js +54 -0
- package/dist/form/Fields/RadioField.js +49 -0
- package/dist/form/Fields/RangeField.js +58 -0
- package/dist/form/Fields/ResourceOptionIcon.d.ts +1 -1
- package/dist/form/Fields/ResourceOptionIcon.js +21 -0
- package/dist/form/Fields/StepField.js +6 -0
- package/dist/form/Fields/StringField.js +37 -0
- package/dist/form/Fields/TextAreaField.js +31 -0
- package/dist/form/Fields/durationValidity.js +11 -0
- package/dist/form/Form.d.ts +4 -21
- package/dist/form/Form.js +643 -0
- package/dist/form/SpecialTypes/DropdownWrapper.js +30 -0
- package/dist/form/SpecialTypes/FormikCustomDropdown.js +122 -0
- package/dist/form/SpecialTypes/FormikCustomInput.js +111 -0
- package/dist/form/SpecialTypes/FormikMultiSelectDropdown.js +31 -0
- package/dist/form/SpecialTypes/FormikNumericInput.js +60 -0
- package/dist/form/Wizard/WizardContainer.js +138 -0
- package/dist/form/Wizard/WizardNavigation.js +92 -0
- package/dist/form/Wizard/WizardStepContent.js +35 -0
- package/dist/form/Wizard/WizardStepIndicator.js +108 -0
- package/dist/form/Wizard/useWizardState.js +118 -0
- package/dist/form/Wizard/utils.js +34 -0
- package/dist/form/fieldContext.js +26 -0
- package/dist/form/fieldRegistry.js +50 -0
- package/dist/form/index.d.ts +11 -12
- package/dist/form/index.js +18 -2445
- package/dist/form/lib.d.ts +6 -1
- package/dist/{chunks/FieldWrapper-Bef01EWO.js → form/lib.js} +5 -104
- package/dist/form/types/fieldComponentTypes.d.ts +3 -2
- package/dist/form/types/fieldTypes.d.ts +6 -20
- package/dist/form/useParsedOpts.d.ts +1 -1
- package/dist/form/useParsedOpts.js +62 -0
- package/dist/form/usePrevious.js +11 -0
- package/dist/form/utils/checkShowIfObject.js +14 -0
- package/dist/form/utils/{slurmDuration.d.ts → duration.d.ts} +2 -2
- package/dist/form/utils/duration.js +69 -0
- package/dist/form/utils/getParentValue.js +23 -0
- package/dist/form/utils/getPlaceholder.js +9 -0
- package/dist/form/utils/getValueUsingPath.js +23 -0
- package/dist/form/utils/secondaryField.js +22 -0
- package/dist/graph/AnnotationBanner.js +141 -0
- package/dist/graph/Collapse.js +41 -0
- package/dist/{workflow/index.js → graph/DependencyGraph.js} +76 -1163
- package/dist/graph/JobSummary.js +104 -0
- package/dist/{workflow → graph}/MatrixGroup.d.ts +2 -2
- package/dist/graph/MatrixGroup.js +107 -0
- package/dist/graph/Reveal.js +57 -0
- package/dist/graph/TreeView.js +711 -0
- package/dist/{workflow → graph}/index.d.ts +1 -1
- package/dist/graph/index.js +2 -0
- package/dist/{workflow → graph}/types.d.ts +3 -3
- package/dist/graph/types.js +6 -0
- package/dist/icons.d.ts +20 -21
- package/dist/index.d.ts +38 -40
- package/dist/index.js +47 -599
- package/dist/list/ActionToolbar.js +184 -0
- package/dist/list/HoverCard.js +73 -0
- package/dist/list/ListPage.js +145 -0
- package/dist/list/ListPager.js +59 -0
- package/dist/list/ListTable.d.ts +1 -1
- package/dist/list/ListTable.js +163 -0
- package/dist/list/ListViewControls.d.ts +2 -2
- package/dist/list/ListViewControls.js +372 -0
- package/dist/list/RowContextMenu.js +350 -0
- package/dist/list/UserHoverCard.js +117 -0
- package/dist/list/index.d.ts +9 -9
- package/dist/list/index.js +11 -2
- package/dist/list/listSearch.js +137 -0
- package/dist/list/listView.js +210 -0
- package/dist/list/textEntry.js +10 -0
- package/dist/logviewer/LogViewer.d.ts +1 -1
- package/dist/logviewer/LogViewer.js +750 -0
- package/dist/logviewer/index.d.ts +1 -0
- package/dist/logviewer/index.js +3 -742
- package/dist/logviewer/segments.d.ts +9 -0
- package/dist/logviewer/segments.js +80 -0
- package/dist/styles/fonts.css +4 -4
- package/dist/styles/theme.css +6 -4
- package/dist/styles.css +1 -1
- package/dist/theme/index.js +2 -2
- package/package.json +38 -14
- package/LICENSE +0 -202
- package/dist/chunks/Monaco-C1POOdVv.js +0 -1046
- package/dist/chunks/PageHeader-l49p1nM9.js +0 -690
- package/dist/chunks/SwitchToggle-CHPP8uZQ.js +0 -755
- package/dist/chunks/editor-9_uVtUyy.js +0 -347
- package/dist/chunks/list-qrojZZNv.js +0 -1411
- package/dist/editor/usesGitlab.d.ts +0 -97
- package/dist/form/Fields/BucketReadOnlyField.d.ts +0 -7
- package/dist/form/types/workflow-schema.d.ts +0 -1145
- package/dist/form/utils/pwResolver.d.ts +0 -18
- package/dist/{chunks/MarkdownImpl-Bq4QhrtA.js → components/MarkdownImpl.js} +1 -1
- /package/dist/{workflow → graph}/AnnotationBanner.d.ts +0 -0
- /package/dist/{workflow → graph}/Collapse.d.ts +0 -0
- /package/dist/{workflow → graph}/DependencyGraph.d.ts +0 -0
- /package/dist/{workflow → graph}/JobSummary.d.ts +0 -0
- /package/dist/{workflow → graph}/Reveal.d.ts +0 -0
- /package/dist/{workflow → graph}/TreeView.d.ts +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { ApprovalAnswerValue, ChatMessage as Message } from '../types.js';
|
|
3
|
+
interface ChatMessageListProps {
|
|
4
|
+
messages: Message[];
|
|
5
|
+
allMessages: Message[];
|
|
6
|
+
streamingMessage?: Message | null;
|
|
7
|
+
queuedMessages?: Message[];
|
|
8
|
+
onRemoveQueued?: (id: string) => void;
|
|
9
|
+
editingMessageId?: string | null | undefined;
|
|
10
|
+
showAuthor?: boolean;
|
|
11
|
+
currentUsername?: string;
|
|
12
|
+
onNavigateBranch?: (messageId: string) => void;
|
|
13
|
+
onEditMessage?: ((messageId: string) => void) | undefined;
|
|
14
|
+
onSaveEdit?: (messageId: string, content: string) => void;
|
|
15
|
+
onCancelEdit?: () => void;
|
|
16
|
+
onRegenerateMessage?: ((messageId: string) => void) | undefined;
|
|
17
|
+
onRetryMessage?: ((messageId: string) => void) | undefined;
|
|
18
|
+
onOpenReasoning?: (reasoning: string, duration: number | null) => void;
|
|
19
|
+
onApprovalAnswer?: (id: string, answer: ApprovalAnswerValue) => void;
|
|
20
|
+
inputElement?: ReactNode;
|
|
21
|
+
/** Whether a turn is in flight, when the host tracks that itself rather
|
|
22
|
+
* than streaming through the provider. */
|
|
23
|
+
isStreaming?: boolean;
|
|
24
|
+
/** Rows without their own side padding, for a host that pads the column. */
|
|
25
|
+
flush?: boolean;
|
|
26
|
+
/** Names the list as a live log for assistive technology. */
|
|
27
|
+
label?: string;
|
|
28
|
+
/** Rendered after the last message, inside the scrolling column. */
|
|
29
|
+
footer?: ReactNode;
|
|
30
|
+
/** Off for a host that shows the turn's activity elsewhere, so the wait
|
|
31
|
+
* for the first frame is not announced twice. */
|
|
32
|
+
workingIndicator?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export default function ChatMessageList({ messages, allMessages, streamingMessage, queuedMessages, onRemoveQueued, editingMessageId, showAuthor, currentUsername, onNavigateBranch, onEditMessage, onSaveEdit, onCancelEdit, onRegenerateMessage, onRetryMessage, onOpenReasoning, onApprovalAnswer, inputElement, isStreaming: isStreamingProp, flush, label, footer, workingIndicator, }: ChatMessageListProps): import("react").JSX.Element;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { ChevronRightIcon, XIcon } from "../../icons.js";
|
|
2
|
+
import { durationToAbsHumanDuration } from "../../duration.js";
|
|
3
|
+
import { useChatConfig } from "../core/config.js";
|
|
4
|
+
import { useChat } from "../core/ChatProvider.js";
|
|
5
|
+
import Markdown from "../ui/Markdown.js";
|
|
6
|
+
import AgentMessageParts from "./agent/AgentMessageParts.js";
|
|
7
|
+
import ChatMessage_default from "./ChatMessage.js";
|
|
8
|
+
import cx from "classnames";
|
|
9
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { Duration } from "luxon";
|
|
12
|
+
//#region src/ai/components/ChatMessageList.tsx
|
|
13
|
+
function ChatMessageList({ messages, allMessages, streamingMessage, queuedMessages, onRemoveQueued, editingMessageId, showAuthor, currentUsername, onNavigateBranch, onEditMessage, onSaveEdit, onCancelEdit, onRegenerateMessage, onRetryMessage, onOpenReasoning, onApprovalAnswer, inputElement, isStreaming: isStreamingProp, flush, label, footer, workingIndicator = true }) {
|
|
14
|
+
const { adapter, isStreaming: providerStreaming, isThinking, streamingReasoning, streamingParts, thinkingStartTime } = useChat();
|
|
15
|
+
const isStreaming = isStreamingProp ?? providerStreaming;
|
|
16
|
+
const { strings } = useChatConfig();
|
|
17
|
+
const tThinking = strings.thinking;
|
|
18
|
+
const attachmentDownloadUrl = useMemo(() => {
|
|
19
|
+
const attachments = adapter.attachments;
|
|
20
|
+
return attachments ? (id) => attachments.downloadUrl(id) : void 0;
|
|
21
|
+
}, [adapter]);
|
|
22
|
+
const onOpenAttachment = useMemo(() => {
|
|
23
|
+
const open = adapter.attachments?.onOpen;
|
|
24
|
+
return open ? open.bind(adapter.attachments) : void 0;
|
|
25
|
+
}, [adapter]);
|
|
26
|
+
const bottomRef = useRef(null);
|
|
27
|
+
const containerRef = useRef(null);
|
|
28
|
+
const reasoningScrollRef = useRef(null);
|
|
29
|
+
const knownMessageIdsRef = useRef(/* @__PURE__ */ new Set());
|
|
30
|
+
const prevMessageCountRef = useRef(messages.length);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const prev = prevMessageCountRef.current;
|
|
33
|
+
if (messages.length > 0 && (prev === 0 || messages.length < prev)) knownMessageIdsRef.current = new Set(messages.map((m) => m.id));
|
|
34
|
+
prevMessageCountRef.current = messages.length;
|
|
35
|
+
}, [messages]);
|
|
36
|
+
const messageCount = messages.length;
|
|
37
|
+
const streamingContent = streamingMessage?.content;
|
|
38
|
+
const streamingMessageParts = streamingMessage?.parts;
|
|
39
|
+
const [elapsedTime, setElapsedTime] = useState(0);
|
|
40
|
+
const [finalThinkingDuration, setFinalThinkingDuration] = useState(null);
|
|
41
|
+
const wasThinkingRef = useRef(false);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (isThinking && !wasThinkingRef.current) {
|
|
44
|
+
wasThinkingRef.current = true;
|
|
45
|
+
setFinalThinkingDuration(null);
|
|
46
|
+
} else if (!isThinking && wasThinkingRef.current && thinkingStartTime) {
|
|
47
|
+
wasThinkingRef.current = false;
|
|
48
|
+
setFinalThinkingDuration(Date.now() - thinkingStartTime);
|
|
49
|
+
}
|
|
50
|
+
}, [isThinking, thinkingStartTime]);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!isStreaming) {
|
|
53
|
+
wasThinkingRef.current = false;
|
|
54
|
+
setFinalThinkingDuration(null);
|
|
55
|
+
}
|
|
56
|
+
}, [isStreaming]);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (!thinkingStartTime || !isThinking) {
|
|
59
|
+
setElapsedTime(0);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const interval = setInterval(() => {
|
|
63
|
+
setElapsedTime(Math.floor((Date.now() - thinkingStartTime) / 1e3));
|
|
64
|
+
}, 1e3);
|
|
65
|
+
return () => clearInterval(interval);
|
|
66
|
+
}, [thinkingStartTime, isThinking]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (reasoningScrollRef.current && isThinking) reasoningScrollRef.current.scrollTop = reasoningScrollRef.current.scrollHeight;
|
|
69
|
+
}, [streamingReasoning, isThinking]);
|
|
70
|
+
const isNearBottomRef = useRef(true);
|
|
71
|
+
const lastScrollTopRef = useRef(0);
|
|
72
|
+
const [pinned, setPinned] = useState(true);
|
|
73
|
+
const handleScroll = useCallback(() => {
|
|
74
|
+
if (!containerRef.current) return;
|
|
75
|
+
const { scrollTop, scrollHeight, clientHeight } = containerRef.current;
|
|
76
|
+
const scrolledDown = scrollTop >= lastScrollTopRef.current;
|
|
77
|
+
lastScrollTopRef.current = scrollTop;
|
|
78
|
+
if (scrollHeight - scrollTop - clientHeight < 24) {
|
|
79
|
+
if (scrolledDown) isNearBottomRef.current = true;
|
|
80
|
+
} else isNearBottomRef.current = false;
|
|
81
|
+
setPinned(isNearBottomRef.current);
|
|
82
|
+
}, []);
|
|
83
|
+
const jumpToLatest = useCallback(() => {
|
|
84
|
+
const el = containerRef.current;
|
|
85
|
+
if (el) {
|
|
86
|
+
el.scrollTop = el.scrollHeight;
|
|
87
|
+
lastScrollTopRef.current = el.scrollTop;
|
|
88
|
+
isNearBottomRef.current = true;
|
|
89
|
+
setPinned(true);
|
|
90
|
+
}
|
|
91
|
+
}, []);
|
|
92
|
+
const hasContent = messages.length > 0 || !!streamingMessage;
|
|
93
|
+
const awaitingApproval = streamingParts.some((part) => part.kind === "approval" && !part.resolved);
|
|
94
|
+
const showWorkingIndicator = workingIndicator && isStreaming && !streamingReasoning && !streamingMessage && !awaitingApproval;
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
const container = containerRef.current;
|
|
97
|
+
if (!container) return;
|
|
98
|
+
const releaseOnWheelUp = (e) => {
|
|
99
|
+
if (e.deltaY < 0) {
|
|
100
|
+
isNearBottomRef.current = false;
|
|
101
|
+
setPinned(false);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const releaseOnTouch = () => {
|
|
105
|
+
isNearBottomRef.current = false;
|
|
106
|
+
setPinned(false);
|
|
107
|
+
};
|
|
108
|
+
container.addEventListener("scroll", handleScroll);
|
|
109
|
+
container.addEventListener("wheel", releaseOnWheelUp, { passive: true });
|
|
110
|
+
container.addEventListener("touchmove", releaseOnTouch, { passive: true });
|
|
111
|
+
return () => {
|
|
112
|
+
container.removeEventListener("scroll", handleScroll);
|
|
113
|
+
container.removeEventListener("wheel", releaseOnWheelUp);
|
|
114
|
+
container.removeEventListener("touchmove", releaseOnTouch);
|
|
115
|
+
};
|
|
116
|
+
}, [handleScroll, hasContent]);
|
|
117
|
+
const hadMessagesRef = useRef(false);
|
|
118
|
+
useLayoutEffect(() => {
|
|
119
|
+
if (!containerRef.current || messageCount === 0) return;
|
|
120
|
+
if (!hadMessagesRef.current) {
|
|
121
|
+
hadMessagesRef.current = true;
|
|
122
|
+
containerRef.current.scrollTop = containerRef.current.scrollHeight;
|
|
123
|
+
}
|
|
124
|
+
}, [messageCount]);
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (messageCount === 0) hadMessagesRef.current = false;
|
|
127
|
+
}, [messageCount]);
|
|
128
|
+
const hasQueuedMessages = queuedMessages && queuedMessages.length > 0;
|
|
129
|
+
useLayoutEffect(() => {
|
|
130
|
+
if (!containerRef.current || !isNearBottomRef.current || !isStreaming || hasQueuedMessages) return;
|
|
131
|
+
containerRef.current.scrollTop = containerRef.current.scrollHeight;
|
|
132
|
+
}, [
|
|
133
|
+
streamingContent,
|
|
134
|
+
streamingParts,
|
|
135
|
+
streamingMessageParts,
|
|
136
|
+
messageCount,
|
|
137
|
+
isStreaming,
|
|
138
|
+
hasQueuedMessages
|
|
139
|
+
]);
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (!containerRef.current || !isNearBottomRef.current || isStreaming || !hadMessagesRef.current) return;
|
|
142
|
+
bottomRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
143
|
+
}, [messageCount, isStreaming]);
|
|
144
|
+
if (messages.length === 0 && !streamingMessage && !hasQueuedMessages) return /* @__PURE__ */ jsxs("div", {
|
|
145
|
+
className: "flex-1 overflow-y-auto flex flex-col bg-(--theme-panel-bg)",
|
|
146
|
+
children: [
|
|
147
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1" }),
|
|
148
|
+
footer && /* @__PURE__ */ jsx("div", {
|
|
149
|
+
className: cx("w-full max-w-[50rem] mx-auto", !flush && "px-4"),
|
|
150
|
+
children: footer
|
|
151
|
+
}),
|
|
152
|
+
inputElement && /* @__PURE__ */ jsx("div", {
|
|
153
|
+
className: "sticky bottom-0 z-10",
|
|
154
|
+
children: inputElement
|
|
155
|
+
})
|
|
156
|
+
]
|
|
157
|
+
});
|
|
158
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
159
|
+
ref: containerRef,
|
|
160
|
+
...label ? {
|
|
161
|
+
role: "log",
|
|
162
|
+
"aria-relevant": "additions",
|
|
163
|
+
"aria-label": label
|
|
164
|
+
} : {},
|
|
165
|
+
className: "flex-1 overflow-y-auto theme-scrollbar flex flex-col bg-(--theme-panel-bg)",
|
|
166
|
+
children: [
|
|
167
|
+
/* @__PURE__ */ jsxs("div", {
|
|
168
|
+
className: "w-full max-w-[50rem] mx-auto pt-10 pb-6 flex-1 px-4",
|
|
169
|
+
children: [
|
|
170
|
+
messages.map((message) => {
|
|
171
|
+
if (message.pseudo) return null;
|
|
172
|
+
const isNew = !knownMessageIdsRef.current.has(message.id);
|
|
173
|
+
if (isNew) knownMessageIdsRef.current.add(message.id);
|
|
174
|
+
return /* @__PURE__ */ jsx("div", {
|
|
175
|
+
className: isNew ? "animate-chat-enter" : "",
|
|
176
|
+
children: /* @__PURE__ */ jsx(ChatMessage_default, {
|
|
177
|
+
message,
|
|
178
|
+
allMessages,
|
|
179
|
+
flush,
|
|
180
|
+
isEditing: editingMessageId === message.id,
|
|
181
|
+
showAuthor,
|
|
182
|
+
currentUsername,
|
|
183
|
+
attachmentDownloadUrl,
|
|
184
|
+
onOpenAttachment,
|
|
185
|
+
onNavigateBranch,
|
|
186
|
+
onEdit: onEditMessage,
|
|
187
|
+
onSaveEdit,
|
|
188
|
+
onCancelEdit,
|
|
189
|
+
onRegenerate: onRegenerateMessage,
|
|
190
|
+
onRetry: onRetryMessage,
|
|
191
|
+
onOpenReasoning,
|
|
192
|
+
onApprovalAnswer
|
|
193
|
+
})
|
|
194
|
+
}, message.id);
|
|
195
|
+
}),
|
|
196
|
+
isStreaming && streamingReasoning && /* @__PURE__ */ jsx("div", {
|
|
197
|
+
className: "animate-chat-enter",
|
|
198
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
199
|
+
className: "py-3 px-4",
|
|
200
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
201
|
+
className: "flex flex-col gap-2",
|
|
202
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
203
|
+
type: "button",
|
|
204
|
+
onClick: () => onOpenReasoning?.(streamingReasoning, finalThinkingDuration),
|
|
205
|
+
className: "flex items-center gap-x-2 text-left",
|
|
206
|
+
children: isThinking ? /* @__PURE__ */ jsx("div", {
|
|
207
|
+
className: "animate-shimmer text-shimmer flex items-center gap-x-2",
|
|
208
|
+
children: /* @__PURE__ */ jsx("span", { children: elapsedTime > 0 ? `${tThinking.label} (${elapsedTime}s)` : tThinking.ellipsis })
|
|
209
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
210
|
+
className: "flex items-center gap-x-1 text-sm theme-muted-text hover:theme-text transition-colors",
|
|
211
|
+
children: [/* @__PURE__ */ jsx("span", { children: tThinking.thoughtFor(finalThinkingDuration ? durationToAbsHumanDuration(Duration.fromMillis(finalThinkingDuration)) : `${elapsedTime}s`) }), /* @__PURE__ */ jsx(ChevronRightIcon, { className: "w-3.5 h-3.5" })]
|
|
212
|
+
})
|
|
213
|
+
}), isThinking && /* @__PURE__ */ jsxs("div", {
|
|
214
|
+
className: "relative ml-6 pl-3 border-l-2 theme-border",
|
|
215
|
+
children: [/* @__PURE__ */ jsx("div", { className: "absolute inset-x-0 top-0 h-3 bg-gradient-to-b from-(--theme-app-bg) to-transparent pointer-events-none z-[1]" }), /* @__PURE__ */ jsx("div", {
|
|
216
|
+
ref: reasoningScrollRef,
|
|
217
|
+
className: "text-sm theme-muted-text max-h-20 overflow-y-hidden pt-1",
|
|
218
|
+
children: /* @__PURE__ */ jsx(Markdown, {
|
|
219
|
+
isStreaming: true,
|
|
220
|
+
children: streamingReasoning
|
|
221
|
+
})
|
|
222
|
+
})]
|
|
223
|
+
})]
|
|
224
|
+
})
|
|
225
|
+
})
|
|
226
|
+
}, "thinking"),
|
|
227
|
+
isStreaming && streamingParts.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
228
|
+
className: "animate-chat-enter py-1 px-4",
|
|
229
|
+
children: /* @__PURE__ */ jsx(AgentMessageParts, {
|
|
230
|
+
message: {
|
|
231
|
+
id: "streaming-parts",
|
|
232
|
+
role: "assistant",
|
|
233
|
+
parts: streamingParts
|
|
234
|
+
},
|
|
235
|
+
isStreaming
|
|
236
|
+
})
|
|
237
|
+
}, "streaming-parts"),
|
|
238
|
+
showWorkingIndicator && /* @__PURE__ */ jsx("div", {
|
|
239
|
+
className: "animate-chat-enter",
|
|
240
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
241
|
+
className: "py-3 px-4",
|
|
242
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
243
|
+
className: "animate-shimmer text-shimmer",
|
|
244
|
+
children: tThinking.ellipsis
|
|
245
|
+
})
|
|
246
|
+
})
|
|
247
|
+
}, "waiting"),
|
|
248
|
+
streamingMessage && /* @__PURE__ */ jsx("div", {
|
|
249
|
+
className: "animate-chat-enter",
|
|
250
|
+
children: /* @__PURE__ */ jsx(ChatMessage_default, {
|
|
251
|
+
message: streamingMessage,
|
|
252
|
+
allMessages,
|
|
253
|
+
flush,
|
|
254
|
+
isStreaming,
|
|
255
|
+
attachmentDownloadUrl,
|
|
256
|
+
onOpenAttachment,
|
|
257
|
+
onApprovalAnswer
|
|
258
|
+
})
|
|
259
|
+
}, "streaming"),
|
|
260
|
+
queuedMessages?.map((msg) => /* @__PURE__ */ jsxs("div", {
|
|
261
|
+
className: "group/queued relative animate-chat-enter opacity-60",
|
|
262
|
+
children: [/* @__PURE__ */ jsx(ChatMessage_default, {
|
|
263
|
+
message: msg,
|
|
264
|
+
allMessages,
|
|
265
|
+
flush,
|
|
266
|
+
attachmentDownloadUrl,
|
|
267
|
+
onOpenAttachment
|
|
268
|
+
}), onRemoveQueued && /* @__PURE__ */ jsx("button", {
|
|
269
|
+
type: "button",
|
|
270
|
+
"aria-label": strings.queue.remove,
|
|
271
|
+
title: strings.queue.remove,
|
|
272
|
+
onClick: () => onRemoveQueued(msg.id),
|
|
273
|
+
className: "absolute top-1 right-1 rounded p-1 opacity-0 transition-opacity group-hover/queued:opacity-100 focus-visible:opacity-100 hover:bg-(--theme-hover) text-(--theme-muted-text-color)",
|
|
274
|
+
children: /* @__PURE__ */ jsx(XIcon, { className: "h-3.5 w-3.5" })
|
|
275
|
+
})]
|
|
276
|
+
}, msg.id)),
|
|
277
|
+
footer,
|
|
278
|
+
/* @__PURE__ */ jsx("div", {
|
|
279
|
+
ref: bottomRef,
|
|
280
|
+
className: "h-8"
|
|
281
|
+
})
|
|
282
|
+
]
|
|
283
|
+
}),
|
|
284
|
+
!pinned && /* @__PURE__ */ jsx("div", {
|
|
285
|
+
className: "sticky bottom-4 z-10 flex h-0 items-start justify-center overflow-visible",
|
|
286
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
287
|
+
type: "button",
|
|
288
|
+
onClick: jumpToLatest,
|
|
289
|
+
className: "-translate-y-full rounded-full border theme-border bg-(--theme-panel-bg) px-3 py-1 text-xs shadow-sm hover:theme-hover",
|
|
290
|
+
children: strings.chrome.jumpToLatest
|
|
291
|
+
})
|
|
292
|
+
}),
|
|
293
|
+
inputElement && /* @__PURE__ */ jsx("div", {
|
|
294
|
+
className: "sticky bottom-0 z-10",
|
|
295
|
+
children: inputElement
|
|
296
|
+
})
|
|
297
|
+
]
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
301
|
+
export { ChatMessageList as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type ConversationGroupKey = 'groupToday' | 'groupYesterday' | 'groupThisWeek' | 'groupThisMonth' | 'groupOlder';
|
|
2
|
+
export default function ChatSidebar({ actions, }: {
|
|
3
|
+
/** False when the host's page header carries new chat, attachments and search. */
|
|
4
|
+
actions?: boolean;
|
|
5
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { DownloadIcon, EditIcon, ImageIcon, NewChatIcon, SearchIcon, SettingsIcon, ShareIcon, SharingIcon, TrashIcon } from "../../icons.js";
|
|
2
|
+
import { positionKeys } from "../../components/keys.js";
|
|
3
|
+
import { useRowMenu } from "../../list/RowContextMenu.js";
|
|
4
|
+
import { useChatConfig } from "../core/config.js";
|
|
5
|
+
import { useChat } from "../core/ChatProvider.js";
|
|
6
|
+
import { FOCUS_SIDEBAR_SEARCH_EVENT } from "../core/events.js";
|
|
7
|
+
import { conversationToMarkdown, downloadText, exportFilename } from "../core/exportConversation.js";
|
|
8
|
+
import { SidebarGroupHeading, SidebarPanel, SidebarRow, SidebarToggle, useRowDialogs } from "../ui/sidebar.js";
|
|
9
|
+
import ShareDialog from "./ShareDialog.js";
|
|
10
|
+
import cx from "classnames";
|
|
11
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
12
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { DateTime } from "luxon";
|
|
14
|
+
//#region src/ai/components/ChatSidebar.tsx
|
|
15
|
+
function groupByDate(conversations) {
|
|
16
|
+
const now = DateTime.now();
|
|
17
|
+
const groups = {
|
|
18
|
+
groupToday: [],
|
|
19
|
+
groupYesterday: [],
|
|
20
|
+
groupThisWeek: [],
|
|
21
|
+
groupThisMonth: [],
|
|
22
|
+
groupOlder: []
|
|
23
|
+
};
|
|
24
|
+
for (const conv of conversations) {
|
|
25
|
+
const dt = DateTime.fromISO(conv.createdAt);
|
|
26
|
+
const diff = now.diff(dt, "days").days;
|
|
27
|
+
if (diff < 1) groups.groupToday.push(conv);
|
|
28
|
+
else if (diff < 2) groups.groupYesterday.push(conv);
|
|
29
|
+
else if (diff < 7) groups.groupThisWeek.push(conv);
|
|
30
|
+
else if (diff < 30) groups.groupThisMonth.push(conv);
|
|
31
|
+
else groups.groupOlder.push(conv);
|
|
32
|
+
}
|
|
33
|
+
return Object.entries(groups).filter(([, items]) => items.length > 0);
|
|
34
|
+
}
|
|
35
|
+
function ConversationRow({ conv, isCurrent, sharingAvailable, openMenu, onRename, onShare, onDelete, onExport }) {
|
|
36
|
+
const { LinkComponent, strings } = useChatConfig();
|
|
37
|
+
const t = strings.sidebar;
|
|
38
|
+
const menuItems = [
|
|
39
|
+
{
|
|
40
|
+
kind: "action",
|
|
41
|
+
label: t.rename,
|
|
42
|
+
icon: /* @__PURE__ */ jsx(EditIcon, {}),
|
|
43
|
+
onSelect: () => onRename(conv)
|
|
44
|
+
},
|
|
45
|
+
...sharingAvailable ? [{
|
|
46
|
+
kind: "action",
|
|
47
|
+
label: t.share,
|
|
48
|
+
icon: /* @__PURE__ */ jsx(ShareIcon, {}),
|
|
49
|
+
onSelect: () => onShare(conv.id)
|
|
50
|
+
}] : [],
|
|
51
|
+
{
|
|
52
|
+
kind: "action",
|
|
53
|
+
label: strings.chrome.download,
|
|
54
|
+
icon: /* @__PURE__ */ jsx(DownloadIcon, {}),
|
|
55
|
+
onSelect: () => onExport(conv.id)
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
kind: "action",
|
|
59
|
+
label: t.delete,
|
|
60
|
+
icon: /* @__PURE__ */ jsx(TrashIcon, {}),
|
|
61
|
+
destructive: true,
|
|
62
|
+
onSelect: () => onDelete(conv)
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
return /* @__PURE__ */ jsx(SidebarRow, {
|
|
66
|
+
selected: isCurrent,
|
|
67
|
+
menuItems,
|
|
68
|
+
openMenu,
|
|
69
|
+
children: /* @__PURE__ */ jsxs(LinkComponent, {
|
|
70
|
+
target: {
|
|
71
|
+
kind: "conversation",
|
|
72
|
+
id: conv.id
|
|
73
|
+
},
|
|
74
|
+
className: "flex min-w-0 flex-1 items-center gap-1.5 py-1 text-left",
|
|
75
|
+
children: [conv.isOwner === false && /* @__PURE__ */ jsx(SharingIcon, {
|
|
76
|
+
className: "h-3 w-3 shrink-0 theme-muted-text",
|
|
77
|
+
title: t.sharedWithYou
|
|
78
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
79
|
+
className: "min-w-0 flex-1 truncate text-sm theme-text",
|
|
80
|
+
children: conv.title || t.untitled
|
|
81
|
+
})]
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
var SIDEBAR_WIDTH_STORAGE_KEY = "aiChatSidebarWidth";
|
|
86
|
+
var SIDEBAR_MIN_WIDTH_PX = 200;
|
|
87
|
+
var SIDEBAR_MAX_WIDTH_PX = 480;
|
|
88
|
+
var SIDEBAR_DEFAULT_WIDTH_PX = 256;
|
|
89
|
+
function clampSidebarWidth(width) {
|
|
90
|
+
return Math.min(SIDEBAR_MAX_WIDTH_PX, Math.max(SIDEBAR_MIN_WIDTH_PX, width));
|
|
91
|
+
}
|
|
92
|
+
function readStoredSidebarWidth() {
|
|
93
|
+
try {
|
|
94
|
+
const stored = Number(window.localStorage.getItem(SIDEBAR_WIDTH_STORAGE_KEY));
|
|
95
|
+
return Number.isFinite(stored) && stored > 0 ? clampSidebarWidth(stored) : SIDEBAR_DEFAULT_WIDTH_PX;
|
|
96
|
+
} catch {
|
|
97
|
+
return SIDEBAR_DEFAULT_WIDTH_PX;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function storeSidebarWidth(width) {
|
|
101
|
+
try {
|
|
102
|
+
window.localStorage.setItem(SIDEBAR_WIDTH_STORAGE_KEY, String(width));
|
|
103
|
+
} catch {}
|
|
104
|
+
}
|
|
105
|
+
function useResizableSidebarWidth() {
|
|
106
|
+
const [width, setWidth] = useState(readStoredSidebarWidth);
|
|
107
|
+
const [resizing, setResizing] = useState(false);
|
|
108
|
+
const widthRef = useRef(width);
|
|
109
|
+
widthRef.current = width;
|
|
110
|
+
const startResize = (e) => {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
const startX = e.clientX;
|
|
113
|
+
const startWidth = widthRef.current;
|
|
114
|
+
setResizing(true);
|
|
115
|
+
const onMove = (ev) => {
|
|
116
|
+
setWidth(clampSidebarWidth(startWidth + ev.clientX - startX));
|
|
117
|
+
};
|
|
118
|
+
const onUp = () => {
|
|
119
|
+
window.removeEventListener("pointermove", onMove);
|
|
120
|
+
window.removeEventListener("pointerup", onUp);
|
|
121
|
+
setResizing(false);
|
|
122
|
+
storeSidebarWidth(widthRef.current);
|
|
123
|
+
};
|
|
124
|
+
window.addEventListener("pointermove", onMove);
|
|
125
|
+
window.addEventListener("pointerup", onUp);
|
|
126
|
+
};
|
|
127
|
+
const reset = () => {
|
|
128
|
+
setWidth(SIDEBAR_DEFAULT_WIDTH_PX);
|
|
129
|
+
storeSidebarWidth(SIDEBAR_DEFAULT_WIDTH_PX);
|
|
130
|
+
};
|
|
131
|
+
const nudge = (delta) => {
|
|
132
|
+
const next = clampSidebarWidth(widthRef.current + delta);
|
|
133
|
+
setWidth(next);
|
|
134
|
+
storeSidebarWidth(next);
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
width,
|
|
138
|
+
resizing,
|
|
139
|
+
startResize,
|
|
140
|
+
reset,
|
|
141
|
+
nudge
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function ChatSidebar({ actions = true }) {
|
|
145
|
+
const { extraLinks, LinkComponent, strings } = useChatConfig();
|
|
146
|
+
const tSidebar = strings.sidebar;
|
|
147
|
+
const { adapter, navigation, notify, activeConversationId, conversations, sidebarCollapsed, toggleSidebar, isLoading, loadConversations, deleteConversation, updateConversationTitle, clearCurrentConversation } = useChat();
|
|
148
|
+
const sharingAvailable = !!adapter.sharing;
|
|
149
|
+
const attachmentsAvailable = !!adapter.attachments;
|
|
150
|
+
const [shareDialogOpen, setShareDialogOpen] = useState(false);
|
|
151
|
+
const [conversationToShare, setConversationToShare] = useState(null);
|
|
152
|
+
const { openMenu, contextMenu } = useRowMenu();
|
|
153
|
+
const { requestDelete, requestRename, dialogs } = useRowDialogs({
|
|
154
|
+
strings: {
|
|
155
|
+
deleteTitle: tSidebar.deleteTitle,
|
|
156
|
+
deleteBody: () => tSidebar.deleteBody,
|
|
157
|
+
deleteAction: tSidebar.deleteAction,
|
|
158
|
+
renameTitle: tSidebar.renameTitle,
|
|
159
|
+
renameLabel: tSidebar.renameLabel,
|
|
160
|
+
renamePlaceholder: tSidebar.renamePlaceholder,
|
|
161
|
+
renameAction: tSidebar.renameAction
|
|
162
|
+
},
|
|
163
|
+
nameOf: (conv) => conv.title || tSidebar.untitled,
|
|
164
|
+
onDelete: (conv) => deleteConversation(conv.id),
|
|
165
|
+
onRename: (conv, title) => updateConversationTitle(conv.id, title)
|
|
166
|
+
});
|
|
167
|
+
const { width: sidebarWidth, resizing, startResize, reset: resetSidebarWidth, nudge: nudgeSidebarWidth } = useResizableSidebarWidth();
|
|
168
|
+
const [search, setSearch] = useState("");
|
|
169
|
+
const searchInputRef = useRef(null);
|
|
170
|
+
const sidebarCollapsedRef = useRef(sidebarCollapsed);
|
|
171
|
+
sidebarCollapsedRef.current = sidebarCollapsed;
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
loadConversations();
|
|
174
|
+
}, [loadConversations]);
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
if (!actions) return;
|
|
177
|
+
const focusSearch = () => {
|
|
178
|
+
if (sidebarCollapsedRef.current) toggleSidebar();
|
|
179
|
+
requestAnimationFrame(() => searchInputRef.current?.focus());
|
|
180
|
+
};
|
|
181
|
+
document.addEventListener(FOCUS_SIDEBAR_SEARCH_EVENT, focusSearch);
|
|
182
|
+
return () => document.removeEventListener(FOCUS_SIDEBAR_SEARCH_EVENT, focusSearch);
|
|
183
|
+
}, [actions, toggleSidebar]);
|
|
184
|
+
const filteredConversations = useMemo(() => {
|
|
185
|
+
const query = search.trim().toLowerCase();
|
|
186
|
+
if (!query) return conversations;
|
|
187
|
+
return conversations.filter((conv) => (conv.title || tSidebar.untitled).toLowerCase().includes(query));
|
|
188
|
+
}, [
|
|
189
|
+
conversations,
|
|
190
|
+
search,
|
|
191
|
+
tSidebar.untitled
|
|
192
|
+
]);
|
|
193
|
+
const groupedConversations = useMemo(() => groupByDate(filteredConversations), [filteredConversations]);
|
|
194
|
+
const handleExport = async (id) => {
|
|
195
|
+
try {
|
|
196
|
+
const conversation = await adapter.conversations.get(id);
|
|
197
|
+
downloadText(exportFilename(conversation.title), conversationToMarkdown(conversation));
|
|
198
|
+
} catch {
|
|
199
|
+
notify.error(strings.chrome.exportError);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
const handleShareClick = (id) => {
|
|
203
|
+
setConversationToShare(id);
|
|
204
|
+
setShareDialogOpen(true);
|
|
205
|
+
};
|
|
206
|
+
const handleNewChat = () => {
|
|
207
|
+
clearCurrentConversation();
|
|
208
|
+
navigation.toNewChat();
|
|
209
|
+
};
|
|
210
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
211
|
+
/* @__PURE__ */ jsxs(SidebarPanel, {
|
|
212
|
+
collapsed: sidebarCollapsed,
|
|
213
|
+
width: sidebarWidth,
|
|
214
|
+
railWidth: 48,
|
|
215
|
+
resizing,
|
|
216
|
+
children: [
|
|
217
|
+
!sidebarCollapsed && /* @__PURE__ */ jsx("div", {
|
|
218
|
+
role: "separator",
|
|
219
|
+
tabIndex: 0,
|
|
220
|
+
"aria-orientation": "vertical",
|
|
221
|
+
"aria-label": "Resize conversation list",
|
|
222
|
+
"aria-valuemin": SIDEBAR_MIN_WIDTH_PX,
|
|
223
|
+
"aria-valuemax": SIDEBAR_MAX_WIDTH_PX,
|
|
224
|
+
"aria-valuenow": sidebarWidth,
|
|
225
|
+
title: "Drag to resize; double-click to reset",
|
|
226
|
+
onPointerDown: startResize,
|
|
227
|
+
onDoubleClick: resetSidebarWidth,
|
|
228
|
+
onKeyDown: (e) => {
|
|
229
|
+
if (e.key === "ArrowLeft") nudgeSidebarWidth(-16);
|
|
230
|
+
else if (e.key === "ArrowRight") nudgeSidebarWidth(16);
|
|
231
|
+
},
|
|
232
|
+
className: cx("absolute inset-y-0 right-0 z-10 w-1 cursor-col-resize touch-none", resizing ? "bg-(--theme-element)" : "hover:bg-(--theme-border)")
|
|
233
|
+
}),
|
|
234
|
+
actions && /* @__PURE__ */ jsxs("div", {
|
|
235
|
+
className: "flex flex-col gap-1 p-1.5",
|
|
236
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
237
|
+
type: "button",
|
|
238
|
+
onClick: handleNewChat,
|
|
239
|
+
className: cx("flex items-center h-9 px-2 gap-3 rounded-lg hover:theme-muted-panel", "transition-colors", !sidebarCollapsed && "border theme-border"),
|
|
240
|
+
title: tSidebar.newChat,
|
|
241
|
+
children: [/* @__PURE__ */ jsx(NewChatIcon, { className: cx("flex-shrink-0", "w-4 h-4") }), /* @__PURE__ */ jsx("span", {
|
|
242
|
+
className: cx("text-sm transition-opacity duration-200", sidebarCollapsed ? "opacity-0 w-0 overflow-hidden" : "opacity-100"),
|
|
243
|
+
children: tSidebar.newChat
|
|
244
|
+
})]
|
|
245
|
+
}), attachmentsAvailable && /* @__PURE__ */ jsxs(LinkComponent, {
|
|
246
|
+
target: { kind: "attachments" },
|
|
247
|
+
className: "flex items-center h-9 px-2 gap-3 rounded-lg hover:theme-muted-panel",
|
|
248
|
+
title: tSidebar.attachments,
|
|
249
|
+
children: [/* @__PURE__ */ jsx(ImageIcon, { className: "flex-shrink-0 w-4 h-4" }), /* @__PURE__ */ jsx("span", {
|
|
250
|
+
className: cx("text-sm transition-opacity duration-200", sidebarCollapsed ? "opacity-0 w-0 overflow-hidden" : "opacity-100"),
|
|
251
|
+
children: tSidebar.attachments
|
|
252
|
+
})]
|
|
253
|
+
})]
|
|
254
|
+
}),
|
|
255
|
+
actions && !sidebarCollapsed && conversations.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
256
|
+
className: "px-2 pb-1",
|
|
257
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
258
|
+
className: "relative",
|
|
259
|
+
children: [/* @__PURE__ */ jsx(SearchIcon, { className: "absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 theme-muted-text pointer-events-none" }), /* @__PURE__ */ jsx("input", {
|
|
260
|
+
ref: searchInputRef,
|
|
261
|
+
type: "text",
|
|
262
|
+
value: search,
|
|
263
|
+
onChange: (e) => setSearch(e.target.value),
|
|
264
|
+
onKeyDown: (e) => {
|
|
265
|
+
if (e.key === "Escape" && search) {
|
|
266
|
+
e.stopPropagation();
|
|
267
|
+
setSearch("");
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
placeholder: strings.chrome.searchPlaceholder,
|
|
271
|
+
"aria-label": strings.chrome.searchLabel,
|
|
272
|
+
className: "w-full h-8 pl-8 pr-2 text-sm rounded-lg border theme-border bg-(--theme-input-bg) placeholder:theme-muted-text focus:outline-none focus:border-(--theme-element)"
|
|
273
|
+
})]
|
|
274
|
+
})
|
|
275
|
+
}),
|
|
276
|
+
/* @__PURE__ */ jsx("div", {
|
|
277
|
+
className: cx("min-h-0 flex-1 overflow-y-auto px-2 pb-2 transition-opacity duration-200", sidebarCollapsed ? "opacity-0 pointer-events-none" : "opacity-100"),
|
|
278
|
+
children: isLoading ? /* @__PURE__ */ jsx("div", {
|
|
279
|
+
className: "space-y-3 px-2 pt-2",
|
|
280
|
+
children: positionKeys(5, "skeleton").map((key, i) => /* @__PURE__ */ jsx("div", {
|
|
281
|
+
className: "animate-pulse",
|
|
282
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
283
|
+
className: "h-4 rounded theme-muted-panel",
|
|
284
|
+
style: { width: `${70 - i * 10}%` }
|
|
285
|
+
})
|
|
286
|
+
}, key))
|
|
287
|
+
}) : conversations.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
288
|
+
className: "theme-muted-text text-sm px-2 whitespace-nowrap",
|
|
289
|
+
children: tSidebar.noConversations
|
|
290
|
+
}) : filteredConversations.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
291
|
+
className: "theme-muted-text text-sm px-2",
|
|
292
|
+
children: strings.chrome.noMatches
|
|
293
|
+
}) : groupedConversations.map(([label, convs]) => /* @__PURE__ */ jsxs("div", {
|
|
294
|
+
className: "mb-2",
|
|
295
|
+
children: [/* @__PURE__ */ jsx(SidebarGroupHeading, { children: tSidebar[label] }), /* @__PURE__ */ jsx("ul", {
|
|
296
|
+
className: "space-y-0.5",
|
|
297
|
+
children: convs.map((conv) => /* @__PURE__ */ jsx(ConversationRow, {
|
|
298
|
+
conv,
|
|
299
|
+
isCurrent: activeConversationId === conv.id,
|
|
300
|
+
sharingAvailable,
|
|
301
|
+
openMenu,
|
|
302
|
+
onRename: requestRename,
|
|
303
|
+
onShare: handleShareClick,
|
|
304
|
+
onDelete: requestDelete,
|
|
305
|
+
onExport: handleExport
|
|
306
|
+
}, conv.id))
|
|
307
|
+
})]
|
|
308
|
+
}, label))
|
|
309
|
+
}),
|
|
310
|
+
/* @__PURE__ */ jsxs("div", {
|
|
311
|
+
className: cx("flex shrink-0 items-center gap-1 p-1.5", sidebarCollapsed ? "justify-center" : extraLinks.manageProviders ? "justify-between" : "justify-end"),
|
|
312
|
+
children: [!sidebarCollapsed && extraLinks.manageProviders && /* @__PURE__ */ jsxs(LinkComponent, {
|
|
313
|
+
target: {
|
|
314
|
+
kind: "external",
|
|
315
|
+
href: extraLinks.manageProviders
|
|
316
|
+
},
|
|
317
|
+
className: "flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-xs theme-muted-text hover:theme-hover",
|
|
318
|
+
title: tSidebar.manageProviders,
|
|
319
|
+
children: [/* @__PURE__ */ jsx(SettingsIcon, { className: "h-3.5 w-3.5 shrink-0" }), /* @__PURE__ */ jsx("span", {
|
|
320
|
+
className: "truncate",
|
|
321
|
+
children: tSidebar.manageProviders
|
|
322
|
+
})]
|
|
323
|
+
}), /* @__PURE__ */ jsx(SidebarToggle, {
|
|
324
|
+
collapsed: sidebarCollapsed,
|
|
325
|
+
onToggle: toggleSidebar,
|
|
326
|
+
openLabel: tSidebar.openSidebar,
|
|
327
|
+
closeLabel: tSidebar.closeSidebar
|
|
328
|
+
})]
|
|
329
|
+
})
|
|
330
|
+
]
|
|
331
|
+
}),
|
|
332
|
+
contextMenu,
|
|
333
|
+
dialogs,
|
|
334
|
+
conversationToShare && /* @__PURE__ */ jsx(ShareDialog, {
|
|
335
|
+
conversationId: conversationToShare,
|
|
336
|
+
isOpen: shareDialogOpen,
|
|
337
|
+
onClose: () => {
|
|
338
|
+
setShareDialogOpen(false);
|
|
339
|
+
setConversationToShare(null);
|
|
340
|
+
}
|
|
341
|
+
})
|
|
342
|
+
] });
|
|
343
|
+
}
|
|
344
|
+
//#endregion
|
|
345
|
+
export { ChatSidebar as default };
|