@myrialabs/clopen 0.2.13 → 0.2.15
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/backend/snapshot/helpers.ts +8 -0
- package/backend/snapshot/snapshot-service.ts +9 -7
- package/backend/ws/snapshot/timeline.ts +6 -2
- package/bin/clopen.ts +377 -100
- package/frontend/components/chat/ChatInterface.svelte +6 -1
- package/frontend/components/chat/formatters/Tools.svelte +3 -1
- package/frontend/components/chat/input/components/EngineModelPicker.svelte +12 -1
- package/frontend/components/chat/input/components/LoadingIndicator.svelte +2 -2
- package/frontend/components/chat/message/ChatMessage.svelte +0 -29
- package/frontend/components/chat/message/ChatMessages.svelte +2 -2
- package/frontend/components/chat/message/MessageBubble.svelte +0 -6
- package/frontend/components/chat/message/MessageHeader.svelte +0 -16
- package/frontend/components/chat/tools/SkillTool.svelte +21 -0
- package/frontend/components/chat/tools/index.ts +1 -0
- package/frontend/components/chat/widgets/ContextIndicator.svelte +186 -0
- package/frontend/components/checkpoint/TimelineModal.svelte +3 -1
- package/frontend/components/common/overlay/Dialog.svelte +2 -2
- package/frontend/components/history/HistoryModal.svelte +3 -3
- package/frontend/components/preview/browser/BrowserPreview.svelte +7 -0
- package/frontend/components/preview/browser/components/Canvas.svelte +8 -0
- package/frontend/components/settings/engines/AIEnginesSettings.svelte +1 -1
- package/frontend/components/settings/general/AuthModeSettings.svelte +2 -2
- package/frontend/components/settings/model/EngineModelPicker.svelte +9 -0
- package/frontend/components/tunnel/TunnelInactive.svelte +4 -4
- package/frontend/components/workspace/PanelHeader.svelte +4 -0
- package/frontend/components/workspace/panels/ChatPanel.svelte +6 -0
- package/frontend/services/chat/chat.service.ts +44 -1
- package/frontend/services/terminal/project.service.ts +52 -0
- package/frontend/stores/ui/settings-modal.svelte.ts +1 -1
- package/frontend/stores/ui/theme.svelte.ts +11 -11
- package/frontend/stores/ui/workspace.svelte.ts +1 -1
- package/frontend/utils/chat/message-grouper.ts +33 -5
- package/frontend/utils/chat/message-processor.ts +2 -1
- package/frontend/utils/chat/tool-handler.ts +38 -3
- package/frontend/utils/context-manager.ts +35 -237
- package/index.html +2 -2
- package/package.json +1 -1
- package/shared/types/messaging/index.ts +1 -0
- package/shared/types/messaging/tool.ts +24 -1
- package/shared/utils/anonymous-user.ts +4 -4
- package/shared/utils/ws-client.ts +23 -1
- package/frontend/components/chat/modal/TokenUsageModal.svelte +0 -124
- package/frontend/components/chat/widgets/TokenUsage.svelte +0 -78
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
NotebookEditTool,
|
|
8
8
|
ReadTool, ReadMcpResourceTool, AgentTool, TaskTool, TodoWriteTool,
|
|
9
9
|
WebFetchTool, WebSearchTool, WriteTool, CustomMcpTool,
|
|
10
|
-
AskUserQuestionTool
|
|
10
|
+
AskUserQuestionTool, SkillTool
|
|
11
11
|
} from '../tools';
|
|
12
12
|
|
|
13
13
|
const { toolInput }: { toolInput: ToolInput } = $props();
|
|
@@ -63,6 +63,8 @@
|
|
|
63
63
|
<WriteTool {toolInput} />
|
|
64
64
|
{:else if toolInput.name === 'AskUserQuestion'}
|
|
65
65
|
<AskUserQuestionTool {toolInput} />
|
|
66
|
+
{:else if toolInput.name === 'Skill'}
|
|
67
|
+
<SkillTool {toolInput} />
|
|
66
68
|
{:else}
|
|
67
69
|
<!-- Generic fallback for unknown tools (Config, EnterWorktree, etc.) -->
|
|
68
70
|
<div class="bg-slate-50 dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-lg p-4 mb-4">
|
|
@@ -330,6 +330,12 @@
|
|
|
330
330
|
.join(' ');
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
+
function formatContextWindow(tokens: number): string {
|
|
334
|
+
if (tokens >= 1_000_000) return `${(tokens / 1_000_000).toFixed(tokens % 1_000_000 === 0 ? 0 : 1)}M`;
|
|
335
|
+
if (tokens >= 1_000) return `${(tokens / 1_000).toFixed(tokens % 1_000 === 0 ? 0 : 1)}K`;
|
|
336
|
+
return `${tokens}`;
|
|
337
|
+
}
|
|
338
|
+
|
|
333
339
|
// Dropdown state
|
|
334
340
|
let showDropdown = $state(false);
|
|
335
341
|
let triggerButton: HTMLButtonElement;
|
|
@@ -610,7 +616,12 @@
|
|
|
610
616
|
|
|
611
617
|
<!-- Model info -->
|
|
612
618
|
<div class="flex-1 min-w-0">
|
|
613
|
-
<div class="
|
|
619
|
+
<div class="flex items-center gap-2">
|
|
620
|
+
<span class="font-medium text-xs">{model.name}</span>
|
|
621
|
+
{#if model.contextWindow}
|
|
622
|
+
<span class="text-3xs text-slate-400 dark:text-slate-500">{formatContextWindow(model.contextWindow)}</span>
|
|
623
|
+
{/if}
|
|
624
|
+
</div>
|
|
614
625
|
{#if model.capabilities.length > 0}
|
|
615
626
|
<div class="flex flex-wrap gap-1 mt-1">
|
|
616
627
|
{#each model.capabilities as cap}
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
|
|
14
14
|
{#if appState.isLoading}
|
|
15
15
|
<div
|
|
16
|
-
class="absolute z-20 {isWelcomeState ? '-top-16' : '-top-14'} left-0 right-0 flex justify-center pointer-events-none"
|
|
16
|
+
class="absolute z-20 h-9 {isWelcomeState ? '-top-16' : '-top-14'} left-0 right-0 flex justify-center pointer-events-none"
|
|
17
17
|
transition:fly={{ y: 100, duration: 300 }}
|
|
18
18
|
>
|
|
19
19
|
{#if appState.isWaitingInput}
|
|
20
20
|
<!-- Waiting for user input state -->
|
|
21
|
-
<div class="flex items-center gap-2.5 px-4 py-2 bg-amber-50 dark:bg-amber-
|
|
21
|
+
<div class="flex items-center gap-2.5 px-4 py-2 bg-amber-50 dark:bg-amber-950 rounded-full border border-amber-200 dark:border-amber-900 shadow-sm">
|
|
22
22
|
<Icon name="lucide:message-circle-question-mark" class="w-4 h-4 text-amber-600 dark:text-amber-400" />
|
|
23
23
|
<span class="text-sm font-medium text-amber-700 dark:text-amber-300">
|
|
24
24
|
Waiting for your input...
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
import { startEdit, shouldDimMessage } from '$frontend/stores/ui/edit-mode.svelte';
|
|
22
22
|
import { debug } from '$shared/utils/logger';
|
|
23
23
|
import MessageBubble from './MessageBubble.svelte';
|
|
24
|
-
import TokenUsageModal from '../modal/TokenUsageModal.svelte';
|
|
25
24
|
import DebugModal from '../modal/DebugModal.svelte';
|
|
26
25
|
import Dialog from '$frontend/components/common/overlay/Dialog.svelte';
|
|
27
26
|
import ConflictResolutionModal from '$frontend/components/checkpoint/ConflictResolutionModal.svelte';
|
|
@@ -38,7 +37,6 @@
|
|
|
38
37
|
|
|
39
38
|
// Modal states
|
|
40
39
|
let showDebugPopup = $state(false);
|
|
41
|
-
let showTokenUsagePopup = $state(false);
|
|
42
40
|
let showRestoreConfirm = $state(false);
|
|
43
41
|
|
|
44
42
|
// Conflict resolution state
|
|
@@ -92,15 +90,6 @@
|
|
|
92
90
|
return message.type;
|
|
93
91
|
});
|
|
94
92
|
|
|
95
|
-
// Get token usage data from assistant messages
|
|
96
|
-
const hasTokenUsageData = $derived.by(() => {
|
|
97
|
-
if ((roleCategory === 'assistant' || roleCategory === 'agent') && 'message' in message) {
|
|
98
|
-
const msg = message.message as any;
|
|
99
|
-
return msg.usage || null;
|
|
100
|
-
}
|
|
101
|
-
return null;
|
|
102
|
-
});
|
|
103
|
-
|
|
104
93
|
// Get sender info from metadata
|
|
105
94
|
const senderName = $derived(message.metadata?.sender_name ?? null);
|
|
106
95
|
|
|
@@ -259,14 +248,6 @@
|
|
|
259
248
|
}
|
|
260
249
|
|
|
261
250
|
// Modal handlers
|
|
262
|
-
function openTokenUsageModal() {
|
|
263
|
-
showTokenUsagePopup = true;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function closeTokenUsageModal() {
|
|
267
|
-
showTokenUsagePopup = false;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
251
|
function openDebugInfoModal() {
|
|
271
252
|
showDebugPopup = true;
|
|
272
253
|
}
|
|
@@ -460,12 +441,10 @@
|
|
|
460
441
|
{roleCategory}
|
|
461
442
|
{agentStatus}
|
|
462
443
|
{senderName}
|
|
463
|
-
{hasTokenUsageData}
|
|
464
444
|
{formatTime}
|
|
465
445
|
onCopy={copyToClipboard}
|
|
466
446
|
onRestore={handleRestore}
|
|
467
447
|
onEdit={handleEdit}
|
|
468
|
-
onShowTokenUsage={openTokenUsageModal}
|
|
469
448
|
onShowDebug={openDebugInfoModal}
|
|
470
449
|
/>
|
|
471
450
|
</div>
|
|
@@ -479,14 +458,6 @@
|
|
|
479
458
|
</div>
|
|
480
459
|
</div>
|
|
481
460
|
|
|
482
|
-
<!-- Token Usage Popup -->
|
|
483
|
-
<TokenUsageModal
|
|
484
|
-
bind:isOpen={showTokenUsagePopup}
|
|
485
|
-
tokenUsage={hasTokenUsageData}
|
|
486
|
-
timestamp={messageTimestamp}
|
|
487
|
-
onClose={closeTokenUsageModal}
|
|
488
|
-
/>
|
|
489
|
-
|
|
490
461
|
<!-- Debug Info Popup -->
|
|
491
462
|
<DebugModal
|
|
492
463
|
bind:isOpen={showDebugPopup}
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
|
|
50
50
|
// Process messages through grouping and embedding
|
|
51
51
|
const processedMessages = $derived.by(() => {
|
|
52
|
-
const { groups, toolUseMap, subAgentMap } = groupMessages(sessionState.messages);
|
|
53
|
-
return embedToolResults(groups, toolUseMap, subAgentMap);
|
|
52
|
+
const { groups, toolUseMap, subAgentMap, skillPromptMap } = groupMessages(sessionState.messages);
|
|
53
|
+
return embedToolResults(groups, toolUseMap, subAgentMap, skillPromptMap);
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
// Filter out messages with empty content arrays
|
|
@@ -24,12 +24,10 @@
|
|
|
24
24
|
roleCategory,
|
|
25
25
|
agentStatus,
|
|
26
26
|
senderName,
|
|
27
|
-
hasTokenUsageData,
|
|
28
27
|
formatTime,
|
|
29
28
|
onCopy,
|
|
30
29
|
onRestore,
|
|
31
30
|
onEdit,
|
|
32
|
-
onShowTokenUsage,
|
|
33
31
|
onShowDebug
|
|
34
32
|
}: {
|
|
35
33
|
message: SDKMessageFormatter;
|
|
@@ -39,12 +37,10 @@
|
|
|
39
37
|
roleCategory: 'user' | 'assistant' | 'agent' | string;
|
|
40
38
|
agentStatus: 'processing' | 'waiting' | 'success' | 'error' | null;
|
|
41
39
|
senderName: string | null;
|
|
42
|
-
hasTokenUsageData: any;
|
|
43
40
|
formatTime: (timestamp?: string) => string;
|
|
44
41
|
onCopy: () => void;
|
|
45
42
|
onRestore: () => void;
|
|
46
43
|
onEdit: () => void;
|
|
47
|
-
onShowTokenUsage: () => void;
|
|
48
44
|
onShowDebug: () => void;
|
|
49
45
|
} = $props();
|
|
50
46
|
|
|
@@ -94,12 +90,10 @@
|
|
|
94
90
|
{roleCategory}
|
|
95
91
|
{agentStatus}
|
|
96
92
|
{senderName}
|
|
97
|
-
{hasTokenUsageData}
|
|
98
93
|
{formatTime}
|
|
99
94
|
{onCopy}
|
|
100
95
|
{onRestore}
|
|
101
96
|
{onEdit}
|
|
102
|
-
{onShowTokenUsage}
|
|
103
97
|
{onShowDebug}
|
|
104
98
|
/>
|
|
105
99
|
|
|
@@ -22,12 +22,10 @@
|
|
|
22
22
|
roleCategory,
|
|
23
23
|
agentStatus,
|
|
24
24
|
senderName,
|
|
25
|
-
hasTokenUsageData,
|
|
26
25
|
formatTime,
|
|
27
26
|
onCopy,
|
|
28
27
|
onRestore,
|
|
29
28
|
onEdit,
|
|
30
|
-
onShowTokenUsage,
|
|
31
29
|
onShowDebug
|
|
32
30
|
}: {
|
|
33
31
|
message: SDKMessageFormatter;
|
|
@@ -37,12 +35,10 @@
|
|
|
37
35
|
roleCategory: 'user' | 'assistant' | 'agent' | string;
|
|
38
36
|
agentStatus: 'processing' | 'waiting' | 'success' | 'error' | null;
|
|
39
37
|
senderName: string | null;
|
|
40
|
-
hasTokenUsageData: any;
|
|
41
38
|
formatTime: (timestamp?: string) => string;
|
|
42
39
|
onCopy: () => void;
|
|
43
40
|
onRestore: () => void;
|
|
44
41
|
onEdit: () => void;
|
|
45
|
-
onShowTokenUsage: () => void;
|
|
46
42
|
onShowDebug: () => void;
|
|
47
43
|
} = $props();
|
|
48
44
|
|
|
@@ -134,18 +130,6 @@
|
|
|
134
130
|
</button>
|
|
135
131
|
{/if}
|
|
136
132
|
|
|
137
|
-
<!-- Token Usage button -->
|
|
138
|
-
{#if hasTokenUsageData}
|
|
139
|
-
<button
|
|
140
|
-
onclick={onShowTokenUsage}
|
|
141
|
-
class="inline-flex p-1.5 rounded-md hover:bg-slate-200 dark:hover:bg-slate-600 transition-colors opacity-60 hover:opacity-100"
|
|
142
|
-
aria-label="Show token usage info"
|
|
143
|
-
title="Token usage"
|
|
144
|
-
>
|
|
145
|
-
<Icon name="lucide:zap" class="w-3.5 h-3.5" />
|
|
146
|
-
</button>
|
|
147
|
-
{/if}
|
|
148
|
-
|
|
149
133
|
<!-- Debug toggle button -->
|
|
150
134
|
<button
|
|
151
135
|
onclick={onShowDebug}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SkillToolInput } from '$shared/types/messaging';
|
|
3
|
+
import { InfoLine } from './components';
|
|
4
|
+
import TextMessage from '../formatters/TextMessage.svelte';
|
|
5
|
+
|
|
6
|
+
const { toolInput }: { toolInput: SkillToolInput } = $props();
|
|
7
|
+
|
|
8
|
+
const skillName = $derived(toolInput.input.skill || '');
|
|
9
|
+
const skillArgs = $derived(toolInput.input.args || '');
|
|
10
|
+
const skillPrompt = $derived(toolInput.$skillPrompt);
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div class="bg-white dark:bg-slate-800 rounded-md border border-slate-200/60 dark:border-slate-700/60 p-3">
|
|
14
|
+
<div class="space-y-1">
|
|
15
|
+
<InfoLine icon="lucide:zap" text="/{skillName}{skillArgs ? ` ${skillArgs}` : ''}" />
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
{#if skillPrompt}
|
|
20
|
+
<TextMessage content={skillPrompt} />
|
|
21
|
+
{/if}
|
|
@@ -18,6 +18,7 @@ export { default as WebFetchTool } from './WebFetchTool.svelte';
|
|
|
18
18
|
export { default as WebSearchTool } from './WebSearchTool.svelte';
|
|
19
19
|
export { default as WriteTool } from './WriteTool.svelte';
|
|
20
20
|
export { default as AskUserQuestionTool } from './AskUserQuestionTool.svelte';
|
|
21
|
+
export { default as SkillTool } from './SkillTool.svelte';
|
|
21
22
|
|
|
22
23
|
// Custom MCP Tools
|
|
23
24
|
export { default as CustomMcpTool } from './CustomMcpTool.svelte';
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Context Window Indicator (compact)
|
|
3
|
+
|
|
4
|
+
Displays remaining context window as a mini progress bar in the PanelHeader.
|
|
5
|
+
Click to show detail popover with token breakdown.
|
|
6
|
+
Uses the session's actual model to determine context window size.
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import { sessionState } from '$frontend/stores/core/sessions.svelte';
|
|
11
|
+
import { settings } from '$frontend/stores/features/settings.svelte';
|
|
12
|
+
import { modelStore } from '$frontend/stores/features/models.svelte';
|
|
13
|
+
import { getContextUsage } from '$frontend/utils/context-manager';
|
|
14
|
+
import Icon from '$frontend/components/common/display/Icon.svelte';
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
isMobile?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const { isMobile = false }: Props = $props();
|
|
21
|
+
|
|
22
|
+
// Resolve model: prefer session model (actual), fallback to selected model
|
|
23
|
+
const model = $derived(
|
|
24
|
+
modelStore.getById(sessionState.currentSession?.model || settings.selectedModel)
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const usage = $derived(
|
|
28
|
+
model ? getContextUsage(sessionState.messages, model.contextWindow) : null
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const barColor = $derived.by(() => {
|
|
32
|
+
if (!usage) return 'bg-slate-400';
|
|
33
|
+
if (usage.percentage >= 90) return 'bg-red-500';
|
|
34
|
+
if (usage.percentage >= 80) return 'bg-amber-500';
|
|
35
|
+
if (usage.percentage >= 60) return 'bg-yellow-500';
|
|
36
|
+
return 'bg-emerald-500';
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const textColor = $derived.by(() => {
|
|
40
|
+
if (!usage) return 'text-slate-400';
|
|
41
|
+
if (usage.percentage >= 90) return 'text-red-500';
|
|
42
|
+
if (usage.percentage >= 80) return 'text-amber-500';
|
|
43
|
+
if (usage.percentage >= 60) return 'text-yellow-500';
|
|
44
|
+
return 'text-slate-500';
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Popover state
|
|
48
|
+
let showPopover = $state(false);
|
|
49
|
+
let containerRef = $state<HTMLDivElement | null>(null);
|
|
50
|
+
|
|
51
|
+
function togglePopover(e: MouseEvent) {
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
showPopover = !showPopover;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
$effect(() => {
|
|
57
|
+
if (showPopover) {
|
|
58
|
+
const handleClickOutside = (e: MouseEvent) => {
|
|
59
|
+
if (containerRef && !containerRef.contains(e.target as Node)) {
|
|
60
|
+
showPopover = false;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
document.addEventListener('click', handleClickOutside, true);
|
|
64
|
+
return () => document.removeEventListener('click', handleClickOutside, true);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Format token numbers compactly (e.g. 125k, 1.2M)
|
|
69
|
+
function formatTokens(n: number): string {
|
|
70
|
+
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;
|
|
71
|
+
if (n >= 1_000) return `${Math.round(n / 1_000)}k`;
|
|
72
|
+
return n.toString();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Get last assistant message usage for detail breakdown
|
|
76
|
+
const lastUsage = $derived.by(() => {
|
|
77
|
+
for (let i = sessionState.messages.length - 1; i >= 0; i--) {
|
|
78
|
+
const msg = sessionState.messages[i];
|
|
79
|
+
if (msg.type === 'assistant' && 'message' in msg) {
|
|
80
|
+
const u = (msg as any).message?.usage;
|
|
81
|
+
if (u && typeof u.input_tokens === 'number') return u;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
});
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
{#if usage}
|
|
89
|
+
<div class="relative" bind:this={containerRef}>
|
|
90
|
+
<button
|
|
91
|
+
type="button"
|
|
92
|
+
class="flex items-center gap-1.5 {isMobile ? 'px-2.5 h-9' : 'px-2 h-6'} bg-transparent border-none rounded-md cursor-pointer transition-all duration-150 hover:bg-violet-500/10 group"
|
|
93
|
+
onclick={togglePopover}
|
|
94
|
+
title="Context: {formatTokens(usage.current)} / {formatTokens(usage.max)} ({Math.round(usage.percentage)}%)"
|
|
95
|
+
>
|
|
96
|
+
<div class="flex items-center gap-1.5">
|
|
97
|
+
<div class="{isMobile ? 'w-14' : 'w-12'} h-2 bg-slate-200 dark:bg-slate-700 rounded-full overflow-hidden">
|
|
98
|
+
<div
|
|
99
|
+
class="{barColor} h-full transition-all duration-500"
|
|
100
|
+
style="width: {Math.min(usage.percentage, 100)}%"
|
|
101
|
+
></div>
|
|
102
|
+
</div>
|
|
103
|
+
<span class="text-2xs font-medium {textColor} tabular-nums group-hover:text-slate-900 dark:group-hover:text-slate-100 transition-colors">
|
|
104
|
+
{Math.round(usage.percentage)}%
|
|
105
|
+
</span>
|
|
106
|
+
</div>
|
|
107
|
+
</button>
|
|
108
|
+
|
|
109
|
+
<!-- Detail popover -->
|
|
110
|
+
{#if showPopover}
|
|
111
|
+
<div class="fixed inset-0 z-40" onclick={() => showPopover = false}></div>
|
|
112
|
+
<div class="absolute top-full right-0 mt-2 z-50 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-lg shadow-lg min-w-60 p-3.5">
|
|
113
|
+
<div class="flex items-center gap-2 mb-3">
|
|
114
|
+
<Icon name="lucide:brain" class="w-4 h-4 text-violet-500" />
|
|
115
|
+
<span class="text-xs font-semibold text-slate-900 dark:text-slate-100">Context Window</span>
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
<!-- Progress bar (larger) -->
|
|
119
|
+
<div class="mb-3">
|
|
120
|
+
<div class="w-full h-2.5 bg-slate-200 dark:bg-slate-700 rounded-full overflow-hidden">
|
|
121
|
+
<div
|
|
122
|
+
class="{barColor} h-full transition-all duration-500"
|
|
123
|
+
style="width: {Math.min(usage.percentage, 100)}%"
|
|
124
|
+
></div>
|
|
125
|
+
</div>
|
|
126
|
+
<div class="flex justify-between mt-1.5">
|
|
127
|
+
<span class="text-2xs text-slate-500">{formatTokens(usage.current)} used</span>
|
|
128
|
+
<span class="text-2xs text-slate-500">{formatTokens(usage.max)} max</span>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
<!-- Token breakdown -->
|
|
133
|
+
{#if lastUsage}
|
|
134
|
+
<div class="space-y-2 border-t border-slate-200 dark:border-slate-700 pt-2.5">
|
|
135
|
+
{#if model}
|
|
136
|
+
<div class="flex justify-between items-center">
|
|
137
|
+
<span class="text-2xs text-slate-500">Model</span>
|
|
138
|
+
<span class="text-2xs font-mono font-medium text-slate-700 dark:text-slate-300 truncate max-w-32">
|
|
139
|
+
{model.name}
|
|
140
|
+
</span>
|
|
141
|
+
</div>
|
|
142
|
+
{/if}
|
|
143
|
+
<div class="flex justify-between items-center">
|
|
144
|
+
<span class="text-2xs text-slate-500">Input</span>
|
|
145
|
+
<span class="text-2xs font-mono font-medium text-slate-700 dark:text-slate-300">
|
|
146
|
+
{(lastUsage.input_tokens ?? 0).toLocaleString()}
|
|
147
|
+
</span>
|
|
148
|
+
</div>
|
|
149
|
+
<div class="flex justify-between items-center">
|
|
150
|
+
<span class="text-2xs text-slate-500">Output</span>
|
|
151
|
+
<span class="text-2xs font-mono font-medium text-slate-700 dark:text-slate-300">
|
|
152
|
+
{(lastUsage.output_tokens ?? 0).toLocaleString()}
|
|
153
|
+
</span>
|
|
154
|
+
</div>
|
|
155
|
+
{#if lastUsage.cache_read_input_tokens > 0}
|
|
156
|
+
<div class="flex justify-between items-center">
|
|
157
|
+
<span class="text-2xs text-slate-500">Cache Read</span>
|
|
158
|
+
<span class="text-2xs font-mono font-medium text-emerald-600 dark:text-emerald-400">
|
|
159
|
+
{(lastUsage.cache_read_input_tokens).toLocaleString()}
|
|
160
|
+
</span>
|
|
161
|
+
</div>
|
|
162
|
+
{/if}
|
|
163
|
+
{#if lastUsage.cache_creation_input_tokens > 0}
|
|
164
|
+
<div class="flex justify-between items-center">
|
|
165
|
+
<span class="text-2xs text-slate-500">Cache Write</span>
|
|
166
|
+
<span class="text-2xs font-mono font-medium text-slate-700 dark:text-slate-300">
|
|
167
|
+
{(lastUsage.cache_creation_input_tokens).toLocaleString()}
|
|
168
|
+
</span>
|
|
169
|
+
</div>
|
|
170
|
+
{/if}
|
|
171
|
+
</div>
|
|
172
|
+
{/if}
|
|
173
|
+
|
|
174
|
+
<!-- Remaining -->
|
|
175
|
+
<div class="border-t border-slate-200 dark:border-slate-700 pt-2.5 mt-2.5">
|
|
176
|
+
<div class="flex justify-between items-center">
|
|
177
|
+
<span class="text-2xs font-medium text-slate-600 dark:text-slate-400">Remaining</span>
|
|
178
|
+
<span class="text-2xs font-mono font-semibold {textColor}">
|
|
179
|
+
{formatTokens(Math.max(0, usage.max - usage.current))} tokens
|
|
180
|
+
</span>
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
{/if}
|
|
185
|
+
</div>
|
|
186
|
+
{/if}
|
|
@@ -247,9 +247,11 @@
|
|
|
247
247
|
const previousCurrentId = timelineData?.currentHeadId;
|
|
248
248
|
if (timelineData) {
|
|
249
249
|
timelineData.currentHeadId = node.id;
|
|
250
|
+
const isInitialRestore = !!node.checkpoint.isInitial;
|
|
250
251
|
graphNodes = graphNodes.map(n => ({
|
|
251
252
|
...n,
|
|
252
|
-
isCurrent: n.id === node.id
|
|
253
|
+
isCurrent: n.id === node.id,
|
|
254
|
+
isOrphaned: isInitialRestore ? n.id !== node.id : n.isOrphaned
|
|
253
255
|
}));
|
|
254
256
|
}
|
|
255
257
|
|
|
@@ -201,7 +201,7 @@
|
|
|
201
201
|
</div>
|
|
202
202
|
{/if}
|
|
203
203
|
|
|
204
|
-
<div class="flex-1 space-y-
|
|
204
|
+
<div class="flex-1 space-y-1">
|
|
205
205
|
<h3 id="dialog-title" class="text-lg font-semibold {colors.text}">
|
|
206
206
|
{title}
|
|
207
207
|
</h3>
|
|
@@ -227,7 +227,7 @@
|
|
|
227
227
|
</div>
|
|
228
228
|
{/if}
|
|
229
229
|
|
|
230
|
-
{#if !children}
|
|
230
|
+
{#if !children || onConfirm}
|
|
231
231
|
<div class="flex justify-end gap-3 pt-2">
|
|
232
232
|
{#if showCancel}
|
|
233
233
|
<button
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { isSessionUnread } from '$frontend/stores/core/app.svelte';
|
|
14
14
|
import { userStore } from '$frontend/stores/features/user.svelte';
|
|
15
15
|
import { debug } from '$shared/utils/logger';
|
|
16
|
+
import { modelStore } from '$frontend/stores/features/models.svelte';
|
|
16
17
|
|
|
17
18
|
interface Props {
|
|
18
19
|
isOpen: boolean;
|
|
@@ -212,9 +213,8 @@
|
|
|
212
213
|
|
|
213
214
|
// Get the engine/model display for a session
|
|
214
215
|
function getSessionModel(session: ChatSession): string {
|
|
215
|
-
if (session.
|
|
216
|
-
|
|
217
|
-
return parts.length > 1 ? parts[1] : session.model;
|
|
216
|
+
if (session.model) {
|
|
217
|
+
return modelStore.getById(session.model)?.name || session.model;
|
|
218
218
|
}
|
|
219
219
|
return '';
|
|
220
220
|
}
|
|
@@ -299,6 +299,13 @@
|
|
|
299
299
|
}
|
|
300
300
|
});
|
|
301
301
|
|
|
302
|
+
// Sync isNavigating back to active tab (Canvas resets this on first frame after navigation)
|
|
303
|
+
$effect(() => {
|
|
304
|
+
if (activeTabId && activeTab && activeTab.isNavigating !== isNavigating) {
|
|
305
|
+
tabManager.updateTab(activeTabId, { isNavigating });
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
|
|
302
309
|
// Watch scale changes and send to backend
|
|
303
310
|
let lastSentScale = 1;
|
|
304
311
|
$effect(() => {
|
|
@@ -573,6 +573,14 @@
|
|
|
573
573
|
isReconnecting = false;
|
|
574
574
|
}, 300);
|
|
575
575
|
}
|
|
576
|
+
|
|
577
|
+
// Reset navigation state when first frame arrives after navigation.
|
|
578
|
+
// The preview:browser-navigation event that normally resets this can be
|
|
579
|
+
// missed during stream reconnect (listeners are removed/re-registered),
|
|
580
|
+
// so use the first rendered frame as definitive signal that navigation completed.
|
|
581
|
+
if (isNavigating) {
|
|
582
|
+
isNavigating = false;
|
|
583
|
+
}
|
|
576
584
|
});
|
|
577
585
|
|
|
578
586
|
// Setup cursor change handler
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
let openCodeCommandCopiedTimer: ReturnType<typeof setTimeout> | null = null;
|
|
74
74
|
|
|
75
75
|
// Debug PTY (xterm.js)
|
|
76
|
-
const showDebug = $state(
|
|
76
|
+
const showDebug = $state(false);
|
|
77
77
|
let debugTermContainer = $state<HTMLDivElement>();
|
|
78
78
|
let debugTerminal: Terminal | null = null;
|
|
79
79
|
let debugFitAddon: FitAddon | null = null;
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
<Icon name="lucide:triangle-alert" class="w-6 h-6 text-amber-600 dark:text-amber-400" />
|
|
189
189
|
</div>
|
|
190
190
|
|
|
191
|
-
<div class="flex-1 space-y-
|
|
191
|
+
<div class="flex-1 space-y-1">
|
|
192
192
|
<h3 class="text-lg font-semibold text-slate-900 dark:text-slate-100">
|
|
193
193
|
Change Authentication Mode
|
|
194
194
|
</h3>
|
|
@@ -197,7 +197,7 @@
|
|
|
197
197
|
</p>
|
|
198
198
|
|
|
199
199
|
<!-- PAT Display -->
|
|
200
|
-
<div class="p-3.5 rounded-lg bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800">
|
|
200
|
+
<div class="mt-3 p-3.5 rounded-lg bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800">
|
|
201
201
|
<div class="flex items-center gap-2 text-sm font-semibold text-amber-800 dark:text-amber-200 mb-2">
|
|
202
202
|
<Icon name="lucide:key-round" class="w-4 h-4" />
|
|
203
203
|
<span>Your Personal Access Token</span>
|
|
@@ -82,6 +82,12 @@
|
|
|
82
82
|
return provider.split(/[-_]/).map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ');
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
function formatContextWindow(tokens: number): string {
|
|
86
|
+
if (tokens >= 1_000_000) return `${(tokens / 1_000_000).toFixed(tokens % 1_000_000 === 0 ? 0 : 1)}M`;
|
|
87
|
+
if (tokens >= 1_000) return `${(tokens / 1_000).toFixed(tokens % 1_000 === 0 ? 0 : 1)}K`;
|
|
88
|
+
return `${tokens}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
85
91
|
async function handleEngineChange(engineType: EngineType) {
|
|
86
92
|
searchQuery = '';
|
|
87
93
|
onEngineChange(engineType);
|
|
@@ -253,6 +259,9 @@
|
|
|
253
259
|
<div class="flex-1 min-w-0">
|
|
254
260
|
<div class="flex items-center gap-2">
|
|
255
261
|
<span class="text-sm font-medium text-slate-900 dark:text-slate-100">{mdl.name}</span>
|
|
262
|
+
{#if mdl.contextWindow}
|
|
263
|
+
<span class="text-2xs text-slate-400 dark:text-slate-500">{formatContextWindow(mdl.contextWindow)}</span>
|
|
264
|
+
{/if}
|
|
256
265
|
</div>
|
|
257
266
|
{#if caps.length > 0}
|
|
258
267
|
<div class="flex flex-wrap gap-1 mt-1.5">
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// Info box visibility - load from localStorage
|
|
16
16
|
let showInfoBox = $state(
|
|
17
17
|
typeof window !== 'undefined'
|
|
18
|
-
? localStorage.getItem('tunnel-info-dismissed') !== 'true'
|
|
18
|
+
? localStorage.getItem('clopen-tunnel-info-dismissed') !== 'true'
|
|
19
19
|
: true
|
|
20
20
|
);
|
|
21
21
|
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
|
|
33
33
|
// Save "don't show again" preference
|
|
34
34
|
if (dontShowWarningAgain) {
|
|
35
|
-
localStorage.setItem('tunnel-warning-dismissed', 'true');
|
|
35
|
+
localStorage.setItem('clopen-tunnel-warning-dismissed', 'true');
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// Close modal immediately
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
warningDismissed = false;
|
|
60
60
|
|
|
61
61
|
// Check if user has dismissed warning permanently
|
|
62
|
-
const securityWarningDismissed = localStorage.getItem('tunnel-warning-dismissed') === 'true';
|
|
62
|
+
const securityWarningDismissed = localStorage.getItem('clopen-tunnel-warning-dismissed') === 'true';
|
|
63
63
|
if (securityWarningDismissed) {
|
|
64
64
|
// Skip warning and start tunnel directly
|
|
65
65
|
handleStartTunnel();
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
|
|
71
71
|
function closeInfoBox() {
|
|
72
72
|
showInfoBox = false;
|
|
73
|
-
localStorage.setItem('tunnel-info-dismissed', 'true');
|
|
73
|
+
localStorage.setItem('clopen-tunnel-info-dismissed', 'true');
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
function dismissError() {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
import type { DeviceSize } from '$frontend/utils/preview-constants';
|
|
21
21
|
|
|
22
22
|
import { DEVICE_VIEWPORTS } from '$frontend/utils/preview-constants';
|
|
23
|
+
import ContextIndicator from '$frontend/components/chat/widgets/ContextIndicator.svelte';
|
|
23
24
|
|
|
24
25
|
interface Props {
|
|
25
26
|
panelId: PanelId;
|
|
@@ -247,6 +248,9 @@
|
|
|
247
248
|
<!-- Panel-specific actions -->
|
|
248
249
|
<div class="flex items-center gap-1.5">
|
|
249
250
|
{#if panelId === 'chat'}
|
|
251
|
+
{#if sessionState.messages.length > 0 || sessionState.hasMessageHistory}
|
|
252
|
+
<ContextIndicator {isMobile} />
|
|
253
|
+
{/if}
|
|
250
254
|
{#if chatSessionUsers.length > 0}
|
|
251
255
|
<div class="relative" bind:this={chatUsersContainer}>
|
|
252
256
|
<div class="flex items-center -space-x-1.5 mr-1 cursor-pointer" title="Users in this session" onclick={toggleChatUsersPopover}>
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { chatService } from '$frontend/services/chat/chat.service';
|
|
17
17
|
import { setSkipNextRestore } from '$frontend/stores/ui/chat-input.svelte';
|
|
18
18
|
import { userStore } from '$frontend/stores/features/user.svelte';
|
|
19
|
+
import { cancelEdit, editModeState } from '$frontend/stores/ui/edit-mode.svelte';
|
|
19
20
|
|
|
20
21
|
// Props
|
|
21
22
|
interface Props {
|
|
@@ -147,6 +148,11 @@
|
|
|
147
148
|
return;
|
|
148
149
|
}
|
|
149
150
|
|
|
151
|
+
// Clear edit mode if active
|
|
152
|
+
if (editModeState.isEditing) {
|
|
153
|
+
cancelEdit();
|
|
154
|
+
}
|
|
155
|
+
|
|
150
156
|
// Reset frontend state without killing the backend stream
|
|
151
157
|
// The old session's stream continues running in the background
|
|
152
158
|
if (appState.isLoading) {
|