@myrialabs/clopen 0.1.2 → 0.1.4

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 (63) hide show
  1. package/CONTRIBUTING.md +40 -355
  2. package/README.md +46 -113
  3. package/backend/lib/engine/adapters/opencode/message-converter.ts +53 -2
  4. package/backend/lib/engine/adapters/opencode/stream.ts +89 -5
  5. package/backend/lib/mcp/config.ts +7 -3
  6. package/backend/lib/mcp/servers/helper.ts +25 -14
  7. package/backend/lib/mcp/servers/index.ts +7 -2
  8. package/backend/lib/project/status-manager.ts +221 -181
  9. package/frontend/lib/components/chat/ChatInterface.svelte +7 -0
  10. package/frontend/lib/components/chat/input/components/EngineModelPicker.svelte +16 -9
  11. package/frontend/lib/components/chat/message/ChatMessages.svelte +16 -4
  12. package/frontend/lib/components/chat/tools/AgentTool.svelte +12 -11
  13. package/frontend/lib/components/chat/tools/BashOutputTool.svelte +3 -3
  14. package/frontend/lib/components/chat/tools/BashTool.svelte +4 -4
  15. package/frontend/lib/components/chat/tools/CustomMcpTool.svelte +3 -1
  16. package/frontend/lib/components/chat/tools/EditTool.svelte +6 -6
  17. package/frontend/lib/components/chat/tools/ExitPlanModeTool.svelte +1 -1
  18. package/frontend/lib/components/chat/tools/GlobTool.svelte +12 -12
  19. package/frontend/lib/components/chat/tools/GrepTool.svelte +5 -5
  20. package/frontend/lib/components/chat/tools/ListMcpResourcesTool.svelte +1 -1
  21. package/frontend/lib/components/chat/tools/NotebookEditTool.svelte +6 -6
  22. package/frontend/lib/components/chat/tools/ReadMcpResourceTool.svelte +2 -2
  23. package/frontend/lib/components/chat/tools/ReadTool.svelte +4 -4
  24. package/frontend/lib/components/chat/tools/TaskStopTool.svelte +1 -1
  25. package/frontend/lib/components/chat/tools/TaskTool.svelte +1 -1
  26. package/frontend/lib/components/chat/tools/TodoWriteTool.svelte +4 -4
  27. package/frontend/lib/components/chat/tools/WebSearchTool.svelte +1 -1
  28. package/frontend/lib/components/chat/tools/WriteTool.svelte +3 -3
  29. package/frontend/lib/components/chat/tools/components/CodeBlock.svelte +3 -3
  30. package/frontend/lib/components/chat/tools/components/DiffBlock.svelte +2 -2
  31. package/frontend/lib/components/chat/tools/components/FileHeader.svelte +1 -1
  32. package/frontend/lib/components/chat/tools/components/InfoLine.svelte +2 -2
  33. package/frontend/lib/components/chat/tools/components/StatsBadges.svelte +1 -1
  34. package/frontend/lib/components/chat/tools/components/TerminalCommand.svelte +5 -5
  35. package/frontend/lib/components/common/Button.svelte +1 -1
  36. package/frontend/lib/components/common/Card.svelte +3 -3
  37. package/frontend/lib/components/common/Input.svelte +3 -3
  38. package/frontend/lib/components/common/LoadingSpinner.svelte +1 -1
  39. package/frontend/lib/components/common/Select.svelte +6 -6
  40. package/frontend/lib/components/common/Textarea.svelte +3 -3
  41. package/frontend/lib/components/files/FileViewer.svelte +1 -1
  42. package/frontend/lib/components/git/ChangesSection.svelte +2 -4
  43. package/frontend/lib/components/preview/browser/BrowserPreview.svelte +9 -29
  44. package/frontend/lib/components/preview/browser/components/Container.svelte +17 -0
  45. package/frontend/lib/components/preview/browser/components/VirtualCursor.svelte +2 -2
  46. package/frontend/lib/components/settings/appearance/AppearanceSettings.svelte +0 -6
  47. package/frontend/lib/components/settings/appearance/LayoutPresetSettings.svelte +15 -15
  48. package/frontend/lib/components/settings/appearance/LayoutPreview.svelte +2 -2
  49. package/frontend/lib/components/settings/engines/AIEnginesSettings.svelte +1 -1
  50. package/frontend/lib/components/workspace/DesktopNavigator.svelte +380 -383
  51. package/frontend/lib/components/workspace/MobileNavigator.svelte +391 -395
  52. package/frontend/lib/components/workspace/PanelHeader.svelte +623 -505
  53. package/frontend/lib/components/workspace/ViewMenu.svelte +9 -25
  54. package/frontend/lib/components/workspace/layout/split-pane/Layout.svelte +29 -4
  55. package/frontend/lib/components/workspace/panels/ChatPanel.svelte +3 -2
  56. package/frontend/lib/services/notification/global-stream-monitor.ts +77 -86
  57. package/frontend/lib/services/project/status.service.ts +160 -159
  58. package/frontend/lib/stores/ui/workspace.svelte.ts +326 -283
  59. package/package.json +1 -1
  60. package/scripts/pre-publish-check.sh +0 -142
  61. package/scripts/setup-hooks.sh +0 -134
  62. package/scripts/validate-branch-name.sh +0 -47
  63. package/scripts/validate-commit-msg.sh +0 -42
@@ -1,505 +1,623 @@
1
- <script lang="ts">
2
- import { browser } from '$frontend/lib/app-environment';
3
- import { onMount, onDestroy } from 'svelte';
4
- import Icon from '$frontend/lib/components/common/Icon.svelte';
5
- import AvatarBubble from '$frontend/lib/components/common/AvatarBubble.svelte';
6
- import { sessionState } from '$frontend/lib/stores/core/sessions.svelte';
7
- import { projectState } from '$frontend/lib/stores/core/projects.svelte';
8
- import { presenceState } from '$frontend/lib/stores/core/presence.svelte';
9
- import { userStore } from '$frontend/lib/stores/features/user.svelte';
10
- import { workspaceState, type PanelId } from '$frontend/lib/stores/ui/workspace.svelte';
11
- import type { IconName } from '$shared/types/ui/icons';
12
- import type { DeviceSize } from '$frontend/lib/constants/preview';
13
- import { DEVICE_VIEWPORTS } from '$frontend/lib/constants/preview';
14
-
15
- interface Props {
16
- panelId: PanelId;
17
- chatPanelRef?: any;
18
- filesPanelRef?: any;
19
- terminalPanelRef?: any;
20
- previewPanelRef?: any;
21
- gitPanelRef?: any;
22
- onHistoryOpen?: () => void;
23
- }
24
-
25
- const {
26
- panelId,
27
- chatPanelRef,
28
- filesPanelRef,
29
- terminalPanelRef,
30
- previewPanelRef,
31
- gitPanelRef,
32
- onHistoryOpen
33
- }: Props = $props();
34
-
35
- const panel = $derived(workspaceState.panels[panelId]);
36
- const iconName = $derived((panel?.icon ?? 'lucide:box') as IconName);
37
-
38
- // Mobile detection
39
- let isMobile = $state(false);
40
-
41
- // Chat session users (other users in the same chat session, excluding self)
42
- const chatSessionUsers = $derived.by(() => {
43
- if (panelId !== 'chat') return [];
44
- const projectId = projectState.currentProject?.id;
45
- const chatSessionId = sessionState.currentSession?.id;
46
- const currentUserId = userStore.currentUser?.id;
47
- if (!projectId || !chatSessionId) return [];
48
- const status = presenceState.statuses.get(projectId);
49
- if (!status?.chatSessionUsers) return [];
50
- const users = status.chatSessionUsers[chatSessionId] || [];
51
- return currentUserId ? users.filter(u => u.userId !== currentUserId) : users;
52
- });
53
-
54
- // Chat session users popover
55
- let showChatUsersPopover = $state(false);
56
- let chatUsersContainer = $state<HTMLDivElement | null>(null);
57
-
58
- function toggleChatUsersPopover(e: MouseEvent) {
59
- e.stopPropagation();
60
- showChatUsersPopover = !showChatUsersPopover;
61
- }
62
-
63
- $effect(() => {
64
- if (showChatUsersPopover) {
65
- const handleClickOutside = (e: MouseEvent) => {
66
- if (chatUsersContainer && !chatUsersContainer.contains(e.target as Node)) {
67
- showChatUsersPopover = false;
68
- }
69
- };
70
- document.addEventListener('click', handleClickOutside, true);
71
- return () => document.removeEventListener('click', handleClickOutside, true);
72
- }
73
- });
74
-
75
- // Preview panel device dropdown state
76
- let showDeviceDropdown = $state(false);
77
-
78
- // Git remote dropdown state
79
- let showRemoteDropdown = $state(false);
80
-
81
- function toggleDeviceDropdown() {
82
- showDeviceDropdown = !showDeviceDropdown;
83
- }
84
-
85
- function closeDeviceDropdown() {
86
- showDeviceDropdown = false;
87
- }
88
-
89
- function selectDevice(size: DeviceSize) {
90
- previewPanelRef?.panelActions?.setDeviceSize(size);
91
- closeDeviceDropdown();
92
- }
93
-
94
- function handleResize() {
95
- if (browser) {
96
- isMobile = window.innerWidth < 1024;
97
- }
98
- }
99
-
100
- onMount(() => {
101
- handleResize();
102
- if (browser) {
103
- window.addEventListener('resize', handleResize);
104
- }
105
- });
106
-
107
- onDestroy(() => {
108
- if (browser) {
109
- window.removeEventListener('resize', handleResize);
110
- }
111
- });
112
- </script>
113
-
114
- <header
115
- class="flex items-center justify-between shrink-0 {isMobile
116
- ? 'h-11 pb-2 px-4 bg-white/90 dark:bg-slate-900/98 border-b border-slate-200 dark:border-slate-800'
117
- : 'py-2.5 px-3.5 bg-slate-100 dark:bg-slate-800/80 border-b border-slate-200 dark:border-slate-800'}"
118
- >
119
- <div class="flex items-center gap-2.5 text-sm font-medium text-slate-900 dark:text-slate-100">
120
- <Icon name={iconName} class="w-4 h-4 text-violet-600" />
121
- <span>{panel?.title ?? 'Panel'}</span>
122
- </div>
123
-
124
- <div class="flex items-center">
125
- <!-- Panel-specific actions -->
126
- <div class="flex items-center gap-1.5">
127
- {#if panelId === 'chat'}
128
- {#if chatSessionUsers.length > 0}
129
- <div class="relative" bind:this={chatUsersContainer}>
130
- <div class="flex items-center -space-x-1.5 mr-1 cursor-pointer" title="Users in this session" onclick={toggleChatUsersPopover}>
131
- {#each chatSessionUsers.slice(0, 3) as user}
132
- <AvatarBubble {user} size="sm" />
133
- {/each}
134
- {#if chatSessionUsers.length > 3}
135
- <span class="w-5 h-5 rounded-full bg-gradient-to-br from-slate-500 to-slate-600 dark:from-slate-600 dark:to-slate-700 text-white text-4xs font-bold flex items-center justify-center border-2 border-white dark:border-slate-800 z-10">
136
- +{chatSessionUsers.length - 3}
137
- </span>
138
- {/if}
139
- </div>
140
- {#if showChatUsersPopover}
141
- <div class="absolute top-full right-0 mt-2 py-2 px-1 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-lg shadow-lg z-50 min-w-[160px]">
142
- <div class="px-2 pb-1.5 text-left text-xs font-semibold text-slate-500 dark:text-slate-400">
143
- In this session ({chatSessionUsers.length})
144
- </div>
145
- {#each chatSessionUsers as user}
146
- <div class="flex items-center gap-2 px-2 py-1.5 rounded-md">
147
- <AvatarBubble {user} size="sm" showName={true} />
148
- </div>
149
- {/each}
150
- </div>
151
- {/if}
152
- </div>
153
- {/if}
154
- <button
155
- type="button"
156
- class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100"
157
- onclick={onHistoryOpen}
158
- title="Switch Session"
159
- >
160
- <Icon name="lucide:history" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
161
- </button>
162
- {#if sessionState.messages.length > 0}
163
- <button
164
- type="button"
165
- class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100"
166
- onclick={() => chatPanelRef?.panelActions?.checkpoints()}
167
- title="Restore Checkpoint"
168
- >
169
- <Icon name="lucide:undo-2" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
170
- </button>
171
- {/if}
172
- <button
173
- type="button"
174
- class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100"
175
- onclick={() => chatPanelRef?.panelActions?.newChat()}
176
- title="New Chat"
177
- >
178
- <Icon name="lucide:plus" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
179
- </button>
180
- {:else if panelId === 'files'}
181
- <!-- Hide view mode toggles when in two-column mode -->
182
- {#if !filesPanelRef?.panelActions?.isTwoColumnMode()}
183
- <div class="flex gap-1 bg-slate-100/80 dark:bg-slate-800/50 rounded-md">
184
- <button
185
- type="button"
186
- class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100 disabled:opacity-40 disabled:cursor-not-allowed
187
- {filesPanelRef?.panelActions?.getViewMode() === 'tree'
188
- ? 'bg-violet-500/15 dark:bg-violet-500/25 text-violet-600'
189
- : ''}"
190
- onclick={() => filesPanelRef?.panelActions?.setViewMode('tree')}
191
- title="Tree View"
192
- >
193
- <Icon name="lucide:folder-tree" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
194
- </button>
195
- <button
196
- type="button"
197
- class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100 disabled:opacity-40 disabled:cursor-not-allowed
198
- {filesPanelRef?.panelActions?.getViewMode() === 'viewer'
199
- ? 'bg-violet-500/15 dark:bg-violet-500/25 text-violet-600'
200
- : ''}"
201
- onclick={() => filesPanelRef?.panelActions?.setViewMode('viewer')}
202
- disabled={!filesPanelRef?.panelActions?.canShowViewer()}
203
- title="File Viewer"
204
- >
205
- <Icon name="lucide:file-code" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
206
- </button>
207
- </div>
208
- {/if}
209
- {:else if panelId === 'terminal'}
210
- <button
211
- type="button"
212
- class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100"
213
- onclick={() => terminalPanelRef?.panelActions?.handleClear()}
214
- title="Clear Terminal"
215
- >
216
- <Icon name="lucide:trash-2" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
217
- </button>
218
- {#if !isMobile || terminalPanelRef?.panelActions?.isExecuting()}
219
- <button
220
- type="button"
221
- class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded-md {isMobile ? 'text-red-600 dark:text-red-400' : 'text-slate-500'} cursor-pointer transition-all duration-150 hover:bg-red-500/10 hover:text-red-600 dark:hover:text-red-400 disabled:opacity-50 disabled:cursor-not-allowed"
222
- onclick={() => terminalPanelRef?.panelActions?.handleCancel()}
223
- disabled={terminalPanelRef?.panelActions?.isCancelling()}
224
- title="{isMobile ? 'Cancel Command (Ctrl+C)' : 'Send Ctrl+C Signal'}"
225
- >
226
- {#if terminalPanelRef?.panelActions?.isCancelling()}
227
- <div
228
- class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} border-2 border-red-500/20 border-t-red-600 rounded-full animate-spin"
229
- ></div>
230
- {:else}
231
- <Icon name="lucide:square" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
232
- {/if}
233
- </button>
234
- {/if}
235
- {:else if panelId === 'preview'}
236
- <!-- Connection status indicator -->
237
- <!-- {@const sessionInfo = previewPanelRef?.panelActions?.getSessionInfo()}
238
- {@const isStreamReady = previewPanelRef?.panelActions?.getIsStreamReady()}
239
- {@const errorMessage = previewPanelRef?.panelActions?.getErrorMessage()}
240
- {@const url = previewPanelRef?.panelActions?.getUrl()}
241
-
242
- {#if url}
243
- <div class="flex items-center gap-1.5 {isMobile ? 'px-2 h-9' : 'px-2 h-6'} rounded-md">
244
- <div class="relative">
245
- {#if !sessionInfo}
246
- <span class="w-2 h-2 rounded-full block bg-amber-400"></span>
247
- {:else if errorMessage}
248
- <span class="w-2 h-2 rounded-full block bg-red-500"></span>
249
- {:else if isStreamReady}
250
- <span class="w-2 h-2 rounded-full block bg-emerald-500"></span>
251
- <span class="absolute inset-0 w-2 h-2 bg-emerald-500 rounded-full animate-ping opacity-75"></span>
252
- {:else}
253
- <span class="w-2 h-2 rounded-full block bg-blue-400 animate-pulse"></span>
254
- {/if}
255
- </div>
256
- <span class="text-xs font-medium {
257
- !sessionInfo ? 'text-amber-600 dark:text-amber-400' :
258
- errorMessage ? 'text-red-600 dark:text-red-400' :
259
- isStreamReady ? 'text-emerald-600 dark:text-emerald-400' :
260
- 'text-blue-600 dark:text-blue-400'
261
- }">
262
- {!sessionInfo ? 'Ready' : errorMessage ? 'Offline' : isStreamReady ? 'Online' : 'Connecting'}
263
- </span>
264
- </div>
265
- {/if} -->
266
-
267
- <!-- Device size dropdown -->
268
- <div class="relative {isMobile ? '' : 'mr-1.5'}">
269
- <button
270
- type="button"
271
- class="flex items-center justify-center gap-1.5 {isMobile ? 'px-2 h-9' : 'px-1 h-6'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100"
272
- onclick={toggleDeviceDropdown}
273
- title="Select device size"
274
- >
275
- {#if previewPanelRef?.panelActions?.getDeviceSize() === 'desktop'}
276
- <Icon name="lucide:monitor" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
277
- <span class="text-xs font-medium">Desktop</span>
278
- {:else if previewPanelRef?.panelActions?.getDeviceSize() === 'laptop'}
279
- <Icon name="lucide:laptop" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
280
- <span class="text-xs font-medium">Laptop</span>
281
- {:else if previewPanelRef?.panelActions?.getDeviceSize() === 'tablet'}
282
- <Icon name="lucide:tablet" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
283
- <span class="text-xs font-medium">Tablet</span>
284
- {:else}
285
- <Icon name="lucide:smartphone" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
286
- <span class="text-xs font-medium">Mobile</span>
287
- {/if}
288
- <Icon name="lucide:chevron-down" class={isMobile ? 'w-3.5 h-3.5' : 'w-3 h-3'} />
289
- </button>
290
-
291
- <!-- Dropdown menu -->
292
- {#if showDeviceDropdown}
293
- <div
294
- class="fixed inset-0 z-40"
295
- onclick={closeDeviceDropdown}
296
- ></div>
297
- <div class="absolute top-full right-0 mt-1 z-50 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-lg shadow-lg overflow-hidden {isMobile ? 'min-w-44' : 'min-w-40'}">
298
- <button
299
- type="button"
300
- class="flex items-center gap-2.5 w-full px-3 {isMobile ? 'py-2.5' : 'py-2'} text-left text-sm bg-transparent border-none cursor-pointer transition-all duration-150 hover:bg-violet-500/10 {previewPanelRef?.panelActions?.getDeviceSize() === 'desktop' ? 'bg-violet-500/5 text-violet-600' : 'text-slate-700 dark:text-slate-300'}"
301
- onclick={() => selectDevice('desktop')}
302
- >
303
- <Icon name="lucide:monitor" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
304
- <div class="flex-1">
305
- <div class="font-medium">Desktop</div>
306
- <div class="text-xs text-slate-500 dark:text-slate-400">
307
- {DEVICE_VIEWPORTS.desktop.width}×{DEVICE_VIEWPORTS.desktop.height}
308
- </div>
309
- </div>
310
- {#if previewPanelRef?.panelActions?.getDeviceSize() === 'desktop'}
311
- <Icon name="lucide:check" class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} text-violet-600" />
312
- {/if}
313
- </button>
314
- <button
315
- type="button"
316
- class="flex items-center gap-2.5 w-full px-3 {isMobile ? 'py-2.5' : 'py-2'} text-left text-sm bg-transparent border-none cursor-pointer transition-all duration-150 hover:bg-violet-500/10 {previewPanelRef?.panelActions?.getDeviceSize() === 'laptop' ? 'bg-violet-500/5 text-violet-600' : 'text-slate-700 dark:text-slate-300'}"
317
- onclick={() => selectDevice('laptop')}
318
- >
319
- <Icon name="lucide:laptop" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
320
- <div class="flex-1">
321
- <div class="font-medium">Laptop</div>
322
- <div class="text-xs text-slate-500 dark:text-slate-400">
323
- {DEVICE_VIEWPORTS.laptop.width}×{DEVICE_VIEWPORTS.laptop.height}
324
- </div>
325
- </div>
326
- {#if previewPanelRef?.panelActions?.getDeviceSize() === 'laptop'}
327
- <Icon name="lucide:check" class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} text-violet-600" />
328
- {/if}
329
- </button>
330
- <button
331
- type="button"
332
- class="flex items-center gap-2.5 w-full px-3 {isMobile ? 'py-2.5' : 'py-2'} text-left text-sm bg-transparent border-none cursor-pointer transition-all duration-150 hover:bg-violet-500/10 {previewPanelRef?.panelActions?.getDeviceSize() === 'tablet' ? 'bg-violet-500/5 text-violet-600' : 'text-slate-700 dark:text-slate-300'}"
333
- onclick={() => selectDevice('tablet')}
334
- >
335
- <Icon name="lucide:tablet" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
336
- <div class="flex-1">
337
- <div class="font-medium">Tablet</div>
338
- <div class="text-xs text-slate-500 dark:text-slate-400">
339
- {DEVICE_VIEWPORTS.tablet.width}×{DEVICE_VIEWPORTS.tablet.height}
340
- </div>
341
- </div>
342
- {#if previewPanelRef?.panelActions?.getDeviceSize() === 'tablet'}
343
- <Icon name="lucide:check" class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} text-violet-600" />
344
- {/if}
345
- </button>
346
- <button
347
- type="button"
348
- class="flex items-center gap-2.5 w-full px-3 {isMobile ? 'py-2.5' : 'py-2'} text-left text-sm bg-transparent border-none cursor-pointer transition-all duration-150 hover:bg-violet-500/10 {previewPanelRef?.panelActions?.getDeviceSize() === 'mobile' ? 'bg-violet-500/5 text-violet-600' : 'text-slate-700 dark:text-slate-300'}"
349
- onclick={() => selectDevice('mobile')}
350
- >
351
- <Icon name="lucide:smartphone" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
352
- <div class="flex-1">
353
- <div class="font-medium">Mobile</div>
354
- <div class="text-xs text-slate-500 dark:text-slate-400">
355
- {DEVICE_VIEWPORTS.mobile.width}×{DEVICE_VIEWPORTS.mobile.height}
356
- </div>
357
- </div>
358
- {#if previewPanelRef?.panelActions?.getDeviceSize() === 'mobile'}
359
- <Icon name="lucide:check" class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} text-violet-600" />
360
- {/if}
361
- </button>
362
- </div>
363
- {/if}
364
- </div>
365
-
366
- <!-- Rotation toggle -->
367
- <button
368
- type="button"
369
- class="flex items-center justify-center gap-1.5 {isMobile ? 'px-2 h-9' : 'px-1 h-6'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100"
370
- onclick={() => previewPanelRef?.panelActions?.toggleRotation()}
371
- title="Toggle orientation"
372
- >
373
- <Icon name="lucide:rotate-cw" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
374
- <span class="text-xs font-medium">
375
- {previewPanelRef?.panelActions?.getRotation() === 'portrait' ? 'Portrait' : 'Landscape'}
376
- </span>
377
- </button>
378
-
379
- <!-- Scale info badge -->
380
- <div class="flex items-center gap-1.5 {isMobile ? 'px-2.5 h-9 bg-transparent' : 'px-2 h-6 bg-slate-100/60 dark:bg-slate-800/40'} rounded-md text-xs font-medium text-slate-500">
381
- <Icon name="lucide:move-diagonal" class={isMobile ? 'w-4 h-4' : 'w-3.5 h-3.5'} />
382
- <span>{Math.round((previewPanelRef?.panelActions?.getScale() || 1) * 100)}%</span>
383
- </div>
384
- {:else if panelId === 'git'}
385
- <!-- View mode toggles (only in single-column mode, like Files panel) -->
386
- {#if !gitPanelRef?.panelActions?.isTwoColumnMode()}
387
- <div class="flex gap-1 bg-slate-100/80 dark:bg-slate-800/50 rounded-md">
388
- <button
389
- type="button"
390
- class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100
391
- {gitPanelRef?.panelActions?.getViewMode() === 'list'
392
- ? 'bg-violet-500/15 dark:bg-violet-500/25 text-violet-600'
393
- : ''}"
394
- onclick={() => gitPanelRef?.panelActions?.setViewMode('list')}
395
- title="Changes List"
396
- >
397
- <Icon name="lucide:list" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
398
- </button>
399
- <button
400
- type="button"
401
- class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100 disabled:opacity-40 disabled:cursor-not-allowed
402
- {gitPanelRef?.panelActions?.getViewMode() === 'diff'
403
- ? 'bg-violet-500/15 dark:bg-violet-500/25 text-violet-600'
404
- : ''}"
405
- onclick={() => gitPanelRef?.panelActions?.setViewMode('diff')}
406
- disabled={!gitPanelRef?.panelActions?.canShowDiff()}
407
- title="Diff Viewer"
408
- >
409
- <Icon name="lucide:file-diff" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
410
- </button>
411
- </div>
412
- {/if}
413
- {@const hasRemotes = gitPanelRef?.panelActions?.getHasRemotes()}
414
- {@const remoteName = gitPanelRef?.panelActions?.getSelectedRemote() || 'origin'}
415
- {@const gitRemotes = gitPanelRef?.panelActions?.getRemotes() || []}
416
-
417
- <!-- Remote selector -->
418
- {#if hasRemotes}
419
- <div class="relative">
420
- <button
421
- type="button"
422
- class="flex items-center gap-1 {isMobile ? 'h-9 px-2' : 'h-6 px-1.5'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100"
423
- onclick={() => showRemoteDropdown = !showRemoteDropdown}
424
- title="Select remote"
425
- >
426
- <Icon name="lucide:globe" class={isMobile ? 'w-4 h-4' : 'w-3.5 h-3.5'} />
427
- <span class="text-xs font-medium">{remoteName}</span>
428
- {#if gitRemotes.length > 1}
429
- <Icon name="lucide:chevron-down" class="w-3 h-3" />
430
- {/if}
431
- </button>
432
-
433
- {#if showRemoteDropdown && gitRemotes.length > 1}
434
- <div class="fixed inset-0 z-40" onclick={() => showRemoteDropdown = false}></div>
435
- <div class="absolute top-full right-0 mt-1 z-50 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-lg shadow-lg overflow-hidden min-w-36">
436
- {#each gitRemotes as remote (remote.name)}
437
- <button
438
- type="button"
439
- class="flex items-center gap-2 w-full px-3 py-2 text-left text-xs bg-transparent border-none cursor-pointer transition-all duration-150 hover:bg-violet-500/10
440
- {remote.name === remoteName ? 'text-violet-600 font-medium' : 'text-slate-700 dark:text-slate-300'}"
441
- onclick={() => { gitPanelRef?.panelActions?.setSelectedRemote(remote.name); showRemoteDropdown = false; }}
442
- >
443
- <Icon name="lucide:globe" class="w-3.5 h-3.5 shrink-0" />
444
- <div class="flex-1 min-w-0">
445
- <div>{remote.name}</div>
446
- <div class="text-[10px] text-slate-400 truncate font-mono">{remote.fetchUrl}</div>
447
- </div>
448
- {#if remote.name === remoteName}
449
- <Icon name="lucide:check" class="w-3.5 h-3.5 text-violet-600 shrink-0" />
450
- {/if}
451
- </button>
452
- {/each}
453
- </div>
454
- {/if}
455
- </div>
456
- {:else if gitPanelRef?.panelActions?.getIsRepo()}
457
- <span class="text-xs text-slate-400 italic px-1">no remote</span>
458
- {/if}
459
-
460
- <!-- Fetch -->
461
- <button
462
- type="button"
463
- class="flex items-center justify-center gap-1 {isMobile ? 'h-9 px-2' : 'h-6 px-1.5'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100 disabled:opacity-50 disabled:cursor-not-allowed"
464
- onclick={() => gitPanelRef?.panelActions?.fetch()}
465
- disabled={gitPanelRef?.panelActions?.getIsFetching() || !hasRemotes}
466
- title={hasRemotes ? `Fetch from ${remoteName}` : 'No remote configured'}
467
- >
468
- {#if gitPanelRef?.panelActions?.getIsFetching()}
469
- <div class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} border-2 border-slate-300/30 border-t-slate-500 rounded-full animate-spin"></div>
470
- {:else}
471
- <Icon name="lucide:cloud-download" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
472
- {/if}
473
- </button>
474
- <!-- Pull -->
475
- <button
476
- type="button"
477
- class="flex items-center justify-center gap-1 {isMobile ? 'h-9 px-2' : 'h-6 px-1.5'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100 disabled:opacity-50 disabled:cursor-not-allowed"
478
- onclick={() => gitPanelRef?.panelActions?.pull()}
479
- disabled={gitPanelRef?.panelActions?.getIsPulling() || !hasRemotes}
480
- title={hasRemotes ? `Pull from ${remoteName}` : 'No remote configured'}
481
- >
482
- {#if gitPanelRef?.panelActions?.getIsPulling()}
483
- <div class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} border-2 border-slate-300/30 border-t-slate-500 rounded-full animate-spin"></div>
484
- {:else}
485
- <Icon name="lucide:arrow-down-to-line" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
486
- {/if}
487
- </button>
488
- <!-- Push -->
489
- <button
490
- type="button"
491
- class="flex items-center justify-center gap-1 {isMobile ? 'h-9 px-2' : 'h-6 px-1.5'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100 disabled:opacity-50 disabled:cursor-not-allowed"
492
- onclick={() => gitPanelRef?.panelActions?.push()}
493
- disabled={gitPanelRef?.panelActions?.getIsPushing() || !hasRemotes}
494
- title={hasRemotes ? `Push to ${remoteName}` : 'No remote configured'}
495
- >
496
- {#if gitPanelRef?.panelActions?.getIsPushing()}
497
- <div class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} border-2 border-slate-300/30 border-t-slate-500 rounded-full animate-spin"></div>
498
- {:else}
499
- <Icon name="lucide:arrow-up-from-line" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
500
- {/if}
501
- </button>
502
- {/if}
503
- </div>
504
- </div>
505
- </header>
1
+ <script lang="ts">
2
+ import { browser } from '$frontend/lib/app-environment';
3
+ import { onMount, onDestroy } from 'svelte';
4
+ import Icon from '$frontend/lib/components/common/Icon.svelte';
5
+ import AvatarBubble from '$frontend/lib/components/common/AvatarBubble.svelte';
6
+ import { sessionState } from '$frontend/lib/stores/core/sessions.svelte';
7
+ import { projectState } from '$frontend/lib/stores/core/projects.svelte';
8
+ import { presenceState } from '$frontend/lib/stores/core/presence.svelte';
9
+ import { userStore } from '$frontend/lib/stores/features/user.svelte';
10
+ import {
11
+ workspaceState,
12
+ type PanelId,
13
+ swapPanel,
14
+ splitPanel,
15
+ closePanel,
16
+ canClosePanel,
17
+ PANEL_OPTIONS
18
+ } from '$frontend/lib/stores/ui/workspace.svelte';
19
+ import type { IconName } from '$shared/types/ui/icons';
20
+ import type { DeviceSize } from '$frontend/lib/constants/preview';
21
+
22
+ import { DEVICE_VIEWPORTS } from '$frontend/lib/constants/preview';
23
+
24
+ interface Props {
25
+ panelId: PanelId;
26
+ chatPanelRef?: any;
27
+ filesPanelRef?: any;
28
+ terminalPanelRef?: any;
29
+ previewPanelRef?: any;
30
+ gitPanelRef?: any;
31
+ onHistoryOpen?: () => void;
32
+ }
33
+
34
+ const {
35
+ panelId,
36
+ chatPanelRef,
37
+ filesPanelRef,
38
+ terminalPanelRef,
39
+ previewPanelRef,
40
+ gitPanelRef,
41
+ onHistoryOpen
42
+ }: Props = $props();
43
+
44
+ const panel = $derived(workspaceState.panels[panelId]);
45
+ const iconName = $derived((panel?.icon ?? 'lucide:box') as IconName);
46
+
47
+ // Mobile detection
48
+ let isMobile = $state(false);
49
+
50
+ // Chat session users (other users in the same chat session, excluding self)
51
+ const chatSessionUsers = $derived.by(() => {
52
+ if (panelId !== 'chat') return [];
53
+ const projectId = projectState.currentProject?.id;
54
+ const chatSessionId = sessionState.currentSession?.id;
55
+ const currentUserId = userStore.currentUser?.id;
56
+ if (!projectId || !chatSessionId) return [];
57
+ const status = presenceState.statuses.get(projectId);
58
+ if (!status?.chatSessionUsers) return [];
59
+ const users = status.chatSessionUsers[chatSessionId] || [];
60
+ return currentUserId ? users.filter(u => u.userId !== currentUserId) : users;
61
+ });
62
+
63
+ // Chat session users popover
64
+ let showChatUsersPopover = $state(false);
65
+ let chatUsersContainer = $state<HTMLDivElement | null>(null);
66
+
67
+ function toggleChatUsersPopover(e: MouseEvent) {
68
+ e.stopPropagation();
69
+ showChatUsersPopover = !showChatUsersPopover;
70
+ }
71
+
72
+ $effect(() => {
73
+ if (showChatUsersPopover) {
74
+ const handleClickOutside = (e: MouseEvent) => {
75
+ if (chatUsersContainer && !chatUsersContainer.contains(e.target as Node)) {
76
+ showChatUsersPopover = false;
77
+ }
78
+ };
79
+ document.addEventListener('click', handleClickOutside, true);
80
+ return () => document.removeEventListener('click', handleClickOutside, true);
81
+ }
82
+ });
83
+
84
+ // Panel actions menu state
85
+ let showActionsMenu = $state(false);
86
+ let actionsButtonRef = $state<HTMLButtonElement | null>(null);
87
+ let menuPosition = $state({ top: 0, left: 0 });
88
+
89
+ function toggleActionsMenu(e: MouseEvent) {
90
+ e.stopPropagation();
91
+ if (!showActionsMenu && actionsButtonRef) {
92
+ const rect = actionsButtonRef.getBoundingClientRect();
93
+ menuPosition = { top: rect.bottom + 4, left: rect.left };
94
+ }
95
+ showActionsMenu = !showActionsMenu;
96
+ }
97
+
98
+ function closeActionsMenu() {
99
+ showActionsMenu = false;
100
+ }
101
+
102
+ function handleSwap(newPanelId: PanelId) {
103
+ swapPanel(panelId, newPanelId);
104
+ closeActionsMenu();
105
+ }
106
+
107
+ function handleSplit(direction: 'vertical' | 'horizontal') {
108
+ splitPanel(panelId, direction);
109
+ closeActionsMenu();
110
+ }
111
+
112
+ function handleClose() {
113
+ closePanel(panelId);
114
+ closeActionsMenu();
115
+ }
116
+
117
+ // Preview panel device dropdown state
118
+ let showDeviceDropdown = $state(false);
119
+
120
+ // Git remote dropdown state
121
+ let showRemoteDropdown = $state(false);
122
+
123
+ function toggleDeviceDropdown() {
124
+ showDeviceDropdown = !showDeviceDropdown;
125
+ }
126
+
127
+ function closeDeviceDropdown() {
128
+ showDeviceDropdown = false;
129
+ }
130
+
131
+ function selectDevice(size: DeviceSize) {
132
+ previewPanelRef?.panelActions?.setDeviceSize(size);
133
+ closeDeviceDropdown();
134
+ }
135
+
136
+ function handleResize() {
137
+ if (browser) {
138
+ isMobile = window.innerWidth < 1024;
139
+ }
140
+ }
141
+
142
+ onMount(() => {
143
+ handleResize();
144
+ if (browser) {
145
+ window.addEventListener('resize', handleResize);
146
+ }
147
+ });
148
+
149
+ onDestroy(() => {
150
+ if (browser) {
151
+ window.removeEventListener('resize', handleResize);
152
+ }
153
+ });
154
+ </script>
155
+
156
+ <header
157
+ class="flex items-center justify-between shrink-0 {isMobile
158
+ ? 'h-11 pb-2 px-4 bg-white/90 dark:bg-slate-900/98 border-b border-slate-200 dark:border-slate-800'
159
+ : 'py-2.5 px-3.5 bg-slate-100 dark:bg-slate-800/80 border-b border-slate-200 dark:border-slate-800'}"
160
+ >
161
+ <div class="flex items-center text-sm font-medium text-slate-900 dark:text-slate-100">
162
+ <!-- Panel layout actions (⋮ menu) -->
163
+ {#if !isMobile}
164
+ <div class="relative -ml-0.5 mr-2 border-slate-200 dark:border-slate-700">
165
+ <button
166
+ bind:this={actionsButtonRef}
167
+ type="button"
168
+ class="flex items-center justify-center w-6 h-6 bg-transparent border-none rounded-md text-slate-400 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-700 dark:hover:text-slate-200"
169
+ onclick={toggleActionsMenu}
170
+ title="Panel actions"
171
+ >
172
+ <Icon name="lucide:ellipsis-vertical" class="w-3.5 h-3.5" />
173
+ </button>
174
+
175
+ {#if showActionsMenu}
176
+ <div class="fixed inset-0 z-40" onclick={closeActionsMenu}></div>
177
+ <div class="fixed z-50 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-lg shadow-lg overflow-hidden min-w-44 py-1" style="top: {menuPosition.top}px; left: {menuPosition.left}px;">
178
+ <!-- Switch to section -->
179
+ <div class="px-3 py-1.5 text-3xs font-semibold text-slate-400 dark:text-slate-500 uppercase tracking-wider">
180
+ Switch to
181
+ </div>
182
+ {#each PANEL_OPTIONS as option}
183
+ <button
184
+ type="button"
185
+ class="flex items-center gap-2.5 w-full px-3 py-1.5 text-left text-xs bg-transparent border-none cursor-pointer transition-all duration-150 hover:bg-violet-500/10
186
+ {option.id === panelId ? 'text-violet-600 dark:text-violet-400 font-medium' : 'text-slate-700 dark:text-slate-300'}"
187
+ onclick={() => handleSwap(option.id)}
188
+ disabled={option.id === panelId}
189
+ >
190
+ <Icon name={option.icon} class="w-3.5 h-3.5" />
191
+ <span class="flex-1">{option.title}</span>
192
+ {#if option.id === panelId}
193
+ <Icon name="lucide:check" class="w-3 h-3 text-violet-600 dark:text-violet-400" />
194
+ {/if}
195
+ </button>
196
+ {/each}
197
+
198
+ <!-- Divider -->
199
+ <div class="my-1 border-t border-slate-200 dark:border-slate-700"></div>
200
+
201
+ <!-- Split actions -->
202
+ <button
203
+ type="button"
204
+ class="flex items-center gap-2.5 w-full px-3 py-1.5 text-left text-xs bg-transparent border-none cursor-pointer transition-all duration-150 hover:bg-violet-500/10 text-slate-700 dark:text-slate-300"
205
+ onclick={() => handleSplit('vertical')}
206
+ >
207
+ <Icon name="lucide:columns-2" class="w-3.5 h-3.5" />
208
+ <span>Split Right</span>
209
+ </button>
210
+ <button
211
+ type="button"
212
+ class="flex items-center gap-2.5 w-full px-3 py-1.5 text-left text-xs bg-transparent border-none cursor-pointer transition-all duration-150 hover:bg-violet-500/10 text-slate-700 dark:text-slate-300"
213
+ onclick={() => handleSplit('horizontal')}
214
+ >
215
+ <Icon name="lucide:rows-2" class="w-3.5 h-3.5" />
216
+ <span>Split Down</span>
217
+ </button>
218
+
219
+ <!-- Divider -->
220
+ <div class="my-1 border-t border-slate-200 dark:border-slate-700"></div>
221
+
222
+ <!-- Close -->
223
+ <button
224
+ type="button"
225
+ class="flex items-center gap-2.5 w-full px-3 py-1.5 text-left text-xs bg-transparent border-none cursor-pointer transition-all duration-150 hover:bg-red-500/10 text-red-600 dark:text-red-400 disabled:opacity-40 disabled:cursor-not-allowed"
226
+ onclick={handleClose}
227
+ disabled={!canClosePanel()}
228
+ title={!canClosePanel() ? 'Cannot close last panel' : 'Close this panel'}
229
+ >
230
+ <Icon name="lucide:x" class="w-3.5 h-3.5" />
231
+ <span>Close Panel</span>
232
+ </button>
233
+ </div>
234
+ {/if}
235
+ </div>
236
+ {/if}
237
+ <Icon name={iconName} class="w-4 h-4 text-violet-600" />
238
+ <span class="ml-2.5">{panel?.title ?? 'Panel'}</span>
239
+ </div>
240
+
241
+ <div class="flex items-center">
242
+ <!-- Panel-specific actions -->
243
+ <div class="flex items-center gap-1.5">
244
+ {#if panelId === 'chat'}
245
+ {#if chatSessionUsers.length > 0}
246
+ <div class="relative" bind:this={chatUsersContainer}>
247
+ <div class="flex items-center -space-x-1.5 mr-1 cursor-pointer" title="Users in this session" onclick={toggleChatUsersPopover}>
248
+ {#each chatSessionUsers.slice(0, 3) as user}
249
+ <AvatarBubble {user} size="sm" />
250
+ {/each}
251
+ {#if chatSessionUsers.length > 3}
252
+ <span class="w-5 h-5 rounded-full bg-gradient-to-br from-slate-500 to-slate-600 dark:from-slate-600 dark:to-slate-700 text-white text-4xs font-bold flex items-center justify-center border-2 border-white dark:border-slate-800 z-10">
253
+ +{chatSessionUsers.length - 3}
254
+ </span>
255
+ {/if}
256
+ </div>
257
+ {#if showChatUsersPopover}
258
+ <div class="absolute top-full right-0 mt-2 py-2 px-1 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-lg shadow-lg z-50 min-w-[160px]">
259
+ <div class="px-2 pb-1.5 text-left text-xs font-semibold text-slate-500 dark:text-slate-400">
260
+ In this session ({chatSessionUsers.length})
261
+ </div>
262
+ {#each chatSessionUsers as user}
263
+ <div class="flex items-center gap-2 px-2 py-1.5 rounded-md">
264
+ <AvatarBubble {user} size="sm" showName={true} />
265
+ </div>
266
+ {/each}
267
+ </div>
268
+ {/if}
269
+ </div>
270
+ {/if}
271
+ <button
272
+ type="button"
273
+ class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100"
274
+ onclick={onHistoryOpen}
275
+ title="Switch Session"
276
+ >
277
+ <Icon name="lucide:history" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
278
+ </button>
279
+ {#if sessionState.messages.length > 0}
280
+ <button
281
+ type="button"
282
+ class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100"
283
+ onclick={() => chatPanelRef?.panelActions?.checkpoints()}
284
+ title="Restore Checkpoint"
285
+ >
286
+ <Icon name="lucide:undo-2" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
287
+ </button>
288
+ {/if}
289
+ <button
290
+ type="button"
291
+ class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100"
292
+ onclick={() => chatPanelRef?.panelActions?.newChat()}
293
+ title="New Chat"
294
+ >
295
+ <Icon name="lucide:plus" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
296
+ </button>
297
+ {:else if panelId === 'files'}
298
+ <!-- Hide view mode toggles when in two-column mode -->
299
+ {#if !filesPanelRef?.panelActions?.isTwoColumnMode()}
300
+ <div class="flex gap-1 bg-slate-100/80 dark:bg-slate-800/50 rounded-md">
301
+ <button
302
+ type="button"
303
+ class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100 disabled:opacity-40 disabled:cursor-not-allowed
304
+ {filesPanelRef?.panelActions?.getViewMode() === 'tree'
305
+ ? 'bg-violet-500/15 dark:bg-violet-500/25 text-violet-600'
306
+ : ''}"
307
+ onclick={() => filesPanelRef?.panelActions?.setViewMode('tree')}
308
+ title="Tree View"
309
+ >
310
+ <Icon name="lucide:folder-tree" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
311
+ </button>
312
+ <button
313
+ type="button"
314
+ class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100 disabled:opacity-40 disabled:cursor-not-allowed
315
+ {filesPanelRef?.panelActions?.getViewMode() === 'viewer'
316
+ ? 'bg-violet-500/15 dark:bg-violet-500/25 text-violet-600'
317
+ : ''}"
318
+ onclick={() => filesPanelRef?.panelActions?.setViewMode('viewer')}
319
+ disabled={!filesPanelRef?.panelActions?.canShowViewer()}
320
+ title="File Viewer"
321
+ >
322
+ <Icon name="lucide:file-code" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
323
+ </button>
324
+ </div>
325
+ {/if}
326
+ {:else if panelId === 'terminal'}
327
+ <button
328
+ type="button"
329
+ class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100"
330
+ onclick={() => terminalPanelRef?.panelActions?.handleClear()}
331
+ title="Clear Terminal"
332
+ >
333
+ <Icon name="lucide:trash-2" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
334
+ </button>
335
+ {#if !isMobile || terminalPanelRef?.panelActions?.isExecuting()}
336
+ <button
337
+ type="button"
338
+ class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded-md {isMobile ? 'text-red-600 dark:text-red-400' : 'text-slate-500'} cursor-pointer transition-all duration-150 hover:bg-red-500/10 hover:text-red-600 dark:hover:text-red-400 disabled:opacity-50 disabled:cursor-not-allowed"
339
+ onclick={() => terminalPanelRef?.panelActions?.handleCancel()}
340
+ disabled={terminalPanelRef?.panelActions?.isCancelling()}
341
+ title="{isMobile ? 'Cancel Command (Ctrl+C)' : 'Send Ctrl+C Signal'}"
342
+ >
343
+ {#if terminalPanelRef?.panelActions?.isCancelling()}
344
+ <div
345
+ class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} border-2 border-red-500/20 border-t-red-600 rounded-full animate-spin"
346
+ ></div>
347
+ {:else}
348
+ <Icon name="lucide:square" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
349
+ {/if}
350
+ </button>
351
+ {/if}
352
+ {:else if panelId === 'preview'}
353
+ <!-- Connection status indicator -->
354
+ <!-- {@const sessionInfo = previewPanelRef?.panelActions?.getSessionInfo()}
355
+ {@const isStreamReady = previewPanelRef?.panelActions?.getIsStreamReady()}
356
+ {@const errorMessage = previewPanelRef?.panelActions?.getErrorMessage()}
357
+ {@const url = previewPanelRef?.panelActions?.getUrl()}
358
+
359
+ {#if url}
360
+ <div class="flex items-center gap-1.5 {isMobile ? 'px-2 h-9' : 'px-2 h-6'} rounded-md">
361
+ <div class="relative">
362
+ {#if !sessionInfo}
363
+ <span class="w-2 h-2 rounded-full block bg-amber-400"></span>
364
+ {:else if errorMessage}
365
+ <span class="w-2 h-2 rounded-full block bg-red-500"></span>
366
+ {:else if isStreamReady}
367
+ <span class="w-2 h-2 rounded-full block bg-emerald-500"></span>
368
+ <span class="absolute inset-0 w-2 h-2 bg-emerald-500 rounded-full animate-ping opacity-75"></span>
369
+ {:else}
370
+ <span class="w-2 h-2 rounded-full block bg-blue-400 animate-pulse"></span>
371
+ {/if}
372
+ </div>
373
+ <span class="text-xs font-medium {
374
+ !sessionInfo ? 'text-amber-600 dark:text-amber-400' :
375
+ errorMessage ? 'text-red-600 dark:text-red-400' :
376
+ isStreamReady ? 'text-emerald-600 dark:text-emerald-400' :
377
+ 'text-blue-600 dark:text-blue-400'
378
+ }">
379
+ {!sessionInfo ? 'Ready' : errorMessage ? 'Offline' : isStreamReady ? 'Online' : 'Connecting'}
380
+ </span>
381
+ </div>
382
+ {/if} -->
383
+
384
+ <!-- Device size dropdown -->
385
+ <div class="relative {isMobile ? '' : 'mr-1.5'}">
386
+ <button
387
+ type="button"
388
+ class="flex items-center justify-center gap-1.5 {isMobile ? 'px-2 h-9' : 'px-1 h-6'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100"
389
+ onclick={toggleDeviceDropdown}
390
+ title="Select device size"
391
+ >
392
+ {#if previewPanelRef?.panelActions?.getDeviceSize() === 'desktop'}
393
+ <Icon name="lucide:monitor" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
394
+ <span class="text-xs font-medium">Desktop</span>
395
+ {:else if previewPanelRef?.panelActions?.getDeviceSize() === 'laptop'}
396
+ <Icon name="lucide:laptop" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
397
+ <span class="text-xs font-medium">Laptop</span>
398
+ {:else if previewPanelRef?.panelActions?.getDeviceSize() === 'tablet'}
399
+ <Icon name="lucide:tablet" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
400
+ <span class="text-xs font-medium">Tablet</span>
401
+ {:else}
402
+ <Icon name="lucide:smartphone" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
403
+ <span class="text-xs font-medium">Mobile</span>
404
+ {/if}
405
+ <Icon name="lucide:chevron-down" class={isMobile ? 'w-3.5 h-3.5' : 'w-3 h-3'} />
406
+ </button>
407
+
408
+ <!-- Dropdown menu -->
409
+ {#if showDeviceDropdown}
410
+ <div
411
+ class="fixed inset-0 z-40"
412
+ onclick={closeDeviceDropdown}
413
+ ></div>
414
+ <div class="absolute top-full right-0 mt-1 z-50 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-lg shadow-lg overflow-hidden {isMobile ? 'min-w-44' : 'min-w-40'}">
415
+ <button
416
+ type="button"
417
+ class="flex items-center gap-2.5 w-full px-3 {isMobile ? 'py-2.5' : 'py-2'} text-left text-sm bg-transparent border-none cursor-pointer transition-all duration-150 hover:bg-violet-500/10 {previewPanelRef?.panelActions?.getDeviceSize() === 'desktop' ? 'bg-violet-500/5 text-violet-600' : 'text-slate-700 dark:text-slate-300'}"
418
+ onclick={() => selectDevice('desktop')}
419
+ >
420
+ <Icon name="lucide:monitor" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
421
+ <div class="flex-1">
422
+ <div class="font-medium">Desktop</div>
423
+ <div class="text-xs text-slate-500 dark:text-slate-400">
424
+ {DEVICE_VIEWPORTS.desktop.width}×{DEVICE_VIEWPORTS.desktop.height}
425
+ </div>
426
+ </div>
427
+ {#if previewPanelRef?.panelActions?.getDeviceSize() === 'desktop'}
428
+ <Icon name="lucide:check" class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} text-violet-600" />
429
+ {/if}
430
+ </button>
431
+ <button
432
+ type="button"
433
+ class="flex items-center gap-2.5 w-full px-3 {isMobile ? 'py-2.5' : 'py-2'} text-left text-sm bg-transparent border-none cursor-pointer transition-all duration-150 hover:bg-violet-500/10 {previewPanelRef?.panelActions?.getDeviceSize() === 'laptop' ? 'bg-violet-500/5 text-violet-600' : 'text-slate-700 dark:text-slate-300'}"
434
+ onclick={() => selectDevice('laptop')}
435
+ >
436
+ <Icon name="lucide:laptop" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
437
+ <div class="flex-1">
438
+ <div class="font-medium">Laptop</div>
439
+ <div class="text-xs text-slate-500 dark:text-slate-400">
440
+ {DEVICE_VIEWPORTS.laptop.width}×{DEVICE_VIEWPORTS.laptop.height}
441
+ </div>
442
+ </div>
443
+ {#if previewPanelRef?.panelActions?.getDeviceSize() === 'laptop'}
444
+ <Icon name="lucide:check" class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} text-violet-600" />
445
+ {/if}
446
+ </button>
447
+ <button
448
+ type="button"
449
+ class="flex items-center gap-2.5 w-full px-3 {isMobile ? 'py-2.5' : 'py-2'} text-left text-sm bg-transparent border-none cursor-pointer transition-all duration-150 hover:bg-violet-500/10 {previewPanelRef?.panelActions?.getDeviceSize() === 'tablet' ? 'bg-violet-500/5 text-violet-600' : 'text-slate-700 dark:text-slate-300'}"
450
+ onclick={() => selectDevice('tablet')}
451
+ >
452
+ <Icon name="lucide:tablet" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
453
+ <div class="flex-1">
454
+ <div class="font-medium">Tablet</div>
455
+ <div class="text-xs text-slate-500 dark:text-slate-400">
456
+ {DEVICE_VIEWPORTS.tablet.width}×{DEVICE_VIEWPORTS.tablet.height}
457
+ </div>
458
+ </div>
459
+ {#if previewPanelRef?.panelActions?.getDeviceSize() === 'tablet'}
460
+ <Icon name="lucide:check" class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} text-violet-600" />
461
+ {/if}
462
+ </button>
463
+ <button
464
+ type="button"
465
+ class="flex items-center gap-2.5 w-full px-3 {isMobile ? 'py-2.5' : 'py-2'} text-left text-sm bg-transparent border-none cursor-pointer transition-all duration-150 hover:bg-violet-500/10 {previewPanelRef?.panelActions?.getDeviceSize() === 'mobile' ? 'bg-violet-500/5 text-violet-600' : 'text-slate-700 dark:text-slate-300'}"
466
+ onclick={() => selectDevice('mobile')}
467
+ >
468
+ <Icon name="lucide:smartphone" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
469
+ <div class="flex-1">
470
+ <div class="font-medium">Mobile</div>
471
+ <div class="text-xs text-slate-500 dark:text-slate-400">
472
+ {DEVICE_VIEWPORTS.mobile.width}×{DEVICE_VIEWPORTS.mobile.height}
473
+ </div>
474
+ </div>
475
+ {#if previewPanelRef?.panelActions?.getDeviceSize() === 'mobile'}
476
+ <Icon name="lucide:check" class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} text-violet-600" />
477
+ {/if}
478
+ </button>
479
+ </div>
480
+ {/if}
481
+ </div>
482
+
483
+ <!-- Rotation toggle -->
484
+ <button
485
+ type="button"
486
+ class="flex items-center justify-center gap-1.5 {isMobile ? 'px-2 h-9' : 'px-1 h-6'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100"
487
+ onclick={() => previewPanelRef?.panelActions?.toggleRotation()}
488
+ title="Toggle orientation"
489
+ >
490
+ <Icon name="lucide:rotate-cw" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
491
+ <span class="text-xs font-medium">
492
+ {previewPanelRef?.panelActions?.getRotation() === 'portrait' ? 'Portrait' : 'Landscape'}
493
+ </span>
494
+ </button>
495
+
496
+ <!-- Scale info badge -->
497
+ <div class="flex items-center gap-1.5 {isMobile ? 'px-2.5 h-9 bg-transparent' : 'px-2 h-6 bg-slate-100/60 dark:bg-slate-800/40'} rounded-md text-xs font-medium text-slate-500">
498
+ <Icon name="lucide:move-diagonal" class={isMobile ? 'w-4 h-4' : 'w-3.5 h-3.5'} />
499
+ <span>{Math.round((previewPanelRef?.panelActions?.getScale() || 1) * 100)}%</span>
500
+ </div>
501
+ {:else if panelId === 'git'}
502
+ <!-- View mode toggles (only in single-column mode, like Files panel) -->
503
+ {#if !gitPanelRef?.panelActions?.isTwoColumnMode()}
504
+ <div class="flex gap-1 bg-slate-100/80 dark:bg-slate-800/50 rounded-md">
505
+ <button
506
+ type="button"
507
+ class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100
508
+ {gitPanelRef?.panelActions?.getViewMode() === 'list'
509
+ ? 'bg-violet-500/15 dark:bg-violet-500/25 text-violet-600'
510
+ : ''}"
511
+ onclick={() => gitPanelRef?.panelActions?.setViewMode('list')}
512
+ title="Changes List"
513
+ >
514
+ <Icon name="lucide:list" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
515
+ </button>
516
+ <button
517
+ type="button"
518
+ class="flex items-center justify-center {isMobile ? 'w-9 h-9' : 'w-6 h-6'} bg-transparent border-none rounded text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100 disabled:opacity-40 disabled:cursor-not-allowed
519
+ {gitPanelRef?.panelActions?.getViewMode() === 'diff'
520
+ ? 'bg-violet-500/15 dark:bg-violet-500/25 text-violet-600'
521
+ : ''}"
522
+ onclick={() => gitPanelRef?.panelActions?.setViewMode('diff')}
523
+ disabled={!gitPanelRef?.panelActions?.canShowDiff()}
524
+ title="Diff Viewer"
525
+ >
526
+ <Icon name="lucide:file-diff" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
527
+ </button>
528
+ </div>
529
+ {/if}
530
+ {@const hasRemotes = gitPanelRef?.panelActions?.getHasRemotes()}
531
+ {@const remoteName = gitPanelRef?.panelActions?.getSelectedRemote() || 'origin'}
532
+ {@const gitRemotes = gitPanelRef?.panelActions?.getRemotes() || []}
533
+
534
+ <!-- Remote selector -->
535
+ {#if hasRemotes}
536
+ <div class="relative">
537
+ <button
538
+ type="button"
539
+ class="flex items-center gap-1 {isMobile ? 'h-9 px-2' : 'h-6 px-1.5'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100"
540
+ onclick={() => showRemoteDropdown = !showRemoteDropdown}
541
+ title="Select remote"
542
+ >
543
+ <Icon name="lucide:globe" class={isMobile ? 'w-4 h-4' : 'w-3.5 h-3.5'} />
544
+ <span class="text-xs font-medium">{remoteName}</span>
545
+ {#if gitRemotes.length > 1}
546
+ <Icon name="lucide:chevron-down" class="w-3 h-3" />
547
+ {/if}
548
+ </button>
549
+
550
+ {#if showRemoteDropdown && gitRemotes.length > 1}
551
+ <div class="fixed inset-0 z-40" onclick={() => showRemoteDropdown = false}></div>
552
+ <div class="absolute top-full right-0 mt-1 z-50 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-lg shadow-lg overflow-hidden min-w-36">
553
+ {#each gitRemotes as remote (remote.name)}
554
+ <button
555
+ type="button"
556
+ class="flex items-center gap-2 w-full px-3 py-2 text-left text-xs bg-transparent border-none cursor-pointer transition-all duration-150 hover:bg-violet-500/10
557
+ {remote.name === remoteName ? 'text-violet-600 font-medium' : 'text-slate-700 dark:text-slate-300'}"
558
+ onclick={() => { gitPanelRef?.panelActions?.setSelectedRemote(remote.name); showRemoteDropdown = false; }}
559
+ >
560
+ <Icon name="lucide:globe" class="w-3.5 h-3.5 shrink-0" />
561
+ <div class="flex-1 min-w-0">
562
+ <div>{remote.name}</div>
563
+ <div class="text-3xs text-slate-400 truncate font-mono">{remote.fetchUrl}</div>
564
+ </div>
565
+ {#if remote.name === remoteName}
566
+ <Icon name="lucide:check" class="w-3.5 h-3.5 text-violet-600 shrink-0" />
567
+ {/if}
568
+ </button>
569
+ {/each}
570
+ </div>
571
+ {/if}
572
+ </div>
573
+ {:else if gitPanelRef?.panelActions?.getIsRepo()}
574
+ <span class="text-xs text-slate-400 italic px-1">no remote</span>
575
+ {/if}
576
+
577
+ <!-- Fetch -->
578
+ <button
579
+ type="button"
580
+ class="flex items-center justify-center gap-1 {isMobile ? 'h-9 px-2' : 'h-6 px-1.5'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100 disabled:opacity-50 disabled:cursor-not-allowed"
581
+ onclick={() => gitPanelRef?.panelActions?.fetch()}
582
+ disabled={gitPanelRef?.panelActions?.getIsFetching() || !hasRemotes}
583
+ title={hasRemotes ? `Fetch from ${remoteName}` : 'No remote configured'}
584
+ >
585
+ {#if gitPanelRef?.panelActions?.getIsFetching()}
586
+ <div class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} border-2 border-slate-300/30 border-t-slate-500 rounded-full animate-spin"></div>
587
+ {:else}
588
+ <Icon name="lucide:cloud-download" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
589
+ {/if}
590
+ </button>
591
+ <!-- Pull -->
592
+ <button
593
+ type="button"
594
+ class="flex items-center justify-center gap-1 {isMobile ? 'h-9 px-2' : 'h-6 px-1.5'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100 disabled:opacity-50 disabled:cursor-not-allowed"
595
+ onclick={() => gitPanelRef?.panelActions?.pull()}
596
+ disabled={gitPanelRef?.panelActions?.getIsPulling() || !hasRemotes}
597
+ title={hasRemotes ? `Pull from ${remoteName}` : 'No remote configured'}
598
+ >
599
+ {#if gitPanelRef?.panelActions?.getIsPulling()}
600
+ <div class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} border-2 border-slate-300/30 border-t-slate-500 rounded-full animate-spin"></div>
601
+ {:else}
602
+ <Icon name="lucide:arrow-down-to-line" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
603
+ {/if}
604
+ </button>
605
+ <!-- Push -->
606
+ <button
607
+ type="button"
608
+ class="flex items-center justify-center gap-1 {isMobile ? 'h-9 px-2' : 'h-6 px-1.5'} bg-transparent border-none rounded-md text-slate-500 cursor-pointer transition-all duration-150 hover:bg-violet-500/10 hover:text-slate-900 dark:hover:text-slate-100 disabled:opacity-50 disabled:cursor-not-allowed"
609
+ onclick={() => gitPanelRef?.panelActions?.push()}
610
+ disabled={gitPanelRef?.panelActions?.getIsPushing() || !hasRemotes}
611
+ title={hasRemotes ? `Push to ${remoteName}` : 'No remote configured'}
612
+ >
613
+ {#if gitPanelRef?.panelActions?.getIsPushing()}
614
+ <div class="{isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} border-2 border-slate-300/30 border-t-slate-500 rounded-full animate-spin"></div>
615
+ {:else}
616
+ <Icon name="lucide:arrow-up-from-line" class={isMobile ? 'w-4.5 h-4.5' : 'w-4 h-4'} />
617
+ {/if}
618
+ </button>
619
+ {/if}
620
+ </div>
621
+
622
+ </div>
623
+ </header>