@wangnanshan/dsh-nanshan-session-manager 0.0.0-stage → 1.1.6
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/LICENSE +21 -0
- package/README.md +157 -2
- package/client.js +2086 -0
- package/cordis.patch.yml +3 -0
- package/icon.svg +68 -0
- package/index.js +1440 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +51 -4
package/client.js
ADDED
|
@@ -0,0 +1,2086 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: '@wangnanshan/dsh-nanshan-session-manager',
|
|
3
|
+
factory(require) {
|
|
4
|
+
const React = require('react');
|
|
5
|
+
const h = React.createElement;
|
|
6
|
+
|
|
7
|
+
const PANEL_ID = 'nanshan-session-manager';
|
|
8
|
+
const API = '/api/nanshan-session-manager';
|
|
9
|
+
const NS = 'nanshan-session-manager';
|
|
10
|
+
const PACKAGE_NAME = '@wangnanshan/dsh-nanshan-session-manager';
|
|
11
|
+
const FILTERS = ['all', 'running', 'open', 'archived', 'subagent', 'pinned', 'migration'];
|
|
12
|
+
|
|
13
|
+
const DICTIONARIES = {
|
|
14
|
+
zh: {
|
|
15
|
+
'nav.title': '【南山】会话管理',
|
|
16
|
+
'page.title': '【南山】会话管理',
|
|
17
|
+
'page.subtitle': '把本机所有会话收进一棵树:按状态筛选、按 ID 搜索、导出导入,删除后还能从回收站恢复。',
|
|
18
|
+
'action.import': '导入会话',
|
|
19
|
+
'action.importing': '正在导入…',
|
|
20
|
+
'action.export': '导出',
|
|
21
|
+
'action.exportAll': '导出全部',
|
|
22
|
+
'action.exportSelected': '导出选中',
|
|
23
|
+
'action.delete': '删除',
|
|
24
|
+
'action.deleteSelected': '删除选中',
|
|
25
|
+
'action.refresh': '刷新',
|
|
26
|
+
'action.back': '返回对话',
|
|
27
|
+
'action.open': '打开会话',
|
|
28
|
+
'action.cancel': '取消',
|
|
29
|
+
'action.confirmDelete': '移入回收站',
|
|
30
|
+
'action.retry': '重新加载',
|
|
31
|
+
'action.selectAll': '全选可见',
|
|
32
|
+
'action.clearSelection': '清空选择',
|
|
33
|
+
'action.expandAll': '全部展开',
|
|
34
|
+
'action.collapseAll': '全部收起',
|
|
35
|
+
'action.close': '关闭',
|
|
36
|
+
'action.copyId': '复制会话 ID',
|
|
37
|
+
'action.dismiss': '知道了',
|
|
38
|
+
'action.copyPackage': '复制插件包名',
|
|
39
|
+
'search.placeholder': '搜索会话 ID…',
|
|
40
|
+
'search.clear': '清空搜索',
|
|
41
|
+
'stats.total': '会话总数',
|
|
42
|
+
'stats.live': '占用中',
|
|
43
|
+
'stats.groups': '分组',
|
|
44
|
+
'stats.size': '占用空间',
|
|
45
|
+
'tree.title': '全部会话',
|
|
46
|
+
'tree.ungrouped': '未分组',
|
|
47
|
+
'tree.noPath': '未记录路径',
|
|
48
|
+
'tree.count': '{n} 个会话',
|
|
49
|
+
'tree.countOne': '1 个会话',
|
|
50
|
+
'tree.monthCount': '{n} 个',
|
|
51
|
+
'tree.emptyFiltered': '没有匹配的会话',
|
|
52
|
+
'tree.emptyFilteredBody': '换一个关键词,或清空搜索查看全部。',
|
|
53
|
+
'status.live': '进行中',
|
|
54
|
+
'status.open': '已打开',
|
|
55
|
+
'status.archived': '已归档',
|
|
56
|
+
'status.subagent': '子代理',
|
|
57
|
+
'status.pinned': '置顶',
|
|
58
|
+
'status.migration': '待迁移',
|
|
59
|
+
'untitled': '未命名会话',
|
|
60
|
+
'empty.title': '还没有会话',
|
|
61
|
+
'empty.body': '开始一段对话后,它会出现在这里;也可以导入之前导出的备份。',
|
|
62
|
+
'empty.cta': '导入备份',
|
|
63
|
+
'loading': '正在整理会话树…',
|
|
64
|
+
'error.load': '没能读取会话列表。',
|
|
65
|
+
'error.action': '操作失败,请稍后再试。',
|
|
66
|
+
'selection.count': '已选 {n} 个',
|
|
67
|
+
'selection.size': '共 {size}',
|
|
68
|
+
'selection.hint': '使用中的会话也可以删除:会先停止并归档隐藏,日志在 DSH 重启后移除,期间可在回收站恢复。',
|
|
69
|
+
'selection.none': '还没有选择会话',
|
|
70
|
+
'selection.export': '导出这些会话',
|
|
71
|
+
'selection.delete': '删除这些会话',
|
|
72
|
+
'selection.liveBlocked': '选中的会话正在使用中,暂时不能删除。',
|
|
73
|
+
'detail.title': '会话详情',
|
|
74
|
+
'detail.empty': '点一条会话,在这里查看它的路径、时间与大小。',
|
|
75
|
+
'detail.workspace': '工作区',
|
|
76
|
+
'detail.path': '目录',
|
|
77
|
+
'detail.created': '创建于',
|
|
78
|
+
'detail.updated': '最近活动',
|
|
79
|
+
'detail.size': '日志大小',
|
|
80
|
+
'detail.id': '会话 ID',
|
|
81
|
+
'detail.turns': '轮次',
|
|
82
|
+
'detail.preset': '代理预设',
|
|
83
|
+
'detail.noPath': '—',
|
|
84
|
+
'import.title': '导入会话备份',
|
|
85
|
+
'import.hint': '支持本插件导出的 .json 备份;可以一次选择多个文件,也可以直接拖进页面。',
|
|
86
|
+
'import.drop': '松开以导入会话备份',
|
|
87
|
+
'import.dropHint': '会话会写回它原来的工作区;重复的 ID 会自动跳过。',
|
|
88
|
+
'import.reading': '正在读取备份…',
|
|
89
|
+
'import.report': '导入结果',
|
|
90
|
+
'import.imported': '已导入 {n}',
|
|
91
|
+
'import.skipped': '跳过 {n}',
|
|
92
|
+
'import.failed': '失败 {n}',
|
|
93
|
+
'delete.title.one': '删除这个会话?',
|
|
94
|
+
'delete.title.many': '删除这 {n} 个会话?',
|
|
95
|
+
'delete.warning': '会话会先移入回收站,可随时恢复;只有彻底删除才会永久移除日志。使用中的会话会先停止并归档隐藏。',
|
|
96
|
+
'delete.liveNote': '另有 {n} 个会话正在使用。',
|
|
97
|
+
'delete.more': '还有 {n} 个…',
|
|
98
|
+
'toast.exportStarted': '已开始导出备份',
|
|
99
|
+
'toast.deleted': '已移入回收站:{n} 个会话',
|
|
100
|
+
'toast.imported': '已导入 {n} 个会话',
|
|
101
|
+
'toast.refreshed': '列表已刷新',
|
|
102
|
+
'toast.openUnavailable': '暂时无法打开会话,请从左侧会话列表进入。',
|
|
103
|
+
'toast.copied': '已复制',
|
|
104
|
+
'toast.noExport': '没有可导出的会话。',
|
|
105
|
+
'toast.partial': '完成,但有 {n} 项被跳过或失败。',
|
|
106
|
+
'footer.storage': '会话目录',
|
|
107
|
+
'footer.package': '插件包名:',
|
|
108
|
+
'footer.note': '删除会先进入回收站;彻底删除才移除本机日志。',
|
|
109
|
+
'view.sessions': '会话树',
|
|
110
|
+
'view.trash': '回收站',
|
|
111
|
+
'filter.label': '状态筛选',
|
|
112
|
+
'filter.all': '全部',
|
|
113
|
+
'filter.running': '进行中',
|
|
114
|
+
'filter.open': '已打开',
|
|
115
|
+
'filter.archived': '已归档',
|
|
116
|
+
'filter.subagent': '子代理',
|
|
117
|
+
'filter.pinned': '置顶',
|
|
118
|
+
'filter.migration': '待迁移',
|
|
119
|
+
'status.deleted': '已删除',
|
|
120
|
+
'status.pendingDelete': '延迟删除',
|
|
121
|
+
'trash.title': '回收站',
|
|
122
|
+
'trash.count': '{n} 个已删除会话',
|
|
123
|
+
'trash.countOne': '1 个已删除会话',
|
|
124
|
+
'trash.empty': '回收站是空的',
|
|
125
|
+
'trash.emptyBody': '删除的会话会先来到这里,可以恢复或彻底删除。',
|
|
126
|
+
'trash.pending': '延迟删除',
|
|
127
|
+
'trash.pendingPurge': '会话仍在使用,重启 DSH 后才能彻底删除。',
|
|
128
|
+
'trash.pendingHint': '会话仍在使用:已从会话树和原生侧栏隐藏,日志会在 DSH 重启后移除。在此期间可以恢复。',
|
|
129
|
+
'trash.deletedAt': '删除于',
|
|
130
|
+
'trash.originalPath': '原目录',
|
|
131
|
+
'trash.restore': '恢复',
|
|
132
|
+
'trash.purge': '彻底删除',
|
|
133
|
+
'trash.purgeTitle': '彻底删除这 {n} 个会话?',
|
|
134
|
+
'trash.restoreSelected': '恢复选中',
|
|
135
|
+
'trash.purgeSelected': '彻底删除选中',
|
|
136
|
+
'trash.restoreHint': '恢复后回到原工作区;删除前已归档的会话会保持归档状态。',
|
|
137
|
+
'trash.purgeHint': '彻底删除不会保留日志,无法恢复。',
|
|
138
|
+
'trash.wasLive': '删除前使用中',
|
|
139
|
+
'trash.wasRunning': '删除前进行中',
|
|
140
|
+
'trash.wasArchived': '删除前已归档',
|
|
141
|
+
'trash.detail': '已删除会话',
|
|
142
|
+
'trash.deletedGroup': '{label} 删除',
|
|
143
|
+
'action.restore': '恢复',
|
|
144
|
+
'action.purge': '彻底删除',
|
|
145
|
+
'action.undo': '撤销',
|
|
146
|
+
'toast.movedToTrash': '已移入回收站:{n} 个会话',
|
|
147
|
+
'toast.movedPending': '{n} 个使用中的会话已隐藏,重启 DSH 后移除日志',
|
|
148
|
+
'toast.restored': '已恢复 {n} 个会话',
|
|
149
|
+
'toast.purged': '已彻底删除 {n} 个会话',
|
|
150
|
+
'delete.activeNote': '其中 {n} 个会话正在使用:会先停止当前工作并归档隐藏,日志将在 DSH 重启后移除。可随时从回收站恢复。',
|
|
151
|
+
'delete.pendingNote': '这些会话已从会话树和原生侧栏隐藏,可在回收站恢复。',
|
|
152
|
+
'delete.confirmStopDelete': '停止并删除',
|
|
153
|
+
'search.trashPlaceholder': '搜索已删除会话的 ID…',
|
|
154
|
+
'selection.trashHint': '恢复会回到原工作区;彻底删除后无法恢复。',
|
|
155
|
+
'error.restore': '恢复会话失败。',
|
|
156
|
+
'error.purge': '彻底删除失败。',
|
|
157
|
+
'stats.trash': '回收站',
|
|
158
|
+
'relative.justNow': '刚刚',
|
|
159
|
+
'relative.minutes': '{n} 分钟前',
|
|
160
|
+
'relative.hours': '{n} 小时前',
|
|
161
|
+
'relative.days': '{n} 天前',
|
|
162
|
+
},
|
|
163
|
+
en: {
|
|
164
|
+
'nav.title': '【南山】Sessions',
|
|
165
|
+
'page.title': '【南山】Sessions',
|
|
166
|
+
'page.subtitle': 'Every session in one tree: filter by state, search by ID, export, import, and recover deleted sessions from Trash.',
|
|
167
|
+
'action.import': 'Import',
|
|
168
|
+
'action.importing': 'Importing…',
|
|
169
|
+
'action.export': 'Export',
|
|
170
|
+
'action.exportAll': 'Export all',
|
|
171
|
+
'action.exportSelected': 'Export selected',
|
|
172
|
+
'action.delete': 'Delete',
|
|
173
|
+
'action.deleteSelected': 'Delete selected',
|
|
174
|
+
'action.refresh': 'Refresh',
|
|
175
|
+
'action.back': 'Back to conversation',
|
|
176
|
+
'action.open': 'Open session',
|
|
177
|
+
'action.cancel': 'Cancel',
|
|
178
|
+
'action.confirmDelete': 'Move to Trash',
|
|
179
|
+
'action.retry': 'Try again',
|
|
180
|
+
'action.selectAll': 'Select visible',
|
|
181
|
+
'action.clearSelection': 'Clear selection',
|
|
182
|
+
'action.expandAll': 'Expand all',
|
|
183
|
+
'action.collapseAll': 'Collapse all',
|
|
184
|
+
'action.close': 'Close',
|
|
185
|
+
'action.copyId': 'Copy session ID',
|
|
186
|
+
'action.dismiss': 'Dismiss',
|
|
187
|
+
'action.copyPackage': 'Copy plugin package name',
|
|
188
|
+
'search.placeholder': 'Search session ID…',
|
|
189
|
+
'search.clear': 'Clear search',
|
|
190
|
+
'stats.total': 'Sessions',
|
|
191
|
+
'stats.live': 'In use',
|
|
192
|
+
'stats.groups': 'Groups',
|
|
193
|
+
'stats.size': 'On disk',
|
|
194
|
+
'tree.title': 'All sessions',
|
|
195
|
+
'tree.ungrouped': 'Ungrouped',
|
|
196
|
+
'tree.noPath': 'No recorded path',
|
|
197
|
+
'tree.count': '{n} sessions',
|
|
198
|
+
'tree.countOne': '1 session',
|
|
199
|
+
'tree.monthCount': '{n}',
|
|
200
|
+
'tree.emptyFiltered': 'No matching sessions',
|
|
201
|
+
'tree.emptyFilteredBody': 'Try another keyword, or clear the search to see everything.',
|
|
202
|
+
'status.live': 'Running',
|
|
203
|
+
'status.open': 'Open',
|
|
204
|
+
'status.archived': 'Archived',
|
|
205
|
+
'status.subagent': 'Subagent',
|
|
206
|
+
'status.pinned': 'Pinned',
|
|
207
|
+
'status.migration': 'Migration',
|
|
208
|
+
'untitled': 'Untitled session',
|
|
209
|
+
'empty.title': 'No sessions yet',
|
|
210
|
+
'empty.body': 'Start a conversation and it appears here, or import a backup you exported earlier.',
|
|
211
|
+
'empty.cta': 'Import a backup',
|
|
212
|
+
'loading': 'Building the session tree…',
|
|
213
|
+
'error.load': 'The session list could not be read.',
|
|
214
|
+
'error.action': 'The action failed. Please try again.',
|
|
215
|
+
'selection.count': '{n} selected',
|
|
216
|
+
'selection.size': '{size} total',
|
|
217
|
+
'selection.hint': 'Sessions in use can be deleted too: they are stopped and hidden first, then removed after DSH restarts. Restore them from Trash meanwhile.',
|
|
218
|
+
'selection.none': 'No session selected',
|
|
219
|
+
'selection.export': 'Export these sessions',
|
|
220
|
+
'selection.delete': 'Delete these sessions',
|
|
221
|
+
'selection.liveBlocked': 'The selected sessions are currently in use and cannot be deleted.',
|
|
222
|
+
'detail.title': 'Session details',
|
|
223
|
+
'detail.empty': 'Pick a session to inspect its path, times, and size.',
|
|
224
|
+
'detail.workspace': 'Workspace',
|
|
225
|
+
'detail.path': 'Directory',
|
|
226
|
+
'detail.created': 'Created',
|
|
227
|
+
'detail.updated': 'Last activity',
|
|
228
|
+
'detail.size': 'Log size',
|
|
229
|
+
'detail.id': 'Session ID',
|
|
230
|
+
'detail.turns': 'Turns',
|
|
231
|
+
'detail.preset': 'Agent preset',
|
|
232
|
+
'detail.noPath': '—',
|
|
233
|
+
'import.title': 'Import session backups',
|
|
234
|
+
'import.hint': 'Use the .json backups exported by this plugin. Choose several files at once, or drop them anywhere on this page.',
|
|
235
|
+
'import.drop': 'Drop to import session backups',
|
|
236
|
+
'import.dropHint': 'Sessions return to their original workspace; duplicate IDs are skipped.',
|
|
237
|
+
'import.reading': 'Reading the backup…',
|
|
238
|
+
'import.report': 'Import result',
|
|
239
|
+
'import.imported': '{n} imported',
|
|
240
|
+
'import.skipped': '{n} skipped',
|
|
241
|
+
'import.failed': '{n} failed',
|
|
242
|
+
'delete.title.one': 'Delete this session?',
|
|
243
|
+
'delete.title.many': 'Delete these {n} sessions?',
|
|
244
|
+
'delete.warning': 'Sessions move to Trash first and can be restored. Only permanent deletion removes logs. Sessions in use are stopped and hidden first.',
|
|
245
|
+
'delete.liveNote': '{n} sessions are currently in use.',
|
|
246
|
+
'delete.more': 'and {n} more…',
|
|
247
|
+
'toast.exportStarted': 'Backup export started',
|
|
248
|
+
'toast.deleted': '{n} sessions moved to Trash',
|
|
249
|
+
'toast.imported': '{n} sessions imported',
|
|
250
|
+
'toast.refreshed': 'List refreshed',
|
|
251
|
+
'toast.openUnavailable': 'The conversation could not be opened from here; use the left sidebar instead.',
|
|
252
|
+
'toast.copied': 'Copied',
|
|
253
|
+
'toast.noExport': 'There is nothing to export.',
|
|
254
|
+
'toast.partial': 'Finished, but {n} item(s) were skipped or failed.',
|
|
255
|
+
'footer.storage': 'Session directory',
|
|
256
|
+
'footer.package': 'Plugin package: ',
|
|
257
|
+
'footer.note': 'Deleted sessions go to Trash first; only permanent deletion removes local logs.',
|
|
258
|
+
'view.sessions': 'Sessions',
|
|
259
|
+
'view.trash': 'Trash',
|
|
260
|
+
'filter.label': 'Filter by state',
|
|
261
|
+
'filter.all': 'All',
|
|
262
|
+
'filter.running': 'Running',
|
|
263
|
+
'filter.open': 'Open',
|
|
264
|
+
'filter.archived': 'Archived',
|
|
265
|
+
'filter.subagent': 'Subagent',
|
|
266
|
+
'filter.pinned': 'Pinned',
|
|
267
|
+
'filter.migration': 'Migration',
|
|
268
|
+
'status.deleted': 'Deleted',
|
|
269
|
+
'status.pendingDelete': 'Pending delete',
|
|
270
|
+
'trash.title': 'Trash',
|
|
271
|
+
'trash.count': '{n} deleted sessions',
|
|
272
|
+
'trash.countOne': '1 deleted session',
|
|
273
|
+
'trash.empty': 'Trash is empty',
|
|
274
|
+
'trash.emptyBody': 'Deleted sessions land here first; restore them or delete them permanently.',
|
|
275
|
+
'trash.pending': 'Pending delete',
|
|
276
|
+
'trash.pendingPurge': 'This session is still in use; permanently delete it after DSH restarts.',
|
|
277
|
+
'trash.pendingHint': 'This session is still in use. It is hidden here and from the native sidebar; its log is removed after DSH restarts. You can restore it meanwhile.',
|
|
278
|
+
'trash.deletedAt': 'Deleted',
|
|
279
|
+
'trash.originalPath': 'Original directory',
|
|
280
|
+
'trash.restore': 'Restore',
|
|
281
|
+
'trash.purge': 'Delete permanently',
|
|
282
|
+
'trash.purgeTitle': 'Permanently delete these {n} sessions?',
|
|
283
|
+
'trash.restoreSelected': 'Restore selected',
|
|
284
|
+
'trash.purgeSelected': 'Delete selected permanently',
|
|
285
|
+
'trash.restoreHint': 'Restored sessions return to their workspace; a session archived before deletion stays archived.',
|
|
286
|
+
'trash.purgeHint': 'Permanent deletion keeps no log and cannot be undone.',
|
|
287
|
+
'trash.wasLive': 'In use when deleted',
|
|
288
|
+
'trash.wasRunning': 'Running when deleted',
|
|
289
|
+
'trash.wasArchived': 'Archived when deleted',
|
|
290
|
+
'trash.detail': 'Deleted session',
|
|
291
|
+
'trash.deletedGroup': 'Deleted {label}',
|
|
292
|
+
'action.restore': 'Restore',
|
|
293
|
+
'action.purge': 'Delete permanently',
|
|
294
|
+
'action.undo': 'Undo',
|
|
295
|
+
'toast.movedToTrash': '{n} sessions moved to Trash',
|
|
296
|
+
'toast.movedPending': '{n} sessions in use are hidden and will be removed after DSH restarts',
|
|
297
|
+
'toast.restored': '{n} sessions restored',
|
|
298
|
+
'toast.purged': '{n} sessions permanently deleted',
|
|
299
|
+
'delete.activeNote': '{n} session(s) are in use: they are stopped and hidden first, and their logs are removed after DSH restarts. Restore them from Trash meanwhile.',
|
|
300
|
+
'delete.pendingNote': 'These sessions are hidden from the session tree and native sidebar; restore them from Trash.',
|
|
301
|
+
'delete.confirmStopDelete': 'Stop and delete',
|
|
302
|
+
'search.trashPlaceholder': 'Search deleted session ID…',
|
|
303
|
+
'selection.trashHint': 'Restore returns sessions to their workspace; permanent deletion cannot be undone.',
|
|
304
|
+
'error.restore': 'Restoring the session failed.',
|
|
305
|
+
'error.purge': 'Permanent deletion failed.',
|
|
306
|
+
'stats.trash': 'Trash',
|
|
307
|
+
'relative.justNow': 'just now',
|
|
308
|
+
'relative.minutes': '{n} min ago',
|
|
309
|
+
'relative.hours': '{n} h ago',
|
|
310
|
+
'relative.days': '{n} d ago',
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
const STYLES = `
|
|
315
|
+
.nsm {
|
|
316
|
+
--nsm-bg: var(--dsw-alias-bg-base);
|
|
317
|
+
--nsm-surface: var(--dsw-alias-bg-layer-1);
|
|
318
|
+
--nsm-muted-surface: var(--dsw-alias-bg-module-platform);
|
|
319
|
+
--nsm-border: var(--dsw-alias-border-l3);
|
|
320
|
+
--nsm-border-strong: var(--dsw-alias-border-l4);
|
|
321
|
+
--nsm-text: var(--dsw-alias-label-primary);
|
|
322
|
+
--nsm-secondary: var(--dsw-alias-label-secondary);
|
|
323
|
+
--nsm-tertiary: var(--dsw-alias-label-tertiary);
|
|
324
|
+
--nsm-hover: var(--dsw-alias-interactive-bg-hover);
|
|
325
|
+
--nsm-accent: var(--dsw-alias-state-business-primary);
|
|
326
|
+
--nsm-accent-soft: color-mix(in srgb, var(--nsm-accent) 9%, transparent);
|
|
327
|
+
--nsm-accent-line: color-mix(in srgb, var(--nsm-accent) 26%, transparent);
|
|
328
|
+
--nsm-danger: var(--dsw-alias-state-error-primary);
|
|
329
|
+
--nsm-danger-soft: color-mix(in srgb, var(--nsm-danger) 8%, transparent);
|
|
330
|
+
--nsm-green: var(--dsw-alias-state-success-primary);
|
|
331
|
+
--nsm-amber: var(--dsw-alias-state-warn-primary);
|
|
332
|
+
--nsm-violet: var(--dsw-alias-state-done-primary);
|
|
333
|
+
--nsm-radius: 9px;
|
|
334
|
+
--nsm-radius-sm: 6px;
|
|
335
|
+
--nsm-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
|
|
336
|
+
height: 100%;
|
|
337
|
+
overflow-y: auto;
|
|
338
|
+
background: var(--nsm-bg);
|
|
339
|
+
color: var(--nsm-text);
|
|
340
|
+
font-family: var(--nsm-font);
|
|
341
|
+
font-size: 13px;
|
|
342
|
+
line-height: 1.5;
|
|
343
|
+
-webkit-font-smoothing: antialiased;
|
|
344
|
+
}
|
|
345
|
+
.nsm *, .nsm *::before, .nsm *::after { box-sizing: border-box; }
|
|
346
|
+
.nsm button, .nsm input { font-family: inherit; }
|
|
347
|
+
.nsm__inner { max-width: 1120px; margin: 0 auto; padding: calc(var(--dsh-frame-top-clearance, 0px) + 28px) 28px 48px; }
|
|
348
|
+
.nsm__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
|
|
349
|
+
.nsm__heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
|
|
350
|
+
.nsm__mark { position: relative; overflow: hidden; display: grid; place-items: center; flex: none; width: 38px; height: 38px; padding: 8px; border: 1px solid rgba(255, 255, 255, .4); border-radius: 9px; background: radial-gradient(120% 90% at 18% 0%, rgba(255, 255, 255, .62), transparent 42%), radial-gradient(80% 80% at 100% 100%, rgba(34, 211, 238, .46), transparent 55%), linear-gradient(145deg, #62b3ff 0%, #2563eb 52%, #172554 100%); color: #fff; box-shadow: 0 10px 22px -10px rgba(37, 99, 235, .85), inset 0 1px 1px rgba(255, 255, 255, .65), inset 0 -10px 18px rgba(2, 6, 23, .28); }
|
|
351
|
+
.nsm__mark::before { content: ""; position: absolute; left: 7px; top: 6px; width: 11px; height: 5px; border-radius: 50%; background: rgba(255, 255, 255, .48); filter: blur(2px); transform: rotate(-18deg); pointer-events: none; }
|
|
352
|
+
.nsm__mark::after { content: ""; position: absolute; inset: 1px 1px 48% 1px; border-radius: 8px 8px 50% 50%; background: linear-gradient(180deg, rgba(255, 255, 255, .34), rgba(255, 255, 255, 0)); pointer-events: none; }
|
|
353
|
+
.nsm__mark svg { position: relative; z-index: 1; filter: drop-shadow(0 1px 1px rgba(2, 6, 23, .25)); }
|
|
354
|
+
.nsm__mark svg { display: block; width: 100%; height: 100%; }
|
|
355
|
+
.nsm__titles { min-width: 0; }
|
|
356
|
+
.nsm__title { margin: 0; font-family: var(--nsm-font); font-size: 24px; font-weight: 600; line-height: 1.2; letter-spacing: -.025em; color: var(--nsm-text); }
|
|
357
|
+
.nsm__subtitle { max-width: 680px; margin: 5px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--nsm-secondary); }
|
|
358
|
+
.nsm__actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
|
|
359
|
+
.nsm__button { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px solid var(--nsm-border-strong); border-radius: 6px; background: var(--nsm-surface); color: var(--nsm-text); font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer; transition: background-color .12s ease, border-color .12s ease, color .12s ease; }
|
|
360
|
+
.nsm__button:hover:not(:disabled) { background: var(--nsm-hover); border-color: var(--nsm-border-strong); }
|
|
361
|
+
.nsm__button:focus-visible { outline: 2px solid var(--nsm-accent); outline-offset: 2px; }
|
|
362
|
+
.nsm__button:disabled { opacity: .42; cursor: not-allowed; }
|
|
363
|
+
.nsm__button--primary { border-color: var(--dsw-alias-button-primary-fill); background: var(--dsw-alias-button-primary-fill); color: var(--dsw-alias-label-primary-foreground); }
|
|
364
|
+
.nsm__button--primary:hover:not(:disabled) { border-color: var(--dsw-alias-button-primary-hover); background: var(--dsw-alias-button-primary-hover); }
|
|
365
|
+
.nsm__button--danger { border-color: color-mix(in srgb, var(--nsm-danger) 26%, transparent); background: transparent; color: var(--nsm-danger); }
|
|
366
|
+
.nsm__button--danger:hover:not(:disabled) { background: var(--nsm-danger-soft); border-color: color-mix(in srgb, var(--nsm-danger) 42%, transparent); }
|
|
367
|
+
.nsm__button--ghost { border-color: transparent; background: transparent; color: var(--nsm-secondary); }
|
|
368
|
+
.nsm__button--ghost:hover:not(:disabled) { background: var(--nsm-hover); color: var(--nsm-text); }
|
|
369
|
+
.nsm__button--small { height: 26px; padding: 0 8px; font-size: 11.5px; }
|
|
370
|
+
.nsm__stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 24px; border: 1px solid var(--nsm-border); border-radius: var(--nsm-radius); background: var(--nsm-surface); overflow: hidden; }
|
|
371
|
+
.nsm__stat { position: relative; padding: 14px 16px; border-left: 1px solid var(--nsm-border); background: transparent; }
|
|
372
|
+
.nsm__stat:first-child { border-left: 0; }
|
|
373
|
+
.nsm__stat::after { display: none; }
|
|
374
|
+
.nsm__stat-label { display: block; font-size: 11px; font-weight: 500; line-height: 1.4; color: var(--nsm-tertiary); }
|
|
375
|
+
.nsm__stat-value { display: block; margin-top: 3px; font-family: var(--nsm-font); font-size: 20px; font-weight: 600; line-height: 1.2; letter-spacing: -.02em; color: var(--nsm-text); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
376
|
+
.nsm__toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding: 8px; border: 1px solid var(--nsm-border); border-radius: var(--nsm-radius); background: var(--nsm-surface); }
|
|
377
|
+
.nsm__viewtabs { display: flex; align-items: center; flex: none; gap: 2px; padding: 2px; border: 1px solid var(--nsm-border); border-radius: var(--nsm-radius-sm); background: var(--nsm-muted-surface); }
|
|
378
|
+
.nsm__viewtab { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 26px; padding: 0 10px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--nsm-secondary); font-size: 11.5px; font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer; }
|
|
379
|
+
.nsm__viewtab:hover { color: var(--nsm-text); background: var(--nsm-hover); }
|
|
380
|
+
.nsm__viewtab:focus-visible { outline: 2px solid var(--nsm-accent); outline-offset: 1px; }
|
|
381
|
+
.nsm__viewtab.is-active { border-color: var(--nsm-border); background: var(--nsm-surface); color: var(--nsm-text); box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
|
|
382
|
+
.nsm__tab-count { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 4px; background: var(--nsm-surface); color: var(--nsm-tertiary); font-size: 9.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
|
|
383
|
+
.nsm__viewtab.is-active .nsm__tab-count { background: var(--nsm-accent-soft); color: var(--nsm-accent); }
|
|
384
|
+
.nsm__search { position: relative; flex: 1 1 260px; min-width: 190px; }
|
|
385
|
+
.nsm__search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--nsm-tertiary); pointer-events: none; }
|
|
386
|
+
.nsm__search input { width: 100%; height: 30px; padding: 0 30px 0 32px; border: 1px solid var(--nsm-border-strong); border-radius: var(--nsm-radius-sm); background: var(--nsm-bg); color: var(--nsm-text); font-size: 12px; outline: none; transition: border-color .12s ease, box-shadow .12s ease; }
|
|
387
|
+
.nsm__search input::placeholder { color: var(--nsm-tertiary); }
|
|
388
|
+
.nsm__search input:focus { border-color: var(--nsm-accent); box-shadow: 0 0 0 3px var(--nsm-accent-soft); }
|
|
389
|
+
.nsm__search-clear { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--nsm-tertiary); cursor: pointer; }
|
|
390
|
+
.nsm__search-clear:hover { background: var(--nsm-hover); color: var(--nsm-text); }
|
|
391
|
+
.nsm__toolbar-spacer { flex: 1 1 auto; }
|
|
392
|
+
.nsm__filters { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
|
|
393
|
+
.nsm__filter { appearance: none; display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--nsm-secondary); font-size: 11px; font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer; }
|
|
394
|
+
.nsm__filter:hover { background: var(--nsm-hover); color: var(--nsm-text); }
|
|
395
|
+
.nsm__filter:focus-visible { outline: 2px solid var(--nsm-accent); outline-offset: 1px; }
|
|
396
|
+
.nsm__filter.is-active { border-color: var(--nsm-accent-line); background: var(--nsm-accent-soft); color: var(--nsm-accent); }
|
|
397
|
+
.nsm__filter-count { color: var(--nsm-tertiary); font-size: 9.5px; font-weight: 400; font-variant-numeric: tabular-nums; }
|
|
398
|
+
.nsm__filter.is-active .nsm__filter-count { color: inherit; opacity: .72; }
|
|
399
|
+
.nsm__layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; margin-top: 16px; }
|
|
400
|
+
.nsm__tree-card { min-width: 0; border: 1px solid var(--nsm-border); border-radius: var(--nsm-radius); background: var(--nsm-surface); overflow: hidden; }
|
|
401
|
+
.nsm__tree-head { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 14px; border-bottom: 1px solid var(--nsm-border); background: transparent; }
|
|
402
|
+
.nsm__tree-head h2 { margin: 0; font-family: var(--nsm-font); font-size: 12.5px; font-weight: 600; line-height: 1.4; letter-spacing: -.01em; color: var(--nsm-text); }
|
|
403
|
+
.nsm__tree-head-meta { margin-left: auto; color: var(--nsm-tertiary); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
404
|
+
.nsm__tree-body { padding: 4px 6px 8px; }
|
|
405
|
+
.nsm__group { margin: 0; border: 0; border-bottom: 1px solid var(--nsm-border); border-radius: 0; background: transparent; overflow: visible; }
|
|
406
|
+
.nsm__group:last-child { border-bottom: 0; }
|
|
407
|
+
.nsm__group-head { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: var(--nsm-radius-sm); cursor: pointer; user-select: none; transition: background-color .12s ease; }
|
|
408
|
+
.nsm__group-head:hover { background: var(--nsm-hover); }
|
|
409
|
+
.nsm__group-head:focus-visible { outline: 2px solid var(--nsm-accent); outline-offset: -2px; }
|
|
410
|
+
.nsm__chevron { display: grid; place-items: center; flex: none; width: 14px; height: 14px; color: var(--nsm-tertiary); transition: transform .16s ease; }
|
|
411
|
+
.nsm__chevron.is-open { transform: rotate(90deg); }
|
|
412
|
+
.nsm__folder { display: grid; place-items: center; flex: none; width: 16px; height: 16px; color: var(--nsm-tertiary); background: transparent; border-radius: 0; }
|
|
413
|
+
.nsm__folder svg { width: 14px; height: 14px; }
|
|
414
|
+
.nsm__folder--trash { color: var(--nsm-danger); }
|
|
415
|
+
.nsm__group-copy { flex: 1 1 auto; min-width: 0; }
|
|
416
|
+
.nsm__group-title { font-family: var(--nsm-font); font-size: 12.5px; font-weight: 600; line-height: 1.4; letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
417
|
+
.nsm__group-path { margin-top: 1px; font-size: 10.5px; line-height: 1.4; color: var(--nsm-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
418
|
+
.nsm__count { display: inline-flex; align-items: center; flex: none; height: 18px; padding: 0 5px; border: 1px solid var(--nsm-border); border-radius: 4px; background: var(--nsm-muted-surface); color: var(--nsm-tertiary); font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
419
|
+
.nsm__months { padding: 0 4px 5px 24px; }
|
|
420
|
+
.nsm__month { margin: 1px 0; }
|
|
421
|
+
.nsm__month-head { display: flex; align-items: center; gap: 7px; padding: 4px 6px; border-radius: 5px; cursor: pointer; user-select: none; }
|
|
422
|
+
.nsm__month-head:hover { background: var(--nsm-hover); }
|
|
423
|
+
.nsm__month-head:focus-visible { outline: 2px solid var(--nsm-accent); outline-offset: 1px; }
|
|
424
|
+
.nsm__month-title { color: var(--nsm-tertiary); font-size: 10px; font-weight: 600; line-height: 1.4; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
|
|
425
|
+
.nsm__month-count { color: var(--nsm-tertiary); font-size: 9.5px; font-variant-numeric: tabular-nums; opacity: .8; }
|
|
426
|
+
.nsm__month-head .nsm__count { margin-left: auto; padding: 0; border: 0; background: transparent; }
|
|
427
|
+
.nsm__rows { display: flex; flex-direction: column; gap: 1px; padding: 2px 0 3px; }
|
|
428
|
+
.nsm__row { position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid transparent; border-radius: var(--nsm-radius-sm); cursor: default; transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease; }
|
|
429
|
+
.nsm__row:hover { background: var(--nsm-hover); border-color: transparent; }
|
|
430
|
+
.nsm__row:focus-visible { outline: 2px solid var(--nsm-accent); outline-offset: -1px; }
|
|
431
|
+
.nsm__row.is-selected { background: var(--nsm-accent-soft); border-color: var(--nsm-accent-line); }
|
|
432
|
+
.nsm__row.is-focused { box-shadow: inset 2px 0 0 var(--nsm-accent); }
|
|
433
|
+
.nsm__row.is-live { background-image: none; }
|
|
434
|
+
.nsm__row--trash:hover { background: var(--nsm-hover); border-color: transparent; }
|
|
435
|
+
.nsm__row--trash.is-pending { background-image: none; }
|
|
436
|
+
.nsm__check { appearance: none; display: grid; place-items: center; flex: none; width: 16px; height: 16px; padding: 0; border: 1px solid var(--nsm-border-strong); border-radius: 4px; background: var(--nsm-surface); color: transparent; cursor: pointer; transition: background-color .12s ease, border-color .12s ease, color .12s ease; }
|
|
437
|
+
.nsm__check:hover { border-color: var(--nsm-accent); }
|
|
438
|
+
.nsm__check:focus-visible { outline: 2px solid var(--nsm-accent); outline-offset: 2px; }
|
|
439
|
+
.nsm__check.is-on { border-color: var(--nsm-accent); background: var(--nsm-accent); color: #fff; }
|
|
440
|
+
.nsm__check.is-mixed { border-color: var(--nsm-accent); background: var(--nsm-accent-soft); color: var(--nsm-accent); }
|
|
441
|
+
.nsm__dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--nsm-tertiary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--nsm-tertiary) 12%, transparent); }
|
|
442
|
+
.nsm__dot.is-live { background: var(--nsm-green); box-shadow: 0 0 0 2px color-mix(in srgb, var(--nsm-green) 16%, transparent); animation: nsm-pulse 1.8s ease-in-out infinite; }
|
|
443
|
+
.nsm__dot.is-open { background: var(--nsm-accent); box-shadow: 0 0 0 2px var(--nsm-accent-soft); }
|
|
444
|
+
.nsm__dot.is-archived { background: var(--nsm-tertiary); }
|
|
445
|
+
.nsm__dot.is-deleted { background: var(--nsm-danger); box-shadow: 0 0 0 2px var(--nsm-danger-soft); }
|
|
446
|
+
.nsm__dot.is-pending { background: var(--nsm-amber); box-shadow: 0 0 0 2px color-mix(in srgb, var(--nsm-amber) 16%, transparent); animation: nsm-pulse 1.8s ease-in-out infinite; }
|
|
447
|
+
.nsm__dot.is-subagent { background: var(--nsm-violet); }
|
|
448
|
+
@keyframes nsm-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
|
|
449
|
+
.nsm__row-main { flex: 1 1 auto; min-width: 0; }
|
|
450
|
+
.nsm__row-title-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
|
|
451
|
+
.nsm__row-title { min-width: 0; color: var(--nsm-text); font-size: 12.5px; font-weight: 600; line-height: 1.4; letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
452
|
+
.nsm__row-meta { display: flex; align-items: center; gap: 6px; min-width: 0; margin-top: 1px; color: var(--nsm-tertiary); font-size: 10.5px; line-height: 1.4; }
|
|
453
|
+
.nsm__row-path { max-width: 55%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
454
|
+
.nsm__meta-sep { opacity: .5; }
|
|
455
|
+
.nsm__row-meta .nsm__meta-size { flex: none; font-variant-numeric: tabular-nums; }
|
|
456
|
+
.nsm__badges { display: flex; align-items: center; flex: none; gap: 4px; }
|
|
457
|
+
.nsm__badge { display: inline-flex; align-items: center; gap: 3px; height: 18px; padding: 0 6px; border: 1px solid transparent; border-radius: 4px; font-size: 9.5px; font-weight: 500; line-height: 1; letter-spacing: .01em; white-space: nowrap; }
|
|
458
|
+
.nsm__badge--live { color: color-mix(in srgb, var(--nsm-green) 62%, var(--nsm-text)); background: color-mix(in srgb, var(--nsm-green) 9%, transparent); border-color: color-mix(in srgb, var(--nsm-green) 20%, transparent); }
|
|
459
|
+
.nsm__badge--open { color: var(--nsm-accent); background: var(--nsm-accent-soft); border-color: var(--nsm-accent-line); }
|
|
460
|
+
.nsm__badge--archived { color: var(--nsm-tertiary); background: var(--nsm-muted-surface); border-color: var(--nsm-border); }
|
|
461
|
+
.nsm__badge--subagent { color: color-mix(in srgb, var(--nsm-violet) 66%, var(--nsm-text)); background: color-mix(in srgb, var(--nsm-violet) 9%, transparent); border-color: color-mix(in srgb, var(--nsm-violet) 20%, transparent); }
|
|
462
|
+
.nsm__badge--migration { color: color-mix(in srgb, var(--nsm-amber) 60%, var(--nsm-text)); background: color-mix(in srgb, var(--nsm-amber) 9%, transparent); border-color: color-mix(in srgb, var(--nsm-amber) 22%, transparent); }
|
|
463
|
+
.nsm__badge--pinned { color: color-mix(in srgb, var(--nsm-amber) 60%, var(--nsm-text)); background: color-mix(in srgb, var(--nsm-amber) 8%, transparent); border-color: color-mix(in srgb, var(--nsm-amber) 20%, transparent); }
|
|
464
|
+
.nsm__badge--deleted { color: var(--nsm-danger); background: var(--nsm-danger-soft); border-color: color-mix(in srgb, var(--nsm-danger) 20%, transparent); }
|
|
465
|
+
.nsm__row-actions { display: flex; align-items: center; flex: none; gap: 0; opacity: 0; transition: opacity .12s ease; }
|
|
466
|
+
.nsm__row:hover .nsm__row-actions, .nsm__row:focus-within .nsm__row-actions { opacity: 1; }
|
|
467
|
+
.nsm__icon-button { appearance: none; display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--nsm-tertiary); cursor: pointer; }
|
|
468
|
+
.nsm__icon-button:hover:not(:disabled) { background: var(--nsm-hover); color: var(--nsm-text); }
|
|
469
|
+
.nsm__icon-button:focus-visible { outline: 2px solid var(--nsm-accent); outline-offset: 1px; }
|
|
470
|
+
.nsm__icon-button:disabled { opacity: .3; cursor: default; }
|
|
471
|
+
.nsm__icon-button--danger:hover:not(:disabled) { background: var(--nsm-danger-soft); color: var(--nsm-danger); }
|
|
472
|
+
.nsm__aside { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
|
|
473
|
+
.nsm__card { padding: 14px; border: 1px solid var(--nsm-border); border-radius: var(--nsm-radius); background: var(--nsm-surface); }
|
|
474
|
+
.nsm__card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
|
|
475
|
+
.nsm__card-head h2 { margin: 0; font-family: var(--nsm-font); font-size: 12.5px; font-weight: 600; line-height: 1.4; letter-spacing: -.005em; color: var(--nsm-text); }
|
|
476
|
+
.nsm__card-head .nsm__icon-button { margin-left: auto; }
|
|
477
|
+
.nsm__selection-actions { display: flex; flex-direction: column; gap: 6px; }
|
|
478
|
+
.nsm__selection-actions .nsm__button { width: 100%; }
|
|
479
|
+
.nsm__selection-size { margin: 0 0 10px; color: var(--nsm-tertiary); font-size: 11px; font-variant-numeric: tabular-nums; }
|
|
480
|
+
.nsm__hint { margin: 10px 0 0; color: var(--nsm-tertiary); font-size: 11px; line-height: 1.55; }
|
|
481
|
+
.nsm__detail-empty p { margin: 0; color: var(--nsm-tertiary); font-size: 11px; line-height: 1.6; }
|
|
482
|
+
.nsm__detail-title { margin: 0; font-family: var(--nsm-font); font-size: 14px; font-weight: 600; line-height: 1.4; letter-spacing: -.01em; color: var(--nsm-text); word-break: break-word; }
|
|
483
|
+
.nsm__detail-badges { display: flex; flex-wrap: wrap; gap: 4px; margin: 7px 0 11px; }
|
|
484
|
+
.nsm__facts { display: flex; flex-direction: column; gap: 7px; margin: 0; }
|
|
485
|
+
.nsm__fact { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px; align-items: baseline; }
|
|
486
|
+
.nsm__fact dt { color: var(--nsm-tertiary); font-size: 10.5px; line-height: 1.5; }
|
|
487
|
+
.nsm__fact dd { min-width: 0; margin: 0; color: var(--nsm-secondary); font-size: 11.5px; line-height: 1.5; word-break: break-word; }
|
|
488
|
+
.nsm__fact code { padding: 1px 5px; border: 1px solid var(--nsm-border); border-radius: 4px; background: var(--nsm-muted-surface); color: var(--nsm-secondary); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
|
|
489
|
+
.nsm__fact button { appearance: none; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; word-break: break-word; cursor: pointer; }
|
|
490
|
+
.nsm__fact button:hover { color: var(--nsm-accent); text-decoration: underline; text-underline-offset: 2px; }
|
|
491
|
+
.nsm__detail-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--nsm-border); }
|
|
492
|
+
.nsm__import-card { background: var(--nsm-surface); }
|
|
493
|
+
.nsm__import-card .nsm__button { margin-top: 2px; }
|
|
494
|
+
.nsm__empty { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 240px; padding: 32px 20px; text-align: center; }
|
|
495
|
+
.nsm__empty-mark { display: grid; place-items: center; width: 48px; height: 48px; padding: 8px; border: 1px solid var(--nsm-accent-line); border-radius: 9px; background: linear-gradient(145deg, color-mix(in srgb, var(--nsm-accent) 14%, transparent), color-mix(in srgb, var(--nsm-accent) 4%, transparent)); color: var(--nsm-accent); }
|
|
496
|
+
.nsm__empty-mark svg { display: block; width: 100%; height: 100%; }
|
|
497
|
+
.nsm__empty-mark--trash { border-color: color-mix(in srgb, var(--nsm-danger) 20%, transparent); background: var(--nsm-danger-soft); color: var(--nsm-danger); }
|
|
498
|
+
.nsm__empty h2 { margin: 14px 0 4px; font-family: var(--nsm-font); font-size: 14px; font-weight: 600; line-height: 1.4; letter-spacing: -.01em; }
|
|
499
|
+
.nsm__empty p { max-width: 330px; margin: 0; color: var(--nsm-tertiary); font-size: 11.5px; line-height: 1.6; }
|
|
500
|
+
.nsm__empty .nsm__button { margin-top: 14px; }
|
|
501
|
+
.nsm__loading { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 280px; gap: 10px; color: var(--nsm-tertiary); font-size: 12px; }
|
|
502
|
+
.nsm__spinner { width: 18px; height: 18px; border: 2px solid var(--nsm-border-strong); border-top-color: var(--nsm-accent); border-radius: 50%; animation: nsm-spin .8s linear infinite; }
|
|
503
|
+
@keyframes nsm-spin { to { transform: rotate(360deg); } }
|
|
504
|
+
.nsm__error { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 240px; padding: 28px; text-align: center; }
|
|
505
|
+
.nsm__error p { margin: 0 0 14px; color: var(--nsm-danger); font-size: 12px; line-height: 1.6; }
|
|
506
|
+
.nsm__report { margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--nsm-border); border-radius: var(--nsm-radius-sm); background: var(--nsm-surface); }
|
|
507
|
+
.nsm__report-head { display: flex; align-items: center; gap: 8px; color: var(--nsm-text); font-size: 12px; font-weight: 500; }
|
|
508
|
+
.nsm__report-head .nsm__icon-button { margin-left: auto; }
|
|
509
|
+
.nsm__report ul { margin: 6px 0 0; padding-left: 18px; color: var(--nsm-tertiary); font-size: 11px; line-height: 1.6; }
|
|
510
|
+
.nsm__footer { display: flex; flex-direction: column; gap: 4px; margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--nsm-border); color: var(--nsm-tertiary); font-size: 10.5px; line-height: 1.6; }
|
|
511
|
+
.nsm__footer-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-width: 0; }
|
|
512
|
+
.nsm__footer code { padding: 1px 5px; border: 1px solid var(--nsm-border); border-radius: 4px; background: var(--nsm-muted-surface); color: var(--nsm-secondary); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; word-break: break-all; }
|
|
513
|
+
.nsm__footer-copy { appearance: none; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 20px; height: 20px; padding: 0; border: 1px solid var(--nsm-border); border-radius: 4px; background: transparent; color: var(--nsm-tertiary); cursor: pointer; }
|
|
514
|
+
.nsm__footer-copy:hover { background: var(--nsm-hover); color: var(--nsm-text); border-color: var(--nsm-border-strong); }
|
|
515
|
+
.nsm__footer-copy:focus-visible { outline: 2px solid var(--nsm-accent); outline-offset: 1px; }
|
|
516
|
+
.nsm__modal { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; padding: 22px; background: rgba(15, 17, 21, .38); backdrop-filter: blur(2px); }
|
|
517
|
+
.nsm__dialog { box-sizing: border-box; width: min(440px, 100%); max-height: min(620px, 90vh); overflow: auto; padding: 20px; border: 1px solid var(--nsm-border); border-radius: 10px; background: var(--nsm-surface); box-shadow: var(--dsw-shadow-lv3, 0 12px 32px rgba(0, 0, 0, .16)); }
|
|
518
|
+
.nsm__dialog h2 { margin: 0 0 8px; font-family: var(--nsm-font); font-size: 16px; font-weight: 600; line-height: 1.35; letter-spacing: -.01em; }
|
|
519
|
+
.nsm__dialog-warning { margin: 0 0 12px; color: var(--nsm-secondary); font-size: 12px; line-height: 1.65; }
|
|
520
|
+
.nsm__dialog-list { margin: 0 0 12px; padding: 8px 10px; list-style: none; border: 1px solid var(--nsm-border); border-radius: var(--nsm-radius-sm); background: var(--nsm-muted-surface); font-size: 11.5px; line-height: 1.75; }
|
|
521
|
+
.nsm__dialog-list li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
522
|
+
.nsm__dialog-more { margin: 0 0 12px; color: var(--nsm-tertiary); font-size: 11px; }
|
|
523
|
+
.nsm__dialog-live-note { margin: 0 0 12px; padding: 8px 10px; border: 1px solid color-mix(in srgb, var(--nsm-amber) 22%, transparent); border-radius: 5px; background: color-mix(in srgb, var(--nsm-amber) 8%, transparent); color: color-mix(in srgb, var(--nsm-amber) 58%, var(--nsm-text)); font-size: 11.5px; line-height: 1.55; }
|
|
524
|
+
.nsm__dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
|
|
525
|
+
.nsm__drop { position: fixed; inset: 0; z-index: 1150; display: grid; place-items: center; padding: 30px; background: rgba(15, 17, 21, .3); backdrop-filter: blur(2px); pointer-events: none; }
|
|
526
|
+
.nsm__drop-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-width: min(420px, 80vw); min-height: 190px; padding: 24px; border: 1px dashed var(--nsm-accent-line); border-radius: 10px; background: var(--nsm-surface); box-shadow: var(--dsw-shadow-lv3, 0 12px 32px rgba(0, 0, 0, .16)); text-align: center; }
|
|
527
|
+
.nsm__drop-card h3 { margin: 0; font-family: var(--nsm-font); font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
|
|
528
|
+
.nsm__drop-card p { max-width: 330px; margin: 0; color: var(--nsm-tertiary); font-size: 11.5px; line-height: 1.6; }
|
|
529
|
+
.nsm__toast { position: fixed; right: 22px; bottom: 22px; z-index: 1300; display: flex; align-items: center; gap: 8px; max-width: min(420px, calc(100vw - 44px)); padding: 9px 12px; border: 0; border-radius: 8px; background: var(--dsw-alias-toast-bg); color: var(--dsw-alias-toast-label); box-shadow: var(--dsw-shadow-lv3, 0 12px 32px rgba(0, 0, 0, .16)); font-size: 12px; line-height: 1.5; animation: nsm-toast-in .16s ease-out; }
|
|
530
|
+
.nsm__toast.is-error, .nsm__toast.is-ok { border: 0; color: var(--dsw-alias-toast-label); }
|
|
531
|
+
.nsm__toast-icon { flex: none; margin-top: 0; color: var(--dsw-alias-toast-label); opacity: .65; }
|
|
532
|
+
.nsm__toast-action { appearance: none; flex: none; margin-left: 4px; height: 22px; padding: 0 8px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 4px; background: rgba(255, 255, 255, .08); color: var(--dsw-alias-toast-label); font-size: 10.5px; font-weight: 500; line-height: 1; cursor: pointer; }
|
|
533
|
+
.nsm__toast-action:hover { background: rgba(255, 255, 255, .16); }
|
|
534
|
+
@keyframes nsm-toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
|
|
535
|
+
.nsm__sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
|
|
536
|
+
@media (max-width: 1080px) {
|
|
537
|
+
.nsm__layout { grid-template-columns: minmax(0, 1fr); }
|
|
538
|
+
.nsm__aside { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
|
|
539
|
+
.nsm__detail-card { grid-column: span 2; }
|
|
540
|
+
}
|
|
541
|
+
@media (max-width: 900px) {
|
|
542
|
+
.nsm__stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
543
|
+
.nsm__stat:nth-child(3) { border-left: 0; border-top: 1px solid var(--nsm-border); }
|
|
544
|
+
.nsm__stat:nth-child(4) { border-top: 1px solid var(--nsm-border); }
|
|
545
|
+
.nsm__inner { padding-left: 22px; padding-right: 22px; }
|
|
546
|
+
}
|
|
547
|
+
@media (max-width: 720px) {
|
|
548
|
+
.nsm__header { gap: 16px; }
|
|
549
|
+
.nsm__title { font-size: 21px; }
|
|
550
|
+
.nsm__mark { width: 34px; height: 34px; padding: 7px; }
|
|
551
|
+
.nsm__actions { width: 100%; }
|
|
552
|
+
.nsm__actions .nsm__button { flex: 1 1 auto; }
|
|
553
|
+
.nsm__toolbar { padding: 7px; }
|
|
554
|
+
.nsm__viewtabs { order: 3; flex: 1 1 100%; }
|
|
555
|
+
.nsm__viewtab { flex: 1; }
|
|
556
|
+
.nsm__toolbar-spacer { display: none; }
|
|
557
|
+
.nsm__row-path { max-width: 100%; }
|
|
558
|
+
.nsm__row-meta { flex-wrap: wrap; }
|
|
559
|
+
.nsm__aside { grid-template-columns: minmax(0, 1fr); }
|
|
560
|
+
.nsm__detail-card { grid-column: auto; }
|
|
561
|
+
.nsm__months { padding-left: 16px; }
|
|
562
|
+
.nsm__row { padding-right: 5px; }
|
|
563
|
+
.nsm__row-actions { opacity: 1; }
|
|
564
|
+
.nsm__dialog { padding: 18px; }
|
|
565
|
+
}
|
|
566
|
+
@media (hover: none) {
|
|
567
|
+
.nsm__row-actions { opacity: 1; }
|
|
568
|
+
}
|
|
569
|
+
@media (prefers-reduced-motion: reduce) {
|
|
570
|
+
.nsm__dot.is-live, .nsm__dot.is-pending { animation: none; }
|
|
571
|
+
.nsm__spinner { animation-duration: 2s; }
|
|
572
|
+
.nsm__button, .nsm__row, .nsm__chevron, .nsm__row-actions, .nsm__toast { transition: none; animation: none; }
|
|
573
|
+
}
|
|
574
|
+
`;
|
|
575
|
+
|
|
576
|
+
function formatBytes(value) {
|
|
577
|
+
const number = Number(value);
|
|
578
|
+
if (!Number.isFinite(number) || number <= 0) return '0 B';
|
|
579
|
+
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
580
|
+
const exponent = Math.min(units.length - 1, Math.floor(Math.log(number) / Math.log(1024)));
|
|
581
|
+
const amount = number / 1024 ** exponent;
|
|
582
|
+
return `${amount >= 10 || exponent === 0 ? Math.round(amount) : amount.toFixed(1)} ${units[exponent]}`;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
function Glyph(props) {
|
|
586
|
+
const size = typeof props.size === 'number' ? props.size : 14;
|
|
587
|
+
const common = {
|
|
588
|
+
width: size,
|
|
589
|
+
height: size,
|
|
590
|
+
viewBox: '0 0 16 16',
|
|
591
|
+
fill: 'none',
|
|
592
|
+
stroke: 'currentColor',
|
|
593
|
+
strokeWidth: 1.5,
|
|
594
|
+
strokeLinecap: 'round',
|
|
595
|
+
strokeLinejoin: 'round',
|
|
596
|
+
'aria-hidden': 'true',
|
|
597
|
+
focusable: 'false',
|
|
598
|
+
style: { display: 'block' },
|
|
599
|
+
};
|
|
600
|
+
const name = props.name;
|
|
601
|
+
if (name === 'check') return h('svg', common, h('path', { d: 'M3.2 8.2 6.4 11.3 12.8 4.8' }));
|
|
602
|
+
if (name === 'minus') return h('svg', common, h('path', { d: 'M3.5 8h9' }));
|
|
603
|
+
if (name === 'chevron') return h('svg', common, h('path', { d: 'M6 3.5 10.5 8 6 12.5' }));
|
|
604
|
+
if (name === 'search') return h('svg', common, h('circle', { cx: 7, cy: 7, r: 4 }), h('path', { d: 'm10.2 10.2 3.1 3.1' }));
|
|
605
|
+
if (name === 'close') return h('svg', common, h('path', { d: 'm4 4 8 8M12 4l-8 8' }));
|
|
606
|
+
if (name === 'folder') return h('svg', common, h('path', { d: 'M2.2 5.2h11.6v7.1H2.2z' }), h('path', { d: 'M2.2 5.2V3.6h4l1.2 1.6' }));
|
|
607
|
+
if (name === 'refresh') return h('svg', common, h('path', { d: 'M13 7a5 5 0 1 0-.9 3.6' }), h('path', { d: 'M13 3.2V7h-3.8' }));
|
|
608
|
+
if (name === 'restore') return h('svg', common, h('path', { d: 'M3 7a5 5 0 1 1 .9 3.6' }), h('path', { d: 'M3 3.2V7h3.8' }), h('path', { d: 'M6.2 7h7.2v5.4H6.2z' }));
|
|
609
|
+
if (name === 'import') return h('svg', common, h('path', { d: 'M8 2.2v7.2' }), h('path', { d: 'm5.2 6.8 2.8 2.8 2.8-2.8' }), h('path', { d: 'M2.6 10.8v2h10.8v-2' }));
|
|
610
|
+
if (name === 'export') return h('svg', common, h('path', { d: 'M8 9.4V2.2' }), h('path', { d: 'm5.2 4.9 2.8-2.8 2.8 2.8' }), h('path', { d: 'M2.6 10.8v2h10.8v-2' }));
|
|
611
|
+
if (name === 'trash') return h('svg', common, h('path', { d: 'M3.2 4.4h9.6' }), h('path', { d: 'M6.2 4.4V3h3.6v1.4' }), h('path', { d: 'M4.4 4.4l.6 8.3h6l.6-8.3' }), h('path', { d: 'M6.8 7v3.4M9.2 7v3.4' }));
|
|
612
|
+
if (name === 'open') return h('svg', common, h('path', { d: 'M6.2 3.2H3.4v9.4h9.4V9.8' }), h('path', { d: 'M9.2 2.8h4v4' }), h('path', { d: 'm8.2 7.8 4.8-4.8' }));
|
|
613
|
+
if (name === 'copy') return h('svg', common, h('rect', { x: 5.2, y: 5.2, width: 7.6, height: 7.6, rx: 1.2 }), h('path', { d: 'M10.8 5.2V3.4H3.2v7.6h1.8' }));
|
|
614
|
+
if (name === 'archive') return h('svg', common, h('path', { d: 'M2.4 4.6h11.2v8H2.4z' }), h('path', { d: 'M2 2.8h12v2.2H2z' }), h('path', { d: 'M6.2 7.4h3.6' }));
|
|
615
|
+
if (name === 'branch') return h('svg', common, h('circle', { cx: 4.5, cy: 3.6, r: 1.5 }), h('circle', { cx: 11.5, cy: 3.6, r: 1.5 }), h('circle', { cx: 8, cy: 12.4, r: 1.5 }), h('path', { d: 'M4.5 5.1v2.2c0 1.5 1.2 2.7 2.7 2.7h1.6' }), h('path', { d: 'M11.5 5.1v2.2c0 1.5-1.2 2.7-2.7 2.7H8v1' }));
|
|
616
|
+
if (name === 'pin') return h('svg', common, h('path', { d: 'M9.7 2.6 13.4 6.3l-1.9.5-2.6 2.6-.2 2.1-1.3-1.3-2.6 2.6-.9-.9 2.6-2.6L5.2 8l2.1-.2 2.6-2.6.5-1.9Z' }));
|
|
617
|
+
if (name === 'alert') return h('svg', common, h('path', { d: 'M8 2.5 14 13H2L8 2.5Z' }), h('path', { d: 'M8 6.2v3.1M8 11.4v.1' }));
|
|
618
|
+
if (name === 'clock') return h('svg', common, h('circle', { cx: 8, cy: 8, r: 5.6 }), h('path', { d: 'M8 4.8V8l2.2 1.4' }));
|
|
619
|
+
return h('svg', common, h('circle', { cx: 8, cy: 8, r: 5 }));
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
function Check(props) {
|
|
623
|
+
const on = props.checked === true;
|
|
624
|
+
const mixed = props.mixed === true;
|
|
625
|
+
return h('button', {
|
|
626
|
+
type: 'button',
|
|
627
|
+
role: 'checkbox',
|
|
628
|
+
className: `nsm__check${on ? ' is-on' : ''}${!on && mixed ? ' is-mixed' : ''}`,
|
|
629
|
+
'aria-checked': mixed && !on ? 'mixed' : on ? 'true' : 'false',
|
|
630
|
+
'aria-label': props.label || '',
|
|
631
|
+
title: props.label || '',
|
|
632
|
+
onClick: (event) => {
|
|
633
|
+
event.stopPropagation();
|
|
634
|
+
props.onChange(!on);
|
|
635
|
+
},
|
|
636
|
+
}, on ? h(Glyph, { name: 'check', size: 12 }) : mixed ? h(Glyph, { name: 'minus', size: 12 }) : null);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
function PageMark(props) {
|
|
640
|
+
const size = typeof props.size === 'number' ? props.size : 32;
|
|
641
|
+
return h('svg', {
|
|
642
|
+
width: size,
|
|
643
|
+
height: size,
|
|
644
|
+
viewBox: '0 0 32 32',
|
|
645
|
+
fill: 'none',
|
|
646
|
+
stroke: 'currentColor',
|
|
647
|
+
strokeWidth: 1.8,
|
|
648
|
+
strokeLinecap: 'round',
|
|
649
|
+
strokeLinejoin: 'round',
|
|
650
|
+
'aria-hidden': 'true',
|
|
651
|
+
focusable: 'false',
|
|
652
|
+
style: { display: 'block' },
|
|
653
|
+
},
|
|
654
|
+
h('path', { d: 'M9 4.5v23' }),
|
|
655
|
+
h('path', { d: 'M9 8.5h10M9 16h15M9 23.5h10' }),
|
|
656
|
+
h('circle', { cx: 9, cy: 4.5, r: 2.3, fill: 'currentColor', stroke: 'none' }),
|
|
657
|
+
h('circle', { cx: 19, cy: 8.5, r: 1.9, fill: 'currentColor', stroke: 'none' }),
|
|
658
|
+
h('circle', { cx: 24, cy: 16, r: 1.9, fill: 'currentColor', stroke: 'none' }),
|
|
659
|
+
h('circle', { cx: 19, cy: 23.5, r: 1.9, fill: 'currentColor', stroke: 'none' }),
|
|
660
|
+
);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
return {
|
|
664
|
+
inject: ['slots'],
|
|
665
|
+
apply(ctx) {
|
|
666
|
+
const localeService = ctx.get('locale');
|
|
667
|
+
const layoutService = ctx.get('layout');
|
|
668
|
+
|
|
669
|
+
if (localeService && typeof localeService.register === 'function') {
|
|
670
|
+
const zhCodes = ['zh', 'zh-CN', 'zh-Hans', 'zh-Hant', 'zh-TW', 'zh-HK'];
|
|
671
|
+
const enCodes = ['en', 'en-US', 'en-GB'];
|
|
672
|
+
for (const code of zhCodes) {
|
|
673
|
+
ctx.effect(() => localeService.register(NS, code, DICTIONARIES.zh), `nanshan-session-manager: ${code} strings`);
|
|
674
|
+
}
|
|
675
|
+
for (const code of enCodes) {
|
|
676
|
+
ctx.effect(() => localeService.register(NS, code, DICTIONARIES.en), `nanshan-session-manager: ${code} strings`);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
function activeLocale() {
|
|
681
|
+
if (localeService && typeof localeService.getSnapshot === 'function') {
|
|
682
|
+
const snapshot = localeService.getSnapshot();
|
|
683
|
+
if (snapshot && typeof snapshot.active === 'string' && snapshot.active !== '') return snapshot.active;
|
|
684
|
+
}
|
|
685
|
+
if (typeof navigator !== 'undefined' && typeof navigator.language === 'string' && navigator.language !== '') return navigator.language;
|
|
686
|
+
return 'en';
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
function systemLocale() {
|
|
690
|
+
if (typeof navigator !== 'undefined' && typeof navigator.language === 'string' && navigator.language !== '') return navigator.language;
|
|
691
|
+
return '';
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
function useChinese() {
|
|
695
|
+
const system = systemLocale().toLowerCase();
|
|
696
|
+
if (system.startsWith('zh')) return true;
|
|
697
|
+
if (system.startsWith('en')) return false;
|
|
698
|
+
return activeLocale().toLowerCase().startsWith('zh');
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
function localized(key) {
|
|
702
|
+
const chinese = useChinese();
|
|
703
|
+
const primary = chinese ? DICTIONARIES.zh : DICTIONARIES.en;
|
|
704
|
+
const fallback = chinese ? DICTIONARIES.en : DICTIONARIES.zh;
|
|
705
|
+
return primary[key] ?? fallback[key] ?? key;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
function tr(key, values) {
|
|
709
|
+
let text = localized(key);
|
|
710
|
+
if (values) {
|
|
711
|
+
for (const [name, value] of Object.entries(values)) {
|
|
712
|
+
text = text.split(`{${name}}`).join(String(value));
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
return text;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
function activeLocaleTag() {
|
|
719
|
+
return useChinese() ? 'zh-CN' : 'en';
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
function useTranslate() {
|
|
723
|
+
const [, increment] = React.useState(0);
|
|
724
|
+
React.useEffect(() => {
|
|
725
|
+
if (!localeService || typeof localeService.subscribe !== 'function') return undefined;
|
|
726
|
+
return localeService.subscribe(() => increment((value) => value + 1));
|
|
727
|
+
}, []);
|
|
728
|
+
return localized;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
function formatDateTime(value) {
|
|
732
|
+
const date = new Date(value);
|
|
733
|
+
if (Number.isNaN(date.getTime())) return '—';
|
|
734
|
+
try {
|
|
735
|
+
return date.toLocaleString(activeLocaleTag(), { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' });
|
|
736
|
+
} catch {
|
|
737
|
+
return date.toISOString().slice(0, 16).replace('T', ' ');
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function formatDate(value) {
|
|
742
|
+
const date = new Date(value);
|
|
743
|
+
if (Number.isNaN(date.getTime())) return '—';
|
|
744
|
+
try {
|
|
745
|
+
return date.toLocaleDateString(activeLocaleTag(), { year: 'numeric', month: 'short', day: 'numeric' });
|
|
746
|
+
} catch {
|
|
747
|
+
return date.toISOString().slice(0, 10);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
function relativeTime(value) {
|
|
752
|
+
const timestamp = Number(value);
|
|
753
|
+
if (!Number.isFinite(timestamp) || timestamp <= 0) return '—';
|
|
754
|
+
const delta = Date.now() - timestamp;
|
|
755
|
+
if (delta < 60_000) return tr('relative.justNow');
|
|
756
|
+
if (delta < 3_600_000) return tr('relative.minutes', { n: Math.max(1, Math.floor(delta / 60_000)) });
|
|
757
|
+
if (delta < 86_400_000) return tr('relative.hours', { n: Math.max(1, Math.floor(delta / 3_600_000)) });
|
|
758
|
+
if (delta < 7 * 86_400_000) return tr('relative.days', { n: Math.max(1, Math.floor(delta / 86_400_000)) });
|
|
759
|
+
return formatDate(timestamp);
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
function monthKey(value) {
|
|
763
|
+
const date = new Date(value);
|
|
764
|
+
if (Number.isNaN(date.getTime())) return '0000-00';
|
|
765
|
+
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}`;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
function monthLabel(key) {
|
|
769
|
+
const parts = key.split('-').map(Number);
|
|
770
|
+
if (!Number.isFinite(parts[0]) || !Number.isFinite(parts[1]) || parts[0] === 0) return key;
|
|
771
|
+
const date = new Date(parts[0], parts[1] - 1, 1);
|
|
772
|
+
try {
|
|
773
|
+
return date.toLocaleDateString(activeLocaleTag(), { year: 'numeric', month: 'long' });
|
|
774
|
+
} catch {
|
|
775
|
+
return key;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
function shortPath(value) {
|
|
780
|
+
if (typeof value !== 'string' || value === '') return tr('tree.noPath');
|
|
781
|
+
return value.replace(/^\/Users\/[^/]+/, '~');
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
function baseName(value) {
|
|
785
|
+
if (typeof value !== 'string' || value === '') return '';
|
|
786
|
+
const parts = value.split(/[\\/]/).filter(Boolean);
|
|
787
|
+
return parts.length > 0 ? parts[parts.length - 1] : value;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
function buildGroups(sessions) {
|
|
791
|
+
const map = new Map();
|
|
792
|
+
for (const session of sessions) {
|
|
793
|
+
const group = session.group && typeof session.group === 'object'
|
|
794
|
+
? session.group
|
|
795
|
+
: { kind: 'none', id: 'ungrouped', title: '', path: null };
|
|
796
|
+
const key = typeof group.id === 'string' && group.id !== '' ? group.id : 'ungrouped';
|
|
797
|
+
let entry = map.get(key);
|
|
798
|
+
if (entry === undefined) {
|
|
799
|
+
entry = { ...group, key, sessions: [], bytes: 0 };
|
|
800
|
+
map.set(key, entry);
|
|
801
|
+
}
|
|
802
|
+
entry.sessions.push(session);
|
|
803
|
+
entry.bytes += Number(session.sizeBytes) || 0;
|
|
804
|
+
}
|
|
805
|
+
const groups = [...map.values()];
|
|
806
|
+
for (const group of groups) {
|
|
807
|
+
group.sessions.sort((left, right) => right.updatedAt - left.updatedAt || right.createdAt - left.createdAt);
|
|
808
|
+
const months = new Map();
|
|
809
|
+
for (const session of group.sessions) {
|
|
810
|
+
const key = monthKey(session.updatedAt || session.createdAt);
|
|
811
|
+
let month = months.get(key);
|
|
812
|
+
if (month === undefined) {
|
|
813
|
+
month = { key, sessions: [], bytes: 0 };
|
|
814
|
+
months.set(key, month);
|
|
815
|
+
}
|
|
816
|
+
month.sessions.push(session);
|
|
817
|
+
month.bytes += Number(session.sizeBytes) || 0;
|
|
818
|
+
}
|
|
819
|
+
group.months = [...months.values()].sort((left, right) => right.key.localeCompare(left.key));
|
|
820
|
+
}
|
|
821
|
+
groups.sort((left, right) => {
|
|
822
|
+
if (left.kind === 'none') return 1;
|
|
823
|
+
if (right.kind === 'none') return -1;
|
|
824
|
+
return String(left.title || '').localeCompare(String(right.title || ''));
|
|
825
|
+
});
|
|
826
|
+
return groups;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
function buildTrashGroups(entries) {
|
|
830
|
+
const months = new Map();
|
|
831
|
+
for (const entry of entries) {
|
|
832
|
+
const key = monthKey(entry.deletedAt);
|
|
833
|
+
let month = months.get(key);
|
|
834
|
+
if (month === undefined) {
|
|
835
|
+
month = { key, entries: [], bytes: 0 };
|
|
836
|
+
months.set(key, month);
|
|
837
|
+
}
|
|
838
|
+
month.entries.push(entry);
|
|
839
|
+
month.bytes += Number(entry.sizeBytes) || 0;
|
|
840
|
+
}
|
|
841
|
+
const groups = [...months.values()];
|
|
842
|
+
for (const group of groups) group.entries.sort((left, right) => right.deletedAt - left.deletedAt);
|
|
843
|
+
groups.sort((left, right) => right.key.localeCompare(left.key));
|
|
844
|
+
return groups;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
function groupTitle(group) {
|
|
848
|
+
if (group.kind === 'none') return tr('tree.ungrouped');
|
|
849
|
+
return group.title || baseName(group.path) || tr('tree.ungrouped');
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
async function post(path, body) {
|
|
853
|
+
const response = await fetch(`${API}${path}`, {
|
|
854
|
+
method: 'POST',
|
|
855
|
+
credentials: 'same-origin',
|
|
856
|
+
headers: { 'content-type': 'application/json' },
|
|
857
|
+
body: JSON.stringify(body),
|
|
858
|
+
});
|
|
859
|
+
const payload = await response.json().catch(() => null);
|
|
860
|
+
if (!response.ok || !payload || payload.ok !== true) {
|
|
861
|
+
const message = payload && typeof payload.message === 'string' ? payload.message : `HTTP ${response.status}`;
|
|
862
|
+
const error = new Error(message);
|
|
863
|
+
error.payload = payload;
|
|
864
|
+
throw error;
|
|
865
|
+
}
|
|
866
|
+
return payload;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
function triggerDownload(url) {
|
|
870
|
+
const link = document.createElement('a');
|
|
871
|
+
link.href = url;
|
|
872
|
+
link.download = '';
|
|
873
|
+
link.rel = 'noopener';
|
|
874
|
+
document.body.appendChild(link);
|
|
875
|
+
link.click();
|
|
876
|
+
link.remove();
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
function Page() {
|
|
880
|
+
const t = useTranslate();
|
|
881
|
+
const [data, setData] = React.useState(null);
|
|
882
|
+
const [status, setStatus] = React.useState('loading');
|
|
883
|
+
const [error, setError] = React.useState('');
|
|
884
|
+
const [query, setQuery] = React.useState('');
|
|
885
|
+
const [view, setView] = React.useState('sessions');
|
|
886
|
+
const [stateFilter, setStateFilter] = React.useState('all');
|
|
887
|
+
const [selectedIds, setSelectedIds] = React.useState([]);
|
|
888
|
+
const [selectedTrashIds, setSelectedTrashIds] = React.useState([]);
|
|
889
|
+
const [focusedId, setFocusedId] = React.useState(null);
|
|
890
|
+
const [focusedTrashId, setFocusedTrashId] = React.useState(null);
|
|
891
|
+
const [collapsed, setCollapsed] = React.useState(() => new Set());
|
|
892
|
+
const collapseInitializedRef = React.useRef(false);
|
|
893
|
+
const [confirm, setConfirm] = React.useState(null);
|
|
894
|
+
const [busy, setBusy] = React.useState(false);
|
|
895
|
+
const [importing, setImporting] = React.useState(false);
|
|
896
|
+
const [importReport, setImportReport] = React.useState(null);
|
|
897
|
+
const [toast, setToast] = React.useState(null);
|
|
898
|
+
const [dragActive, setDragActive] = React.useState(false);
|
|
899
|
+
const dataRef = React.useRef(null);
|
|
900
|
+
const dragDepth = React.useRef(0);
|
|
901
|
+
const fileInputRef = React.useRef(null);
|
|
902
|
+
const toastSeq = React.useRef(0);
|
|
903
|
+
|
|
904
|
+
const showToast = React.useCallback((kind, text, action) => {
|
|
905
|
+
toastSeq.current += 1;
|
|
906
|
+
setToast({ kind, text, action, seq: toastSeq.current });
|
|
907
|
+
}, []);
|
|
908
|
+
|
|
909
|
+
const fetchList = React.useCallback(async (signal) => {
|
|
910
|
+
const response = await fetch(API, { method: 'GET', credentials: 'same-origin', headers: { accept: 'application/json' }, signal });
|
|
911
|
+
const payload = await response.json().catch(() => null);
|
|
912
|
+
if (!response.ok || !payload || payload.ok !== true) {
|
|
913
|
+
throw new Error(payload && payload.message ? payload.message : `HTTP ${response.status}`);
|
|
914
|
+
}
|
|
915
|
+
return payload;
|
|
916
|
+
}, []);
|
|
917
|
+
|
|
918
|
+
const load = React.useCallback(async (options = {}) => {
|
|
919
|
+
if (!options.silent) setStatus(dataRef.current === null ? 'loading' : 'refreshing');
|
|
920
|
+
setError('');
|
|
921
|
+
try {
|
|
922
|
+
const payload = await fetchList(options.signal);
|
|
923
|
+
if (!collapseInitializedRef.current) {
|
|
924
|
+
collapseInitializedRef.current = true;
|
|
925
|
+
setCollapsed(new Set(buildGroups(Array.isArray(payload.sessions) ? payload.sessions : []).map((group) => group.key)));
|
|
926
|
+
}
|
|
927
|
+
dataRef.current = payload;
|
|
928
|
+
setData(payload);
|
|
929
|
+
setStatus('ready');
|
|
930
|
+
} catch (failure) {
|
|
931
|
+
if (failure && failure.name === 'AbortError') return;
|
|
932
|
+
setError(t('error.load'));
|
|
933
|
+
setStatus(dataRef.current === null ? 'error' : 'ready');
|
|
934
|
+
}
|
|
935
|
+
}, [fetchList, t]);
|
|
936
|
+
|
|
937
|
+
React.useEffect(() => {
|
|
938
|
+
const controller = new AbortController();
|
|
939
|
+
load({ signal: controller.signal });
|
|
940
|
+
return () => controller.abort();
|
|
941
|
+
}, [load]);
|
|
942
|
+
|
|
943
|
+
React.useEffect(() => {
|
|
944
|
+
const timer = setInterval(() => {
|
|
945
|
+
if (document.visibilityState === 'visible' && !document.querySelector('.nsm__modal')) load({ silent: true });
|
|
946
|
+
}, 30_000);
|
|
947
|
+
return () => clearInterval(timer);
|
|
948
|
+
}, [load]);
|
|
949
|
+
|
|
950
|
+
React.useEffect(() => {
|
|
951
|
+
if (!toast) return undefined;
|
|
952
|
+
const timer = setTimeout(() => setToast(null), toast.action ? 7000 : 4200);
|
|
953
|
+
return () => clearTimeout(timer);
|
|
954
|
+
}, [toast]);
|
|
955
|
+
|
|
956
|
+
React.useEffect(() => {
|
|
957
|
+
if (!data) return;
|
|
958
|
+
const ids = new Set(data.sessions.map((session) => session.id));
|
|
959
|
+
const trashIds = new Set((Array.isArray(data.trash) ? data.trash : []).map((entry) => entry.trashId));
|
|
960
|
+
setSelectedIds((previous) => previous.filter((id) => ids.has(id)));
|
|
961
|
+
setFocusedId((previous) => previous !== null && ids.has(previous) ? previous : null);
|
|
962
|
+
setSelectedTrashIds((previous) => previous.filter((id) => trashIds.has(id)));
|
|
963
|
+
setFocusedTrashId((previous) => previous !== null && trashIds.has(previous) ? previous : null);
|
|
964
|
+
}, [data]);
|
|
965
|
+
|
|
966
|
+
React.useEffect(() => {
|
|
967
|
+
setSelectedIds([]);
|
|
968
|
+
setSelectedTrashIds([]);
|
|
969
|
+
setFocusedId(null);
|
|
970
|
+
setFocusedTrashId(null);
|
|
971
|
+
}, [view]);
|
|
972
|
+
|
|
973
|
+
React.useEffect(() => {
|
|
974
|
+
if (!confirm) return undefined;
|
|
975
|
+
const onKeyDown = (event) => {
|
|
976
|
+
if (event.key === 'Escape' && !busy) setConfirm(null);
|
|
977
|
+
};
|
|
978
|
+
window.addEventListener('keydown', onKeyDown);
|
|
979
|
+
return () => window.removeEventListener('keydown', onKeyDown);
|
|
980
|
+
}, [confirm, busy]);
|
|
981
|
+
|
|
982
|
+
const sessions = data && Array.isArray(data.sessions) ? data.sessions : [];
|
|
983
|
+
const trash = data && Array.isArray(data.trash) ? data.trash : [];
|
|
984
|
+
const stats = data && data.stats ? data.stats : { total: 0, groups: 0, live: 0, archived: 0, trash: 0, bytes: 0 };
|
|
985
|
+
const normalizedQuery = query.trim().toLocaleLowerCase();
|
|
986
|
+
const filterCounts = React.useMemo(() => ({
|
|
987
|
+
all: sessions.length,
|
|
988
|
+
running: sessions.filter((session) => session.running).length,
|
|
989
|
+
open: sessions.filter((session) => session.live && !session.running).length,
|
|
990
|
+
archived: sessions.filter((session) => session.archived).length,
|
|
991
|
+
subagent: sessions.filter((session) => session.origin === 'subagent').length,
|
|
992
|
+
pinned: sessions.filter((session) => session.pinned).length,
|
|
993
|
+
migration: sessions.filter((session) => session.formatStatus === 'migration-required').length,
|
|
994
|
+
}), [sessions]);
|
|
995
|
+
const visibleSessions = React.useMemo(() => {
|
|
996
|
+
return sessions.filter((session) => {
|
|
997
|
+
if (normalizedQuery !== '' && !session.id.toLocaleLowerCase().includes(normalizedQuery)) return false;
|
|
998
|
+
if (stateFilter === 'running') return session.running === true;
|
|
999
|
+
if (stateFilter === 'open') return session.live === true && session.running !== true;
|
|
1000
|
+
if (stateFilter === 'archived') return session.archived === true;
|
|
1001
|
+
if (stateFilter === 'subagent') return session.origin === 'subagent';
|
|
1002
|
+
if (stateFilter === 'pinned') return session.pinned === true;
|
|
1003
|
+
if (stateFilter === 'migration') return session.formatStatus === 'migration-required';
|
|
1004
|
+
return true;
|
|
1005
|
+
});
|
|
1006
|
+
}, [sessions, normalizedQuery, stateFilter]);
|
|
1007
|
+
const groups = React.useMemo(() => buildGroups(visibleSessions), [visibleSessions]);
|
|
1008
|
+
const visibleIds = React.useMemo(() => visibleSessions.map((session) => session.id), [visibleSessions]);
|
|
1009
|
+
const selectedSet = React.useMemo(() => new Set(selectedIds), [selectedIds]);
|
|
1010
|
+
const selectedSessions = React.useMemo(() => sessions.filter((session) => selectedSet.has(session.id)), [sessions, selectedSet]);
|
|
1011
|
+
const focusedSession = React.useMemo(() => sessions.find((session) => session.id === focusedId) || null, [sessions, focusedId]);
|
|
1012
|
+
const selectedBytes = selectedSessions.reduce((total, session) => total + (Number(session.sizeBytes) || 0), 0);
|
|
1013
|
+
const allVisibleSelected = visibleIds.length > 0 && visibleIds.every((id) => selectedSet.has(id));
|
|
1014
|
+
const someVisibleSelected = !allVisibleSelected && visibleIds.some((id) => selectedSet.has(id));
|
|
1015
|
+
const canDeleteSelected = selectedSessions.some((session) => session.exists);
|
|
1016
|
+
const visibleTrash = React.useMemo(() => {
|
|
1017
|
+
if (normalizedQuery === '') return trash;
|
|
1018
|
+
return trash.filter((entry) => entry.id.toLocaleLowerCase().includes(normalizedQuery));
|
|
1019
|
+
}, [trash, normalizedQuery]);
|
|
1020
|
+
const trashGroups = React.useMemo(() => buildTrashGroups(visibleTrash), [visibleTrash]);
|
|
1021
|
+
const visibleTrashIds = React.useMemo(() => visibleTrash.map((entry) => entry.trashId), [visibleTrash]);
|
|
1022
|
+
const trashSelectedSet = React.useMemo(() => new Set(selectedTrashIds), [selectedTrashIds]);
|
|
1023
|
+
const selectedTrashEntries = React.useMemo(() => trash.filter((entry) => trashSelectedSet.has(entry.trashId)), [trash, trashSelectedSet]);
|
|
1024
|
+
const focusedTrash = React.useMemo(() => trash.find((entry) => entry.trashId === focusedTrashId) || null, [trash, focusedTrashId]);
|
|
1025
|
+
const selectedTrashBytes = selectedTrashEntries.reduce((total, entry) => total + (Number(entry.sizeBytes) || 0), 0);
|
|
1026
|
+
const allTrashSelected = visibleTrashIds.length > 0 && visibleTrashIds.every((id) => trashSelectedSet.has(id));
|
|
1027
|
+
const someTrashSelected = !allTrashSelected && visibleTrashIds.some((id) => trashSelectedSet.has(id));
|
|
1028
|
+
const activeVisibleIds = view === 'trash' ? visibleTrashIds : visibleIds;
|
|
1029
|
+
const activeAllSelected = view === 'trash' ? allTrashSelected : allVisibleSelected;
|
|
1030
|
+
const activeSomeSelected = view === 'trash' ? someTrashSelected : someVisibleSelected;
|
|
1031
|
+
const activeSelectionCount = view === 'trash' ? selectedTrashIds.length : selectedIds.length;
|
|
1032
|
+
const sessionCount = (n) => n === 1 ? t('tree.countOne') : tr('tree.count', { n });
|
|
1033
|
+
const trashCount = (n) => n === 1 ? t('trash.countOne') : tr('trash.count', { n });
|
|
1034
|
+
|
|
1035
|
+
function toggleSelected(ids, on) {
|
|
1036
|
+
setSelectedIds((previous) => {
|
|
1037
|
+
const next = new Set(previous);
|
|
1038
|
+
for (const id of ids) {
|
|
1039
|
+
if (on) next.add(id);
|
|
1040
|
+
else next.delete(id);
|
|
1041
|
+
}
|
|
1042
|
+
return [...next];
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
function toggleOne(id) {
|
|
1047
|
+
setSelectedIds((previous) => previous.includes(id) ? previous.filter((value) => value !== id) : [...previous, id]);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
function toggleTrashSelected(ids, on) {
|
|
1051
|
+
setSelectedTrashIds((previous) => {
|
|
1052
|
+
const next = new Set(previous);
|
|
1053
|
+
for (const id of ids) {
|
|
1054
|
+
if (on) next.add(id);
|
|
1055
|
+
else next.delete(id);
|
|
1056
|
+
}
|
|
1057
|
+
return [...next];
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
function toggleTrashOne(id) {
|
|
1062
|
+
setSelectedTrashIds((previous) => previous.includes(id) ? previous.filter((value) => value !== id) : [...previous, id]);
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
function toggleCollapsed(key) {
|
|
1066
|
+
setCollapsed((previous) => {
|
|
1067
|
+
const next = new Set(previous);
|
|
1068
|
+
if (next.has(key)) next.delete(key);
|
|
1069
|
+
else next.add(key);
|
|
1070
|
+
return next;
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
function allGroupKeys() {
|
|
1075
|
+
const keys = [];
|
|
1076
|
+
if (view === 'trash') {
|
|
1077
|
+
for (const group of trashGroups) keys.push(`trash:${group.key}`);
|
|
1078
|
+
return keys;
|
|
1079
|
+
}
|
|
1080
|
+
for (const group of groups) {
|
|
1081
|
+
keys.push(group.key);
|
|
1082
|
+
for (const month of group.months) keys.push(`${group.key}::${month.key}`);
|
|
1083
|
+
}
|
|
1084
|
+
return keys;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
function expandAll() {
|
|
1088
|
+
setCollapsed(new Set());
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
function collapseAll() {
|
|
1092
|
+
setCollapsed(new Set(allGroupKeys()));
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
async function refreshNative() {
|
|
1096
|
+
const sessionsService = ctx.get('sessions');
|
|
1097
|
+
if (sessionsService && typeof sessionsService.refresh === 'function') {
|
|
1098
|
+
try {
|
|
1099
|
+
await sessionsService.refresh();
|
|
1100
|
+
} catch {
|
|
1101
|
+
// The local page has its own fresh list; the native sidebar can lag.
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
async function openSession(session) {
|
|
1107
|
+
const workspacesService = ctx.get('workspaces');
|
|
1108
|
+
if (session.archived && workspacesService && typeof workspacesService.unarchiveSession === 'function') {
|
|
1109
|
+
try {
|
|
1110
|
+
await workspacesService.unarchiveSession(session.id);
|
|
1111
|
+
await load({ silent: true });
|
|
1112
|
+
} catch {
|
|
1113
|
+
// Opening still has a chance if the session is already visible.
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
const uiWorkspace = ctx.get('uiWorkspace');
|
|
1117
|
+
if (uiWorkspace && typeof uiWorkspace.openSession === 'function') {
|
|
1118
|
+
try {
|
|
1119
|
+
uiWorkspace.openSession(session.id);
|
|
1120
|
+
return;
|
|
1121
|
+
} catch {
|
|
1122
|
+
// Fall through to the explanatory toast.
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
const layout = ctx.get('layout');
|
|
1126
|
+
if (layout && typeof layout.selectPanel === 'function') layout.selectPanel(null);
|
|
1127
|
+
showToast('error', t('toast.openUnavailable'));
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
function goBack() {
|
|
1131
|
+
if (layoutService && typeof layoutService.selectPanel === 'function') layoutService.selectPanel(null);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
function requestDelete(ids) {
|
|
1135
|
+
const targets = sessions.filter((session) => ids.includes(session.id));
|
|
1136
|
+
if (targets.length === 0) return;
|
|
1137
|
+
const active = targets.filter((session) => session.live).length;
|
|
1138
|
+
setConfirm({
|
|
1139
|
+
kind: 'delete',
|
|
1140
|
+
ids: targets.map((session) => session.id),
|
|
1141
|
+
titles: targets.map((session) => session.title || t('untitled')),
|
|
1142
|
+
active,
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
function requestPurge(trashIds) {
|
|
1147
|
+
const selected = trash.filter((entry) => trashIds.includes(entry.trashId));
|
|
1148
|
+
const targets = selected.filter((entry) => entry.pending !== true);
|
|
1149
|
+
if (targets.length === 0) {
|
|
1150
|
+
if (selected.length > 0) showToast('info', t('trash.pendingPurge'));
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
1153
|
+
setConfirm({
|
|
1154
|
+
kind: 'purge',
|
|
1155
|
+
trashIds: targets.map((entry) => entry.trashId),
|
|
1156
|
+
titles: targets.map((entry) => entry.title || t('untitled')),
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
async function restoreEntries(trashIds) {
|
|
1161
|
+
if (!Array.isArray(trashIds) || trashIds.length === 0 || busy) return;
|
|
1162
|
+
setBusy(true);
|
|
1163
|
+
try {
|
|
1164
|
+
const result = await post('/restore', { trashIds });
|
|
1165
|
+
const restored = Array.isArray(result.restored) ? result.restored : [];
|
|
1166
|
+
const skipped = (Array.isArray(result.skipped) ? result.skipped.length : 0) + (Array.isArray(result.errors) ? result.errors.length : 0);
|
|
1167
|
+
setSelectedTrashIds((previous) => previous.filter((id) => !trashIds.includes(id)));
|
|
1168
|
+
setFocusedTrashId(null);
|
|
1169
|
+
await load({ silent: true });
|
|
1170
|
+
await refreshNative();
|
|
1171
|
+
if (restored.length > 0) {
|
|
1172
|
+
showToast(skipped > 0 ? 'info' : 'ok', skipped > 0
|
|
1173
|
+
? `${tr('toast.restored', { n: restored.length })} · ${tr('toast.partial', { n: skipped })}`
|
|
1174
|
+
: tr('toast.restored', { n: restored.length }));
|
|
1175
|
+
} else {
|
|
1176
|
+
showToast('error', t('error.restore'));
|
|
1177
|
+
}
|
|
1178
|
+
} catch (failure) {
|
|
1179
|
+
showToast('error', failure && failure.message ? failure.message : t('error.restore'));
|
|
1180
|
+
} finally {
|
|
1181
|
+
setBusy(false);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
async function performConfirm() {
|
|
1186
|
+
if (!confirm || busy) return;
|
|
1187
|
+
setBusy(true);
|
|
1188
|
+
try {
|
|
1189
|
+
if (confirm.kind === 'purge') {
|
|
1190
|
+
const result = await post('/purge', { trashIds: confirm.trashIds });
|
|
1191
|
+
const purged = Array.isArray(result.purged) ? result.purged : [];
|
|
1192
|
+
const skipped = (Array.isArray(result.skipped) ? result.skipped.length : 0) + (Array.isArray(result.errors) ? result.errors.length : 0);
|
|
1193
|
+
setConfirm(null);
|
|
1194
|
+
setSelectedTrashIds((previous) => previous.filter((id) => !confirm.trashIds.includes(id)));
|
|
1195
|
+
await load({ silent: true });
|
|
1196
|
+
if (purged.length > 0) {
|
|
1197
|
+
showToast(skipped > 0 ? 'info' : 'ok', skipped > 0
|
|
1198
|
+
? `${tr('toast.purged', { n: purged.length })} · ${tr('toast.partial', { n: skipped })}`
|
|
1199
|
+
: tr('toast.purged', { n: purged.length }));
|
|
1200
|
+
} else {
|
|
1201
|
+
showToast('error', t('error.purge'));
|
|
1202
|
+
}
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
const result = await post('/delete', { ids: confirm.ids, stopActive: true });
|
|
1207
|
+
const deleted = Array.isArray(result.deleted) ? result.deleted : [];
|
|
1208
|
+
const trashIds = Array.isArray(result.trashIds) ? result.trashIds : [];
|
|
1209
|
+
const pending = Array.isArray(result.pending) ? result.pending : [];
|
|
1210
|
+
const skipped = (Array.isArray(result.skipped) ? result.skipped.length : 0) + (Array.isArray(result.errors) ? result.errors.length : 0);
|
|
1211
|
+
setConfirm(null);
|
|
1212
|
+
setSelectedIds((previous) => previous.filter((id) => !deleted.includes(id)));
|
|
1213
|
+
await load({ silent: true });
|
|
1214
|
+
await refreshNative();
|
|
1215
|
+
if (!document.querySelector('.nsm')) {
|
|
1216
|
+
try { layoutService?.selectPanel?.(PANEL_ID); } catch { /* The panel can be reopened from the sidebar. */ }
|
|
1217
|
+
}
|
|
1218
|
+
if (deleted.length > 0) {
|
|
1219
|
+
let message = tr('toast.deleted', { n: deleted.length });
|
|
1220
|
+
if (pending.length > 0) message += ` · ${tr('toast.movedPending', { n: pending.length })}`;
|
|
1221
|
+
if (skipped > 0) message += ` · ${tr('toast.partial', { n: skipped })}`;
|
|
1222
|
+
const undo = trashIds.length > 0
|
|
1223
|
+
? { label: t('action.undo'), onClick: () => restoreEntries(trashIds) }
|
|
1224
|
+
: undefined;
|
|
1225
|
+
showToast(skipped > 0 ? 'info' : 'ok', message, undo);
|
|
1226
|
+
} else {
|
|
1227
|
+
showToast('error', t('error.action'));
|
|
1228
|
+
}
|
|
1229
|
+
} catch (failure) {
|
|
1230
|
+
showToast('error', failure && failure.message ? failure.message : t('error.action'));
|
|
1231
|
+
} finally {
|
|
1232
|
+
setBusy(false);
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
function exportSessions(ids) {
|
|
1237
|
+
const list = Array.isArray(ids) ? ids.filter((id) => typeof id === 'string' && id !== '') : [];
|
|
1238
|
+
if (sessions.length === 0) {
|
|
1239
|
+
showToast('error', t('toast.noExport'));
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
const url = list.length > 0 ? `${API}/export?ids=${encodeURIComponent(list.join(','))}` : `${API}/export`;
|
|
1243
|
+
triggerDownload(url);
|
|
1244
|
+
showToast('info', t('toast.exportStarted'));
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
async function importFiles(files) {
|
|
1248
|
+
const list = Array.from(files || []).filter((file) => file && /\.json$/i.test(file.name || ''));
|
|
1249
|
+
if (list.length === 0) {
|
|
1250
|
+
showToast('error', t('error.action'));
|
|
1251
|
+
return;
|
|
1252
|
+
}
|
|
1253
|
+
setImporting(true);
|
|
1254
|
+
setImportReport(null);
|
|
1255
|
+
let imported = 0;
|
|
1256
|
+
let skipped = 0;
|
|
1257
|
+
let failed = 0;
|
|
1258
|
+
const details = [];
|
|
1259
|
+
for (const file of list) {
|
|
1260
|
+
try {
|
|
1261
|
+
const text = await file.text();
|
|
1262
|
+
let bundle;
|
|
1263
|
+
try {
|
|
1264
|
+
bundle = JSON.parse(text);
|
|
1265
|
+
} catch {
|
|
1266
|
+
failed += 1;
|
|
1267
|
+
details.push(`${file.name}: JSON`);
|
|
1268
|
+
continue;
|
|
1269
|
+
}
|
|
1270
|
+
const result = await post('/import', bundle);
|
|
1271
|
+
imported += Number(result.imported) || 0;
|
|
1272
|
+
skipped += Array.isArray(result.skipped) ? result.skipped.length : 0;
|
|
1273
|
+
failed += Array.isArray(result.errors) ? result.errors.length : 0;
|
|
1274
|
+
for (const item of Array.isArray(result.skipped) ? result.skipped.slice(0, 3) : []) {
|
|
1275
|
+
details.push(`${file.name}: ${String(item.reason || 'skipped')}`);
|
|
1276
|
+
}
|
|
1277
|
+
for (const item of Array.isArray(result.errors) ? result.errors.slice(0, 3) : []) {
|
|
1278
|
+
details.push(`${file.name}: ${String(item.message || 'failed')}`);
|
|
1279
|
+
}
|
|
1280
|
+
} catch (failure) {
|
|
1281
|
+
failed += 1;
|
|
1282
|
+
details.push(`${file.name}: ${failure && failure.message ? failure.message : 'failed'}`);
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
setImportReport({ imported, skipped, failed, details });
|
|
1286
|
+
await load({ silent: true });
|
|
1287
|
+
await refreshNative();
|
|
1288
|
+
setImporting(false);
|
|
1289
|
+
if (imported > 0) {
|
|
1290
|
+
showToast(skipped + failed > 0 ? 'info' : 'ok', skipped + failed > 0
|
|
1291
|
+
? `${tr('toast.imported', { n: imported })} · ${tr('toast.partial', { n: skipped + failed })}`
|
|
1292
|
+
: tr('toast.imported', { n: imported }));
|
|
1293
|
+
} else {
|
|
1294
|
+
showToast('error', details.length > 0 ? details[0] : t('error.action'));
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
function onFilePicked(event) {
|
|
1299
|
+
// Snapshot the FileList before clearing the input: setting value to
|
|
1300
|
+
// '' can empty the live list and silently drop the selection.
|
|
1301
|
+
const files = event.target.files ? Array.from(event.target.files) : [];
|
|
1302
|
+
event.target.value = '';
|
|
1303
|
+
if (files.length > 0) importFiles(files);
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
function hasFiles(event) {
|
|
1307
|
+
return Boolean(event.dataTransfer && Array.from(event.dataTransfer.types || []).includes('Files'));
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
function onDragEnter(event) {
|
|
1311
|
+
if (!hasFiles(event)) return;
|
|
1312
|
+
event.preventDefault();
|
|
1313
|
+
dragDepth.current += 1;
|
|
1314
|
+
setDragActive(true);
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
function onDragOver(event) {
|
|
1318
|
+
if (!hasFiles(event)) return;
|
|
1319
|
+
event.preventDefault();
|
|
1320
|
+
if (event.dataTransfer) event.dataTransfer.dropEffect = 'copy';
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
function onDragLeave() {
|
|
1324
|
+
dragDepth.current = Math.max(0, dragDepth.current - 1);
|
|
1325
|
+
if (dragDepth.current === 0) setDragActive(false);
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
function onDrop(event) {
|
|
1329
|
+
if (!hasFiles(event)) return;
|
|
1330
|
+
event.preventDefault();
|
|
1331
|
+
dragDepth.current = 0;
|
|
1332
|
+
setDragActive(false);
|
|
1333
|
+
if (event.dataTransfer && event.dataTransfer.files) importFiles(event.dataTransfer.files);
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
function fallbackCopy(text) {
|
|
1337
|
+
try {
|
|
1338
|
+
const area = document.createElement('textarea');
|
|
1339
|
+
area.value = text;
|
|
1340
|
+
area.setAttribute('readonly', '');
|
|
1341
|
+
area.style.position = 'fixed';
|
|
1342
|
+
area.style.left = '-9999px';
|
|
1343
|
+
area.style.top = '0';
|
|
1344
|
+
document.body.appendChild(area);
|
|
1345
|
+
area.select();
|
|
1346
|
+
area.setSelectionRange(0, area.value.length);
|
|
1347
|
+
const copied = document.execCommand('copy');
|
|
1348
|
+
area.remove();
|
|
1349
|
+
return copied;
|
|
1350
|
+
} catch {
|
|
1351
|
+
return false;
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
async function copyId(id) {
|
|
1356
|
+
try {
|
|
1357
|
+
await navigator.clipboard.writeText(id);
|
|
1358
|
+
showToast('ok', t('toast.copied'));
|
|
1359
|
+
} catch {
|
|
1360
|
+
if (fallbackCopy(id)) showToast('ok', t('toast.copied'));
|
|
1361
|
+
else showToast('error', t('error.action'));
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
function statusOf(session) {
|
|
1366
|
+
if (session.running) return 'live';
|
|
1367
|
+
if (session.live) return 'open';
|
|
1368
|
+
if (session.archived) return 'archived';
|
|
1369
|
+
if (session.origin === 'subagent') return 'subagent';
|
|
1370
|
+
return 'idle';
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
function sessionBadges(session) {
|
|
1374
|
+
const badges = [];
|
|
1375
|
+
if (session.running) badges.push(h('span', { key: 'live', className: 'nsm__badge nsm__badge--live' }, t('status.live')));
|
|
1376
|
+
else if (session.live) badges.push(h('span', { key: 'open', className: 'nsm__badge nsm__badge--open' }, t('status.open')));
|
|
1377
|
+
if (session.archived) badges.push(h('span', { key: 'archived', className: 'nsm__badge nsm__badge--archived' }, t('status.archived')));
|
|
1378
|
+
if (session.origin === 'subagent') badges.push(h('span', { key: 'subagent', className: 'nsm__badge nsm__badge--subagent' }, t('status.subagent')));
|
|
1379
|
+
if (session.formatStatus === 'migration-required') badges.push(h('span', { key: 'migration', className: 'nsm__badge nsm__badge--migration' }, t('status.migration')));
|
|
1380
|
+
if (session.pinned) badges.push(h('span', { key: 'pinned', className: 'nsm__badge nsm__badge--pinned' }, h(Glyph, { name: 'pin', size: 9 }), t('status.pinned')));
|
|
1381
|
+
return badges;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
function renderRow(session) {
|
|
1385
|
+
const selected = selectedSet.has(session.id);
|
|
1386
|
+
const canDelete = session.exists === true;
|
|
1387
|
+
const title = session.title || t('untitled');
|
|
1388
|
+
return h('div', {
|
|
1389
|
+
key: session.id,
|
|
1390
|
+
className: `nsm__row${selected ? ' is-selected' : ''}${focusedId === session.id ? ' is-focused' : ''}${session.live ? ' is-live' : ''}`,
|
|
1391
|
+
role: 'treeitem',
|
|
1392
|
+
tabIndex: 0,
|
|
1393
|
+
'aria-selected': selected ? 'true' : 'false',
|
|
1394
|
+
'aria-label': title,
|
|
1395
|
+
onClick: () => setFocusedId(session.id),
|
|
1396
|
+
onDoubleClick: () => openSession(session),
|
|
1397
|
+
onKeyDown: (event) => {
|
|
1398
|
+
if (event.target !== event.currentTarget) return;
|
|
1399
|
+
if (event.key === ' ') {
|
|
1400
|
+
event.preventDefault();
|
|
1401
|
+
toggleOne(session.id);
|
|
1402
|
+
} else if (event.key === 'Enter') {
|
|
1403
|
+
event.preventDefault();
|
|
1404
|
+
openSession(session);
|
|
1405
|
+
} else if (event.key === 'Delete' && canDelete) {
|
|
1406
|
+
event.preventDefault();
|
|
1407
|
+
requestDelete([session.id]);
|
|
1408
|
+
}
|
|
1409
|
+
},
|
|
1410
|
+
},
|
|
1411
|
+
h(Check, {
|
|
1412
|
+
checked: selected,
|
|
1413
|
+
label: title,
|
|
1414
|
+
onChange: () => toggleOne(session.id),
|
|
1415
|
+
}),
|
|
1416
|
+
h('span', {
|
|
1417
|
+
className: `nsm__dot is-${statusOf(session)}`,
|
|
1418
|
+
title: session.running ? t('status.live') : session.live ? t('status.open') : session.archived ? t('status.archived') : session.origin === 'subagent' ? t('status.subagent') : '',
|
|
1419
|
+
}),
|
|
1420
|
+
h('div', { className: 'nsm__row-main' },
|
|
1421
|
+
h('div', { className: 'nsm__row-title-line' },
|
|
1422
|
+
h('span', { className: 'nsm__row-title', title }, title),
|
|
1423
|
+
h('span', { className: 'nsm__badges' }, sessionBadges(session)),
|
|
1424
|
+
),
|
|
1425
|
+
h('div', { className: 'nsm__row-meta' },
|
|
1426
|
+
h('span', { className: 'nsm__row-path', title: session.cwd || '' }, shortPath(session.cwd)),
|
|
1427
|
+
h('span', { className: 'nsm__meta-sep' }, '·'),
|
|
1428
|
+
h('span', null, relativeTime(session.updatedAt)),
|
|
1429
|
+
h('span', { className: 'nsm__meta-sep' }, '·'),
|
|
1430
|
+
h('span', { className: 'nsm__meta-size' }, formatBytes(session.sizeBytes)),
|
|
1431
|
+
),
|
|
1432
|
+
),
|
|
1433
|
+
h('div', { className: 'nsm__row-actions' },
|
|
1434
|
+
h('button', {
|
|
1435
|
+
type: 'button',
|
|
1436
|
+
className: 'nsm__icon-button',
|
|
1437
|
+
title: t('action.open'),
|
|
1438
|
+
'aria-label': t('action.open'),
|
|
1439
|
+
onClick: (event) => { event.stopPropagation(); openSession(session); },
|
|
1440
|
+
}, h(Glyph, { name: 'open', size: 13 })),
|
|
1441
|
+
h('button', {
|
|
1442
|
+
type: 'button',
|
|
1443
|
+
className: 'nsm__icon-button',
|
|
1444
|
+
title: t('action.export'),
|
|
1445
|
+
'aria-label': t('action.export'),
|
|
1446
|
+
onClick: (event) => { event.stopPropagation(); exportSessions([session.id]); },
|
|
1447
|
+
}, h(Glyph, { name: 'export', size: 13 })),
|
|
1448
|
+
h('button', {
|
|
1449
|
+
type: 'button',
|
|
1450
|
+
className: 'nsm__icon-button nsm__icon-button--danger',
|
|
1451
|
+
title: canDelete ? t('action.delete') : t('error.action'),
|
|
1452
|
+
'aria-label': t('action.delete'),
|
|
1453
|
+
disabled: !canDelete,
|
|
1454
|
+
onClick: (event) => { event.stopPropagation(); requestDelete([session.id]); },
|
|
1455
|
+
}, h(Glyph, { name: 'trash', size: 13 })),
|
|
1456
|
+
),
|
|
1457
|
+
);
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
function renderMonth(group, month) {
|
|
1461
|
+
const key = `${group.key}::${month.key}`;
|
|
1462
|
+
const isCollapsed = normalizedQuery === '' && stateFilter === 'all' && collapsed.has(key);
|
|
1463
|
+
const ids = month.sessions.map((session) => session.id);
|
|
1464
|
+
const all = ids.length > 0 && ids.every((id) => selectedSet.has(id));
|
|
1465
|
+
const some = !all && ids.some((id) => selectedSet.has(id));
|
|
1466
|
+
return h('div', { key: month.key, className: 'nsm__month' },
|
|
1467
|
+
h('div', {
|
|
1468
|
+
className: 'nsm__month-head',
|
|
1469
|
+
role: 'button',
|
|
1470
|
+
tabIndex: 0,
|
|
1471
|
+
'aria-expanded': isCollapsed ? 'false' : 'true',
|
|
1472
|
+
onClick: () => toggleCollapsed(key),
|
|
1473
|
+
onKeyDown: (event) => {
|
|
1474
|
+
if (event.target !== event.currentTarget) return;
|
|
1475
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
1476
|
+
event.preventDefault();
|
|
1477
|
+
toggleCollapsed(key);
|
|
1478
|
+
}
|
|
1479
|
+
},
|
|
1480
|
+
},
|
|
1481
|
+
h('span', { className: `nsm__chevron${isCollapsed ? '' : ' is-open'}` }, h(Glyph, { name: 'chevron', size: 12 })),
|
|
1482
|
+
h('span', { className: 'nsm__month-title' }, monthLabel(month.key)),
|
|
1483
|
+
h('span', { className: 'nsm__month-count' }, tr('tree.monthCount', { n: ids.length })),
|
|
1484
|
+
h('span', { className: 'nsm__count' }, formatBytes(month.bytes)),
|
|
1485
|
+
h(Check, { checked: all, mixed: some, label: monthLabel(month.key), onChange: (next) => toggleSelected(ids, next) }),
|
|
1486
|
+
),
|
|
1487
|
+
isCollapsed ? null : h('div', { className: 'nsm__rows', role: 'group' }, month.sessions.map(renderRow)),
|
|
1488
|
+
);
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
function renderGroup(group) {
|
|
1492
|
+
const ids = group.sessions.map((session) => session.id);
|
|
1493
|
+
const isCollapsed = normalizedQuery === '' && stateFilter === 'all' && collapsed.has(group.key);
|
|
1494
|
+
const all = ids.length > 0 && ids.every((id) => selectedSet.has(id));
|
|
1495
|
+
const some = !all && ids.some((id) => selectedSet.has(id));
|
|
1496
|
+
const title = groupTitle(group);
|
|
1497
|
+
return h('section', { key: group.key, className: 'nsm__group', role: 'group', 'aria-label': title },
|
|
1498
|
+
h('div', {
|
|
1499
|
+
className: 'nsm__group-head',
|
|
1500
|
+
role: 'button',
|
|
1501
|
+
tabIndex: 0,
|
|
1502
|
+
'aria-expanded': isCollapsed ? 'false' : 'true',
|
|
1503
|
+
onClick: () => toggleCollapsed(group.key),
|
|
1504
|
+
onKeyDown: (event) => {
|
|
1505
|
+
if (event.target !== event.currentTarget) return;
|
|
1506
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
1507
|
+
event.preventDefault();
|
|
1508
|
+
toggleCollapsed(group.key);
|
|
1509
|
+
}
|
|
1510
|
+
},
|
|
1511
|
+
},
|
|
1512
|
+
h('span', { className: `nsm__chevron${isCollapsed ? '' : ' is-open'}` }, h(Glyph, { name: 'chevron', size: 13 })),
|
|
1513
|
+
h('span', { className: 'nsm__folder' }, h(Glyph, { name: 'folder', size: 15 })),
|
|
1514
|
+
h('div', { className: 'nsm__group-copy' },
|
|
1515
|
+
h('div', { className: 'nsm__group-title' }, title),
|
|
1516
|
+
group.path ? h('div', { className: 'nsm__group-path', title: group.path }, shortPath(group.path)) : null,
|
|
1517
|
+
),
|
|
1518
|
+
h('span', { className: 'nsm__count' }, sessionCount(ids.length)),
|
|
1519
|
+
h(Check, { checked: all, mixed: some, label: title, onChange: (next) => toggleSelected(ids, next) }),
|
|
1520
|
+
),
|
|
1521
|
+
isCollapsed ? null : h('div', { className: 'nsm__months' }, group.months.map((month) => renderMonth(group, month))),
|
|
1522
|
+
);
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
function trashBadges(entry) {
|
|
1526
|
+
const badges = [];
|
|
1527
|
+
badges.push(h('span', { key: 'deleted', className: 'nsm__badge nsm__badge--deleted' }, entry.pending ? t('trash.pending') : t('status.deleted')));
|
|
1528
|
+
if (entry.wasRunning) badges.push(h('span', { key: 'running', className: 'nsm__badge nsm__badge--live' }, t('trash.wasRunning')));
|
|
1529
|
+
if (entry.wasArchived) badges.push(h('span', { key: 'archived', className: 'nsm__badge nsm__badge--archived' }, t('trash.wasArchived')));
|
|
1530
|
+
return badges;
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
function renderTrashRow(entry) {
|
|
1534
|
+
const selected = trashSelectedSet.has(entry.trashId);
|
|
1535
|
+
const title = entry.title || t('untitled');
|
|
1536
|
+
return h('div', {
|
|
1537
|
+
key: entry.trashId,
|
|
1538
|
+
className: `nsm__row nsm__row--trash${selected ? ' is-selected' : ''}${focusedTrashId === entry.trashId ? ' is-focused' : ''}${entry.pending ? ' is-pending' : ''}`,
|
|
1539
|
+
role: 'treeitem',
|
|
1540
|
+
tabIndex: 0,
|
|
1541
|
+
'aria-selected': selected ? 'true' : 'false',
|
|
1542
|
+
'aria-label': title,
|
|
1543
|
+
onClick: () => setFocusedTrashId(entry.trashId),
|
|
1544
|
+
onKeyDown: (event) => {
|
|
1545
|
+
if (event.target !== event.currentTarget) return;
|
|
1546
|
+
if (event.key === ' ') {
|
|
1547
|
+
event.preventDefault();
|
|
1548
|
+
toggleTrashOne(entry.trashId);
|
|
1549
|
+
}
|
|
1550
|
+
},
|
|
1551
|
+
},
|
|
1552
|
+
h(Check, { checked: selected, label: title, onChange: () => toggleTrashOne(entry.trashId) }),
|
|
1553
|
+
h('span', { className: `nsm__dot ${entry.pending ? 'is-pending' : 'is-deleted'}`, title: entry.pending ? t('trash.pending') : t('status.deleted') }),
|
|
1554
|
+
h('div', { className: 'nsm__row-main' },
|
|
1555
|
+
h('div', { className: 'nsm__row-title-line' },
|
|
1556
|
+
h('span', { className: 'nsm__row-title', title }, title),
|
|
1557
|
+
h('span', { className: 'nsm__badges' }, trashBadges(entry)),
|
|
1558
|
+
),
|
|
1559
|
+
h('div', { className: 'nsm__row-meta' },
|
|
1560
|
+
h('span', { className: 'nsm__row-path', title: entry.cwd || '' }, shortPath(entry.cwd)),
|
|
1561
|
+
h('span', { className: 'nsm__meta-sep' }, '·'),
|
|
1562
|
+
h('span', null, `${t('trash.deletedAt')} ${relativeTime(entry.deletedAt)}`),
|
|
1563
|
+
h('span', { className: 'nsm__meta-sep' }, '·'),
|
|
1564
|
+
h('span', { className: 'nsm__meta-size' }, formatBytes(entry.sizeBytes)),
|
|
1565
|
+
),
|
|
1566
|
+
),
|
|
1567
|
+
h('div', { className: 'nsm__row-actions' },
|
|
1568
|
+
h('button', {
|
|
1569
|
+
type: 'button',
|
|
1570
|
+
className: 'nsm__icon-button',
|
|
1571
|
+
title: t('trash.restore'),
|
|
1572
|
+
'aria-label': t('trash.restore'),
|
|
1573
|
+
disabled: busy,
|
|
1574
|
+
onClick: (event) => { event.stopPropagation(); restoreEntries([entry.trashId]); },
|
|
1575
|
+
}, h(Glyph, { name: 'restore', size: 13 })),
|
|
1576
|
+
h('button', {
|
|
1577
|
+
type: 'button',
|
|
1578
|
+
className: 'nsm__icon-button nsm__icon-button--danger',
|
|
1579
|
+
title: entry.pending ? t('trash.pendingHint') : t('trash.purge'),
|
|
1580
|
+
'aria-label': t('trash.purge'),
|
|
1581
|
+
disabled: busy || entry.pending,
|
|
1582
|
+
onClick: (event) => { event.stopPropagation(); requestPurge([entry.trashId]); },
|
|
1583
|
+
}, h(Glyph, { name: 'trash', size: 13 })),
|
|
1584
|
+
),
|
|
1585
|
+
);
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
function renderTrashGroup(group) {
|
|
1589
|
+
const key = `trash:${group.key}`;
|
|
1590
|
+
const isCollapsed = normalizedQuery === '' && collapsed.has(key);
|
|
1591
|
+
const ids = group.entries.map((entry) => entry.trashId);
|
|
1592
|
+
const all = ids.length > 0 && ids.every((id) => trashSelectedSet.has(id));
|
|
1593
|
+
const some = !all && ids.some((id) => trashSelectedSet.has(id));
|
|
1594
|
+
const label = tr('trash.deletedGroup', { label: monthLabel(group.key) });
|
|
1595
|
+
return h('section', { key, className: 'nsm__group nsm__group--trash', role: 'group', 'aria-label': label },
|
|
1596
|
+
h('div', {
|
|
1597
|
+
className: 'nsm__group-head',
|
|
1598
|
+
role: 'button',
|
|
1599
|
+
tabIndex: 0,
|
|
1600
|
+
'aria-expanded': isCollapsed ? 'false' : 'true',
|
|
1601
|
+
onClick: () => toggleCollapsed(key),
|
|
1602
|
+
onKeyDown: (event) => {
|
|
1603
|
+
if (event.target !== event.currentTarget) return;
|
|
1604
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
1605
|
+
event.preventDefault();
|
|
1606
|
+
toggleCollapsed(key);
|
|
1607
|
+
}
|
|
1608
|
+
},
|
|
1609
|
+
},
|
|
1610
|
+
h('span', { className: `nsm__chevron${isCollapsed ? '' : ' is-open'}` }, h(Glyph, { name: 'chevron', size: 13 })),
|
|
1611
|
+
h('span', { className: 'nsm__folder nsm__folder--trash' }, h(Glyph, { name: 'trash', size: 15 })),
|
|
1612
|
+
h('div', { className: 'nsm__group-copy' },
|
|
1613
|
+
h('div', { className: 'nsm__group-title' }, label),
|
|
1614
|
+
),
|
|
1615
|
+
h('span', { className: 'nsm__count' }, sessionCount(ids.length)),
|
|
1616
|
+
h('Check', { checked: all, mixed: some, label, onChange: (next) => toggleTrashSelected(ids, next) }),
|
|
1617
|
+
),
|
|
1618
|
+
isCollapsed ? null : h('div', { className: 'nsm__rows', role: 'group' }, group.entries.map(renderTrashRow)),
|
|
1619
|
+
);
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
function fact(label, value, options = {}) {
|
|
1623
|
+
return h('div', { className: 'nsm__fact', key: label },
|
|
1624
|
+
h('dt', null, label),
|
|
1625
|
+
h('dd', null, options.button ? h('button', { type: 'button', onClick: options.onClick, title: options.title }, value) : value),
|
|
1626
|
+
);
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
function renderTrashDetail() {
|
|
1630
|
+
if (!focusedTrash) {
|
|
1631
|
+
return h('section', { className: 'nsm__card nsm__detail-card nsm__detail-empty' },
|
|
1632
|
+
h('div', { className: 'nsm__card-head' }, h('h2', null, t('trash.detail'))),
|
|
1633
|
+
h('p', null, t('trash.emptyBody')),
|
|
1634
|
+
);
|
|
1635
|
+
}
|
|
1636
|
+
const entry = focusedTrash;
|
|
1637
|
+
return h('section', { className: 'nsm__card nsm__detail-card' },
|
|
1638
|
+
h('div', { className: 'nsm__card-head' },
|
|
1639
|
+
h('h2', { className: 'nsm__detail-title' }, entry.title || t('untitled')),
|
|
1640
|
+
h('button', {
|
|
1641
|
+
type: 'button',
|
|
1642
|
+
className: 'nsm__icon-button',
|
|
1643
|
+
title: t('action.close'),
|
|
1644
|
+
'aria-label': t('action.close'),
|
|
1645
|
+
onClick: () => setFocusedTrashId(null),
|
|
1646
|
+
}, h(Glyph, { name: 'close', size: 13 })),
|
|
1647
|
+
),
|
|
1648
|
+
h('div', { className: 'nsm__detail-badges' }, trashBadges(entry)),
|
|
1649
|
+
h('dl', { className: 'nsm__facts' },
|
|
1650
|
+
fact(t('trash.deletedAt'), formatDateTime(entry.deletedAt)),
|
|
1651
|
+
fact(t('trash.originalPath'), shortPath(entry.cwd), { title: entry.cwd || '', button: true, onClick: () => entry.cwd && copyId(entry.cwd) }),
|
|
1652
|
+
fact(t('detail.created'), formatDateTime(entry.createdAt)),
|
|
1653
|
+
fact(t('detail.size'), formatBytes(entry.sizeBytes)),
|
|
1654
|
+
fact(t('detail.id'), h('code', null, entry.id), { title: t('action.copyId'), button: true, onClick: () => copyId(entry.id) }),
|
|
1655
|
+
),
|
|
1656
|
+
entry.pending ? h('p', { className: 'nsm__hint', style: { marginTop: 10 } }, t('trash.pendingHint')) : null,
|
|
1657
|
+
h('div', { className: 'nsm__detail-actions' },
|
|
1658
|
+
h('button', {
|
|
1659
|
+
type: 'button',
|
|
1660
|
+
className: 'nsm__button nsm__button--small nsm__button--primary',
|
|
1661
|
+
disabled: busy,
|
|
1662
|
+
onClick: () => restoreEntries([entry.trashId]),
|
|
1663
|
+
}, h(Glyph, { name: 'restore', size: 12 }), t('trash.restore')),
|
|
1664
|
+
h('button', {
|
|
1665
|
+
type: 'button',
|
|
1666
|
+
className: 'nsm__button nsm__button--small nsm__button--danger',
|
|
1667
|
+
disabled: busy || entry.pending,
|
|
1668
|
+
title: entry.pending ? t('trash.pendingHint') : t('trash.purge'),
|
|
1669
|
+
onClick: () => requestPurge([entry.trashId]),
|
|
1670
|
+
}, h(Glyph, { name: 'trash', size: 12 }), t('trash.purge')),
|
|
1671
|
+
),
|
|
1672
|
+
);
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
function renderDetail() {
|
|
1676
|
+
if (view === 'trash') return renderTrashDetail();
|
|
1677
|
+
if (!focusedSession) {
|
|
1678
|
+
return h('section', { className: 'nsm__card nsm__detail-card nsm__detail-empty' },
|
|
1679
|
+
h('div', { className: 'nsm__card-head' }, h('h2', null, t('detail.title'))),
|
|
1680
|
+
h('p', null, t('detail.empty')),
|
|
1681
|
+
);
|
|
1682
|
+
}
|
|
1683
|
+
const session = focusedSession;
|
|
1684
|
+
const canDelete = session.exists === true;
|
|
1685
|
+
return h('section', { className: 'nsm__card nsm__detail-card' },
|
|
1686
|
+
h('div', { className: 'nsm__card-head' },
|
|
1687
|
+
h('h2', { className: 'nsm__detail-title' }, session.title || t('untitled')),
|
|
1688
|
+
h('button', {
|
|
1689
|
+
type: 'button',
|
|
1690
|
+
className: 'nsm__icon-button',
|
|
1691
|
+
title: t('action.close'),
|
|
1692
|
+
'aria-label': t('action.close'),
|
|
1693
|
+
onClick: () => setFocusedId(null),
|
|
1694
|
+
}, h(Glyph, { name: 'close', size: 13 })),
|
|
1695
|
+
),
|
|
1696
|
+
h('div', { className: 'nsm__detail-badges' }, sessionBadges(session)),
|
|
1697
|
+
h('dl', { className: 'nsm__facts' },
|
|
1698
|
+
fact(t('detail.workspace'), session.workspace ? session.workspace.title : session.group && session.group.kind !== 'none' ? session.group.title : t('tree.ungrouped')),
|
|
1699
|
+
fact(t('detail.path'), shortPath(session.cwd), { title: session.cwd || '', button: true, onClick: () => session.cwd && copyId(session.cwd) }),
|
|
1700
|
+
fact(t('detail.created'), formatDateTime(session.createdAt)),
|
|
1701
|
+
fact(t('detail.updated'), formatDateTime(session.updatedAt)),
|
|
1702
|
+
fact(t('detail.size'), formatBytes(session.sizeBytes)),
|
|
1703
|
+
fact(t('detail.turns'), String(session.turns || 0)),
|
|
1704
|
+
session.agentPreset ? fact(t('detail.preset'), session.agentPreset) : null,
|
|
1705
|
+
fact(t('detail.id'), h('code', null, session.id), { title: t('action.copyId'), button: true, onClick: () => copyId(session.id) }),
|
|
1706
|
+
),
|
|
1707
|
+
h('div', { className: 'nsm__detail-actions' },
|
|
1708
|
+
h('button', { type: 'button', className: 'nsm__button nsm__button--small nsm__button--primary', onClick: () => openSession(session) }, h(Glyph, { name: 'open', size: 12 }), t('action.open')),
|
|
1709
|
+
h('button', { type: 'button', className: 'nsm__button nsm__button--small', onClick: () => exportSessions([session.id]) }, h(Glyph, { name: 'export', size: 12 }), t('action.export')),
|
|
1710
|
+
h('button', {
|
|
1711
|
+
type: 'button',
|
|
1712
|
+
className: 'nsm__button nsm__button--small nsm__button--danger',
|
|
1713
|
+
disabled: !canDelete || busy,
|
|
1714
|
+
title: canDelete ? t('action.delete') : t('error.action'),
|
|
1715
|
+
onClick: () => requestDelete([session.id]),
|
|
1716
|
+
}, h(Glyph, { name: 'trash', size: 12 }), t('action.delete')),
|
|
1717
|
+
),
|
|
1718
|
+
);
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
const content = [];
|
|
1722
|
+
content.push(h('style', { key: 'styles' }, STYLES));
|
|
1723
|
+
content.push(h('header', { key: 'header', className: 'nsm__header' },
|
|
1724
|
+
h('div', { className: 'nsm__heading' },
|
|
1725
|
+
h('span', { className: 'nsm__mark' }, h(PageMark, { size: 58 })),
|
|
1726
|
+
h('div', { className: 'nsm__titles' },
|
|
1727
|
+
h('h1', { className: 'nsm__title' }, t('page.title')),
|
|
1728
|
+
h('p', { className: 'nsm__subtitle' }, t('page.subtitle')),
|
|
1729
|
+
),
|
|
1730
|
+
),
|
|
1731
|
+
h('div', { className: 'nsm__actions' },
|
|
1732
|
+
h('button', {
|
|
1733
|
+
type: 'button',
|
|
1734
|
+
className: 'nsm__button nsm__button--primary',
|
|
1735
|
+
disabled: importing,
|
|
1736
|
+
onClick: () => fileInputRef.current && fileInputRef.current.click(),
|
|
1737
|
+
}, h(Glyph, { name: 'import', size: 13 }), importing ? t('action.importing') : t('action.import')),
|
|
1738
|
+
h('button', {
|
|
1739
|
+
type: 'button',
|
|
1740
|
+
className: 'nsm__button',
|
|
1741
|
+
disabled: sessions.length === 0,
|
|
1742
|
+
onClick: () => exportSessions([]),
|
|
1743
|
+
}, h(Glyph, { name: 'export', size: 13 }), t('action.exportAll')),
|
|
1744
|
+
h('button', { type: 'button', className: 'nsm__button nsm__button--ghost', onClick: goBack }, t('action.back')),
|
|
1745
|
+
),
|
|
1746
|
+
));
|
|
1747
|
+
|
|
1748
|
+
if (importReport) {
|
|
1749
|
+
const parts = [tr('import.imported', { n: importReport.imported })];
|
|
1750
|
+
if (importReport.skipped > 0) parts.push(tr('import.skipped', { n: importReport.skipped }));
|
|
1751
|
+
if (importReport.failed > 0) parts.push(tr('import.failed', { n: importReport.failed }));
|
|
1752
|
+
content.push(h('div', { key: 'report', className: 'nsm__report', role: 'status' },
|
|
1753
|
+
h('div', { className: 'nsm__report-head' },
|
|
1754
|
+
h(Glyph, { name: 'alert', size: 13 }),
|
|
1755
|
+
h('span', null, `${t('import.report')} · ${parts.join(' · ')}`),
|
|
1756
|
+
h('button', {
|
|
1757
|
+
type: 'button',
|
|
1758
|
+
className: 'nsm__icon-button',
|
|
1759
|
+
title: t('action.dismiss'),
|
|
1760
|
+
'aria-label': t('action.dismiss'),
|
|
1761
|
+
onClick: () => setImportReport(null),
|
|
1762
|
+
}, h(Glyph, { name: 'close', size: 12 })),
|
|
1763
|
+
),
|
|
1764
|
+
importReport.details.length > 0
|
|
1765
|
+
? h('ul', null, importReport.details.slice(0, 5).map((detail, index) => h('li', { key: index }, detail)))
|
|
1766
|
+
: null,
|
|
1767
|
+
));
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
if (data) {
|
|
1771
|
+
content.push(h('section', { key: 'stats', className: 'nsm__stats' },
|
|
1772
|
+
h('div', { className: 'nsm__stat' }, h('span', { className: 'nsm__stat-label' }, t('stats.total')), h('span', { className: 'nsm__stat-value' }, String(stats.total))),
|
|
1773
|
+
h('div', { className: 'nsm__stat' }, h('span', { className: 'nsm__stat-label' }, t('stats.live')), h('span', { className: 'nsm__stat-value' }, String(stats.live))),
|
|
1774
|
+
h('div', { className: 'nsm__stat' }, h('span', { className: 'nsm__stat-label' }, t('stats.groups')), h('span', { className: 'nsm__stat-value' }, String(stats.groups))),
|
|
1775
|
+
h('div', { className: 'nsm__stat' }, h('span', { className: 'nsm__stat-label' }, t('stats.size')), h('span', { className: 'nsm__stat-value' }, formatBytes(stats.bytes))),
|
|
1776
|
+
));
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
content.push(h('div', { key: 'toolbar', className: 'nsm__toolbar' },
|
|
1780
|
+
h('div', { className: 'nsm__viewtabs', role: 'tablist' },
|
|
1781
|
+
h('button', {
|
|
1782
|
+
type: 'button',
|
|
1783
|
+
role: 'tab',
|
|
1784
|
+
'aria-selected': view === 'sessions' ? 'true' : 'false',
|
|
1785
|
+
className: `nsm__viewtab${view === 'sessions' ? ' is-active' : ''}`,
|
|
1786
|
+
onClick: () => setView('sessions'),
|
|
1787
|
+
}, t('view.sessions')),
|
|
1788
|
+
h('button', {
|
|
1789
|
+
type: 'button',
|
|
1790
|
+
role: 'tab',
|
|
1791
|
+
'aria-selected': view === 'trash' ? 'true' : 'false',
|
|
1792
|
+
className: `nsm__viewtab${view === 'trash' ? ' is-active' : ''}`,
|
|
1793
|
+
onClick: () => setView('trash'),
|
|
1794
|
+
}, t('view.trash'), h('span', { className: 'nsm__tab-count' }, String(trash.length))),
|
|
1795
|
+
),
|
|
1796
|
+
h('div', { className: 'nsm__search' },
|
|
1797
|
+
h('span', { className: 'nsm__search-icon' }, h(Glyph, { name: 'search', size: 14 })),
|
|
1798
|
+
h('input', {
|
|
1799
|
+
type: 'search',
|
|
1800
|
+
value: query,
|
|
1801
|
+
placeholder: view === 'trash' ? t('search.trashPlaceholder') : t('search.placeholder'),
|
|
1802
|
+
'aria-label': view === 'trash' ? t('search.trashPlaceholder') : t('search.placeholder'),
|
|
1803
|
+
onChange: (event) => setQuery(event.target.value),
|
|
1804
|
+
}),
|
|
1805
|
+
query !== '' ? h('button', {
|
|
1806
|
+
type: 'button',
|
|
1807
|
+
className: 'nsm__search-clear',
|
|
1808
|
+
title: t('search.clear'),
|
|
1809
|
+
'aria-label': t('search.clear'),
|
|
1810
|
+
onClick: () => setQuery(''),
|
|
1811
|
+
}, h(Glyph, { name: 'close', size: 12 })) : null,
|
|
1812
|
+
),
|
|
1813
|
+
h(Check, {
|
|
1814
|
+
checked: activeAllSelected,
|
|
1815
|
+
mixed: activeSomeSelected,
|
|
1816
|
+
label: t('action.selectAll'),
|
|
1817
|
+
onChange: (next) => view === 'trash' ? toggleTrashSelected(visibleTrashIds, next) : toggleSelected(visibleIds, next),
|
|
1818
|
+
}),
|
|
1819
|
+
h('button', {
|
|
1820
|
+
type: 'button',
|
|
1821
|
+
className: 'nsm__button nsm__button--small nsm__button--ghost',
|
|
1822
|
+
disabled: activeVisibleIds.length === 0 && activeSelectionCount === 0,
|
|
1823
|
+
onClick: activeSelectionCount > 0
|
|
1824
|
+
? () => { if (view === 'trash') setSelectedTrashIds([]); else setSelectedIds([]); }
|
|
1825
|
+
: () => { if (view === 'trash') toggleTrashSelected(visibleTrashIds, true); else toggleSelected(visibleIds, true); },
|
|
1826
|
+
}, activeSelectionCount > 0 ? t('action.clearSelection') : t('action.selectAll')),
|
|
1827
|
+
h('span', { className: 'nsm__toolbar-spacer' }),
|
|
1828
|
+
h('button', { type: 'button', className: 'nsm__button nsm__button--small nsm__button--ghost', onClick: expandAll }, t('action.expandAll')),
|
|
1829
|
+
h('button', { type: 'button', className: 'nsm__button nsm__button--small nsm__button--ghost', onClick: collapseAll }, t('action.collapseAll')),
|
|
1830
|
+
h('button', {
|
|
1831
|
+
type: 'button',
|
|
1832
|
+
className: 'nsm__button nsm__button--small',
|
|
1833
|
+
disabled: status === 'refreshing' || status === 'loading',
|
|
1834
|
+
onClick: async () => {
|
|
1835
|
+
await load({ silent: true });
|
|
1836
|
+
await refreshNative();
|
|
1837
|
+
showToast('ok', t('toast.refreshed'));
|
|
1838
|
+
},
|
|
1839
|
+
}, h(Glyph, { name: 'refresh', size: 12 }), t('action.refresh')),
|
|
1840
|
+
));
|
|
1841
|
+
|
|
1842
|
+
if (data && view === 'sessions') {
|
|
1843
|
+
content.push(h('div', { key: 'filters', className: 'nsm__filters', role: 'group', 'aria-label': t('filter.label') },
|
|
1844
|
+
FILTERS.map((id) => h('button', {
|
|
1845
|
+
key: id,
|
|
1846
|
+
type: 'button',
|
|
1847
|
+
className: `nsm__filter${stateFilter === id ? ' is-active' : ''}`,
|
|
1848
|
+
'aria-pressed': stateFilter === id ? 'true' : 'false',
|
|
1849
|
+
onClick: () => setStateFilter(id),
|
|
1850
|
+
}, t(`filter.${id}`), h('span', { className: 'nsm__filter-count' }, String(filterCounts[id] || 0)))),
|
|
1851
|
+
));
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
if (status === 'loading' && !data) {
|
|
1855
|
+
content.push(h('div', { key: 'loading', className: 'nsm__loading' }, h('span', { className: 'nsm__spinner' }), h('span', null, t('loading'))));
|
|
1856
|
+
} else if (status === 'error' && !data) {
|
|
1857
|
+
content.push(h('div', { key: 'error', className: 'nsm__error' },
|
|
1858
|
+
h('p', null, error || t('error.load')),
|
|
1859
|
+
h('button', { type: 'button', className: 'nsm__button', onClick: () => load({}) }, t('action.retry')),
|
|
1860
|
+
));
|
|
1861
|
+
} else if (data) {
|
|
1862
|
+
content.push(h('div', { key: 'layout', className: 'nsm__layout' },
|
|
1863
|
+
h('section', { key: 'tree', className: 'nsm__tree-card' },
|
|
1864
|
+
h('div', { className: 'nsm__tree-head' },
|
|
1865
|
+
h('h2', null, view === 'trash' ? t('trash.title') : t('tree.title')),
|
|
1866
|
+
h('span', { className: 'nsm__tree-head-meta' }, view === 'trash'
|
|
1867
|
+
? trashCount(visibleTrash.length)
|
|
1868
|
+
: sessionCount(visibleSessions.length)),
|
|
1869
|
+
),
|
|
1870
|
+
h('div', { className: 'nsm__tree-body', role: 'tree', 'aria-label': view === 'trash' ? t('trash.title') : t('page.title') },
|
|
1871
|
+
view === 'trash'
|
|
1872
|
+
? (visibleTrash.length === 0
|
|
1873
|
+
? h('div', { className: 'nsm__empty' },
|
|
1874
|
+
h('span', { className: 'nsm__empty-mark nsm__empty-mark--trash' }, h(Glyph, { name: 'trash', size: 52 })),
|
|
1875
|
+
h('h2', null, normalizedQuery === '' ? t('trash.empty') : t('tree.emptyFiltered')),
|
|
1876
|
+
h('p', null, normalizedQuery === '' ? t('trash.emptyBody') : t('tree.emptyFilteredBody')),
|
|
1877
|
+
normalizedQuery === ''
|
|
1878
|
+
? h('button', { type: 'button', className: 'nsm__button', onClick: () => setView('sessions') }, t('view.sessions'))
|
|
1879
|
+
: h('button', { type: 'button', className: 'nsm__button', onClick: () => setQuery('') }, t('search.clear')),
|
|
1880
|
+
)
|
|
1881
|
+
: trashGroups.map(renderTrashGroup))
|
|
1882
|
+
: (visibleSessions.length === 0
|
|
1883
|
+
? h('div', { className: 'nsm__empty' },
|
|
1884
|
+
h('span', { className: 'nsm__empty-mark' }, h(PageMark, { size: 64 })),
|
|
1885
|
+
h('h2', null, normalizedQuery === '' && stateFilter === 'all' ? t('empty.title') : t('tree.emptyFiltered')),
|
|
1886
|
+
h('p', null, normalizedQuery === '' && stateFilter === 'all' ? t('empty.body') : t('tree.emptyFilteredBody')),
|
|
1887
|
+
normalizedQuery === '' && stateFilter === 'all'
|
|
1888
|
+
? h('button', { type: 'button', className: 'nsm__button nsm__button--primary', onClick: () => fileInputRef.current && fileInputRef.current.click() }, t('empty.cta'))
|
|
1889
|
+
: h('button', { type: 'button', className: 'nsm__button', onClick: () => { setQuery(''); setStateFilter('all'); } }, t('search.clear')),
|
|
1890
|
+
)
|
|
1891
|
+
: groups.map(renderGroup)),
|
|
1892
|
+
),
|
|
1893
|
+
),
|
|
1894
|
+
h('aside', { key: 'aside', className: 'nsm__aside' },
|
|
1895
|
+
h('section', { className: 'nsm__card' },
|
|
1896
|
+
h('div', { className: 'nsm__card-head' }, h('h2', null, view === 'trash'
|
|
1897
|
+
? (selectedTrashEntries.length > 0 ? tr('selection.count', { n: selectedTrashEntries.length }) : t('selection.none'))
|
|
1898
|
+
: (selectedSessions.length > 0 ? tr('selection.count', { n: selectedSessions.length }) : t('selection.none')))),
|
|
1899
|
+
(view === 'trash' ? selectedTrashEntries.length > 0 : selectedSessions.length > 0)
|
|
1900
|
+
? h('p', { className: 'nsm__selection-size' }, tr('selection.size', { size: formatBytes(view === 'trash' ? selectedTrashBytes : selectedBytes) }))
|
|
1901
|
+
: null,
|
|
1902
|
+
h('div', { className: 'nsm__selection-actions' },
|
|
1903
|
+
view === 'trash' ? [
|
|
1904
|
+
h('button', {
|
|
1905
|
+
key: 'restore',
|
|
1906
|
+
type: 'button',
|
|
1907
|
+
className: 'nsm__button nsm__button--primary',
|
|
1908
|
+
disabled: selectedTrashEntries.length === 0 || busy,
|
|
1909
|
+
onClick: () => restoreEntries(selectedTrashEntries.map((entry) => entry.trashId)),
|
|
1910
|
+
}, h(Glyph, { name: 'restore', size: 13 }), t('trash.restoreSelected')),
|
|
1911
|
+
h('button', {
|
|
1912
|
+
key: 'purge',
|
|
1913
|
+
type: 'button',
|
|
1914
|
+
className: 'nsm__button nsm__button--danger',
|
|
1915
|
+
disabled: selectedTrashEntries.length === 0 || busy,
|
|
1916
|
+
onClick: () => requestPurge(selectedTrashEntries.map((entry) => entry.trashId)),
|
|
1917
|
+
}, h(Glyph, { name: 'trash', size: 13 }), t('trash.purgeSelected')),
|
|
1918
|
+
] : [
|
|
1919
|
+
h('button', {
|
|
1920
|
+
key: 'export',
|
|
1921
|
+
type: 'button',
|
|
1922
|
+
className: 'nsm__button',
|
|
1923
|
+
disabled: selectedSessions.length === 0,
|
|
1924
|
+
onClick: () => exportSessions(selectedSessions.map((session) => session.id)),
|
|
1925
|
+
}, h(Glyph, { name: 'export', size: 13 }), t('action.exportSelected')),
|
|
1926
|
+
h('button', {
|
|
1927
|
+
key: 'delete',
|
|
1928
|
+
type: 'button',
|
|
1929
|
+
className: 'nsm__button nsm__button--danger',
|
|
1930
|
+
disabled: !canDeleteSelected || busy,
|
|
1931
|
+
onClick: () => requestDelete(selectedSessions.map((session) => session.id)),
|
|
1932
|
+
}, h(Glyph, { name: 'trash', size: 13 }), t('action.deleteSelected')),
|
|
1933
|
+
],
|
|
1934
|
+
),
|
|
1935
|
+
h('p', { className: 'nsm__hint' }, view === 'trash' ? t('selection.trashHint') : t('selection.hint')),
|
|
1936
|
+
),
|
|
1937
|
+
renderDetail(),
|
|
1938
|
+
h('section', { className: 'nsm__card nsm__import-card' },
|
|
1939
|
+
h('div', { className: 'nsm__card-head' }, h('h2', null, t('import.title'))),
|
|
1940
|
+
h('p', { className: 'nsm__hint', style: { marginTop: 0 } }, t('import.hint')),
|
|
1941
|
+
h('button', {
|
|
1942
|
+
type: 'button',
|
|
1943
|
+
className: 'nsm__button',
|
|
1944
|
+
disabled: importing,
|
|
1945
|
+
onClick: () => fileInputRef.current && fileInputRef.current.click(),
|
|
1946
|
+
}, h(Glyph, { name: 'import', size: 13 }), importing ? t('action.importing') : t('action.import')),
|
|
1947
|
+
),
|
|
1948
|
+
),
|
|
1949
|
+
));
|
|
1950
|
+
|
|
1951
|
+
if (data.sessionRoot) {
|
|
1952
|
+
content.push(h('footer', { key: 'footer', className: 'nsm__footer' },
|
|
1953
|
+
h('div', { className: 'nsm__footer-line' },
|
|
1954
|
+
h('span', null, `${t('footer.storage')} `, h('code', null, data.sessionRoot)),
|
|
1955
|
+
),
|
|
1956
|
+
h('div', { className: 'nsm__footer-line' },
|
|
1957
|
+
h('span', null, t('footer.package'), h('code', null, PACKAGE_NAME)),
|
|
1958
|
+
h('button', {
|
|
1959
|
+
type: 'button',
|
|
1960
|
+
className: 'nsm__footer-copy',
|
|
1961
|
+
title: t('action.copyPackage'),
|
|
1962
|
+
'aria-label': t('action.copyPackage'),
|
|
1963
|
+
onClick: () => copyId(PACKAGE_NAME),
|
|
1964
|
+
}, h(Glyph, { name: 'copy', size: 11 })),
|
|
1965
|
+
),
|
|
1966
|
+
h('div', { className: 'nsm__footer-line' }, h('span', null, t('footer.note'))),
|
|
1967
|
+
));
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
if (dragActive) {
|
|
1972
|
+
content.push(h('div', { key: 'drop', className: 'nsm__drop' },
|
|
1973
|
+
h('div', { className: 'nsm__drop-card' },
|
|
1974
|
+
h('span', { className: 'nsm__mark' }, h(PageMark, { size: 58 })),
|
|
1975
|
+
h('h3', null, t('import.drop')),
|
|
1976
|
+
h('p', null, t('import.dropHint')),
|
|
1977
|
+
),
|
|
1978
|
+
));
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
if (confirm) {
|
|
1982
|
+
const isPurge = confirm.kind === 'purge';
|
|
1983
|
+
const count = isPurge ? confirm.trashIds.length : confirm.ids.length;
|
|
1984
|
+
const title = isPurge
|
|
1985
|
+
? tr('trash.purgeTitle', { n: count })
|
|
1986
|
+
: (count === 1 ? t('delete.title.one') : tr('delete.title.many', { n: count }));
|
|
1987
|
+
content.push(h('div', {
|
|
1988
|
+
key: 'modal',
|
|
1989
|
+
className: 'nsm__modal',
|
|
1990
|
+
onMouseDown: (event) => { if (event.target === event.currentTarget && !busy) setConfirm(null); },
|
|
1991
|
+
},
|
|
1992
|
+
h('div', { className: 'nsm__dialog', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': 'nsm-delete-title' },
|
|
1993
|
+
h('h2', { id: 'nsm-delete-title' }, title),
|
|
1994
|
+
h('p', { className: 'nsm__dialog-warning' }, isPurge ? t('trash.purgeHint') : t('delete.warning')),
|
|
1995
|
+
h('ul', { className: 'nsm__dialog-list' }, confirm.titles.slice(0, 6).map((value, index) => h('li', { key: index }, value))),
|
|
1996
|
+
confirm.titles.length > 6 ? h('p', { className: 'nsm__dialog-more' }, tr('delete.more', { n: confirm.titles.length - 6 })) : null,
|
|
1997
|
+
!isPurge && confirm.active > 0 ? h('p', { className: 'nsm__dialog-live-note' }, tr('delete.activeNote', { n: confirm.active })) : null,
|
|
1998
|
+
h('div', { className: 'nsm__dialog-actions' },
|
|
1999
|
+
h('button', { type: 'button', className: 'nsm__button', disabled: busy, autoFocus: true, onClick: () => setConfirm(null) }, t('action.cancel')),
|
|
2000
|
+
h('button', {
|
|
2001
|
+
type: 'button',
|
|
2002
|
+
className: 'nsm__button nsm__button--danger',
|
|
2003
|
+
disabled: busy,
|
|
2004
|
+
onClick: performConfirm,
|
|
2005
|
+
}, busy
|
|
2006
|
+
? (isPurge ? t('trash.purge') : t('action.deleteSelected'))
|
|
2007
|
+
: (isPurge ? t('trash.purge') : (confirm.active > 0 ? t('delete.confirmStopDelete') : t('action.confirmDelete')))),
|
|
2008
|
+
),
|
|
2009
|
+
),
|
|
2010
|
+
));
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
if (toast) {
|
|
2014
|
+
content.push(h('div', { key: 'toast', className: `nsm__toast is-${toast.kind}`, role: 'status', 'aria-live': 'polite' },
|
|
2015
|
+
h('span', { className: 'nsm__toast-icon' }, h(Glyph, { name: toast.kind === 'error' ? 'alert' : toast.kind === 'ok' ? 'check' : 'clock', size: 14 })),
|
|
2016
|
+
h('span', null, toast.text),
|
|
2017
|
+
toast.action ? h('button', {
|
|
2018
|
+
type: 'button',
|
|
2019
|
+
className: 'nsm__toast-action',
|
|
2020
|
+
onClick: () => { const action = toast.action; setToast(null); action.onClick(); },
|
|
2021
|
+
}, toast.action.label) : null,
|
|
2022
|
+
));
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
content.push(h('input', {
|
|
2026
|
+
key: 'file',
|
|
2027
|
+
ref: fileInputRef,
|
|
2028
|
+
type: 'file',
|
|
2029
|
+
accept: '.json,application/json',
|
|
2030
|
+
multiple: true,
|
|
2031
|
+
className: 'nsm__sr',
|
|
2032
|
+
onChange: onFilePicked,
|
|
2033
|
+
}));
|
|
2034
|
+
|
|
2035
|
+
return h('div', {
|
|
2036
|
+
className: 'nsm',
|
|
2037
|
+
onDragEnter,
|
|
2038
|
+
onDragOver,
|
|
2039
|
+
onDragLeave,
|
|
2040
|
+
onDrop,
|
|
2041
|
+
}, h('div', { className: 'nsm__inner' }, content));
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
|
|
2045
|
+
name: 'sidebar.panellist',
|
|
2046
|
+
id: PANEL_ID,
|
|
2047
|
+
order: 40,
|
|
2048
|
+
label: () => localized('nav.title'),
|
|
2049
|
+
}, function SessionsIcon(props) {
|
|
2050
|
+
const size = typeof props.size === 'number' ? props.size : 16;
|
|
2051
|
+
return h('svg', {
|
|
2052
|
+
width: size,
|
|
2053
|
+
height: size,
|
|
2054
|
+
viewBox: '0 0 16 16',
|
|
2055
|
+
fill: 'none',
|
|
2056
|
+
stroke: 'url(#nsm-nav-blue)',
|
|
2057
|
+
strokeWidth: 1.5,
|
|
2058
|
+
strokeLinecap: 'round',
|
|
2059
|
+
strokeLinejoin: 'round',
|
|
2060
|
+
'aria-hidden': 'true',
|
|
2061
|
+
focusable: 'false',
|
|
2062
|
+
style: { display: 'block' },
|
|
2063
|
+
},
|
|
2064
|
+
h('defs', null,
|
|
2065
|
+
h('linearGradient', { id: 'nsm-nav-blue', x1: '3', y1: '3', x2: '13', y2: '13', gradientUnits: 'userSpaceOnUse' },
|
|
2066
|
+
h('stop', { offset: '0', stopColor: '#8fd3ff' }),
|
|
2067
|
+
h('stop', { offset: '1', stopColor: '#1d4ed8' }),
|
|
2068
|
+
),
|
|
2069
|
+
),
|
|
2070
|
+
h('path', { d: 'M3.5 3.5v9' }),
|
|
2071
|
+
h('path', { d: 'M3.5 5h4.5M3.5 8h6.5M3.5 11h4.5' }),
|
|
2072
|
+
h('circle', { cx: 3.5, cy: 3.5, r: 1.2, fill: '#e0f2fe', stroke: 'none' }),
|
|
2073
|
+
h('circle', { cx: 8, cy: 5, r: 1, fill: 'url(#nsm-nav-blue)', stroke: 'none' }),
|
|
2074
|
+
h('circle', { cx: 10, cy: 8, r: 1, fill: '#67e8f9', stroke: 'none' }),
|
|
2075
|
+
h('circle', { cx: 8, cy: 11, r: 1, fill: 'url(#nsm-nav-blue)', stroke: 'none' }),
|
|
2076
|
+
);
|
|
2077
|
+
}));
|
|
2078
|
+
|
|
2079
|
+
ctx.slots.inject('main', () => ctx.slots.register({
|
|
2080
|
+
name: 'main',
|
|
2081
|
+
key: PANEL_ID,
|
|
2082
|
+
}, Page));
|
|
2083
|
+
},
|
|
2084
|
+
};
|
|
2085
|
+
},
|
|
2086
|
+
});
|