@nocturnium/svelte-ide 1.0.0-rc.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/LICENSE +21 -0
- package/README.md +251 -0
- package/dist/components/agents/AgentActivityPanel.svelte +565 -0
- package/dist/components/agents/AgentActivityPanel.svelte.d.ts +24 -0
- package/dist/components/agents/AgentAvatar.svelte +417 -0
- package/dist/components/agents/AgentAvatar.svelte.d.ts +23 -0
- package/dist/components/agents/AgentCursor.svelte +224 -0
- package/dist/components/agents/AgentCursor.svelte.d.ts +35 -0
- package/dist/components/agents/AgentPresenceBar.svelte +261 -0
- package/dist/components/agents/AgentPresenceBar.svelte.d.ts +20 -0
- package/dist/components/agents/index.d.ts +4 -0
- package/dist/components/agents/index.js +5 -0
- package/dist/components/ai/AIConversationList.svelte +524 -0
- package/dist/components/ai/AIConversationList.svelte.d.ts +17 -0
- package/dist/components/ai/AIEditPreview.svelte +132 -0
- package/dist/components/ai/AIEditPreview.svelte.d.ts +8 -0
- package/dist/components/ai/AIInlineEdit.svelte +155 -0
- package/dist/components/ai/AIInlineEdit.svelte.d.ts +10 -0
- package/dist/components/ai/AIMessage.svelte +239 -0
- package/dist/components/ai/AIMessage.svelte.d.ts +13 -0
- package/dist/components/ai/AIMessageActions.svelte +176 -0
- package/dist/components/ai/AIMessageActions.svelte.d.ts +12 -0
- package/dist/components/ai/AIMessageContent.svelte +355 -0
- package/dist/components/ai/AIMessageContent.svelte.d.ts +7 -0
- package/dist/components/ai/AIPanel.svelte +561 -0
- package/dist/components/ai/AIPanel.svelte.d.ts +7 -0
- package/dist/components/ai/AISuggestionWidget.svelte +132 -0
- package/dist/components/ai/AISuggestionWidget.svelte.d.ts +10 -0
- package/dist/components/ai/AIToolCallDisplay.svelte +317 -0
- package/dist/components/ai/AIToolCallDisplay.svelte.d.ts +12 -0
- package/dist/components/ai/index.d.ts +9 -0
- package/dist/components/ai/index.js +10 -0
- package/dist/components/core/Avatar.svelte +110 -0
- package/dist/components/core/Avatar.svelte.d.ts +12 -0
- package/dist/components/core/Badge.svelte +98 -0
- package/dist/components/core/Badge.svelte.d.ts +11 -0
- package/dist/components/core/Button.svelte +175 -0
- package/dist/components/core/Button.svelte.d.ts +18 -0
- package/dist/components/core/ConnectionStatus.svelte +294 -0
- package/dist/components/core/ConnectionStatus.svelte.d.ts +20 -0
- package/dist/components/core/ContextMenu.svelte +176 -0
- package/dist/components/core/ContextMenu.svelte.d.ts +19 -0
- package/dist/components/core/ErrorBoundary.svelte +277 -0
- package/dist/components/core/ErrorBoundary.svelte.d.ts +23 -0
- package/dist/components/core/Icon.svelte +107 -0
- package/dist/components/core/Icon.svelte.d.ts +8 -0
- package/dist/components/core/Input.svelte +138 -0
- package/dist/components/core/Input.svelte.d.ts +20 -0
- package/dist/components/core/Kbd.svelte +34 -0
- package/dist/components/core/Kbd.svelte.d.ts +7 -0
- package/dist/components/core/ResizeHandle.svelte +200 -0
- package/dist/components/core/ResizeHandle.svelte.d.ts +23 -0
- package/dist/components/core/Spinner.svelte +35 -0
- package/dist/components/core/Spinner.svelte.d.ts +7 -0
- package/dist/components/core/Textarea.svelte +112 -0
- package/dist/components/core/Textarea.svelte.d.ts +18 -0
- package/dist/components/core/Tooltip.svelte +103 -0
- package/dist/components/core/Tooltip.svelte.d.ts +11 -0
- package/dist/components/core/index.d.ts +13 -0
- package/dist/components/core/index.js +14 -0
- package/dist/components/editor/AIFocusLayer.svelte +430 -0
- package/dist/components/editor/AIFocusLayer.svelte.d.ts +32 -0
- package/dist/components/editor/Breadcrumbs.svelte +435 -0
- package/dist/components/editor/Breadcrumbs.svelte.d.ts +33 -0
- package/dist/components/editor/BreakpointLayer.svelte +642 -0
- package/dist/components/editor/BreakpointLayer.svelte.d.ts +20 -0
- package/dist/components/editor/CognitiveLoadMeter.svelte +324 -0
- package/dist/components/editor/CognitiveLoadMeter.svelte.d.ts +18 -0
- package/dist/components/editor/CollaborativeEditor.svelte +218 -0
- package/dist/components/editor/CollaborativeEditor.svelte.d.ts +32 -0
- package/dist/components/editor/CommandPalette.svelte +434 -0
- package/dist/components/editor/CommandPalette.svelte.d.ts +11 -0
- package/dist/components/editor/ComplexityLayer.svelte +293 -0
- package/dist/components/editor/ComplexityLayer.svelte.d.ts +23 -0
- package/dist/components/editor/ConflictZoneLayer.svelte +441 -0
- package/dist/components/editor/ConflictZoneLayer.svelte.d.ts +25 -0
- package/dist/components/editor/ContextLens.svelte +262 -0
- package/dist/components/editor/ContextLens.svelte.d.ts +27 -0
- package/dist/components/editor/CustomEditor.svelte +1242 -0
- package/dist/components/editor/CustomEditor.svelte.d.ts +37 -0
- package/dist/components/editor/DebugConsole.svelte +646 -0
- package/dist/components/editor/DebugConsole.svelte.d.ts +41 -0
- package/dist/components/editor/EchoCursorLayer.svelte +363 -0
- package/dist/components/editor/EchoCursorLayer.svelte.d.ts +24 -0
- package/dist/components/editor/Editor.svelte +61 -0
- package/dist/components/editor/Editor.svelte.d.ts +22 -0
- package/dist/components/editor/EditorGutter.svelte +119 -0
- package/dist/components/editor/EditorGutter.svelte.d.ts +19 -0
- package/dist/components/editor/EditorLines.svelte +182 -0
- package/dist/components/editor/EditorLines.svelte.d.ts +43 -0
- package/dist/components/editor/EditorPane.svelte +134 -0
- package/dist/components/editor/EditorPane.svelte.d.ts +9 -0
- package/dist/components/editor/EditorSelections.svelte +186 -0
- package/dist/components/editor/EditorSelections.svelte.d.ts +25 -0
- package/dist/components/editor/EditorTabs.svelte +170 -0
- package/dist/components/editor/EditorTabs.svelte.d.ts +12 -0
- package/dist/components/editor/FileExplorer.svelte +811 -0
- package/dist/components/editor/FileExplorer.svelte.d.ts +67 -0
- package/dist/components/editor/FileIcon.svelte +110 -0
- package/dist/components/editor/FileIcon.svelte.d.ts +10 -0
- package/dist/components/editor/FindReplace.svelte +448 -0
- package/dist/components/editor/FindReplace.svelte.d.ts +40 -0
- package/dist/components/editor/GhostBracketLayer.svelte +391 -0
- package/dist/components/editor/GhostBracketLayer.svelte.d.ts +24 -0
- package/dist/components/editor/GitBlameLayer.svelte +436 -0
- package/dist/components/editor/GitBlameLayer.svelte.d.ts +18 -0
- package/dist/components/editor/InlineDiagnosticsLayer.svelte +540 -0
- package/dist/components/editor/InlineDiagnosticsLayer.svelte.d.ts +35 -0
- package/dist/components/editor/InlineDiffLayer.svelte +337 -0
- package/dist/components/editor/InlineDiffLayer.svelte.d.ts +31 -0
- package/dist/components/editor/MinimalEditor.svelte +75 -0
- package/dist/components/editor/MinimalEditor.svelte.d.ts +6 -0
- package/dist/components/editor/MinimalEditor2.svelte +84 -0
- package/dist/components/editor/MinimalEditor2.svelte.d.ts +6 -0
- package/dist/components/editor/Minimap.svelte +327 -0
- package/dist/components/editor/Minimap.svelte.d.ts +34 -0
- package/dist/components/editor/PluginPreviewSandbox.svelte +793 -0
- package/dist/components/editor/PluginPreviewSandbox.svelte.d.ts +49 -0
- package/dist/components/editor/ProblemsPanel.svelte +628 -0
- package/dist/components/editor/ProblemsPanel.svelte.d.ts +25 -0
- package/dist/components/editor/QuickActionsMenu.svelte +403 -0
- package/dist/components/editor/QuickActionsMenu.svelte.d.ts +18 -0
- package/dist/components/editor/SnippetPalette.svelte +530 -0
- package/dist/components/editor/SnippetPalette.svelte.d.ts +16 -0
- package/dist/components/editor/StructureMap.svelte +431 -0
- package/dist/components/editor/StructureMap.svelte.d.ts +37 -0
- package/dist/components/editor/SymbolOutline.svelte +722 -0
- package/dist/components/editor/SymbolOutline.svelte.d.ts +44 -0
- package/dist/components/editor/TimelineScrubber.svelte +470 -0
- package/dist/components/editor/TimelineScrubber.svelte.d.ts +40 -0
- package/dist/components/editor/TokenRenderer.svelte +69 -0
- package/dist/components/editor/TokenRenderer.svelte.d.ts +15 -0
- package/dist/components/editor/constants.d.ts +32 -0
- package/dist/components/editor/constants.js +36 -0
- package/dist/components/editor/core/ai-awareness.d.ts +176 -0
- package/dist/components/editor/core/ai-awareness.js +210 -0
- package/dist/components/editor/core/bracket-healer.d.ts +189 -0
- package/dist/components/editor/core/bracket-healer.js +406 -0
- package/dist/components/editor/core/breakpoints.d.ts +203 -0
- package/dist/components/editor/core/breakpoints.js +414 -0
- package/dist/components/editor/core/commands.d.ts +108 -0
- package/dist/components/editor/core/commands.js +246 -0
- package/dist/components/editor/core/complexity-analyzer.d.ts +123 -0
- package/dist/components/editor/core/complexity-analyzer.js +376 -0
- package/dist/components/editor/core/conflict-predictor.d.ts +135 -0
- package/dist/components/editor/core/conflict-predictor.js +316 -0
- package/dist/components/editor/core/crdt-binding.d.ts +118 -0
- package/dist/components/editor/core/crdt-binding.js +286 -0
- package/dist/components/editor/core/diagnostics.d.ts +210 -0
- package/dist/components/editor/core/diagnostics.js +335 -0
- package/dist/components/editor/core/echo-cursor.d.ts +201 -0
- package/dist/components/editor/core/echo-cursor.js +267 -0
- package/dist/components/editor/core/folding.d.ts +124 -0
- package/dist/components/editor/core/folding.js +672 -0
- package/dist/components/editor/core/ghost-pair.d.ts +122 -0
- package/dist/components/editor/core/ghost-pair.js +221 -0
- package/dist/components/editor/core/git-blame.d.ts +170 -0
- package/dist/components/editor/core/git-blame.js +324 -0
- package/dist/components/editor/core/index.d.ts +26 -0
- package/dist/components/editor/core/index.js +24 -0
- package/dist/components/editor/core/keybindings.d.ts +79 -0
- package/dist/components/editor/core/keybindings.js +357 -0
- package/dist/components/editor/core/multi-cursor.d.ts +196 -0
- package/dist/components/editor/core/multi-cursor.js +521 -0
- package/dist/components/editor/core/navigation.d.ts +107 -0
- package/dist/components/editor/core/navigation.js +408 -0
- package/dist/components/editor/core/quick-actions.d.ts +189 -0
- package/dist/components/editor/core/quick-actions.js +427 -0
- package/dist/components/editor/core/search.d.ts +88 -0
- package/dist/components/editor/core/search.js +192 -0
- package/dist/components/editor/core/semantic-analyzer.d.ts +77 -0
- package/dist/components/editor/core/semantic-analyzer.js +424 -0
- package/dist/components/editor/core/snippet-manager.d.ts +202 -0
- package/dist/components/editor/core/snippet-manager.js +565 -0
- package/dist/components/editor/core/state.d.ts +367 -0
- package/dist/components/editor/core/state.js +900 -0
- package/dist/components/editor/core/timeline.d.ts +204 -0
- package/dist/components/editor/core/timeline.js +349 -0
- package/dist/components/editor/editor-find.d.ts +56 -0
- package/dist/components/editor/editor-find.js +148 -0
- package/dist/components/editor/editor-input.d.ts +77 -0
- package/dist/components/editor/editor-input.js +445 -0
- package/dist/components/editor/editor-multicursor.d.ts +21 -0
- package/dist/components/editor/editor-multicursor.js +196 -0
- package/dist/components/editor/editor-scroll.d.ts +14 -0
- package/dist/components/editor/editor-scroll.js +34 -0
- package/dist/components/editor/index.d.ts +15 -0
- package/dist/components/editor/index.js +21 -0
- package/dist/components/editor/languages.d.ts +62 -0
- package/dist/components/editor/languages.js +285 -0
- package/dist/components/editor/theme.d.ts +88 -0
- package/dist/components/editor/theme.js +139 -0
- package/dist/components/editor/tokenizer/base.d.ts +40 -0
- package/dist/components/editor/tokenizer/base.js +203 -0
- package/dist/components/editor/tokenizer/index.d.ts +56 -0
- package/dist/components/editor/tokenizer/index.js +215 -0
- package/dist/components/editor/tokenizer/languages/css.d.ts +17 -0
- package/dist/components/editor/tokenizer/languages/css.js +194 -0
- package/dist/components/editor/tokenizer/languages/go.d.ts +17 -0
- package/dist/components/editor/tokenizer/languages/go.js +220 -0
- package/dist/components/editor/tokenizer/languages/html.d.ts +24 -0
- package/dist/components/editor/tokenizer/languages/html.js +145 -0
- package/dist/components/editor/tokenizer/languages/javascript.d.ts +56 -0
- package/dist/components/editor/tokenizer/languages/javascript.js +452 -0
- package/dist/components/editor/tokenizer/languages/json.d.ts +12 -0
- package/dist/components/editor/tokenizer/languages/json.js +91 -0
- package/dist/components/editor/tokenizer/languages/markdown.d.ts +16 -0
- package/dist/components/editor/tokenizer/languages/markdown.js +156 -0
- package/dist/components/editor/tokenizer/languages/python.d.ts +20 -0
- package/dist/components/editor/tokenizer/languages/python.js +227 -0
- package/dist/components/editor/tokenizer/languages/svelte.d.ts +40 -0
- package/dist/components/editor/tokenizer/languages/svelte.js +326 -0
- package/dist/components/editor/tokenizer/types.d.ts +86 -0
- package/dist/components/editor/tokenizer/types.js +4 -0
- package/dist/components/layout/IDELayout.svelte +274 -0
- package/dist/components/layout/IDELayout.svelte.d.ts +29 -0
- package/dist/components/layout/StatusBar.svelte +511 -0
- package/dist/components/layout/StatusBar.svelte.d.ts +47 -0
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/layout/index.js +3 -0
- package/dist/components/lsp/AutocompleteWidget.svelte +364 -0
- package/dist/components/lsp/AutocompleteWidget.svelte.d.ts +33 -0
- package/dist/components/lsp/DiagnosticMarker.svelte +166 -0
- package/dist/components/lsp/DiagnosticMarker.svelte.d.ts +19 -0
- package/dist/components/lsp/DiagnosticsPanel.svelte +388 -0
- package/dist/components/lsp/DiagnosticsPanel.svelte.d.ts +21 -0
- package/dist/components/lsp/HoverTooltip.svelte +274 -0
- package/dist/components/lsp/HoverTooltip.svelte.d.ts +24 -0
- package/dist/components/lsp/LSPEditor.svelte +486 -0
- package/dist/components/lsp/LSPEditor.svelte.d.ts +39 -0
- package/dist/components/lsp/SignatureHelpWidget.svelte +216 -0
- package/dist/components/lsp/SignatureHelpWidget.svelte.d.ts +22 -0
- package/dist/components/lsp/index.d.ts +6 -0
- package/dist/components/lsp/index.js +7 -0
- package/dist/components/plugins/PluginCard.svelte +153 -0
- package/dist/components/plugins/PluginCard.svelte.d.ts +19 -0
- package/dist/components/plugins/PluginPanel.svelte +280 -0
- package/dist/components/plugins/PluginPanel.svelte.d.ts +8 -0
- package/dist/components/plugins/PluginProposalForm.svelte +250 -0
- package/dist/components/plugins/PluginProposalForm.svelte.d.ts +6 -0
- package/dist/components/plugins/PluginStatusBadge.svelte +14 -0
- package/dist/components/plugins/PluginStatusBadge.svelte.d.ts +8 -0
- package/dist/components/plugins/index.d.ts +4 -0
- package/dist/components/plugins/index.js +5 -0
- package/dist/components/vfs/LockConflictDialog.svelte +705 -0
- package/dist/components/vfs/LockConflictDialog.svelte.d.ts +21 -0
- package/dist/components/vfs/LockIndicator.svelte +194 -0
- package/dist/components/vfs/LockIndicator.svelte.d.ts +29 -0
- package/dist/components/vfs/LockOverlay.svelte +344 -0
- package/dist/components/vfs/LockOverlay.svelte.d.ts +17 -0
- package/dist/components/vfs/VersionConflictDialog.svelte +549 -0
- package/dist/components/vfs/VersionConflictDialog.svelte.d.ts +24 -0
- package/dist/components/vfs/index.d.ts +4 -0
- package/dist/components/vfs/index.js +5 -0
- package/dist/crdt/awareness.d.ts +42 -0
- package/dist/crdt/awareness.js +109 -0
- package/dist/crdt/document.d.ts +101 -0
- package/dist/crdt/document.js +187 -0
- package/dist/crdt/index.d.ts +9 -0
- package/dist/crdt/index.js +8 -0
- package/dist/crdt/provider.d.ts +85 -0
- package/dist/crdt/provider.js +150 -0
- package/dist/crdt/types.d.ts +61 -0
- package/dist/crdt/types.js +4 -0
- package/dist/crdt/undo.d.ts +34 -0
- package/dist/crdt/undo.js +70 -0
- package/dist/index.d.ts +277 -0
- package/dist/index.js +280 -0
- package/dist/plugins/index.d.ts +103 -0
- package/dist/plugins/index.js +153 -0
- package/dist/services/error-handling.d.ts +95 -0
- package/dist/services/error-handling.js +413 -0
- package/dist/services/ide-integration.d.ts +83 -0
- package/dist/services/ide-integration.js +367 -0
- package/dist/services/lsp-client.d.ts +69 -0
- package/dist/services/lsp-client.js +667 -0
- package/dist/services/mock-ai.d.ts +37 -0
- package/dist/services/mock-ai.js +318 -0
- package/dist/services/optimistic.d.ts +141 -0
- package/dist/services/optimistic.js +367 -0
- package/dist/services/vfs-client.d.ts +81 -0
- package/dist/services/vfs-client.js +348 -0
- package/dist/stores/agents.svelte.d.ts +85 -0
- package/dist/stores/agents.svelte.js +459 -0
- package/dist/stores/ai-persistence.svelte.d.ts +76 -0
- package/dist/stores/ai-persistence.svelte.js +334 -0
- package/dist/stores/ai.svelte.d.ts +140 -0
- package/dist/stores/ai.svelte.js +383 -0
- package/dist/stores/collaboration.svelte.d.ts +164 -0
- package/dist/stores/collaboration.svelte.js +334 -0
- package/dist/stores/editor.svelte.d.ts +131 -0
- package/dist/stores/editor.svelte.js +250 -0
- package/dist/stores/index.d.ts +10 -0
- package/dist/stores/index.js +29 -0
- package/dist/stores/layout.svelte.d.ts +171 -0
- package/dist/stores/layout.svelte.js +351 -0
- package/dist/stores/plugin.svelte.d.ts +121 -0
- package/dist/stores/plugin.svelte.js +410 -0
- package/dist/stores/vfs.svelte.d.ts +123 -0
- package/dist/stores/vfs.svelte.js +680 -0
- package/dist/styles/theme.css +623 -0
- package/dist/types/agents.d.ts +127 -0
- package/dist/types/agents.js +5 -0
- package/dist/types/ai.d.ts +137 -0
- package/dist/types/ai.js +4 -0
- package/dist/types/crdt.d.ts +222 -0
- package/dist/types/crdt.js +5 -0
- package/dist/types/editor.d.ts +52 -0
- package/dist/types/editor.js +18 -0
- package/dist/types/events.d.ts +133 -0
- package/dist/types/events.js +4 -0
- package/dist/types/filesystem.d.ts +77 -0
- package/dist/types/filesystem.js +4 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +12 -0
- package/dist/types/lsp.d.ts +691 -0
- package/dist/types/lsp.js +108 -0
- package/dist/types/plugin.d.ts +239 -0
- package/dist/types/plugin.js +5 -0
- package/dist/types/vfs.d.ts +191 -0
- package/dist/types/vfs.js +18 -0
- package/dist/utils/format.d.ts +55 -0
- package/dist/utils/format.js +152 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/keybindings.d.ts +33 -0
- package/dist/utils/keybindings.js +171 -0
- package/dist/utils/language.d.ts +27 -0
- package/dist/utils/language.js +222 -0
- package/package.json +178 -0
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import { Button, Icon, Spinner, Avatar } from '../core';
|
|
4
|
+
import {
|
|
5
|
+
getMessages,
|
|
6
|
+
getIsStreaming,
|
|
7
|
+
sendMessage,
|
|
8
|
+
createConversation,
|
|
9
|
+
deleteConversation as deleteConv,
|
|
10
|
+
getConversations,
|
|
11
|
+
getActiveConversationId,
|
|
12
|
+
setActiveConversation,
|
|
13
|
+
getActiveConversation,
|
|
14
|
+
getError,
|
|
15
|
+
clearError
|
|
16
|
+
} from '../../stores/ai.svelte';
|
|
17
|
+
import {
|
|
18
|
+
initPersistence,
|
|
19
|
+
saveConversation,
|
|
20
|
+
loadConversations,
|
|
21
|
+
deleteConversation as deletePersisted,
|
|
22
|
+
toggleStarConversation,
|
|
23
|
+
exportConversationMarkdown,
|
|
24
|
+
exportConversationJSON
|
|
25
|
+
} from '../../stores/ai-persistence.svelte';
|
|
26
|
+
import AIMessage from './AIMessage.svelte';
|
|
27
|
+
import AIConversationList from './AIConversationList.svelte';
|
|
28
|
+
import type { AIConversation, AIMessage as AIMessageType } from '../../types';
|
|
29
|
+
|
|
30
|
+
interface Props {
|
|
31
|
+
class?: string;
|
|
32
|
+
showSidebar?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let { class: className = '', showSidebar = false }: Props = $props();
|
|
36
|
+
|
|
37
|
+
let inputValue = $state('');
|
|
38
|
+
let messagesContainer: HTMLDivElement;
|
|
39
|
+
let textareaEl: HTMLTextAreaElement;
|
|
40
|
+
let sidebarOpen = $state(false);
|
|
41
|
+
|
|
42
|
+
// Sync with prop changes
|
|
43
|
+
$effect(() => {
|
|
44
|
+
sidebarOpen = showSidebar;
|
|
45
|
+
});
|
|
46
|
+
let persistedConversations = $state<AIConversation[]>([]);
|
|
47
|
+
|
|
48
|
+
// Auto-resize textarea without causing cursor jump
|
|
49
|
+
function autoResizeTextarea() {
|
|
50
|
+
if (!textareaEl) return;
|
|
51
|
+
// Set to auto first to get accurate scrollHeight, then clamp
|
|
52
|
+
textareaEl.style.height = 'auto';
|
|
53
|
+
textareaEl.style.height = Math.min(textareaEl.scrollHeight, 120) + 'px';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Reset textarea height after submit
|
|
57
|
+
function resetTextareaHeight() {
|
|
58
|
+
if (!textareaEl) return;
|
|
59
|
+
textareaEl.style.height = '';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Initialize persistence on mount
|
|
63
|
+
onMount(async () => {
|
|
64
|
+
await initPersistence();
|
|
65
|
+
persistedConversations = await loadConversations();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Auto-scroll to bottom when new messages arrive
|
|
69
|
+
$effect(() => {
|
|
70
|
+
if (messagesContainer && getMessages().length > 0) {
|
|
71
|
+
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Auto-save conversation when messages change
|
|
76
|
+
$effect(() => {
|
|
77
|
+
const conv = getActiveConversation();
|
|
78
|
+
if (conv && getMessages().length > 0) {
|
|
79
|
+
saveConversation(conv);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
let isSubmitting = $state(false);
|
|
84
|
+
|
|
85
|
+
async function handleSubmit() {
|
|
86
|
+
if (!inputValue.trim() || getIsStreaming() || isSubmitting) return;
|
|
87
|
+
|
|
88
|
+
const message = inputValue.trim();
|
|
89
|
+
inputValue = '';
|
|
90
|
+
isSubmitting = true;
|
|
91
|
+
resetTextareaHeight();
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
await sendMessage(message);
|
|
95
|
+
} finally {
|
|
96
|
+
isSubmitting = false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
101
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
handleSubmit();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function handleNewConversation() {
|
|
108
|
+
createConversation();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function handleSelectConversation(conv: AIConversation) {
|
|
112
|
+
setActiveConversation(conv.id);
|
|
113
|
+
if (window.innerWidth < 768) {
|
|
114
|
+
sidebarOpen = false;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function handleDeleteConversation(conv: AIConversation) {
|
|
119
|
+
deleteConv(conv.id);
|
|
120
|
+
await deletePersisted(conv.id);
|
|
121
|
+
persistedConversations = await loadConversations();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function handleRenameConversation(conv: AIConversation, newTitle: string) {
|
|
125
|
+
// Update in store and persistence
|
|
126
|
+
const updated = { ...conv, title: newTitle };
|
|
127
|
+
await saveConversation(updated);
|
|
128
|
+
persistedConversations = await loadConversations();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function handleStarConversation(conv: AIConversation, starred: boolean) {
|
|
132
|
+
await toggleStarConversation(conv.id, starred);
|
|
133
|
+
persistedConversations = await loadConversations();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function handleExportConversation(conv: AIConversation, format: 'json' | 'md') {
|
|
137
|
+
const content = format === 'md' ? exportConversationMarkdown(conv) : exportConversationJSON(conv);
|
|
138
|
+
const blob = new Blob([content], { type: format === 'md' ? 'text/markdown' : 'application/json' });
|
|
139
|
+
const url = URL.createObjectURL(blob);
|
|
140
|
+
const a = document.createElement('a');
|
|
141
|
+
a.href = url;
|
|
142
|
+
a.download = `${conv.title.replace(/[^a-z0-9]/gi, '-').toLowerCase()}.${format === 'md' ? 'md' : 'json'}`;
|
|
143
|
+
a.click();
|
|
144
|
+
URL.revokeObjectURL(url);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function handleCopyMessage(msg: AIMessageType) {
|
|
148
|
+
navigator.clipboard.writeText(msg.content);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function handleRetryMessage(msg: AIMessageType) {
|
|
152
|
+
if (msg.role === 'user') {
|
|
153
|
+
inputValue = msg.content;
|
|
154
|
+
} else {
|
|
155
|
+
// Regenerate from last user message
|
|
156
|
+
const userMessages = getMessages().filter((m) => m.role === 'user');
|
|
157
|
+
const lastUserMessage = userMessages[userMessages.length - 1];
|
|
158
|
+
if (lastUserMessage) {
|
|
159
|
+
sendMessage(lastUserMessage.content);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Combine persisted and in-memory conversations
|
|
165
|
+
const allConversations = $derived.by(() => {
|
|
166
|
+
// Use in-memory conversations as source of truth, merge with persisted metadata
|
|
167
|
+
const convMap = new Map(persistedConversations.map((c) => [c.id, c]));
|
|
168
|
+
return getConversations().map((conv) => ({
|
|
169
|
+
...conv,
|
|
170
|
+
starred: (convMap.get(conv.id) as AIConversation & { starred?: boolean })?.starred || false
|
|
171
|
+
}));
|
|
172
|
+
});
|
|
173
|
+
</script>
|
|
174
|
+
|
|
175
|
+
<div class="ai-panel {className}" class:ai-panel--with-sidebar={sidebarOpen}>
|
|
176
|
+
<!-- Sidebar -->
|
|
177
|
+
{#if sidebarOpen}
|
|
178
|
+
<div class="ai-panel__sidebar">
|
|
179
|
+
<AIConversationList
|
|
180
|
+
conversations={allConversations}
|
|
181
|
+
activeId={getActiveConversationId()}
|
|
182
|
+
onSelect={handleSelectConversation}
|
|
183
|
+
onNew={handleNewConversation}
|
|
184
|
+
onDelete={handleDeleteConversation}
|
|
185
|
+
onRename={handleRenameConversation}
|
|
186
|
+
onStar={handleStarConversation}
|
|
187
|
+
onExport={handleExportConversation}
|
|
188
|
+
/>
|
|
189
|
+
</div>
|
|
190
|
+
{/if}
|
|
191
|
+
|
|
192
|
+
<!-- Main Panel -->
|
|
193
|
+
<div class="ai-panel__main">
|
|
194
|
+
<!-- Header -->
|
|
195
|
+
<div class="ai-panel__header">
|
|
196
|
+
<div class="ai-panel__header-left">
|
|
197
|
+
<Button
|
|
198
|
+
variant="ghost"
|
|
199
|
+
size="xs"
|
|
200
|
+
onclick={() => (sidebarOpen = !sidebarOpen)}
|
|
201
|
+
title={sidebarOpen ? 'Hide sidebar' : 'Show sidebar'}
|
|
202
|
+
>
|
|
203
|
+
<Icon name={sidebarOpen ? 'panel-left-close' : 'panel-left'} size={14} />
|
|
204
|
+
</Button>
|
|
205
|
+
<div class="ai-panel__title">
|
|
206
|
+
<Icon name="sparkles" size={16} />
|
|
207
|
+
<span>AI Assistant</span>
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
<div class="ai-panel__actions">
|
|
211
|
+
<Button variant="ghost" size="xs" onclick={handleNewConversation} title="New conversation">
|
|
212
|
+
<Icon name="plus" size={14} />
|
|
213
|
+
</Button>
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
<!-- Messages -->
|
|
218
|
+
<div class="ai-panel__messages" bind:this={messagesContainer} role="log" aria-live="polite" aria-label="Conversation messages">
|
|
219
|
+
{#if getMessages().length === 0}
|
|
220
|
+
<div class="ai-panel__empty">
|
|
221
|
+
<div class="ai-panel__empty-icon">
|
|
222
|
+
<Icon name="message-circle" size={40} />
|
|
223
|
+
</div>
|
|
224
|
+
<h3>Start a conversation</h3>
|
|
225
|
+
<p>Ask questions, request code changes, or get explanations about your code.</p>
|
|
226
|
+
<div class="ai-panel__suggestions">
|
|
227
|
+
<button class="suggestion-chip" onclick={() => (inputValue = 'Explain this code')}>
|
|
228
|
+
Explain this code
|
|
229
|
+
</button>
|
|
230
|
+
<button class="suggestion-chip" onclick={() => (inputValue = 'Find bugs in this file')}>
|
|
231
|
+
Find bugs
|
|
232
|
+
</button>
|
|
233
|
+
<button class="suggestion-chip" onclick={() => (inputValue = 'Write tests for this function')}>
|
|
234
|
+
Write tests
|
|
235
|
+
</button>
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
{:else}
|
|
239
|
+
{#each getMessages() as message (message.id)}
|
|
240
|
+
<AIMessage
|
|
241
|
+
{message}
|
|
242
|
+
onCopy={handleCopyMessage}
|
|
243
|
+
onRetry={handleRetryMessage}
|
|
244
|
+
/>
|
|
245
|
+
{/each}
|
|
246
|
+
{#if getIsStreaming()}
|
|
247
|
+
<div class="ai-panel__typing">
|
|
248
|
+
<Avatar name="AI" isAI size="sm" />
|
|
249
|
+
<div class="ai-panel__typing-indicator">
|
|
250
|
+
<span></span>
|
|
251
|
+
<span></span>
|
|
252
|
+
<span></span>
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
{/if}
|
|
256
|
+
{/if}
|
|
257
|
+
</div>
|
|
258
|
+
|
|
259
|
+
<!-- Error display -->
|
|
260
|
+
{#if getError()}
|
|
261
|
+
<div class="ai-panel__error">
|
|
262
|
+
<Icon name="alert-circle" size={14} />
|
|
263
|
+
<span>{getError()}</span>
|
|
264
|
+
<Button variant="ghost" size="xs" onclick={clearError}>
|
|
265
|
+
<Icon name="x" size={12} />
|
|
266
|
+
</Button>
|
|
267
|
+
</div>
|
|
268
|
+
{/if}
|
|
269
|
+
|
|
270
|
+
<!-- Input -->
|
|
271
|
+
<div class="ai-panel__input">
|
|
272
|
+
<textarea
|
|
273
|
+
bind:this={textareaEl}
|
|
274
|
+
bind:value={inputValue}
|
|
275
|
+
class="ai-panel__textarea"
|
|
276
|
+
placeholder="Ask AI anything... (Enter to send, Shift+Enter for new line)"
|
|
277
|
+
rows={1}
|
|
278
|
+
disabled={getIsStreaming() || isSubmitting}
|
|
279
|
+
onkeydown={handleKeydown}
|
|
280
|
+
oninput={autoResizeTextarea}
|
|
281
|
+
aria-label="Message input"
|
|
282
|
+
></textarea>
|
|
283
|
+
<Button
|
|
284
|
+
variant="primary"
|
|
285
|
+
size="sm"
|
|
286
|
+
disabled={!inputValue.trim() || getIsStreaming() || isSubmitting}
|
|
287
|
+
onclick={handleSubmit}
|
|
288
|
+
aria-label={getIsStreaming() || isSubmitting ? 'Sending message...' : 'Send message'}
|
|
289
|
+
>
|
|
290
|
+
{#if getIsStreaming() || isSubmitting}
|
|
291
|
+
<Spinner size="sm" />
|
|
292
|
+
{:else}
|
|
293
|
+
<Icon name="send" size={14} />
|
|
294
|
+
{/if}
|
|
295
|
+
</Button>
|
|
296
|
+
</div>
|
|
297
|
+
</div>
|
|
298
|
+
</div>
|
|
299
|
+
|
|
300
|
+
<style>
|
|
301
|
+
.ai-panel {
|
|
302
|
+
display: flex;
|
|
303
|
+
height: 100%;
|
|
304
|
+
background: var(--ide-bg-primary);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.ai-panel__sidebar {
|
|
308
|
+
width: 280px;
|
|
309
|
+
border-right: 1px solid var(--ide-border);
|
|
310
|
+
flex-shrink: 0;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.ai-panel__main {
|
|
314
|
+
flex: 1;
|
|
315
|
+
display: flex;
|
|
316
|
+
flex-direction: column;
|
|
317
|
+
min-width: 0;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.ai-panel__header {
|
|
321
|
+
display: flex;
|
|
322
|
+
align-items: center;
|
|
323
|
+
justify-content: space-between;
|
|
324
|
+
padding: var(--ide-spacing-sm) var(--ide-spacing-md);
|
|
325
|
+
border-bottom: 1px solid var(--ide-border);
|
|
326
|
+
background: var(--ide-bg-secondary);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.ai-panel__header-left {
|
|
330
|
+
display: flex;
|
|
331
|
+
align-items: center;
|
|
332
|
+
gap: var(--ide-spacing-sm);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.ai-panel__title {
|
|
336
|
+
display: flex;
|
|
337
|
+
align-items: center;
|
|
338
|
+
gap: var(--ide-spacing-sm);
|
|
339
|
+
font-size: var(--ide-font-size-sm);
|
|
340
|
+
font-weight: 600;
|
|
341
|
+
color: var(--ide-text-primary);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.ai-panel__actions {
|
|
345
|
+
display: flex;
|
|
346
|
+
gap: var(--ide-spacing-xs);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.ai-panel__messages {
|
|
350
|
+
flex: 1;
|
|
351
|
+
overflow-y: auto;
|
|
352
|
+
padding: var(--ide-spacing-md);
|
|
353
|
+
display: flex;
|
|
354
|
+
flex-direction: column;
|
|
355
|
+
gap: var(--ide-spacing-sm);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.ai-panel__empty {
|
|
359
|
+
display: flex;
|
|
360
|
+
flex-direction: column;
|
|
361
|
+
align-items: center;
|
|
362
|
+
justify-content: center;
|
|
363
|
+
height: 100%;
|
|
364
|
+
text-align: center;
|
|
365
|
+
padding: var(--ide-spacing-xl);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.ai-panel__empty-icon {
|
|
369
|
+
margin-bottom: var(--ide-spacing-md);
|
|
370
|
+
color: var(--ide-text-muted);
|
|
371
|
+
opacity: 0.5;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.ai-panel__empty h3 {
|
|
375
|
+
margin: 0 0 var(--ide-spacing-xs);
|
|
376
|
+
font-size: var(--ide-font-size-md);
|
|
377
|
+
font-weight: 600;
|
|
378
|
+
color: var(--ide-text-primary);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.ai-panel__empty p {
|
|
382
|
+
margin: 0 0 var(--ide-spacing-lg);
|
|
383
|
+
font-size: var(--ide-font-size-sm);
|
|
384
|
+
color: var(--ide-text-muted);
|
|
385
|
+
max-width: 280px;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.ai-panel__suggestions {
|
|
389
|
+
display: flex;
|
|
390
|
+
flex-wrap: wrap;
|
|
391
|
+
justify-content: center;
|
|
392
|
+
gap: var(--ide-spacing-xs);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
.suggestion-chip {
|
|
396
|
+
padding: 0.375rem 0.75rem;
|
|
397
|
+
background: var(--ide-bg-secondary);
|
|
398
|
+
border: 1px solid var(--ide-border);
|
|
399
|
+
border-radius: var(--ide-radius-full);
|
|
400
|
+
font-size: var(--ide-font-size-xs);
|
|
401
|
+
color: var(--ide-text-secondary);
|
|
402
|
+
cursor: pointer;
|
|
403
|
+
transition: all 0.15s ease;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.suggestion-chip:hover {
|
|
407
|
+
background: var(--color-nocturnium-wave);
|
|
408
|
+
border-color: var(--color-nocturnium-wave);
|
|
409
|
+
color: var(--color-nocturnium-night);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
.ai-panel__typing {
|
|
413
|
+
display: flex;
|
|
414
|
+
align-items: center;
|
|
415
|
+
gap: var(--ide-spacing-sm);
|
|
416
|
+
padding: var(--ide-spacing-sm) 0;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.ai-panel__typing-indicator {
|
|
420
|
+
display: flex;
|
|
421
|
+
gap: 4px;
|
|
422
|
+
padding: var(--ide-spacing-sm) var(--ide-spacing-md);
|
|
423
|
+
background: var(--ide-bg-secondary);
|
|
424
|
+
border-radius: var(--ide-radius-lg);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
.ai-panel__typing-indicator span {
|
|
428
|
+
width: 6px;
|
|
429
|
+
height: 6px;
|
|
430
|
+
background: var(--ide-text-muted);
|
|
431
|
+
border-radius: 50%;
|
|
432
|
+
animation: typing-bounce 1.4s infinite ease-in-out;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
.ai-panel__typing-indicator span:nth-child(1) {
|
|
436
|
+
animation-delay: 0s;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
.ai-panel__typing-indicator span:nth-child(2) {
|
|
440
|
+
animation-delay: 0.2s;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
.ai-panel__typing-indicator span:nth-child(3) {
|
|
444
|
+
animation-delay: 0.4s;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
@keyframes typing-bounce {
|
|
448
|
+
0%,
|
|
449
|
+
60%,
|
|
450
|
+
100% {
|
|
451
|
+
transform: translateY(0);
|
|
452
|
+
}
|
|
453
|
+
30% {
|
|
454
|
+
transform: translateY(-4px);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.ai-panel__error {
|
|
459
|
+
display: flex;
|
|
460
|
+
align-items: center;
|
|
461
|
+
gap: var(--ide-spacing-sm);
|
|
462
|
+
padding: var(--ide-spacing-sm) var(--ide-spacing-md);
|
|
463
|
+
background: color-mix(in srgb, var(--ide-error) 15%, transparent);
|
|
464
|
+
color: var(--ide-error);
|
|
465
|
+
font-size: var(--ide-font-size-xs);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
.ai-panel__error span {
|
|
469
|
+
flex: 1;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.ai-panel__input {
|
|
473
|
+
display: flex;
|
|
474
|
+
align-items: flex-end;
|
|
475
|
+
gap: var(--ide-spacing-sm);
|
|
476
|
+
padding: var(--ide-spacing-md);
|
|
477
|
+
border-top: 1px solid var(--ide-border);
|
|
478
|
+
background: var(--ide-bg-secondary);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
.ai-panel__textarea {
|
|
482
|
+
flex: 1;
|
|
483
|
+
min-height: 40px;
|
|
484
|
+
max-height: 120px;
|
|
485
|
+
padding: var(--ide-spacing-sm) var(--ide-spacing-md);
|
|
486
|
+
font-family: var(--ide-font-sans);
|
|
487
|
+
font-size: var(--ide-font-size-sm);
|
|
488
|
+
line-height: var(--ide-line-height-normal);
|
|
489
|
+
background: var(--ide-bg-primary);
|
|
490
|
+
color: var(--ide-text-primary);
|
|
491
|
+
border: 1px solid var(--ide-border);
|
|
492
|
+
border-radius: var(--ide-radius-md);
|
|
493
|
+
resize: none;
|
|
494
|
+
transition: border-color var(--ide-transition-fast);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
.ai-panel__textarea:focus {
|
|
498
|
+
outline: none;
|
|
499
|
+
border-color: var(--color-nocturnium-wave);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.ai-panel__textarea::placeholder {
|
|
503
|
+
color: var(--ide-text-muted);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
.ai-panel__textarea:disabled {
|
|
507
|
+
opacity: 0.5;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/* Responsive */
|
|
511
|
+
@media (max-width: 1024px) {
|
|
512
|
+
.ai-panel__sidebar {
|
|
513
|
+
width: 260px;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
@media (max-width: 768px) {
|
|
518
|
+
.ai-panel__sidebar {
|
|
519
|
+
position: absolute;
|
|
520
|
+
left: 0;
|
|
521
|
+
top: 0;
|
|
522
|
+
bottom: 0;
|
|
523
|
+
z-index: 10;
|
|
524
|
+
width: calc(100% - 48px);
|
|
525
|
+
max-width: 300px;
|
|
526
|
+
background: var(--ide-bg-primary);
|
|
527
|
+
box-shadow: 4px 0 12px rgba(0, 0, 0, 0.3);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.ai-panel__messages {
|
|
531
|
+
padding: var(--ide-spacing-sm);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
.ai-panel__input {
|
|
535
|
+
padding: var(--ide-spacing-sm);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
@media (max-width: 480px) {
|
|
540
|
+
.ai-panel__sidebar {
|
|
541
|
+
width: calc(100% - 24px);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
.ai-panel__empty {
|
|
545
|
+
padding: var(--ide-spacing-md);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
.ai-panel__empty p {
|
|
549
|
+
max-width: 100%;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.ai-panel__suggestions {
|
|
553
|
+
flex-direction: column;
|
|
554
|
+
align-items: stretch;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.suggestion-chip {
|
|
558
|
+
text-align: center;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
</style>
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Button, Icon, Badge } from '../core';
|
|
3
|
+
import type { AISuggestion } from '../../types';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
suggestion: AISuggestion;
|
|
7
|
+
onAccept: () => void;
|
|
8
|
+
onDismiss: () => void;
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { suggestion, onAccept, onDismiss, class: className = '' }: Props = $props();
|
|
13
|
+
|
|
14
|
+
const typeIcon = $derived(() => {
|
|
15
|
+
switch (suggestion.type) {
|
|
16
|
+
case 'completion':
|
|
17
|
+
return 'sparkles';
|
|
18
|
+
case 'refactor':
|
|
19
|
+
return 'refresh';
|
|
20
|
+
case 'fix':
|
|
21
|
+
return 'zap';
|
|
22
|
+
case 'explain':
|
|
23
|
+
return 'info';
|
|
24
|
+
default:
|
|
25
|
+
return 'sparkles';
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const typeLabel = $derived(() => {
|
|
30
|
+
switch (suggestion.type) {
|
|
31
|
+
case 'completion':
|
|
32
|
+
return 'Completion';
|
|
33
|
+
case 'refactor':
|
|
34
|
+
return 'Refactor';
|
|
35
|
+
case 'fix':
|
|
36
|
+
return 'Fix';
|
|
37
|
+
case 'explain':
|
|
38
|
+
return 'Explain';
|
|
39
|
+
default:
|
|
40
|
+
return 'Suggestion';
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<div class="ai-suggestion {className}">
|
|
46
|
+
<div class="ai-suggestion__header">
|
|
47
|
+
<Icon name={typeIcon()} size={14} />
|
|
48
|
+
<Badge variant="info" size="sm">{typeLabel()}</Badge>
|
|
49
|
+
{#if suggestion.confidence}
|
|
50
|
+
<span class="ai-suggestion__confidence">{Math.round(suggestion.confidence * 100)}%</span>
|
|
51
|
+
{/if}
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
{#if suggestion.description}
|
|
55
|
+
<div class="ai-suggestion__description">
|
|
56
|
+
{suggestion.description}
|
|
57
|
+
</div>
|
|
58
|
+
{/if}
|
|
59
|
+
|
|
60
|
+
<div class="ai-suggestion__preview">
|
|
61
|
+
<pre>{suggestion.content}</pre>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<div class="ai-suggestion__actions">
|
|
65
|
+
<Button variant="ghost" size="xs" onclick={onDismiss}>
|
|
66
|
+
Dismiss
|
|
67
|
+
</Button>
|
|
68
|
+
<Button variant="primary" size="xs" onclick={onAccept}>
|
|
69
|
+
{#snippet icon()}<Icon name="check" size={12} />{/snippet}
|
|
70
|
+
Accept
|
|
71
|
+
</Button>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<style>
|
|
76
|
+
.ai-suggestion {
|
|
77
|
+
min-width: 280px;
|
|
78
|
+
max-width: 400px;
|
|
79
|
+
background: var(--ide-bg-elevated);
|
|
80
|
+
border: 1px solid var(--ide-ai-assistant);
|
|
81
|
+
border-radius: var(--ide-radius-md);
|
|
82
|
+
box-shadow: var(--ide-shadow-lg);
|
|
83
|
+
overflow: hidden;
|
|
84
|
+
animation: ide-fade-in var(--ide-transition-fast);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.ai-suggestion__header {
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
gap: var(--ide-spacing-sm);
|
|
91
|
+
padding: var(--ide-spacing-sm) var(--ide-spacing-md);
|
|
92
|
+
background: color-mix(in srgb, var(--ide-ai-assistant) 15%, transparent);
|
|
93
|
+
color: var(--ide-ai-assistant);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.ai-suggestion__confidence {
|
|
97
|
+
margin-left: auto;
|
|
98
|
+
font-size: var(--ide-font-size-xs);
|
|
99
|
+
color: var(--ide-text-muted);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.ai-suggestion__description {
|
|
103
|
+
padding: var(--ide-spacing-sm) var(--ide-spacing-md);
|
|
104
|
+
font-size: var(--ide-font-size-sm);
|
|
105
|
+
color: var(--ide-text-secondary);
|
|
106
|
+
border-bottom: 1px solid var(--ide-border);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.ai-suggestion__preview {
|
|
110
|
+
max-height: 150px;
|
|
111
|
+
overflow: auto;
|
|
112
|
+
background: var(--ide-bg-secondary);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.ai-suggestion__preview pre {
|
|
116
|
+
margin: 0;
|
|
117
|
+
padding: var(--ide-spacing-sm) var(--ide-spacing-md);
|
|
118
|
+
font-family: var(--ide-font-mono);
|
|
119
|
+
font-size: var(--ide-font-size-xs);
|
|
120
|
+
line-height: 1.5;
|
|
121
|
+
white-space: pre-wrap;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.ai-suggestion__actions {
|
|
125
|
+
display: flex;
|
|
126
|
+
justify-content: flex-end;
|
|
127
|
+
gap: var(--ide-spacing-sm);
|
|
128
|
+
padding: var(--ide-spacing-sm) var(--ide-spacing-md);
|
|
129
|
+
background: var(--ide-bg-primary);
|
|
130
|
+
border-top: 1px solid var(--ide-border);
|
|
131
|
+
}
|
|
132
|
+
</style>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AISuggestion } from '../../types';
|
|
2
|
+
interface Props {
|
|
3
|
+
suggestion: AISuggestion;
|
|
4
|
+
onAccept: () => void;
|
|
5
|
+
onDismiss: () => void;
|
|
6
|
+
class?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const AISuggestionWidget: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type AISuggestionWidget = ReturnType<typeof AISuggestionWidget>;
|
|
10
|
+
export default AISuggestionWidget;
|