@myrialabs/clopen 0.2.16 → 0.2.18
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/.env.example +4 -4
- package/backend/utils/env.ts +5 -5
- package/bin/clopen.ts +21 -298
- package/dist/assets/addon-clipboard-wHJhZAA4.js +1 -0
- package/dist/assets/addon-fit-DX4qG4td.js +1 -0
- package/dist/assets/addon-ligatures-DpDY8N_X.js +2 -0
- package/dist/assets/addon-unicode11-Bt8F3D7-.js +7 -0
- package/dist/assets/addon-web-links-DIbG5aQx.js +1 -0
- package/dist/assets/index-C-eR9PGW.js +2 -0
- package/dist/assets/main-D1IISCsM.js +247 -0
- package/dist/assets/main-DzSwlujO.css +1 -0
- package/dist/assets/xterm-B-qIQCd3.js +16 -0
- package/{index.html → dist/index.html} +2 -1
- package/package.json +12 -2
- package/scripts/start.ts +3 -3
- package/shared/utils/logger.ts +1 -1
- package/.dockerignore +0 -5
- package/.github/workflows/ci.yml +0 -86
- package/CONTRIBUTING.md +0 -188
- package/bun.lock +0 -1127
- package/docker-compose.yml +0 -31
- package/frontend/App.svelte +0 -77
- package/frontend/app-environment.ts +0 -10
- package/frontend/app.css +0 -313
- package/frontend/components/auth/InvitePage.svelte +0 -215
- package/frontend/components/auth/LoginPage.svelte +0 -129
- package/frontend/components/auth/SetupPage.svelte +0 -1054
- package/frontend/components/chat/ChatInterface.svelte +0 -426
- package/frontend/components/chat/formatters/ErrorMessage.svelte +0 -57
- package/frontend/components/chat/formatters/MessageFormatter.svelte +0 -244
- package/frontend/components/chat/formatters/TextMessage.svelte +0 -383
- package/frontend/components/chat/formatters/Tools.svelte +0 -79
- package/frontend/components/chat/formatters/index.ts +0 -3
- package/frontend/components/chat/input/ChatInput.svelte +0 -492
- package/frontend/components/chat/input/components/ChatInputActions.svelte +0 -88
- package/frontend/components/chat/input/components/DragDropOverlay.svelte +0 -30
- package/frontend/components/chat/input/components/EditModeIndicator.svelte +0 -33
- package/frontend/components/chat/input/components/EngineModelPicker.svelte +0 -642
- package/frontend/components/chat/input/components/FileAttachmentPreview.svelte +0 -48
- package/frontend/components/chat/input/components/LoadingIndicator.svelte +0 -43
- package/frontend/components/chat/input/composables/use-animations.svelte.ts +0 -217
- package/frontend/components/chat/input/composables/use-chat-actions.svelte.ts +0 -152
- package/frontend/components/chat/input/composables/use-file-handling.svelte.ts +0 -216
- package/frontend/components/chat/input/composables/use-input-state.svelte.ts +0 -357
- package/frontend/components/chat/input/composables/use-textarea-resize.svelte.ts +0 -69
- package/frontend/components/chat/message/ChatMessage.svelte +0 -509
- package/frontend/components/chat/message/ChatMessages.svelte +0 -553
- package/frontend/components/chat/message/DateSeparator.svelte +0 -86
- package/frontend/components/chat/message/MessageBubble.svelte +0 -114
- package/frontend/components/chat/message/MessageHeader.svelte +0 -143
- package/frontend/components/chat/modal/DebugModal.svelte +0 -59
- package/frontend/components/chat/shared/index.ts +0 -2
- package/frontend/components/chat/shared/utils.ts +0 -116
- package/frontend/components/chat/tools/AgentTool.svelte +0 -96
- package/frontend/components/chat/tools/AskUserQuestionTool.svelte +0 -391
- package/frontend/components/chat/tools/BashOutputTool.svelte +0 -35
- package/frontend/components/chat/tools/BashTool.svelte +0 -51
- package/frontend/components/chat/tools/CustomMcpTool.svelte +0 -141
- package/frontend/components/chat/tools/EditTool.svelte +0 -48
- package/frontend/components/chat/tools/EnterPlanModeTool.svelte +0 -24
- package/frontend/components/chat/tools/ExitPlanModeTool.svelte +0 -29
- package/frontend/components/chat/tools/GlobTool.svelte +0 -51
- package/frontend/components/chat/tools/GrepTool.svelte +0 -90
- package/frontend/components/chat/tools/ListMcpResourcesTool.svelte +0 -31
- package/frontend/components/chat/tools/NotebookEditTool.svelte +0 -38
- package/frontend/components/chat/tools/ReadMcpResourceTool.svelte +0 -34
- package/frontend/components/chat/tools/ReadTool.svelte +0 -41
- package/frontend/components/chat/tools/SkillTool.svelte +0 -21
- package/frontend/components/chat/tools/TaskStopTool.svelte +0 -26
- package/frontend/components/chat/tools/TaskTool.svelte +0 -64
- package/frontend/components/chat/tools/TodoWriteTool.svelte +0 -75
- package/frontend/components/chat/tools/WebFetchTool.svelte +0 -35
- package/frontend/components/chat/tools/WebSearchTool.svelte +0 -84
- package/frontend/components/chat/tools/WriteTool.svelte +0 -33
- package/frontend/components/chat/tools/components/CodeBlock.svelte +0 -79
- package/frontend/components/chat/tools/components/DiffBlock.svelte +0 -408
- package/frontend/components/chat/tools/components/FileHeader.svelte +0 -59
- package/frontend/components/chat/tools/components/InfoLine.svelte +0 -19
- package/frontend/components/chat/tools/components/StatsBadges.svelte +0 -27
- package/frontend/components/chat/tools/components/TerminalCommand.svelte +0 -61
- package/frontend/components/chat/tools/components/index.ts +0 -7
- package/frontend/components/chat/tools/index.ts +0 -30
- package/frontend/components/chat/widgets/ContextIndicator.svelte +0 -186
- package/frontend/components/chat/widgets/FloatingTodoList.svelte +0 -367
- package/frontend/components/checkpoint/ConflictResolutionModal.svelte +0 -189
- package/frontend/components/checkpoint/TimelineModal.svelte +0 -447
- package/frontend/components/checkpoint/timeline/TimelineEdge.svelte +0 -26
- package/frontend/components/checkpoint/timeline/TimelineGraph.svelte +0 -87
- package/frontend/components/checkpoint/timeline/TimelineNode.svelte +0 -119
- package/frontend/components/checkpoint/timeline/TimelineVersionGroup.svelte +0 -59
- package/frontend/components/checkpoint/timeline/animation.ts +0 -168
- package/frontend/components/checkpoint/timeline/config.ts +0 -44
- package/frontend/components/checkpoint/timeline/graph-builder.ts +0 -304
- package/frontend/components/checkpoint/timeline/types.ts +0 -69
- package/frontend/components/checkpoint/timeline/utils.ts +0 -53
- package/frontend/components/common/display/AvatarBubble.svelte +0 -56
- package/frontend/components/common/display/Button.svelte +0 -71
- package/frontend/components/common/display/Card.svelte +0 -102
- package/frontend/components/common/display/Icon.svelte +0 -58
- package/frontend/components/common/display/PageTemplate.svelte +0 -76
- package/frontend/components/common/display/ProjectUserAvatars.svelte +0 -79
- package/frontend/components/common/display/ThemeToggle.svelte +0 -44
- package/frontend/components/common/editor/MonacoEditor.svelte +0 -583
- package/frontend/components/common/feedback/Alert.svelte +0 -139
- package/frontend/components/common/feedback/ConnectionBanner.svelte +0 -55
- package/frontend/components/common/feedback/LoadingScreen.svelte +0 -52
- package/frontend/components/common/feedback/LoadingSpinner.svelte +0 -48
- package/frontend/components/common/feedback/NotificationToast.svelte +0 -128
- package/frontend/components/common/feedback/RestartRequiredModal.svelte +0 -53
- package/frontend/components/common/feedback/UpdateBanner.svelte +0 -99
- package/frontend/components/common/form/Checkbox.svelte +0 -48
- package/frontend/components/common/form/FolderBrowser.svelte +0 -856
- package/frontend/components/common/form/Input.svelte +0 -72
- package/frontend/components/common/form/ModelSelector.svelte +0 -110
- package/frontend/components/common/form/Select.svelte +0 -98
- package/frontend/components/common/form/Textarea.svelte +0 -80
- package/frontend/components/common/lucide-icons.ts +0 -1642
- package/frontend/components/common/material-icons.ts +0 -1082
- package/frontend/components/common/media/MediaPreview.svelte +0 -187
- package/frontend/components/common/overlay/Dialog.svelte +0 -251
- package/frontend/components/common/overlay/Lightbox.svelte +0 -233
- package/frontend/components/common/overlay/Modal.svelte +0 -177
- package/frontend/components/common/overlay/ModalProvider.svelte +0 -28
- package/frontend/components/common/xterm/XTerm.svelte +0 -743
- package/frontend/components/common/xterm/index.ts +0 -16
- package/frontend/components/common/xterm/terminal-config.ts +0 -68
- package/frontend/components/common/xterm/types.ts +0 -32
- package/frontend/components/common/xterm/xterm-service.ts +0 -437
- package/frontend/components/files/FileNode.svelte +0 -327
- package/frontend/components/files/FileTree.svelte +0 -690
- package/frontend/components/files/FileViewer.svelte +0 -551
- package/frontend/components/files/SearchResults.svelte +0 -303
- package/frontend/components/git/BranchManager.svelte +0 -446
- package/frontend/components/git/ChangesSection.svelte +0 -196
- package/frontend/components/git/CommitForm.svelte +0 -128
- package/frontend/components/git/ConflictResolver.svelte +0 -158
- package/frontend/components/git/DiffViewer.svelte +0 -298
- package/frontend/components/git/FileChangeItem.svelte +0 -119
- package/frontend/components/git/GitButton.svelte +0 -33
- package/frontend/components/git/GitLog.svelte +0 -401
- package/frontend/components/git/GitModal.svelte +0 -80
- package/frontend/components/history/HistoryModal.svelte +0 -602
- package/frontend/components/history/HistoryView.svelte +0 -561
- package/frontend/components/index.ts +0 -34
- package/frontend/components/preview/browser/BrowserPreview.svelte +0 -558
- package/frontend/components/preview/browser/components/Canvas.svelte +0 -1523
- package/frontend/components/preview/browser/components/ConsolePanel.svelte +0 -757
- package/frontend/components/preview/browser/components/Container.svelte +0 -507
- package/frontend/components/preview/browser/components/ContextMenu.svelte +0 -236
- package/frontend/components/preview/browser/components/SelectDropdown.svelte +0 -224
- package/frontend/components/preview/browser/components/Toolbar.svelte +0 -358
- package/frontend/components/preview/browser/components/VirtualCursor.svelte +0 -36
- package/frontend/components/preview/browser/core/cleanup.svelte.ts +0 -155
- package/frontend/components/preview/browser/core/coordinator.svelte.ts +0 -885
- package/frontend/components/preview/browser/core/interactions.svelte.ts +0 -113
- package/frontend/components/preview/browser/core/mcp-handlers.svelte.ts +0 -331
- package/frontend/components/preview/browser/core/native-ui-handlers.svelte.ts +0 -391
- package/frontend/components/preview/browser/core/stream-handler.svelte.ts +0 -288
- package/frontend/components/preview/browser/core/tab-manager.svelte.ts +0 -210
- package/frontend/components/preview/browser/core/tab-operations.svelte.ts +0 -241
- package/frontend/components/preview/index.ts +0 -2
- package/frontend/components/settings/SettingsModal.svelte +0 -268
- package/frontend/components/settings/SettingsView.svelte +0 -54
- package/frontend/components/settings/account/AccountSettings.svelte +0 -5
- package/frontend/components/settings/admin/InviteManagement.svelte +0 -239
- package/frontend/components/settings/admin/UserManagement.svelte +0 -127
- package/frontend/components/settings/appearance/AppearanceSettings.svelte +0 -104
- package/frontend/components/settings/appearance/LayoutPresetSettings.svelte +0 -160
- package/frontend/components/settings/appearance/LayoutPreview.svelte +0 -76
- package/frontend/components/settings/engines/AIEnginesSettings.svelte +0 -917
- package/frontend/components/settings/general/AdvancedSettings.svelte +0 -193
- package/frontend/components/settings/general/AuthModeSettings.svelte +0 -229
- package/frontend/components/settings/general/DataManagementSettings.svelte +0 -89
- package/frontend/components/settings/general/GeneralSettings.svelte +0 -20
- package/frontend/components/settings/general/UpdateSettings.svelte +0 -130
- package/frontend/components/settings/git/GitSettings.svelte +0 -392
- package/frontend/components/settings/model/EngineModelPicker.svelte +0 -284
- package/frontend/components/settings/model/ModelSettings.svelte +0 -240
- package/frontend/components/settings/notifications/NotificationSettings.svelte +0 -205
- package/frontend/components/settings/security/SecuritySettings.svelte +0 -10
- package/frontend/components/settings/system/SystemSettings.svelte +0 -10
- package/frontend/components/settings/tunnel/TunnelSettings.svelte +0 -1060
- package/frontend/components/settings/user/UserSettings.svelte +0 -270
- package/frontend/components/terminal/Terminal.svelte +0 -338
- package/frontend/components/terminal/TerminalTabs.svelte +0 -88
- package/frontend/components/terminal/TerminalView.svelte +0 -55
- package/frontend/components/tunnel/TunnelActive.svelte +0 -218
- package/frontend/components/tunnel/TunnelButton.svelte +0 -60
- package/frontend/components/tunnel/TunnelInactive.svelte +0 -260
- package/frontend/components/tunnel/TunnelModal.svelte +0 -101
- package/frontend/components/tunnel/TunnelQRCode.svelte +0 -49
- package/frontend/components/workspace/DesktopNavigator.svelte +0 -445
- package/frontend/components/workspace/MobileNavigator.svelte +0 -427
- package/frontend/components/workspace/PanelContainer.svelte +0 -100
- package/frontend/components/workspace/PanelHeader.svelte +0 -664
- package/frontend/components/workspace/ViewMenu.svelte +0 -146
- package/frontend/components/workspace/WorkspaceLayout.svelte +0 -199
- package/frontend/components/workspace/layout/DesktopLayout.svelte +0 -15
- package/frontend/components/workspace/layout/MobileLayout.svelte +0 -17
- package/frontend/components/workspace/layout/split-pane/Container.svelte +0 -42
- package/frontend/components/workspace/layout/split-pane/Handle.svelte +0 -85
- package/frontend/components/workspace/layout/split-pane/Layout.svelte +0 -62
- package/frontend/components/workspace/panels/ChatPanel.svelte +0 -282
- package/frontend/components/workspace/panels/FilesPanel.svelte +0 -1376
- package/frontend/components/workspace/panels/GitPanel.svelte +0 -1601
- package/frontend/components/workspace/panels/PreviewPanel.svelte +0 -153
- package/frontend/components/workspace/panels/TerminalPanel.svelte +0 -73
- package/frontend/main.ts +0 -17
- package/frontend/services/chat/chat.service.ts +0 -975
- package/frontend/services/chat/index.ts +0 -7
- package/frontend/services/favicon.service.ts +0 -103
- package/frontend/services/notification/global-stream-monitor.ts +0 -120
- package/frontend/services/notification/index.ts +0 -8
- package/frontend/services/notification/push.service.ts +0 -144
- package/frontend/services/notification/sound.service.ts +0 -127
- package/frontend/services/preview/browser/browser-console.service.ts +0 -61
- package/frontend/services/preview/browser/browser-webcodecs.service.ts +0 -1643
- package/frontend/services/preview/browser/mcp-integration.svelte.ts +0 -67
- package/frontend/services/preview/index.ts +0 -23
- package/frontend/services/project/index.ts +0 -8
- package/frontend/services/project/status.service.ts +0 -170
- package/frontend/services/snapshot/snapshot.service.ts +0 -86
- package/frontend/services/terminal/background/index.ts +0 -130
- package/frontend/services/terminal/background/session-restore.ts +0 -274
- package/frontend/services/terminal/background/stream-manager.ts +0 -286
- package/frontend/services/terminal/index.ts +0 -14
- package/frontend/services/terminal/persistence.service.ts +0 -260
- package/frontend/services/terminal/project.service.ts +0 -1004
- package/frontend/services/terminal/session.service.ts +0 -364
- package/frontend/services/terminal/terminal.service.ts +0 -379
- package/frontend/stores/core/app.svelte.ts +0 -296
- package/frontend/stores/core/files.svelte.ts +0 -87
- package/frontend/stores/core/presence.svelte.ts +0 -128
- package/frontend/stores/core/projects.svelte.ts +0 -325
- package/frontend/stores/core/sessions.svelte.ts +0 -452
- package/frontend/stores/features/auth.svelte.ts +0 -336
- package/frontend/stores/features/claude-accounts.svelte.ts +0 -58
- package/frontend/stores/features/models.svelte.ts +0 -89
- package/frontend/stores/features/settings.svelte.ts +0 -151
- package/frontend/stores/features/terminal.svelte.ts +0 -747
- package/frontend/stores/features/tunnel-config.svelte.ts +0 -205
- package/frontend/stores/features/tunnel.svelte.ts +0 -277
- package/frontend/stores/features/user.svelte.ts +0 -54
- package/frontend/stores/ui/chat-input.svelte.ts +0 -57
- package/frontend/stores/ui/chat-model.svelte.ts +0 -61
- package/frontend/stores/ui/connection.svelte.ts +0 -40
- package/frontend/stores/ui/dialog.svelte.ts +0 -59
- package/frontend/stores/ui/edit-mode.svelte.ts +0 -214
- package/frontend/stores/ui/notification.svelte.ts +0 -169
- package/frontend/stores/ui/settings-modal.svelte.ts +0 -116
- package/frontend/stores/ui/theme.svelte.ts +0 -179
- package/frontend/stores/ui/todo-panel.svelte.ts +0 -39
- package/frontend/stores/ui/update.svelte.ts +0 -159
- package/frontend/stores/ui/workspace.svelte.ts +0 -798
- package/frontend/utils/chat/date-separator.ts +0 -39
- package/frontend/utils/chat/message-grouper.ts +0 -329
- package/frontend/utils/chat/message-processor.ts +0 -169
- package/frontend/utils/chat/tool-handler.ts +0 -287
- package/frontend/utils/chat/virtual-scroll.svelte.ts +0 -142
- package/frontend/utils/click-outside.ts +0 -20
- package/frontend/utils/context-manager.ts +0 -55
- package/frontend/utils/file-icon-mappings.ts +0 -769
- package/frontend/utils/file-type.ts +0 -68
- package/frontend/utils/folder-icon-mappings.ts +0 -1030
- package/frontend/utils/git-status.ts +0 -68
- package/frontend/utils/native-ui.ts +0 -73
- package/frontend/utils/platform.ts +0 -113
- package/frontend/utils/port-check.ts +0 -65
- package/frontend/utils/preview-constants.ts +0 -45
- package/frontend/utils/terminal-formatter.ts +0 -207
- package/frontend/utils/theme.ts +0 -6
- package/frontend/utils/tree-visualizer.ts +0 -320
- package/frontend/utils/ws.ts +0 -90
- package/scripts/dev.ts +0 -46
- package/scripts/generate-icons.ts +0 -87
- package/svelte.config.js +0 -20
- package/vite.config.ts +0 -51
- /package/{static → dist}/audio/notification.ogg +0 -0
- /package/{static → dist}/favicon.svg +0 -0
- /package/{static → dist}/fonts/dm-sans/dm-sans-italic-latin-ext.woff2 +0 -0
- /package/{static → dist}/fonts/dm-sans/dm-sans-italic-latin.woff2 +0 -0
- /package/{static → dist}/fonts/dm-sans/dm-sans-normal-latin-ext.woff2 +0 -0
- /package/{static → dist}/fonts/dm-sans/dm-sans-normal-latin.woff2 +0 -0
- /package/{static → dist}/fonts/dm-sans.css +0 -0
- /package/{static → dist}/manifest.json +0 -0
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Favicon Badge Service
|
|
3
|
-
*
|
|
4
|
-
* Dynamically renders a badge on the favicon showing the count of
|
|
5
|
-
* non-idle status indicators across all projects (streaming, waiting
|
|
6
|
-
* input, unread).
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { debug } from '$shared/utils/logger';
|
|
10
|
-
|
|
11
|
-
const FAVICON_HREF = '/favicon.svg';
|
|
12
|
-
const BADGE_COLOR = '#000000';
|
|
13
|
-
const BADGE_TEXT_COLOR = '#FFFFFF';
|
|
14
|
-
const ICON_SIZE = 128; // canvas resolution — higher for crisp badge text
|
|
15
|
-
|
|
16
|
-
let originalIconUrl: string | null = null;
|
|
17
|
-
let currentCount = -1; // -1 = not yet rendered
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Update the favicon badge.
|
|
21
|
-
* Renders the original SVG favicon with an optional numeric badge
|
|
22
|
-
* in the bottom-right corner.
|
|
23
|
-
*
|
|
24
|
-
* @param count Number of active indicators (0 = remove badge)
|
|
25
|
-
*/
|
|
26
|
-
export function updateFaviconBadge(count: number): void {
|
|
27
|
-
// Avoid unnecessary re-renders
|
|
28
|
-
if (count === currentCount) return;
|
|
29
|
-
currentCount = count;
|
|
30
|
-
|
|
31
|
-
if (count <= 0) {
|
|
32
|
-
restoreOriginalFavicon();
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const img = new Image();
|
|
37
|
-
img.onload = () => {
|
|
38
|
-
try {
|
|
39
|
-
const canvas = document.createElement('canvas');
|
|
40
|
-
canvas.width = ICON_SIZE;
|
|
41
|
-
canvas.height = ICON_SIZE;
|
|
42
|
-
const ctx = canvas.getContext('2d');
|
|
43
|
-
if (!ctx) return;
|
|
44
|
-
|
|
45
|
-
// Draw original favicon
|
|
46
|
-
ctx.drawImage(img, 0, 0, ICON_SIZE, ICON_SIZE);
|
|
47
|
-
|
|
48
|
-
// Badge text with outline (bottom-right)
|
|
49
|
-
const displayText = count > 9 ? '9+' : String(count);
|
|
50
|
-
const fontSize = count > 9 ? 56 : 64;
|
|
51
|
-
const textX = ICON_SIZE - (count > 9 ? 32 : 24);
|
|
52
|
-
const textY = ICON_SIZE - 20;
|
|
53
|
-
|
|
54
|
-
ctx.font = `bold ${fontSize}px sans-serif`;
|
|
55
|
-
ctx.textAlign = 'center';
|
|
56
|
-
ctx.textBaseline = 'middle';
|
|
57
|
-
|
|
58
|
-
// Black outline
|
|
59
|
-
ctx.strokeStyle = BADGE_COLOR;
|
|
60
|
-
ctx.lineWidth = 14;
|
|
61
|
-
ctx.lineJoin = 'round';
|
|
62
|
-
ctx.strokeText(displayText, textX, textY);
|
|
63
|
-
|
|
64
|
-
// White fill
|
|
65
|
-
ctx.fillStyle = BADGE_TEXT_COLOR;
|
|
66
|
-
ctx.fillText(displayText, textX, textY);
|
|
67
|
-
|
|
68
|
-
// Apply to favicon
|
|
69
|
-
const dataUrl = canvas.toDataURL('image/png');
|
|
70
|
-
setFaviconHref(dataUrl);
|
|
71
|
-
} catch (err) {
|
|
72
|
-
debug.error('workspace', 'Failed to render favicon badge:', err);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
img.onerror = () => {
|
|
77
|
-
debug.error('workspace', 'Failed to load favicon SVG for badge rendering');
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
img.src = FAVICON_HREF;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function setFaviconHref(href: string): void {
|
|
84
|
-
let link = document.querySelector<HTMLLinkElement>('link[rel="icon"]');
|
|
85
|
-
if (!link) {
|
|
86
|
-
link = document.createElement('link');
|
|
87
|
-
link.rel = 'icon';
|
|
88
|
-
document.head.appendChild(link);
|
|
89
|
-
}
|
|
90
|
-
if (!originalIconUrl) {
|
|
91
|
-
originalIconUrl = FAVICON_HREF;
|
|
92
|
-
}
|
|
93
|
-
link.href = href;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function restoreOriginalFavicon(): void {
|
|
97
|
-
if (originalIconUrl) {
|
|
98
|
-
const link = document.querySelector<HTMLLinkElement>('link[rel="icon"]');
|
|
99
|
-
if (link) {
|
|
100
|
-
link.href = originalIconUrl;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Global Stream Monitor Service
|
|
3
|
-
*
|
|
4
|
-
* Single source of truth for chat stream notifications (sound + push).
|
|
5
|
-
*
|
|
6
|
-
* Listens for backend events and triggers notifications for ALL projects —
|
|
7
|
-
* both active and non-active:
|
|
8
|
-
* - chat:stream-finished → stream completed/errored/cancelled
|
|
9
|
-
* - chat:waiting-input → AskUserQuestion requires user input
|
|
10
|
-
*
|
|
11
|
-
* The backend uses ws.emit.projectMembers() so notifications reach users
|
|
12
|
-
* even when they are on a different project or session.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { soundNotification, pushNotification } from '$frontend/services/notification';
|
|
16
|
-
import { projectState } from '$frontend/stores/core/projects.svelte';
|
|
17
|
-
import { debug } from '$shared/utils/logger';
|
|
18
|
-
import ws from '$frontend/utils/ws';
|
|
19
|
-
|
|
20
|
-
class GlobalStreamMonitor {
|
|
21
|
-
private initialized = false;
|
|
22
|
-
|
|
23
|
-
/** Track notified AskUserQuestion tool_use IDs to ensure once-only notification */
|
|
24
|
-
private notifiedToolUseIds = new Set<string>();
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Initialize the monitor - subscribes to WS events.
|
|
28
|
-
* Safe to call multiple times (idempotent).
|
|
29
|
-
*/
|
|
30
|
-
initialize(): void {
|
|
31
|
-
if (this.initialized) return;
|
|
32
|
-
this.initialized = true;
|
|
33
|
-
|
|
34
|
-
debug.log('notification', 'GlobalStreamMonitor: Initializing WS listeners');
|
|
35
|
-
|
|
36
|
-
// Stream finished — notify on completion
|
|
37
|
-
ws.on('chat:stream-finished', async (data) => {
|
|
38
|
-
const { projectId, status, chatSessionId, reason } = data;
|
|
39
|
-
|
|
40
|
-
debug.log('notification', 'GlobalStreamMonitor: Stream finished', { projectId, status, reason });
|
|
41
|
-
|
|
42
|
-
// Clean up notified IDs for this session (stream is done)
|
|
43
|
-
this.clearSessionNotifications(chatSessionId);
|
|
44
|
-
|
|
45
|
-
// Skip notifications when stream was cancelled due to session deletion
|
|
46
|
-
if (reason === 'session-deleted') return;
|
|
47
|
-
|
|
48
|
-
// Play sound notification
|
|
49
|
-
try {
|
|
50
|
-
await soundNotification.play();
|
|
51
|
-
} catch (error) {
|
|
52
|
-
debug.error('notification', 'Error playing sound notification:', error);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Send push notification with project context
|
|
56
|
-
try {
|
|
57
|
-
const projectName = projectState.projects.find(p => p.id === projectId)?.name || 'Unknown';
|
|
58
|
-
|
|
59
|
-
if (status === 'completed') {
|
|
60
|
-
await pushNotification.sendChatComplete(`Chat response ready in "${projectName}"`);
|
|
61
|
-
} else if (status === 'error') {
|
|
62
|
-
await pushNotification.sendChatError(`Chat error in "${projectName}"`);
|
|
63
|
-
} else if (status === 'cancelled') {
|
|
64
|
-
await pushNotification.sendChatComplete(`Chat interrupted in "${projectName}"`);
|
|
65
|
-
}
|
|
66
|
-
} catch (error) {
|
|
67
|
-
debug.error('notification', 'Error sending push notification:', error);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// Waiting for input — notify once per AskUserQuestion
|
|
72
|
-
ws.on('chat:waiting-input', async (data) => {
|
|
73
|
-
const { projectId, chatSessionId, toolUseId } = data;
|
|
74
|
-
|
|
75
|
-
// Deduplicate: only notify once per tool_use ID
|
|
76
|
-
if (this.notifiedToolUseIds.has(toolUseId)) return;
|
|
77
|
-
this.notifiedToolUseIds.add(toolUseId);
|
|
78
|
-
|
|
79
|
-
debug.log('notification', 'GlobalStreamMonitor: Waiting for input', { projectId, chatSessionId, toolUseId });
|
|
80
|
-
|
|
81
|
-
// Play sound notification
|
|
82
|
-
try {
|
|
83
|
-
await soundNotification.play();
|
|
84
|
-
} catch (error) {
|
|
85
|
-
debug.error('notification', 'Error playing sound notification:', error);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Send push notification
|
|
89
|
-
try {
|
|
90
|
-
const projectName = projectState.projects.find(p => p.id === projectId)?.name || 'Unknown';
|
|
91
|
-
await pushNotification.sendChatComplete(`Waiting for your input in "${projectName}"`);
|
|
92
|
-
} catch (error) {
|
|
93
|
-
debug.error('notification', 'Error sending push notification:', error);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Remove tracked tool_use IDs for a finished session
|
|
100
|
-
*/
|
|
101
|
-
private clearSessionNotifications(chatSessionId: string): void {
|
|
102
|
-
// Tool IDs are globally unique, so a simple clear-on-stream-finish
|
|
103
|
-
// is enough — they won't collide across sessions.
|
|
104
|
-
// For long-running apps, periodically trim to avoid unbounded growth.
|
|
105
|
-
if (this.notifiedToolUseIds.size > 500) {
|
|
106
|
-
this.notifiedToolUseIds.clear();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Clear state (for cleanup/testing)
|
|
112
|
-
*/
|
|
113
|
-
clear(): void {
|
|
114
|
-
this.notifiedToolUseIds.clear();
|
|
115
|
-
debug.log('notification', 'GlobalStreamMonitor: Clearing state');
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Export singleton instance
|
|
120
|
-
export const globalStreamMonitor = new GlobalStreamMonitor();
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Native Push Notification Service
|
|
3
|
-
*
|
|
4
|
-
* Handles native browser push notifications for chat responses
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { settings } from '$frontend/stores/features/settings.svelte';
|
|
8
|
-
|
|
9
|
-
import { debug } from '$shared/utils/logger';
|
|
10
|
-
// Check if browser supports notifications
|
|
11
|
-
function isSupported(): boolean {
|
|
12
|
-
return typeof window !== 'undefined' && 'Notification' in window;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Get current permission status
|
|
16
|
-
function getPermissionStatus(): NotificationPermission | null {
|
|
17
|
-
if (!isSupported()) return null;
|
|
18
|
-
return Notification.permission;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Request notification permission
|
|
22
|
-
async function requestPermission(): Promise<NotificationPermission> {
|
|
23
|
-
if (!isSupported()) {
|
|
24
|
-
throw new Error('Notifications not supported');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const permission = await Notification.requestPermission();
|
|
28
|
-
return permission;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Send native push notification
|
|
32
|
-
async function sendNotification(
|
|
33
|
-
title: string,
|
|
34
|
-
options: NotificationOptions = {},
|
|
35
|
-
isTesting: boolean = false
|
|
36
|
-
): Promise<void> {
|
|
37
|
-
// Check if push notifications are enabled in settings
|
|
38
|
-
if (!isTesting && !settings.pushNotifications) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Check browser support
|
|
43
|
-
if (!isSupported()) {
|
|
44
|
-
debug.warn('notification', 'Native notifications not supported');
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Check permission
|
|
49
|
-
const permission = getPermissionStatus();
|
|
50
|
-
if (permission !== 'granted') {
|
|
51
|
-
debug.warn('notification', 'Notification permission not granted:', permission);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
const notification = new Notification(title, {
|
|
57
|
-
icon: '/favicon.svg',
|
|
58
|
-
badge: '/favicon.svg',
|
|
59
|
-
...options
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Auto-close notification after 5 seconds
|
|
63
|
-
setTimeout(() => {
|
|
64
|
-
notification.close();
|
|
65
|
-
}, 5000);
|
|
66
|
-
|
|
67
|
-
} catch (error) {
|
|
68
|
-
debug.warn('notification', 'Failed to send notification:', error);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Public API
|
|
73
|
-
export const pushNotification = {
|
|
74
|
-
/**
|
|
75
|
-
* Check if notifications are supported
|
|
76
|
-
*/
|
|
77
|
-
isSupported,
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Get current permission status
|
|
81
|
-
*/
|
|
82
|
-
getPermissionStatus,
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Request notification permission from user
|
|
86
|
-
*/
|
|
87
|
-
requestPermission,
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Send notification for chat response completion
|
|
91
|
-
*/
|
|
92
|
-
async sendChatComplete(message?: string): Promise<void> {
|
|
93
|
-
await sendNotification('Claude Response Complete', {
|
|
94
|
-
body: message || 'Your chat response is ready',
|
|
95
|
-
tag: 'chat-complete'
|
|
96
|
-
});
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Send notification for chat error
|
|
101
|
-
*/
|
|
102
|
-
async sendChatError(error?: string): Promise<void> {
|
|
103
|
-
await sendNotification('Claude Response Error', {
|
|
104
|
-
body: error || 'There was an error with your chat response',
|
|
105
|
-
tag: 'chat-error'
|
|
106
|
-
});
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Test notification (for settings)
|
|
111
|
-
*/
|
|
112
|
-
async testNotification(): Promise<boolean> {
|
|
113
|
-
try {
|
|
114
|
-
await sendNotification('Test Notification', {
|
|
115
|
-
body: 'Push notifications are working correctly',
|
|
116
|
-
tag: 'test'
|
|
117
|
-
}, true);
|
|
118
|
-
return true;
|
|
119
|
-
} catch (error) {
|
|
120
|
-
debug.error('notification', 'Test notification failed:', error);
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Initialize and request permissions if needed
|
|
127
|
-
*/
|
|
128
|
-
async initialize(): Promise<boolean> {
|
|
129
|
-
if (!isSupported()) {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const currentPermission = getPermissionStatus();
|
|
134
|
-
|
|
135
|
-
if (currentPermission === 'default') {
|
|
136
|
-
const permission = await requestPermission();
|
|
137
|
-
return permission === 'granted';
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return currentPermission === 'granted';
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export default pushNotification;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sound Notification Service
|
|
3
|
-
*
|
|
4
|
-
* Handles single audio notification for chat responses using local notification.ogg file
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { settings } from '$frontend/stores/features/settings.svelte';
|
|
8
|
-
|
|
9
|
-
import { debug } from '$shared/utils/logger';
|
|
10
|
-
// Cache for audio element
|
|
11
|
-
let audioElement: HTMLAudioElement | null = null;
|
|
12
|
-
|
|
13
|
-
// Local notification sound file path
|
|
14
|
-
const NOTIFICATION_SOUND_URL = '/audio/notification.ogg';
|
|
15
|
-
|
|
16
|
-
// Initialize audio element
|
|
17
|
-
function initAudioElement(): HTMLAudioElement {
|
|
18
|
-
if (!audioElement) {
|
|
19
|
-
audioElement = new Audio();
|
|
20
|
-
audioElement.preload = 'auto';
|
|
21
|
-
audioElement.volume = 1;
|
|
22
|
-
|
|
23
|
-
// Set the notification sound URL
|
|
24
|
-
audioElement.src = NOTIFICATION_SOUND_URL;
|
|
25
|
-
|
|
26
|
-
// Load the audio to check if it works
|
|
27
|
-
audioElement.load();
|
|
28
|
-
|
|
29
|
-
// Handle loading errors
|
|
30
|
-
audioElement.onerror = (error) => {
|
|
31
|
-
debug.warn('notification', 'Failed to load notification sound from:', NOTIFICATION_SOUND_URL, error);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// Log when audio is ready
|
|
35
|
-
audioElement.oncanplaythrough = () => {
|
|
36
|
-
debug.log('notification', 'Notification sound loaded successfully');
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
return audioElement;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Play notification sound
|
|
43
|
-
function playNotificationSound(isTesting: boolean = false): Promise<void> {
|
|
44
|
-
return new Promise((resolve) => {
|
|
45
|
-
try {
|
|
46
|
-
// Check if sound notifications are enabled
|
|
47
|
-
if (!isTesting && !settings.soundNotifications) {
|
|
48
|
-
resolve();
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Check if browser supports HTML5 Audio
|
|
53
|
-
if (typeof window === 'undefined' || !window.Audio) {
|
|
54
|
-
resolve(); // Silently fail on unsupported browsers
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const audio = initAudioElement();
|
|
59
|
-
|
|
60
|
-
// Reset audio to beginning
|
|
61
|
-
audio.currentTime = 0;
|
|
62
|
-
|
|
63
|
-
// Play audio
|
|
64
|
-
const playPromise = audio.play();
|
|
65
|
-
|
|
66
|
-
if (playPromise !== undefined) {
|
|
67
|
-
playPromise
|
|
68
|
-
.then(() => {
|
|
69
|
-
// Audio played successfully
|
|
70
|
-
audio.onended = () => resolve();
|
|
71
|
-
})
|
|
72
|
-
.catch((error) => {
|
|
73
|
-
debug.warn('notification', 'Failed to play notification sound:', error);
|
|
74
|
-
resolve(); // Don't reject, just silently fail
|
|
75
|
-
});
|
|
76
|
-
} else {
|
|
77
|
-
// Older browser support
|
|
78
|
-
audio.onended = () => resolve();
|
|
79
|
-
setTimeout(() => resolve(), 1000); // Fallback timeout
|
|
80
|
-
}
|
|
81
|
-
} catch (error) {
|
|
82
|
-
debug.warn('notification', 'Failed to play notification sound:', error);
|
|
83
|
-
resolve(); // Don't reject, just silently fail
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Public API
|
|
89
|
-
export const soundNotification = {
|
|
90
|
-
/**
|
|
91
|
-
* Play notification sound (single sound for all notifications)
|
|
92
|
-
*/
|
|
93
|
-
play(): Promise<void> {
|
|
94
|
-
return playNotificationSound();
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Test sound notification (for settings)
|
|
99
|
-
*/
|
|
100
|
-
async testSound(): Promise<boolean> {
|
|
101
|
-
try {
|
|
102
|
-
await playNotificationSound(true);
|
|
103
|
-
return true;
|
|
104
|
-
} catch (error) {
|
|
105
|
-
debug.error('notification', 'Sound test failed:', error);
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Check if sound notifications are supported
|
|
112
|
-
*/
|
|
113
|
-
isSupported(): boolean {
|
|
114
|
-
return typeof window !== 'undefined' && !!window.Audio;
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Initialize audio element (call on user interaction)
|
|
119
|
-
*/
|
|
120
|
-
initialize(): void {
|
|
121
|
-
if (this.isSupported()) {
|
|
122
|
-
initAudioElement();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export default soundNotification;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { debug } from '$shared/utils/logger';
|
|
2
|
-
import ws from '$frontend/utils/ws';
|
|
3
|
-
|
|
4
|
-
export interface ConsoleMessage {
|
|
5
|
-
id: string;
|
|
6
|
-
type: 'log' | 'info' | 'warn' | 'error' | 'debug' | 'trace' | 'clear';
|
|
7
|
-
text: string;
|
|
8
|
-
args?: unknown[];
|
|
9
|
-
location?: {
|
|
10
|
-
url: string;
|
|
11
|
-
lineNumber: number;
|
|
12
|
-
columnNumber: number;
|
|
13
|
-
};
|
|
14
|
-
stackTrace?: string;
|
|
15
|
-
timestamp: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class BrowserConsoleService {
|
|
19
|
-
async getConsoleLogs(sessionId: string): Promise<ConsoleMessage[]> {
|
|
20
|
-
try {
|
|
21
|
-
const result = await ws.http('preview:browser-console-get', {}, 5000);
|
|
22
|
-
return result.logs || [];
|
|
23
|
-
} catch (error) {
|
|
24
|
-
debug.error('preview', 'Error getting console logs:', error);
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async clearConsoleLogs(sessionId: string): Promise<void> {
|
|
30
|
-
try {
|
|
31
|
-
await ws.http('preview:browser-console-clear', {}, 5000);
|
|
32
|
-
} catch (error) {
|
|
33
|
-
debug.error('preview', 'Error clearing console logs:', error);
|
|
34
|
-
throw error;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async executeConsoleCommand(sessionId: string, command: string): Promise<any> {
|
|
39
|
-
try {
|
|
40
|
-
// Backend uses active tab automatically
|
|
41
|
-
const result = await ws.http('preview:browser-console-execute', { command }, 10000);
|
|
42
|
-
return result.result;
|
|
43
|
-
} catch (error) {
|
|
44
|
-
debug.error('preview', 'Error executing console command:', error);
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async toggleConsoleLogging(sessionId: string, enabled: boolean): Promise<void> {
|
|
50
|
-
try {
|
|
51
|
-
// Backend uses active tab automatically
|
|
52
|
-
await ws.http('preview:browser-console-toggle', { enabled }, 5000);
|
|
53
|
-
} catch (error) {
|
|
54
|
-
debug.error('preview', 'Error toggling console logging:', error);
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Singleton instance
|
|
61
|
-
export const browserConsoleService = new BrowserConsoleService();
|