@goodandready/dsh-remote-workspace 0.3.0 → 0.3.2

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/lib/client.js CHANGED
@@ -1,1991 +1,2316 @@
1
- // Remote Workspace Settings Card (settings.plugin.item) & Session Utility Chip.
2
- window.__ModuleLoader__.load({
3
- id: '@goodandready/dsh-remote-workspace',
4
- factory: (require) => {
5
- var module = { exports: {} }
6
- var exports = module.exports
7
- const React = require('react')
8
-
9
- const NS = 'dsh-remote-workspace'
10
-
11
- function ensureCss() {
12
- if (typeof document === 'undefined') return
13
- if (document.getElementById('drw-clinebot-full-css')) return
14
- const style = document.createElement('style')
15
- style.id = 'drw-clinebot-full-css'
16
- style.dataset.dshPlugin = NS
17
- style.textContent = `
18
- .drw-page{display:flex;flex-direction:column;gap:18px;padding:6px 0 24px;max-width:960px}
19
- .drw-header{display:flex;flex-direction:column;gap:8px;padding-bottom:14px;border-bottom:1px solid var(--dsw-alias-border-l2)}
20
- .drw-header-top{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px}
21
- .drw-page-title{font-size:20px;font-weight:700;color:var(--dsw-alias-label-primary);display:flex;align-items:center;gap:10px}
22
- .drw-page-sub{font-size:13px;color:var(--dsw-alias-label-secondary);line-height:1.5}
23
- .drw-header-badges{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
24
-
25
- .drw-card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:12px;padding:16px 18px;display:flex;flex-direction:column;gap:14px;list-style:none}
26
- .drw-card-title{font-size:15px;font-weight:600;color:var(--dsw-alias-label-primary);display:flex;align-items:center;justify-content:space-between}
27
- .drw-card-desc{font-size:13px;color:var(--dsw-alias-label-secondary);margin-top:-6px;line-height:1.4}
28
-
29
- .drw-row{display:flex;flex-wrap:wrap;gap:10px;align-items:center}
30
- .drw-grid-2{display:grid;grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));gap:12px}
31
- .drw-grid-4{display:grid;grid-template-columns:repeat(auto-fit, minmax(190px, 1fr));gap:10px}
32
-
33
- .drw-badge{font-size:11px;padding:3px 9px;border-radius:999px;border:1px solid var(--dsw-alias-border-l2);display:inline-flex;align-items:center;gap:5px;font-weight:500;font-family:monospace}
34
- .drw-badge-ok{border-color:var(--dsw-alias-state-success-primary);color:var(--dsw-alias-state-success-primary);background:rgba(16,185,129,0.08)}
35
- .drw-badge-warn{border-color:var(--dsw-alias-state-warning-primary);color:var(--dsw-alias-state-warning-primary);background:rgba(245,158,11,0.08)}
36
- .drw-badge-err{border-color:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-state-error-primary);background:rgba(239,68,68,0.08)}
37
-
38
- .drw-input{height:34px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 10px;font-size:13px;width:100%;box-sizing:border-box}
39
- .drw-input:focus{outline:none;border-color:var(--dsw-alias-state-brand-primary)}
40
- .drw-label{font-size:12px;font-weight:500;color:var(--dsw-alias-label-secondary);margin-bottom:2px}
41
- .drw-hint{font-size:11px;color:var(--dsw-alias-label-dimmed, var(--dsw-alias-label-secondary));line-height:1.3}
42
- .drw-field{display:flex;flex-direction:column;gap:3px;flex:1;min-width:180px}
43
-
44
- .drw-btn{appearance:none;font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:6px 12px;font-size:13px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-weight:500;display:inline-flex;align-items:center;justify-content:center;gap:6px;transition:all .15s ease}
45
- .drw-btn:hover:not(:disabled){background:var(--dsw-alias-bg-layer-4, var(--dsw-alias-bg-layer-2));border-color:var(--dsw-alias-label-dimmed, var(--dsw-alias-border-l2))}
46
- .drw-btn:disabled{opacity:0.6;cursor:not-allowed}
47
- .drw-btn-primary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3);border-color:transparent}
48
- .drw-btn-primary:hover:not(:disabled){opacity:0.9}
49
- .drw-btn-danger{color:var(--dsw-alias-state-error-primary);border-color:rgba(239,68,68,0.3)}
50
- .drw-btn-danger:hover:not(:disabled){background:rgba(239,68,68,0.12);border-color:rgba(239,68,68,0.5)}
51
-
52
- .drw-segmented{display:inline-flex;border-radius:8px;padding:2px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);gap:2px}
53
- .drw-segmented-item{appearance:none;border:none;background:none;cursor:pointer;padding:5px 12px;font-size:12px;font-weight:500;border-radius:6px;color:var(--dsw-alias-label-secondary);transition:all .15s ease}
54
- .drw-segmented-item-active{background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);box-shadow:0 1px 2px rgba(0,0,0,0.08);font-weight:600}
55
-
56
- .drw-table{width:100%;border-collapse:collapse;margin-top:4px}
57
- .drw-table th{text-align:left;font-size:12px;color:var(--dsw-alias-label-secondary);padding:8px 10px;border-bottom:1px solid var(--dsw-alias-border-l2);font-weight:600}
58
- .drw-table td{padding:9px 10px;border-bottom:1px solid var(--dsw-alias-border-l2);font-size:13px;color:var(--dsw-alias-label-primary)}
59
- .drw-table tr:hover{background:var(--dsw-alias-bg-layer-2)}
60
-
61
- .drw-stat-box{padding:10px 12px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-layer-2);display:flex;flex-direction:column;gap:3px}
62
- .drw-stat-val{font-size:14px;font-weight:700;color:var(--dsw-alias-label-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
63
- .drw-stat-lbl{font-size:11px;color:var(--dsw-alias-label-secondary)}
64
- .drw-preview{padding:10px 12px;border-radius:8px;background:var(--dsw-alias-bg-layer-2);font-family:monospace;font-size:12px;white-space:pre-wrap;word-break:break-all;border:1px solid var(--dsw-alias-border-l2);line-height:1.4}
65
-
66
- .drw-browser-modal{border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-2);padding:12px;display:flex;flex-direction:column;gap:8px;max-height:280px}
67
- .drw-browser-list{overflow-y:auto;display:flex;flex-direction:column;gap:2px;max-height:190px;padding-right:4px}
68
- .drw-browser-item{display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:6px;cursor:pointer;font-size:13px;font-family:monospace}
69
- .drw-browser-item:hover{background:var(--dsw-alias-bg-layer-3)}
70
-
71
- .drw-tabs{display:flex;gap:6px;border-bottom:1px solid var(--dsw-alias-border-l2);padding-bottom:10px;margin-bottom:14px;overflow-x:auto}
72
- .drw-tab-btn{appearance:none;border:1px solid transparent;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);padding:6px 14px;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;display:inline-flex;align-items:center;gap:6px;transition:all .15s ease}
73
- .drw-tab-btn:hover{background:var(--dsw-alias-bg-layer-4);color:var(--dsw-alias-label-primary)}
74
- .drw-tab-btn.active{background:var(--dsw-alias-bg-layer-4);border-color:var(--dsw-alias-state-brand-primary);color:var(--dsw-alias-state-brand-primary)}
75
-
76
- .drw-term-window{background:#0d1117;border:1px solid #30363d;border-radius:10px;display:flex;flex-direction:column;height:340px;overflow:hidden;box-shadow:0 4px 14px rgba(0,0,0,0.25)}
77
- .drw-term-header{background:#161b22;padding:6px 12px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #30363d;font-size:12px;color:#8b949e;font-family:monospace}
78
- .drw-term-body{flex:1;padding:10px 12px;overflow-y:auto;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12.5px;line-height:1.45;color:#c9d1d9;white-space:pre-wrap;word-break:break-all}
79
- .drw-term-footer{display:flex;background:#161b22;border-top:1px solid #30363d;padding:6px}
80
- .drw-term-input{flex:1;background:transparent;border:none;color:#58a6ff;font-family:monospace;font-size:13px;padding:4px 8px;outline:none}
81
-
82
- .drw-explorer-box{border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-2);padding:12px;display:flex;flex-direction:column;gap:10px}
83
- .drw-explorer-nav{display:flex;align-items:center;gap:8px;font-family:monospace;font-size:12px;background:var(--dsw-alias-bg-layer-1);padding:6px 10px;border-radius:6px;border:1px solid var(--dsw-alias-border-l2)}
84
- .drw-file-list{display:flex;flex-direction:column;gap:3px;max-height:260px;overflow-y:auto}
85
- .drw-file-row{display:flex;align-items:center;justify-content:space-between;padding:6px 10px;border-radius:6px;cursor:pointer;font-size:13px;font-family:monospace;transition:background .1s ease}
86
- .drw-file-row:hover{background:var(--dsw-alias-bg-layer-3)}
87
- .drw-file-meta{display:flex;align-items:center;gap:12px;color:var(--dsw-alias-label-secondary);font-size:11.5px}
88
-
89
- .drw-modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:9999;display:flex;align-items:center;justify-content:center;padding:20px}
90
- .drw-modal-dialog{background:var(--dsw-alias-bg-layer-3);border:1px solid var(--dsw-alias-border-l2);border-radius:12px;width:100%;max-width:800px;max-height:85vh;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 12px 32px rgba(0,0,0,0.4)}
91
- .drw-modal-hdr{padding:12px 16px;border-bottom:1px solid var(--dsw-alias-border-l2);display:flex;align-items:center;justify-content:space-between;font-weight:600}
92
- .drw-modal-body{flex:1;padding:12px 16px;overflow-y:auto}
93
-
94
- .drw-health-bar{display:grid;grid-template-columns:repeat(auto-fit, minmax(130px, 1fr));gap:8px;padding:8px 12px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;font-size:11.5px;font-family:monospace}
95
- .drw-health-item{display:flex;flex-direction:column;gap:2px}
96
- .drw-progress{height:6px;background:var(--dsw-alias-bg-layer-1);border-radius:3px;overflow:hidden}
97
- .drw-progress-fill{height:100%;border-radius:3px;transition:width .2s ease}
98
-
99
- .drw-container-row{display:grid;grid-template-columns:2fr 2fr 1.5fr 1.5fr auto;align-items:center;gap:10px;padding:8px 10px;border-bottom:1px solid var(--dsw-alias-border-l2);font-size:12.5px;font-family:monospace}
100
- .drw-container-row:hover{background:var(--dsw-alias-bg-layer-3)}
101
-
102
- `
103
- document.head.appendChild(style)
104
- }
105
-
106
- const en = {
107
- title: 'Remote Workspace',
108
- subtitle: 'Native SSH connections, SFTP file access, 3-way mirror sync, and port forwarding tunnels.',
109
- status: 'Ready',
110
-
111
- tabProfiles: '🖥️ Host Profiles',
112
-
113
- tabContainers: '🐳 Containers',
114
- containersTitle: 'Remote Docker / Podman Engine',
115
- containerName: 'Container',
116
- containerImage: 'Image',
117
- containerStatus: 'Status',
118
- containerPorts: 'Ports',
119
- btnLogs: 'Logs',
120
- btnRestart: 'Restart',
121
- btnStop: 'Stop',
122
- noContainers: 'No active containers found or Docker daemon not running.',
123
- healthCpu: 'CPU: {val}%',
124
- healthMem: 'RAM: {val}% ({used}/{total} MB)',
125
- healthDisk: 'Disk: {val}%',
126
- healthUptime: 'Up: {val}',
127
- autoSyncTitle: 'Live Auto-Sync on Save',
128
- autoSyncDesc: 'Automatically push modified files to remote workspace on local save.',
129
- btnTransfer: 'Copy to Host...',
130
- transferTitle: 'Server-to-Server Direct Transfer',
131
- transferDestHost: 'Destination Server',
132
- transferDestPath: 'Destination File Path',
133
- transferBtnExec: 'Transfer Directly',
134
- transferSuccess: 'Successfully transferred {bytes} bytes to {host}:{path}',
135
- fJumpHost: 'Jump Host (Bastion)',
136
- fJumpHostNone: 'Direct Connection (No Jump Host)',
137
-
138
- tabTerminal: '⚡ Web Terminal',
139
- tabExplorer: '📂 File Explorer',
140
- tabTunnels: '🔗 Port Tunnels',
141
- tabSync: '🔄 Sync Station',
142
- vaultProtectedBadge: '🛡️ .env Vault Protected',
143
- termStart: 'Connect Terminal',
144
- termStop: 'Disconnect',
145
- termClear: 'Clear',
146
- termPlaceholder: 'Type command and press Enter (e.g. htop, ls, docker ps)...',
147
- termConnected: 'Connected to PTY session {id} on {host}',
148
- termDisconnected: 'Terminal disconnected.',
149
- explorerTitle: 'Remote Filesystem Explorer',
150
- filePreviewTitle: 'File Viewer: {path}',
151
- fileSize: '{size} KB',
152
- btnSaveFile: 'Save Changes',
153
- fileSaved: 'File saved successfully.',
154
- tunnelTraffic: 'RX: {rx} | TX: {tx}',
155
- tunnelUptime: 'Up: {sec}s',
156
- openLocalLink: '🌐 Open Local Port',
157
- badgeOnline: 'Active Host: {name} ({latency} ms)',
158
- badgeOffline: 'No active host',
159
- badgeTunnels: 'Tunnels: {count}',
160
- badgeKey: '🔑 Key Auth',
161
- badgePassword: '🔒 Password Auth',
162
- profilesTitle: '🖥️ Remote SSH Profiles',
163
- profilesDesc: 'Configure remote machines for code execution, SFTP browsing, and background mirror sync.',
164
- addBtn: '+ Add Host',
165
- nameCol: 'Name',
166
- hostCol: 'Host / User',
167
- portCol: 'Port',
168
- pathCol: 'Remote Workspace',
169
- actionsCol: 'Actions',
170
- noHosts: 'No remote hosts configured yet. Click "+ Add Host" to create your first connection.',
171
- activeBadge: 'Active',
172
- pinBtn: 'Pin Active',
173
- editBtn: 'Edit',
174
- delBtn: 'Delete',
175
- delConfirm: 'Delete host profile "{name}"?',
176
- formTitleNew: 'Add New Host Profile',
177
- formTitleEdit: 'Edit Host Profile',
178
- fName: 'Profile Name',
179
- fHost: 'Host / IP Address',
180
- fPort: 'Port',
181
- fUser: 'Username',
182
- fAuthType: 'Authentication Method',
183
- fAuthKey: 'SSH Private Key',
184
- fAuthPass: 'Password',
185
- fKeyPath: 'Private Key Path',
186
- fKeyPathHint: 'Path to ~/.ssh/id_rsa or /home/user/.ssh/id_ed25519',
187
- fPassphrase: 'Key Passphrase (optional)',
188
- fPassword: 'Account Password',
189
- fRemotePath: 'Remote Workspace Directory',
190
- fRemotePathHint: 'Absolute path on the server (e.g. /home/user/my-project)',
191
- fLocalMirror: 'Local Mirror Directory',
192
- fLocalMirrorHint: 'Local directory where files are mirrored for fast 3-way synchronization',
193
- btnBrowse: '📁 Browse Remote...',
194
- btnSelectThis: 'Select Directory',
195
- btnTest: '⚡ Test Connection (Ping)',
196
- btnSave: 'Save Profile',
197
- btnCancel: 'Cancel',
198
- testing: 'Testing Connection...',
199
- saving: 'Saving...',
200
- testOk: '✅ Connection OK! Latency: {latency} ms | OS: {os}',
201
- testFail: '❌ Connection Failed: {err}',
202
- diagTitle: '📊 Active Connection Diagnostics',
203
- diagDesc: 'Real-time telemetry and engine status for the currently selected remote machine.',
204
- diagProbeBtn: '⚡ Quick Probe',
205
- syncTitle: '🔄 Two-Way Workspace Mirror Sync',
206
- syncDesc: 'Fast 3-way conflict-aware file synchronization between local mirror and remote server.',
207
- pullBtn: '⬇️ Pull from Remote',
208
- pushBtn: '⬆️ Push to Remote',
209
- pulling: 'Pulling files…',
210
- pushing: 'Pushing files…',
211
- syncOk: 'Sync completed! Updated {count} file(s).',
212
- syncConflict: 'Conflict warning: {count} file(s) modified on both sides.',
213
- syncErr: 'Sync error: {err}',
214
- tunnelsTitle: '🔀 SSH Port Forwarding (Tunnels)',
215
- tunnelsDesc: 'Forward remote ports (e.g. databases, web servers, APIs) to your local machine via encrypted SSH tunnels.',
216
- tLocalPort: 'Local Port',
217
- tRemotePort: 'Remote Port',
218
- tOpenBtn: '+ Open Tunnel',
219
- tOpening: 'Opening…',
220
- tStopBtn: 'Stop',
221
- tNoTunnels: 'No active port forwarding tunnels.',
222
- tunnelsColId: 'Tunnel ID',
223
- tunnelsColRoute: 'Forwarding Route',
224
- tunnelsColActions: 'Actions',
225
- tOpenOk: 'Tunnel opened: 127.0.0.1:{localPort} -> Remote:{remotePort}',
226
- tOpenErr: 'Failed to open tunnel: {err}'
227
- }
228
-
229
- const ru = {
230
- title: 'Удалённое рабочее пространство',
231
- subtitle: 'SSH-подключения, доступ к файлам по SFTP, 3-way синхронизация зеркала и проброс портов.',
232
- status: 'Готово',
233
- badgeOnline: 'Активный хост: {name} ({latency} мс)',
234
- badgeOffline: 'Хост не выбран',
235
- badgeTunnels: 'Туннелей: {count}',
236
- badgeKey: '🔑 Авторизация по ключу',
237
- badgePassword: '🔒 Авторизация по паролю',
238
- profilesTitle: '🖥️ Профили SSH серверов',
239
- profilesDesc: 'Настройка удалённых серверов для запуска команд, SFTP-навигации и синхронизации зеркала.',
240
- addBtn: '+ Добавить хост',
241
- nameCol: 'Имя',
242
- hostCol: 'Хост / Пользователь',
243
- portCol: 'Порт',
244
- pathCol: 'Удалённый путь',
245
- actionsCol: 'Действия',
246
- noHosts: 'Удалённые хосты ещё не настроены. Нажмите «+ Добавить хост» для создания подключения.',
247
- activeBadge: 'Активен',
248
- pinBtn: 'Сделать активным',
249
- editBtn: 'Править',
250
- delBtn: 'Удалить',
251
- delConfirm: 'Удалить профиль хоста «{name}»?',
252
- formTitleNew: 'Добавление нового SSH хоста',
253
- formTitleEdit: 'Редактирование профиля хоста',
254
- fName: 'Название подключения',
255
- fHost: 'Хост / IP-адрес',
256
- fPort: 'Порт',
257
- fUser: 'Имя пользователя',
258
- fAuthType: 'Способ авторизации',
259
- fAuthKey: 'SSH-ключ',
260
- fAuthPass: 'Пароль',
261
- fKeyPath: 'Путь к приватному ключу',
262
- fKeyPathHint: 'Путь к ~/.ssh/id_rsa или /home/user/.ssh/id_ed25519',
263
- fPassphrase: 'Кодовая фраза ключа (если есть)',
264
- fPassword: 'Пароль учётной записи',
265
- fRemotePath: 'Удалённая папка проекта',
266
- fRemotePathHint: 'Абсолютный путь на сервере (например, /home/user/project)',
267
- fLocalMirror: 'Локальная папка зеркала',
268
- fLocalMirrorHint: 'Локальная папка для быстрого зеркалирования и бесконфликтной 3-way синхронизации',
269
- btnBrowse: '📁 Обзор на сервере…',
270
- btnSelectThis: 'Выбрать папку',
271
- btnTest: '⚡ Проверить связь (Ping)',
272
- btnSave: 'Сохранить профиль',
273
- btnCancel: 'Отмена',
274
- testing: 'Проверка соединения…',
275
- saving: 'Сохранение…',
276
- testOk: '✅ Соединение успешно! Задержка: {latency} мс | ОС: {os}',
277
- testFail: '❌ Ошибка подключения: {err}',
278
- diagTitle: '📊 Диагностика активного подключения',
279
- diagDesc: 'Телеметрия в реальном времени и состояние подсистемы для выбранного сервера.',
280
- diagProbeBtn: '⚡ Опросить сервер',
281
- syncTitle: '🔄 Двусторонняя синхронизация зеркала',
282
- syncDesc: 'Бесконфликтная 3-way синхронизация файлов между локальным зеркалом и сервером.',
283
- pullBtn: '⬇️ Скачать с сервера (Pull)',
284
- pushBtn: '⬆️ Загрузить на сервер (Push)',
285
- pulling: 'Скачивание файлов…',
286
- pushing: 'Загрузка файлов…',
287
- syncOk: 'Синхронизация завершена! Обновлено файлов: {count}.',
288
- syncConflict: 'Внимание: конфликт изменений в {count} файлах.',
289
- syncErr: 'Ошибка синхронизации: {err}',
290
- tunnelsTitle: '🔀 SSH-туннели (Port Forwarding)',
291
- tunnelsDesc: 'Проброс удалённых портов (базы данных, dev-серверы, API) на локальный компьютер через зашифрованный канал.',
292
- tLocalPort: 'Локальный порт',
293
- tRemotePort: 'Удалённый порт',
294
- tOpenBtn: '+ Открыть туннель',
295
- tOpening: 'Открытие…',
296
- tStopBtn: 'Закрыть',
297
- tNoTunnels: 'Нет активных туннелей проброса портов.',
298
- tunnelsColId: 'ID туннеля',
299
- tunnelsColRoute: 'Маршрут перенаправления',
300
- tunnelsColActions: 'Действия',
301
- tOpenOk: 'Туннель запущен: 127.0.0.1:{localPort} -> Remote:{remotePort}',
302
- tOpenErr: 'Не удалось запустить туннель: {err}'
303
- }
304
-
305
- function makeT(dict, fallback) {
306
- return function t(key, vars) {
307
- let val = (dict && dict[key]) || (fallback && fallback[key]) || key
308
- if (vars && typeof val === 'string') {
309
- for (const k of Object.keys(vars)) {
310
- val = val.replace(new RegExp('\\{' + k + '\\}', 'g'), String(vars[k]))
311
- }
312
- }
313
- return val
314
- }
315
- }
316
-
317
- function FallbackChevron() {
318
- return React.createElement(
319
- 'svg',
320
- { width: 14, height: 14, viewBox: '0 0 14 14', fill: 'none', 'aria-hidden': true },
321
- React.createElement('path', {
322
- d: 'M3.5 5.25L7 8.75L10.5 5.25',
323
- stroke: 'currentColor',
324
- strokeWidth: 1.5,
325
- strokeLinecap: 'round',
326
- strokeLinejoin: 'round',
327
- })
328
- )
329
- }
330
-
331
-
332
-
333
- // --- Sub-component: Docker Containers Tab ---
334
- function ContainersTab(props) {
335
- const { activeProfile, t } = props
336
- const [containers, setContainers] = React.useState([])
337
- const [loading, setLoading] = React.useState(false)
338
- const [logsModal, setLogsModal] = React.useState(null)
339
- const [logsContent, setLogsContent] = React.useState('')
340
- const [logsLoading, setLogsLoading] = React.useState(false)
341
-
342
- const loadContainers = async () => {
343
- if (!activeProfile) return
344
- setLoading(true)
345
- try {
346
- const res = await fetch(`/dsh-remote-workspace/docker/list?profileId=${activeProfile.id}`)
347
- const data = await res.json()
348
- if (data.ok && Array.isArray(data.containers)) {
349
- setContainers(data.containers)
350
- } else {
351
- setContainers([])
352
- }
353
- } catch (_) {}
354
- setLoading(false)
355
- }
356
-
357
- React.useEffect(() => {
358
- loadContainers()
359
- }, [activeProfile?.id])
360
-
361
- const handleAction = async (containerId, action) => {
362
- try {
363
- await fetch('/dsh-remote-workspace/docker/action', {
364
- method: 'POST',
365
- headers: { 'Content-Type': 'application/json' },
366
- body: JSON.stringify({ profileId: activeProfile.id, containerId, action })
367
- })
368
- await loadContainers()
369
- } catch (_) {}
370
- }
371
-
372
- const showLogs = async (containerId, name) => {
373
- setLogsModal({ id: containerId, name })
374
- setLogsLoading(true)
375
- try {
376
- const res = await fetch('/dsh-remote-workspace/docker/logs', {
377
- method: 'POST',
378
- headers: { 'Content-Type': 'application/json' },
379
- body: JSON.stringify({ profileId: activeProfile.id, containerId, tail: 150 })
380
- })
381
- const data = await res.json()
382
- setLogsContent(data.logs || '[No logs output]')
383
- } catch (err) {
384
- setLogsContent(`[Error: ${err.message}]`)
385
- }
386
- setLogsLoading(false)
387
- }
388
-
389
- return React.createElement(
390
- 'div',
391
- { style: { display: 'flex', flexDirection: 'column', gap: '12px' } },
392
- React.createElement(
393
- 'div',
394
- { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } },
395
- React.createElement('div', { style: { fontWeight: 600, fontSize: '14px' } }, t('containersTitle')),
396
- React.createElement(
397
- 'button',
398
- {
399
- type: 'button',
400
- className: 'drw-btn',
401
- onClick: loadContainers,
402
- disabled: loading
403
- },
404
- loading ? 'Refreshing...' : '🔄 Refresh'
405
- )
406
- ),
407
- React.createElement(
408
- 'div',
409
- { style: { border: '1px solid var(--dsw-alias-border-l2)', borderRadius: '8px', overflow: 'hidden', background: 'var(--dsw-alias-bg-layer-2)' } },
410
- React.createElement(
411
- 'div',
412
- { className: 'drw-container-row', style: { fontWeight: 600, color: 'var(--dsw-alias-label-secondary)', background: 'var(--dsw-alias-bg-layer-1)' } },
413
- React.createElement('span', null, t('containerName')),
414
- React.createElement('span', null, t('containerImage')),
415
- React.createElement('span', null, t('containerStatus')),
416
- React.createElement('span', null, t('containerPorts')),
417
- React.createElement('span', { style: { textAlign: 'right' } }, t('actionsCol'))
418
- ),
419
- containers.length === 0
420
- ? React.createElement('div', { style: { padding: '24px', textAlign: 'center', color: 'var(--dsw-alias-label-secondary)' } }, t('noContainers'))
421
- : containers.map((c) =>
422
- React.createElement(
423
- 'div',
424
- { key: c.id, className: 'drw-container-row' },
425
- React.createElement(
426
- 'div',
427
- { style: { display: 'flex', alignItems: 'center', gap: '6px' } },
428
- React.createElement('span', { className: `drw-badge ${c.state === 'running' ? 'drw-badge-ok' : 'drw-badge-warn'}` }, c.state),
429
- React.createElement('span', { style: { fontWeight: 600 } }, c.names)
430
- ),
431
- React.createElement('span', { style: { opacity: 0.8, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, c.image),
432
- React.createElement('span', { style: { fontSize: '11px', opacity: 0.7 } }, c.status),
433
- React.createElement('span', { style: { fontSize: '11px', opacity: 0.7, overflow: 'hidden', textOverflow: 'ellipsis' } }, c.ports || '—'),
434
- React.createElement(
435
- 'div',
436
- { style: { display: 'flex', gap: '4px', justifyContent: 'flex-end' } },
437
- React.createElement(
438
- 'button',
439
- { type: 'button', className: 'drw-btn', style: { padding: '2px 6px', fontSize: '11px' }, onClick: () => showLogs(c.id, c.names) },
440
- t('btnLogs')
441
- ),
442
- React.createElement(
443
- 'button',
444
- { type: 'button', className: 'drw-btn', style: { padding: '2px 6px', fontSize: '11px' }, onClick: () => handleAction(c.id, 'restart') },
445
- t('btnRestart')
446
- ),
447
- c.state === 'running'
448
- ? React.createElement(
449
- 'button',
450
- { type: 'button', className: 'drw-btn drw-btn-danger', style: { padding: '2px 6px', fontSize: '11px' }, onClick: () => handleAction(c.id, 'stop') },
451
- t('btnStop')
452
- )
453
- : null
454
- )
455
- )
456
- )
457
- ),
458
- // Container Logs Modal
459
- logsModal
460
- ? React.createElement(
461
- 'div',
462
- { className: 'drw-modal-overlay', onClick: () => setLogsModal(null) },
463
- React.createElement(
464
- 'div',
465
- { className: 'drw-modal-dialog', onClick: (e) => e.stopPropagation() },
466
- React.createElement(
467
- 'div',
468
- { className: 'drw-modal-hdr' },
469
- React.createElement('span', { style: { fontFamily: 'monospace' } }, `Docker Logs: ${logsModal.name} (${logsModal.id})`),
470
- React.createElement('button', { type: 'button', className: 'drw-btn', onClick: () => setLogsModal(null) }, '✕')
471
- ),
472
- React.createElement(
473
- 'div',
474
- { className: 'drw-modal-body' },
475
- React.createElement('pre', { style: { background: '#0d1117', color: '#c9d1d9', padding: '12px', borderRadius: '8px', fontSize: '12px', maxHeight: '420px', overflowY: 'auto', whiteSpace: 'pre-wrap' } }, logsLoading ? 'Fetching logs...' : logsContent)
476
- )
477
- )
478
- )
479
- : null
480
- )
481
- }
482
-
483
- // --- Sub-component: Web Terminal Tab ---
484
- function TerminalTab(props) {
485
- const { activeProfile, t } = props
486
- const [connected, setConnected] = React.useState(false)
487
- const [sessionId, setSessionId] = React.useState(null)
488
- const [output, setOutput] = React.useState('')
489
- const [cmdInput, setCmdInput] = React.useState('')
490
- const [loading, setLoading] = React.useState(false)
491
- const termEndRef = React.useRef(null)
492
- const evtSourceRef = React.useRef(null)
493
-
494
- React.useEffect(() => {
495
- if (termEndRef.current) {
496
- termEndRef.current.scrollIntoView({ behavior: 'smooth' })
497
- }
498
- }, [output])
499
-
500
- React.useEffect(() => {
501
- return () => {
502
- if (evtSourceRef.current) {
503
- evtSourceRef.current.close()
504
- }
505
- }
506
- }, [])
507
-
508
- const handleConnect = async () => {
509
- if (!activeProfile) return
510
- setLoading(true)
511
- try {
512
- const res = await fetch('/dsh-remote-workspace/terminal/create', {
513
- method: 'POST',
514
- headers: { 'Content-Type': 'application/json' },
515
- body: JSON.stringify({ profileId: activeProfile.id, cols: 80, rows: 24 })
516
- })
517
- const data = await res.json()
518
- if (data.ok && data.sessionId) {
519
- setSessionId(data.sessionId)
520
- setConnected(true)
521
- setOutput((prev) => prev + `\n[+] ` + t('termConnected', { id: data.sessionId, host: activeProfile.host }) + `\n`)
522
-
523
- // Connect SSE stream
524
- const es = new EventSource(`/dsh-remote-workspace/terminal/stream?sessionId=${data.sessionId}`)
525
- evtSourceRef.current = es
526
- es.onmessage = (e) => {
527
- try {
528
- const parsed = JSON.parse(e.data)
529
- if (parsed.chunk) {
530
- setOutput((p) => p + parsed.chunk)
531
- }
532
- } catch (_) {}
533
- }
534
- es.onerror = () => {
535
- setOutput((p) => p + `\n[-] ` + t('termDisconnected') + `\n`)
536
- setConnected(false)
537
- es.close()
538
- }
539
- }
540
- } catch (err) {
541
- setOutput((p) => p + `\n[!] Connection error: ${err.message}\n`)
542
- }
543
- setLoading(false)
544
- }
545
-
546
- const handleDisconnect = async () => {
547
- if (sessionId) {
548
- try {
549
- await fetch('/dsh-remote-workspace/terminal/close', {
550
- method: 'POST',
551
- headers: { 'Content-Type': 'application/json' },
552
- body: JSON.stringify({ sessionId })
553
- })
554
- } catch (_) {}
555
- }
556
- if (evtSourceRef.current) {
557
- evtSourceRef.current.close()
558
- }
559
- setConnected(false)
560
- setSessionId(null)
561
- setOutput((p) => p + `\n[-] ` + t('termDisconnected') + `\n`)
562
- }
563
-
564
- const sendCommand = async (e) => {
565
- if (e) e.preventDefault()
566
- if (!cmdInput || !sessionId) return
567
- const toSend = cmdInput + '\n'
568
- setCmdInput('')
569
- try {
570
- await fetch('/dsh-remote-workspace/terminal/input', {
571
- method: 'POST',
572
- headers: { 'Content-Type': 'application/json' },
573
- body: JSON.stringify({ sessionId, data: toSend })
574
- })
575
- } catch (_) {}
576
- }
577
-
578
- const sendCtrlC = async () => {
579
- if (!sessionId) return
580
- try {
581
- await fetch('/dsh-remote-workspace/terminal/input', {
582
- method: 'POST',
583
- headers: { 'Content-Type': 'application/json' },
584
- body: JSON.stringify({ sessionId, data: '\x03' })
585
- })
586
- } catch (_) {}
587
- }
588
-
589
- return React.createElement(
590
- 'div',
591
- { style: { display: 'flex', flexDirection: 'column', gap: '12px' } },
592
- React.createElement(
593
- 'div',
594
- { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: '8px' } },
595
- React.createElement(
596
- 'div',
597
- { style: { display: 'flex', alignItems: 'center', gap: '8px' } },
598
- React.createElement('span', { style: { fontWeight: 600, fontSize: '14px' } }, 'SSH PTY Shell:'),
599
- React.createElement(
600
- 'span',
601
- { className: `drw-badge ${connected ? 'drw-badge-ok' : 'drw-badge-warn'}` },
602
- connected ? `🟢 Online (${activeProfile?.host})` : '⚪ Idle'
603
- )
604
- ),
605
- React.createElement(
606
- 'div',
607
- { style: { display: 'flex', gap: '8px' } },
608
- !connected
609
- ? React.createElement(
610
- 'button',
611
- {
612
- type: 'button',
613
- className: 'drw-btn drw-btn-primary',
614
- disabled: !activeProfile || loading,
615
- onClick: handleConnect
616
- },
617
- loading ? 'Connecting...' : t('termStart')
618
- )
619
- : React.createElement(
620
- 'button',
621
- {
622
- type: 'button',
623
- className: 'drw-btn drw-btn-danger',
624
- onClick: handleDisconnect
625
- },
626
- t('termStop')
627
- ),
628
- connected
629
- ? React.createElement(
630
- 'button',
631
- {
632
- type: 'button',
633
- className: 'drw-btn',
634
- onClick: sendCtrlC
635
- },
636
- 'Ctrl+C'
637
- )
638
- : null,
639
- React.createElement(
640
- 'button',
641
- {
642
- type: 'button',
643
- className: 'drw-btn',
644
- onClick: () => setOutput('')
645
- },
646
- t('termClear')
647
- )
648
- )
649
- ),
650
- React.createElement(
651
- 'div',
652
- { className: 'drw-term-window' },
653
- React.createElement(
654
- 'div',
655
- { className: 'drw-term-header' },
656
- React.createElement('span', null, `terminal ~ ${activeProfile?.username || 'user'}@${activeProfile?.host || 'remote'}`),
657
- React.createElement('span', null, connected ? `Session: ${sessionId}` : 'Offline')
658
- ),
659
- React.createElement(
660
- 'div',
661
- { className: 'drw-term-body' },
662
- output || (activeProfile ? `[i] Ready to connect to ${activeProfile.username || 'root'}@${activeProfile.host}. Click 'Connect Terminal'.` : `[!] No active host profile selected. Configure and activate a profile first.`),
663
- React.createElement('div', { ref: termEndRef })
664
- ),
665
- connected
666
- ? React.createElement(
667
- 'form',
668
- { className: 'drw-term-footer', onSubmit: sendCommand },
669
- React.createElement('span', { style: { color: '#38bdf8', padding: '4px 6px', fontFamily: 'monospace' } }, '$'),
670
- React.createElement('input', {
671
- className: 'drw-term-input',
672
- type: 'text',
673
- placeholder: t('termPlaceholder'),
674
- value: cmdInput,
675
- onChange: (e) => setCmdInput(e.target.value)
676
- }),
677
- React.createElement(
678
- 'button',
679
- { type: 'submit', className: 'drw-btn', style: { padding: '2px 8px', fontSize: '11px' } },
680
- 'Send ↵'
681
- )
682
- )
683
- : null
684
- )
685
- )
686
- }
687
-
688
- // --- Sub-component: Remote File Explorer Tab ---
689
- function ExplorerTab(props) {
690
- const { activeProfile, t } = props
691
- const [currentPath, setCurrentPath] = React.useState(activeProfile?.remoteWorkspace || '/')
692
- const [entries, setEntries] = React.useState([])
693
- const [loading, setLoading] = React.useState(false)
694
- const [previewFile, setPreviewFile] = React.useState(null)
695
- const [previewContent, setPreviewContent] = React.useState('')
696
- const [editContent, setEditContent] = React.useState('')
697
- const [previewLoading, setPreviewLoading] = React.useState(false)
698
- const [saveStatus, setSaveStatus] = React.useState(null)
699
-
700
- const loadDir = async (dirPath) => {
701
- if (!activeProfile) return
702
- setLoading(true)
703
- try {
704
- const res = await fetch('/dsh-remote-workspace/browse', {
705
- method: 'POST',
706
- headers: { 'Content-Type': 'application/json' },
707
- body: JSON.stringify({ profileId: activeProfile.id, remotePath: dirPath })
708
- })
709
- const data = await res.json()
710
- if (data.ok && Array.isArray(data.entries)) {
711
- setCurrentPath(dirPath)
712
- setEntries(data.entries)
713
- }
714
- } catch (_) {}
715
- setLoading(false)
716
- }
717
-
718
- React.useEffect(() => {
719
- if (activeProfile) {
720
- loadDir(activeProfile.remoteWorkspace || '/')
721
- }
722
- }, [activeProfile?.id])
723
-
724
- const handleNavUp = () => {
725
- const parts = currentPath.split('/').filter(Boolean)
726
- parts.pop()
727
- const parent = '/' + parts.join('/')
728
- loadDir(parent || '/')
729
- }
730
-
731
- const openFile = async (entry) => {
732
- const filePath = currentPath.endsWith('/') ? currentPath + entry.filename : currentPath + '/' + entry.filename
733
- setPreviewLoading(true)
734
- setPreviewFile(filePath)
735
- setSaveStatus(null)
736
- try {
737
- const res = await fetch('/dsh-remote-workspace/file/view', {
738
- method: 'POST',
739
- headers: { 'Content-Type': 'application/json' },
740
- body: JSON.stringify({ profileId: activeProfile.id, filePath })
741
- })
742
- const data = await res.json()
743
- if (data.ok) {
744
- setPreviewContent(data.content)
745
- setEditContent(data.content)
746
- } else {
747
- setPreviewContent(`[Error loading file: ${data.error || 'Failed'}]`)
748
- setEditContent('')
749
- }
750
- } catch (err) {
751
- setPreviewContent(`[Error: ${err.message}]`)
752
- }
753
- setPreviewLoading(false)
754
- }
755
-
756
- const handleSaveFile = async () => {
757
- if (!previewFile || !activeProfile) return
758
- setSaveStatus('saving')
759
- try {
760
- const res = await fetch('/dsh-remote-workspace/file/save', {
761
- method: 'POST',
762
- headers: { 'Content-Type': 'application/json' },
763
- body: JSON.stringify({ profileId: activeProfile.id, filePath: previewFile, content: editContent })
764
- })
765
- const data = await res.json()
766
- if (data.ok) {
767
- setSaveStatus('saved')
768
- setPreviewContent(editContent)
769
- } else {
770
- setSaveStatus('error')
771
- }
772
- } catch (_) {
773
- setSaveStatus('error')
774
- }
775
- }
776
-
777
- return React.createElement(
778
- 'div',
779
- { className: 'drw-explorer-box' },
780
- React.createElement(
781
- 'div',
782
- { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } },
783
- React.createElement('div', { style: { fontWeight: 600, fontSize: '14px' } }, t('explorerTitle')),
784
- React.createElement(
785
- 'button',
786
- {
787
- type: 'button',
788
- className: 'drw-btn',
789
- onClick: () => loadDir(currentPath),
790
- disabled: loading
791
- },
792
- loading ? 'Refreshing...' : '🔄 Refresh'
793
- )
794
- ),
795
- React.createElement(
796
- 'div',
797
- { className: 'drw-explorer-nav' },
798
- React.createElement(
799
- 'button',
800
- {
801
- type: 'button',
802
- className: 'drw-btn',
803
- style: { padding: '2px 8px', fontSize: '11px' },
804
- onClick: handleNavUp,
805
- disabled: currentPath === '/' || loading
806
- },
807
- '⬆️ Up'
808
- ),
809
- React.createElement('span', { style: { color: 'var(--dsw-alias-label-secondary)' } }, 'Path:'),
810
- React.createElement('span', { style: { fontWeight: 600, color: 'var(--dsw-alias-state-brand-primary)' } }, currentPath)
811
- ),
812
- React.createElement(
813
- 'div',
814
- { className: 'drw-file-list' },
815
- entries.length === 0
816
- ? React.createElement('div', { style: { padding: '16px', textAlign: 'center', color: 'var(--dsw-alias-label-secondary)' } }, loading ? 'Reading directory...' : 'Directory is empty.')
817
- : entries.map((e) =>
818
- React.createElement(
819
- 'div',
820
- {
821
- key: e.filename,
822
- className: 'drw-file-row',
823
- onClick: () => (e.isDirectory ? loadDir(currentPath.endsWith('/') ? currentPath + e.filename : currentPath + '/' + e.filename) : openFile(e))
824
- },
825
- React.createElement(
826
- 'div',
827
- { style: { display: 'flex', alignItems: 'center', gap: '8px' } },
828
- React.createElement('span', null, e.isDirectory ? '📁' : '📄'),
829
- React.createElement('span', { style: { fontWeight: e.isDirectory ? 600 : 400 } }, e.filename)
830
- ),
831
- React.createElement(
832
- 'div',
833
- { className: 'drw-file-meta' },
834
- e.size !== undefined ? React.createElement('span', null, `${Math.round(e.size / 1024)} KB`) : null,
835
- e.permissions ? React.createElement('span', { style: { opacity: 0.6 } }, e.permissions) : null
836
- )
837
- )
838
- )
839
- ),
840
- // File Preview / Edit Modal
841
- previewFile
842
- ? React.createElement(
843
- 'div',
844
- { className: 'drw-modal-overlay', onClick: () => setPreviewFile(null) },
845
- React.createElement(
846
- 'div',
847
- { className: 'drw-modal-dialog', onClick: (e) => e.stopPropagation() },
848
- React.createElement(
849
- 'div',
850
- { className: 'drw-modal-hdr' },
851
- React.createElement('span', { style: { fontFamily: 'monospace' } }, t('filePreviewTitle', { path: previewFile })),
852
- React.createElement(
853
- 'button',
854
- {
855
- type: 'button',
856
- className: 'drw-btn',
857
- style: { padding: '2px 8px' },
858
- onClick: () => setPreviewFile(null)
859
- },
860
- '✕'
861
- )
862
- ),
863
- React.createElement(
864
- 'div',
865
- { className: 'drw-modal-body', style: { display: 'flex', flexDirection: 'column', gap: '10px' } },
866
- previewLoading
867
- ? React.createElement('div', { style: { padding: '20px', textAlign: 'center' } }, 'Loading content...')
868
- : React.createElement('textarea', {
869
- style: {
870
- width: '100%',
871
- height: '320px',
872
- background: '#0d1117',
873
- color: '#c9d1d9',
874
- fontFamily: 'monospace',
875
- fontSize: '12px',
876
- padding: '10px',
877
- border: '1px solid #30363d',
878
- borderRadius: '8px',
879
- resize: 'vertical',
880
- boxSizing: 'border-box'
881
- },
882
- value: editContent,
883
- onChange: (e) => setEditContent(e.target.value)
884
- }),
885
- React.createElement(
886
- 'div',
887
- { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } },
888
- React.createElement(
889
- 'span',
890
- { style: { fontSize: '12px', color: saveStatus === 'saved' ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-label-secondary)' } },
891
- saveStatus === 'saved' ? t('fileSaved') : saveStatus === 'error' ? 'Error saving file.' : ''
892
- ),
893
- React.createElement(
894
- 'div',
895
- { style: { display: 'flex', gap: '8px' } },
896
- React.createElement(
897
- 'button',
898
- {
899
- type: 'button',
900
- className: 'drw-btn',
901
- onClick: () => setPreviewFile(null)
902
- },
903
- 'Close'
904
- ),
905
- React.createElement(
906
- 'button',
907
- {
908
- type: 'button',
909
- className: 'drw-btn drw-btn-primary',
910
- onClick: handleSaveFile,
911
- disabled: saveStatus === 'saving'
912
- },
913
- saveStatus === 'saving' ? 'Saving...' : t('btnSaveFile')
914
- )
915
- )
916
- )
917
- )
918
- )
919
- )
920
- : null
921
- )
922
- }
923
-
924
- function SettingsView(props) {
925
- const [activeTab, setActiveTab] = React.useState('profiles')
926
- const [healthData, setHealthData] = React.useState(null)
927
- const [autoSync, setAutoSync] = React.useState(false)
928
-
929
- const t = props.locale === 'ru' ? makeT(ru, en) : makeT(en, ru)
930
- const [profiles, setProfiles] = React.useState([])
931
- const [activeId, setActiveId] = React.useState(null)
932
- const [tunnels, setTunnels] = React.useState([])
933
- const [editing, setEditing] = React.useState(null)
934
- const [busy, setBusy] = React.useState(null)
935
- const [testResult, setTestResult] = React.useState(null)
936
- const [syncMsg, setSyncMsg] = React.useState(null)
937
- const [tunnelMsg, setTunnelMsg] = React.useState(null)
938
- const [showPassword, setShowPassword] = React.useState(false)
939
-
940
- // Tunnel creation inputs
941
- const [newTunnelLocal, setNewTunnelLocal] = React.useState('3000')
942
- const [newTunnelRemote, setNewTunnelRemote] = React.useState('3000')
943
-
944
- // Remote Directory Browser State
945
- const [browserOpen, setBrowserOpen] = React.useState(false)
946
- const [browserPath, setBrowserPath] = React.useState('/')
947
- const [browserEntries, setBrowserEntries] = React.useState([])
948
- const [browserLoading, setBrowserLoading] = React.useState(false)
949
-
950
- const loadState = async () => {
951
- try {
952
- const res = await fetch('/dsh-remote-workspace/state')
953
- if (res.ok) {
954
- const data = await res.json()
955
- if (data.ok) {
956
- setProfiles(data.profiles || [])
957
- setActiveId(data.activeId || null)
958
- setTunnels(data.tunnels || [])
959
- setAutoSync(Boolean(data.autoSync))
960
- if (data.activeId) {
961
- fetch(`/dsh-remote-workspace/health?profileId=${data.activeId}`).then(r => r.json()).then(h => { if (h.ok) setHealthData(h.health) }).catch(() => {})
962
- }
963
- }
964
- }
965
- } catch (_) {}
966
- }
967
-
968
- React.useEffect(() => {
969
- ensureCss()
970
- loadState()
971
- }, [])
972
-
973
- const handleSave = async (profile) => {
974
- setBusy('saving')
975
- try {
976
- const res = await fetch('/dsh-remote-workspace/profiles/save', {
977
- method: 'POST',
978
- headers: { 'Content-Type': 'application/json' },
979
- body: JSON.stringify(profile)
980
- })
981
- if (res.ok) {
982
- setEditing(null)
983
- setBrowserOpen(false)
984
- setTestResult(null)
985
- await loadState()
986
- }
987
- } catch (_) {}
988
- setBusy(null)
989
- }
990
-
991
- const handleDelete = async (id, name) => {
992
- if (!confirm(t('delConfirm', { name: name || id }))) return
993
- try {
994
- const res = await fetch('/dsh-remote-workspace/profiles/delete', {
995
- method: 'POST',
996
- headers: { 'Content-Type': 'application/json' },
997
- body: JSON.stringify({ id })
998
- })
999
- if (res.ok) {
1000
- if (editing && editing.id === id) setEditing(null)
1001
- await loadState()
1002
- }
1003
- } catch (_) {}
1004
- }
1005
-
1006
- const handleSetActive = async (id) => {
1007
- try {
1008
- const res = await fetch('/dsh-remote-workspace/profiles/active', {
1009
- method: 'POST',
1010
- headers: { 'Content-Type': 'application/json' },
1011
- body: JSON.stringify({ id })
1012
- })
1013
- if (res.ok) {
1014
- await loadState()
1015
- }
1016
- } catch (_) {}
1017
- }
1018
-
1019
- const handleTest = async (prof) => {
1020
- setBusy('testing')
1021
- setTestResult(null)
1022
- try {
1023
- const res = await fetch('/dsh-remote-workspace/test', {
1024
- method: 'POST',
1025
- headers: { 'Content-Type': 'application/json' },
1026
- body: JSON.stringify({ profile: prof })
1027
- })
1028
- const data = await res.json()
1029
- setTestResult(data)
1030
- } catch (err) {
1031
- setTestResult({ ok: false, error: err.message })
1032
- }
1033
- setBusy(null)
1034
- }
1035
-
1036
- const openDirectoryBrowser = async (initialPath) => {
1037
- setBrowserOpen(true)
1038
- const target = initialPath && initialPath.startsWith('/') ? initialPath : '/'
1039
- await fetchRemoteDir(target)
1040
- }
1041
-
1042
- const fetchRemoteDir = async (dirPath) => {
1043
- setBrowserLoading(true)
1044
- try {
1045
- const res = await fetch('/dsh-remote-workspace/browse', {
1046
- method: 'POST',
1047
- headers: { 'Content-Type': 'application/json' },
1048
- body: JSON.stringify({ profile: editing, remotePath: dirPath })
1049
- })
1050
- const data = await res.json()
1051
- if (data.ok) {
1052
- setBrowserPath(data.currentPath || dirPath)
1053
- setBrowserEntries(data.entries || [])
1054
- }
1055
- } catch (_) {}
1056
- setBrowserLoading(false)
1057
- }
1058
-
1059
- const handleSync = async (direction) => {
1060
- setBusy(`sync_${direction}`)
1061
- setSyncMsg(null)
1062
- try {
1063
- const res = await fetch('/dsh-remote-workspace/sync', {
1064
- method: 'POST',
1065
- headers: { 'Content-Type': 'application/json' },
1066
- body: JSON.stringify({ direction })
1067
- })
1068
- const data = await res.json()
1069
- if (data.ok) {
1070
- const count = (direction === 'push' ? data.pushed?.length : data.pulled?.length) || 0
1071
- if (data.conflicts && data.conflicts.length > 0) {
1072
- setSyncMsg({ ok: false, text: t('syncConflict', { count: data.conflicts.length }) })
1073
- } else {
1074
- setSyncMsg({ ok: true, text: t('syncOk', { count }) })
1075
- }
1076
- } else {
1077
- setSyncMsg({ ok: false, text: t('syncErr', { err: data.error || 'Unknown error' }) })
1078
- }
1079
- } catch (err) {
1080
- setSyncMsg({ ok: false, text: t('syncErr', { err: err.message }) })
1081
- }
1082
- setBusy(null)
1083
- }
1084
-
1085
- const handleStartTunnel = async () => {
1086
- if (!activeId) return
1087
- setBusy('tunnel_open')
1088
- setTunnelMsg(null)
1089
- try {
1090
- const res = await fetch('/dsh-remote-workspace/tunnels/start', {
1091
- method: 'POST',
1092
- headers: { 'Content-Type': 'application/json' },
1093
- body: JSON.stringify({
1094
- profileId: activeId,
1095
- localPort: newTunnelLocal,
1096
- remotePort: newTunnelRemote
1097
- })
1098
- })
1099
- const data = await res.json()
1100
- if (data.ok) {
1101
- setTunnelMsg({ ok: true, text: t('tOpenOk', { localPort: newTunnelLocal, remotePort: newTunnelRemote }) })
1102
- await loadState()
1103
- } else {
1104
- setTunnelMsg({ ok: false, text: t('tOpenErr', { err: data.error || 'Failed' }) })
1105
- }
1106
- } catch (err) {
1107
- setTunnelMsg({ ok: false, text: t('tOpenErr', { err: err.message }) })
1108
- }
1109
- setBusy(null)
1110
- }
1111
-
1112
- const handleStopTunnel = async (tunnelId) => {
1113
- try {
1114
- const res = await fetch('/dsh-remote-workspace/tunnels/stop', {
1115
- method: 'POST',
1116
- headers: { 'Content-Type': 'application/json' },
1117
- body: JSON.stringify({ tunnelId })
1118
- })
1119
- if (res.ok) {
1120
- await loadState()
1121
- }
1122
- } catch (_) {}
1123
- }
1124
-
1125
- const activeProfile = profiles.find((p) => p.id === activeId)
1126
-
1127
- return React.createElement(
1128
- 'div',
1129
- { className: 'drw-page' },
1130
-
1131
- // Header with Live Badges (ClineBot Style)
1132
- React.createElement(
1133
- 'div',
1134
- { className: 'drw-header' },
1135
- React.createElement(
1136
- 'div',
1137
- { className: 'drw-header-top' },
1138
- React.createElement('div', { className: 'drw-page-title' }, '🌐 ' + t('title')),
1139
- React.createElement(
1140
- 'div',
1141
- { className: 'drw-header-badges' },
1142
- activeProfile
1143
- ? React.createElement('span', { className: 'drw-badge drw-badge-ok' }, t('badgeOnline', { name: activeProfile.name || activeProfile.host, latency: testResult?.latencyMs ?? 15 }))
1144
- : React.createElement('span', { className: 'drw-badge drw-badge-warn' }, t('badgeOffline')),
1145
- activeProfile
1146
- ? React.createElement('span', { className: 'drw-badge' }, activeProfile.authType === 'password' ? t('badgePassword') : t('badgeKey'))
1147
- : null,
1148
- React.createElement('span', { className: `drw-badge ${tunnels.length > 0 ? 'drw-badge-ok' : ''}` }, t('badgeTunnels', { count: tunnels.length }))
1149
- )
1150
- ),
1151
- React.createElement('div', { className: 'drw-page-sub' }, t('subtitle'))
1152
- ),
1153
-
1154
- // Section 1: SSH Profiles Table & Management
1155
- React.createElement(
1156
- 'div',
1157
- { className: 'drw-card' },
1158
- React.createElement(
1159
- 'div',
1160
- { className: 'drw-card-title' },
1161
- React.createElement('span', null, t('profilesTitle')),
1162
- !editing
1163
- ? React.createElement(
1164
- 'button',
1165
- {
1166
- type: 'button',
1167
- className: 'drw-btn drw-btn-primary',
1168
- onClick: () => {
1169
- setEditing({
1170
- id: 'prof_' + Math.random().toString(36).substr(2, 9),
1171
- name: 'New Server',
1172
- host: '',
1173
- port: 22,
1174
- username: 'root',
1175
- authType: 'key',
1176
- privateKeyPath: '~/.ssh/id_rsa',
1177
- passphrase: '',
1178
- password: '',
1179
- remoteWorkspace: '',
1180
- localMirrorPath: ''
1181
- })
1182
- setTestResult(null)
1183
- }
1184
- },
1185
- t('addBtn')
1186
- )
1187
- : null
1188
- ),
1189
- React.createElement('div', { className: 'drw-card-desc' }, t('profilesDesc')),
1190
-
1191
- // Interactive Editing Form
1192
- editing
1193
- ? React.createElement(
1194
- 'div',
1195
- {
1196
- style: {
1197
- padding: '16px',
1198
- borderRadius: '10px',
1199
- background: 'var(--dsw-alias-bg-layer-2)',
1200
- border: '1px solid var(--dsw-alias-border-l2)',
1201
- display: 'flex',
1202
- flexDirection: 'column',
1203
- gap: '14px'
1204
- }
1205
- },
1206
- React.createElement(
1207
- 'div',
1208
- { style: { fontWeight: 600, fontSize: '14px', color: 'var(--dsw-alias-label-primary)' } },
1209
- editing.name ? t('formTitleEdit') : t('formTitleNew')
1210
- ),
1211
- React.createElement(
1212
- 'div',
1213
- { className: 'drw-grid-2' },
1214
- React.createElement(
1215
- 'div',
1216
- { className: 'drw-field' },
1217
- React.createElement('span', { className: 'drw-label' }, t('fName')),
1218
- React.createElement('input', {
1219
- className: 'drw-input',
1220
- value: editing.name || '',
1221
- onChange: (e) => setEditing({ ...editing, name: e.target.value })
1222
- })
1223
- ),
1224
- React.createElement(
1225
- 'div',
1226
- { className: 'drw-field' },
1227
- React.createElement('span', { className: 'drw-label' }, t('fHost')),
1228
- React.createElement('input', {
1229
- className: 'drw-input',
1230
- placeholder: '192.168.1.100 or server.domain.com',
1231
- value: editing.host || '',
1232
- onChange: (e) => setEditing({ ...editing, host: e.target.value })
1233
- })
1234
- ),
1235
- React.createElement(
1236
- 'div',
1237
- { className: 'drw-field' },
1238
- React.createElement('span', { className: 'drw-label' }, t('fPort')),
1239
- React.createElement('input', {
1240
- className: 'drw-input',
1241
- type: 'number',
1242
- value: editing.port || 22,
1243
- onChange: (e) => setEditing({ ...editing, port: parseInt(e.target.value, 10) || 22 })
1244
- })
1245
- ),
1246
- React.createElement(
1247
- 'div',
1248
- { className: 'drw-field' },
1249
- React.createElement('span', { className: 'drw-label' }, t('fUser')),
1250
- React.createElement('input', {
1251
- className: 'drw-input',
1252
- value: editing.username || '',
1253
- onChange: (e) => setEditing({ ...editing, username: e.target.value })
1254
- })
1255
- )
1256
- ),
1257
-
1258
- // Auth Method Segmented Switcher (Key vs Password)
1259
- React.createElement(
1260
- 'div',
1261
- { style: { display: 'flex', flexDirection: 'column', gap: '8px' } },
1262
- React.createElement('span', { className: 'drw-label' }, t('fAuthType')),
1263
- React.createElement(
1264
- 'div',
1265
- { className: 'drw-segmented' },
1266
- React.createElement(
1267
- 'button',
1268
- {
1269
- type: 'button',
1270
- className: `drw-segmented-item ${editing.authType !== 'password' ? 'drw-segmented-item-active' : ''}`,
1271
- onClick: () => setEditing({ ...editing, authType: 'key' })
1272
- },
1273
- '🔑 ' + t('fAuthKey')
1274
- ),
1275
- React.createElement(
1276
- 'button',
1277
- {
1278
- type: 'button',
1279
- className: `drw-segmented-item ${editing.authType === 'password' ? 'drw-segmented-item-active' : ''}`,
1280
- onClick: () => setEditing({ ...editing, authType: 'password' })
1281
- },
1282
- '🔒 ' + t('fAuthPass')
1283
- )
1284
- )
1285
- ),
1286
-
1287
- // Conditional Auth Inputs
1288
- editing.authType === 'password'
1289
- ? React.createElement(
1290
- 'div',
1291
- { className: 'drw-field' },
1292
- React.createElement('span', { className: 'drw-label' }, t('fPassword')),
1293
- React.createElement(
1294
- 'div',
1295
- { style: { display: 'flex', gap: '8px' } },
1296
- React.createElement('input', {
1297
- className: 'drw-input',
1298
- type: showPassword ? 'text' : 'password',
1299
- placeholder: '••••••••••••',
1300
- value: editing.password || '',
1301
- onChange: (e) => setEditing({ ...editing, password: e.target.value })
1302
- }),
1303
- React.createElement(
1304
- 'button',
1305
- {
1306
- type: 'button',
1307
- className: 'drw-btn',
1308
- style: { fontSize: '11px', whiteSpace: 'nowrap' },
1309
- onClick: () => setShowPassword((v) => !v)
1310
- },
1311
- showPassword ? 'Hide' : 'Show'
1312
- )
1313
- )
1314
- )
1315
- : React.createElement(
1316
- 'div',
1317
- { className: 'drw-grid-2' },
1318
- React.createElement(
1319
- 'div',
1320
- { className: 'drw-field' },
1321
- React.createElement('span', { className: 'drw-label' }, t('fKeyPath')),
1322
- React.createElement('input', {
1323
- className: 'drw-input',
1324
- placeholder: '~/.ssh/id_rsa or /home/user/.ssh/id_ed25519',
1325
- value: editing.privateKeyPath || '',
1326
- onChange: (e) => setEditing({ ...editing, privateKeyPath: e.target.value })
1327
- }),
1328
- React.createElement('span', { className: 'drw-hint' }, t('fKeyPathHint'))
1329
- ),
1330
- React.createElement(
1331
- 'div',
1332
- { className: 'drw-field' },
1333
- React.createElement('span', { className: 'drw-label' }, t('fPassphrase')),
1334
- React.createElement('input', {
1335
- className: 'drw-input',
1336
- type: 'password',
1337
- placeholder: 'Optional passphrase',
1338
- value: editing.passphrase || '',
1339
- onChange: (e) => setEditing({ ...editing, passphrase: e.target.value })
1340
- })
1341
- )
1342
- ),
1343
-
1344
- // Workspace Paths (Remote Workspace & Local Mirror)
1345
- React.createElement(
1346
- 'div',
1347
- { className: 'drw-grid-2' },
1348
- React.createElement(
1349
- 'div',
1350
- { className: 'drw-field' },
1351
- React.createElement('span', { className: 'drw-label' }, t('fRemotePath')),
1352
- React.createElement(
1353
- 'div',
1354
- { style: { display: 'flex', gap: '8px' } },
1355
- React.createElement('input', {
1356
- className: 'drw-input',
1357
- placeholder: '/home/user/project',
1358
- value: editing.remoteWorkspace || '',
1359
- onChange: (e) => setEditing({ ...editing, remoteWorkspace: e.target.value })
1360
- }),
1361
- React.createElement(
1362
- 'button',
1363
- {
1364
- type: 'button',
1365
- className: 'drw-btn',
1366
- style: { whiteSpace: 'nowrap', fontSize: '12px' },
1367
- disabled: !editing.host,
1368
- onClick: () => openDirectoryBrowser(editing.remoteWorkspace || '/')
1369
- },
1370
- t('btnBrowse')
1371
- )
1372
- ),
1373
- React.createElement('span', { className: 'drw-hint' }, t('fRemotePathHint'))
1374
- ),
1375
- React.createElement(
1376
- 'div',
1377
- { className: 'drw-field' },
1378
- React.createElement('span', { className: 'drw-label' }, t('fLocalMirror')),
1379
- React.createElement('input', {
1380
- className: 'drw-input',
1381
- placeholder: '~/.dsh/mirrors/my-project',
1382
- value: editing.localMirrorPath || '',
1383
- onChange: (e) => setEditing({ ...editing, localMirrorPath: e.target.value })
1384
- }),
1385
- React.createElement('span', { className: 'drw-hint' }, t('fLocalMirrorHint'))
1386
- )
1387
- ),
1388
-
1389
- // Directory Browser Modal
1390
- browserOpen
1391
- ? React.createElement(
1392
- 'div',
1393
- { className: 'drw-browser-modal' },
1394
- React.createElement(
1395
- 'div',
1396
- { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } },
1397
- React.createElement('span', { style: { fontSize: '12px', fontWeight: 600, color: 'var(--dsw-alias-label-primary)' } }, `📂 ${browserPath}`),
1398
- React.createElement(
1399
- 'div',
1400
- { style: { display: 'flex', gap: '6px' } },
1401
- React.createElement(
1402
- 'button',
1403
- {
1404
- type: 'button',
1405
- className: 'drw-btn drw-btn-primary',
1406
- style: { fontSize: '11px', padding: '3px 8px' },
1407
- onClick: () => {
1408
- setEditing({ ...editing, remoteWorkspace: browserPath })
1409
- setBrowserOpen(false)
1410
- }
1411
- },
1412
- t('btnSelectThis')
1413
- ),
1414
- React.createElement(
1415
- 'button',
1416
- {
1417
- type: 'button',
1418
- className: 'drw-btn',
1419
- style: { fontSize: '11px', padding: '3px 8px' },
1420
- onClick: () => setBrowserOpen(false)
1421
- },
1422
- '✕'
1423
- )
1424
- )
1425
- ),
1426
- React.createElement(
1427
- 'div',
1428
- { className: 'drw-browser-list' },
1429
- browserLoading
1430
- ? React.createElement('div', { style: { padding: '8px', fontSize: '12px', color: 'var(--dsw-alias-label-secondary)' } }, 'Loading directory entries...')
1431
- : React.createElement(
1432
- React.Fragment,
1433
- null,
1434
- browserPath !== '/'
1435
- ? React.createElement(
1436
- 'div',
1437
- {
1438
- className: 'drw-browser-item',
1439
- onClick: () => {
1440
- const parent = browserPath.substring(0, browserPath.lastIndexOf('/')) || '/'
1441
- fetchRemoteDir(parent)
1442
- }
1443
- },
1444
- '📁 .. (parent directory)'
1445
- )
1446
- : null,
1447
- browserEntries
1448
- .filter((e) => e.isDirectory)
1449
- .map((e) =>
1450
- React.createElement(
1451
- 'div',
1452
- {
1453
- key: e.filename,
1454
- className: 'drw-browser-item',
1455
- onClick: () => {
1456
- const next = browserPath === '/' ? `/${e.filename}` : `${browserPath}/${e.filename}`
1457
- fetchRemoteDir(next)
1458
- }
1459
- },
1460
- `📁 ${e.filename}`
1461
- )
1462
- )
1463
- )
1464
- )
1465
- )
1466
- : null,
1467
-
1468
- // Form Action Buttons
1469
- React.createElement(
1470
- 'div',
1471
- { className: 'drw-row', style: { justifyContent: 'flex-end', marginTop: '6px' } },
1472
- React.createElement(
1473
- 'button',
1474
- {
1475
- type: 'button',
1476
- className: 'drw-btn',
1477
- disabled: !editing.host || !!busy,
1478
- onClick: () => handleTest(editing)
1479
- },
1480
- busy === 'testing' ? t('testing') : t('btnTest')
1481
- ),
1482
- React.createElement(
1483
- 'button',
1484
- {
1485
- type: 'button',
1486
- className: 'drw-btn',
1487
- onClick: () => {
1488
- setEditing(null)
1489
- setBrowserOpen(false)
1490
- setTestResult(null)
1491
- }
1492
- },
1493
- t('btnCancel')
1494
- ),
1495
- React.createElement(
1496
- 'button',
1497
- {
1498
- type: 'button',
1499
- className: 'drw-btn drw-btn-primary',
1500
- disabled: !editing.host || !!busy,
1501
- onClick: () => handleSave(editing)
1502
- },
1503
- busy === 'saving' ? t('saving') : t('btnSave')
1504
- )
1505
- ),
1506
- testResult
1507
- ? React.createElement(
1508
- 'div',
1509
- {
1510
- className: 'drw-preview',
1511
- style: {
1512
- borderColor: testResult.ok ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-state-error-primary)'
1513
- }
1514
- },
1515
- testResult.ok
1516
- ? t('testOk', { latency: testResult.latencyMs ?? testResult.latency ?? 0, os: testResult.remoteOs || testResult.os || 'Linux' })
1517
- : t('testFail', { err: testResult.error || 'Connection timed out' })
1518
- )
1519
- : null
1520
- )
1521
- : null,
1522
-
1523
- // Profiles List Table
1524
- profiles.length > 0
1525
- ? React.createElement(
1526
- 'table',
1527
- { className: 'drw-table' },
1528
- React.createElement(
1529
- 'thead',
1530
- null,
1531
- React.createElement(
1532
- 'tr',
1533
- null,
1534
- React.createElement('th', null, t('nameCol')),
1535
- React.createElement('th', null, t('hostCol')),
1536
- React.createElement('th', null, t('portCol')),
1537
- React.createElement('th', null, t('pathCol')),
1538
- React.createElement('th', { style: { textAlign: 'right' } }, t('actionsCol'))
1539
- )
1540
- ),
1541
- React.createElement(
1542
- 'tbody',
1543
- null,
1544
- profiles.map((p) => {
1545
- const isAct = p.id === activeId
1546
- return React.createElement(
1547
- 'tr',
1548
- { key: p.id },
1549
- React.createElement(
1550
- 'td',
1551
- null,
1552
- React.createElement('span', { style: { fontWeight: 600 } }, p.name || 'Server'),
1553
- React.createElement(
1554
- 'span',
1555
- { className: 'drw-badge', style: { marginLeft: '8px' } },
1556
- p.authType === 'password' ? '🔒 pwd' : '🔑 key'
1557
- ),
1558
- isAct
1559
- ? React.createElement('span', { className: 'drw-badge drw-badge-ok', style: { marginLeft: '6px' } }, t('activeBadge'))
1560
- : null
1561
- ),
1562
- React.createElement('td', { style: { fontFamily: 'monospace' } }, `${p.username || 'root'}@${p.host}`),
1563
- React.createElement('td', { style: { fontFamily: 'monospace' } }, p.port || 22),
1564
- React.createElement('td', { style: { fontFamily: 'monospace', fontSize: '12px' } }, p.remoteWorkspace || '—'),
1565
- React.createElement(
1566
- 'td',
1567
- { style: { textAlign: 'right' } },
1568
- React.createElement(
1569
- 'div',
1570
- { style: { display: 'inline-flex', gap: '6px' } },
1571
- !isAct
1572
- ? React.createElement(
1573
- 'button',
1574
- {
1575
- type: 'button',
1576
- className: 'drw-btn',
1577
- style: { fontSize: '11px', padding: '3px 8px' },
1578
- onClick: () => handleSetActive(p.id)
1579
- },
1580
- t('pinBtn')
1581
- )
1582
- : null,
1583
- React.createElement(
1584
- 'button',
1585
- {
1586
- type: 'button',
1587
- className: 'drw-btn',
1588
- style: { fontSize: '11px', padding: '3px 8px' },
1589
- onClick: () => {
1590
- setEditing({ ...p })
1591
- setTestResult(null)
1592
- }
1593
- },
1594
- t('editBtn')
1595
- ),
1596
- React.createElement(
1597
- 'button',
1598
- {
1599
- type: 'button',
1600
- className: 'drw-btn drw-btn-danger',
1601
- style: { fontSize: '11px', padding: '3px 8px' },
1602
- onClick: () => handleDelete(p.id, p.name)
1603
- },
1604
- t('delBtn')
1605
- )
1606
- )
1607
- )
1608
- )
1609
- })
1610
- )
1611
- )
1612
- : !editing
1613
- ? React.createElement('div', { style: { fontSize: '13px', color: 'var(--dsw-alias-label-secondary)' } }, t('noHosts'))
1614
- : null
1615
- ),
1616
-
1617
- // Section 2: Active Connection Diagnostics (ClineBot Card 4 style)
1618
- activeProfile
1619
- ? React.createElement(
1620
- 'div',
1621
- { className: 'drw-card' },
1622
- React.createElement(
1623
- 'div',
1624
- { className: 'drw-card-title' },
1625
- React.createElement('span', null, t('diagTitle')),
1626
- React.createElement(
1627
- 'button',
1628
- {
1629
- type: 'button',
1630
- className: 'drw-btn',
1631
- style: { fontSize: '11px', padding: '3px 9px' },
1632
- disabled: busy === 'testing',
1633
- onClick: () => handleTest(activeProfile)
1634
- },
1635
- busy === 'testing' ? t('testing') : t('diagProbeBtn')
1636
- )
1637
- ),
1638
- React.createElement('div', { className: 'drw-card-desc' }, t('diagDesc')),
1639
- React.createElement(
1640
- 'div',
1641
- { className: 'drw-grid-4' },
1642
- React.createElement(
1643
- 'div',
1644
- { className: 'drw-stat-box' },
1645
- React.createElement('div', { className: 'drw-stat-val' }, activeProfile.name || activeProfile.host),
1646
- React.createElement('div', { className: 'drw-stat-lbl' }, `SSH: ${activeProfile.username}@${activeProfile.host}:${activeProfile.port || 22}`)
1647
- ),
1648
- React.createElement(
1649
- 'div',
1650
- { className: 'drw-stat-box' },
1651
- React.createElement('div', { className: 'drw-stat-val' }, activeProfile.remoteWorkspace || '—'),
1652
- React.createElement('div', { className: 'drw-stat-lbl' }, 'Remote Workspace')
1653
- ),
1654
- React.createElement(
1655
- 'div',
1656
- { className: 'drw-stat-box' },
1657
- React.createElement('div', { className: 'drw-stat-val' }, activeProfile.localMirrorPath || '—'),
1658
- React.createElement('div', { className: 'drw-stat-lbl' }, 'Local Mirror Path')
1659
- ),
1660
- React.createElement(
1661
- 'div',
1662
- { className: 'drw-stat-box' },
1663
- React.createElement('div', { className: 'drw-stat-val', style: { color: 'var(--dsw-alias-state-success-primary)' } }, 'Ready ✓'),
1664
- React.createElement('div', { className: 'drw-stat-lbl' }, activeProfile.authType === 'password' ? 'Password Auth' : 'SSH Key Auth')
1665
- )
1666
- )
1667
- )
1668
- : null,
1669
-
1670
- // Section 3: Mirror Sync (ClineBot Action Card style)
1671
- activeProfile
1672
- ? React.createElement(
1673
- 'div',
1674
- { className: 'drw-card' },
1675
- React.createElement('div', { className: 'drw-card-title' }, t('syncTitle')),
1676
- React.createElement('div', { className: 'drw-card-desc' }, t('syncDesc')),
1677
-
1678
- React.createElement(
1679
- 'div',
1680
- { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '10px 14px', background: 'var(--dsw-alias-bg-layer-2)', borderRadius: '8px', border: '1px solid var(--dsw-alias-border-l2)', marginBottom: '12px' } },
1681
- React.createElement(
1682
- 'div',
1683
- { style: { display: 'flex', flexDirection: 'column', gap: '2px' } },
1684
- React.createElement('span', { style: { fontWeight: 600, fontSize: '13px' } }, t('autoSyncTitle')),
1685
- React.createElement('span', { style: { fontSize: '11px', color: 'var(--dsw-alias-label-secondary)' } }, t('autoSyncDesc'))
1686
- ),
1687
- React.createElement(
1688
- 'button',
1689
- {
1690
- type: 'button',
1691
- className: `drw-btn ${autoSync ? 'drw-btn-primary' : ''}`,
1692
- style: { padding: '4px 12px', fontSize: '12px' },
1693
- onClick: async () => {
1694
- const next = !autoSync
1695
- try {
1696
- const res = await fetch('/dsh-remote-workspace/watcher/toggle', {
1697
- method: 'POST',
1698
- headers: { 'Content-Type': 'application/json' },
1699
- body: JSON.stringify({ enabled: next })
1700
- })
1701
- const d = await res.json()
1702
- if (d.ok) setAutoSync(d.autoSync)
1703
- } catch (_) {}
1704
- }
1705
- },
1706
- autoSync ? '⚡ Active (ON)' : '⚪ Off'
1707
- )
1708
- ),
1709
-
1710
- React.createElement(
1711
- 'div',
1712
- { className: 'drw-row' },
1713
- React.createElement(
1714
- 'button',
1715
- {
1716
- type: 'button',
1717
- className: 'drw-btn',
1718
- disabled: !!busy || !activeProfile.remoteWorkspace || !activeProfile.localMirrorPath,
1719
- onClick: () => handleSync('pull')
1720
- },
1721
- busy === 'sync_pull' ? t('pulling') : t('pullBtn')
1722
- ),
1723
- React.createElement(
1724
- 'button',
1725
- {
1726
- type: 'button',
1727
- className: 'drw-btn',
1728
- disabled: !!busy || !activeProfile.remoteWorkspace || !activeProfile.localMirrorPath,
1729
- onClick: () => handleSync('push')
1730
- },
1731
- busy === 'sync_push' ? t('pushing') : t('pushBtn')
1732
- )
1733
- ),
1734
- syncMsg
1735
- ? React.createElement(
1736
- 'div',
1737
- {
1738
- className: 'drw-preview',
1739
- style: {
1740
- borderColor: syncMsg.ok ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-state-error-primary)'
1741
- }
1742
- },
1743
- syncMsg.text
1744
- )
1745
- : null
1746
- )
1747
- : null,
1748
-
1749
- // Section 4: SSH Port Forwarding (Tunnels Manager)
1750
- React.createElement(
1751
- 'div',
1752
- { className: 'drw-card' },
1753
- React.createElement('div', { className: 'drw-card-title' }, t('tunnelsTitle')),
1754
- React.createElement('div', { className: 'drw-card-desc' }, t('tunnelsDesc')),
1755
-
1756
- // Start tunnel inline row
1757
- activeProfile
1758
- ? React.createElement(
1759
- 'div',
1760
- { className: 'drw-row', style: { alignItems: 'flex-end', background: 'var(--dsw-alias-bg-layer-2)', padding: '10px 12px', borderRadius: '8px' } },
1761
- React.createElement(
1762
- 'div',
1763
- { style: { display: 'flex', flexDirection: 'column', gap: '3px' } },
1764
- React.createElement('span', { className: 'drw-label' }, t('tLocalPort')),
1765
- React.createElement('input', {
1766
- className: 'drw-input',
1767
- style: { width: '120px' },
1768
- type: 'number',
1769
- value: newTunnelLocal,
1770
- onChange: (e) => setNewTunnelLocal(e.target.value)
1771
- })
1772
- ),
1773
- React.createElement('span', { style: { paddingBottom: '8px', color: 'var(--dsw-alias-label-secondary)' } }, '→'),
1774
- React.createElement(
1775
- 'div',
1776
- { style: { display: 'flex', flexDirection: 'column', gap: '3px' } },
1777
- React.createElement('span', { className: 'drw-label' }, t('tRemotePort')),
1778
- React.createElement('input', {
1779
- className: 'drw-input',
1780
- style: { width: '120px' },
1781
- type: 'number',
1782
- value: newTunnelRemote,
1783
- onChange: (e) => setNewTunnelRemote(e.target.value)
1784
- })
1785
- ),
1786
- React.createElement(
1787
- 'button',
1788
- {
1789
- type: 'button',
1790
- className: 'drw-btn drw-btn-primary',
1791
- disabled: busy === 'tunnel_open',
1792
- onClick: handleStartTunnel
1793
- },
1794
- busy === 'tunnel_open' ? t('tOpening') : t('tOpenBtn')
1795
- )
1796
- )
1797
- : null,
1798
-
1799
- tunnelMsg
1800
- ? React.createElement(
1801
- 'div',
1802
- {
1803
- className: 'drw-preview',
1804
- style: {
1805
- borderColor: tunnelMsg.ok ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-state-error-primary)'
1806
- }
1807
- },
1808
- tunnelMsg.text
1809
- )
1810
- : null,
1811
-
1812
- // Tunnels Table
1813
- tunnels.length > 0
1814
- ? React.createElement(
1815
- 'table',
1816
- { className: 'drw-table' },
1817
- React.createElement(
1818
- 'thead',
1819
- null,
1820
- React.createElement(
1821
- 'tr',
1822
- null,
1823
- React.createElement('th', null, t('tunnelsColId')),
1824
- React.createElement('th', null, t('tunnelsColRoute')),
1825
- React.createElement('th', { style: { textAlign: 'right' } }, t('tunnelsColActions'))
1826
- )
1827
- ),
1828
- React.createElement(
1829
- 'tbody',
1830
- null,
1831
- tunnels.map((tun) =>
1832
- React.createElement(
1833
- 'tr',
1834
- { key: tun.id },
1835
- React.createElement('td', { style: { fontFamily: 'monospace', fontSize: '12px' } }, tun.id),
1836
- React.createElement(
1837
- 'td',
1838
- null,
1839
- React.createElement('span', { className: 'drw-badge drw-badge-ok' }, `127.0.0.1:${tun.localPort}`),
1840
- ' → ',
1841
- React.createElement('span', { className: 'drw-badge' }, `${tun.targetHost || '127.0.0.1'}:${tun.remotePort}`)
1842
- ),
1843
- React.createElement(
1844
- 'td',
1845
- { style: { textAlign: 'right' } },
1846
- React.createElement(
1847
- 'button',
1848
- {
1849
- type: 'button',
1850
- className: 'drw-btn drw-btn-danger',
1851
- style: { fontSize: '11px', padding: '3px 8px' },
1852
- onClick: () => handleStopTunnel(tun.id)
1853
- },
1854
- t('tStopBtn')
1855
- )
1856
- )
1857
- )
1858
- )
1859
- )
1860
- )
1861
- : React.createElement('div', { style: { fontSize: '13px', color: 'var(--dsw-alias-label-secondary)' } }, t('tNoTunnels'))
1862
- )
1863
- )
1864
- }
1865
-
1866
- // Accordion item for Settings -> Plugins section
1867
- function PluginCard(props) {
1868
- const [open, setOpen] = React.useState(false)
1869
- const t = props.locale === 'ru' ? makeT(ru, en) : makeT(en, ru)
1870
-
1871
- React.useEffect(() => {
1872
- ensureCss()
1873
- }, [])
1874
-
1875
- return React.createElement(
1876
- 'li',
1877
- { className: 'drw-card', style: { listStyle: 'none', marginBottom: '12px' } },
1878
- React.createElement(
1879
- 'button',
1880
- {
1881
- type: 'button',
1882
- style: {
1883
- background: 'none',
1884
- border: 'none',
1885
- cursor: 'pointer',
1886
- display: 'flex',
1887
- alignItems: 'center',
1888
- width: '100%',
1889
- padding: 0,
1890
- textAlign: 'left',
1891
- },
1892
- 'aria-expanded': open,
1893
- onClick: () => setOpen((v) => !v),
1894
- },
1895
- React.createElement('span', { style: { fontSize: '20px', marginRight: '12px' } }, '🌐'),
1896
- React.createElement(
1897
- 'div',
1898
- { style: { flex: 1 } },
1899
- React.createElement('div', { style: { fontWeight: 600, fontSize: '15px', color: 'var(--dsw-alias-label-primary)' } }, t('title')),
1900
- React.createElement('div', { style: { fontSize: '13px', color: 'var(--dsw-alias-label-secondary)' } }, t('subtitle'))
1901
- ),
1902
- React.createElement('span', { className: 'drw-badge drw-badge-ok', style: { marginRight: '14px' } }, t('status')),
1903
- React.createElement(
1904
- 'span',
1905
- { style: { transform: open ? 'rotate(180deg)' : 'none', transition: 'transform .16s' } },
1906
- React.createElement(FallbackChevron)
1907
- )
1908
- ),
1909
- open
1910
- ? React.createElement(
1911
- 'div',
1912
- { style: { marginTop: '16px', borderTop: '1px solid var(--dsw-alias-border-l2)', paddingTop: '16px' } },
1913
- React.createElement(SettingsView, props)
1914
- )
1915
- : null
1916
- )
1917
- }
1918
-
1919
- function RemoteWorkspaceChip(props) {
1920
- ensureCss()
1921
- const [activeHost, setActiveHost] = React.useState(null)
1922
-
1923
- React.useEffect(() => {
1924
- fetch('/dsh-remote-workspace/state')
1925
- .then((r) => r.json())
1926
- .then((d) => {
1927
- if (d.ok && d.activeId && d.profiles) {
1928
- const f = d.profiles.find((p) => p.id === d.activeId)
1929
- if (f) setActiveHost(f.name || f.host)
1930
- }
1931
- })
1932
- .catch(() => {})
1933
- }, [])
1934
-
1935
- return React.createElement(
1936
- 'div',
1937
- {
1938
- style: {
1939
- display: 'flex',
1940
- alignItems: 'center',
1941
- gap: '6px',
1942
- padding: '2px 8px',
1943
- fontSize: '11px',
1944
- fontFamily: 'monospace',
1945
- borderRadius: '999px',
1946
- border: '1px solid var(--dsw-alias-border-l2)',
1947
- background: 'var(--dsw-alias-bg-layer-1)',
1948
- color: activeHost ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-label-secondary)',
1949
- cursor: 'pointer'
1950
- }
1951
- },
1952
- React.createElement('span', null, '🌐'),
1953
- React.createElement('span', null, activeHost ? `SSH: ${activeHost}` : 'SSH: Local')
1954
- )
1955
- }
1956
-
1957
- function apply(ctx) {
1958
- if (ctx.locale && typeof ctx.locale.register === 'function') {
1959
- try { ctx.locale.register(NS, { en, ru }) } catch (_) {}
1960
- }
1961
-
1962
- if (ctx.slots && typeof ctx.slots.inject === 'function') {
1963
- ctx.slots.inject('settings.plugin.item', () =>
1964
- ctx.slots.register(
1965
- {
1966
- name: 'settings.plugin.item',
1967
- key: NS,
1968
- locale: NS,
1969
- inject: () => ({ ctx })
1970
- },
1971
- (props) => React.createElement(PluginCard, Object.assign({}, props, { ctx }))
1972
- )
1973
- )
1974
-
1975
- ctx.slots.inject('conversation.session.header.utilities', () =>
1976
- ctx.slots.register(
1977
- {
1978
- name: 'conversation.session.header.utilities',
1979
- id: '@goodandready/dsh-remote-workspace',
1980
- order: 30
1981
- },
1982
- (props) => React.createElement(RemoteWorkspaceChip, props)
1983
- )
1984
- )
1985
- }
1986
- }
1987
-
1988
- module.exports = { apply, inject: ['slots', 'locale'] }
1989
- return module.exports
1990
- }
1991
- })
1
+ // Remote Workspace Settings Card (settings.plugin.item) & Session Utility Chip.
2
+ window.__ModuleLoader__.load({
3
+ id: '@goodandready/dsh-remote-workspace',
4
+ factory: (require) => {
5
+ var module = { exports: {} }
6
+ var exports = module.exports
7
+ const React = require('react')
8
+
9
+ const NS = 'dsh-remote-workspace'
10
+
11
+ function ensureCss() {
12
+ if (typeof document === 'undefined') return
13
+ if (document.getElementById('drw-clinebot-full-css')) return
14
+ const style = document.createElement('style')
15
+ style.id = 'drw-clinebot-full-css'
16
+ style.dataset.dshPlugin = NS
17
+ style.textContent = `
18
+ .drw-page{display:flex;flex-direction:column;gap:18px;padding:6px 0 24px;max-width:960px}
19
+ .drw-header{display:flex;flex-direction:column;gap:8px;padding-bottom:14px;border-bottom:1px solid var(--dsw-alias-border-l2)}
20
+ .drw-header-top{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px}
21
+ .drw-page-title{font-size:20px;font-weight:700;color:var(--dsw-alias-label-primary);display:flex;align-items:center;gap:10px}
22
+ .drw-page-sub{font-size:13px;color:var(--dsw-alias-label-secondary);line-height:1.5}
23
+ .drw-header-badges{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
24
+
25
+ .drw-card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:12px;padding:16px 18px;display:flex;flex-direction:column;gap:14px;list-style:none}
26
+ .drw-card-title{font-size:15px;font-weight:600;color:var(--dsw-alias-label-primary);display:flex;align-items:center;justify-content:space-between}
27
+ .drw-card-desc{font-size:13px;color:var(--dsw-alias-label-secondary);margin-top:-6px;line-height:1.4}
28
+
29
+ .drw-row{display:flex;flex-wrap:wrap;gap:10px;align-items:center}
30
+ .drw-grid-2{display:grid;grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));gap:12px}
31
+ .drw-grid-4{display:grid;grid-template-columns:repeat(auto-fit, minmax(190px, 1fr));gap:10px}
32
+
33
+ .drw-badge{font-size:11px;padding:3px 9px;border-radius:999px;border:1px solid var(--dsw-alias-border-l2);display:inline-flex;align-items:center;gap:5px;font-weight:500;font-family:monospace}
34
+ .drw-badge-ok{border-color:var(--dsw-alias-state-success-primary);color:var(--dsw-alias-state-success-primary);background:var(--dsw-alias-state-success-bg, var(--dsw-alias-bg-layer-2))}
35
+ .drw-badge-warn{border-color:var(--dsw-alias-state-warning-primary);color:var(--dsw-alias-state-warning-primary);background:var(--dsw-alias-state-warning-bg, var(--dsw-alias-bg-layer-2))}
36
+ .drw-badge-err{border-color:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-state-error-primary);background:var(--dsw-alias-state-error-bg, var(--dsw-alias-bg-layer-2))}
37
+
38
+ .drw-input{height:34px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 10px;font-size:13px;width:100%;box-sizing:border-box}
39
+ .drw-input:focus{outline:none;border-color:var(--dsw-alias-state-brand-primary)}
40
+ .drw-label{font-size:12px;font-weight:500;color:var(--dsw-alias-label-secondary);margin-bottom:2px}
41
+ .drw-hint{font-size:11px;color:var(--dsw-alias-label-dimmed, var(--dsw-alias-label-secondary));line-height:1.3}
42
+ .drw-field{display:flex;flex-direction:column;gap:3px;flex:1;min-width:180px}
43
+
44
+ .drw-btn{appearance:none;font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:6px 12px;font-size:13px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-weight:500;display:inline-flex;align-items:center;justify-content:center;gap:6px;transition:all .15s ease}
45
+ .drw-btn:hover:not(:disabled){background:var(--dsw-alias-bg-layer-4, var(--dsw-alias-bg-layer-2));border-color:var(--dsw-alias-label-dimmed, var(--dsw-alias-border-l2))}
46
+ .drw-btn:disabled{opacity:0.6;cursor:not-allowed}
47
+ .drw-btn-primary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3);border-color:transparent}
48
+ .drw-btn-primary:hover:not(:disabled){opacity:0.9}
49
+ .drw-btn-danger{color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-border, var(--dsw-alias-border-l2))}
50
+ .drw-btn-danger:hover:not(:disabled){background:var(--dsw-alias-state-error-bg, var(--dsw-alias-bg-layer-2));border-color:var(--dsw-alias-state-error-border, var(--dsw-alias-border-l2))}
51
+
52
+ .drw-segmented{display:inline-flex;border-radius:8px;padding:2px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);gap:2px}
53
+ .drw-segmented-item{appearance:none;border:none;background:none;cursor:pointer;padding:5px 12px;font-size:12px;font-weight:500;border-radius:6px;color:var(--dsw-alias-label-secondary);transition:all .15s ease}
54
+ .drw-segmented-item-active{background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l2);font-weight:600}
55
+
56
+ .drw-table{width:100%;border-collapse:collapse;margin-top:4px}
57
+ .drw-table th{text-align:left;font-size:12px;color:var(--dsw-alias-label-secondary);padding:8px 10px;border-bottom:1px solid var(--dsw-alias-border-l2);font-weight:600}
58
+ .drw-table td{padding:9px 10px;border-bottom:1px solid var(--dsw-alias-border-l2);font-size:13px;color:var(--dsw-alias-label-primary)}
59
+ .drw-table tr:hover{background:var(--dsw-alias-bg-layer-2)}
60
+
61
+ .drw-stat-box{padding:10px 12px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-layer-2);display:flex;flex-direction:column;gap:3px}
62
+ .drw-stat-val{font-size:14px;font-weight:700;color:var(--dsw-alias-label-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
63
+ .drw-stat-lbl{font-size:11px;color:var(--dsw-alias-label-secondary)}
64
+ .drw-preview{padding:10px 12px;border-radius:8px;background:var(--dsw-alias-bg-layer-2);font-family:monospace;font-size:12px;white-space:pre-wrap;word-break:break-all;border:1px solid var(--dsw-alias-border-l2);line-height:1.4}
65
+
66
+ .drw-browser-modal{border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-2);padding:12px;display:flex;flex-direction:column;gap:8px;max-height:280px}
67
+ .drw-browser-list{overflow-y:auto;display:flex;flex-direction:column;gap:2px;max-height:190px;padding-right:4px}
68
+ .drw-browser-item{display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:6px;cursor:pointer;font-size:13px;font-family:monospace}
69
+ .drw-browser-item:hover{background:var(--dsw-alias-bg-layer-3)}
70
+
71
+ .drw-tabs{display:flex;gap:6px;border-bottom:1px solid var(--dsw-alias-border-l2);padding-bottom:10px;margin-bottom:14px;overflow-x:auto}
72
+ .drw-tab-btn{appearance:none;border:1px solid transparent;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);padding:6px 14px;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;display:inline-flex;align-items:center;gap:6px;transition:all .15s ease}
73
+ .drw-tab-btn:hover{background:var(--dsw-alias-bg-layer-4);color:var(--dsw-alias-label-primary)}
74
+ .drw-tab-btn.active{background:var(--dsw-alias-bg-layer-4);border-color:var(--dsw-alias-state-brand-primary);color:var(--dsw-alias-state-brand-primary)}
75
+
76
+ .drw-term-window{background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);border-radius:10px;display:flex;flex-direction:column;height:340px;overflow:hidden;box-shadow:0 4px 14px var(--dsw-alias-border-l1)}
77
+ .drw-term-header{background:var(--dsw-alias-bg-layer-2);padding:6px 12px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--dsw-alias-border-l2);font-size:12px;color:var(--dsw-alias-label-secondary);font-family:monospace}
78
+ .drw-term-body{flex:1;padding:10px 12px;overflow-y:auto;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12.5px;line-height:1.45;color:var(--dsw-alias-label-primary);white-space:pre-wrap;word-break:break-all}
79
+ .drw-term-footer{display:flex;background:var(--dsw-alias-bg-layer-2);border-top:1px solid var(--dsw-alias-border-l2);padding:6px}
80
+ .drw-term-input{flex:1;background:transparent;border:none;color:var(--dsw-alias-link-primary, var(--dsw-alias-label-primary));font-family:monospace;font-size:13px;padding:4px 8px;outline:none}
81
+
82
+ .drw-explorer-box{border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-2);padding:12px;display:flex;flex-direction:column;gap:10px}
83
+ .drw-explorer-nav{display:flex;align-items:center;gap:8px;font-family:monospace;font-size:12px;background:var(--dsw-alias-bg-layer-1);padding:6px 10px;border-radius:6px;border:1px solid var(--dsw-alias-border-l2)}
84
+ .drw-file-list{display:flex;flex-direction:column;gap:3px;max-height:260px;overflow-y:auto}
85
+ .drw-file-row{display:flex;align-items:center;justify-content:space-between;padding:6px 10px;border-radius:6px;cursor:pointer;font-size:13px;font-family:monospace;transition:background .1s ease}
86
+ .drw-file-row:hover{background:var(--dsw-alias-bg-layer-3)}
87
+ .drw-file-meta{display:flex;align-items:center;gap:12px;color:var(--dsw-alias-label-secondary);font-size:11.5px}
88
+
89
+ .drw-modal-overlay{position:fixed;inset:0;background:var(--dsw-alias-mask, var(--dsw-alias-bg-layer-1));z-index:9999;display:flex;align-items:center;justify-content:center;padding:20px}
90
+ .drw-modal-dialog{background:var(--dsw-alias-bg-layer-3);border:1px solid var(--dsw-alias-border-l2);border-radius:12px;width:100%;max-width:800px;max-height:85vh;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 12px 32px var(--dsw-alias-border-l1)}
91
+ .drw-modal-hdr{padding:12px 16px;border-bottom:1px solid var(--dsw-alias-border-l2);display:flex;align-items:center;justify-content:space-between;font-weight:600}
92
+ .drw-modal-body{flex:1;padding:12px 16px;overflow-y:auto}
93
+
94
+ .drw-health-bar{display:grid;grid-template-columns:repeat(auto-fit, minmax(130px, 1fr));gap:8px;padding:8px 12px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;font-size:11.5px;font-family:monospace}
95
+ .drw-health-item{display:flex;flex-direction:column;gap:2px}
96
+ .drw-progress{height:6px;background:var(--dsw-alias-bg-layer-1);border-radius:3px;overflow:hidden}
97
+ .drw-progress-fill{height:100%;border-radius:3px;transition:width .2s ease}
98
+
99
+ .drw-container-row{display:grid;grid-template-columns:2fr 2fr 1.5fr 1.5fr auto;align-items:center;gap:10px;padding:8px 10px;border-bottom:1px solid var(--dsw-alias-border-l2);font-size:12.5px;font-family:monospace}
100
+ .drw-container-row:hover{background:var(--dsw-alias-bg-layer-3)}
101
+
102
+ .drw-env-table{width:100%;border-collapse:collapse}
103
+ .drw-env-row{display:grid;grid-template-columns:220px 1fr 90px;gap:8px;padding:6px 0;align-items:center;border-bottom:1px solid var(--dsw-alias-border-l2)}
104
+ .drw-alert-badge{padding:4px 8px;border-radius:6px;font-size:11px;font-family:monospace;display:flex;align-items:center;gap:6px}
105
+ .drw-alert-critical{background:var(--dsw-alias-state-error-bg, var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-state-error-primary);border:1px solid var(--dsw-alias-state-error-border, var(--dsw-alias-border-l2))}
106
+ .drw-alert-warning{background:var(--dsw-alias-state-warning-bg, var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-state-warning-primary);border:1px solid var(--dsw-alias-state-warning-border, var(--dsw-alias-border-l2))}
107
+
108
+
109
+ `
110
+ document.head.appendChild(style)
111
+ }
112
+
113
+ const en = {
114
+ title: 'Remote Workspace',
115
+ subtitle: 'Native SSH connections, SFTP file access, 3-way mirror sync, and port forwarding tunnels.',
116
+ status: 'Ready',
117
+
118
+ tabProfiles: '🖥️ Host Profiles',
119
+
120
+ tabContainers: '🐳 Containers',
121
+
122
+ tabEnv: '🗃️ .env Manager',
123
+ btnImportSsh: 'Import ~/.ssh/config',
124
+ envTitle: 'Remote Environment Variables (.env)',
125
+ envKey: 'Key',
126
+ envVal: 'Value',
127
+ envSaveVar: 'Save',
128
+ envShowVal: 'Show',
129
+ envHideVal: 'Hide',
130
+ tarSyncFast: '🚀 Fast Tarball Stream',
131
+ diagnoseTitle: 'Quick Diagnostics',
132
+ diagnosePorts: 'Open Ports',
133
+ diagnoseOom: 'OOM Killer Check',
134
+ diagnoseDisk: 'Disk Usage',
135
+ alertLabel: 'Alerts ({count})',
136
+
137
+ containersTitle: 'Remote Docker / Podman Engine',
138
+ containerName: 'Container',
139
+ containerImage: 'Image',
140
+ containerStatus: 'Status',
141
+ containerPorts: 'Ports',
142
+ btnLogs: 'Logs',
143
+ btnRestart: 'Restart',
144
+ btnStop: 'Stop',
145
+ noContainers: 'No active containers found or Docker daemon not running.',
146
+ healthCpu: 'CPU: {val}%',
147
+ healthMem: 'RAM: {val}% ({used}/{total} MB)',
148
+ healthDisk: 'Disk: {val}%',
149
+ healthUptime: 'Up: {val}',
150
+ autoSyncTitle: 'Live Auto-Sync on Save',
151
+ autoSyncDesc: 'Automatically push modified files to remote workspace on local save.',
152
+ btnTransfer: 'Copy to Host...',
153
+ transferTitle: 'Server-to-Server Direct Transfer',
154
+ transferDestHost: 'Destination Server',
155
+ transferDestPath: 'Destination File Path',
156
+ transferBtnExec: 'Transfer Directly',
157
+ transferSuccess: 'Successfully transferred {bytes} bytes to {host}:{path}',
158
+ fJumpHost: 'Jump Host (Bastion)',
159
+ fJumpHostNone: 'Direct Connection (No Jump Host)',
160
+
161
+ tabTerminal: '⚡ Web Terminal',
162
+ tabExplorer: '📂 File Explorer',
163
+ tabTunnels: '🔗 Port Tunnels',
164
+ tabSync: '🔄 Sync Station',
165
+ vaultProtectedBadge: '🛡️ .env Vault Protected',
166
+ termStart: 'Connect Terminal',
167
+ termStop: 'Disconnect',
168
+ termClear: 'Clear',
169
+ termPlaceholder: 'Type command and press Enter (e.g. htop, ls, docker ps)...',
170
+ termConnected: 'Connected to PTY session {id} on {host}',
171
+ termDisconnected: 'Terminal disconnected.',
172
+ explorerTitle: 'Remote Filesystem Explorer',
173
+ filePreviewTitle: 'File Viewer: {path}',
174
+ fileSize: '{size} KB',
175
+ btnSaveFile: 'Save Changes',
176
+ fileSaved: 'File saved successfully.',
177
+ tunnelTraffic: 'RX: {rx} | TX: {tx}',
178
+ tunnelUptime: 'Up: {sec}s',
179
+ openLocalLink: '🌐 Open Local Port',
180
+ badgeOnline: 'Active Host: {name} ({latency} ms)',
181
+ badgeOffline: 'No active host',
182
+ badgeTunnels: 'Tunnels: {count}',
183
+ badgeKey: '🔑 Key Auth',
184
+ badgePassword: '🔒 Password Auth',
185
+ profilesTitle: '🖥️ Remote SSH Profiles',
186
+ profilesDesc: 'Configure remote machines for code execution, SFTP browsing, and background mirror sync.',
187
+ addBtn: '+ Add Host',
188
+ nameCol: 'Name',
189
+ hostCol: 'Host / User',
190
+ portCol: 'Port',
191
+ pathCol: 'Remote Workspace',
192
+ actionsCol: 'Actions',
193
+ noHosts: 'No remote hosts configured yet. Click "+ Add Host" to create your first connection.',
194
+ activeBadge: 'Active',
195
+ pinBtn: 'Pin Active',
196
+ editBtn: 'Edit',
197
+ delBtn: 'Delete',
198
+ delConfirm: 'Delete host profile "{name}"?',
199
+ formTitleNew: 'Add New Host Profile',
200
+ formTitleEdit: 'Edit Host Profile',
201
+ fName: 'Profile Name',
202
+ fHost: 'Host / IP Address',
203
+ fPort: 'Port',
204
+ fUser: 'Username',
205
+ fAuthType: 'Authentication Method',
206
+ fAuthKey: 'SSH Private Key',
207
+ fAuthPass: 'Password',
208
+ fKeyPath: 'Private Key Path',
209
+ fKeyPathHint: 'Path to ~/.ssh/id_rsa or /home/user/.ssh/id_ed25519',
210
+ fPassphrase: 'Key Passphrase (optional)',
211
+ fPassword: 'Account Password',
212
+ fRemotePath: 'Remote Workspace Directory',
213
+ fRemotePathHint: 'Absolute path on the server (e.g. /home/user/my-project)',
214
+ fLocalMirror: 'Local Mirror Directory',
215
+ fLocalMirrorHint: 'Local directory where files are mirrored for fast 3-way synchronization',
216
+ btnBrowse: '📁 Browse Remote...',
217
+ btnSelectThis: 'Select Directory',
218
+ btnTest: '⚡ Test Connection (Ping)',
219
+ btnSave: 'Save Profile',
220
+ btnCancel: 'Cancel',
221
+ testing: 'Testing Connection...',
222
+ saving: 'Saving...',
223
+ testOk: '✅ Connection OK! Latency: {latency} ms | OS: {os}',
224
+ testFail: '❌ Connection Failed: {err}',
225
+ diagTitle: '📊 Active Connection Diagnostics',
226
+ diagDesc: 'Real-time telemetry and engine status for the currently selected remote machine.',
227
+ diagProbeBtn: '⚡ Quick Probe',
228
+ syncTitle: '🔄 Two-Way Workspace Mirror Sync',
229
+ syncDesc: 'Fast 3-way conflict-aware file synchronization between local mirror and remote server.',
230
+ pullBtn: '⬇️ Pull from Remote',
231
+ pushBtn: '⬆️ Push to Remote',
232
+ pulling: 'Pulling files…',
233
+ pushing: 'Pushing files…',
234
+ syncOk: 'Sync completed! Updated {count} file(s).',
235
+ syncConflict: 'Conflict warning: {count} file(s) modified on both sides.',
236
+ syncErr: 'Sync error: {err}',
237
+ tunnelsTitle: '🔀 SSH Port Forwarding (Tunnels)',
238
+ tunnelsDesc: 'Forward remote ports (e.g. databases, web servers, APIs) to your local machine via encrypted SSH tunnels.',
239
+ tLocalPort: 'Local Port',
240
+ tRemotePort: 'Remote Port',
241
+ tOpenBtn: '+ Open Tunnel',
242
+ tOpening: 'Opening…',
243
+ tStopBtn: 'Stop',
244
+ tNoTunnels: 'No active port forwarding tunnels.',
245
+ tunnelsColId: 'Tunnel ID',
246
+ tunnelsColRoute: 'Forwarding Route',
247
+ tunnelsColActions: 'Actions',
248
+ tOpenOk: 'Tunnel opened: 127.0.0.1:{localPort} -> Remote:{remotePort}',
249
+ tOpenErr: 'Failed to open tunnel: {err}'
250
+ }
251
+
252
+ const zh = {
253
+ title: '远程开发工作区',
254
+ subtitle: '支持原生 SSH 连接、SFTP 文件访问、3-way 镜像同步与端口转发隧道。',
255
+ status: '就绪',
256
+
257
+ tabProfiles: '🖥️ 主机配置',
258
+ tabContainers: '🐳 容器管理',
259
+ tabEnv: '🗃️ 环境变量',
260
+ btnImportSsh: '导入 ~/.ssh/config',
261
+ envTitle: '远程环境变量配置 (.env)',
262
+ envKey: '变量名',
263
+ envVal: '变量值',
264
+ envSaveVar: '保存',
265
+ envShowVal: '显示',
266
+ envHideVal: '隐藏',
267
+ tarSyncFast: '🚀 快速 Tarball 流式同步',
268
+ diagnoseTitle: '快速诊断',
269
+ diagnosePorts: '开放端口',
270
+ diagnoseOom: 'OOM 检查',
271
+ diagnoseDisk: '磁盘分析',
272
+ alertLabel: '告警 ({count})',
273
+
274
+ containersTitle: '远程 Docker / Podman 引擎',
275
+ containerName: '容器名',
276
+ containerImage: '镜像',
277
+ containerStatus: '运行状态',
278
+ containerPorts: '端口映射',
279
+ btnLogs: '日志',
280
+ btnRestart: '重启',
281
+ btnStop: '停止',
282
+ noContainers: '未找到运行中的容器或 Docker 守护进程未启动。',
283
+ healthCpu: 'CPU: {val}%',
284
+ healthMem: '内存: {val}% ({used}/{total} MB)',
285
+ healthDisk: '磁盘: {val}%',
286
+ healthUptime: '运行: {val}',
287
+ autoSyncTitle: '保存时自动增量同步',
288
+ autoSyncDesc: '本地文件保存时,后台自动增量推送到远程对应工作目录。',
289
+ btnTransfer: '跨主机传输...',
290
+ transferTitle: '主机间直接流式传输',
291
+ transferDestHost: '目标主机',
292
+ transferDestPath: '目标文件路径',
293
+ transferBtnExec: '立即直传',
294
+ transferSuccess: '成功传输 {bytes} 字节到 {host}:{path}',
295
+ fJumpHost: '跳板机 (Bastion)',
296
+ fJumpHostNone: '直连模式 (无跳板机)',
297
+
298
+ tabTerminal: '⚡ 网页终端',
299
+ tabExplorer: '📂 文件管理',
300
+ tabTunnels: '🔗 端口隧道',
301
+ tabSync: '🔄 同步控制台',
302
+ vaultProtectedBadge: '🛡️ .env 保管库加密保护',
303
+ termStart: '连接终端',
304
+ termStop: '断开连接',
305
+ termClear: '清屏',
306
+ termPlaceholder: '输入命令后回车 (如 htop, ls, docker ps)...',
307
+ termConnected: '已连接至主机 {host} 的 PTY 会话 {id}',
308
+ termDisconnected: '终端已断开。',
309
+ explorerTitle: '远程文件系统浏览',
310
+ filePreviewTitle: '文件查看器: {path}',
311
+ fileSize: '{size} KB',
312
+ btnSaveFile: '保存文件更改',
313
+ fileSaved: '文件保存成功。',
314
+ tunnelTraffic: '下行: {rx} | 上行: {tx}',
315
+ tunnelUptime: '运行: {sec}秒',
316
+ openLocalLink: '🌐 打开本地端口',
317
+ badgeOnline: '当前主机: {name} ({latency} ms)',
318
+ badgeOffline: '未选定活跃主机',
319
+ badgeTunnels: '活动隧道: {count}',
320
+ badgeKey: '🔑 私钥认证',
321
+ badgePassword: '🔒 密码认证',
322
+ profilesTitle: '🖥️ 远程 SSH 主机配置',
323
+ profilesDesc: '配置用于命令执行、SFTP 浏览与后台镜像同步的远程服务器。',
324
+ addBtn: '+ 添加主机',
325
+ nameCol: '配置名称',
326
+ hostCol: '主机 / 用户',
327
+ portCol: '端口',
328
+ pathCol: '远程工作区',
329
+ actionsCol: '操作',
330
+ noHosts: '暂无配置的主机。点击 "+ 添加主机" 建立首个连接。',
331
+ activeBadge: '活动中',
332
+ updaterTitle: '插件更新',
333
+ currentVersion: '当前版本',
334
+ latestVersion: 'npm 最新版',
335
+ checkUpdate: '检查更新',
336
+ checking: '正在检查...',
337
+ updateNow: '立即更新',
338
+ updating: '正在更新...',
339
+ upToDate: '已是最新版本',
340
+ updateAvailable: '发现新版本',
341
+ restartRequired: '更新已成功安装,请重启 DSH 使其生效。',
342
+ updateFailed: '更新失败',
343
+ pinBtn: '设为默认',
344
+ editBtn: '编辑',
345
+ delBtn: '删除',
346
+ delConfirm: '确认删除主机配置 "{name}" 吗?',
347
+ formTitleNew: '添加新主机配置',
348
+ formTitleEdit: '编辑主机配置',
349
+ fName: '配置别名',
350
+ fHost: '主机名 / IP 地址',
351
+ fPort: '端口',
352
+ fUser: '登录用户名',
353
+ fAuthType: '身份认证方式',
354
+ fAuthKey: 'SSH 私钥',
355
+ fAuthPass: '账户密码',
356
+ fKeyPath: '私钥文件路径',
357
+ fKeyPathHint: '例如 ~/.ssh/id_rsa 或 /home/user/.ssh/id_ed25519',
358
+ fPassphrase: '私钥口令 (可选)',
359
+ fPassword: '登录密码',
360
+ fRemotePath: '远程项目工作区目录',
361
+ fRemotePathHint: '服务器上的绝对路径 (例如 /home/user/my-project)',
362
+ fLocalMirror: '本地镜像同步目录',
363
+ fLocalMirrorHint: '用于 3-way 差异比对与快速同步的本地镜像路径',
364
+ btnBrowse: '📁 浏览远程目录...',
365
+ btnSelectThis: '选择当前目录',
366
+ btnTest: '⚡ 测试网络连通性 (Ping)',
367
+ btnSave: '保存配置',
368
+ btnCancel: '取消',
369
+ testing: '正在测试连接...',
370
+ saving: '正在保存...',
371
+ testOk: '✅ 连接成功!延迟: {latency} ms | 系统: {os}',
372
+ testFail: '❌ 连接失败: {err}',
373
+ diagTitle: '📊 实时连接状态诊断',
374
+ diagDesc: '查看当前选定主机的网络延迟、系统资源及底层服务运行指标。',
375
+ diagProbeBtn: '⚡ 即时探测',
376
+ syncTitle: '🔄 双向工作区镜像同步',
377
+ syncDesc: '基于三方冲突感知的快速差异同步,支持本地与远程端双向推拉。',
378
+ pullBtn: '⬇️ 拉取至本地 (Pull)',
379
+ pushBtn: '⬆️ 推送至远程 (Push)',
380
+ pulling: '正在拉取文件…',
381
+ pushing: '正在推送文件…',
382
+ syncOk: '同步完成!共更新 {count} 个文件。',
383
+ syncConflict: '冲突警告: 检测到 {count} 个文件在两端均有修改。',
384
+ syncErr: '同步异常: {err}',
385
+ tunnelsTitle: '🔀 SSH 端口安全隧道',
386
+ tunnelsDesc: '通过加密 SSH 隧道将远程端口 (如数据库、开发服务、API) 映射至本地访问。',
387
+ tLocalPort: '本地监听端口',
388
+ tRemotePort: '远程目标端口',
389
+ tOpenBtn: '+ 建立隧道',
390
+ tOpening: '正在建立…',
391
+ tStopBtn: '关闭',
392
+ tNoTunnels: '当前没有运行中的端口转发隧道。',
393
+ tunnelsColId: '隧道标识',
394
+ tunnelsColRoute: '转发路由',
395
+ tunnelsColActions: '管理操作',
396
+ tOpenOk: '隧道已启动: 127.0.0.1:{localPort} -> Remote:{remotePort}',
397
+ tOpenErr: '启动隧道失败: {err}'
398
+ }
399
+
400
+ function makeT(dict, fallback) {
401
+ return function t(key, vars) {
402
+ let val = (dict && dict[key]) || (fallback && fallback[key]) || key
403
+ if (vars && typeof val === 'string') {
404
+ for (const k of Object.keys(vars)) {
405
+ val = val.replace(new RegExp('\\{' + k + '\\}', 'g'), String(vars[k]))
406
+ }
407
+ }
408
+ return val
409
+ }
410
+ }
411
+
412
+ let ChevronIcon = null;
413
+ try {
414
+ const primitives = require('@deepseek-ai/dsh-client-ui-primitives');
415
+ ChevronIcon = primitives && primitives.IconChevronDownOutline14;
416
+ } catch (err) {
417
+ ChevronIcon = null;
418
+ }
419
+
420
+ function FallbackChevron() {
421
+ return React.createElement(
422
+ 'svg',
423
+ { width: 14, height: 14, viewBox: '0 0 14 14', fill: 'none', 'aria-hidden': true },
424
+ React.createElement('path', {
425
+ d: 'M3.5 5.25L7 8.75L10.5 5.25',
426
+ stroke: 'currentColor',
427
+ strokeWidth: 1.5,
428
+ strokeLinecap: 'round',
429
+ strokeLinejoin: 'round',
430
+ })
431
+ )
432
+ }
433
+
434
+
435
+
436
+
437
+ // --- Sub-component: Remote Environment Tab (New in v0.3.1) ---
438
+ function EnvTab(props) {
439
+ const { activeProfile, t } = props
440
+ const [envEntries, setEnvEntries] = React.useState([])
441
+ const [loading, setLoading] = React.useState(false)
442
+ const [visibleKeys, setVisibleKeys] = React.useState({})
443
+ const [editValues, setEditValues] = React.useState({})
444
+ const [msg, setMsg] = React.useState('')
445
+
446
+ const loadEnv = async () => {
447
+ if (!activeProfile) return
448
+ setLoading(true)
449
+ try {
450
+ const res = await fetch('/dsh-remote-workspace/env/view', {
451
+ method: 'POST',
452
+ headers: { 'Content-Type': 'application/json' },
453
+ body: JSON.stringify({ profileId: activeProfile.id })
454
+ })
455
+ const data = await res.json()
456
+ if (data.ok && Array.isArray(data.entries)) {
457
+ setEnvEntries(data.entries.filter((e) => e.type === 'var'))
458
+ const initialEdits = {}
459
+ data.entries.forEach((e) => {
460
+ if (e.type === 'var') initialEdits[e.key] = e.value
461
+ })
462
+ setEditValues(initialEdits)
463
+ }
464
+ } catch (err) {
465
+ setMsg(`Error loading .env: ${err.message}`)
466
+ }
467
+ setLoading(false)
468
+ }
469
+
470
+ React.useEffect(() => {
471
+ loadEnv()
472
+ }, [activeProfile?.id])
473
+
474
+ const toggleVisible = (key) => {
475
+ setVisibleKeys((prev) => ({ ...prev, [key]: !prev[key] }))
476
+ }
477
+
478
+ const saveVar = async (key) => {
479
+ try {
480
+ const res = await fetch('/dsh-remote-workspace/env/save', {
481
+ method: 'POST',
482
+ headers: { 'Content-Type': 'application/json' },
483
+ body: JSON.stringify({
484
+ profileId: activeProfile.id,
485
+ key,
486
+ value: editValues[key] || ''
487
+ })
488
+ })
489
+ const data = await res.json()
490
+ if (data.ok) {
491
+ setMsg(`Saved ${key} successfully!`)
492
+ setTimeout(() => setMsg(''), 3000)
493
+ }
494
+ } catch (err) {
495
+ setMsg(`Save failed: ${err.message}`)
496
+ }
497
+ }
498
+
499
+ return React.createElement(
500
+ 'div',
501
+ { style: { display: 'flex', flexDirection: 'column', gap: '14px' } },
502
+ React.createElement(
503
+ 'div',
504
+ { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } },
505
+ React.createElement('div', { style: { fontWeight: 600, fontSize: '14px' } }, t('envTitle')),
506
+ React.createElement('button', { type: 'button', className: 'drw-btn', onClick: loadEnv, disabled: loading }, loading ? 'Loading...' : '🔄 Refresh')
507
+ ),
508
+ msg ? React.createElement('div', { className: 'drw-badge drw-badge-ok' }, msg) : null,
509
+ React.createElement(
510
+ 'div',
511
+ { style: { border: '1px solid var(--dsw-alias-border-l2)', borderRadius: '8px', padding: '12px', background: 'var(--dsw-alias-bg-layer-2)' } },
512
+ envEntries.length === 0
513
+ ? React.createElement('div', { style: { textAlign: 'center', padding: '16px', color: 'var(--dsw-alias-label-secondary)' } }, 'No variables found in remote .env')
514
+ : envEntries.map((e) =>
515
+ React.createElement(
516
+ 'div',
517
+ { key: e.key, className: 'drw-env-row' },
518
+ React.createElement('span', { style: { fontWeight: 600, fontFamily: 'monospace', fontSize: '12.5px' } }, e.key),
519
+ React.createElement('input', {
520
+ type: visibleKeys[e.key] ? 'text' : 'password',
521
+ className: 'drw-input',
522
+ value: editValues[e.key] !== undefined ? editValues[e.key] : e.value,
523
+ onChange: (ev) => {
524
+ const val = ev.target.value
525
+ setEditValues((prev) => ({ ...prev, [e.key]: val }))
526
+ }
527
+ }),
528
+ React.createElement(
529
+ 'div',
530
+ { style: { display: 'flex', gap: '4px', justifyContent: 'flex-end' } },
531
+ React.createElement('button', { type: 'button', className: 'drw-btn', style: { padding: '2px 6px', fontSize: '11px' }, onClick: () => toggleVisible(e.key) }, visibleKeys[e.key] ? t('envHideVal') : t('envShowVal')),
532
+ React.createElement('button', { type: 'button', className: 'drw-btn drw-btn-primary', style: { padding: '2px 6px', fontSize: '11px' }, onClick: () => saveVar(e.key) }, t('envSaveVar'))
533
+ )
534
+ )
535
+ )
536
+ )
537
+ )
538
+ }
539
+
540
+ // --- Sub-component: Docker Containers Tab ---
541
+ function ContainersTab(props) {
542
+ const { activeProfile, t } = props
543
+ const [containers, setContainers] = React.useState([])
544
+ const [loading, setLoading] = React.useState(false)
545
+ const [logsModal, setLogsModal] = React.useState(null)
546
+ const [logsContent, setLogsContent] = React.useState('')
547
+ const [logsLoading, setLogsLoading] = React.useState(false)
548
+
549
+ const loadContainers = async () => {
550
+ if (!activeProfile) return
551
+ setLoading(true)
552
+ try {
553
+ const res = await fetch(`/dsh-remote-workspace/docker/list?profileId=${activeProfile.id}`)
554
+ const data = await res.json()
555
+ if (data.ok && Array.isArray(data.containers)) {
556
+ setContainers(data.containers)
557
+ } else {
558
+ setContainers([])
559
+ }
560
+ } catch (err) { /* best-effort cleanup */ }
561
+ setLoading(false)
562
+ }
563
+
564
+ React.useEffect(() => {
565
+ loadContainers()
566
+ }, [activeProfile?.id])
567
+
568
+ const handleAction = async (containerId, action) => {
569
+ try {
570
+ await fetch('/dsh-remote-workspace/docker/action', {
571
+ method: 'POST',
572
+ headers: { 'Content-Type': 'application/json' },
573
+ body: JSON.stringify({ profileId: activeProfile.id, containerId, action })
574
+ })
575
+ await loadContainers()
576
+ } catch (err) { /* best-effort cleanup */ }
577
+ }
578
+
579
+ const showLogs = async (containerId, name) => {
580
+ setLogsModal({ id: containerId, name })
581
+ setLogsLoading(true)
582
+ try {
583
+ const res = await fetch('/dsh-remote-workspace/docker/logs', {
584
+ method: 'POST',
585
+ headers: { 'Content-Type': 'application/json' },
586
+ body: JSON.stringify({ profileId: activeProfile.id, containerId, tail: 150 })
587
+ })
588
+ const data = await res.json()
589
+ setLogsContent(data.logs || '[No logs output]')
590
+ } catch (err) {
591
+ setLogsContent(`[Error: ${err.message}]`)
592
+ }
593
+ setLogsLoading(false)
594
+ }
595
+
596
+ return React.createElement(
597
+ 'div',
598
+ { style: { display: 'flex', flexDirection: 'column', gap: '12px' } },
599
+ React.createElement(
600
+ 'div',
601
+ { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } },
602
+ React.createElement('div', { style: { fontWeight: 600, fontSize: '14px' } }, t('containersTitle')),
603
+ React.createElement(
604
+ 'button',
605
+ {
606
+ type: 'button',
607
+ className: 'drw-btn',
608
+ onClick: loadContainers,
609
+ disabled: loading
610
+ },
611
+ loading ? 'Refreshing...' : '🔄 Refresh'
612
+ )
613
+ ),
614
+ React.createElement(
615
+ 'div',
616
+ { style: { border: '1px solid var(--dsw-alias-border-l2)', borderRadius: '8px', overflow: 'hidden', background: 'var(--dsw-alias-bg-layer-2)' } },
617
+ React.createElement(
618
+ 'div',
619
+ { className: 'drw-container-row', style: { fontWeight: 600, color: 'var(--dsw-alias-label-secondary)', background: 'var(--dsw-alias-bg-layer-1)' } },
620
+ React.createElement('span', null, t('containerName')),
621
+ React.createElement('span', null, t('containerImage')),
622
+ React.createElement('span', null, t('containerStatus')),
623
+ React.createElement('span', null, t('containerPorts')),
624
+ React.createElement('span', { style: { textAlign: 'right' } }, t('actionsCol'))
625
+ ),
626
+ containers.length === 0
627
+ ? React.createElement('div', { style: { padding: '24px', textAlign: 'center', color: 'var(--dsw-alias-label-secondary)' } }, t('noContainers'))
628
+ : containers.map((c) =>
629
+ React.createElement(
630
+ 'div',
631
+ { key: c.id, className: 'drw-container-row' },
632
+ React.createElement(
633
+ 'div',
634
+ { style: { display: 'flex', alignItems: 'center', gap: '6px' } },
635
+ React.createElement('span', { className: `drw-badge ${c.state === 'running' ? 'drw-badge-ok' : 'drw-badge-warn'}` }, c.state),
636
+ React.createElement('span', { style: { fontWeight: 600 } }, c.names)
637
+ ),
638
+ React.createElement('span', { style: { opacity: 0.8, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, c.image),
639
+ React.createElement('span', { style: { fontSize: '11px', opacity: 0.7 } }, c.status),
640
+ React.createElement('span', { style: { fontSize: '11px', opacity: 0.7, overflow: 'hidden', textOverflow: 'ellipsis' } }, c.ports || '—'),
641
+ React.createElement(
642
+ 'div',
643
+ { style: { display: 'flex', gap: '4px', justifyContent: 'flex-end' } },
644
+ React.createElement(
645
+ 'button',
646
+ { type: 'button', className: 'drw-btn', style: { padding: '2px 6px', fontSize: '11px' }, onClick: () => showLogs(c.id, c.names) },
647
+ t('btnLogs')
648
+ ),
649
+ React.createElement(
650
+ 'button',
651
+ { type: 'button', className: 'drw-btn', style: { padding: '2px 6px', fontSize: '11px' }, onClick: () => handleAction(c.id, 'restart') },
652
+ t('btnRestart')
653
+ ),
654
+ c.state === 'running'
655
+ ? React.createElement(
656
+ 'button',
657
+ { type: 'button', className: 'drw-btn drw-btn-danger', style: { padding: '2px 6px', fontSize: '11px' }, onClick: () => handleAction(c.id, 'stop') },
658
+ t('btnStop')
659
+ )
660
+ : null
661
+ )
662
+ )
663
+ )
664
+ ),
665
+ // Container Logs Modal
666
+ logsModal
667
+ ? React.createElement(
668
+ 'div',
669
+ { className: 'drw-modal-overlay', onClick: () => setLogsModal(null) },
670
+ React.createElement(
671
+ 'div',
672
+ { className: 'drw-modal-dialog', onClick: (e) => e.stopPropagation() },
673
+ React.createElement(
674
+ 'div',
675
+ { className: 'drw-modal-hdr' },
676
+ React.createElement('span', { style: { fontFamily: 'monospace' } }, `Docker Logs: ${logsModal.name} (${logsModal.id})`),
677
+ React.createElement('button', { type: 'button', className: 'drw-btn', onClick: () => setLogsModal(null) }, '✕')
678
+ ),
679
+ React.createElement(
680
+ 'div',
681
+ { className: 'drw-modal-body' },
682
+ React.createElement('pre', { style: { background: 'var(--dsw-alias-bg-layer-1)', color: 'var(--dsw-alias-label-primary)', padding: '12px', borderRadius: '8px', fontSize: '12px', maxHeight: '420px', overflowY: 'auto', whiteSpace: 'pre-wrap' } }, logsLoading ? 'Fetching logs...' : logsContent)
683
+ )
684
+ )
685
+ )
686
+ : null
687
+ )
688
+ }
689
+
690
+ // --- Sub-component: Web Terminal Tab ---
691
+ function TerminalTab(props) {
692
+ const { activeProfile, t } = props
693
+ const [connected, setConnected] = React.useState(false)
694
+ const [sessionId, setSessionId] = React.useState(null)
695
+ const [output, setOutput] = React.useState('')
696
+ const [cmdInput, setCmdInput] = React.useState('')
697
+ const [loading, setLoading] = React.useState(false)
698
+ const termEndRef = React.useRef(null)
699
+ const evtSourceRef = React.useRef(null)
700
+
701
+ React.useEffect(() => {
702
+ if (termEndRef.current) {
703
+ termEndRef.current.scrollIntoView({ behavior: 'smooth' })
704
+ }
705
+ }, [output])
706
+
707
+ React.useEffect(() => {
708
+ return () => {
709
+ if (evtSourceRef.current) {
710
+ evtSourceRef.current.close()
711
+ }
712
+ }
713
+ }, [])
714
+
715
+ const handleConnect = async () => {
716
+ if (!activeProfile) return
717
+ setLoading(true)
718
+ try {
719
+ const res = await fetch('/dsh-remote-workspace/terminal/create', {
720
+ method: 'POST',
721
+ headers: { 'Content-Type': 'application/json' },
722
+ body: JSON.stringify({ profileId: activeProfile.id, cols: 80, rows: 24 })
723
+ })
724
+ const data = await res.json()
725
+ if (data.ok && data.sessionId) {
726
+ setSessionId(data.sessionId)
727
+ setConnected(true)
728
+ setOutput((prev) => prev + `\n[+] ` + t('termConnected', { id: data.sessionId, host: activeProfile.host }) + `\n`)
729
+
730
+ // Connect SSE stream
731
+ const es = new EventSource(`/dsh-remote-workspace/terminal/stream?sessionId=${data.sessionId}`)
732
+ evtSourceRef.current = es
733
+ es.onmessage = (e) => {
734
+ try {
735
+ const parsed = JSON.parse(e.data)
736
+ if (parsed.chunk) {
737
+ setOutput((p) => p + parsed.chunk)
738
+ }
739
+ } catch (err) { /* best-effort cleanup */ }
740
+ }
741
+ es.onerror = () => {
742
+ setOutput((p) => p + `\n[-] ` + t('termDisconnected') + `\n`)
743
+ setConnected(false)
744
+ es.close()
745
+ }
746
+ }
747
+ } catch (err) {
748
+ setOutput((p) => p + `\n[!] Connection error: ${err.message}\n`)
749
+ }
750
+ setLoading(false)
751
+ }
752
+
753
+ const handleDisconnect = async () => {
754
+ if (sessionId) {
755
+ try {
756
+ await fetch('/dsh-remote-workspace/terminal/close', {
757
+ method: 'POST',
758
+ headers: { 'Content-Type': 'application/json' },
759
+ body: JSON.stringify({ sessionId })
760
+ })
761
+ } catch (err) { /* best-effort cleanup */ }
762
+ }
763
+ if (evtSourceRef.current) {
764
+ evtSourceRef.current.close()
765
+ }
766
+ setConnected(false)
767
+ setSessionId(null)
768
+ setOutput((p) => p + `\n[-] ` + t('termDisconnected') + `\n`)
769
+ }
770
+
771
+ const sendCommand = async (e) => {
772
+ if (e) e.preventDefault()
773
+ if (!cmdInput || !sessionId) return
774
+ const toSend = cmdInput + '\n'
775
+ setCmdInput('')
776
+ try {
777
+ await fetch('/dsh-remote-workspace/terminal/input', {
778
+ method: 'POST',
779
+ headers: { 'Content-Type': 'application/json' },
780
+ body: JSON.stringify({ sessionId, data: toSend })
781
+ })
782
+ } catch (err) { /* best-effort cleanup */ }
783
+ }
784
+
785
+ const sendCtrlC = async () => {
786
+ if (!sessionId) return
787
+ try {
788
+ await fetch('/dsh-remote-workspace/terminal/input', {
789
+ method: 'POST',
790
+ headers: { 'Content-Type': 'application/json' },
791
+ body: JSON.stringify({ sessionId, data: '\x03' })
792
+ })
793
+ } catch (err) { /* best-effort cleanup */ }
794
+ }
795
+
796
+ return React.createElement(
797
+ 'div',
798
+ { style: { display: 'flex', flexDirection: 'column', gap: '12px' } },
799
+ React.createElement(
800
+ 'div',
801
+ { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: '8px' } },
802
+ React.createElement(
803
+ 'div',
804
+ { style: { display: 'flex', alignItems: 'center', gap: '8px' } },
805
+ React.createElement('span', { style: { fontWeight: 600, fontSize: '14px' } }, 'SSH PTY Shell:'),
806
+ React.createElement(
807
+ 'span',
808
+ { className: `drw-badge ${connected ? 'drw-badge-ok' : 'drw-badge-warn'}` },
809
+ connected ? `🟢 Online (${activeProfile?.host})` : '⚪ Idle'
810
+ )
811
+ ),
812
+ React.createElement(
813
+ 'div',
814
+ { style: { display: 'flex', gap: '8px' } },
815
+ !connected
816
+ ? React.createElement(
817
+ 'button',
818
+ {
819
+ type: 'button',
820
+ className: 'drw-btn drw-btn-primary',
821
+ disabled: !activeProfile || loading,
822
+ onClick: handleConnect
823
+ },
824
+ loading ? 'Connecting...' : t('termStart')
825
+ )
826
+ : React.createElement(
827
+ 'button',
828
+ {
829
+ type: 'button',
830
+ className: 'drw-btn drw-btn-danger',
831
+ onClick: handleDisconnect
832
+ },
833
+ t('termStop')
834
+ ),
835
+ connected
836
+ ? React.createElement(
837
+ 'button',
838
+ {
839
+ type: 'button',
840
+ className: 'drw-btn',
841
+ onClick: sendCtrlC
842
+ },
843
+ 'Ctrl+C'
844
+ )
845
+ : null,
846
+ React.createElement(
847
+ 'button',
848
+ {
849
+ type: 'button',
850
+ className: 'drw-btn',
851
+ onClick: () => setOutput('')
852
+ },
853
+ t('termClear')
854
+ )
855
+ )
856
+ ),
857
+ React.createElement(
858
+ 'div',
859
+ { className: 'drw-term-window' },
860
+ React.createElement(
861
+ 'div',
862
+ { className: 'drw-term-header' },
863
+ React.createElement('span', null, `terminal ~ ${activeProfile?.username || 'user'}@${activeProfile?.host || 'remote'}`),
864
+ React.createElement('span', null, connected ? `Session: ${sessionId}` : 'Offline')
865
+ ),
866
+ React.createElement(
867
+ 'div',
868
+ { className: 'drw-term-body' },
869
+ output || (activeProfile ? `[i] Ready to connect to ${activeProfile.username || 'root'}@${activeProfile.host}. Click 'Connect Terminal'.` : `[!] No active host profile selected. Configure and activate a profile first.`),
870
+ React.createElement('div', { ref: termEndRef })
871
+ ),
872
+ connected
873
+ ? React.createElement(
874
+ 'form',
875
+ { className: 'drw-term-footer', onSubmit: sendCommand },
876
+ React.createElement('span', { style: { color: 'var(--dsw-alias-link-primary)', padding: '4px 6px', fontFamily: 'monospace' } }, '$'),
877
+ React.createElement('input', {
878
+ className: 'drw-term-input',
879
+ type: 'text',
880
+ placeholder: t('termPlaceholder'),
881
+ value: cmdInput,
882
+ onChange: (e) => setCmdInput(e.target.value)
883
+ }),
884
+ React.createElement(
885
+ 'button',
886
+ { type: 'submit', className: 'drw-btn', style: { padding: '2px 8px', fontSize: '11px' } },
887
+ 'Send ↵'
888
+ )
889
+ )
890
+ : null
891
+ )
892
+ )
893
+ }
894
+
895
+ // --- Sub-component: Remote File Explorer Tab ---
896
+ function ExplorerTab(props) {
897
+ const { activeProfile, t } = props
898
+ const [currentPath, setCurrentPath] = React.useState(activeProfile?.remoteWorkspace || '/')
899
+ const [entries, setEntries] = React.useState([])
900
+ const [loading, setLoading] = React.useState(false)
901
+ const [previewFile, setPreviewFile] = React.useState(null)
902
+ const [previewContent, setPreviewContent] = React.useState('')
903
+ const [editContent, setEditContent] = React.useState('')
904
+ const [previewLoading, setPreviewLoading] = React.useState(false)
905
+ const [saveStatus, setSaveStatus] = React.useState(null)
906
+
907
+ const loadDir = async (dirPath) => {
908
+ if (!activeProfile) return
909
+ setLoading(true)
910
+ try {
911
+ const res = await fetch('/dsh-remote-workspace/browse', {
912
+ method: 'POST',
913
+ headers: { 'Content-Type': 'application/json' },
914
+ body: JSON.stringify({ profileId: activeProfile.id, remotePath: dirPath })
915
+ })
916
+ const data = await res.json()
917
+ if (data.ok && Array.isArray(data.entries)) {
918
+ setCurrentPath(dirPath)
919
+ setEntries(data.entries)
920
+ }
921
+ } catch (err) { /* best-effort cleanup */ }
922
+ setLoading(false)
923
+ }
924
+
925
+ React.useEffect(() => {
926
+ if (activeProfile) {
927
+ loadDir(activeProfile.remoteWorkspace || '/')
928
+ }
929
+ }, [activeProfile?.id])
930
+
931
+ const handleNavUp = () => {
932
+ const parts = currentPath.split('/').filter(Boolean)
933
+ parts.pop()
934
+ const parent = '/' + parts.join('/')
935
+ loadDir(parent || '/')
936
+ }
937
+
938
+ const openFile = async (entry) => {
939
+ const filePath = currentPath.endsWith('/') ? currentPath + entry.filename : currentPath + '/' + entry.filename
940
+ setPreviewLoading(true)
941
+ setPreviewFile(filePath)
942
+ setSaveStatus(null)
943
+ try {
944
+ const res = await fetch('/dsh-remote-workspace/file/view', {
945
+ method: 'POST',
946
+ headers: { 'Content-Type': 'application/json' },
947
+ body: JSON.stringify({ profileId: activeProfile.id, filePath })
948
+ })
949
+ const data = await res.json()
950
+ if (data.ok) {
951
+ setPreviewContent(data.content)
952
+ setEditContent(data.content)
953
+ } else {
954
+ setPreviewContent(`[Error loading file: ${data.error || 'Failed'}]`)
955
+ setEditContent('')
956
+ }
957
+ } catch (err) {
958
+ setPreviewContent(`[Error: ${err.message}]`)
959
+ }
960
+ setPreviewLoading(false)
961
+ }
962
+
963
+ const handleSaveFile = async () => {
964
+ if (!previewFile || !activeProfile) return
965
+ setSaveStatus('saving')
966
+ try {
967
+ const res = await fetch('/dsh-remote-workspace/file/save', {
968
+ method: 'POST',
969
+ headers: { 'Content-Type': 'application/json' },
970
+ body: JSON.stringify({ profileId: activeProfile.id, filePath: previewFile, content: editContent })
971
+ })
972
+ const data = await res.json()
973
+ if (data.ok) {
974
+ setSaveStatus('saved')
975
+ setPreviewContent(editContent)
976
+ } else {
977
+ setSaveStatus('error')
978
+ }
979
+ } catch (_) {
980
+ setSaveStatus('error')
981
+ }
982
+ }
983
+
984
+ return React.createElement(
985
+ 'div',
986
+ { className: 'drw-explorer-box' },
987
+ React.createElement(
988
+ 'div',
989
+ { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } },
990
+ React.createElement('div', { style: { fontWeight: 600, fontSize: '14px' } }, t('explorerTitle')),
991
+ React.createElement(
992
+ 'button',
993
+ {
994
+ type: 'button',
995
+ className: 'drw-btn',
996
+ onClick: () => loadDir(currentPath),
997
+ disabled: loading
998
+ },
999
+ loading ? 'Refreshing...' : '🔄 Refresh'
1000
+ )
1001
+ ),
1002
+ React.createElement(
1003
+ 'div',
1004
+ { className: 'drw-explorer-nav' },
1005
+ React.createElement(
1006
+ 'button',
1007
+ {
1008
+ type: 'button',
1009
+ className: 'drw-btn',
1010
+ style: { padding: '2px 8px', fontSize: '11px' },
1011
+ onClick: handleNavUp,
1012
+ disabled: currentPath === '/' || loading
1013
+ },
1014
+ '⬆️ Up'
1015
+ ),
1016
+ React.createElement('span', { style: { color: 'var(--dsw-alias-label-secondary)' } }, 'Path:'),
1017
+ React.createElement('span', { style: { fontWeight: 600, color: 'var(--dsw-alias-state-brand-primary)' } }, currentPath)
1018
+ ),
1019
+ React.createElement(
1020
+ 'div',
1021
+ { className: 'drw-file-list' },
1022
+ entries.length === 0
1023
+ ? React.createElement('div', { style: { padding: '16px', textAlign: 'center', color: 'var(--dsw-alias-label-secondary)' } }, loading ? 'Reading directory...' : 'Directory is empty.')
1024
+ : entries.map((e) =>
1025
+ React.createElement(
1026
+ 'div',
1027
+ {
1028
+ key: e.filename,
1029
+ className: 'drw-file-row',
1030
+ onClick: () => (e.isDirectory ? loadDir(currentPath.endsWith('/') ? currentPath + e.filename : currentPath + '/' + e.filename) : openFile(e))
1031
+ },
1032
+ React.createElement(
1033
+ 'div',
1034
+ { style: { display: 'flex', alignItems: 'center', gap: '8px' } },
1035
+ React.createElement('span', null, e.isDirectory ? '📁' : '📄'),
1036
+ React.createElement('span', { style: { fontWeight: e.isDirectory ? 600 : 400 } }, e.filename)
1037
+ ),
1038
+ React.createElement(
1039
+ 'div',
1040
+ { className: 'drw-file-meta' },
1041
+ e.size !== undefined ? React.createElement('span', null, `${Math.round(e.size / 1024)} KB`) : null,
1042
+ e.permissions ? React.createElement('span', { style: { opacity: 0.6 } }, e.permissions) : null
1043
+ )
1044
+ )
1045
+ )
1046
+ ),
1047
+ // File Preview / Edit Modal
1048
+ previewFile
1049
+ ? React.createElement(
1050
+ 'div',
1051
+ { className: 'drw-modal-overlay', onClick: () => setPreviewFile(null) },
1052
+ React.createElement(
1053
+ 'div',
1054
+ { className: 'drw-modal-dialog', onClick: (e) => e.stopPropagation() },
1055
+ React.createElement(
1056
+ 'div',
1057
+ { className: 'drw-modal-hdr' },
1058
+ React.createElement('span', { style: { fontFamily: 'monospace' } }, t('filePreviewTitle', { path: previewFile })),
1059
+ React.createElement(
1060
+ 'button',
1061
+ {
1062
+ type: 'button',
1063
+ className: 'drw-btn',
1064
+ style: { padding: '2px 8px' },
1065
+ onClick: () => setPreviewFile(null)
1066
+ },
1067
+ '✕'
1068
+ )
1069
+ ),
1070
+ React.createElement(
1071
+ 'div',
1072
+ { className: 'drw-modal-body', style: { display: 'flex', flexDirection: 'column', gap: '10px' } },
1073
+ previewLoading
1074
+ ? React.createElement('div', { style: { padding: '20px', textAlign: 'center' } }, 'Loading content...')
1075
+ : React.createElement('textarea', {
1076
+ style: {
1077
+ width: '100%',
1078
+ height: '320px',
1079
+ background: 'var(--dsw-alias-bg-layer-1)',
1080
+ color: 'var(--dsw-alias-label-primary)',
1081
+ fontFamily: 'monospace',
1082
+ fontSize: '12px',
1083
+ padding: '10px',
1084
+ border: '1px solid var(--dsw-alias-border-l2)',
1085
+ borderRadius: '8px',
1086
+ resize: 'vertical',
1087
+ boxSizing: 'border-box'
1088
+ },
1089
+ value: editContent,
1090
+ onChange: (e) => setEditContent(e.target.value)
1091
+ }),
1092
+ React.createElement(
1093
+ 'div',
1094
+ { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } },
1095
+ React.createElement(
1096
+ 'span',
1097
+ { style: { fontSize: '12px', color: saveStatus === 'saved' ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-label-secondary)' } },
1098
+ saveStatus === 'saved' ? t('fileSaved') : saveStatus === 'error' ? 'Error saving file.' : ''
1099
+ ),
1100
+ React.createElement(
1101
+ 'div',
1102
+ { style: { display: 'flex', gap: '8px' } },
1103
+ React.createElement(
1104
+ 'button',
1105
+ {
1106
+ type: 'button',
1107
+ className: 'drw-btn',
1108
+ onClick: () => setPreviewFile(null)
1109
+ },
1110
+ 'Close'
1111
+ ),
1112
+ React.createElement(
1113
+ 'button',
1114
+ {
1115
+ type: 'button',
1116
+ className: 'drw-btn drw-btn-primary',
1117
+ onClick: handleSaveFile,
1118
+ disabled: saveStatus === 'saving'
1119
+ },
1120
+ saveStatus === 'saving' ? 'Saving...' : t('btnSaveFile')
1121
+ )
1122
+ )
1123
+ )
1124
+ )
1125
+ )
1126
+ )
1127
+ : null
1128
+ )
1129
+ }
1130
+
1131
+ function SettingsView(props) {
1132
+ const [activeTab, setActiveTab] = React.useState('profiles')
1133
+ const [healthData, setHealthData] = React.useState(null)
1134
+ const [autoSync, setAutoSync] = React.useState(false)
1135
+
1136
+ const t = props.t || (props.locale === 'zh' ? makeT(zh, en) : makeT(en, zh))
1137
+ const [profiles, setProfiles] = React.useState([])
1138
+ const [activeId, setActiveId] = React.useState(null)
1139
+ const [tunnels, setTunnels] = React.useState([])
1140
+ const [editing, setEditing] = React.useState(null)
1141
+ const [busy, setBusy] = React.useState(null)
1142
+ const [testResult, setTestResult] = React.useState(null)
1143
+ const [syncMsg, setSyncMsg] = React.useState(null)
1144
+ const [tunnelMsg, setTunnelMsg] = React.useState(null)
1145
+ const [showPassword, setShowPassword] = React.useState(false)
1146
+
1147
+ // Tunnel creation inputs
1148
+ const [newTunnelLocal, setNewTunnelLocal] = React.useState('3000')
1149
+ const [newTunnelRemote, setNewTunnelRemote] = React.useState('3000')
1150
+
1151
+ // Remote Directory Browser State
1152
+ const [browserOpen, setBrowserOpen] = React.useState(false)
1153
+ const [browserPath, setBrowserPath] = React.useState('/')
1154
+ const [browserEntries, setBrowserEntries] = React.useState([])
1155
+ const [browserLoading, setBrowserLoading] = React.useState(false)
1156
+
1157
+ const loadState = async () => {
1158
+ try {
1159
+ const res = await fetch('/dsh-remote-workspace/state')
1160
+ if (res.ok) {
1161
+ const data = await res.json()
1162
+ if (data.ok) {
1163
+ setProfiles(data.profiles || [])
1164
+ setActiveId(data.activeId || null)
1165
+ setTunnels(data.tunnels || [])
1166
+ setAutoSync(Boolean(data.autoSync))
1167
+ if (data.activeId) {
1168
+ fetch(`/dsh-remote-workspace/health?profileId=${data.activeId}`).then(r => r.json()).then(h => { if (h.ok) setHealthData(h.health) }).catch(() => {})
1169
+ }
1170
+ }
1171
+ }
1172
+ } catch (err) { /* best-effort cleanup */ }
1173
+ }
1174
+
1175
+ React.useEffect(() => {
1176
+ ensureCss()
1177
+ loadState()
1178
+ }, [])
1179
+
1180
+ const handleSave = async (profile) => {
1181
+ setBusy('saving')
1182
+ try {
1183
+ const res = await fetch('/dsh-remote-workspace/profiles/save', {
1184
+ method: 'POST',
1185
+ headers: { 'Content-Type': 'application/json' },
1186
+ body: JSON.stringify(profile)
1187
+ })
1188
+ if (res.ok) {
1189
+ setEditing(null)
1190
+ setBrowserOpen(false)
1191
+ setTestResult(null)
1192
+ await loadState()
1193
+ }
1194
+ } catch (err) { /* best-effort cleanup */ }
1195
+ setBusy(null)
1196
+ }
1197
+
1198
+ const handleDelete = async (id, name) => {
1199
+ if (!confirm(t('delConfirm', { name: name || id }))) return
1200
+ try {
1201
+ const res = await fetch('/dsh-remote-workspace/profiles/delete', {
1202
+ method: 'POST',
1203
+ headers: { 'Content-Type': 'application/json' },
1204
+ body: JSON.stringify({ id })
1205
+ })
1206
+ if (res.ok) {
1207
+ if (editing && editing.id === id) setEditing(null)
1208
+ await loadState()
1209
+ }
1210
+ } catch (err) { /* best-effort cleanup */ }
1211
+ }
1212
+
1213
+ const handleSetActive = async (id) => {
1214
+ try {
1215
+ const res = await fetch('/dsh-remote-workspace/profiles/active', {
1216
+ method: 'POST',
1217
+ headers: { 'Content-Type': 'application/json' },
1218
+ body: JSON.stringify({ id })
1219
+ })
1220
+ if (res.ok) {
1221
+ await loadState()
1222
+ }
1223
+ } catch (err) { /* best-effort cleanup */ }
1224
+ }
1225
+
1226
+ const handleTest = async (prof) => {
1227
+ setBusy('testing')
1228
+ setTestResult(null)
1229
+ try {
1230
+ const res = await fetch('/dsh-remote-workspace/test', {
1231
+ method: 'POST',
1232
+ headers: { 'Content-Type': 'application/json' },
1233
+ body: JSON.stringify({ profile: prof })
1234
+ })
1235
+ const data = await res.json()
1236
+ setTestResult(data)
1237
+ } catch (err) {
1238
+ setTestResult({ ok: false, error: err.message })
1239
+ }
1240
+ setBusy(null)
1241
+ }
1242
+
1243
+ const openDirectoryBrowser = async (initialPath) => {
1244
+ setBrowserOpen(true)
1245
+ const target = initialPath && initialPath.startsWith('/') ? initialPath : '/'
1246
+ await fetchRemoteDir(target)
1247
+ }
1248
+
1249
+ const fetchRemoteDir = async (dirPath) => {
1250
+ setBrowserLoading(true)
1251
+ try {
1252
+ const res = await fetch('/dsh-remote-workspace/browse', {
1253
+ method: 'POST',
1254
+ headers: { 'Content-Type': 'application/json' },
1255
+ body: JSON.stringify({ profile: editing, remotePath: dirPath })
1256
+ })
1257
+ const data = await res.json()
1258
+ if (data.ok) {
1259
+ setBrowserPath(data.currentPath || dirPath)
1260
+ setBrowserEntries(data.entries || [])
1261
+ }
1262
+ } catch (err) { /* best-effort cleanup */ }
1263
+ setBrowserLoading(false)
1264
+ }
1265
+
1266
+ const handleSync = async (direction) => {
1267
+ setBusy(`sync_${direction}`)
1268
+ setSyncMsg(null)
1269
+ try {
1270
+ const res = await fetch('/dsh-remote-workspace/sync', {
1271
+ method: 'POST',
1272
+ headers: { 'Content-Type': 'application/json' },
1273
+ body: JSON.stringify({ direction })
1274
+ })
1275
+ const data = await res.json()
1276
+ if (data.ok) {
1277
+ const count = (direction === 'push' ? data.pushed?.length : data.pulled?.length) || 0
1278
+ if (data.conflicts && data.conflicts.length > 0) {
1279
+ setSyncMsg({ ok: false, text: t('syncConflict', { count: data.conflicts.length }) })
1280
+ } else {
1281
+ setSyncMsg({ ok: true, text: t('syncOk', { count }) })
1282
+ }
1283
+ } else {
1284
+ setSyncMsg({ ok: false, text: t('syncErr', { err: data.error || 'Unknown error' }) })
1285
+ }
1286
+ } catch (err) {
1287
+ setSyncMsg({ ok: false, text: t('syncErr', { err: err.message }) })
1288
+ }
1289
+ setBusy(null)
1290
+ }
1291
+
1292
+ const handleStartTunnel = async () => {
1293
+ if (!activeId) return
1294
+ setBusy('tunnel_open')
1295
+ setTunnelMsg(null)
1296
+ try {
1297
+ const res = await fetch('/dsh-remote-workspace/tunnels/start', {
1298
+ method: 'POST',
1299
+ headers: { 'Content-Type': 'application/json' },
1300
+ body: JSON.stringify({
1301
+ profileId: activeId,
1302
+ localPort: newTunnelLocal,
1303
+ remotePort: newTunnelRemote
1304
+ })
1305
+ })
1306
+ const data = await res.json()
1307
+ if (data.ok) {
1308
+ setTunnelMsg({ ok: true, text: t('tOpenOk', { localPort: newTunnelLocal, remotePort: newTunnelRemote }) })
1309
+ await loadState()
1310
+ } else {
1311
+ setTunnelMsg({ ok: false, text: t('tOpenErr', { err: data.error || 'Failed' }) })
1312
+ }
1313
+ } catch (err) {
1314
+ setTunnelMsg({ ok: false, text: t('tOpenErr', { err: err.message }) })
1315
+ }
1316
+ setBusy(null)
1317
+ }
1318
+
1319
+ const handleStopTunnel = async (tunnelId) => {
1320
+ try {
1321
+ const res = await fetch('/dsh-remote-workspace/tunnels/stop', {
1322
+ method: 'POST',
1323
+ headers: { 'Content-Type': 'application/json' },
1324
+ body: JSON.stringify({ tunnelId })
1325
+ })
1326
+ if (res.ok) {
1327
+ await loadState()
1328
+ }
1329
+ } catch (err) { /* best-effort cleanup */ }
1330
+ }
1331
+
1332
+ const activeProfile = profiles.find((p) => p.id === activeId)
1333
+
1334
+ return React.createElement(
1335
+ 'div',
1336
+ { className: 'drw-page' },
1337
+
1338
+ // Header with Live Badges (ClineBot Style)
1339
+ React.createElement(
1340
+ 'div',
1341
+ { className: 'drw-header' },
1342
+ React.createElement(
1343
+ 'div',
1344
+ { className: 'drw-header-top' },
1345
+ React.createElement('div', { className: 'drw-page-title' }, '🌐 ' + t('title')),
1346
+ React.createElement(
1347
+ 'div',
1348
+ { className: 'drw-header-badges' },
1349
+ activeProfile
1350
+ ? React.createElement('span', { className: 'drw-badge drw-badge-ok' }, t('badgeOnline', { name: activeProfile.name || activeProfile.host, latency: testResult?.latencyMs ?? 15 }))
1351
+ : React.createElement('span', { className: 'drw-badge drw-badge-warn' }, t('badgeOffline')),
1352
+ activeProfile
1353
+ ? React.createElement('span', { className: 'drw-badge' }, activeProfile.authType === 'password' ? t('badgePassword') : t('badgeKey'))
1354
+ : null,
1355
+ React.createElement('span', { className: `drw-badge ${tunnels.length > 0 ? 'drw-badge-ok' : ''}` }, t('badgeTunnels', { count: tunnels.length }))
1356
+ )
1357
+ ),
1358
+ React.createElement('div', { className: 'drw-page-sub' }, t('subtitle'))
1359
+ ),
1360
+
1361
+ // Section 1: SSH Profiles Table & Management
1362
+ React.createElement(
1363
+ 'div',
1364
+ { className: 'drw-card' },
1365
+ React.createElement(
1366
+ 'div',
1367
+ { className: 'drw-card-title' },
1368
+ React.createElement('span', null, t('profilesTitle')),
1369
+ !editing
1370
+ ? React.createElement(
1371
+ 'button',
1372
+ {
1373
+ type: 'button',
1374
+ className: 'drw-btn drw-btn-primary',
1375
+ onClick: () => {
1376
+ setEditing({
1377
+ id: 'prof_' + Math.random().toString(36).substr(2, 9),
1378
+ name: 'New Server',
1379
+ host: '',
1380
+ port: 22,
1381
+ username: 'root',
1382
+ authType: 'key',
1383
+ privateKeyPath: '~/.ssh/id_rsa',
1384
+ passphrase: '',
1385
+ password: '',
1386
+ remoteWorkspace: '',
1387
+ localMirrorPath: ''
1388
+ })
1389
+ setTestResult(null)
1390
+ }
1391
+ },
1392
+ t('addBtn')
1393
+ )
1394
+ : null
1395
+ ),
1396
+ React.createElement('div', { className: 'drw-card-desc' }, t('profilesDesc')),
1397
+
1398
+ // Interactive Editing Form
1399
+ editing
1400
+ ? React.createElement(
1401
+ 'div',
1402
+ {
1403
+ style: {
1404
+ padding: '16px',
1405
+ borderRadius: '10px',
1406
+ background: 'var(--dsw-alias-bg-layer-2)',
1407
+ border: '1px solid var(--dsw-alias-border-l2)',
1408
+ display: 'flex',
1409
+ flexDirection: 'column',
1410
+ gap: '14px'
1411
+ }
1412
+ },
1413
+ React.createElement(
1414
+ 'div',
1415
+ { style: { fontWeight: 600, fontSize: '14px', color: 'var(--dsw-alias-label-primary)' } },
1416
+ editing.name ? t('formTitleEdit') : t('formTitleNew')
1417
+ ),
1418
+ React.createElement(
1419
+ 'div',
1420
+ { className: 'drw-grid-2' },
1421
+ React.createElement(
1422
+ 'div',
1423
+ { className: 'drw-field' },
1424
+ React.createElement('span', { className: 'drw-label' }, t('fName')),
1425
+ React.createElement('input', {
1426
+ className: 'drw-input',
1427
+ value: editing.name || '',
1428
+ onChange: (e) => setEditing({ ...editing, name: e.target.value })
1429
+ })
1430
+ ),
1431
+ React.createElement(
1432
+ 'div',
1433
+ { className: 'drw-field' },
1434
+ React.createElement('span', { className: 'drw-label' }, t('fHost')),
1435
+ React.createElement('input', {
1436
+ className: 'drw-input',
1437
+ placeholder: '192.168.1.100 or server.domain.com',
1438
+ value: editing.host || '',
1439
+ onChange: (e) => setEditing({ ...editing, host: e.target.value })
1440
+ })
1441
+ ),
1442
+ React.createElement(
1443
+ 'div',
1444
+ { className: 'drw-field' },
1445
+ React.createElement('span', { className: 'drw-label' }, t('fPort')),
1446
+ React.createElement('input', {
1447
+ className: 'drw-input',
1448
+ type: 'number',
1449
+ value: editing.port || 22,
1450
+ onChange: (e) => setEditing({ ...editing, port: parseInt(e.target.value, 10) || 22 })
1451
+ })
1452
+ ),
1453
+ React.createElement(
1454
+ 'div',
1455
+ { className: 'drw-field' },
1456
+ React.createElement('span', { className: 'drw-label' }, t('fUser')),
1457
+ React.createElement('input', {
1458
+ className: 'drw-input',
1459
+ value: editing.username || '',
1460
+ onChange: (e) => setEditing({ ...editing, username: e.target.value })
1461
+ })
1462
+ )
1463
+ ),
1464
+
1465
+ // Auth Method Segmented Switcher (Key vs Password)
1466
+ React.createElement(
1467
+ 'div',
1468
+ { style: { display: 'flex', flexDirection: 'column', gap: '8px' } },
1469
+ React.createElement('span', { className: 'drw-label' }, t('fAuthType')),
1470
+ React.createElement(
1471
+ 'div',
1472
+ { className: 'drw-segmented' },
1473
+ React.createElement(
1474
+ 'button',
1475
+ {
1476
+ type: 'button',
1477
+ className: `drw-segmented-item ${editing.authType !== 'password' ? 'drw-segmented-item-active' : ''}`,
1478
+ onClick: () => setEditing({ ...editing, authType: 'key' })
1479
+ },
1480
+ '🔑 ' + t('fAuthKey')
1481
+ ),
1482
+ React.createElement(
1483
+ 'button',
1484
+ {
1485
+ type: 'button',
1486
+ className: `drw-segmented-item ${editing.authType === 'password' ? 'drw-segmented-item-active' : ''}`,
1487
+ onClick: () => setEditing({ ...editing, authType: 'password' })
1488
+ },
1489
+ '🔒 ' + t('fAuthPass')
1490
+ )
1491
+ )
1492
+ ),
1493
+
1494
+ // Conditional Auth Inputs
1495
+ editing.authType === 'password'
1496
+ ? React.createElement(
1497
+ 'div',
1498
+ { className: 'drw-field' },
1499
+ React.createElement('span', { className: 'drw-label' }, t('fPassword')),
1500
+ React.createElement(
1501
+ 'div',
1502
+ { style: { display: 'flex', gap: '8px' } },
1503
+ React.createElement('input', {
1504
+ className: 'drw-input',
1505
+ type: showPassword ? 'text' : 'password',
1506
+ placeholder: '••••••••••••',
1507
+ value: editing.password || '',
1508
+ onChange: (e) => setEditing({ ...editing, password: e.target.value })
1509
+ }),
1510
+ React.createElement(
1511
+ 'button',
1512
+ {
1513
+ type: 'button',
1514
+ className: 'drw-btn',
1515
+ style: { fontSize: '11px', whiteSpace: 'nowrap' },
1516
+ onClick: () => setShowPassword((v) => !v)
1517
+ },
1518
+ showPassword ? 'Hide' : 'Show'
1519
+ )
1520
+ )
1521
+ )
1522
+ : React.createElement(
1523
+ 'div',
1524
+ { className: 'drw-grid-2' },
1525
+ React.createElement(
1526
+ 'div',
1527
+ { className: 'drw-field' },
1528
+ React.createElement('span', { className: 'drw-label' }, t('fKeyPath')),
1529
+ React.createElement('input', {
1530
+ className: 'drw-input',
1531
+ placeholder: '~/.ssh/id_rsa or /home/user/.ssh/id_ed25519',
1532
+ value: editing.privateKeyPath || '',
1533
+ onChange: (e) => setEditing({ ...editing, privateKeyPath: e.target.value })
1534
+ }),
1535
+ React.createElement('span', { className: 'drw-hint' }, t('fKeyPathHint'))
1536
+ ),
1537
+ React.createElement(
1538
+ 'div',
1539
+ { className: 'drw-field' },
1540
+ React.createElement('span', { className: 'drw-label' }, t('fPassphrase')),
1541
+ React.createElement('input', {
1542
+ className: 'drw-input',
1543
+ type: 'password',
1544
+ placeholder: 'Optional passphrase',
1545
+ value: editing.passphrase || '',
1546
+ onChange: (e) => setEditing({ ...editing, passphrase: e.target.value })
1547
+ })
1548
+ )
1549
+ ),
1550
+
1551
+ // Workspace Paths (Remote Workspace & Local Mirror)
1552
+ React.createElement(
1553
+ 'div',
1554
+ { className: 'drw-grid-2' },
1555
+ React.createElement(
1556
+ 'div',
1557
+ { className: 'drw-field' },
1558
+ React.createElement('span', { className: 'drw-label' }, t('fRemotePath')),
1559
+ React.createElement(
1560
+ 'div',
1561
+ { style: { display: 'flex', gap: '8px' } },
1562
+ React.createElement('input', {
1563
+ className: 'drw-input',
1564
+ placeholder: '/home/user/project',
1565
+ value: editing.remoteWorkspace || '',
1566
+ onChange: (e) => setEditing({ ...editing, remoteWorkspace: e.target.value })
1567
+ }),
1568
+ React.createElement(
1569
+ 'button',
1570
+ {
1571
+ type: 'button',
1572
+ className: 'drw-btn',
1573
+ style: { whiteSpace: 'nowrap', fontSize: '12px' },
1574
+ disabled: !editing.host,
1575
+ onClick: () => openDirectoryBrowser(editing.remoteWorkspace || '/')
1576
+ },
1577
+ t('btnBrowse')
1578
+ )
1579
+ ),
1580
+ React.createElement('span', { className: 'drw-hint' }, t('fRemotePathHint'))
1581
+ ),
1582
+ React.createElement(
1583
+ 'div',
1584
+ { className: 'drw-field' },
1585
+ React.createElement('span', { className: 'drw-label' }, t('fLocalMirror')),
1586
+ React.createElement('input', {
1587
+ className: 'drw-input',
1588
+ placeholder: '~/.dsh/mirrors/my-project',
1589
+ value: editing.localMirrorPath || '',
1590
+ onChange: (e) => setEditing({ ...editing, localMirrorPath: e.target.value })
1591
+ }),
1592
+ React.createElement('span', { className: 'drw-hint' }, t('fLocalMirrorHint'))
1593
+ )
1594
+ ),
1595
+
1596
+ // Directory Browser Modal
1597
+ browserOpen
1598
+ ? React.createElement(
1599
+ 'div',
1600
+ { className: 'drw-browser-modal' },
1601
+ React.createElement(
1602
+ 'div',
1603
+ { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } },
1604
+ React.createElement('span', { style: { fontSize: '12px', fontWeight: 600, color: 'var(--dsw-alias-label-primary)' } }, `📂 ${browserPath}`),
1605
+ React.createElement(
1606
+ 'div',
1607
+ { style: { display: 'flex', gap: '6px' } },
1608
+ React.createElement(
1609
+ 'button',
1610
+ {
1611
+ type: 'button',
1612
+ className: 'drw-btn drw-btn-primary',
1613
+ style: { fontSize: '11px', padding: '3px 8px' },
1614
+ onClick: () => {
1615
+ setEditing({ ...editing, remoteWorkspace: browserPath })
1616
+ setBrowserOpen(false)
1617
+ }
1618
+ },
1619
+ t('btnSelectThis')
1620
+ ),
1621
+ React.createElement(
1622
+ 'button',
1623
+ {
1624
+ type: 'button',
1625
+ className: 'drw-btn',
1626
+ style: { fontSize: '11px', padding: '3px 8px' },
1627
+ onClick: () => setBrowserOpen(false)
1628
+ },
1629
+ '✕'
1630
+ )
1631
+ )
1632
+ ),
1633
+ React.createElement(
1634
+ 'div',
1635
+ { className: 'drw-browser-list' },
1636
+ browserLoading
1637
+ ? React.createElement('div', { style: { padding: '8px', fontSize: '12px', color: 'var(--dsw-alias-label-secondary)' } }, 'Loading directory entries...')
1638
+ : React.createElement(
1639
+ React.Fragment,
1640
+ null,
1641
+ browserPath !== '/'
1642
+ ? React.createElement(
1643
+ 'div',
1644
+ {
1645
+ className: 'drw-browser-item',
1646
+ onClick: () => {
1647
+ const parent = browserPath.substring(0, browserPath.lastIndexOf('/')) || '/'
1648
+ fetchRemoteDir(parent)
1649
+ }
1650
+ },
1651
+ '📁 .. (parent directory)'
1652
+ )
1653
+ : null,
1654
+ browserEntries
1655
+ .filter((e) => e.isDirectory)
1656
+ .map((e) =>
1657
+ React.createElement(
1658
+ 'div',
1659
+ {
1660
+ key: e.filename,
1661
+ className: 'drw-browser-item',
1662
+ onClick: () => {
1663
+ const next = browserPath === '/' ? `/${e.filename}` : `${browserPath}/${e.filename}`
1664
+ fetchRemoteDir(next)
1665
+ }
1666
+ },
1667
+ `📁 ${e.filename}`
1668
+ )
1669
+ )
1670
+ )
1671
+ )
1672
+ )
1673
+ : null,
1674
+
1675
+ // Form Action Buttons
1676
+ React.createElement(
1677
+ 'div',
1678
+ { className: 'drw-row', style: { justifyContent: 'flex-end', marginTop: '6px' } },
1679
+ React.createElement(
1680
+ 'button',
1681
+ {
1682
+ type: 'button',
1683
+ className: 'drw-btn',
1684
+ disabled: !editing.host || !!busy,
1685
+ onClick: () => handleTest(editing)
1686
+ },
1687
+ busy === 'testing' ? t('testing') : t('btnTest')
1688
+ ),
1689
+ React.createElement(
1690
+ 'button',
1691
+ {
1692
+ type: 'button',
1693
+ className: 'drw-btn',
1694
+ onClick: () => {
1695
+ setEditing(null)
1696
+ setBrowserOpen(false)
1697
+ setTestResult(null)
1698
+ }
1699
+ },
1700
+ t('btnCancel')
1701
+ ),
1702
+ React.createElement(
1703
+ 'button',
1704
+ {
1705
+ type: 'button',
1706
+ className: 'drw-btn drw-btn-primary',
1707
+ disabled: !editing.host || !!busy,
1708
+ onClick: () => handleSave(editing)
1709
+ },
1710
+ busy === 'saving' ? t('saving') : t('btnSave')
1711
+ )
1712
+ ),
1713
+ testResult
1714
+ ? React.createElement(
1715
+ 'div',
1716
+ {
1717
+ className: 'drw-preview',
1718
+ style: {
1719
+ borderColor: testResult.ok ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-state-error-primary)'
1720
+ }
1721
+ },
1722
+ testResult.ok
1723
+ ? t('testOk', { latency: testResult.latencyMs ?? testResult.latency ?? 0, os: testResult.remoteOs || testResult.os || 'Linux' })
1724
+ : t('testFail', { err: testResult.error || 'Connection timed out' })
1725
+ )
1726
+ : null
1727
+ )
1728
+ : null,
1729
+
1730
+ // Profiles List Table
1731
+ profiles.length > 0
1732
+ ? React.createElement(
1733
+ 'table',
1734
+ { className: 'drw-table' },
1735
+ React.createElement(
1736
+ 'thead',
1737
+ null,
1738
+ React.createElement(
1739
+ 'tr',
1740
+ null,
1741
+ React.createElement('th', null, t('nameCol')),
1742
+ React.createElement('th', null, t('hostCol')),
1743
+ React.createElement('th', null, t('portCol')),
1744
+ React.createElement('th', null, t('pathCol')),
1745
+ React.createElement('th', { style: { textAlign: 'right' } }, t('actionsCol'))
1746
+ )
1747
+ ),
1748
+ React.createElement(
1749
+ 'tbody',
1750
+ null,
1751
+ profiles.map((p) => {
1752
+ const isAct = p.id === activeId
1753
+ return React.createElement(
1754
+ 'tr',
1755
+ { key: p.id },
1756
+ React.createElement(
1757
+ 'td',
1758
+ null,
1759
+ React.createElement('span', { style: { fontWeight: 600 } }, p.name || 'Server'),
1760
+ React.createElement(
1761
+ 'span',
1762
+ { className: 'drw-badge', style: { marginLeft: '8px' } },
1763
+ p.authType === 'password' ? '🔒 pwd' : '🔑 key'
1764
+ ),
1765
+ isAct
1766
+ ? React.createElement('span', { className: 'drw-badge drw-badge-ok', style: { marginLeft: '6px' } }, t('activeBadge'))
1767
+ : null
1768
+ ),
1769
+ React.createElement('td', { style: { fontFamily: 'monospace' } }, `${p.username || 'root'}@${p.host}`),
1770
+ React.createElement('td', { style: { fontFamily: 'monospace' } }, p.port || 22),
1771
+ React.createElement('td', { style: { fontFamily: 'monospace', fontSize: '12px' } }, p.remoteWorkspace || '—'),
1772
+ React.createElement(
1773
+ 'td',
1774
+ { style: { textAlign: 'right' } },
1775
+ React.createElement(
1776
+ 'div',
1777
+ { style: { display: 'inline-flex', gap: '6px' } },
1778
+ !isAct
1779
+ ? React.createElement(
1780
+ 'button',
1781
+ {
1782
+ type: 'button',
1783
+ className: 'drw-btn',
1784
+ style: { fontSize: '11px', padding: '3px 8px' },
1785
+ onClick: () => handleSetActive(p.id)
1786
+ },
1787
+ t('pinBtn')
1788
+ )
1789
+ : null,
1790
+ React.createElement(
1791
+ 'button',
1792
+ {
1793
+ type: 'button',
1794
+ className: 'drw-btn',
1795
+ style: { fontSize: '11px', padding: '3px 8px' },
1796
+ onClick: () => {
1797
+ setEditing({ ...p })
1798
+ setTestResult(null)
1799
+ }
1800
+ },
1801
+ t('editBtn')
1802
+ ),
1803
+ React.createElement(
1804
+ 'button',
1805
+ {
1806
+ type: 'button',
1807
+ className: 'drw-btn drw-btn-danger',
1808
+ style: { fontSize: '11px', padding: '3px 8px' },
1809
+ onClick: () => handleDelete(p.id, p.name)
1810
+ },
1811
+ t('delBtn')
1812
+ )
1813
+ )
1814
+ )
1815
+ )
1816
+ })
1817
+ )
1818
+ )
1819
+ : !editing
1820
+ ? React.createElement('div', { style: { fontSize: '13px', color: 'var(--dsw-alias-label-secondary)' } }, t('noHosts'))
1821
+ : null
1822
+ ),
1823
+
1824
+ // Section 2: Active Connection Diagnostics (ClineBot Card 4 style)
1825
+ activeProfile
1826
+ ? React.createElement(
1827
+ 'div',
1828
+ { className: 'drw-card' },
1829
+ React.createElement(
1830
+ 'div',
1831
+ { className: 'drw-card-title' },
1832
+ React.createElement('span', null, t('diagTitle')),
1833
+ React.createElement(
1834
+ 'button',
1835
+ {
1836
+ type: 'button',
1837
+ className: 'drw-btn',
1838
+ style: { fontSize: '11px', padding: '3px 9px' },
1839
+ disabled: busy === 'testing',
1840
+ onClick: () => handleTest(activeProfile)
1841
+ },
1842
+ busy === 'testing' ? t('testing') : t('diagProbeBtn')
1843
+ )
1844
+ ),
1845
+ React.createElement('div', { className: 'drw-card-desc' }, t('diagDesc')),
1846
+ React.createElement(
1847
+ 'div',
1848
+ { className: 'drw-grid-4' },
1849
+ React.createElement(
1850
+ 'div',
1851
+ { className: 'drw-stat-box' },
1852
+ React.createElement('div', { className: 'drw-stat-val' }, activeProfile.name || activeProfile.host),
1853
+ React.createElement('div', { className: 'drw-stat-lbl' }, `SSH: ${activeProfile.username}@${activeProfile.host}:${activeProfile.port || 22}`)
1854
+ ),
1855
+ React.createElement(
1856
+ 'div',
1857
+ { className: 'drw-stat-box' },
1858
+ React.createElement('div', { className: 'drw-stat-val' }, activeProfile.remoteWorkspace || '—'),
1859
+ React.createElement('div', { className: 'drw-stat-lbl' }, 'Remote Workspace')
1860
+ ),
1861
+ React.createElement(
1862
+ 'div',
1863
+ { className: 'drw-stat-box' },
1864
+ React.createElement('div', { className: 'drw-stat-val' }, activeProfile.localMirrorPath || '—'),
1865
+ React.createElement('div', { className: 'drw-stat-lbl' }, 'Local Mirror Path')
1866
+ ),
1867
+ React.createElement(
1868
+ 'div',
1869
+ { className: 'drw-stat-box' },
1870
+ React.createElement('div', { className: 'drw-stat-val', style: { color: 'var(--dsw-alias-state-success-primary)' } }, 'Ready ✓'),
1871
+ React.createElement('div', { className: 'drw-stat-lbl' }, activeProfile.authType === 'password' ? 'Password Auth' : 'SSH Key Auth')
1872
+ )
1873
+ )
1874
+ )
1875
+ : null,
1876
+
1877
+ // Section 3: Mirror Sync (ClineBot Action Card style)
1878
+ activeProfile
1879
+ ? React.createElement(
1880
+ 'div',
1881
+ { className: 'drw-card' },
1882
+ React.createElement('div', { className: 'drw-card-title' }, t('syncTitle')),
1883
+ React.createElement('div', { className: 'drw-card-desc' }, t('syncDesc')),
1884
+
1885
+ React.createElement(
1886
+ 'div',
1887
+ { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '10px 14px', background: 'var(--dsw-alias-bg-layer-2)', borderRadius: '8px', border: '1px solid var(--dsw-alias-border-l2)', marginBottom: '12px' } },
1888
+ React.createElement(
1889
+ 'div',
1890
+ { style: { display: 'flex', flexDirection: 'column', gap: '2px' } },
1891
+ React.createElement('span', { style: { fontWeight: 600, fontSize: '13px' } }, t('autoSyncTitle')),
1892
+ React.createElement('span', { style: { fontSize: '11px', color: 'var(--dsw-alias-label-secondary)' } }, t('autoSyncDesc'))
1893
+ ),
1894
+ React.createElement(
1895
+ 'button',
1896
+ {
1897
+ type: 'button',
1898
+ className: `drw-btn ${autoSync ? 'drw-btn-primary' : ''}`,
1899
+ style: { padding: '4px 12px', fontSize: '12px' },
1900
+ onClick: async () => {
1901
+ const next = !autoSync
1902
+ try {
1903
+ const res = await fetch('/dsh-remote-workspace/watcher/toggle', {
1904
+ method: 'POST',
1905
+ headers: { 'Content-Type': 'application/json' },
1906
+ body: JSON.stringify({ enabled: next })
1907
+ })
1908
+ const d = await res.json()
1909
+ if (d.ok) setAutoSync(d.autoSync)
1910
+ } catch (err) { /* best-effort cleanup */ }
1911
+ }
1912
+ },
1913
+ autoSync ? '⚡ Active (ON)' : '⚪ Off'
1914
+ )
1915
+ ),
1916
+
1917
+ React.createElement(
1918
+ 'div',
1919
+ { className: 'drw-row' },
1920
+ React.createElement(
1921
+ 'button',
1922
+ {
1923
+ type: 'button',
1924
+ className: 'drw-btn',
1925
+ disabled: !!busy || !activeProfile.remoteWorkspace || !activeProfile.localMirrorPath,
1926
+ onClick: () => handleSync('pull')
1927
+ },
1928
+ busy === 'sync_pull' ? t('pulling') : t('pullBtn')
1929
+ ),
1930
+ React.createElement(
1931
+ 'button',
1932
+ {
1933
+ type: 'button',
1934
+ className: 'drw-btn',
1935
+ disabled: !!busy || !activeProfile.remoteWorkspace || !activeProfile.localMirrorPath,
1936
+ onClick: () => handleSync('push')
1937
+ },
1938
+ busy === 'sync_push' ? t('pushing') : t('pushBtn')
1939
+ )
1940
+ ),
1941
+ syncMsg
1942
+ ? React.createElement(
1943
+ 'div',
1944
+ {
1945
+ className: 'drw-preview',
1946
+ style: {
1947
+ borderColor: syncMsg.ok ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-state-error-primary)'
1948
+ }
1949
+ },
1950
+ syncMsg.text
1951
+ )
1952
+ : null
1953
+ )
1954
+ : null,
1955
+
1956
+ // Section 4: SSH Port Forwarding (Tunnels Manager)
1957
+ React.createElement(
1958
+ 'div',
1959
+ { className: 'drw-card' },
1960
+ React.createElement('div', { className: 'drw-card-title' }, t('tunnelsTitle')),
1961
+ React.createElement('div', { className: 'drw-card-desc' }, t('tunnelsDesc')),
1962
+
1963
+ // Start tunnel inline row
1964
+ activeProfile
1965
+ ? React.createElement(
1966
+ 'div',
1967
+ { className: 'drw-row', style: { alignItems: 'flex-end', background: 'var(--dsw-alias-bg-layer-2)', padding: '10px 12px', borderRadius: '8px' } },
1968
+ React.createElement(
1969
+ 'div',
1970
+ { style: { display: 'flex', flexDirection: 'column', gap: '3px' } },
1971
+ React.createElement('span', { className: 'drw-label' }, t('tLocalPort')),
1972
+ React.createElement('input', {
1973
+ className: 'drw-input',
1974
+ style: { width: '120px' },
1975
+ type: 'number',
1976
+ value: newTunnelLocal,
1977
+ onChange: (e) => setNewTunnelLocal(e.target.value)
1978
+ })
1979
+ ),
1980
+ React.createElement('span', { style: { paddingBottom: '8px', color: 'var(--dsw-alias-label-secondary)' } }, '→'),
1981
+ React.createElement(
1982
+ 'div',
1983
+ { style: { display: 'flex', flexDirection: 'column', gap: '3px' } },
1984
+ React.createElement('span', { className: 'drw-label' }, t('tRemotePort')),
1985
+ React.createElement('input', {
1986
+ className: 'drw-input',
1987
+ style: { width: '120px' },
1988
+ type: 'number',
1989
+ value: newTunnelRemote,
1990
+ onChange: (e) => setNewTunnelRemote(e.target.value)
1991
+ })
1992
+ ),
1993
+ React.createElement(
1994
+ 'button',
1995
+ {
1996
+ type: 'button',
1997
+ className: 'drw-btn drw-btn-primary',
1998
+ disabled: busy === 'tunnel_open',
1999
+ onClick: handleStartTunnel
2000
+ },
2001
+ busy === 'tunnel_open' ? t('tOpening') : t('tOpenBtn')
2002
+ )
2003
+ )
2004
+ : null,
2005
+
2006
+ tunnelMsg
2007
+ ? React.createElement(
2008
+ 'div',
2009
+ {
2010
+ className: 'drw-preview',
2011
+ style: {
2012
+ borderColor: tunnelMsg.ok ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-state-error-primary)'
2013
+ }
2014
+ },
2015
+ tunnelMsg.text
2016
+ )
2017
+ : null,
2018
+
2019
+ // Tunnels Table
2020
+ tunnels.length > 0
2021
+ ? React.createElement(
2022
+ 'table',
2023
+ { className: 'drw-table' },
2024
+ React.createElement(
2025
+ 'thead',
2026
+ null,
2027
+ React.createElement(
2028
+ 'tr',
2029
+ null,
2030
+ React.createElement('th', null, t('tunnelsColId')),
2031
+ React.createElement('th', null, t('tunnelsColRoute')),
2032
+ React.createElement('th', { style: { textAlign: 'right' } }, t('tunnelsColActions'))
2033
+ )
2034
+ ),
2035
+ React.createElement(
2036
+ 'tbody',
2037
+ null,
2038
+ tunnels.map((tun) =>
2039
+ React.createElement(
2040
+ 'tr',
2041
+ { key: tun.id },
2042
+ React.createElement('td', { style: { fontFamily: 'monospace', fontSize: '12px' } }, tun.id),
2043
+ React.createElement(
2044
+ 'td',
2045
+ null,
2046
+ React.createElement('span', { className: 'drw-badge drw-badge-ok' }, `127.0.0.1:${tun.localPort}`),
2047
+ ' → ',
2048
+ React.createElement('span', { className: 'drw-badge' }, `${tun.targetHost || '127.0.0.1'}:${tun.remotePort}`)
2049
+ ),
2050
+ React.createElement(
2051
+ 'td',
2052
+ { style: { textAlign: 'right' } },
2053
+ React.createElement(
2054
+ 'button',
2055
+ {
2056
+ type: 'button',
2057
+ className: 'drw-btn drw-btn-danger',
2058
+ style: { fontSize: '11px', padding: '3px 8px' },
2059
+ onClick: () => handleStopTunnel(tun.id)
2060
+ },
2061
+ t('tStopBtn')
2062
+ )
2063
+ )
2064
+ )
2065
+ )
2066
+ )
2067
+ )
2068
+ : React.createElement('div', { style: { fontSize: '13px', color: 'var(--dsw-alias-label-secondary)' } }, t('tNoTunnels'))
2069
+ )
2070
+ )
2071
+ }
2072
+
2073
+ // Accordion item for Settings -> Plugins section
2074
+ function UpdaterSection(props) {
2075
+ const t = props.t || ((k) => k);
2076
+ const [updateStatus, setUpdateStatus] = React.useState(null);
2077
+ const [loading, setLoading] = React.useState(false);
2078
+ const [updating, setUpdating] = React.useState(false);
2079
+ const [msg, setMsg] = React.useState(null);
2080
+
2081
+ const checkUpdate = React.useCallback(async () => {
2082
+ setLoading(true);
2083
+ setMsg(null);
2084
+ try {
2085
+ const res = await fetch('/dsh-remote-workspace/update', {
2086
+ headers: { accept: 'application/json' },
2087
+ cache: 'no-store'
2088
+ });
2089
+ if (!res.ok) throw new Error('HTTP ' + res.status);
2090
+ const data = await res.json();
2091
+ setUpdateStatus(data);
2092
+ } catch (e) {
2093
+ setMsg({ ok: false, text: (t('updateFailed') || 'Failed: ') + (e?.message || String(e)) });
2094
+ } finally {
2095
+ setLoading(false);
2096
+ }
2097
+ }, [t]);
2098
+
2099
+ const doUpdate = async () => {
2100
+ setUpdating(true);
2101
+ setMsg(null);
2102
+ try {
2103
+ const res = await fetch('/dsh-remote-workspace/update', {
2104
+ method: 'POST',
2105
+ headers: {
2106
+ 'x-dsh-plugin-update': '1',
2107
+ 'content-type': 'application/json'
2108
+ }
2109
+ });
2110
+ const data = await res.json();
2111
+ if (!res.ok) throw new Error(data.error || ('HTTP ' + res.status));
2112
+ setUpdateStatus(data);
2113
+ if (data.restartRequired) {
2114
+ setMsg({ ok: true, text: t('restartRequired') });
2115
+ }
2116
+ } catch (e) {
2117
+ setMsg({ ok: false, text: (t('updateFailed') || 'Update failed: ') + (e?.message || String(e)) });
2118
+ } finally {
2119
+ setUpdating(false);
2120
+ }
2121
+ };
2122
+
2123
+ React.useEffect(() => {
2124
+ checkUpdate();
2125
+ }, [checkUpdate]);
2126
+
2127
+ return React.createElement(
2128
+ 'div',
2129
+ {
2130
+ style: {
2131
+ display: 'flex',
2132
+ alignItems: 'center',
2133
+ justifyContent: 'space-between',
2134
+ padding: '10px 14px',
2135
+ marginBottom: '14px',
2136
+ borderRadius: '8px',
2137
+ background: 'var(--dsw-alias-bg-layer-2)',
2138
+ border: '1px solid var(--dsw-alias-border-l2)',
2139
+ fontSize: '13px'
2140
+ }
2141
+ },
2142
+ React.createElement(
2143
+ 'div',
2144
+ { style: { display: 'flex', alignItems: 'center', gap: '8px' } },
2145
+ React.createElement('span', null, '📦'),
2146
+ React.createElement(
2147
+ 'div',
2148
+ null,
2149
+ React.createElement('span', { style: { fontWeight: 500 } }, 'v' + (updateStatus?.currentVersion || '0.3.1')),
2150
+ updateStatus?.latestVersion && updateStatus.latestVersion !== updateStatus.currentVersion
2151
+ ? React.createElement('span', { style: { marginLeft: '8px', color: 'var(--dsw-alias-state-warning-text)' } }, '→ v' + updateStatus.latestVersion)
2152
+ : null,
2153
+ msg
2154
+ ? React.createElement('div', { style: { fontSize: '11px', marginTop: '3px', color: msg.ok ? 'var(--dsw-alias-state-success-text)' : 'var(--dsw-alias-state-error-text)' } }, msg.text)
2155
+ : null
2156
+ )
2157
+ ),
2158
+ React.createElement(
2159
+ 'div',
2160
+ { style: { display: 'flex', gap: '8px' } },
2161
+ updateStatus?.updateAvailable
2162
+ ? React.createElement(
2163
+ 'button',
2164
+ {
2165
+ type: 'button',
2166
+ className: 'drw-btn drw-btn-primary',
2167
+ disabled: updating,
2168
+ onClick: doUpdate,
2169
+ style: { fontSize: '12px', padding: '4px 10px' }
2170
+ },
2171
+ updating ? t('updating') : t('updateNow')
2172
+ )
2173
+ : React.createElement(
2174
+ 'button',
2175
+ {
2176
+ type: 'button',
2177
+ className: 'drw-btn',
2178
+ disabled: loading,
2179
+ onClick: checkUpdate,
2180
+ style: { fontSize: '12px', padding: '4px 10px' }
2181
+ },
2182
+ loading ? t('checking') : (updateStatus?.updateAvailable === false ? t('upToDate') : t('checkUpdate'))
2183
+ )
2184
+ )
2185
+ );
2186
+ }
2187
+
2188
+ function PluginCard(props) {
2189
+ const [open, setOpen] = React.useState(false)
2190
+ const t = props.t || (props.locale === 'zh' ? makeT(zh, en) : makeT(en, zh))
2191
+
2192
+ React.useEffect(() => {
2193
+ ensureCss()
2194
+ }, [])
2195
+
2196
+ return React.createElement(
2197
+ 'li',
2198
+ { className: 'drw-card', style: { listStyle: 'none', marginBottom: '12px' } },
2199
+ React.createElement(
2200
+ 'button',
2201
+ {
2202
+ type: 'button',
2203
+ style: {
2204
+ background: 'none',
2205
+ border: 'none',
2206
+ cursor: 'pointer',
2207
+ display: 'flex',
2208
+ alignItems: 'center',
2209
+ width: '100%',
2210
+ padding: 0,
2211
+ textAlign: 'left',
2212
+ },
2213
+ 'aria-expanded': open,
2214
+ onClick: () => setOpen((v) => !v),
2215
+ },
2216
+ React.createElement('span', { style: { fontSize: '20px', marginRight: '12px' } }, '🌐'),
2217
+ React.createElement(
2218
+ 'div',
2219
+ { style: { flex: 1 } },
2220
+ React.createElement('div', { style: { fontWeight: 600, fontSize: '15px', color: 'var(--dsw-alias-label-primary)' } }, t('title')),
2221
+ React.createElement('div', { style: { fontSize: '13px', color: 'var(--dsw-alias-label-secondary)' } }, t('subtitle'))
2222
+ ),
2223
+ React.createElement('span', { className: 'drw-badge drw-badge-ok', style: { marginRight: '14px' } }, t('status')),
2224
+ React.createElement(
2225
+ 'span',
2226
+ { style: { transform: open ? 'rotate(180deg)' : 'none', transition: 'transform .16s' } },
2227
+ React.createElement(FallbackChevron)
2228
+ )
2229
+ ),
2230
+ open
2231
+ ? React.createElement(
2232
+ 'div',
2233
+ { style: { marginTop: '16px', borderTop: '1px solid var(--dsw-alias-border-l2)', paddingTop: '16px' } },
2234
+ React.createElement(React.Fragment, null, React.createElement(UpdaterSection, props), React.createElement(SettingsView, props))
2235
+ )
2236
+ : null
2237
+ )
2238
+ }
2239
+
2240
+ function RemoteWorkspaceChip(props) {
2241
+ ensureCss()
2242
+ const [activeHost, setActiveHost] = React.useState(null)
2243
+
2244
+ React.useEffect(() => {
2245
+ fetch('/dsh-remote-workspace/state')
2246
+ .then((r) => r.json())
2247
+ .then((d) => {
2248
+ if (d.ok && d.activeId && d.profiles) {
2249
+ const f = d.profiles.find((p) => p.id === d.activeId)
2250
+ if (f) setActiveHost(f.name || f.host)
2251
+ }
2252
+ })
2253
+ .catch(() => {})
2254
+ }, [])
2255
+
2256
+ return React.createElement(
2257
+ 'div',
2258
+ {
2259
+ style: {
2260
+ display: 'flex',
2261
+ alignItems: 'center',
2262
+ gap: '6px',
2263
+ padding: '2px 8px',
2264
+ fontSize: '11px',
2265
+ fontFamily: 'monospace',
2266
+ borderRadius: '999px',
2267
+ border: '1px solid var(--dsw-alias-border-l2)',
2268
+ background: 'var(--dsw-alias-bg-layer-1)',
2269
+ color: activeHost ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-label-secondary)',
2270
+ cursor: 'pointer'
2271
+ }
2272
+ },
2273
+ React.createElement('span', null, '🌐'),
2274
+ React.createElement('span', null, activeHost ? `SSH: ${activeHost}` : 'SSH: Local')
2275
+ )
2276
+ }
2277
+
2278
+ function apply(ctx) {
2279
+ if (ctx.locale && typeof ctx.locale.register === 'function') {
2280
+ if (typeof ctx.effect === 'function') {
2281
+ ctx.effect(() => ctx.locale.register(NS, { en, zh }), 'dsh-remote-workspace: dictionaries');
2282
+ } else {
2283
+ ctx.locale.register(NS, { en, zh });
2284
+ }
2285
+ }
2286
+
2287
+ if (ctx.slots && typeof ctx.slots.inject === 'function') {
2288
+ ctx.slots.inject('settings.plugin.item', () =>
2289
+ ctx.slots.register(
2290
+ {
2291
+ name: 'settings.plugin.item',
2292
+ key: NS,
2293
+ locale: NS,
2294
+ inject: () => ({ ctx })
2295
+ },
2296
+ (props) => React.createElement(PluginCard, Object.assign({}, props, { ctx }))
2297
+ )
2298
+ )
2299
+
2300
+ ctx.slots.inject('conversation.session.header.utilities', () =>
2301
+ ctx.slots.register(
2302
+ {
2303
+ name: 'conversation.session.header.utilities',
2304
+ id: '@goodandready/dsh-remote-workspace',
2305
+ order: 30
2306
+ },
2307
+ (props) => React.createElement(RemoteWorkspaceChip, props)
2308
+ )
2309
+ )
2310
+ }
2311
+ }
2312
+
2313
+ module.exports = { apply, inject: ['slots', 'locale'] }
2314
+ return module.exports
2315
+ }
2316
+ })