@myrialabs/clopen 0.2.14 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/backend/engine/adapters/opencode/server.ts +72 -33
  2. package/backend/snapshot/helpers.ts +8 -0
  3. package/backend/tunnel/cloudflared/binary.ts +153 -0
  4. package/backend/tunnel/cloudflared/index.ts +21 -0
  5. package/backend/tunnel/cloudflared/tunnel.ts +389 -0
  6. package/backend/tunnel/global-tunnel-manager.ts +538 -152
  7. package/backend/tunnel/project-tunnel-manager.ts +6 -14
  8. package/backend/tunnel/tunnel-config.ts +234 -0
  9. package/backend/ws/tunnel/config.ts +108 -0
  10. package/backend/ws/tunnel/index.ts +3 -1
  11. package/backend/ws/tunnel/operations.ts +290 -43
  12. package/bin/clopen.ts +1 -1
  13. package/bun.lock +0 -4
  14. package/frontend/App.svelte +2 -1
  15. package/frontend/components/chat/ChatInterface.svelte +6 -1
  16. package/frontend/components/chat/formatters/Tools.svelte +3 -1
  17. package/frontend/components/chat/input/components/EngineModelPicker.svelte +12 -1
  18. package/frontend/components/chat/message/ChatMessage.svelte +0 -29
  19. package/frontend/components/chat/message/ChatMessages.svelte +2 -2
  20. package/frontend/components/chat/message/MessageBubble.svelte +0 -6
  21. package/frontend/components/chat/message/MessageHeader.svelte +0 -16
  22. package/frontend/components/chat/tools/SkillTool.svelte +21 -0
  23. package/frontend/components/chat/tools/index.ts +1 -0
  24. package/frontend/components/chat/widgets/ContextIndicator.svelte +186 -0
  25. package/frontend/components/history/HistoryModal.svelte +3 -3
  26. package/frontend/components/settings/SettingsModal.svelte +5 -0
  27. package/frontend/components/settings/SettingsView.svelte +4 -0
  28. package/frontend/components/settings/model/EngineModelPicker.svelte +9 -0
  29. package/frontend/components/settings/tunnel/TunnelSettings.svelte +1060 -0
  30. package/frontend/components/tunnel/TunnelActive.svelte +132 -71
  31. package/frontend/components/tunnel/TunnelButton.svelte +4 -4
  32. package/frontend/components/tunnel/TunnelInactive.svelte +38 -65
  33. package/frontend/components/tunnel/TunnelModal.svelte +55 -2
  34. package/frontend/components/workspace/PanelHeader.svelte +4 -0
  35. package/frontend/components/workspace/WorkspaceLayout.svelte +31 -1
  36. package/frontend/components/workspace/panels/ChatPanel.svelte +6 -0
  37. package/frontend/services/favicon.service.ts +103 -0
  38. package/frontend/services/terminal/project.service.ts +52 -0
  39. package/frontend/stores/features/tunnel-config.svelte.ts +205 -0
  40. package/frontend/stores/features/tunnel.svelte.ts +194 -80
  41. package/frontend/stores/ui/settings-modal.svelte.ts +7 -0
  42. package/frontend/utils/chat/message-grouper.ts +33 -5
  43. package/frontend/utils/chat/message-processor.ts +2 -1
  44. package/frontend/utils/chat/tool-handler.ts +38 -3
  45. package/frontend/utils/context-manager.ts +35 -237
  46. package/package.json +1 -2
  47. package/shared/types/messaging/index.ts +1 -0
  48. package/shared/types/messaging/tool.ts +24 -1
  49. package/shared/utils/ws-client.ts +23 -1
  50. package/frontend/components/chat/modal/TokenUsageModal.svelte +0 -124
  51. package/frontend/components/chat/widgets/TokenUsage.svelte +0 -78
@@ -3,46 +3,84 @@
3
3
  import Icon from '$frontend/components/common/display/Icon.svelte';
4
4
  import TunnelQRCode from './TunnelQRCode.svelte';
5
5
  import { addNotification } from '$frontend/stores/ui/notification.svelte';
6
+ import { debug } from '$shared/utils/logger';
6
7
 
7
8
  import { onMount } from 'svelte';
8
9
 
10
+ interface IngressInfo {
11
+ hostname?: string;
12
+ service: string;
13
+ }
14
+
9
15
  interface Props {
10
16
  port: number;
11
17
  publicUrl: string;
12
18
  startedAt: string;
13
19
  autoStopMinutes: number;
20
+ type?: 'quick' | 'remote' | 'local';
21
+ label?: string;
22
+ configId?: string;
23
+ ingress?: IngressInfo[];
14
24
  }
15
25
 
16
- const { port, publicUrl, startedAt, autoStopMinutes }: Props = $props();
26
+ const { port, publicUrl, startedAt, autoStopMinutes, type = 'quick', label, configId, ingress }: Props = $props();
27
+
28
+ const isQuick = $derived(type === 'quick');
29
+ const displayLabel = $derived(
30
+ label ? label : isQuick ? `Port ${port}` : type === 'remote' ? 'Remote Tunnel' : 'Local Tunnel'
31
+ );
32
+ const typeIcon = $derived(
33
+ type === 'remote' ? 'lucide:cloud' : type === 'local' ? 'lucide:server' : 'lucide:zap'
34
+ );
35
+ const typeBadge = $derived(
36
+ type === 'remote' ? 'Remote' : type === 'local' ? 'Local' : 'Quick'
37
+ );
38
+ const ingressHostnames = $derived(ingress?.filter((r) => r.hostname) ?? []);
39
+ const isManagedTunnel = $derived(type === 'remote' || type === 'local');
40
+
41
+ // Build a unified list of URL entries for consistent rendering
42
+ const urlEntries = $derived(() => {
43
+ if (ingressHostnames.length > 0) {
44
+ return ingressHostnames.map((r) => ({
45
+ url: `https://${r.hostname}`,
46
+ hostname: r.hostname!,
47
+ service: r.service
48
+ }));
49
+ }
50
+ if (publicUrl) {
51
+ return [{ url: publicUrl, hostname: publicUrl.replace(/^https?:\/\//, ''), service: `http://localhost:${port}` }];
52
+ }
53
+ return [];
54
+ });
17
55
 
18
- let showQR = $state(false);
19
- let copied = $state(false);
56
+ let qrUrl = $state('');
57
+ let copiedUrl = $state<string | null>(null);
20
58
  let now = $state(Date.now());
21
59
 
22
- // Update every second for countdown
60
+ // Update every second for countdown (only needed for quick tunnels with auto-stop)
23
61
  onMount(() => {
62
+ if (!isQuick || autoStopMinutes === 0) return;
24
63
  const interval = setInterval(() => {
25
64
  now = Date.now();
26
65
  }, 1000);
27
66
  return () => clearInterval(interval);
28
67
  });
29
68
 
30
- async function copyUrl() {
69
+ async function copyUrl(url: string) {
31
70
  try {
32
- await navigator.clipboard.writeText(publicUrl);
33
- copied = true;
71
+ await navigator.clipboard.writeText(url);
72
+ copiedUrl = url;
34
73
  addNotification({
35
74
  type: 'success',
36
75
  title: 'Success',
37
76
  message: 'URL copied to clipboard'
38
77
  });
39
78
 
40
- // Reset icon after 2 seconds
41
79
  setTimeout(() => {
42
- copied = false;
80
+ copiedUrl = null;
43
81
  }, 2000);
44
82
  } catch (error) {
45
- console.error('Failed to copy:', error);
83
+ debug.error('tunnel', 'Failed to copy:', error);
46
84
  addNotification({
47
85
  type: 'error',
48
86
  title: 'Error',
@@ -53,14 +91,14 @@
53
91
 
54
92
  async function handleStopTunnel() {
55
93
  try {
56
- await tunnelStore.stopTunnel(port);
94
+ await tunnelStore.stopQuickTunnel(port);
57
95
  addNotification({
58
96
  type: 'success',
59
97
  title: 'Success',
60
98
  message: `Tunnel on port ${port} stopped`
61
99
  });
62
100
  } catch (error) {
63
- console.error('Failed to stop tunnel:', error);
101
+ debug.error('tunnel', 'Failed to stop tunnel:', error);
64
102
  addNotification({
65
103
  type: 'error',
66
104
  title: 'Error',
@@ -70,6 +108,8 @@
70
108
  }
71
109
 
72
110
  function getCountdown(startedAt: string, autoStopMins: number, currentTime: number): string {
111
+ if (autoStopMins === 0) return 'No limit';
112
+
73
113
  const start = new Date(startedAt).getTime();
74
114
  const endTime = start + autoStopMins * 60 * 1000;
75
115
  const remainingMs = endTime - currentTime;
@@ -87,70 +127,91 @@
87
127
  }
88
128
  </script>
89
129
 
90
- <div class="bg-white dark:bg-slate-800/50 border border-slate-200 dark:border-slate-700 rounded-lg p-4">
130
+ <div class="bg-white dark:bg-slate-800/50 border border-slate-200 dark:border-slate-700 rounded-lg overflow-hidden">
91
131
  <!-- Header -->
92
- <div class="flex items-start justify-between gap-3 mb-3">
93
- <div class="flex items-center gap-2">
94
- <div class="flex items-center gap-1.5">
95
- <div class="w-2 h-2 rounded-full bg-green-500"></div>
96
- <span class="text-sm font-semibold text-slate-900 dark:text-slate-100">Port {port}</span>
97
- </div>
98
- <span class="text-xs text-slate-500 dark:text-slate-400">{getCountdown(startedAt, autoStopMinutes, now)}</span>
132
+ <div class="flex items-center justify-between gap-3 px-4 py-3 border-b border-slate-100 dark:border-slate-700/50">
133
+ <div class="flex items-center gap-2.5">
134
+ <Icon name={typeIcon} class="w-4 h-4 text-slate-500 dark:text-slate-400" />
135
+ <span class="text-sm font-semibold text-slate-900 dark:text-slate-100">{displayLabel}</span>
136
+ <span class="text-2xs px-1.5 py-0.5 rounded-full bg-slate-100 dark:bg-slate-700 text-slate-500 dark:text-slate-400 font-medium">
137
+ {typeBadge}
138
+ </span>
99
139
  </div>
100
- <button
101
- onclick={handleStopTunnel}
102
- class="flex items-center gap-1.5 px-2 py-1 text-xs font-medium text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors"
103
- >
104
- <Icon name="lucide:circle-x" class="w-3.5 h-3.5" />
105
- Stop
106
- </button>
107
- </div>
108
-
109
- <!-- Public URL -->
110
- <div class="space-y-3">
111
140
  <div class="flex items-center gap-2">
112
- <Icon name="lucide:link" class="w-4 h-4 text-violet-600 dark:text-violet-400 flex-shrink-0" />
113
- <a
114
- href={publicUrl}
115
- target="_blank"
116
- rel="noopener noreferrer"
117
- class="text-sm text-violet-600 dark:text-violet-400 hover:underline truncate flex-1 font-medium"
118
- >
119
- {publicUrl}
120
- </a>
121
- </div>
122
-
123
- <!-- Action Buttons -->
124
- <div class="flex gap-2">
125
- <button
126
- onclick={copyUrl}
127
- class={`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors rounded ${
128
- copied
129
- ? 'text-green-700 dark:text-green-400 bg-green-100 dark:bg-green-900/20'
130
- : 'text-slate-700 dark:text-slate-300 bg-slate-100 dark:bg-slate-700/50 hover:bg-slate-200 dark:hover:bg-slate-700'
131
- }`}
132
- >
133
- {#if copied}
134
- <Icon name="lucide:check" class="w-3.5 h-3.5" />
135
- Copied!
136
- {:else}
137
- <Icon name="lucide:copy" class="w-3.5 h-3.5" />
138
- Copy
139
- {/if}
140
- </button>
141
- <button
142
- onclick={() => (showQR = !showQR)}
143
- class="flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-slate-700 dark:text-slate-300 bg-slate-100 dark:bg-slate-700/50 hover:bg-slate-200 dark:hover:bg-slate-700 rounded transition-colors"
144
- >
145
- <Icon name="lucide:qr-code" class="w-3.5 h-3.5" />
146
- {showQR ? 'Hide' : 'Show'} QR
147
- </button>
141
+ {#if isQuick && autoStopMinutes > 0}
142
+ <span class="text-xs text-slate-500 dark:text-slate-400">{getCountdown(startedAt, autoStopMinutes, now)}</span>
143
+ {/if}
144
+ {#if isQuick}
145
+ <button
146
+ onclick={handleStopTunnel}
147
+ class="flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors cursor-pointer"
148
+ >
149
+ <Icon name="lucide:circle-x" class="w-3.5 h-3.5" />
150
+ Stop
151
+ </button>
152
+ {:else}
153
+ <span class="text-2xs text-slate-400 dark:text-slate-500 italic">Managed in Settings</span>
154
+ {/if}
148
155
  </div>
156
+ </div>
149
157
 
150
- <!-- QR Code -->
151
- {#if showQR}
152
- <div class="pt-2 border-t border-slate-200 dark:border-slate-700">
153
- <TunnelQRCode value={publicUrl} />
158
+ <!-- URL entries - unified layout for all types -->
159
+ <div class="px-4 py-3">
160
+ {#if urlEntries().length > 0}
161
+ <div class="space-y-2.5">
162
+ {#each urlEntries() as entry}
163
+ <div>
164
+ <!-- URL row -->
165
+ <div class="flex items-start justify-between gap-2">
166
+ <a
167
+ href={entry.url}
168
+ target="_blank"
169
+ rel="noopener noreferrer"
170
+ class="flex items-start gap-2 text-sm font-medium text-violet-600 dark:text-violet-400 hover:underline break-all"
171
+ >
172
+ <Icon name="lucide:globe" class="w-4 h-4 shrink-0 mt-0.5" />
173
+ {entry.hostname}
174
+ </a>
175
+ <div class="flex items-center gap-1 shrink-0">
176
+ <button
177
+ onclick={() => copyUrl(entry.url)}
178
+ class="flex p-1.5 rounded transition-colors cursor-pointer {copiedUrl === entry.url
179
+ ? 'text-green-600 dark:text-green-400 bg-green-100 dark:bg-green-900/20'
180
+ : 'text-slate-400 hover:text-slate-600 dark:hover:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-700'}"
181
+ title="Copy URL"
182
+ >
183
+ <Icon name={copiedUrl === entry.url ? 'lucide:check' : 'lucide:copy'} class="w-3.5 h-3.5" />
184
+ </button>
185
+ <button
186
+ onclick={() => { qrUrl = qrUrl === entry.url ? '' : entry.url; }}
187
+ class="flex p-1.5 rounded transition-colors cursor-pointer {qrUrl === entry.url
188
+ ? 'text-violet-600 dark:text-violet-400 bg-violet-100 dark:bg-violet-900/20'
189
+ : 'text-slate-400 hover:text-slate-600 dark:hover:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-700'}"
190
+ title="Show QR Code"
191
+ >
192
+ <Icon name="lucide:qr-code" class="w-3.5 h-3.5" />
193
+ </button>
194
+ </div>
195
+ </div>
196
+ <!-- Service target -->
197
+ <div class="flex items-center gap-2 pl-6 mt-0.5 text-xs text-slate-500 dark:text-slate-400">
198
+ <Icon name="lucide:arrow-right" class="w-3 h-3 shrink-0" />
199
+ <span class="font-mono">{entry.service}</span>
200
+ </div>
201
+ <!-- QR Code inline per domain -->
202
+ {#if qrUrl === entry.url}
203
+ <div class="mt-2 ml-6 p-3 rounded-lg border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-800/50">
204
+ <TunnelQRCode value={entry.url} />
205
+ </div>
206
+ {/if}
207
+ </div>
208
+ {/each}
209
+ </div>
210
+ {:else if isManagedTunnel}
211
+ <!-- Empty state for managed tunnels without domains -->
212
+ <div class="flex items-center gap-2 py-1 text-slate-400 dark:text-slate-500">
213
+ <Icon name="lucide:globe" class="w-4 h-4 shrink-0" />
214
+ <span class="text-sm italic">No domains connected to this tunnel service yet</span>
154
215
  </div>
155
216
  {/if}
156
217
  </div>
@@ -10,8 +10,8 @@
10
10
 
11
11
  const { collapsed = false, mobile = false, onClick }: Props = $props();
12
12
 
13
- const activeTunnels = $derived(tunnelStore.tunnels);
14
- const hasActiveTunnels = $derived(activeTunnels.length > 0);
13
+ const activeDomainCount = $derived(tunnelStore.activeDomainCount);
14
+ const hasActiveTunnels = $derived(activeDomainCount > 0);
15
15
  </script>
16
16
 
17
17
  {#if collapsed}
@@ -31,7 +31,7 @@
31
31
  <span
32
32
  class="absolute top-0.5 right-0.5 min-w-4 h-4 px-0.5 rounded-full bg-green-500 text-white text-3xs font-bold flex items-center justify-center border-2 border-slate-50 dark:border-slate-900/95"
33
33
  >
34
- {activeTunnels.length}
34
+ {activeDomainCount}
35
35
  </span>
36
36
  {/if}
37
37
  </button>
@@ -53,7 +53,7 @@
53
53
  <span class="flex-1 text-left">Public Tunnel</span>
54
54
  {#if hasActiveTunnels}
55
55
  <span class="text-xs text-green-600 dark:text-green-400 font-semibold">
56
- {activeTunnels.length}
56
+ {activeDomainCount}
57
57
  </span>
58
58
  {/if}
59
59
  </button>
@@ -12,56 +12,56 @@
12
12
  let warningMessage = $state<string | null>(null);
13
13
  let warningDismissed = $state(false);
14
14
 
15
- // Info box visibility - load from localStorage
16
15
  let showInfoBox = $state(
17
16
  typeof window !== 'undefined'
18
17
  ? localStorage.getItem('clopen-tunnel-info-dismissed') !== 'true'
19
18
  : true
20
19
  );
21
20
 
22
- async function handleStartTunnel() {
23
- if (!port) return;
21
+ const key = $derived(String(port ?? 0));
22
+ const loadingState = $derived(tunnelStore.getLoadingState(key));
23
+ const isLoading = $derived(loadingState.isLoading);
24
+ const progress = $derived(loadingState.progress);
25
+ const error = $derived(loadingState.error);
24
26
 
25
- // Check if tunnel already exists for this port
26
- if (tunnelStore.getTunnel(port)) {
27
- warningMessage = `Tunnel already active on port ${port}`;
28
- warningDismissed = false;
29
- showWarning = false;
30
- return;
31
- }
27
+ const isStartDisabled = $derived(isLoading || !port);
32
28
 
33
- // Save "don't show again" preference
29
+ async function handleStartTunnel() {
34
30
  if (dontShowWarningAgain) {
35
31
  localStorage.setItem('clopen-tunnel-warning-dismissed', 'true');
36
32
  }
37
33
 
38
- // Close modal immediately
39
34
  showWarning = false;
40
35
 
41
36
  try {
42
- await tunnelStore.startTunnel(port, autoStopMinutes);
43
- } catch (error) {
44
- console.error('Failed to start tunnel:', error);
37
+ if (!port) return;
38
+
39
+ if (tunnelStore.getTunnel(port)) {
40
+ warningMessage = `Tunnel already active on port ${port}`;
41
+ warningDismissed = false;
42
+ return;
43
+ }
44
+
45
+ await tunnelStore.startQuickTunnel(port, autoStopMinutes);
46
+ } catch {
47
+ // Error handled by store
45
48
  }
46
49
  }
47
50
 
48
- // Get loading and progress state for current port
49
- const isLoading = $derived(tunnelStore.isLoading(port ?? 0));
50
- const progress = $derived(tunnelStore.getProgress(port ?? 0));
51
- const error = $derived(tunnelStore.getError(port ?? 0));
52
-
53
51
  function openWarningModal() {
54
- // Clear any previous warning messages
55
52
  warningMessage = null;
56
-
57
- // Reset error and warning dismissed state when user tries to start again
58
53
  errorDismissed = false;
59
54
  warningDismissed = false;
60
55
 
61
- // Check if user has dismissed warning permanently
56
+ if (!port) return;
57
+ if (tunnelStore.getTunnel(port)) {
58
+ warningMessage = `Tunnel already active on port ${port}`;
59
+ warningDismissed = false;
60
+ return;
61
+ }
62
+
62
63
  const securityWarningDismissed = localStorage.getItem('clopen-tunnel-warning-dismissed') === 'true';
63
64
  if (securityWarningDismissed) {
64
- // Skip warning and start tunnel directly
65
65
  handleStartTunnel();
66
66
  } else {
67
67
  showWarning = true;
@@ -85,16 +85,14 @@
85
85
  <div class="space-y-6">
86
86
  <!-- Info Card -->
87
87
  {#if showInfoBox}
88
- <div
89
- class="p-4 bg-violet-500/5 dark:bg-violet-500/10 border border-violet-500/20 rounded-xl"
90
- >
88
+ <div class="p-4 bg-violet-500/5 dark:bg-violet-500/10 border border-violet-500/20 rounded-xl">
91
89
  <div class="flex gap-3">
92
90
  <Icon name="lucide:info" class="w-5 h-5 text-violet-600 dark:text-violet-400 flex-shrink-0 mt-0.5" />
93
91
  <div class="flex-1 text-sm text-slate-700 dark:text-slate-300">
94
92
  <p class="font-semibold mb-1">What is Public Tunnel?</p>
95
93
  <p class="text-slate-600 dark:text-slate-400">
96
94
  Create a secure HTTPS tunnel to share your local development server with anyone on the
97
- internet.
95
+ internet. Uses a random <span class="font-mono text-xs">*.trycloudflare.com</span> URL.
98
96
  </p>
99
97
  </div>
100
98
  <button
@@ -124,9 +122,6 @@
124
122
  placeholder="3000"
125
123
  class="block w-full px-3 py-3 border border-slate-300 dark:border-slate-600 rounded-lg transition-colors duration-200 focus:outline-none text-sm font-medium focus:border-violet-500 focus:ring-2 focus:ring-violet-200 dark:focus:ring-violet-900/20 bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-100 placeholder-slate-400 dark:placeholder-slate-500"
126
124
  />
127
- <!-- <p class="text-xs text-slate-500 dark:text-slate-400">
128
- Port number where your app is running (e.g., 3000 for Vite, 8080 for API)
129
- </p> -->
130
125
  </div>
131
126
 
132
127
  <!-- Auto-Stop Timer -->
@@ -144,22 +139,18 @@
144
139
  <option value={60}>1 hour</option>
145
140
  <option value={120}>2 hours</option>
146
141
  <option value={180}>3 hours</option>
142
+ <option value={0}>No limit</option>
147
143
  </select>
148
- <!-- <p class="text-xs text-slate-500 dark:text-slate-400">
149
- Tunnel will automatically stop after this duration
150
- </p> -->
151
144
  </div>
152
145
 
153
146
  <!-- Start Button -->
154
147
  <button
155
148
  onclick={openWarningModal}
156
- disabled={isLoading || !port}
149
+ disabled={isStartDisabled}
157
150
  class="inline-flex items-center justify-center font-semibold transition-colors duration-200 focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed w-full px-3 md:px-4 py-2.5 text-sm rounded-lg bg-violet-600 hover:bg-violet-700 text-white gap-2"
158
151
  >
159
152
  {#if isLoading}
160
- <div
161
- class="animate-spin rounded-full h-4 w-4 border-2 border-current border-t-transparent"
162
- ></div>
153
+ <div class="animate-spin rounded-full h-4 w-4 border-2 border-current border-t-transparent"></div>
163
154
  <span>
164
155
  {#if progress.stage === 'checking-binary'}
165
156
  Checking binary...
@@ -183,52 +174,35 @@
183
174
  {/if}
184
175
  </button>
185
176
 
186
- <!-- Warning Message (e.g., tunnel already active) -->
177
+ <!-- Warning Message -->
187
178
  {#if warningMessage && !warningDismissed}
188
- <div
189
- class="bg-yellow-500/10 border border-yellow-500/20 rounded-lg p-4 text-sm"
190
- >
179
+ <div class="bg-yellow-500/10 border border-yellow-500/20 rounded-lg p-4 text-sm">
191
180
  <div class="flex items-start gap-2 text-yellow-600 dark:text-yellow-400">
192
181
  <Icon name="lucide:triangle-alert" class="w-5 h-5 flex-shrink-0 mt-0.5" />
193
182
  <div class="flex-1 space-y-1">
194
183
  <div class="font-semibold">Warning</div>
195
- <div class="text-yellow-500 dark:text-yellow-300">
196
- {warningMessage}
197
- </div>
184
+ <div class="text-yellow-500 dark:text-yellow-300">{warningMessage}</div>
198
185
  </div>
199
- <button
200
- onclick={dismissWarning}
201
- class="text-yellow-400 hover:text-yellow-600 dark:hover:text-yellow-300 transition-colors flex-shrink-0"
202
- title="Dismiss"
203
- >
186
+ <button onclick={dismissWarning} class="text-yellow-400 hover:text-yellow-600 dark:hover:text-yellow-300 transition-colors flex-shrink-0" title="Dismiss">
204
187
  <Icon name="lucide:x" class="w-5 h-5" />
205
188
  </button>
206
189
  </div>
207
190
  </div>
208
191
  {/if}
209
192
 
193
+ <!-- Error -->
210
194
  {#if (error || progress.stage === 'failed') && !errorDismissed}
211
- <div
212
- class="bg-red-500/10 border border-red-500/20 rounded-lg p-4 text-sm space-y-3"
213
- >
195
+ <div class="bg-red-500/10 border border-red-500/20 rounded-lg p-4 text-sm space-y-3">
214
196
  <div class="flex items-start gap-2 text-red-600 dark:text-red-400">
215
197
  <Icon name="lucide:circle-alert" class="w-5 h-5 flex-shrink-0 mt-0.5" />
216
198
  <div class="flex-1 space-y-1">
217
199
  <div class="font-semibold">Tunnel Failed</div>
218
- <div class="text-red-500 dark:text-red-300">
219
- {error}
220
- </div>
200
+ <div class="text-red-500 dark:text-red-300">{error}</div>
221
201
  </div>
222
- <button
223
- onclick={dismissError}
224
- class="text-red-400 hover:text-red-600 dark:hover:text-red-300 transition-colors flex-shrink-0"
225
- title="Dismiss"
226
- >
202
+ <button onclick={dismissError} class="text-red-400 hover:text-red-600 dark:hover:text-red-300 transition-colors flex-shrink-0" title="Dismiss">
227
203
  <Icon name="lucide:x" class="w-5 h-5" />
228
204
  </button>
229
205
  </div>
230
-
231
- <!-- Common solutions -->
232
206
  <div class="text-xs text-slate-700 dark:text-slate-300 space-y-1 pt-2 border-t border-red-500/20">
233
207
  <div class="font-semibold">Common solutions:</div>
234
208
  <ul class="list-disc list-inside space-y-0.5 text-slate-600 dark:text-slate-400">
@@ -259,7 +233,6 @@
259
233
  </div>
260
234
  </div>
261
235
 
262
- <!-- Don't show again checkbox -->
263
236
  <div class="pt-2">
264
237
  <Checkbox
265
238
  id="dontShowWarning"
@@ -1,8 +1,12 @@
1
1
  <script lang="ts">
2
+ import { onMount, onDestroy } from 'svelte';
2
3
  import Modal from '$frontend/components/common/overlay/Modal.svelte';
4
+ import Icon from '$frontend/components/common/display/Icon.svelte';
3
5
  import TunnelInactive from './TunnelInactive.svelte';
4
6
  import TunnelActive from './TunnelActive.svelte';
5
7
  import { tunnelStore } from '$frontend/stores/features/tunnel.svelte';
8
+ import { openSettingsModal } from '$frontend/stores/ui/settings-modal.svelte';
9
+ import ws from '$frontend/utils/ws';
6
10
 
7
11
  interface Props {
8
12
  isOpen: boolean;
@@ -13,12 +17,46 @@
13
17
 
14
18
  const activeTunnels = $derived(tunnelStore.tunnels);
15
19
 
20
+ // Deduplicate tunnels by unique key to prevent each_key_duplicate
21
+ const uniqueTunnels = $derived(() => {
22
+ const seen = new Set<string>();
23
+ return activeTunnels.filter((tunnel) => {
24
+ const key = tunnel.configId
25
+ ? `${tunnel.type}-${tunnel.configId}`
26
+ : `${tunnel.type}-${tunnel.port}`;
27
+ if (seen.has(key)) return false;
28
+ seen.add(key);
29
+ return true;
30
+ });
31
+ });
32
+
33
+ const cleanups: Array<() => void> = [];
34
+
35
+ onMount(() => {
36
+ // Auto-sync tunnel list when status changes (from Settings start/stop)
37
+ cleanups.push(
38
+ ws.on('tunnel:status-changed', () => {
39
+ tunnelStore.checkStatus();
40
+ })
41
+ );
42
+ });
43
+
44
+ onDestroy(() => {
45
+ for (const cleanup of cleanups) cleanup();
46
+ cleanups.length = 0;
47
+ });
48
+
16
49
  // Load tunnels when modal opens
17
50
  $effect(() => {
18
51
  if (isOpen) {
19
52
  tunnelStore.checkStatus();
20
53
  }
21
54
  });
55
+
56
+ function goToSettings() {
57
+ onClose();
58
+ openSettingsModal('tunnel');
59
+ }
22
60
  </script>
23
61
 
24
62
  <Modal {isOpen} {onClose} title="Public Tunnel" size="md">
@@ -27,22 +65,37 @@
27
65
  <TunnelInactive />
28
66
 
29
67
  <!-- Active tunnels list -->
30
- {#if activeTunnels.length > 0}
68
+ {#if uniqueTunnels().length > 0}
31
69
  <div>
32
70
  <div class="text-sm font-semibold text-slate-700 dark:text-slate-300 mb-3">
33
71
  Active Tunnels
34
72
  </div>
35
73
  <div class="space-y-3">
36
- {#each activeTunnels as tunnel (tunnel.port)}
74
+ {#each uniqueTunnels() as tunnel (tunnel.configId ? `${tunnel.type}-${tunnel.configId}` : `${tunnel.type}-${tunnel.port}`)}
37
75
  <TunnelActive
38
76
  port={tunnel.port}
39
77
  publicUrl={tunnel.publicUrl}
40
78
  startedAt={tunnel.startedAt}
41
79
  autoStopMinutes={tunnel.autoStopMinutes}
80
+ type={tunnel.type}
81
+ label={tunnel.label}
82
+ configId={tunnel.configId}
83
+ ingress={tunnel.ingress}
42
84
  />
43
85
  {/each}
44
86
  </div>
45
87
  </div>
46
88
  {/if}
89
+
90
+ <!-- Settings hint -->
91
+ <div class="flex items-center gap-2 px-3 py-2 rounded-lg bg-slate-50 dark:bg-slate-800/50 border border-slate-200 dark:border-slate-700/30">
92
+ <Icon name="lucide:info" class="w-3.5 h-3.5 text-slate-400 shrink-0" />
93
+ <p class="text-xs text-slate-400 dark:text-slate-500">
94
+ For persistent custom domains, configure tunnels in
95
+ <button type="button" class="text-violet-600 dark:text-violet-400 hover:underline cursor-pointer font-medium" onclick={goToSettings}>
96
+ Settings &rarr; Tunnel
97
+ </button>
98
+ </p>
99
+ </div>
47
100
  </div>
48
101
  </Modal>
@@ -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}>
@@ -29,7 +29,8 @@
29
29
  import { initializeNotifications, notificationStore } from '$frontend/stores/ui/notification.svelte';
30
30
  import { applyServerSettings, loadSystemSettings } from '$frontend/stores/features/settings.svelte';
31
31
  import { applyTodoPanelState } from '$frontend/stores/ui/todo-panel.svelte';
32
- import { initPresence } from '$frontend/stores/core/presence.svelte';
32
+ import { presenceState, initPresence } from '$frontend/stores/core/presence.svelte';
33
+ import { updateFaviconBadge } from '$frontend/services/favicon.service';
33
34
  import ws from '$frontend/utils/ws';
34
35
  import { debug } from '$shared/utils/logger';
35
36
 
@@ -130,6 +131,35 @@
130
131
  window.removeEventListener('resize', handleResize);
131
132
  }
132
133
  });
134
+
135
+ // Reactive favicon badge: count non-idle indicators across all projects
136
+ $effect(() => {
137
+ const statuses = presenceState.statuses;
138
+ const unreadSessions = appState.unreadSessions;
139
+ const currentSessionId = sessionState.currentSession?.id;
140
+
141
+ // Count streaming sessions (green + amber)
142
+ const streamingSessionIds = new Set<string>();
143
+ for (const status of statuses.values()) {
144
+ if (!status.streams) continue;
145
+ for (const stream of status.streams) {
146
+ if (stream.status === 'active') {
147
+ streamingSessionIds.add(stream.chatSessionId);
148
+ }
149
+ }
150
+ }
151
+
152
+ // Count unread sessions (excluding current session and already-streaming ones)
153
+ let unreadCount = 0;
154
+ for (const [sessionId] of unreadSessions) {
155
+ if (sessionId !== currentSessionId && !streamingSessionIds.has(sessionId)) {
156
+ unreadCount++;
157
+ }
158
+ }
159
+
160
+ const totalCount = streamingSessionIds.size + unreadCount;
161
+ updateFaviconBadge(totalCount);
162
+ });
133
163
  </script>
134
164
 
135
165
  <!-- Loading Screen -->