@codeasier/dsh-plugin-orca-projects 0.0.0-stage → 0.1.1
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 +290 -2
- package/README.zh.md +109 -0
- package/client.js +4880 -0
- package/cordis.patch.yml +8 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +249 -0
- package/dist/index.js.map +1 -0
- package/icon.svg +7 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +7 -0
- package/package.json +86 -3
package/client.js
ADDED
|
@@ -0,0 +1,4880 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: '@codeasier/dsh-plugin-orca-projects',
|
|
3
|
+
factory(require) {
|
|
4
|
+
const React = require('react')
|
|
5
|
+
const h = React.createElement
|
|
6
|
+
|
|
7
|
+
const NS = 'orcaSidebar'
|
|
8
|
+
const STORAGE_KEY = 'dsh.orca-projects.v1'
|
|
9
|
+
const UNGROUPED = '__ungrouped__'
|
|
10
|
+
const MODES = ['orca', 'workspace', 'workspace-tree', 'flat']
|
|
11
|
+
const FILTERS = ['hide', 'all', 'only']
|
|
12
|
+
const EMPTY_STATUS = new Map()
|
|
13
|
+
const SessionStatusContext = React.createContext(null)
|
|
14
|
+
const WorkspacePathContext = React.createContext(null)
|
|
15
|
+
|
|
16
|
+
const en = {
|
|
17
|
+
'title.projects': 'Projects',
|
|
18
|
+
'title.workspaces': 'Workspaces',
|
|
19
|
+
'title.sessions': 'Sessions',
|
|
20
|
+
'action.search': 'Search',
|
|
21
|
+
'action.viewOptions': 'View options',
|
|
22
|
+
'action.add': 'Add',
|
|
23
|
+
'action.addProject': 'Add project…',
|
|
24
|
+
'action.addWorkspace': 'Add workspace…',
|
|
25
|
+
'action.newGroup': 'New group…',
|
|
26
|
+
'action.clear': 'Clear',
|
|
27
|
+
'action.refresh': 'Refresh',
|
|
28
|
+
'placeholder.search': 'Search projects or sessions',
|
|
29
|
+
'section.groupBy': 'Group by',
|
|
30
|
+
'group.workspace': 'Workspace',
|
|
31
|
+
'group.workspaceTree': 'Workspace tree',
|
|
32
|
+
'group.flat': 'Single list',
|
|
33
|
+
'group.orca': 'Orca-like',
|
|
34
|
+
'order.label': 'Sort by',
|
|
35
|
+
'order.manual': 'Manual',
|
|
36
|
+
'order.updated': 'Last updated',
|
|
37
|
+
'filter.label': 'Filter sessions',
|
|
38
|
+
'filter.hide': 'Hide archived',
|
|
39
|
+
'filter.all': 'All conversations (show archived)',
|
|
40
|
+
'filter.only': 'Archived only',
|
|
41
|
+
'filter.activeOnly': 'Active sessions only',
|
|
42
|
+
'active.empty': 'No active sessions',
|
|
43
|
+
'active.hint': 'Turn off Active sessions only to see every session.',
|
|
44
|
+
'active.showAll': 'Show all sessions',
|
|
45
|
+
'pinned.title': 'Pinned',
|
|
46
|
+
'pinned.empty': 'Pinned sessions collect here, above every project.',
|
|
47
|
+
'pinned.hint': 'Pinned',
|
|
48
|
+
'pinned.short': 'Pinned',
|
|
49
|
+
'pinned.pin': 'Pin session',
|
|
50
|
+
'pinned.unpin': 'Unpin session',
|
|
51
|
+
'group.ungrouped': 'Ungrouped',
|
|
52
|
+
'group.empty': 'Drop a project here, or use a project menu.',
|
|
53
|
+
'group.drop': 'Move to group',
|
|
54
|
+
'group.rename': 'Rename group',
|
|
55
|
+
'group.delete': 'Delete group',
|
|
56
|
+
'group.deleteConfirm': 'Delete “{name}”? Its projects return to Ungrouped.',
|
|
57
|
+
'group.name': 'Group name',
|
|
58
|
+
'group.namePlaceholder': 'e.g. Client work',
|
|
59
|
+
'group.created': 'Group “{name}” created',
|
|
60
|
+
'group.deleted': 'Group deleted',
|
|
61
|
+
'group.moved': 'Moved “{name}” to {group}',
|
|
62
|
+
'project.newSession': 'New session',
|
|
63
|
+
'project.newSessionIn': 'New session in {name}',
|
|
64
|
+
'project.open': 'Open workspace',
|
|
65
|
+
'project.move': 'Move to group',
|
|
66
|
+
'project.rename': 'Rename project',
|
|
67
|
+
'project.delete': 'Delete project',
|
|
68
|
+
'project.deleteConfirm':
|
|
69
|
+
'Remove “{name}” from the workspace list? Files and sessions are kept.',
|
|
70
|
+
'project.deleteConfirmMany':
|
|
71
|
+
'Remove “{name}” and its {n} worktree workspaces from DSH? Files and sessions are kept.',
|
|
72
|
+
'project.renamePlaceholder': 'Project name',
|
|
73
|
+
'project.ungrouped': 'Ungrouped',
|
|
74
|
+
'project.sessions': '{n} sessions',
|
|
75
|
+
'loose.title': 'Unassigned sessions',
|
|
76
|
+
'loose.hint': 'Sessions outside every registered workspace.',
|
|
77
|
+
'migration.action': 'Migrate unassigned sessions…',
|
|
78
|
+
'migration.short': 'Migrate',
|
|
79
|
+
'migration.revert': 'Undo session migration',
|
|
80
|
+
'migration.title': 'Migrate unassigned sessions',
|
|
81
|
+
'migration.description':
|
|
82
|
+
'Detected {n} sessions for {projects} projects; {unmatched} could not be matched. This writes only an external project mapping; DSH workspaces and session ownership stay unchanged.',
|
|
83
|
+
'migration.confirm': 'Migrate {n}',
|
|
84
|
+
'migration.done': 'Migrated {n} sessions into projects',
|
|
85
|
+
'migration.changed': 'The session matches changed. Review a fresh migration preview.',
|
|
86
|
+
'migration.reverted': 'Session migration cleared',
|
|
87
|
+
'migration.none': 'No unassigned session could be matched to a project.',
|
|
88
|
+
'project.worktrees': '{n} worktrees',
|
|
89
|
+
'project.worktreesTitle': 'Worktrees: {list}',
|
|
90
|
+
'project.worktreesSection': 'Worktrees',
|
|
91
|
+
'project.worktreeMain': 'main',
|
|
92
|
+
'project.added': 'Workspace “{name}” added',
|
|
93
|
+
'project.autoExpand': 'Show sessions',
|
|
94
|
+
'session.open': 'Open',
|
|
95
|
+
'session.reveal': 'Show in project',
|
|
96
|
+
'session.pin': 'Pin session',
|
|
97
|
+
'session.unpin': 'Unpin session',
|
|
98
|
+
'session.archive': 'Archive session',
|
|
99
|
+
'session.unarchive': 'Restore session',
|
|
100
|
+
'session.copyId': 'Copy session ID',
|
|
101
|
+
'session.copied': 'Session ID copied',
|
|
102
|
+
'session.copyFailed': 'Copy failed',
|
|
103
|
+
'session.archivedHint': 'Archived',
|
|
104
|
+
'session.status.archived': 'Archived',
|
|
105
|
+
'session.status.pending': 'Waiting for your input',
|
|
106
|
+
'session.status.running': 'Running',
|
|
107
|
+
'session.status.completed': 'Finished, not yet viewed',
|
|
108
|
+
'session.status.idle': 'Idle',
|
|
109
|
+
'session.archivedNotOpenable': 'Restore this session before opening it.',
|
|
110
|
+
'session.new': 'New session',
|
|
111
|
+
'session.untitled': 'Untitled',
|
|
112
|
+
'session.stopArchive': 'Stop and archive',
|
|
113
|
+
'session.stopArchiveTitle': 'Stop this session and archive it?',
|
|
114
|
+
'session.stopArchiveDesc':
|
|
115
|
+
'“{name}” still has work running. Archiving stops that work first.',
|
|
116
|
+
'session.pinned': 'Pinned “{name}”',
|
|
117
|
+
'session.unpinned': 'Unpinned “{name}”',
|
|
118
|
+
'session.archived': 'Archived “{name}”',
|
|
119
|
+
'session.unarchived': 'Restored “{name}”',
|
|
120
|
+
'session.actionFailed': 'Could not update the session.',
|
|
121
|
+
'dialog.cancel': 'Cancel',
|
|
122
|
+
'dialog.create': 'Create',
|
|
123
|
+
'dialog.save': 'Save',
|
|
124
|
+
'dialog.delete': 'Delete',
|
|
125
|
+
'dialog.close': 'Close',
|
|
126
|
+
'toast.noPicker': 'No directory picker is available.',
|
|
127
|
+
'toast.workspaceFailed': 'Could not add the workspace.',
|
|
128
|
+
'toast.projectFailed': 'Could not update the workspace.',
|
|
129
|
+
'toast.pinFailed': 'Could not update the pin.',
|
|
130
|
+
'toast.archiveFailed': 'Could not archive the session.',
|
|
131
|
+
'empty.projects': 'No projects yet',
|
|
132
|
+
'empty.projectsHint': 'Add a folder to start a project.',
|
|
133
|
+
'empty.sessions': 'No sessions',
|
|
134
|
+
'sessions.expand': 'Show {n} more sessions',
|
|
135
|
+
'sessions.collapsed': 'Show fewer',
|
|
136
|
+
'empty.noMatches': 'No matching sessions',
|
|
137
|
+
'empty.archivedOnly': 'No archived sessions',
|
|
138
|
+
'empty.viewOthers': 'View other sessions',
|
|
139
|
+
loading: 'Loading workspaces…',
|
|
140
|
+
'new': 'New',
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const zh = {
|
|
144
|
+
'title.projects': '项目',
|
|
145
|
+
'title.workspaces': '工作区',
|
|
146
|
+
'title.sessions': '会话',
|
|
147
|
+
'action.search': '搜索',
|
|
148
|
+
'action.viewOptions': '视图选项',
|
|
149
|
+
'action.add': '添加',
|
|
150
|
+
'action.addProject': '添加项目…',
|
|
151
|
+
'action.addWorkspace': '添加工作区…',
|
|
152
|
+
'action.newGroup': '新建分组…',
|
|
153
|
+
'action.clear': '清除',
|
|
154
|
+
'action.refresh': '刷新',
|
|
155
|
+
'placeholder.search': '搜索项目或会话',
|
|
156
|
+
'section.groupBy': '分组方式',
|
|
157
|
+
'group.workspace': '按工作区',
|
|
158
|
+
'group.workspaceTree': '按工作区树',
|
|
159
|
+
'group.flat': '单列表',
|
|
160
|
+
'group.orca': 'Orca-like',
|
|
161
|
+
'order.label': '排序方式',
|
|
162
|
+
'order.manual': '手动排序',
|
|
163
|
+
'order.updated': '最近更新',
|
|
164
|
+
'filter.label': '筛选会话',
|
|
165
|
+
'filter.hide': '隐藏已归档',
|
|
166
|
+
'filter.all': '全部对话(显示已归档)',
|
|
167
|
+
'filter.only': '仅显示已归档',
|
|
168
|
+
'filter.activeOnly': '仅活跃会话',
|
|
169
|
+
'active.empty': '暂无活跃会话',
|
|
170
|
+
'active.hint': '关闭“仅活跃会话”可查看全部会话。',
|
|
171
|
+
'active.showAll': '查看全部会话',
|
|
172
|
+
'pinned.title': '已置顶',
|
|
173
|
+
'pinned.empty': '置顶的会话会集中显示在这里。',
|
|
174
|
+
'pinned.hint': '已置顶',
|
|
175
|
+
'pinned.short': '置顶',
|
|
176
|
+
'pinned.pin': '置顶会话',
|
|
177
|
+
'pinned.unpin': '取消置顶',
|
|
178
|
+
'group.ungrouped': '未分组',
|
|
179
|
+
'group.empty': '将项目拖到这里,或使用项目菜单。',
|
|
180
|
+
'group.drop': '移动到分组',
|
|
181
|
+
'group.rename': '重命名分组',
|
|
182
|
+
'group.delete': '删除分组',
|
|
183
|
+
'group.deleteConfirm': '删除“{name}”?其中的项目会回到未分组。',
|
|
184
|
+
'group.name': '分组名称',
|
|
185
|
+
'group.namePlaceholder': '例如:客户项目',
|
|
186
|
+
'group.created': '已创建分组“{name}”',
|
|
187
|
+
'group.deleted': '分组已删除',
|
|
188
|
+
'group.moved': '已将“{name}”移动到{group}',
|
|
189
|
+
'project.newSession': '新建会话',
|
|
190
|
+
'project.newSessionIn': '在 {name} 中新建会话',
|
|
191
|
+
'project.open': '打开工作区',
|
|
192
|
+
'project.move': '移动到分组',
|
|
193
|
+
'project.rename': '重命名项目',
|
|
194
|
+
'project.delete': '删除项目',
|
|
195
|
+
'project.deleteConfirm': '将“{name}”从工作区列表移除?文件夹与会话会保留。',
|
|
196
|
+
'project.deleteConfirmMany':
|
|
197
|
+
'将“{name}”及其 {n} 个 worktree 工作区从 DSH 移除?文件夹与会话会保留。',
|
|
198
|
+
'project.renamePlaceholder': '项目名称',
|
|
199
|
+
'project.ungrouped': '未分组',
|
|
200
|
+
'project.sessions': '{n} 个会话',
|
|
201
|
+
'loose.title': '未归属会话',
|
|
202
|
+
'loose.hint': '这些会话不属于任何已注册工作区。',
|
|
203
|
+
'migration.action': '迁移未归属会话…',
|
|
204
|
+
'migration.short': '迁移',
|
|
205
|
+
'migration.revert': '撤销会话迁移',
|
|
206
|
+
'migration.title': '迁移未归属会话',
|
|
207
|
+
'migration.description':
|
|
208
|
+
'识别到 {n} 个会话可归入 {projects} 个项目,另有 {unmatched} 个无法匹配。此操作只写入外挂 projectId 映射,不会修改 DSH workspace 或会话归属。',
|
|
209
|
+
'migration.confirm': '迁移 {n} 条',
|
|
210
|
+
'migration.done': '已将 {n} 个会话归入项目',
|
|
211
|
+
'migration.changed': '会话匹配已变化,请重新查看迁移预览。',
|
|
212
|
+
'migration.reverted': '已清除会话迁移',
|
|
213
|
+
'migration.none': '没有可匹配到项目的未归属会话。',
|
|
214
|
+
'project.worktrees': '{n} 个工作树',
|
|
215
|
+
'project.worktreesTitle': '工作树:{list}',
|
|
216
|
+
'project.worktreesSection': '工作树',
|
|
217
|
+
'project.worktreeMain': 'main',
|
|
218
|
+
'project.added': '已添加工作区“{name}”',
|
|
219
|
+
'project.autoExpand': '展开会话',
|
|
220
|
+
'session.open': '打开',
|
|
221
|
+
'session.reveal': '在项目中显示',
|
|
222
|
+
'session.pin': '置顶会话',
|
|
223
|
+
'session.unpin': '取消置顶',
|
|
224
|
+
'session.archive': '归档会话',
|
|
225
|
+
'session.unarchive': '取消归档',
|
|
226
|
+
'session.copyId': '复制 Session ID',
|
|
227
|
+
'session.copied': 'Session ID 已复制',
|
|
228
|
+
'session.copyFailed': '复制失败',
|
|
229
|
+
'session.archivedHint': '已归档',
|
|
230
|
+
'session.status.archived': '已归档',
|
|
231
|
+
'session.status.pending': '等待你的操作',
|
|
232
|
+
'session.status.running': '正在运行',
|
|
233
|
+
'session.status.completed': '已完成,尚未查看',
|
|
234
|
+
'session.status.idle': '空闲',
|
|
235
|
+
'session.archivedNotOpenable': '请先取消归档再打开。',
|
|
236
|
+
'session.new': '新会话',
|
|
237
|
+
'session.untitled': '未命名',
|
|
238
|
+
'session.stopArchive': '停止并归档',
|
|
239
|
+
'session.stopArchiveTitle': '停止并归档此会话?',
|
|
240
|
+
'session.stopArchiveDesc': '“{name}”仍有正在进行的工作。归档会先停止这些工作。',
|
|
241
|
+
'session.pinned': '已置顶“{name}”',
|
|
242
|
+
'session.unpinned': '已取消置顶“{name}”',
|
|
243
|
+
'session.archived': '已归档“{name}”',
|
|
244
|
+
'session.unarchived': '已取消归档“{name}”',
|
|
245
|
+
'session.actionFailed': '无法更新该会话。',
|
|
246
|
+
'dialog.cancel': '取消',
|
|
247
|
+
'dialog.create': '创建',
|
|
248
|
+
'dialog.save': '保存',
|
|
249
|
+
'dialog.delete': '删除',
|
|
250
|
+
'dialog.close': '关闭',
|
|
251
|
+
'toast.noPicker': '目录选择器不可用。',
|
|
252
|
+
'toast.workspaceFailed': '无法添加工作区。',
|
|
253
|
+
'toast.projectFailed': '无法更新工作区。',
|
|
254
|
+
'toast.pinFailed': '无法更新置顶状态。',
|
|
255
|
+
'toast.archiveFailed': '无法归档该会话。',
|
|
256
|
+
'empty.projects': '暂无项目',
|
|
257
|
+
'empty.projectsHint': '添加一个文件夹来开始项目。',
|
|
258
|
+
'empty.sessions': '暂无会话',
|
|
259
|
+
'sessions.expand': '显示其余 {n} 个会话',
|
|
260
|
+
'sessions.collapsed': '收起',
|
|
261
|
+
'empty.noMatches': '无匹配会话',
|
|
262
|
+
'empty.archivedOnly': '暂无已归档会话',
|
|
263
|
+
'empty.viewOthers': '查看其他会话',
|
|
264
|
+
loading: '正在加载工作区…',
|
|
265
|
+
'new': '新',
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function cx(...parts) {
|
|
269
|
+
let value = ''
|
|
270
|
+
for (const part of parts) {
|
|
271
|
+
if (part) value += (value ? ' ' : '') + part
|
|
272
|
+
}
|
|
273
|
+
return value
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const ICONS = {
|
|
277
|
+
search: [
|
|
278
|
+
['circle', { cx: 7, cy: 7, r: 4.4 }],
|
|
279
|
+
['path', { d: 'M10.3 10.3 14 14' }],
|
|
280
|
+
],
|
|
281
|
+
sliders: [
|
|
282
|
+
['path', { d: 'M2.5 4.5h3.2M9.3 4.5h4.2M2.5 8h6.1M12.4 8h1.1M2.5 11.5h1.7M7.9 11.5h5.6' }],
|
|
283
|
+
['circle', { cx: 7.3, cy: 4.5, r: 1.4 }],
|
|
284
|
+
['circle', { cx: 10.3, cy: 8, r: 1.4 }],
|
|
285
|
+
['circle', { cx: 6.2, cy: 11.5, r: 1.4 }],
|
|
286
|
+
],
|
|
287
|
+
plus: [['path', { d: 'M8 3v10M3 8h10' }]],
|
|
288
|
+
minus: [['path', { d: 'M3 8h10' }]],
|
|
289
|
+
chevron: [['path', { d: 'm6 3.5 4.5 4.5L6 12.5' }]],
|
|
290
|
+
folder: [
|
|
291
|
+
[
|
|
292
|
+
'path',
|
|
293
|
+
{
|
|
294
|
+
d: 'M2.2 4.6a1.1 1.1 0 0 1 1.1-1.1h3.1l1.3 1.5h5a1.1 1.1 0 0 1 1.1 1.1v5.8a1.1 1.1 0 0 1-1.1 1.1H3.3a1.1 1.1 0 0 1-1.1-1.1Z',
|
|
295
|
+
},
|
|
296
|
+
],
|
|
297
|
+
],
|
|
298
|
+
folderOpen: [
|
|
299
|
+
['path', { d: 'M2.2 4.6a1.1 1.1 0 0 1 1.1-1.1h3.1l1.3 1.5h4.5' }],
|
|
300
|
+
['path', { d: 'M2.2 6.2h11.3l-1.2 6.3H3.4Z' }],
|
|
301
|
+
],
|
|
302
|
+
pin: [
|
|
303
|
+
['path', { d: 'M9.9 2.2 13.8 6.1 12.2 7.7l-.1 2.2-2.5 2.5-4.9-4.9 2.5-2.5 2.2-.1Z' }],
|
|
304
|
+
['path', { d: 'M6.3 9.7 2.4 13.6' }],
|
|
305
|
+
],
|
|
306
|
+
pinFilled: [
|
|
307
|
+
[
|
|
308
|
+
'path',
|
|
309
|
+
{
|
|
310
|
+
d: 'M9.9 2.2 13.8 6.1 12.2 7.7l-.1 2.2-2.5 2.5-4.9-4.9 2.5-2.5 2.2-.1Z',
|
|
311
|
+
fill: 'currentColor',
|
|
312
|
+
stroke: 'none',
|
|
313
|
+
},
|
|
314
|
+
],
|
|
315
|
+
['path', { d: 'M6.3 9.7 2.4 13.6' }],
|
|
316
|
+
],
|
|
317
|
+
more: [
|
|
318
|
+
['circle', { cx: 3.2, cy: 8, r: 1.05, fill: 'currentColor', stroke: 'none' }],
|
|
319
|
+
['circle', { cx: 8, cy: 8, r: 1.05, fill: 'currentColor', stroke: 'none' }],
|
|
320
|
+
['circle', { cx: 12.8, cy: 8, r: 1.05, fill: 'currentColor', stroke: 'none' }],
|
|
321
|
+
],
|
|
322
|
+
close: [['path', { d: 'm4 4 8 8M12 4l-8 8' }]],
|
|
323
|
+
check: [['path', { d: 'm3 8.2 3.2 3.2L13 4.6' }]],
|
|
324
|
+
trash: [
|
|
325
|
+
[
|
|
326
|
+
'path',
|
|
327
|
+
{
|
|
328
|
+
d: 'M3.2 4.5h9.6M6.2 4.5V3.2h3.6v1.3M4.4 4.5l.6 8.2a1 1 0 0 0 1 .9h4a1 1 0 0 0 1-.9l.6-8.2',
|
|
329
|
+
},
|
|
330
|
+
],
|
|
331
|
+
['path', { d: 'M6.6 7v4M9.4 7v4' }],
|
|
332
|
+
],
|
|
333
|
+
edit: [
|
|
334
|
+
['path', { d: 'm10.6 2.9 2.5 2.5-7.4 7.4-3.2.7.7-3.2Z' }],
|
|
335
|
+
['path', { d: 'm9.4 4.1 2.5 2.5' }],
|
|
336
|
+
],
|
|
337
|
+
layers: [
|
|
338
|
+
['path', { d: 'm8 2.2 6 3.3-6 3.3-6-3.3Z' }],
|
|
339
|
+
['path', { d: 'm2.6 8.2 5.4 3 5.4-3M2.6 11.2l5.4 3 5.4-3' }],
|
|
340
|
+
],
|
|
341
|
+
groupAdd: [
|
|
342
|
+
['path', { d: 'M2.2 4.6a1.1 1.1 0 0 1 1.1-1.1h3.1l1.3 1.5h5a1.1 1.1 0 0 1 1.1 1.1v3' }],
|
|
343
|
+
['path', { d: 'M2.2 5.8v6.1h7.2M11 10.4v4.1M8.95 12.45h4.1' }],
|
|
344
|
+
],
|
|
345
|
+
archive: [
|
|
346
|
+
['path', { d: 'M2.4 5.6h11.2v7.9H2.4Z' }],
|
|
347
|
+
['path', { d: 'M1.9 3.2h12.2v2.4H1.9ZM6.2 8.5h3.6' }],
|
|
348
|
+
],
|
|
349
|
+
restore: [
|
|
350
|
+
['path', { d: 'M3.4 6.2A5 5 0 1 1 3 9.6' }],
|
|
351
|
+
['path', { d: 'M3.4 2.8v3.4h3.4' }],
|
|
352
|
+
],
|
|
353
|
+
copy: [
|
|
354
|
+
['rect', { x: 5.3, y: 5.3, width: 8.2, height: 8.2, rx: 1.2 }],
|
|
355
|
+
[
|
|
356
|
+
'path',
|
|
357
|
+
{
|
|
358
|
+
d: 'M10.7 5.3V3.7a1.2 1.2 0 0 0-1.2-1.2H3.7a1.2 1.2 0 0 0-1.2 1.2v5.8a1.2 1.2 0 0 0 1.2 1.2h1.6',
|
|
359
|
+
},
|
|
360
|
+
],
|
|
361
|
+
],
|
|
362
|
+
open: [
|
|
363
|
+
['path', { d: 'M9.2 2.8h4v4M13.2 2.8 7.6 8.4' }],
|
|
364
|
+
['path', { d: 'M12.4 9.4v3.4H3.2V3.6h3.4' }],
|
|
365
|
+
],
|
|
366
|
+
chat: [
|
|
367
|
+
[
|
|
368
|
+
'path',
|
|
369
|
+
{
|
|
370
|
+
d: 'M2.4 3.5a1 1 0 0 1 1-1h9.2a1 1 0 0 1 1 1v6.2a1 1 0 0 1-1 1H7.1l-3.3 2.7v-2.7H3.4a1 1 0 0 1-1-1Z',
|
|
371
|
+
},
|
|
372
|
+
],
|
|
373
|
+
],
|
|
374
|
+
inbox: [
|
|
375
|
+
['path', { d: 'M2.2 8.6 4.1 3.3h7.8l1.9 5.3v3.4a1 1 0 0 1-1 1H3.2a1 1 0 0 1-1-1Z' }],
|
|
376
|
+
['path', { d: 'M2.2 8.6h3.3l.8 1.5h3.4l.8-1.5h3.3' }],
|
|
377
|
+
],
|
|
378
|
+
warning: [
|
|
379
|
+
['path', { d: 'M8 2.5 14 13H2Z' }],
|
|
380
|
+
['path', { d: 'M8 6.2v3.1M8 11.2v.1' }],
|
|
381
|
+
],
|
|
382
|
+
dot: [['circle', { cx: 8, cy: 8, r: 3.1, fill: 'currentColor', stroke: 'none' }]],
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function Icon({ name, size = 14, className }) {
|
|
386
|
+
const parts = ICONS[name] || []
|
|
387
|
+
return h(
|
|
388
|
+
'svg',
|
|
389
|
+
{
|
|
390
|
+
className,
|
|
391
|
+
width: size,
|
|
392
|
+
height: size,
|
|
393
|
+
viewBox: '0 0 16 16',
|
|
394
|
+
fill: 'none',
|
|
395
|
+
stroke: 'currentColor',
|
|
396
|
+
strokeWidth: 1.5,
|
|
397
|
+
strokeLinecap: 'round',
|
|
398
|
+
strokeLinejoin: 'round',
|
|
399
|
+
'aria-hidden': 'true',
|
|
400
|
+
focusable: 'false',
|
|
401
|
+
},
|
|
402
|
+
parts.map(([tag, attributes], index) => h(tag, { key: index, ...attributes })),
|
|
403
|
+
)
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function normalizePath(value) {
|
|
407
|
+
const text = String(value || '')
|
|
408
|
+
const normalized = text.replace(/\\/g, '/').replace(/\/+$/u, '')
|
|
409
|
+
return normalized === '' ? '/' : normalized
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function baseName(value) {
|
|
413
|
+
const path = normalizePath(value)
|
|
414
|
+
const index = path.lastIndexOf('/')
|
|
415
|
+
return index >= 0 ? path.slice(index + 1) || path : path
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function isAncestor(parent, child) {
|
|
419
|
+
const left = normalizePath(parent)
|
|
420
|
+
const right = normalizePath(child)
|
|
421
|
+
if (left === right) return false
|
|
422
|
+
if (left === '/') return right.startsWith('/')
|
|
423
|
+
return right.startsWith(`${left}/`)
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function worktreeFromPath(value) {
|
|
427
|
+
const path = normalizePath(value)
|
|
428
|
+
const marker = path.match(/\/(?:\.worktrees?|worktrees?)\/([^/]+)/i)
|
|
429
|
+
if (marker?.[1]) return { label: marker[1], main: false }
|
|
430
|
+
const orca = path.match(/\/orca\/workspaces\/[^/]+\/([^/]+)(?:\/|$)/i)
|
|
431
|
+
if (orca?.[1]) return { label: orca[1], main: false }
|
|
432
|
+
return { label: 'main', main: true }
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function repositoryWorktree(repo, path) {
|
|
436
|
+
if (!repo || repo.main === true) return 'main'
|
|
437
|
+
if (repo.worktree) return repo.worktree
|
|
438
|
+
const derived = worktreeFromPath(path)
|
|
439
|
+
if (!derived.main) return derived.label
|
|
440
|
+
return baseName(path) || 'main'
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
function sessionWorktree(session, project) {
|
|
444
|
+
if (!session || !project?.path) return null
|
|
445
|
+
const root = normalizePath(project.path)
|
|
446
|
+
const cwd = session.cwd ? normalizePath(session.cwd) : null
|
|
447
|
+
const worktrees = Array.isArray(project.worktrees) ? project.worktrees : []
|
|
448
|
+
const checkout =
|
|
449
|
+
worktrees
|
|
450
|
+
.filter(
|
|
451
|
+
(entry) => cwd && (normalizePath(entry.path) === cwd || isAncestor(entry.path, cwd)),
|
|
452
|
+
)
|
|
453
|
+
.sort(
|
|
454
|
+
(left, right) => normalizePath(right.path).length - normalizePath(left.path).length,
|
|
455
|
+
)[0] || worktrees.find((entry) => normalizePath(entry.path) === root)
|
|
456
|
+
if (checkout) return { label: checkout.label, main: checkout.main === true }
|
|
457
|
+
const rootWorktree = worktreeFromPath(root)
|
|
458
|
+
if (!cwd || cwd === root) return rootWorktree
|
|
459
|
+
if (isAncestor(root, cwd)) {
|
|
460
|
+
const relative = cwd.slice(root.length + 1)
|
|
461
|
+
const segments = relative.split('/').filter(Boolean)
|
|
462
|
+
const index = segments.findIndex((segment) =>
|
|
463
|
+
/^(?:\.worktrees?|worktrees?)$/i.test(segment),
|
|
464
|
+
)
|
|
465
|
+
if (index >= 0 && segments[index + 1]) return { label: segments[index + 1], main: false }
|
|
466
|
+
return rootWorktree
|
|
467
|
+
}
|
|
468
|
+
const cwdWorktree = worktreeFromPath(cwd)
|
|
469
|
+
if (!cwdWorktree.main) return cwdWorktree
|
|
470
|
+
return { label: baseName(cwd), main: false }
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function repoFromPathFallback(value) {
|
|
474
|
+
const path = normalizePath(value)
|
|
475
|
+
const nested = path.match(/^(.*?)\/(?:\.worktrees?|worktrees)\/([^/]+)(?:\/|$)/i)
|
|
476
|
+
if (nested?.[1] && nested[2]) {
|
|
477
|
+
const root = normalizePath(nested[1])
|
|
478
|
+
return {
|
|
479
|
+
key: root,
|
|
480
|
+
root,
|
|
481
|
+
title: baseName(root),
|
|
482
|
+
main: false,
|
|
483
|
+
worktree: nested[2],
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
const orca = path.match(/^(.*\/orca\/workspaces\/([^/]+))\/[^/]+(?:\/|$)/i)
|
|
487
|
+
if (orca?.[1] && orca[2]) {
|
|
488
|
+
const root = normalizePath(orca[1])
|
|
489
|
+
return {
|
|
490
|
+
key: `orca:${root}`,
|
|
491
|
+
root,
|
|
492
|
+
title: orca[2],
|
|
493
|
+
main: false,
|
|
494
|
+
worktree: baseName(path),
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return null
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function workspaceRepo(workspace, repoMap) {
|
|
501
|
+
const path = normalizePath(workspace?.path)
|
|
502
|
+
const entry = repoMap && typeof repoMap.get === 'function' ? repoMap.get(path) : undefined
|
|
503
|
+
if (
|
|
504
|
+
entry &&
|
|
505
|
+
entry.status !== 'missing' &&
|
|
506
|
+
entry.status !== 'error' &&
|
|
507
|
+
typeof entry.key === 'string' &&
|
|
508
|
+
entry.key
|
|
509
|
+
) {
|
|
510
|
+
const key = normalizePath(entry.key)
|
|
511
|
+
const root = normalizePath(entry.root || entry.key)
|
|
512
|
+
return {
|
|
513
|
+
key,
|
|
514
|
+
root,
|
|
515
|
+
title: entry.title || baseName(root) || path,
|
|
516
|
+
main: entry.main === true,
|
|
517
|
+
worktree: repositoryWorktree(entry, path),
|
|
518
|
+
worktrees: Array.isArray(entry.worktrees) ? entry.worktrees : [],
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return (
|
|
522
|
+
repoFromPathFallback(path) || {
|
|
523
|
+
key: path,
|
|
524
|
+
root: path,
|
|
525
|
+
title: workspace?.title || baseName(path),
|
|
526
|
+
main: true,
|
|
527
|
+
worktree: worktreeFromPath(path).label,
|
|
528
|
+
}
|
|
529
|
+
)
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function projectWorktrees(group) {
|
|
533
|
+
const found = new Map()
|
|
534
|
+
for (const member of group.members) {
|
|
535
|
+
for (const entry of member.repo.worktrees || []) {
|
|
536
|
+
if (!entry || typeof entry.path !== 'string') continue
|
|
537
|
+
const path = normalizePath(entry.path)
|
|
538
|
+
if (!path || found.has(path)) continue
|
|
539
|
+
found.set(path, {
|
|
540
|
+
workspaceId: null,
|
|
541
|
+
path,
|
|
542
|
+
label: entry.label || worktreeFromPath(path).label || baseName(path),
|
|
543
|
+
main: entry.main === true,
|
|
544
|
+
branch: entry.branch,
|
|
545
|
+
title: baseName(path),
|
|
546
|
+
sessionCount: 0,
|
|
547
|
+
registered: false,
|
|
548
|
+
})
|
|
549
|
+
}
|
|
550
|
+
const discovered = (member.repo.worktrees || []).find(
|
|
551
|
+
(entry) => normalizePath(entry.path) === member.path,
|
|
552
|
+
)
|
|
553
|
+
found.set(member.path, {
|
|
554
|
+
workspaceId: member.workspace.workspaceId,
|
|
555
|
+
path: member.path,
|
|
556
|
+
label: repositoryWorktree(member.repo, member.path),
|
|
557
|
+
main: member.repo.main === true || member.path === normalizePath(member.repo.root),
|
|
558
|
+
branch: discovered?.branch,
|
|
559
|
+
title: member.workspace.title || baseName(member.path),
|
|
560
|
+
sessionCount: member.sessions.length,
|
|
561
|
+
registered: true,
|
|
562
|
+
})
|
|
563
|
+
}
|
|
564
|
+
return [...found.values()].sort((left, right) => {
|
|
565
|
+
if (left.main !== right.main) return left.main ? -1 : 1
|
|
566
|
+
return String(left.label).localeCompare(String(right.label))
|
|
567
|
+
})
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
function projectForLooseSession(session, projects) {
|
|
571
|
+
if (!session?.cwd) return null
|
|
572
|
+
const cwd = normalizePath(session.cwd)
|
|
573
|
+
let best = null
|
|
574
|
+
let bestLength = -1
|
|
575
|
+
for (const project of projects) {
|
|
576
|
+
if (project.isUngrouped) continue
|
|
577
|
+
const paths = [
|
|
578
|
+
project.path,
|
|
579
|
+
...(project.memberPaths || []),
|
|
580
|
+
...(project.worktrees || []).map((worktree) => worktree.path),
|
|
581
|
+
]
|
|
582
|
+
for (const value of paths) {
|
|
583
|
+
if (!value) continue
|
|
584
|
+
const path = normalizePath(value)
|
|
585
|
+
if (cwd !== path && !isAncestor(path, cwd)) continue
|
|
586
|
+
if (path.length <= bestLength) continue
|
|
587
|
+
best = project
|
|
588
|
+
bestLength = path.length
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return best
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
function groupLooseSessions(sessions, workspaces) {
|
|
595
|
+
const groups = new Map()
|
|
596
|
+
for (const session of sessions) {
|
|
597
|
+
const cwd = session.cwd ? normalizePath(session.cwd) : null
|
|
598
|
+
let workspace = null
|
|
599
|
+
let bestLength = -1
|
|
600
|
+
for (const candidate of workspaces) {
|
|
601
|
+
const path = normalizePath(candidate.path)
|
|
602
|
+
if (!path) continue
|
|
603
|
+
if (cwd !== path && !isAncestor(path, cwd)) continue
|
|
604
|
+
if (path.length <= bestLength) continue
|
|
605
|
+
workspace = candidate
|
|
606
|
+
bestLength = path.length
|
|
607
|
+
}
|
|
608
|
+
const key = workspace ? normalizePath(workspace.path) : cwd || UNGROUPED
|
|
609
|
+
let group = groups.get(key)
|
|
610
|
+
if (!group) {
|
|
611
|
+
group = {
|
|
612
|
+
key,
|
|
613
|
+
title: workspace?.title || (cwd ? baseName(cwd) : UNGROUPED),
|
|
614
|
+
path: workspace?.path || cwd,
|
|
615
|
+
workspaceId: workspace?.workspaceId || null,
|
|
616
|
+
sessions: [],
|
|
617
|
+
}
|
|
618
|
+
groups.set(key, group)
|
|
619
|
+
}
|
|
620
|
+
group.sessions.push(session)
|
|
621
|
+
}
|
|
622
|
+
return [...groups.values()].sort((left, right) => {
|
|
623
|
+
const delta = right.sessions.length - left.sessions.length
|
|
624
|
+
if (delta !== 0) return delta
|
|
625
|
+
return String(left.title || '').localeCompare(String(right.title || ''))
|
|
626
|
+
})
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
function worktreeForSession(session, project, workspaceBySession) {
|
|
630
|
+
const workspacePath =
|
|
631
|
+
workspaceBySession && typeof workspaceBySession.get === 'function'
|
|
632
|
+
? workspaceBySession.get(session.id)
|
|
633
|
+
: undefined
|
|
634
|
+
if (workspacePath) {
|
|
635
|
+
const checkout = project?.worktrees?.find(
|
|
636
|
+
(entry) => normalizePath(entry.path) === normalizePath(workspacePath),
|
|
637
|
+
)
|
|
638
|
+
if (checkout) return { label: checkout.label, main: checkout.main === true }
|
|
639
|
+
return sessionWorktree(session, { path: workspacePath, worktrees: project?.worktrees })
|
|
640
|
+
}
|
|
641
|
+
if (project?.path) return sessionWorktree(session, project)
|
|
642
|
+
return session?.cwd ? worktreeFromPath(session.cwd) : null
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
async function fetchRepositories(paths, signal) {
|
|
646
|
+
const response = await fetch('api/orca-projects/resolve', {
|
|
647
|
+
method: 'POST',
|
|
648
|
+
headers: { 'content-type': 'application/json' },
|
|
649
|
+
body: JSON.stringify({ paths }),
|
|
650
|
+
...(signal === undefined ? {} : { signal }),
|
|
651
|
+
})
|
|
652
|
+
if (!response.ok) return null
|
|
653
|
+
const value = await response.json()
|
|
654
|
+
const repositories = value?.repositories
|
|
655
|
+
return Array.isArray(repositories) ? repositories : null
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function defaultState() {
|
|
659
|
+
return {
|
|
660
|
+
version: 1,
|
|
661
|
+
mode: 'orca',
|
|
662
|
+
orderBy: 'updated',
|
|
663
|
+
archivedFilter: 'hide',
|
|
664
|
+
activeOnly: false,
|
|
665
|
+
groups: [],
|
|
666
|
+
assignments: {},
|
|
667
|
+
projectNames: {},
|
|
668
|
+
sessionProjects: {},
|
|
669
|
+
projectOrder: {},
|
|
670
|
+
sessionOrder: {},
|
|
671
|
+
collapsed: {},
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
function asStringArray(value) {
|
|
676
|
+
if (!Array.isArray(value)) return []
|
|
677
|
+
return value.filter((entry) => typeof entry === 'string')
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
function sanitizeState(raw) {
|
|
681
|
+
const next = defaultState()
|
|
682
|
+
if (!raw || typeof raw !== 'object' || raw.version !== 1) return next
|
|
683
|
+
if (MODES.includes(raw.mode)) next.mode = raw.mode
|
|
684
|
+
if (raw.orderBy === 'manual' || raw.orderBy === 'updated') next.orderBy = raw.orderBy
|
|
685
|
+
if (FILTERS.includes(raw.archivedFilter)) next.archivedFilter = raw.archivedFilter
|
|
686
|
+
if (typeof raw.activeOnly === 'boolean') next.activeOnly = raw.activeOnly
|
|
687
|
+
|
|
688
|
+
if (Array.isArray(raw.groups)) {
|
|
689
|
+
const seen = new Set()
|
|
690
|
+
for (const entry of raw.groups) {
|
|
691
|
+
if (!entry || typeof entry !== 'object') continue
|
|
692
|
+
const id = typeof entry.id === 'string' ? entry.id : ''
|
|
693
|
+
const name = typeof entry.name === 'string' ? entry.name.trim() : ''
|
|
694
|
+
if (!id || !name || seen.has(id) || next.groups.length >= 50) continue
|
|
695
|
+
seen.add(id)
|
|
696
|
+
next.groups.push({ id, name })
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
if (raw.assignments && typeof raw.assignments === 'object') {
|
|
701
|
+
for (const [key, value] of Object.entries(raw.assignments)) {
|
|
702
|
+
if (typeof key === 'string' && typeof value === 'string' && value)
|
|
703
|
+
next.assignments[key] = value
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
if (raw.sessionProjects && typeof raw.sessionProjects === 'object') {
|
|
708
|
+
let count = 0
|
|
709
|
+
for (const [sessionId, projectId] of Object.entries(raw.sessionProjects)) {
|
|
710
|
+
if (count >= 5000) break
|
|
711
|
+
if (typeof sessionId !== 'string' || typeof projectId !== 'string') continue
|
|
712
|
+
if (!sessionId || !projectId) continue
|
|
713
|
+
next.sessionProjects[sessionId] = projectId
|
|
714
|
+
count += 1
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
if (raw.projectNames && typeof raw.projectNames === 'object') {
|
|
719
|
+
let count = 0
|
|
720
|
+
for (const [key, value] of Object.entries(raw.projectNames)) {
|
|
721
|
+
if (count >= 200) break
|
|
722
|
+
if (typeof key !== 'string' || typeof value !== 'string') continue
|
|
723
|
+
const name = value.trim()
|
|
724
|
+
if (!name || name.length > 80) continue
|
|
725
|
+
next.projectNames[key] = name
|
|
726
|
+
count += 1
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
if (raw.projectOrder && typeof raw.projectOrder === 'object') {
|
|
731
|
+
for (const [key, value] of Object.entries(raw.projectOrder)) {
|
|
732
|
+
if (typeof key === 'string') next.projectOrder[key] = asStringArray(value)
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
if (raw.sessionOrder && typeof raw.sessionOrder === 'object') {
|
|
737
|
+
for (const [key, value] of Object.entries(raw.sessionOrder)) {
|
|
738
|
+
if (typeof key === 'string') next.sessionOrder[key] = asStringArray(value)
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
if (raw.collapsed && typeof raw.collapsed === 'object') {
|
|
743
|
+
for (const [key, value] of Object.entries(raw.collapsed)) {
|
|
744
|
+
if (typeof key === 'string' && typeof value === 'boolean') next.collapsed[key] = value
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
return next
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
function loadState() {
|
|
752
|
+
try {
|
|
753
|
+
const raw = window.localStorage.getItem(STORAGE_KEY)
|
|
754
|
+
if (!raw) return defaultState()
|
|
755
|
+
return sanitizeState(JSON.parse(raw))
|
|
756
|
+
} catch {
|
|
757
|
+
return defaultState()
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
function saveState(state) {
|
|
762
|
+
try {
|
|
763
|
+
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(state))
|
|
764
|
+
} catch {
|
|
765
|
+
// The browser may deny storage; the in-memory state still works.
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
function nextGroupId() {
|
|
770
|
+
return `g_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 7)}`
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
function withAssignments(state, path, groupId, memberPaths) {
|
|
774
|
+
const assignments = { ...(state.assignments || {}) }
|
|
775
|
+
if (Array.isArray(memberPaths)) {
|
|
776
|
+
for (const member of memberPaths) {
|
|
777
|
+
if (typeof member === 'string' && member !== path) delete assignments[member]
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
if (groupId) assignments[path] = groupId
|
|
781
|
+
else delete assignments[path]
|
|
782
|
+
return assignments
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
function assignProject(state, path, groupId) {
|
|
786
|
+
return { ...state, assignments: withAssignments(state, path, groupId) }
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
function renameProject(state, key, name) {
|
|
790
|
+
const projectNames = { ...(state.projectNames || {}) }
|
|
791
|
+
const trimmed = typeof name === 'string' ? name.trim() : ''
|
|
792
|
+
if (trimmed) projectNames[key] = trimmed
|
|
793
|
+
else delete projectNames[key]
|
|
794
|
+
return { ...state, projectNames }
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
function createGroup(state, id, name) {
|
|
798
|
+
const groups = Array.isArray(state.groups) ? state.groups.slice() : []
|
|
799
|
+
groups.push({ id, name })
|
|
800
|
+
return { ...state, groups }
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
function deleteGroup(state, id) {
|
|
804
|
+
const groups = (Array.isArray(state.groups) ? state.groups : []).filter(
|
|
805
|
+
(group) => group.id !== id,
|
|
806
|
+
)
|
|
807
|
+
const assignments = { ...(state.assignments || {}) }
|
|
808
|
+
for (const [path, groupId] of Object.entries(assignments)) {
|
|
809
|
+
if (groupId === id) delete assignments[path]
|
|
810
|
+
}
|
|
811
|
+
const projectOrder = { ...(state.projectOrder || {}) }
|
|
812
|
+
delete projectOrder[id]
|
|
813
|
+
const collapsed = { ...(state.collapsed || {}) }
|
|
814
|
+
delete collapsed[`g:${id}`]
|
|
815
|
+
return { ...state, groups, assignments, projectOrder, collapsed }
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
function renameGroup(state, id, name) {
|
|
819
|
+
return {
|
|
820
|
+
...state,
|
|
821
|
+
groups: (state.groups || []).map((group) => (group.id === id ? { ...group, name } : group)),
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// Refill the visible slots without moving a filtered-out entry from its slot.
|
|
826
|
+
function mergeVisibleOrder(previous, next, aliases) {
|
|
827
|
+
const visible = new Set(next)
|
|
828
|
+
let index = 0
|
|
829
|
+
const prior = new Set(previous || [])
|
|
830
|
+
const aliasSlots = new Map()
|
|
831
|
+
// Like orderIndexForProject, prefer the exact key and then the first
|
|
832
|
+
// present member path in project membership order, not saved-slot order.
|
|
833
|
+
for (const [key, canonical] of aliases || []) {
|
|
834
|
+
if (!prior.has(canonical) && prior.has(key) && !aliasSlots.has(canonical)) {
|
|
835
|
+
aliasSlots.set(canonical, key)
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
const order = new Set()
|
|
839
|
+
for (const key of prior) {
|
|
840
|
+
const canonical = aliases?.get(key)
|
|
841
|
+
if (canonical === undefined) order.add(key)
|
|
842
|
+
else if (aliasSlots.get(canonical) === key) order.add(canonical)
|
|
843
|
+
}
|
|
844
|
+
return [
|
|
845
|
+
...Array.from(order, (key) => (visible.has(key) ? next[index++] : key)),
|
|
846
|
+
...next.slice(index),
|
|
847
|
+
]
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
function moveProjectInOrder(
|
|
851
|
+
state,
|
|
852
|
+
path,
|
|
853
|
+
groupId,
|
|
854
|
+
orderedKeys,
|
|
855
|
+
anchorKey,
|
|
856
|
+
position,
|
|
857
|
+
memberPaths,
|
|
858
|
+
aliases,
|
|
859
|
+
) {
|
|
860
|
+
const order = (Array.isArray(orderedKeys) ? orderedKeys : []).filter((key) => key !== path)
|
|
861
|
+
let index = anchorKey ? order.indexOf(anchorKey) : -1
|
|
862
|
+
if (index < 0) index = order.length
|
|
863
|
+
else if (position === 'after') index += 1
|
|
864
|
+
order.splice(index, 0, path)
|
|
865
|
+
const orderKey = groupId || UNGROUPED
|
|
866
|
+
return {
|
|
867
|
+
...state,
|
|
868
|
+
assignments: withAssignments(state, path, groupId, memberPaths),
|
|
869
|
+
projectOrder: {
|
|
870
|
+
...(state.projectOrder || {}),
|
|
871
|
+
[orderKey]: mergeVisibleOrder(state.projectOrder?.[orderKey], order, aliases),
|
|
872
|
+
},
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
function moveSessionInOrder(
|
|
877
|
+
state,
|
|
878
|
+
projectKey,
|
|
879
|
+
sessionId,
|
|
880
|
+
orderedIds,
|
|
881
|
+
anchorId,
|
|
882
|
+
position,
|
|
883
|
+
memberPaths,
|
|
884
|
+
) {
|
|
885
|
+
const order = (Array.isArray(orderedIds) ? orderedIds : []).filter((id) => id !== sessionId)
|
|
886
|
+
let index = anchorId ? order.indexOf(anchorId) : -1
|
|
887
|
+
if (index < 0) index = order.length
|
|
888
|
+
else if (position === 'after') index += 1
|
|
889
|
+
order.splice(index, 0, sessionId)
|
|
890
|
+
return {
|
|
891
|
+
...state,
|
|
892
|
+
orderBy: 'manual',
|
|
893
|
+
sessionOrder: {
|
|
894
|
+
...(state.sessionOrder || {}),
|
|
895
|
+
[projectKey]: mergeVisibleOrder(
|
|
896
|
+
orderForProject(state.sessionOrder, projectKey, memberPaths),
|
|
897
|
+
order,
|
|
898
|
+
),
|
|
899
|
+
},
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
function isCollapsed(state, key, defaultExpanded) {
|
|
904
|
+
const stored = state.collapsed ? state.collapsed[key] : undefined
|
|
905
|
+
return stored === undefined ? !defaultExpanded : stored === true
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
function toggleCollapsed(state, key, defaultExpanded) {
|
|
909
|
+
const collapsed = { ...(state.collapsed || {}) }
|
|
910
|
+
collapsed[key] = !isCollapsed(state, key, defaultExpanded)
|
|
911
|
+
return { ...state, collapsed }
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
function archivedSetOf(snapshot) {
|
|
915
|
+
return new Set(
|
|
916
|
+
snapshot && Array.isArray(snapshot.archivedSessionIds) ? snapshot.archivedSessionIds : [],
|
|
917
|
+
)
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
function sessionVisible(summary, archived, filter, currentId) {
|
|
921
|
+
if (!summary) return false
|
|
922
|
+
if (summary.origin === 'subagent') return false
|
|
923
|
+
if (summary.blank && summary.id !== currentId) return false
|
|
924
|
+
const isArchived = archived.has(summary.id)
|
|
925
|
+
if (filter === 'hide' && isArchived) return false
|
|
926
|
+
if (filter === 'only' && !isArchived) return false
|
|
927
|
+
return true
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
function isActiveSession(summary, statusMap) {
|
|
931
|
+
if (!summary) return false
|
|
932
|
+
const status =
|
|
933
|
+
statusMap && typeof statusMap.get === 'function' ? statusMap.get(summary.id) : undefined
|
|
934
|
+
if (status) {
|
|
935
|
+
if (status.running === true || status.pendingInteraction != null) return true
|
|
936
|
+
if (status.running === false) return false
|
|
937
|
+
}
|
|
938
|
+
return summary.running === true
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
function _sessionHasPendingInteraction(summary, statusMap) {
|
|
942
|
+
const status =
|
|
943
|
+
statusMap && typeof statusMap.get === 'function' ? statusMap.get(summary.id) : undefined
|
|
944
|
+
return Boolean(status?.pendingInteraction)
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
function compareSessions(left, right) {
|
|
948
|
+
const delta = (Number(right.updatedAt) || 0) - (Number(left.updatedAt) || 0)
|
|
949
|
+
if (delta !== 0) return delta
|
|
950
|
+
return String(left.displayTitle || '').localeCompare(String(right.displayTitle || ''))
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
function orderForProject(orderMap, projectKey, memberPaths) {
|
|
954
|
+
if (orderMap && Array.isArray(orderMap[projectKey])) return orderMap[projectKey]
|
|
955
|
+
for (const path of memberPaths || []) {
|
|
956
|
+
if (orderMap && Array.isArray(orderMap[path])) return orderMap[path]
|
|
957
|
+
}
|
|
958
|
+
return null
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
function orderIndexForProject(order, project) {
|
|
962
|
+
let index = order.indexOf(project.key)
|
|
963
|
+
if (index !== -1) return index
|
|
964
|
+
for (const path of project.memberPaths || []) {
|
|
965
|
+
index = order.indexOf(path)
|
|
966
|
+
if (index !== -1) return index
|
|
967
|
+
}
|
|
968
|
+
return -1
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
function sortSessions(list, state, projectKey, memberPaths) {
|
|
972
|
+
const order =
|
|
973
|
+
state.orderBy === 'manual'
|
|
974
|
+
? orderForProject(state.sessionOrder, projectKey, memberPaths)
|
|
975
|
+
: null
|
|
976
|
+
return list.slice().sort((left, right) => {
|
|
977
|
+
if (order) {
|
|
978
|
+
const li = order.indexOf(left.id)
|
|
979
|
+
const ri = order.indexOf(right.id)
|
|
980
|
+
if (li !== -1 || ri !== -1) {
|
|
981
|
+
return (
|
|
982
|
+
(li === -1 ? Number.MAX_SAFE_INTEGER : li) -
|
|
983
|
+
(ri === -1 ? Number.MAX_SAFE_INTEGER : ri)
|
|
984
|
+
)
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
return compareSessions(left, right)
|
|
988
|
+
})
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
function pinFirst(list, pinned) {
|
|
992
|
+
return list.slice().sort((left, right) => {
|
|
993
|
+
const lp = pinned.has(left.id) ? 0 : 1
|
|
994
|
+
const rp = pinned.has(right.id) ? 0 : 1
|
|
995
|
+
return lp - rp
|
|
996
|
+
})
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
function sortProjects(list, state, orderKey) {
|
|
1000
|
+
const order =
|
|
1001
|
+
state.orderBy === 'manual' ? state.projectOrder[orderKey || UNGROUPED] || [] : null
|
|
1002
|
+
list.sort((left, right) => {
|
|
1003
|
+
if (order) {
|
|
1004
|
+
const li = orderIndexForProject(order, left)
|
|
1005
|
+
const ri = orderIndexForProject(order, right)
|
|
1006
|
+
if (li !== -1 || ri !== -1) {
|
|
1007
|
+
return (
|
|
1008
|
+
(li === -1 ? Number.MAX_SAFE_INTEGER : li) -
|
|
1009
|
+
(ri === -1 ? Number.MAX_SAFE_INTEGER : ri)
|
|
1010
|
+
)
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
const delta = (Number(right.updatedAt) || 0) - (Number(left.updatedAt) || 0)
|
|
1014
|
+
if (delta !== 0) return delta
|
|
1015
|
+
return String(left.title || '').localeCompare(String(right.title || ''))
|
|
1016
|
+
})
|
|
1017
|
+
return list
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
function assignmentForProject(state, project) {
|
|
1021
|
+
const assignments =
|
|
1022
|
+
state.assignments && typeof state.assignments === 'object' ? state.assignments : {}
|
|
1023
|
+
const groupIds = new Set((Array.isArray(state.groups) ? state.groups : []).map((g) => g.id))
|
|
1024
|
+
for (const candidate of [project.key, ...(project.memberPaths || [])]) {
|
|
1025
|
+
const groupId = assignments[candidate]
|
|
1026
|
+
if (typeof groupId === 'string' && groupIds.has(groupId)) return groupId
|
|
1027
|
+
}
|
|
1028
|
+
return null
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
function buildTree(projects) {
|
|
1032
|
+
const nodes = new Map()
|
|
1033
|
+
for (const project of projects) nodes.set(project.key, { project, children: [] })
|
|
1034
|
+
const roots = []
|
|
1035
|
+
for (const project of projects) {
|
|
1036
|
+
let parent = null
|
|
1037
|
+
for (const candidate of projects) {
|
|
1038
|
+
if (candidate === project) continue
|
|
1039
|
+
if (!candidate.path || !project.path) continue
|
|
1040
|
+
if (!isAncestor(candidate.path, project.path)) continue
|
|
1041
|
+
if (!parent || normalizePath(candidate.path).length > normalizePath(parent.path).length)
|
|
1042
|
+
parent = candidate
|
|
1043
|
+
}
|
|
1044
|
+
if (parent) nodes.get(parent.key).children.push(nodes.get(project.key))
|
|
1045
|
+
else roots.push(nodes.get(project.key))
|
|
1046
|
+
}
|
|
1047
|
+
const sortNodes = (list) => {
|
|
1048
|
+
list.sort((left, right) => {
|
|
1049
|
+
const delta =
|
|
1050
|
+
(Number(right.project.updatedAt) || 0) - (Number(left.project.updatedAt) || 0)
|
|
1051
|
+
if (delta !== 0) return delta
|
|
1052
|
+
return String(left.project.title || '').localeCompare(String(right.project.title || ''))
|
|
1053
|
+
})
|
|
1054
|
+
for (const node of list) sortNodes(node.children)
|
|
1055
|
+
}
|
|
1056
|
+
sortNodes(roots)
|
|
1057
|
+
return roots
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
function searchSessions(query, projects, pinned) {
|
|
1061
|
+
const results = []
|
|
1062
|
+
for (const project of projects) {
|
|
1063
|
+
const projectText = String(`${project.title || ''} ${project.path || ''}`).toLowerCase()
|
|
1064
|
+
for (const session of project.sessions) {
|
|
1065
|
+
const text = [session.displayTitle, session.title, session.cwd]
|
|
1066
|
+
.filter(Boolean)
|
|
1067
|
+
.join(' ')
|
|
1068
|
+
.toLowerCase()
|
|
1069
|
+
if (!text.includes(query) && !projectText.includes(query)) continue
|
|
1070
|
+
results.push({ session, project })
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
results.sort((left, right) => {
|
|
1074
|
+
const lp = pinned.has(left.session.id) ? 0 : 1
|
|
1075
|
+
const rp = pinned.has(right.session.id) ? 0 : 1
|
|
1076
|
+
if (lp !== rp) return lp - rp
|
|
1077
|
+
return compareSessions(left.session, right.session)
|
|
1078
|
+
})
|
|
1079
|
+
return results.slice(0, 80)
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
function buildView(input) {
|
|
1083
|
+
const snapshot = input.workspaceSnapshot || {
|
|
1084
|
+
items: [],
|
|
1085
|
+
archivedSessionIds: [],
|
|
1086
|
+
pinnedSessionIds: [],
|
|
1087
|
+
phase: 'pending',
|
|
1088
|
+
}
|
|
1089
|
+
const sessionSnapshot = input.sessionSnapshot || { ids: [], byId: {} }
|
|
1090
|
+
const state = input.state || defaultState()
|
|
1091
|
+
const statusMap = input.statusMap
|
|
1092
|
+
const currentId = input.currentId
|
|
1093
|
+
const query = typeof input.query === 'string' ? input.query : ''
|
|
1094
|
+
const activeOnly = state.activeOnly === true && state.mode === 'orca'
|
|
1095
|
+
const filter = FILTERS.includes(state.archivedFilter) ? state.archivedFilter : 'hide'
|
|
1096
|
+
const archived = archivedSetOf(snapshot)
|
|
1097
|
+
const pinnedIds = Array.isArray(snapshot.pinnedSessionIds) ? snapshot.pinnedSessionIds : []
|
|
1098
|
+
const pinned = new Set(pinnedIds)
|
|
1099
|
+
const summaries = sessionSnapshot.byId || {}
|
|
1100
|
+
const sessionIds = Array.isArray(sessionSnapshot.ids) ? sessionSnapshot.ids : []
|
|
1101
|
+
const items = Array.isArray(snapshot.items) ? snapshot.items : []
|
|
1102
|
+
let projects = []
|
|
1103
|
+
const accounted = new Set()
|
|
1104
|
+
const workspaceBySession = new Map()
|
|
1105
|
+
const consolidate = state.mode === 'orca'
|
|
1106
|
+
const repoMap = input.repoMap
|
|
1107
|
+
const groupsByKey = new Map()
|
|
1108
|
+
|
|
1109
|
+
for (const workspace of items) {
|
|
1110
|
+
const sessions = []
|
|
1111
|
+
for (const id of workspace.sessionIds || []) {
|
|
1112
|
+
accounted.add(id)
|
|
1113
|
+
const summary = summaries[id]
|
|
1114
|
+
if (!summary || !sessionVisible(summary, archived, filter, currentId)) continue
|
|
1115
|
+
if (activeOnly && !isActiveSession(summary, statusMap)) continue
|
|
1116
|
+
sessions.push(summary)
|
|
1117
|
+
}
|
|
1118
|
+
const path = normalizePath(workspace.path)
|
|
1119
|
+
const repo = workspaceRepo(workspace, repoMap)
|
|
1120
|
+
const key = consolidate ? repo.key : path
|
|
1121
|
+
let group = groupsByKey.get(key)
|
|
1122
|
+
if (!group) {
|
|
1123
|
+
group = {
|
|
1124
|
+
key,
|
|
1125
|
+
root: consolidate ? repo.root : path,
|
|
1126
|
+
title: consolidate ? repo.title : workspace.title || baseName(path),
|
|
1127
|
+
mainWorkspace: null,
|
|
1128
|
+
members: [],
|
|
1129
|
+
}
|
|
1130
|
+
groupsByKey.set(key, group)
|
|
1131
|
+
}
|
|
1132
|
+
group.members.push({ workspace, path, repo, sessions })
|
|
1133
|
+
if (!group.mainWorkspace && (repo.main === true || path === normalizePath(repo.root))) {
|
|
1134
|
+
group.mainWorkspace = workspace
|
|
1135
|
+
}
|
|
1136
|
+
for (const session of sessions) {
|
|
1137
|
+
if (!workspaceBySession.has(session.id)) workspaceBySession.set(session.id, path)
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
for (const group of groupsByKey.values()) {
|
|
1142
|
+
const all = []
|
|
1143
|
+
const seen = new Set()
|
|
1144
|
+
for (const member of group.members) {
|
|
1145
|
+
for (const session of member.sessions) {
|
|
1146
|
+
if (seen.has(session.id)) continue
|
|
1147
|
+
seen.add(session.id)
|
|
1148
|
+
all.push(session)
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
const projectKey = normalizePath(group.key)
|
|
1152
|
+
const memberPaths = group.members.map((member) => member.path)
|
|
1153
|
+
const ordered = sortSessions(all, state, projectKey, memberPaths)
|
|
1154
|
+
const mainWorkspace = group.mainWorkspace
|
|
1155
|
+
const primary = mainWorkspace || group.members[0]?.workspace || null
|
|
1156
|
+
const customTitle =
|
|
1157
|
+
state.projectNames && typeof state.projectNames === 'object'
|
|
1158
|
+
? state.projectNames[projectKey]
|
|
1159
|
+
: undefined
|
|
1160
|
+
const title =
|
|
1161
|
+
(typeof customTitle === 'string' && customTitle) ||
|
|
1162
|
+
mainWorkspace?.title ||
|
|
1163
|
+
group.title ||
|
|
1164
|
+
group.members[0]?.workspace?.title ||
|
|
1165
|
+
baseName(projectKey)
|
|
1166
|
+
const worktrees = projectWorktrees(group)
|
|
1167
|
+
const updatedAt =
|
|
1168
|
+
ordered.reduce((value, session) => Math.max(value, Number(session.updatedAt) || 0), 0) ||
|
|
1169
|
+
group.members.reduce(
|
|
1170
|
+
(value, member) => Math.max(value, Date.parse(member.workspace.updatedAt || '') || 0),
|
|
1171
|
+
0,
|
|
1172
|
+
)
|
|
1173
|
+
projects.push({
|
|
1174
|
+
key: projectKey,
|
|
1175
|
+
projectId: projectKey,
|
|
1176
|
+
workspaceId: primary ? primary.workspaceId : null,
|
|
1177
|
+
workspaceIds: group.members.map((member) => member.workspace.workspaceId),
|
|
1178
|
+
memberPaths,
|
|
1179
|
+
worktrees,
|
|
1180
|
+
groupId: null,
|
|
1181
|
+
title,
|
|
1182
|
+
path: group.root || primary?.path || null,
|
|
1183
|
+
sessions: ordered,
|
|
1184
|
+
pinnedFirst: pinFirst(ordered, pinned),
|
|
1185
|
+
updatedAt,
|
|
1186
|
+
isUngrouped: false,
|
|
1187
|
+
})
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
const loose = []
|
|
1191
|
+
for (const id of sessionIds) {
|
|
1192
|
+
if (accounted.has(id)) continue
|
|
1193
|
+
const summary = summaries[id]
|
|
1194
|
+
if (!summary) continue
|
|
1195
|
+
if (summary.origin === 'subagent') continue
|
|
1196
|
+
if (!sessionVisible(summary, archived, filter, currentId)) continue
|
|
1197
|
+
if (activeOnly && !isActiveSession(summary, statusMap)) continue
|
|
1198
|
+
loose.push(summary)
|
|
1199
|
+
}
|
|
1200
|
+
const sessionProjects =
|
|
1201
|
+
consolidate && state.sessionProjects && typeof state.sessionProjects === 'object'
|
|
1202
|
+
? state.sessionProjects
|
|
1203
|
+
: {}
|
|
1204
|
+
const adoptedByProject = new Map()
|
|
1205
|
+
const migrationCandidates = []
|
|
1206
|
+
const unmatchedLoose = []
|
|
1207
|
+
const remainingLoose = []
|
|
1208
|
+
for (const session of loose) {
|
|
1209
|
+
if (!consolidate) {
|
|
1210
|
+
remainingLoose.push(session)
|
|
1211
|
+
unmatchedLoose.push(session)
|
|
1212
|
+
continue
|
|
1213
|
+
}
|
|
1214
|
+
const manualId =
|
|
1215
|
+
typeof sessionProjects[session.id] === 'string'
|
|
1216
|
+
? normalizePath(sessionProjects[session.id])
|
|
1217
|
+
: null
|
|
1218
|
+
if (manualId) {
|
|
1219
|
+
const target = projects.find(
|
|
1220
|
+
(project) => !project.isUngrouped && normalizePath(project.projectId) === manualId,
|
|
1221
|
+
)
|
|
1222
|
+
if (!target) {
|
|
1223
|
+
remainingLoose.push(session)
|
|
1224
|
+
unmatchedLoose.push(session)
|
|
1225
|
+
continue
|
|
1226
|
+
}
|
|
1227
|
+
if (!adoptedByProject.has(target.key)) adoptedByProject.set(target.key, [])
|
|
1228
|
+
adoptedByProject.get(target.key).push(session)
|
|
1229
|
+
continue
|
|
1230
|
+
}
|
|
1231
|
+
const target = projectForLooseSession(session, projects)
|
|
1232
|
+
if (target) {
|
|
1233
|
+
migrationCandidates.push({
|
|
1234
|
+
sessionId: session.id,
|
|
1235
|
+
title: session.displayTitle || session.title || '',
|
|
1236
|
+
projectId: target.projectId,
|
|
1237
|
+
projectTitle: target.title || target.path || '',
|
|
1238
|
+
})
|
|
1239
|
+
remainingLoose.push(session)
|
|
1240
|
+
} else {
|
|
1241
|
+
remainingLoose.push(session)
|
|
1242
|
+
unmatchedLoose.push(session)
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
for (const [key, sessions] of adoptedByProject) {
|
|
1246
|
+
const target = projects.find((project) => project.key === key)
|
|
1247
|
+
if (!target) continue
|
|
1248
|
+
target.sessions = sortSessions(
|
|
1249
|
+
[...target.sessions, ...sessions],
|
|
1250
|
+
state,
|
|
1251
|
+
target.key,
|
|
1252
|
+
target.memberPaths,
|
|
1253
|
+
)
|
|
1254
|
+
target.pinnedFirst = pinFirst(target.sessions, pinned)
|
|
1255
|
+
target.updatedAt = target.sessions.reduce(
|
|
1256
|
+
(value, session) => Math.max(value, Number(session.updatedAt) || 0),
|
|
1257
|
+
target.updatedAt,
|
|
1258
|
+
)
|
|
1259
|
+
}
|
|
1260
|
+
// Adoption and migration matching must see registered projects even when
|
|
1261
|
+
// their only active sessions are loose sessions with an external mapping.
|
|
1262
|
+
if (activeOnly) projects = projects.filter((project) => project.sessions.length > 0)
|
|
1263
|
+
if (remainingLoose.length > 0) {
|
|
1264
|
+
const ordered = sortSessions(remainingLoose, state, UNGROUPED)
|
|
1265
|
+
projects.push({
|
|
1266
|
+
key: UNGROUPED,
|
|
1267
|
+
projectId: UNGROUPED,
|
|
1268
|
+
workspaceId: null,
|
|
1269
|
+
workspaceIds: [],
|
|
1270
|
+
memberPaths: [],
|
|
1271
|
+
worktrees: [],
|
|
1272
|
+
looseGroups: groupLooseSessions(ordered, items),
|
|
1273
|
+
groupId: null,
|
|
1274
|
+
title: null,
|
|
1275
|
+
path: null,
|
|
1276
|
+
sessions: ordered,
|
|
1277
|
+
pinnedFirst: pinFirst(ordered, pinned),
|
|
1278
|
+
updatedAt: ordered.reduce(
|
|
1279
|
+
(value, session) => Math.max(value, Number(session.updatedAt) || 0),
|
|
1280
|
+
0,
|
|
1281
|
+
),
|
|
1282
|
+
isUngrouped: true,
|
|
1283
|
+
})
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
const projectBySession = new Map()
|
|
1287
|
+
for (const project of projects) {
|
|
1288
|
+
for (const session of project.sessions) {
|
|
1289
|
+
if (!projectBySession.has(session.id)) projectBySession.set(session.id, project)
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
const pinnedSessions = []
|
|
1294
|
+
for (const id of pinnedIds) {
|
|
1295
|
+
const summary = summaries[id]
|
|
1296
|
+
if (!summary) continue
|
|
1297
|
+
if (summary.origin === 'subagent') continue
|
|
1298
|
+
if (!sessionVisible(summary, archived, filter, currentId)) continue
|
|
1299
|
+
if (activeOnly && !isActiveSession(summary, statusMap)) continue
|
|
1300
|
+
pinnedSessions.push({ session: summary, project: projectBySession.get(id) || null })
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
const groups = []
|
|
1304
|
+
const configured = Array.isArray(state.groups) ? state.groups : []
|
|
1305
|
+
const groupIds = new Set(configured.map((group) => group.id))
|
|
1306
|
+
const assigned = new Map()
|
|
1307
|
+
for (const project of projects) {
|
|
1308
|
+
if (project.isUngrouped) continue
|
|
1309
|
+
const groupId = assignmentForProject(state, project)
|
|
1310
|
+
project.groupId = groupId
|
|
1311
|
+
if (typeof groupId === 'string' && groupIds.has(groupId)) {
|
|
1312
|
+
if (!assigned.has(groupId)) assigned.set(groupId, [])
|
|
1313
|
+
assigned.get(groupId).push(project)
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
for (const group of configured) {
|
|
1317
|
+
const list = assigned.get(group.id) || []
|
|
1318
|
+
sortProjects(list, state, group.id)
|
|
1319
|
+
groups.push({ id: group.id, name: group.name, projects: list })
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
const ungroupedProjects = projects.filter((project) => {
|
|
1323
|
+
if (project.isUngrouped) return false
|
|
1324
|
+
return !project.groupId
|
|
1325
|
+
})
|
|
1326
|
+
sortProjects(ungroupedProjects, state, UNGROUPED)
|
|
1327
|
+
|
|
1328
|
+
const flat = []
|
|
1329
|
+
for (const project of projects) {
|
|
1330
|
+
for (const session of project.sessions) flat.push({ session, project })
|
|
1331
|
+
}
|
|
1332
|
+
flat.sort((left, right) => {
|
|
1333
|
+
const lp = pinned.has(left.session.id) ? 0 : 1
|
|
1334
|
+
const rp = pinned.has(right.session.id) ? 0 : 1
|
|
1335
|
+
if (lp !== rp) return lp - rp
|
|
1336
|
+
return compareSessions(left.session, right.session)
|
|
1337
|
+
})
|
|
1338
|
+
|
|
1339
|
+
const trimmed = query.trim().toLowerCase()
|
|
1340
|
+
return {
|
|
1341
|
+
projects,
|
|
1342
|
+
groups,
|
|
1343
|
+
ungroupedProjects,
|
|
1344
|
+
pinned: pinnedSessions,
|
|
1345
|
+
tree: buildTree(projects.filter((project) => !project.isUngrouped)),
|
|
1346
|
+
flat,
|
|
1347
|
+
searchResults: trimmed ? searchSessions(trimmed, projects, pinned) : [],
|
|
1348
|
+
projectBySession,
|
|
1349
|
+
workspaceBySession,
|
|
1350
|
+
migration: {
|
|
1351
|
+
candidates: migrationCandidates,
|
|
1352
|
+
unmatched: unmatchedLoose.length,
|
|
1353
|
+
adopted: Object.keys(sessionProjects).length,
|
|
1354
|
+
},
|
|
1355
|
+
counts: {
|
|
1356
|
+
projects: projects.filter((project) => !project.isUngrouped).length,
|
|
1357
|
+
sessions: projects.reduce((value, project) => value + project.sessions.length, 0),
|
|
1358
|
+
pinned: pinnedSessions.length,
|
|
1359
|
+
},
|
|
1360
|
+
hasProjects: projects.length > 0,
|
|
1361
|
+
phase: snapshot.phase || 'pending',
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
function useSource(source) {
|
|
1366
|
+
const subscribe = React.useCallback(
|
|
1367
|
+
(listener) => (source ? source.subscribe(listener) : () => {}),
|
|
1368
|
+
[source],
|
|
1369
|
+
)
|
|
1370
|
+
const read = React.useCallback(() => (source ? source.getSnapshot() : undefined), [source])
|
|
1371
|
+
return React.useSyncExternalStore(subscribe, read, read)
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
function findCurrentId(sessionSnapshot) {
|
|
1375
|
+
if (!sessionSnapshot) return undefined
|
|
1376
|
+
const ids = Array.isArray(sessionSnapshot.ids)
|
|
1377
|
+
? sessionSnapshot.ids
|
|
1378
|
+
: Object.keys(sessionSnapshot.byId || {})
|
|
1379
|
+
for (const id of ids) {
|
|
1380
|
+
const summary = sessionSnapshot.byId ? sessionSnapshot.byId[id] : undefined
|
|
1381
|
+
if (summary?.retainedBy && summary.retainedBy.mainView > 0) return id
|
|
1382
|
+
}
|
|
1383
|
+
return undefined
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
function sessionLabel(session, currentId, t) {
|
|
1387
|
+
if (!session) return t('session.untitled')
|
|
1388
|
+
if (session.blank && session.id === currentId) return t('session.new')
|
|
1389
|
+
return session.displayTitle || session.title || t('session.untitled')
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
function errorMessage(error) {
|
|
1393
|
+
if (!error) return ''
|
|
1394
|
+
if (typeof error === 'string') return error
|
|
1395
|
+
if (typeof error.message === 'string' && error.message) return error.message
|
|
1396
|
+
if (error.rpcError && typeof error.rpcError.message === 'string')
|
|
1397
|
+
return error.rpcError.message
|
|
1398
|
+
return ''
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
function isActiveWorkRefusal(error) {
|
|
1402
|
+
return Boolean(
|
|
1403
|
+
error &&
|
|
1404
|
+
error.name === 'WorkspaceArchiveError' &&
|
|
1405
|
+
error.rpcError &&
|
|
1406
|
+
error.rpcError.code === 'workspace/session-active',
|
|
1407
|
+
)
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
function stopEvent(event) {
|
|
1411
|
+
if (!event) return
|
|
1412
|
+
event.preventDefault()
|
|
1413
|
+
event.stopPropagation()
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
function clearDropIndicators() {
|
|
1417
|
+
for (const element of document.querySelectorAll('[data-orca-drop]')) {
|
|
1418
|
+
delete element.dataset.orcaDrop
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
function setDropIndicator(element, position) {
|
|
1423
|
+
if (!element) return
|
|
1424
|
+
clearDropIndicators()
|
|
1425
|
+
element.dataset.orcaDrop = position
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
let dragPayload = null
|
|
1429
|
+
|
|
1430
|
+
function IconButton({ icon, label, onClick, active, danger, disabled, size = 22 }) {
|
|
1431
|
+
return h(
|
|
1432
|
+
'button',
|
|
1433
|
+
{
|
|
1434
|
+
type: 'button',
|
|
1435
|
+
className: cx('orca-icon-button', active && 'is-active', danger && 'is-danger'),
|
|
1436
|
+
'aria-label': label,
|
|
1437
|
+
title: label,
|
|
1438
|
+
disabled,
|
|
1439
|
+
onClick: (event) => {
|
|
1440
|
+
stopEvent(event)
|
|
1441
|
+
if (!disabled && onClick) onClick(event)
|
|
1442
|
+
},
|
|
1443
|
+
},
|
|
1444
|
+
h(Icon, { name: icon, size: size === 22 ? 14 : size }),
|
|
1445
|
+
)
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
function SessionStatusIndicator({ running, completed, pending, archived, t }) {
|
|
1449
|
+
const state = archived
|
|
1450
|
+
? 'archived'
|
|
1451
|
+
: pending
|
|
1452
|
+
? 'pending'
|
|
1453
|
+
: running
|
|
1454
|
+
? 'running'
|
|
1455
|
+
: completed
|
|
1456
|
+
? 'completed'
|
|
1457
|
+
: 'idle'
|
|
1458
|
+
const className =
|
|
1459
|
+
state === 'running'
|
|
1460
|
+
? 'orca-spinner'
|
|
1461
|
+
: cx('orca-status-dot', state !== 'idle' && `is-${state}`)
|
|
1462
|
+
const label = t(`session.status.${state}`)
|
|
1463
|
+
return h('span', { className, role: 'img', 'aria-label': label, title: label })
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
function CountBadge({ children }) {
|
|
1467
|
+
return h('span', { className: 'orca-count' }, children)
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
function Chevron({ open }) {
|
|
1471
|
+
return h(
|
|
1472
|
+
'span',
|
|
1473
|
+
{ className: cx('orca-chevron', open && 'is-open') },
|
|
1474
|
+
h(Icon, { name: 'chevron', size: 11 }),
|
|
1475
|
+
)
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
function SessionRow(props) {
|
|
1479
|
+
const {
|
|
1480
|
+
session,
|
|
1481
|
+
project,
|
|
1482
|
+
t,
|
|
1483
|
+
actions,
|
|
1484
|
+
variant,
|
|
1485
|
+
depth = 0,
|
|
1486
|
+
drag,
|
|
1487
|
+
pinned,
|
|
1488
|
+
archived,
|
|
1489
|
+
current,
|
|
1490
|
+
hideProject = false,
|
|
1491
|
+
} = props
|
|
1492
|
+
const statusMap = React.useContext(SessionStatusContext)
|
|
1493
|
+
const workspaceBySession = React.useContext(WorkspacePathContext)
|
|
1494
|
+
const worktree = worktreeForSession(session, project, workspaceBySession)
|
|
1495
|
+
const liveStatus =
|
|
1496
|
+
statusMap && typeof statusMap.get === 'function' ? statusMap.get(session.id) : undefined
|
|
1497
|
+
const running =
|
|
1498
|
+
!archived &&
|
|
1499
|
+
(liveStatus && liveStatus.running !== undefined
|
|
1500
|
+
? liveStatus.running === true
|
|
1501
|
+
: session.running === true)
|
|
1502
|
+
const completed = !archived && Boolean(liveStatus?.completionUnread)
|
|
1503
|
+
const pending = !archived && Boolean(liveStatus?.pendingInteraction)
|
|
1504
|
+
const pinHint = Boolean(props.pinHint)
|
|
1505
|
+
const title = sessionLabel(session, props.currentId, t)
|
|
1506
|
+
const showMeta = variant === 'pinned' || variant === 'flat' || variant === 'search'
|
|
1507
|
+
const meta = showMeta
|
|
1508
|
+
? project
|
|
1509
|
+
? project.isUngrouped
|
|
1510
|
+
? session.cwd
|
|
1511
|
+
? baseName(session.cwd)
|
|
1512
|
+
: t('project.ungrouped')
|
|
1513
|
+
: project.title
|
|
1514
|
+
: session.cwd
|
|
1515
|
+
? baseName(session.cwd)
|
|
1516
|
+
: null
|
|
1517
|
+
: null
|
|
1518
|
+
const showPinnedHint = pinHint && pinned
|
|
1519
|
+
const showPinGlyph = pinned && !pinHint
|
|
1520
|
+
const worktreeBadge = worktree
|
|
1521
|
+
? h(
|
|
1522
|
+
'span',
|
|
1523
|
+
{
|
|
1524
|
+
className: cx('orca-worktree', worktree.main && 'is-main'),
|
|
1525
|
+
title: session.cwd ? `${worktree.label} — ${session.cwd}` : worktree.label,
|
|
1526
|
+
},
|
|
1527
|
+
h('span', { className: 'orca-worktree-label' }, worktree.label),
|
|
1528
|
+
)
|
|
1529
|
+
: null
|
|
1530
|
+
const pinnedHint = showPinnedHint
|
|
1531
|
+
? h(
|
|
1532
|
+
'span',
|
|
1533
|
+
{ className: 'orca-session-hint' },
|
|
1534
|
+
h(Icon, { name: 'pinFilled', size: 9 }),
|
|
1535
|
+
t('pinned.hint'),
|
|
1536
|
+
)
|
|
1537
|
+
: null
|
|
1538
|
+
const archivedBadge = archived
|
|
1539
|
+
? h('span', { className: 'orca-session-hint is-archived' }, t('session.archivedHint'))
|
|
1540
|
+
: null
|
|
1541
|
+
const projectBadge =
|
|
1542
|
+
!hideProject && meta && !(worktree && worktree.label === meta)
|
|
1543
|
+
? h(
|
|
1544
|
+
'span',
|
|
1545
|
+
{ className: 'orca-session-project' },
|
|
1546
|
+
h(Icon, { name: 'folder', size: 10, className: 'orca-session-project-icon' }),
|
|
1547
|
+
h('span', { className: 'orca-session-meta', title: meta }, meta),
|
|
1548
|
+
)
|
|
1549
|
+
: null
|
|
1550
|
+
const pinGlyph = showPinGlyph
|
|
1551
|
+
? h(Icon, { name: 'pinFilled', size: 10, className: 'orca-session-pin' })
|
|
1552
|
+
: null
|
|
1553
|
+
const titleBadge = h('span', { className: 'orca-session-title', title }, title)
|
|
1554
|
+
const hasMeta = Boolean(worktreeBadge || projectBadge || pinnedHint || archivedBadge)
|
|
1555
|
+
|
|
1556
|
+
const main = h(
|
|
1557
|
+
'div',
|
|
1558
|
+
{
|
|
1559
|
+
className: cx('orca-session-main', current && 'is-current'),
|
|
1560
|
+
role: 'button',
|
|
1561
|
+
tabIndex: 0,
|
|
1562
|
+
'aria-current': current ? 'page' : undefined,
|
|
1563
|
+
draggable: drag ? true : undefined,
|
|
1564
|
+
style: { marginLeft: variant === 'tree' ? depth * 13 : 0 },
|
|
1565
|
+
onClick: () => actions.open(session, variant),
|
|
1566
|
+
onKeyDown: (event) => {
|
|
1567
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
1568
|
+
stopEvent(event)
|
|
1569
|
+
actions.open(session, variant)
|
|
1570
|
+
}
|
|
1571
|
+
},
|
|
1572
|
+
onDragStart: drag ? (event) => drag.start(event, session) : undefined,
|
|
1573
|
+
onDragOver: drag ? (event) => drag.over(event, session) : undefined,
|
|
1574
|
+
onDrop: drag ? (event) => drag.drop(event, session) : undefined,
|
|
1575
|
+
onDragEnd: drag ? drag.end : undefined,
|
|
1576
|
+
},
|
|
1577
|
+
h(
|
|
1578
|
+
'div',
|
|
1579
|
+
{ className: 'orca-session-line' },
|
|
1580
|
+
h(SessionStatusIndicator, { running, completed, pending, archived, t }),
|
|
1581
|
+
pinGlyph,
|
|
1582
|
+
titleBadge,
|
|
1583
|
+
),
|
|
1584
|
+
h(
|
|
1585
|
+
'div',
|
|
1586
|
+
{ className: 'orca-session-subline' },
|
|
1587
|
+
worktreeBadge,
|
|
1588
|
+
projectBadge,
|
|
1589
|
+
pinnedHint,
|
|
1590
|
+
archivedBadge,
|
|
1591
|
+
),
|
|
1592
|
+
)
|
|
1593
|
+
|
|
1594
|
+
const hover = h(
|
|
1595
|
+
'div',
|
|
1596
|
+
{ className: 'orca-session-actions' },
|
|
1597
|
+
!archived
|
|
1598
|
+
? h(IconButton, {
|
|
1599
|
+
icon: pinned ? 'pinFilled' : 'pin',
|
|
1600
|
+
label: pinned ? t('pinned.unpin') : t('pinned.pin'),
|
|
1601
|
+
active: pinned,
|
|
1602
|
+
onClick: () => (pinned ? actions.unpin(session) : actions.pin(session)),
|
|
1603
|
+
})
|
|
1604
|
+
: h(IconButton, {
|
|
1605
|
+
icon: 'restore',
|
|
1606
|
+
label: t('session.unarchive'),
|
|
1607
|
+
onClick: () => actions.unarchive(session),
|
|
1608
|
+
}),
|
|
1609
|
+
h(IconButton, {
|
|
1610
|
+
icon: 'more',
|
|
1611
|
+
label: t('action.viewOptions'),
|
|
1612
|
+
onClick: (event) => actions.menu(event, session, pinned, archived, variant),
|
|
1613
|
+
}),
|
|
1614
|
+
)
|
|
1615
|
+
|
|
1616
|
+
return h(
|
|
1617
|
+
'div',
|
|
1618
|
+
{
|
|
1619
|
+
className: cx(
|
|
1620
|
+
'orca-session',
|
|
1621
|
+
`orca-session--${variant}`,
|
|
1622
|
+
hasMeta && 'has-meta',
|
|
1623
|
+
pinned && pinHint && 'is-pinned-ref',
|
|
1624
|
+
archived && 'is-archived',
|
|
1625
|
+
current && 'is-current',
|
|
1626
|
+
),
|
|
1627
|
+
'data-session-id': session.id,
|
|
1628
|
+
},
|
|
1629
|
+
main,
|
|
1630
|
+
hover,
|
|
1631
|
+
)
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
function ProjectRow(props) {
|
|
1635
|
+
const {
|
|
1636
|
+
project,
|
|
1637
|
+
t,
|
|
1638
|
+
actions,
|
|
1639
|
+
variant,
|
|
1640
|
+
depth = 0,
|
|
1641
|
+
groupId,
|
|
1642
|
+
siblings,
|
|
1643
|
+
collapsed,
|
|
1644
|
+
onToggle,
|
|
1645
|
+
allowDrag,
|
|
1646
|
+
beforeSessions,
|
|
1647
|
+
currentId,
|
|
1648
|
+
pinnedSet,
|
|
1649
|
+
archivedSet,
|
|
1650
|
+
drag,
|
|
1651
|
+
} = props
|
|
1652
|
+
const expanded = !collapsed
|
|
1653
|
+
const guided = variant === 'orca'
|
|
1654
|
+
const [sessionLimit, setSessionLimit] = React.useState(8)
|
|
1655
|
+
const sessions = variant === 'orca' ? project.sessions : project.pinnedFirst
|
|
1656
|
+
const visibleSessions = sessions.filter(
|
|
1657
|
+
(session, index) =>
|
|
1658
|
+
index < sessionLimit || session.id === currentId || pinnedSet.has(session.id),
|
|
1659
|
+
)
|
|
1660
|
+
const hiddenSessions = sessions.length - visibleSessions.length
|
|
1661
|
+
const title = project.title || t('project.ungrouped')
|
|
1662
|
+
const containsCurrent = Boolean(
|
|
1663
|
+
currentId && project.sessions.some((session) => session.id === currentId),
|
|
1664
|
+
)
|
|
1665
|
+
const canManage = project.workspaceId !== null && project.workspaceId !== undefined
|
|
1666
|
+
const worktrees = Array.isArray(project.worktrees) ? project.worktrees : []
|
|
1667
|
+
const worktreeBadge =
|
|
1668
|
+
worktrees.length > 1
|
|
1669
|
+
? h(
|
|
1670
|
+
'span',
|
|
1671
|
+
{
|
|
1672
|
+
className: 'orca-project-worktrees',
|
|
1673
|
+
title: t('project.worktreesTitle', {
|
|
1674
|
+
list: worktrees.map((entry) => entry.label).join(', '),
|
|
1675
|
+
}),
|
|
1676
|
+
'aria-label': t('project.worktrees', { n: worktrees.length }),
|
|
1677
|
+
},
|
|
1678
|
+
h(Icon, { name: 'layers', size: 9 }),
|
|
1679
|
+
String(worktrees.length),
|
|
1680
|
+
)
|
|
1681
|
+
: null
|
|
1682
|
+
|
|
1683
|
+
const head = h(
|
|
1684
|
+
'div',
|
|
1685
|
+
{
|
|
1686
|
+
className: 'orca-project-head',
|
|
1687
|
+
role: 'button',
|
|
1688
|
+
tabIndex: 0,
|
|
1689
|
+
'aria-expanded': expanded,
|
|
1690
|
+
draggable: allowDrag ? true : undefined,
|
|
1691
|
+
style: { paddingLeft: 5 + depth * 13 },
|
|
1692
|
+
onClick: onToggle,
|
|
1693
|
+
onKeyDown: (event) => {
|
|
1694
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
1695
|
+
stopEvent(event)
|
|
1696
|
+
onToggle()
|
|
1697
|
+
}
|
|
1698
|
+
},
|
|
1699
|
+
onDragStart: allowDrag && drag ? (event) => drag.start(event, project) : undefined,
|
|
1700
|
+
onDragOver: allowDrag && drag ? (event) => drag.over(event, project) : undefined,
|
|
1701
|
+
onDragLeave: allowDrag && drag ? drag.leave : undefined,
|
|
1702
|
+
onDrop:
|
|
1703
|
+
allowDrag && drag ? (event) => drag.drop(event, project, groupId, siblings) : undefined,
|
|
1704
|
+
onDragEnd: allowDrag && drag ? drag.end : undefined,
|
|
1705
|
+
},
|
|
1706
|
+
h(Chevron, { open: expanded }),
|
|
1707
|
+
h(Icon, {
|
|
1708
|
+
name: expanded ? 'folderOpen' : 'folder',
|
|
1709
|
+
size: 14,
|
|
1710
|
+
className: 'orca-project-folder',
|
|
1711
|
+
}),
|
|
1712
|
+
h('span', { className: 'orca-project-title', title: project.path || title }, title),
|
|
1713
|
+
worktreeBadge,
|
|
1714
|
+
h(CountBadge, null, String(project.sessions.length)),
|
|
1715
|
+
)
|
|
1716
|
+
|
|
1717
|
+
const hover = canManage
|
|
1718
|
+
? h(
|
|
1719
|
+
'div',
|
|
1720
|
+
{ className: 'orca-project-actions' },
|
|
1721
|
+
h(IconButton, {
|
|
1722
|
+
icon: 'chat',
|
|
1723
|
+
label: t('project.newSession'),
|
|
1724
|
+
onClick: () => actions.startSession(project),
|
|
1725
|
+
}),
|
|
1726
|
+
h(IconButton, {
|
|
1727
|
+
icon: 'more',
|
|
1728
|
+
label: t('action.viewOptions'),
|
|
1729
|
+
onClick: (event) => actions.projectMenu(event, project, groupId),
|
|
1730
|
+
}),
|
|
1731
|
+
)
|
|
1732
|
+
: null
|
|
1733
|
+
|
|
1734
|
+
return h(
|
|
1735
|
+
'div',
|
|
1736
|
+
{
|
|
1737
|
+
className: cx('orca-project', containsCurrent && 'has-current'),
|
|
1738
|
+
'data-project-key': project.key,
|
|
1739
|
+
},
|
|
1740
|
+
h('div', { className: 'orca-project-row' }, head, hover),
|
|
1741
|
+
expanded
|
|
1742
|
+
? h(
|
|
1743
|
+
'div',
|
|
1744
|
+
{ className: cx('orca-project-body', guided && 'is-guided') },
|
|
1745
|
+
beforeSessions || null,
|
|
1746
|
+
sessions.length > 0
|
|
1747
|
+
? visibleSessions.map((session) =>
|
|
1748
|
+
h(SessionRow, {
|
|
1749
|
+
key: session.id,
|
|
1750
|
+
session,
|
|
1751
|
+
project,
|
|
1752
|
+
t,
|
|
1753
|
+
actions,
|
|
1754
|
+
variant: variant === 'tree' ? 'tree' : 'project',
|
|
1755
|
+
depth: depth + 1,
|
|
1756
|
+
pinned: pinnedSet.has(session.id),
|
|
1757
|
+
pinHint: variant === 'orca',
|
|
1758
|
+
archived: archivedSet.has(session.id),
|
|
1759
|
+
current: currentId === session.id,
|
|
1760
|
+
currentId,
|
|
1761
|
+
guided,
|
|
1762
|
+
drag:
|
|
1763
|
+
variant === 'orca' && drag
|
|
1764
|
+
? {
|
|
1765
|
+
start: (event) => drag.startSession(event, session, project),
|
|
1766
|
+
over: (event) => drag.overSession(event, session, project),
|
|
1767
|
+
drop: (event) =>
|
|
1768
|
+
drag.dropSession(
|
|
1769
|
+
event,
|
|
1770
|
+
session,
|
|
1771
|
+
project,
|
|
1772
|
+
sessions.map((entry) => entry.id),
|
|
1773
|
+
),
|
|
1774
|
+
end: drag.end,
|
|
1775
|
+
}
|
|
1776
|
+
: undefined,
|
|
1777
|
+
}),
|
|
1778
|
+
)
|
|
1779
|
+
: h('div', { className: 'orca-empty-inline' }, t('empty.sessions')),
|
|
1780
|
+
hiddenSessions > 0
|
|
1781
|
+
? h(
|
|
1782
|
+
'button',
|
|
1783
|
+
{
|
|
1784
|
+
type: 'button',
|
|
1785
|
+
className: 'orca-show-more',
|
|
1786
|
+
style: {
|
|
1787
|
+
paddingLeft: (guided ? 10 : 25) + (depth + 1) * (guided ? 12 : 13),
|
|
1788
|
+
},
|
|
1789
|
+
onClick: () => setSessionLimit(sessionLimit + 8),
|
|
1790
|
+
},
|
|
1791
|
+
t('sessions.expand', { n: hiddenSessions }),
|
|
1792
|
+
)
|
|
1793
|
+
: null,
|
|
1794
|
+
)
|
|
1795
|
+
: null,
|
|
1796
|
+
)
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
function PinnedGroup(props) {
|
|
1800
|
+
const { entries, t, actions, collapsed, onToggle, currentId, archivedSet, emptyHint } = props
|
|
1801
|
+
return h(
|
|
1802
|
+
'section',
|
|
1803
|
+
{ className: cx('orca-pinned-group', collapsed && 'is-collapsed') },
|
|
1804
|
+
h(
|
|
1805
|
+
'div',
|
|
1806
|
+
{
|
|
1807
|
+
className: 'orca-group-head orca-pinned-head',
|
|
1808
|
+
role: 'button',
|
|
1809
|
+
tabIndex: 0,
|
|
1810
|
+
'aria-expanded': !collapsed,
|
|
1811
|
+
onClick: onToggle,
|
|
1812
|
+
onKeyDown: (event) => {
|
|
1813
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
1814
|
+
stopEvent(event)
|
|
1815
|
+
onToggle()
|
|
1816
|
+
}
|
|
1817
|
+
},
|
|
1818
|
+
},
|
|
1819
|
+
h(Chevron, { open: !collapsed }),
|
|
1820
|
+
h(Icon, { name: 'pinFilled', size: 12, className: 'orca-pinned-icon' }),
|
|
1821
|
+
h('span', { className: 'orca-group-title' }, t('pinned.title')),
|
|
1822
|
+
h(CountBadge, null, String(entries.length)),
|
|
1823
|
+
),
|
|
1824
|
+
collapsed
|
|
1825
|
+
? null
|
|
1826
|
+
: h(
|
|
1827
|
+
'div',
|
|
1828
|
+
{ className: 'orca-pinned-body' },
|
|
1829
|
+
entries.length > 0
|
|
1830
|
+
? entries.map((entry) =>
|
|
1831
|
+
h(SessionRow, {
|
|
1832
|
+
key: entry.session.id,
|
|
1833
|
+
session: entry.session,
|
|
1834
|
+
project: entry.project,
|
|
1835
|
+
t,
|
|
1836
|
+
actions,
|
|
1837
|
+
variant: 'pinned',
|
|
1838
|
+
pinned: true,
|
|
1839
|
+
archived: archivedSet.has(entry.session.id),
|
|
1840
|
+
current: currentId === entry.session.id,
|
|
1841
|
+
currentId,
|
|
1842
|
+
}),
|
|
1843
|
+
)
|
|
1844
|
+
: h('div', { className: 'orca-empty-inline' }, emptyHint || t('pinned.empty')),
|
|
1845
|
+
),
|
|
1846
|
+
)
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
function LooseSessions(props) {
|
|
1850
|
+
const {
|
|
1851
|
+
project,
|
|
1852
|
+
t,
|
|
1853
|
+
actions,
|
|
1854
|
+
collapsed,
|
|
1855
|
+
onToggle,
|
|
1856
|
+
currentId,
|
|
1857
|
+
pinnedSet,
|
|
1858
|
+
pinHint = false,
|
|
1859
|
+
archivedSet,
|
|
1860
|
+
state,
|
|
1861
|
+
migration,
|
|
1862
|
+
onMigrate,
|
|
1863
|
+
} = props
|
|
1864
|
+
if (!project || project.sessions.length === 0) return null
|
|
1865
|
+
const groups =
|
|
1866
|
+
Array.isArray(project.looseGroups) && project.looseGroups.length > 0
|
|
1867
|
+
? project.looseGroups
|
|
1868
|
+
: [{ key: UNGROUPED, title: t('loose.title'), path: null, sessions: project.sessions }]
|
|
1869
|
+
const hover =
|
|
1870
|
+
migration && migration.candidates.length > 0
|
|
1871
|
+
? h(
|
|
1872
|
+
'div',
|
|
1873
|
+
{ className: 'orca-group-actions' },
|
|
1874
|
+
h(IconButton, {
|
|
1875
|
+
icon: 'layers',
|
|
1876
|
+
label: t('migration.action'),
|
|
1877
|
+
onClick: onMigrate,
|
|
1878
|
+
}),
|
|
1879
|
+
)
|
|
1880
|
+
: null
|
|
1881
|
+
return h(
|
|
1882
|
+
'section',
|
|
1883
|
+
{ className: 'orca-group orca-group--loose' },
|
|
1884
|
+
h(
|
|
1885
|
+
'div',
|
|
1886
|
+
{ className: 'orca-group-row' },
|
|
1887
|
+
h(
|
|
1888
|
+
'div',
|
|
1889
|
+
{
|
|
1890
|
+
className: 'orca-group-head',
|
|
1891
|
+
role: 'button',
|
|
1892
|
+
tabIndex: 0,
|
|
1893
|
+
'aria-expanded': !collapsed,
|
|
1894
|
+
title: t('loose.hint'),
|
|
1895
|
+
onClick: onToggle,
|
|
1896
|
+
onKeyDown: (event) => {
|
|
1897
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
1898
|
+
stopEvent(event)
|
|
1899
|
+
onToggle()
|
|
1900
|
+
}
|
|
1901
|
+
},
|
|
1902
|
+
},
|
|
1903
|
+
h(Chevron, { open: !collapsed }),
|
|
1904
|
+
h(Icon, { name: 'chat', size: 12, className: 'orca-group-icon' }),
|
|
1905
|
+
h('span', { className: 'orca-group-title' }, t('loose.title')),
|
|
1906
|
+
h(CountBadge, null, String(project.sessions.length)),
|
|
1907
|
+
),
|
|
1908
|
+
hover,
|
|
1909
|
+
),
|
|
1910
|
+
collapsed
|
|
1911
|
+
? null
|
|
1912
|
+
: h(
|
|
1913
|
+
'div',
|
|
1914
|
+
{ className: 'orca-group-body' },
|
|
1915
|
+
groups.map((group) => {
|
|
1916
|
+
const groupCollapsed = isCollapsed(state, `lg:${group.key}`, false)
|
|
1917
|
+
return h(
|
|
1918
|
+
'div',
|
|
1919
|
+
{ className: 'orca-loose-workspace', key: group.key },
|
|
1920
|
+
h(
|
|
1921
|
+
'div',
|
|
1922
|
+
{
|
|
1923
|
+
className: 'orca-loose-workspace-head',
|
|
1924
|
+
role: 'button',
|
|
1925
|
+
tabIndex: 0,
|
|
1926
|
+
'aria-expanded': !groupCollapsed,
|
|
1927
|
+
title: group.path || group.title,
|
|
1928
|
+
onClick: () => actions.toggleGroup(`lg:${group.key}`, false),
|
|
1929
|
+
onKeyDown: (event) => {
|
|
1930
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
1931
|
+
stopEvent(event)
|
|
1932
|
+
actions.toggleGroup(`lg:${group.key}`, false)
|
|
1933
|
+
}
|
|
1934
|
+
},
|
|
1935
|
+
},
|
|
1936
|
+
h(Chevron, { open: !groupCollapsed }),
|
|
1937
|
+
h(Icon, { name: 'folder', size: 12, className: 'orca-loose-workspace-icon' }),
|
|
1938
|
+
h('span', { className: 'orca-loose-workspace-title' }, group.title),
|
|
1939
|
+
h(CountBadge, null, String(group.sessions.length)),
|
|
1940
|
+
),
|
|
1941
|
+
groupCollapsed
|
|
1942
|
+
? null
|
|
1943
|
+
: h(
|
|
1944
|
+
'div',
|
|
1945
|
+
{ className: 'orca-loose-workspace-body' },
|
|
1946
|
+
group.sessions.map((session) => {
|
|
1947
|
+
const isPinned = pinnedSet.has(session.id)
|
|
1948
|
+
return h(SessionRow, {
|
|
1949
|
+
key: session.id,
|
|
1950
|
+
session,
|
|
1951
|
+
project,
|
|
1952
|
+
t,
|
|
1953
|
+
actions,
|
|
1954
|
+
variant: 'flat',
|
|
1955
|
+
hideProject: !isPinned,
|
|
1956
|
+
pinned: isPinned,
|
|
1957
|
+
pinHint,
|
|
1958
|
+
archived: archivedSet.has(session.id),
|
|
1959
|
+
current: currentId === session.id,
|
|
1960
|
+
currentId,
|
|
1961
|
+
})
|
|
1962
|
+
}),
|
|
1963
|
+
),
|
|
1964
|
+
)
|
|
1965
|
+
}),
|
|
1966
|
+
),
|
|
1967
|
+
)
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
function GroupSection(props) {
|
|
1971
|
+
const {
|
|
1972
|
+
group,
|
|
1973
|
+
projects,
|
|
1974
|
+
t,
|
|
1975
|
+
actions,
|
|
1976
|
+
state,
|
|
1977
|
+
toggleGroup,
|
|
1978
|
+
onToggle,
|
|
1979
|
+
drag,
|
|
1980
|
+
currentId,
|
|
1981
|
+
pinnedSet,
|
|
1982
|
+
archivedSet,
|
|
1983
|
+
emptyHint,
|
|
1984
|
+
} = props
|
|
1985
|
+
const groupId = group ? group.id : null
|
|
1986
|
+
const name = group ? group.name : t('group.ungrouped')
|
|
1987
|
+
const collapsed = onToggle.collapsed
|
|
1988
|
+
const canManage = Boolean(group)
|
|
1989
|
+
const projectKeys = projects.map((project) => project.key)
|
|
1990
|
+
|
|
1991
|
+
const head = h(
|
|
1992
|
+
'div',
|
|
1993
|
+
{
|
|
1994
|
+
className: 'orca-group-head',
|
|
1995
|
+
role: 'button',
|
|
1996
|
+
tabIndex: 0,
|
|
1997
|
+
'aria-expanded': !collapsed,
|
|
1998
|
+
onClick: () => toggleGroup(),
|
|
1999
|
+
onKeyDown: (event) => {
|
|
2000
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
2001
|
+
stopEvent(event)
|
|
2002
|
+
toggleGroup()
|
|
2003
|
+
}
|
|
2004
|
+
},
|
|
2005
|
+
},
|
|
2006
|
+
h(Chevron, { open: !collapsed }),
|
|
2007
|
+
h(Icon, { name: canManage ? 'layers' : 'inbox', size: 12, className: 'orca-group-icon' }),
|
|
2008
|
+
h('span', { className: 'orca-group-title' }, name),
|
|
2009
|
+
h(CountBadge, null, String(projects.length)),
|
|
2010
|
+
)
|
|
2011
|
+
|
|
2012
|
+
const hover = canManage
|
|
2013
|
+
? h(
|
|
2014
|
+
'div',
|
|
2015
|
+
{ className: 'orca-group-actions' },
|
|
2016
|
+
h(IconButton, {
|
|
2017
|
+
icon: 'more',
|
|
2018
|
+
label: t('action.viewOptions'),
|
|
2019
|
+
onClick: (event) => actions.groupMenu(event, group),
|
|
2020
|
+
}),
|
|
2021
|
+
)
|
|
2022
|
+
: null
|
|
2023
|
+
|
|
2024
|
+
const sectionDrop = drag
|
|
2025
|
+
? {
|
|
2026
|
+
onDragOver: (event) => {
|
|
2027
|
+
if (dragPayload?.kind !== 'project') return
|
|
2028
|
+
event.preventDefault()
|
|
2029
|
+
event.stopPropagation()
|
|
2030
|
+
setDropIndicator(event.currentTarget, 'group')
|
|
2031
|
+
},
|
|
2032
|
+
onDragLeave: (event) => {
|
|
2033
|
+
if (event.currentTarget.contains(event.relatedTarget)) return
|
|
2034
|
+
if (event.currentTarget.dataset.orcaDrop) delete event.currentTarget.dataset.orcaDrop
|
|
2035
|
+
},
|
|
2036
|
+
onDrop: (event) => {
|
|
2037
|
+
if (dragPayload?.kind !== 'project') return
|
|
2038
|
+
stopEvent(event)
|
|
2039
|
+
drag.dropOnGroup(event, groupId, projectKeys)
|
|
2040
|
+
},
|
|
2041
|
+
}
|
|
2042
|
+
: null
|
|
2043
|
+
|
|
2044
|
+
return h(
|
|
2045
|
+
'section',
|
|
2046
|
+
{ className: cx('orca-group', !group && 'orca-group--ungrouped'), ...sectionDrop },
|
|
2047
|
+
h('div', { className: 'orca-group-row' }, head, hover),
|
|
2048
|
+
collapsed
|
|
2049
|
+
? null
|
|
2050
|
+
: h(
|
|
2051
|
+
'div',
|
|
2052
|
+
{ className: 'orca-group-body' },
|
|
2053
|
+
projects.length > 0
|
|
2054
|
+
? projects.map((project) =>
|
|
2055
|
+
h(ProjectRow, {
|
|
2056
|
+
key: project.key,
|
|
2057
|
+
project,
|
|
2058
|
+
t,
|
|
2059
|
+
actions,
|
|
2060
|
+
variant: 'orca',
|
|
2061
|
+
depth: 0,
|
|
2062
|
+
groupId,
|
|
2063
|
+
siblings: projectKeys,
|
|
2064
|
+
collapsed: isCollapsed(
|
|
2065
|
+
state,
|
|
2066
|
+
`p:${project.key}`,
|
|
2067
|
+
project.key === props.currentProjectKey,
|
|
2068
|
+
),
|
|
2069
|
+
onToggle: () =>
|
|
2070
|
+
actions.toggleProject(project.key, project.key === props.currentProjectKey),
|
|
2071
|
+
allowDrag: Boolean(drag) && !project.isUngrouped,
|
|
2072
|
+
currentId,
|
|
2073
|
+
pinnedSet,
|
|
2074
|
+
archivedSet,
|
|
2075
|
+
drag,
|
|
2076
|
+
}),
|
|
2077
|
+
)
|
|
2078
|
+
: h('div', { className: 'orca-empty-inline' }, emptyHint || t('group.empty')),
|
|
2079
|
+
),
|
|
2080
|
+
)
|
|
2081
|
+
}
|
|
2082
|
+
|
|
2083
|
+
function TreeNode(props) {
|
|
2084
|
+
const { node, depth, t, actions, state, currentId, pinnedSet, archivedSet } = props
|
|
2085
|
+
const project = node.project
|
|
2086
|
+
const key = `p:${project.key}`
|
|
2087
|
+
const defaultExpanded = true
|
|
2088
|
+
const collapsed = isCollapsed(state, key, defaultExpanded)
|
|
2089
|
+
const children = collapsed
|
|
2090
|
+
? null
|
|
2091
|
+
: node.children.length > 0
|
|
2092
|
+
? h(
|
|
2093
|
+
'div',
|
|
2094
|
+
null,
|
|
2095
|
+
node.children.map((child) =>
|
|
2096
|
+
h(TreeNode, {
|
|
2097
|
+
key: child.project.key,
|
|
2098
|
+
node: child,
|
|
2099
|
+
depth: depth + 1,
|
|
2100
|
+
t,
|
|
2101
|
+
actions,
|
|
2102
|
+
state,
|
|
2103
|
+
currentId,
|
|
2104
|
+
pinnedSet,
|
|
2105
|
+
archivedSet,
|
|
2106
|
+
}),
|
|
2107
|
+
),
|
|
2108
|
+
)
|
|
2109
|
+
: null
|
|
2110
|
+
return h(ProjectRow, {
|
|
2111
|
+
project,
|
|
2112
|
+
t,
|
|
2113
|
+
actions,
|
|
2114
|
+
variant: 'tree',
|
|
2115
|
+
depth,
|
|
2116
|
+
collapsed,
|
|
2117
|
+
onToggle: () => actions.toggleProject(project.key, defaultExpanded),
|
|
2118
|
+
beforeSessions: children,
|
|
2119
|
+
currentId,
|
|
2120
|
+
pinnedSet,
|
|
2121
|
+
archivedSet,
|
|
2122
|
+
})
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
function EmptyState({ icon, title, hint, actionLabel, onAction }) {
|
|
2126
|
+
return h(
|
|
2127
|
+
'div',
|
|
2128
|
+
{ className: 'orca-empty' },
|
|
2129
|
+
h('div', { className: 'orca-empty-glyph' }, h(Icon, { name: icon, size: 20 })),
|
|
2130
|
+
h('div', { className: 'orca-empty-title' }, title),
|
|
2131
|
+
hint ? h('div', { className: 'orca-empty-hint' }, hint) : null,
|
|
2132
|
+
actionLabel
|
|
2133
|
+
? h(
|
|
2134
|
+
'button',
|
|
2135
|
+
{
|
|
2136
|
+
type: 'button',
|
|
2137
|
+
className: 'orca-text-button',
|
|
2138
|
+
onClick: onAction,
|
|
2139
|
+
},
|
|
2140
|
+
actionLabel,
|
|
2141
|
+
)
|
|
2142
|
+
: null,
|
|
2143
|
+
)
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
function OrcaView(props) {
|
|
2147
|
+
const {
|
|
2148
|
+
view,
|
|
2149
|
+
state,
|
|
2150
|
+
t,
|
|
2151
|
+
actions,
|
|
2152
|
+
currentProjectKey,
|
|
2153
|
+
currentId,
|
|
2154
|
+
pinnedSet,
|
|
2155
|
+
archivedSet,
|
|
2156
|
+
drag,
|
|
2157
|
+
} = props
|
|
2158
|
+
const pinnedCollapsed = isCollapsed(state, 'pinned', true)
|
|
2159
|
+
const hasGroups = view.groups.length > 0
|
|
2160
|
+
const activeOnly = state.activeOnly === true
|
|
2161
|
+
const emptyHint = activeOnly ? t('active.empty') : t('group.empty')
|
|
2162
|
+
if (activeOnly && view.pinned.length === 0 && !view.hasProjects) {
|
|
2163
|
+
return h(
|
|
2164
|
+
'div',
|
|
2165
|
+
{ className: 'orca-view' },
|
|
2166
|
+
h(EmptyState, {
|
|
2167
|
+
icon: 'chat',
|
|
2168
|
+
title: t('active.empty'),
|
|
2169
|
+
hint: t('active.hint'),
|
|
2170
|
+
actionLabel: t('active.showAll'),
|
|
2171
|
+
onAction: () => actions.setActiveOnly(false),
|
|
2172
|
+
}),
|
|
2173
|
+
)
|
|
2174
|
+
}
|
|
2175
|
+
return h(
|
|
2176
|
+
'div',
|
|
2177
|
+
{ className: 'orca-view' },
|
|
2178
|
+
h(PinnedGroup, {
|
|
2179
|
+
entries: view.pinned,
|
|
2180
|
+
t,
|
|
2181
|
+
actions,
|
|
2182
|
+
collapsed: pinnedCollapsed,
|
|
2183
|
+
onToggle: () => actions.toggleGroup('pinned', true),
|
|
2184
|
+
currentId,
|
|
2185
|
+
archivedSet,
|
|
2186
|
+
emptyHint: activeOnly ? t('active.empty') : t('pinned.empty'),
|
|
2187
|
+
}),
|
|
2188
|
+
hasGroups
|
|
2189
|
+
? [
|
|
2190
|
+
...view.groups.map((group) =>
|
|
2191
|
+
h(GroupSection, {
|
|
2192
|
+
key: group.id,
|
|
2193
|
+
group,
|
|
2194
|
+
projects: group.projects,
|
|
2195
|
+
t,
|
|
2196
|
+
actions,
|
|
2197
|
+
state,
|
|
2198
|
+
toggleGroup: () => actions.toggleGroup(`g:${group.id}`, true),
|
|
2199
|
+
onToggle: { collapsed: isCollapsed(state, `g:${group.id}`, true) },
|
|
2200
|
+
currentProjectKey,
|
|
2201
|
+
currentId,
|
|
2202
|
+
pinnedSet,
|
|
2203
|
+
archivedSet,
|
|
2204
|
+
emptyHint,
|
|
2205
|
+
drag,
|
|
2206
|
+
}),
|
|
2207
|
+
),
|
|
2208
|
+
h(GroupSection, {
|
|
2209
|
+
key: 'ungrouped',
|
|
2210
|
+
group: null,
|
|
2211
|
+
projects: view.ungroupedProjects,
|
|
2212
|
+
t,
|
|
2213
|
+
actions,
|
|
2214
|
+
state,
|
|
2215
|
+
toggleGroup: () => actions.toggleGroup(`g:${UNGROUPED}`, true),
|
|
2216
|
+
onToggle: { collapsed: isCollapsed(state, `g:${UNGROUPED}`, true) },
|
|
2217
|
+
currentProjectKey,
|
|
2218
|
+
currentId,
|
|
2219
|
+
pinnedSet,
|
|
2220
|
+
archivedSet,
|
|
2221
|
+
emptyHint,
|
|
2222
|
+
drag,
|
|
2223
|
+
}),
|
|
2224
|
+
]
|
|
2225
|
+
: view.ungroupedProjects.map((project) =>
|
|
2226
|
+
h(ProjectRow, {
|
|
2227
|
+
key: project.key,
|
|
2228
|
+
project,
|
|
2229
|
+
t,
|
|
2230
|
+
actions,
|
|
2231
|
+
variant: 'orca',
|
|
2232
|
+
depth: 0,
|
|
2233
|
+
groupId: null,
|
|
2234
|
+
siblings: view.ungroupedProjects.map((entry) => entry.key),
|
|
2235
|
+
collapsed: isCollapsed(
|
|
2236
|
+
state,
|
|
2237
|
+
`p:${project.key}`,
|
|
2238
|
+
project.key === currentProjectKey,
|
|
2239
|
+
),
|
|
2240
|
+
onToggle: () =>
|
|
2241
|
+
actions.toggleProject(project.key, project.key === currentProjectKey),
|
|
2242
|
+
allowDrag: Boolean(drag),
|
|
2243
|
+
currentId,
|
|
2244
|
+
pinnedSet,
|
|
2245
|
+
archivedSet,
|
|
2246
|
+
drag,
|
|
2247
|
+
}),
|
|
2248
|
+
),
|
|
2249
|
+
view.projects
|
|
2250
|
+
.filter((project) => project.isUngrouped)
|
|
2251
|
+
.map((project) =>
|
|
2252
|
+
h(LooseSessions, {
|
|
2253
|
+
key: project.key,
|
|
2254
|
+
project,
|
|
2255
|
+
t,
|
|
2256
|
+
actions,
|
|
2257
|
+
collapsed: isCollapsed(state, 'loose', false),
|
|
2258
|
+
onToggle: () => actions.toggleGroup('loose', false),
|
|
2259
|
+
currentId,
|
|
2260
|
+
pinnedSet,
|
|
2261
|
+
pinHint: true,
|
|
2262
|
+
archivedSet,
|
|
2263
|
+
state,
|
|
2264
|
+
migration: view.migration,
|
|
2265
|
+
onMigrate: actions.migrateLoose,
|
|
2266
|
+
}),
|
|
2267
|
+
),
|
|
2268
|
+
!view.hasProjects
|
|
2269
|
+
? h(EmptyState, {
|
|
2270
|
+
icon: activeOnly ? 'chat' : 'folder',
|
|
2271
|
+
title: activeOnly ? t('active.empty') : t('empty.projects'),
|
|
2272
|
+
hint: activeOnly ? t('active.hint') : t('empty.projectsHint'),
|
|
2273
|
+
actionLabel: activeOnly ? t('active.showAll') : t('action.addProject'),
|
|
2274
|
+
onAction: activeOnly
|
|
2275
|
+
? () => actions.setActiveOnly(false)
|
|
2276
|
+
: (event) => actions.addMenu(event, null),
|
|
2277
|
+
})
|
|
2278
|
+
: null,
|
|
2279
|
+
)
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
function WorkspaceView(props) {
|
|
2283
|
+
const { view, state, t, actions, currentId, pinnedSet, archivedSet } = props
|
|
2284
|
+
const list = React.useMemo(() => {
|
|
2285
|
+
const copy = view.projects.filter((project) => !project.isUngrouped)
|
|
2286
|
+
sortProjects(copy, state, '__workspace__')
|
|
2287
|
+
return copy
|
|
2288
|
+
}, [view.projects, state.orderBy, state.projectOrder])
|
|
2289
|
+
const loose = view.projects.find((project) => project.isUngrouped)
|
|
2290
|
+
return h(
|
|
2291
|
+
'div',
|
|
2292
|
+
{ className: 'orca-view' },
|
|
2293
|
+
list.map((project) =>
|
|
2294
|
+
h(ProjectRow, {
|
|
2295
|
+
key: project.key,
|
|
2296
|
+
project,
|
|
2297
|
+
t,
|
|
2298
|
+
actions,
|
|
2299
|
+
variant: 'workspace',
|
|
2300
|
+
depth: 0,
|
|
2301
|
+
collapsed: isCollapsed(state, `p:${project.key}`, true),
|
|
2302
|
+
onToggle: () => actions.toggleProject(project.key, true),
|
|
2303
|
+
allowDrag: false,
|
|
2304
|
+
currentId,
|
|
2305
|
+
pinnedSet,
|
|
2306
|
+
archivedSet,
|
|
2307
|
+
}),
|
|
2308
|
+
),
|
|
2309
|
+
loose
|
|
2310
|
+
? h(LooseSessions, {
|
|
2311
|
+
key: loose.key,
|
|
2312
|
+
project: loose,
|
|
2313
|
+
t,
|
|
2314
|
+
actions,
|
|
2315
|
+
collapsed: isCollapsed(state, 'loose', false),
|
|
2316
|
+
onToggle: () => actions.toggleGroup('loose', false),
|
|
2317
|
+
currentId,
|
|
2318
|
+
pinnedSet,
|
|
2319
|
+
archivedSet,
|
|
2320
|
+
state,
|
|
2321
|
+
migration: view.migration,
|
|
2322
|
+
onMigrate: actions.migrateLoose,
|
|
2323
|
+
})
|
|
2324
|
+
: null,
|
|
2325
|
+
list.length === 0 && !loose
|
|
2326
|
+
? h(EmptyState, {
|
|
2327
|
+
icon: 'folder',
|
|
2328
|
+
title: t('empty.projects'),
|
|
2329
|
+
hint: t('empty.projectsHint'),
|
|
2330
|
+
actionLabel: t('action.addWorkspace'),
|
|
2331
|
+
onAction: (event) => actions.addMenu(event, null),
|
|
2332
|
+
})
|
|
2333
|
+
: null,
|
|
2334
|
+
)
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
function TreeView(props) {
|
|
2338
|
+
const { view, state, t, actions, currentId, pinnedSet, archivedSet } = props
|
|
2339
|
+
const loose = view.projects.find((project) => project.isUngrouped)
|
|
2340
|
+
return h(
|
|
2341
|
+
'div',
|
|
2342
|
+
{ className: 'orca-view' },
|
|
2343
|
+
view.tree.map((node) =>
|
|
2344
|
+
h(TreeNode, {
|
|
2345
|
+
key: node.project.key,
|
|
2346
|
+
node,
|
|
2347
|
+
depth: 0,
|
|
2348
|
+
t,
|
|
2349
|
+
actions,
|
|
2350
|
+
state,
|
|
2351
|
+
currentId,
|
|
2352
|
+
pinnedSet,
|
|
2353
|
+
archivedSet,
|
|
2354
|
+
}),
|
|
2355
|
+
),
|
|
2356
|
+
loose
|
|
2357
|
+
? h(LooseSessions, {
|
|
2358
|
+
key: loose.key,
|
|
2359
|
+
project: loose,
|
|
2360
|
+
t,
|
|
2361
|
+
actions,
|
|
2362
|
+
collapsed: isCollapsed(state, 'loose', false),
|
|
2363
|
+
onToggle: () => actions.toggleGroup('loose', false),
|
|
2364
|
+
currentId,
|
|
2365
|
+
pinnedSet,
|
|
2366
|
+
archivedSet,
|
|
2367
|
+
state,
|
|
2368
|
+
migration: view.migration,
|
|
2369
|
+
onMigrate: actions.migrateLoose,
|
|
2370
|
+
})
|
|
2371
|
+
: null,
|
|
2372
|
+
view.tree.length === 0 && !loose
|
|
2373
|
+
? h(EmptyState, {
|
|
2374
|
+
icon: 'folder',
|
|
2375
|
+
title: t('empty.projects'),
|
|
2376
|
+
hint: t('empty.projectsHint'),
|
|
2377
|
+
actionLabel: t('action.addWorkspace'),
|
|
2378
|
+
onAction: (event) => actions.addMenu(event, null),
|
|
2379
|
+
})
|
|
2380
|
+
: null,
|
|
2381
|
+
)
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
function FlatView(props) {
|
|
2385
|
+
const { view, t, actions, currentId, archivedSet } = props
|
|
2386
|
+
return h(
|
|
2387
|
+
'div',
|
|
2388
|
+
{ className: 'orca-view orca-flat' },
|
|
2389
|
+
view.flat.map((entry) =>
|
|
2390
|
+
h(SessionRow, {
|
|
2391
|
+
key: entry.session.id,
|
|
2392
|
+
session: entry.session,
|
|
2393
|
+
project: entry.project,
|
|
2394
|
+
t,
|
|
2395
|
+
actions,
|
|
2396
|
+
variant: 'flat',
|
|
2397
|
+
pinned: view.pinned.some((pinned) => pinned.session.id === entry.session.id),
|
|
2398
|
+
archived: archivedSet.has(entry.session.id),
|
|
2399
|
+
current: currentId === entry.session.id,
|
|
2400
|
+
currentId,
|
|
2401
|
+
}),
|
|
2402
|
+
),
|
|
2403
|
+
view.flat.length === 0
|
|
2404
|
+
? h(EmptyState, {
|
|
2405
|
+
icon: 'chat',
|
|
2406
|
+
title: t('empty.sessions'),
|
|
2407
|
+
hint: t('empty.projectsHint'),
|
|
2408
|
+
actionLabel: t('action.addWorkspace'),
|
|
2409
|
+
onAction: (event) => actions.addMenu(event, null),
|
|
2410
|
+
})
|
|
2411
|
+
: null,
|
|
2412
|
+
)
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
function SearchView(props) {
|
|
2416
|
+
const { view, t, actions, currentId, archivedSet, query, onClear } = props
|
|
2417
|
+
return h(
|
|
2418
|
+
'div',
|
|
2419
|
+
{ className: 'orca-view orca-search' },
|
|
2420
|
+
view.searchResults.map((entry) =>
|
|
2421
|
+
h(SessionRow, {
|
|
2422
|
+
key: entry.session.id,
|
|
2423
|
+
session: entry.session,
|
|
2424
|
+
project: entry.project,
|
|
2425
|
+
t,
|
|
2426
|
+
actions,
|
|
2427
|
+
variant: 'search',
|
|
2428
|
+
pinned: view.pinned.some((pinned) => pinned.session.id === entry.session.id),
|
|
2429
|
+
archived: archivedSet.has(entry.session.id),
|
|
2430
|
+
current: currentId === entry.session.id,
|
|
2431
|
+
currentId,
|
|
2432
|
+
}),
|
|
2433
|
+
),
|
|
2434
|
+
view.searchResults.length === 0
|
|
2435
|
+
? h(EmptyState, {
|
|
2436
|
+
icon: 'search',
|
|
2437
|
+
title: t('empty.noMatches'),
|
|
2438
|
+
hint: query,
|
|
2439
|
+
actionLabel: t('action.clear'),
|
|
2440
|
+
onAction: onClear,
|
|
2441
|
+
})
|
|
2442
|
+
: null,
|
|
2443
|
+
)
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
function Header(props) {
|
|
2447
|
+
const { t, mode, query, searchOpen, count, onSearchToggle, onQuery, onViewMenu, onAddMenu } =
|
|
2448
|
+
props
|
|
2449
|
+
const inputRef = React.useRef(null)
|
|
2450
|
+
React.useEffect(() => {
|
|
2451
|
+
if (searchOpen && inputRef.current) inputRef.current.focus()
|
|
2452
|
+
}, [searchOpen])
|
|
2453
|
+
return h(
|
|
2454
|
+
'div',
|
|
2455
|
+
{ className: 'orca-header' },
|
|
2456
|
+
h(
|
|
2457
|
+
'div',
|
|
2458
|
+
{ className: 'orca-title-row' },
|
|
2459
|
+
h(
|
|
2460
|
+
'span',
|
|
2461
|
+
{ className: 'orca-title' },
|
|
2462
|
+
mode === 'orca'
|
|
2463
|
+
? t('title.projects')
|
|
2464
|
+
: mode === 'flat'
|
|
2465
|
+
? t('title.sessions')
|
|
2466
|
+
: t('title.workspaces'),
|
|
2467
|
+
),
|
|
2468
|
+
count > 0 ? h(CountBadge, null, String(count)) : null,
|
|
2469
|
+
h(
|
|
2470
|
+
'div',
|
|
2471
|
+
{ className: 'orca-head-actions' },
|
|
2472
|
+
h(IconButton, {
|
|
2473
|
+
icon: 'search',
|
|
2474
|
+
label: t('action.search'),
|
|
2475
|
+
active: searchOpen,
|
|
2476
|
+
onClick: onSearchToggle,
|
|
2477
|
+
}),
|
|
2478
|
+
h(IconButton, {
|
|
2479
|
+
icon: 'sliders',
|
|
2480
|
+
label: t('action.viewOptions'),
|
|
2481
|
+
onClick: onViewMenu,
|
|
2482
|
+
}),
|
|
2483
|
+
h(IconButton, {
|
|
2484
|
+
icon: 'plus',
|
|
2485
|
+
label: t('action.add'),
|
|
2486
|
+
onClick: onAddMenu,
|
|
2487
|
+
}),
|
|
2488
|
+
),
|
|
2489
|
+
),
|
|
2490
|
+
searchOpen
|
|
2491
|
+
? h(
|
|
2492
|
+
'div',
|
|
2493
|
+
{ className: 'orca-search-field', role: 'search' },
|
|
2494
|
+
h(Icon, { name: 'search', size: 13, className: 'orca-search-icon' }),
|
|
2495
|
+
h('input', {
|
|
2496
|
+
ref: inputRef,
|
|
2497
|
+
type: 'text',
|
|
2498
|
+
value: query,
|
|
2499
|
+
placeholder: t('placeholder.search'),
|
|
2500
|
+
'aria-label': t('action.search'),
|
|
2501
|
+
onChange: (event) => onQuery(event.target.value),
|
|
2502
|
+
onKeyDown: (event) => {
|
|
2503
|
+
if (event.key === 'Escape') {
|
|
2504
|
+
stopEvent(event)
|
|
2505
|
+
onSearchToggle(true)
|
|
2506
|
+
}
|
|
2507
|
+
},
|
|
2508
|
+
}),
|
|
2509
|
+
query
|
|
2510
|
+
? h(IconButton, {
|
|
2511
|
+
icon: 'close',
|
|
2512
|
+
label: t('action.clear'),
|
|
2513
|
+
onClick: () => onQuery(''),
|
|
2514
|
+
size: 20,
|
|
2515
|
+
})
|
|
2516
|
+
: null,
|
|
2517
|
+
)
|
|
2518
|
+
: null,
|
|
2519
|
+
)
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2522
|
+
function MenuLayer(props) {
|
|
2523
|
+
const { menu, onClose } = props
|
|
2524
|
+
const ref = React.useRef(null)
|
|
2525
|
+
React.useEffect(() => {
|
|
2526
|
+
const onPointerDown = (event) => {
|
|
2527
|
+
if (!ref.current || ref.current.contains(event.target)) return
|
|
2528
|
+
onClose()
|
|
2529
|
+
}
|
|
2530
|
+
const onKeyDown = (event) => {
|
|
2531
|
+
if (event.key === 'Escape') onClose()
|
|
2532
|
+
}
|
|
2533
|
+
const onScroll = (event) => {
|
|
2534
|
+
if (ref.current && event.target instanceof Node && ref.current.contains(event.target))
|
|
2535
|
+
return
|
|
2536
|
+
onClose()
|
|
2537
|
+
}
|
|
2538
|
+
document.addEventListener('pointerdown', onPointerDown, true)
|
|
2539
|
+
document.addEventListener('keydown', onKeyDown, true)
|
|
2540
|
+
window.addEventListener('resize', onScroll)
|
|
2541
|
+
window.addEventListener('scroll', onScroll, true)
|
|
2542
|
+
return () => {
|
|
2543
|
+
document.removeEventListener('pointerdown', onPointerDown, true)
|
|
2544
|
+
document.removeEventListener('keydown', onKeyDown, true)
|
|
2545
|
+
window.removeEventListener('resize', onScroll)
|
|
2546
|
+
window.removeEventListener('scroll', onScroll, true)
|
|
2547
|
+
}
|
|
2548
|
+
}, [onClose])
|
|
2549
|
+
|
|
2550
|
+
return h(
|
|
2551
|
+
'div',
|
|
2552
|
+
{
|
|
2553
|
+
ref,
|
|
2554
|
+
className: 'orca-menu',
|
|
2555
|
+
role: 'menu',
|
|
2556
|
+
style: { left: menu.x, top: menu.y, width: menu.width },
|
|
2557
|
+
},
|
|
2558
|
+
menu.items.map((item, index) => {
|
|
2559
|
+
if (item.divider)
|
|
2560
|
+
return h('div', {
|
|
2561
|
+
key: `divider-${index}`,
|
|
2562
|
+
className: 'orca-menu-divider',
|
|
2563
|
+
role: 'separator',
|
|
2564
|
+
})
|
|
2565
|
+
if (item.section)
|
|
2566
|
+
return h(
|
|
2567
|
+
'div',
|
|
2568
|
+
{ key: `section-${index}`, className: 'orca-menu-section' },
|
|
2569
|
+
item.section,
|
|
2570
|
+
)
|
|
2571
|
+
return h(
|
|
2572
|
+
'button',
|
|
2573
|
+
{
|
|
2574
|
+
key: `item-${index}`,
|
|
2575
|
+
type: 'button',
|
|
2576
|
+
role: 'menuitem',
|
|
2577
|
+
className: cx(
|
|
2578
|
+
'orca-menu-item',
|
|
2579
|
+
item.danger && 'is-danger',
|
|
2580
|
+
item.disabled && 'is-disabled',
|
|
2581
|
+
),
|
|
2582
|
+
disabled: item.disabled,
|
|
2583
|
+
onClick: () => {
|
|
2584
|
+
if (item.disabled) return
|
|
2585
|
+
onClose()
|
|
2586
|
+
if (item.onSelect) item.onSelect()
|
|
2587
|
+
},
|
|
2588
|
+
},
|
|
2589
|
+
h(
|
|
2590
|
+
'span',
|
|
2591
|
+
{ className: 'orca-menu-icon' },
|
|
2592
|
+
item.icon ? h(Icon, { name: item.icon, size: 13 }) : null,
|
|
2593
|
+
),
|
|
2594
|
+
h('span', { className: 'orca-menu-label' }, item.label),
|
|
2595
|
+
item.badge ? h('span', { className: 'orca-menu-badge' }, item.badge) : null,
|
|
2596
|
+
item.checked
|
|
2597
|
+
? h(Icon, { name: 'check', size: 13, className: 'orca-menu-check' })
|
|
2598
|
+
: null,
|
|
2599
|
+
)
|
|
2600
|
+
}),
|
|
2601
|
+
)
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2604
|
+
function DialogLayer(props) {
|
|
2605
|
+
const { dialog, t, onCancel, onConfirm } = props
|
|
2606
|
+
const [value, setValue] = React.useState(dialog.value || '')
|
|
2607
|
+
const inputRef = React.useRef(null)
|
|
2608
|
+
const primaryRef = React.useRef(null)
|
|
2609
|
+
React.useEffect(() => {
|
|
2610
|
+
if (dialog.input && inputRef.current) {
|
|
2611
|
+
inputRef.current.focus()
|
|
2612
|
+
inputRef.current.select()
|
|
2613
|
+
} else if (primaryRef.current) {
|
|
2614
|
+
primaryRef.current.focus()
|
|
2615
|
+
}
|
|
2616
|
+
}, [dialog.input])
|
|
2617
|
+
const canConfirm = !dialog.input || value.trim().length > 0
|
|
2618
|
+
const submit = () => {
|
|
2619
|
+
if (!canConfirm) return
|
|
2620
|
+
onConfirm(dialog.input ? value.trim() : null)
|
|
2621
|
+
}
|
|
2622
|
+
return h(
|
|
2623
|
+
'div',
|
|
2624
|
+
{
|
|
2625
|
+
className: 'orca-dialog-overlay',
|
|
2626
|
+
role: 'presentation',
|
|
2627
|
+
onPointerDown: (event) => {
|
|
2628
|
+
if (event.target === event.currentTarget) onCancel()
|
|
2629
|
+
},
|
|
2630
|
+
},
|
|
2631
|
+
h(
|
|
2632
|
+
'div',
|
|
2633
|
+
{
|
|
2634
|
+
className: 'orca-dialog',
|
|
2635
|
+
role: 'dialog',
|
|
2636
|
+
'aria-modal': 'true',
|
|
2637
|
+
'aria-label': dialog.title,
|
|
2638
|
+
},
|
|
2639
|
+
h('div', { className: 'orca-dialog-title' }, dialog.title),
|
|
2640
|
+
dialog.description
|
|
2641
|
+
? h('div', { className: 'orca-dialog-description' }, dialog.description)
|
|
2642
|
+
: null,
|
|
2643
|
+
dialog.input
|
|
2644
|
+
? h('input', {
|
|
2645
|
+
ref: inputRef,
|
|
2646
|
+
className: 'orca-dialog-input',
|
|
2647
|
+
type: 'text',
|
|
2648
|
+
value,
|
|
2649
|
+
placeholder: dialog.placeholder || '',
|
|
2650
|
+
'aria-label': dialog.title,
|
|
2651
|
+
onChange: (event) => setValue(event.target.value),
|
|
2652
|
+
onKeyDown: (event) => {
|
|
2653
|
+
if (event.key === 'Enter') {
|
|
2654
|
+
stopEvent(event)
|
|
2655
|
+
submit()
|
|
2656
|
+
} else if (event.key === 'Escape') {
|
|
2657
|
+
stopEvent(event)
|
|
2658
|
+
onCancel()
|
|
2659
|
+
}
|
|
2660
|
+
},
|
|
2661
|
+
})
|
|
2662
|
+
: null,
|
|
2663
|
+
h(
|
|
2664
|
+
'div',
|
|
2665
|
+
{ className: 'orca-dialog-actions' },
|
|
2666
|
+
h(
|
|
2667
|
+
'button',
|
|
2668
|
+
{ type: 'button', className: 'orca-button', onClick: onCancel },
|
|
2669
|
+
t('dialog.cancel'),
|
|
2670
|
+
),
|
|
2671
|
+
h(
|
|
2672
|
+
'button',
|
|
2673
|
+
{
|
|
2674
|
+
ref: primaryRef,
|
|
2675
|
+
type: 'button',
|
|
2676
|
+
className: cx(
|
|
2677
|
+
'orca-button',
|
|
2678
|
+
dialog.danger ? 'orca-button--danger' : 'orca-button--primary',
|
|
2679
|
+
),
|
|
2680
|
+
disabled: !canConfirm,
|
|
2681
|
+
onClick: submit,
|
|
2682
|
+
},
|
|
2683
|
+
dialog.confirm,
|
|
2684
|
+
),
|
|
2685
|
+
),
|
|
2686
|
+
),
|
|
2687
|
+
)
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
function ToastLayer({ toast }) {
|
|
2691
|
+
return h(
|
|
2692
|
+
'div',
|
|
2693
|
+
{ className: cx('orca-toast', toast.tone === 'error' && 'is-error'), role: 'status' },
|
|
2694
|
+
h(Icon, { name: toast.tone === 'error' ? 'warning' : 'check', size: 13 }),
|
|
2695
|
+
h('span', null, toast.message),
|
|
2696
|
+
)
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
const EMPTY_WORKSPACES = {
|
|
2700
|
+
items: [],
|
|
2701
|
+
archivedSessionIds: [],
|
|
2702
|
+
pinnedSessionIds: [],
|
|
2703
|
+
phase: 'pending',
|
|
2704
|
+
}
|
|
2705
|
+
const EMPTY_SESSIONS = { ids: [], byId: {} }
|
|
2706
|
+
|
|
2707
|
+
function OrcaBrowser(props) {
|
|
2708
|
+
const {
|
|
2709
|
+
t,
|
|
2710
|
+
wide,
|
|
2711
|
+
expandSidebar,
|
|
2712
|
+
workspaceSource,
|
|
2713
|
+
sessionSource,
|
|
2714
|
+
sessionStatusSource,
|
|
2715
|
+
layoutSource,
|
|
2716
|
+
searchRequestSource,
|
|
2717
|
+
resolveRepositories,
|
|
2718
|
+
openSession: openSessionService,
|
|
2719
|
+
startSession: startSessionService,
|
|
2720
|
+
openWorkspace: openWorkspaceService,
|
|
2721
|
+
pickDirectory,
|
|
2722
|
+
createWorkspace,
|
|
2723
|
+
deleteWorkspace,
|
|
2724
|
+
pinSession: pinSessionService,
|
|
2725
|
+
unpinSession: unpinSessionService,
|
|
2726
|
+
archiveSession: archiveSessionService,
|
|
2727
|
+
unarchiveSession: unarchiveSessionService,
|
|
2728
|
+
} = props
|
|
2729
|
+
|
|
2730
|
+
const [state, setState] = React.useState(loadState)
|
|
2731
|
+
const [query, setQuery] = React.useState('')
|
|
2732
|
+
const [searchOpen, setSearchOpen] = React.useState(false)
|
|
2733
|
+
const [menu, setMenu] = React.useState(null)
|
|
2734
|
+
const [dialog, setDialog] = React.useState(null)
|
|
2735
|
+
const [toast, setToast] = React.useState(null)
|
|
2736
|
+
const [repoMap, setRepoMap] = React.useState(null)
|
|
2737
|
+
const toastTimer = React.useRef(undefined)
|
|
2738
|
+
const searchRoot = React.useRef(null)
|
|
2739
|
+
const lastSearchRequest = React.useRef(0)
|
|
2740
|
+
const searchFocusPending = React.useRef(false)
|
|
2741
|
+
const searchRequest = useSource(searchRequestSource) || 0
|
|
2742
|
+
|
|
2743
|
+
React.useEffect(() => {
|
|
2744
|
+
if (searchRequest === 0 || searchRequest === lastSearchRequest.current) return
|
|
2745
|
+
lastSearchRequest.current = searchRequest
|
|
2746
|
+
searchFocusPending.current = true
|
|
2747
|
+
setSearchOpen(true)
|
|
2748
|
+
if (wide === false || searchRoot.current?.closest('[inert]')) expandSidebar?.()
|
|
2749
|
+
}, [searchRequest, wide, expandSidebar])
|
|
2750
|
+
|
|
2751
|
+
// Drawer visibility can change while wide stays true; retry only pending focus.
|
|
2752
|
+
React.useEffect(() => {
|
|
2753
|
+
if (!searchFocusPending.current || !searchOpen || wide === false) return
|
|
2754
|
+
const input = searchRoot.current?.querySelector('.orca-search-field input')
|
|
2755
|
+
if (!input || input.closest('[inert]')) return
|
|
2756
|
+
input.focus({ preventScroll: true })
|
|
2757
|
+
searchFocusPending.current = false
|
|
2758
|
+
})
|
|
2759
|
+
|
|
2760
|
+
const workspaceSnapshot = useSource(workspaceSource)
|
|
2761
|
+
const sessionSnapshot = useSource(sessionSource)
|
|
2762
|
+
const sessionStatusSnapshot = useSource(sessionStatusSource)
|
|
2763
|
+
const layoutSnapshot = useSource(layoutSource)
|
|
2764
|
+
const workspaceState = workspaceSnapshot || EMPTY_WORKSPACES
|
|
2765
|
+
const sessionState = sessionSnapshot || EMPTY_SESSIONS
|
|
2766
|
+
const statusMap = sessionStatusSnapshot || EMPTY_STATUS
|
|
2767
|
+
const workspacePathsKey = React.useMemo(
|
|
2768
|
+
() =>
|
|
2769
|
+
(workspaceState.items || [])
|
|
2770
|
+
.map((workspace) => normalizePath(workspace.path))
|
|
2771
|
+
.filter(Boolean)
|
|
2772
|
+
.sort()
|
|
2773
|
+
.join('\n'),
|
|
2774
|
+
[workspaceState],
|
|
2775
|
+
)
|
|
2776
|
+
|
|
2777
|
+
React.useEffect(() => {
|
|
2778
|
+
if (typeof resolveRepositories !== 'function') {
|
|
2779
|
+
setRepoMap(null)
|
|
2780
|
+
return undefined
|
|
2781
|
+
}
|
|
2782
|
+
const paths = workspacePathsKey ? workspacePathsKey.split('\n').filter(Boolean) : []
|
|
2783
|
+
if (paths.length === 0) {
|
|
2784
|
+
setRepoMap(null)
|
|
2785
|
+
return undefined
|
|
2786
|
+
}
|
|
2787
|
+
const controller = new AbortController()
|
|
2788
|
+
let cancelled = false
|
|
2789
|
+
resolveRepositories(paths, controller.signal)
|
|
2790
|
+
.then((repositories) => {
|
|
2791
|
+
if (cancelled) return
|
|
2792
|
+
if (!Array.isArray(repositories)) {
|
|
2793
|
+
setRepoMap(null)
|
|
2794
|
+
return
|
|
2795
|
+
}
|
|
2796
|
+
const next = new Map()
|
|
2797
|
+
for (const repository of repositories) {
|
|
2798
|
+
if (!repository || typeof repository.key !== 'string') continue
|
|
2799
|
+
next.set(normalizePath(repository.path), repository)
|
|
2800
|
+
}
|
|
2801
|
+
setRepoMap(next)
|
|
2802
|
+
})
|
|
2803
|
+
.catch((error) => {
|
|
2804
|
+
if (cancelled || error?.name === 'AbortError') return
|
|
2805
|
+
setRepoMap(null)
|
|
2806
|
+
})
|
|
2807
|
+
return () => {
|
|
2808
|
+
cancelled = true
|
|
2809
|
+
controller.abort()
|
|
2810
|
+
}
|
|
2811
|
+
}, [workspacePathsKey, resolveRepositories])
|
|
2812
|
+
|
|
2813
|
+
React.useEffect(() => {
|
|
2814
|
+
saveState(state)
|
|
2815
|
+
}, [state])
|
|
2816
|
+
|
|
2817
|
+
React.useEffect(
|
|
2818
|
+
() => () => {
|
|
2819
|
+
if (toastTimer.current) window.clearTimeout(toastTimer.current)
|
|
2820
|
+
},
|
|
2821
|
+
[],
|
|
2822
|
+
)
|
|
2823
|
+
|
|
2824
|
+
const showToast = React.useCallback((message, tone) => {
|
|
2825
|
+
if (!message) return
|
|
2826
|
+
setToast({ message, tone: tone || 'info', key: Date.now() })
|
|
2827
|
+
if (toastTimer.current) window.clearTimeout(toastTimer.current)
|
|
2828
|
+
toastTimer.current = window.setTimeout(() => setToast(null), 3000)
|
|
2829
|
+
}, [])
|
|
2830
|
+
|
|
2831
|
+
const fail = React.useCallback(
|
|
2832
|
+
(error, fallbackKey) => {
|
|
2833
|
+
showToast(errorMessage(error) || t(fallbackKey), 'error')
|
|
2834
|
+
},
|
|
2835
|
+
[showToast, t],
|
|
2836
|
+
)
|
|
2837
|
+
|
|
2838
|
+
const currentId = findCurrentId(sessionState)
|
|
2839
|
+
const activePanel =
|
|
2840
|
+
layoutSnapshot &&
|
|
2841
|
+
layoutSnapshot.activePanelId !== null &&
|
|
2842
|
+
layoutSnapshot.activePanelId !== undefined
|
|
2843
|
+
const currentForView = activePanel ? undefined : currentId
|
|
2844
|
+
const view = React.useMemo(
|
|
2845
|
+
() =>
|
|
2846
|
+
buildView({
|
|
2847
|
+
workspaceSnapshot: workspaceState,
|
|
2848
|
+
sessionSnapshot: sessionState,
|
|
2849
|
+
statusMap,
|
|
2850
|
+
state,
|
|
2851
|
+
currentId,
|
|
2852
|
+
query,
|
|
2853
|
+
repoMap,
|
|
2854
|
+
}),
|
|
2855
|
+
[workspaceState, sessionState, statusMap, state, currentId, query, repoMap],
|
|
2856
|
+
)
|
|
2857
|
+
const archivedSet = React.useMemo(() => archivedSetOf(workspaceState), [workspaceState])
|
|
2858
|
+
const pinnedSet = React.useMemo(
|
|
2859
|
+
() =>
|
|
2860
|
+
new Set(
|
|
2861
|
+
Array.isArray(workspaceState.pinnedSessionIds) ? workspaceState.pinnedSessionIds : [],
|
|
2862
|
+
),
|
|
2863
|
+
[workspaceState],
|
|
2864
|
+
)
|
|
2865
|
+
const currentProject = currentId ? view.projectBySession.get(currentId) : undefined
|
|
2866
|
+
const currentProjectKey = currentProject ? currentProject.key : undefined
|
|
2867
|
+
|
|
2868
|
+
const closeMenu = React.useCallback(() => setMenu(null), [])
|
|
2869
|
+
const closeDialog = React.useCallback(() => setDialog(null), [])
|
|
2870
|
+
|
|
2871
|
+
const openMenuAtRect = React.useCallback((rect, items, width) => {
|
|
2872
|
+
const menuWidth = Math.min(width || 248, Math.max(180, window.innerWidth - 16))
|
|
2873
|
+
const estimated = items.reduce(
|
|
2874
|
+
(sum, item) => sum + (item.section ? 26 : item.divider ? 9 : 31),
|
|
2875
|
+
8,
|
|
2876
|
+
)
|
|
2877
|
+
const x = Math.min(Math.max(8, rect.right - menuWidth), window.innerWidth - menuWidth - 8)
|
|
2878
|
+
let y = rect.bottom + 4
|
|
2879
|
+
if (y + estimated > window.innerHeight - 8) y = Math.max(8, rect.top - estimated - 4)
|
|
2880
|
+
setMenu({ x, y, width: menuWidth, items, key: Date.now() })
|
|
2881
|
+
}, [])
|
|
2882
|
+
|
|
2883
|
+
const toggleSearch = (force) => {
|
|
2884
|
+
if (force === true || searchOpen) {
|
|
2885
|
+
setSearchOpen(false)
|
|
2886
|
+
setQuery('')
|
|
2887
|
+
return
|
|
2888
|
+
}
|
|
2889
|
+
setSearchOpen(true)
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
const setMode = (mode) => {
|
|
2893
|
+
if (!MODES.includes(mode)) return
|
|
2894
|
+
setState((prev) => ({ ...prev, mode }))
|
|
2895
|
+
}
|
|
2896
|
+
const setOrderBy = (orderBy) => {
|
|
2897
|
+
setState((prev) => ({ ...prev, orderBy }))
|
|
2898
|
+
}
|
|
2899
|
+
const setFilter = (archivedFilter) => {
|
|
2900
|
+
setState((prev) => ({ ...prev, archivedFilter }))
|
|
2901
|
+
}
|
|
2902
|
+
const setActiveOnly = (activeOnly) => {
|
|
2903
|
+
setState((prev) => ({ ...prev, activeOnly: Boolean(activeOnly) }))
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2906
|
+
const toggleGroup = (key, defaultExpanded) => {
|
|
2907
|
+
setState((prev) => toggleCollapsed(prev, key, defaultExpanded))
|
|
2908
|
+
}
|
|
2909
|
+
const toggleProject = (key, isCurrent) => {
|
|
2910
|
+
setState((prev) => toggleCollapsed(prev, `p:${key}`, isCurrent))
|
|
2911
|
+
}
|
|
2912
|
+
|
|
2913
|
+
const openSession = (session, fromVariant) => {
|
|
2914
|
+
if (archivedSet.has(session.id)) {
|
|
2915
|
+
showToast(t('session.archivedNotOpenable'), 'error')
|
|
2916
|
+
return
|
|
2917
|
+
}
|
|
2918
|
+
const project = view.projectBySession.get(session.id)
|
|
2919
|
+
if (project) {
|
|
2920
|
+
const key = `p:${project.key}`
|
|
2921
|
+
setState((prev) => {
|
|
2922
|
+
const collapsed = isCollapsed(prev, key, project.key === currentProjectKey)
|
|
2923
|
+
let groupCollapsed = false
|
|
2924
|
+
if (prev.mode === 'orca' && prev.groups.length > 0) {
|
|
2925
|
+
const assigned = assignmentForProject(prev, project)
|
|
2926
|
+
const valid = assigned && prev.groups.some((group) => group.id === assigned)
|
|
2927
|
+
groupCollapsed = isCollapsed(prev, `g:${valid ? assigned : UNGROUPED}`, true)
|
|
2928
|
+
}
|
|
2929
|
+
if (fromVariant === 'pinned') {
|
|
2930
|
+
if (!collapsed && !groupCollapsed) return prev
|
|
2931
|
+
return { ...prev, collapsed: { ...prev.collapsed, [key]: true } }
|
|
2932
|
+
}
|
|
2933
|
+
if (!collapsed) return prev
|
|
2934
|
+
return { ...prev, collapsed: { ...prev.collapsed, [key]: false } }
|
|
2935
|
+
})
|
|
2936
|
+
}
|
|
2937
|
+
openSessionService(session.id)
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2940
|
+
const revealSession = (session) => {
|
|
2941
|
+
const project = view.projectBySession.get(session.id)
|
|
2942
|
+
if (!project) return
|
|
2943
|
+
const looseGroup = project.isUngrouped
|
|
2944
|
+
? project.looseGroups?.find((group) =>
|
|
2945
|
+
group.sessions.some((entry) => entry.id === session.id),
|
|
2946
|
+
)
|
|
2947
|
+
: undefined
|
|
2948
|
+
if (project.isUngrouped && !looseGroup) return
|
|
2949
|
+
setState((prev) => {
|
|
2950
|
+
const collapsed = { ...(prev.collapsed || {}) }
|
|
2951
|
+
if (looseGroup) {
|
|
2952
|
+
collapsed.loose = false
|
|
2953
|
+
collapsed[`lg:${looseGroup.key}`] = false
|
|
2954
|
+
return { ...prev, collapsed }
|
|
2955
|
+
}
|
|
2956
|
+
if (prev.mode === 'orca' && Array.isArray(prev.groups) && prev.groups.length > 0) {
|
|
2957
|
+
const assigned = assignmentForProject(prev, project)
|
|
2958
|
+
const valid = assigned && prev.groups.some((group) => group.id === assigned)
|
|
2959
|
+
collapsed[`g:${valid ? assigned : UNGROUPED}`] = false
|
|
2960
|
+
}
|
|
2961
|
+
collapsed[`p:${project.key}`] = false
|
|
2962
|
+
return { ...prev, collapsed }
|
|
2963
|
+
})
|
|
2964
|
+
const selector = looseGroup
|
|
2965
|
+
? '.orca-group--loose .orca-session--flat[data-session-id]'
|
|
2966
|
+
: '.orca-session--project[data-session-id], .orca-session--tree[data-session-id]'
|
|
2967
|
+
let attempts = 0
|
|
2968
|
+
const scrollToRow = () => {
|
|
2969
|
+
const root = searchRoot.current
|
|
2970
|
+
if (!root) return
|
|
2971
|
+
const row = Array.from(root.querySelectorAll(selector)).find(
|
|
2972
|
+
(element) => element.dataset.sessionId === session.id,
|
|
2973
|
+
)
|
|
2974
|
+
if (row) {
|
|
2975
|
+
row.scrollIntoView({ block: 'nearest' })
|
|
2976
|
+
return
|
|
2977
|
+
}
|
|
2978
|
+
attempts += 1
|
|
2979
|
+
if (attempts < 30) window.setTimeout(scrollToRow, 100)
|
|
2980
|
+
}
|
|
2981
|
+
window.setTimeout(scrollToRow, 50)
|
|
2982
|
+
}
|
|
2983
|
+
|
|
2984
|
+
const pin = async (session) => {
|
|
2985
|
+
try {
|
|
2986
|
+
await pinSessionService(session.id)
|
|
2987
|
+
showToast(t('session.pinned', { name: sessionLabel(session, currentId, t) }))
|
|
2988
|
+
} catch (error) {
|
|
2989
|
+
fail(error, 'toast.pinFailed')
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
const unpin = async (session) => {
|
|
2993
|
+
try {
|
|
2994
|
+
await unpinSessionService(session.id)
|
|
2995
|
+
showToast(t('session.unpinned', { name: sessionLabel(session, currentId, t) }))
|
|
2996
|
+
} catch (error) {
|
|
2997
|
+
fail(error, 'toast.pinFailed')
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
3000
|
+
const archiveById = async (sessionId, sessionTitle, stopActivity) => {
|
|
3001
|
+
try {
|
|
3002
|
+
await archiveSessionService(sessionId, { stopActivity: Boolean(stopActivity) })
|
|
3003
|
+
showToast(t('session.archived', { name: sessionTitle }))
|
|
3004
|
+
} catch (error) {
|
|
3005
|
+
if (!stopActivity && isActiveWorkRefusal(error)) {
|
|
3006
|
+
setDialog({
|
|
3007
|
+
key: `d${Date.now()}`,
|
|
3008
|
+
kind: 'archive-confirm',
|
|
3009
|
+
sessionId,
|
|
3010
|
+
sessionTitle,
|
|
3011
|
+
title: t('session.stopArchiveTitle'),
|
|
3012
|
+
description: t('session.stopArchiveDesc', { name: sessionTitle }),
|
|
3013
|
+
confirm: t('session.stopArchive'),
|
|
3014
|
+
danger: true,
|
|
3015
|
+
})
|
|
3016
|
+
return
|
|
3017
|
+
}
|
|
3018
|
+
fail(error, 'toast.archiveFailed')
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
const archive = (session) => {
|
|
3022
|
+
archiveById(session.id, sessionLabel(session, currentId, t), false)
|
|
3023
|
+
}
|
|
3024
|
+
const unarchive = async (session) => {
|
|
3025
|
+
try {
|
|
3026
|
+
await unarchiveSessionService(session.id)
|
|
3027
|
+
showToast(t('session.unarchived', { name: sessionLabel(session, currentId, t) }))
|
|
3028
|
+
} catch (error) {
|
|
3029
|
+
fail(error, 'toast.archiveFailed')
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
const copy = async (session) => {
|
|
3033
|
+
try {
|
|
3034
|
+
await navigator.clipboard.writeText(session.id)
|
|
3035
|
+
showToast(t('session.copied'))
|
|
3036
|
+
} catch {
|
|
3037
|
+
showToast(t('session.copyFailed'), 'error')
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
|
|
3041
|
+
const startSession = (project) => {
|
|
3042
|
+
if (!project.workspaceId) return
|
|
3043
|
+
startSessionService(project.workspaceId)
|
|
3044
|
+
}
|
|
3045
|
+
const startSessionIn = async (worktree) => {
|
|
3046
|
+
if (!worktree) return
|
|
3047
|
+
try {
|
|
3048
|
+
if (worktree.workspaceId) {
|
|
3049
|
+
startSessionService(worktree.workspaceId)
|
|
3050
|
+
return
|
|
3051
|
+
}
|
|
3052
|
+
const path = normalizePath(worktree.path)
|
|
3053
|
+
const existing = (workspaceState.items || []).find(
|
|
3054
|
+
(workspace) => normalizePath(workspace.path) === path,
|
|
3055
|
+
)
|
|
3056
|
+
if (existing?.workspaceId) {
|
|
3057
|
+
startSessionService(existing.workspaceId)
|
|
3058
|
+
return
|
|
3059
|
+
}
|
|
3060
|
+
const created = await createWorkspace(worktree.path)
|
|
3061
|
+
if (!created?.workspaceId) {
|
|
3062
|
+
showToast(t('toast.workspaceFailed'), 'error')
|
|
3063
|
+
return
|
|
3064
|
+
}
|
|
3065
|
+
startSessionService(created.workspaceId)
|
|
3066
|
+
} catch (error) {
|
|
3067
|
+
fail(error, 'toast.workspaceFailed')
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
const openWorkspace = (project) => {
|
|
3071
|
+
if (!project.workspaceId) return
|
|
3072
|
+
openWorkspaceService(project.workspaceId)
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
const addWorkspace = async (groupId) => {
|
|
3076
|
+
try {
|
|
3077
|
+
const path = await pickDirectory()
|
|
3078
|
+
if (!path) return
|
|
3079
|
+
const workspace = await createWorkspace(path)
|
|
3080
|
+
if (!workspace?.path) return
|
|
3081
|
+
const key = normalizePath(workspace.path)
|
|
3082
|
+
if (groupId) {
|
|
3083
|
+
setState((prev) => {
|
|
3084
|
+
const target = view.groups.find((group) => group.id === groupId)
|
|
3085
|
+
const keys = target ? target.projects.map((project) => project.key) : []
|
|
3086
|
+
return moveProjectInOrder(prev, key, groupId, keys, null, 'after')
|
|
3087
|
+
})
|
|
3088
|
+
}
|
|
3089
|
+
showToast(t('project.added', { name: workspace.title || baseName(workspace.path) }))
|
|
3090
|
+
} catch (error) {
|
|
3091
|
+
fail(error, 'toast.workspaceFailed')
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
|
|
3095
|
+
const createGroupNow = (name, assignPath) => {
|
|
3096
|
+
const id = nextGroupId()
|
|
3097
|
+
setState((prev) => {
|
|
3098
|
+
let next = createGroup(prev, id, name)
|
|
3099
|
+
if (assignPath) {
|
|
3100
|
+
const project = view.projects.find((entry) => entry.key === assignPath)
|
|
3101
|
+
next = moveProjectInOrder(next, assignPath, id, [], null, 'after', project?.memberPaths)
|
|
3102
|
+
}
|
|
3103
|
+
return next
|
|
3104
|
+
})
|
|
3105
|
+
showToast(t('group.created', { name }))
|
|
3106
|
+
}
|
|
3107
|
+
const renameGroupNow = (id, name) => {
|
|
3108
|
+
setState((prev) => renameGroup(prev, id, name))
|
|
3109
|
+
}
|
|
3110
|
+
const deleteGroupNow = (id) => {
|
|
3111
|
+
setState((prev) => deleteGroup(prev, id))
|
|
3112
|
+
showToast(t('group.deleted'))
|
|
3113
|
+
}
|
|
3114
|
+
const moveProject = (path, groupId, orderedKeys, anchorKey, position) => {
|
|
3115
|
+
if (anchorKey && path === anchorKey) return
|
|
3116
|
+
const project = view.projects.find((entry) => entry.key === path)
|
|
3117
|
+
const previousGroup = project ? project.groupId : null
|
|
3118
|
+
const nextGroup = groupId || null
|
|
3119
|
+
const visible = new Set([...(orderedKeys || []), path])
|
|
3120
|
+
const aliases = new Map()
|
|
3121
|
+
for (const sibling of view.projects) {
|
|
3122
|
+
if (!visible.has(sibling.key)) continue
|
|
3123
|
+
// Keep member order so a legacy alias uses the same slot as sorting.
|
|
3124
|
+
for (const member of sibling.memberPaths) {
|
|
3125
|
+
if (!visible.has(member)) aliases.set(member, sibling.key)
|
|
3126
|
+
}
|
|
3127
|
+
}
|
|
3128
|
+
setState((prev) =>
|
|
3129
|
+
moveProjectInOrder(
|
|
3130
|
+
prev,
|
|
3131
|
+
path,
|
|
3132
|
+
groupId,
|
|
3133
|
+
orderedKeys,
|
|
3134
|
+
anchorKey,
|
|
3135
|
+
position,
|
|
3136
|
+
project?.memberPaths,
|
|
3137
|
+
aliases,
|
|
3138
|
+
),
|
|
3139
|
+
)
|
|
3140
|
+
if (project && previousGroup !== nextGroup) {
|
|
3141
|
+
const groupName = groupId
|
|
3142
|
+
? state.groups.find((group) => group.id === groupId)?.name || t('group.ungrouped')
|
|
3143
|
+
: t('group.ungrouped')
|
|
3144
|
+
showToast(t('group.moved', { name: project.title, group: groupName }))
|
|
3145
|
+
}
|
|
3146
|
+
}
|
|
3147
|
+
const moveProjectToGroup = (path, groupId) => {
|
|
3148
|
+
const target = groupId
|
|
3149
|
+
? view.groups.find((group) => group.id === groupId)?.projects || []
|
|
3150
|
+
: view.ungroupedProjects
|
|
3151
|
+
const keys = target.map((project) => project.key).filter((key) => key !== path)
|
|
3152
|
+
moveProject(path, groupId, keys, null, 'after')
|
|
3153
|
+
}
|
|
3154
|
+
const moveSession = (projectKey, sessionId, orderedIds, anchorId, position) => {
|
|
3155
|
+
if (sessionId === anchorId) return
|
|
3156
|
+
const project = view.projects.find((entry) => entry.key === projectKey)
|
|
3157
|
+
setState((prev) =>
|
|
3158
|
+
moveSessionInOrder(
|
|
3159
|
+
prev,
|
|
3160
|
+
projectKey,
|
|
3161
|
+
sessionId,
|
|
3162
|
+
orderedIds,
|
|
3163
|
+
anchorId,
|
|
3164
|
+
position,
|
|
3165
|
+
project?.memberPaths,
|
|
3166
|
+
),
|
|
3167
|
+
)
|
|
3168
|
+
}
|
|
3169
|
+
|
|
3170
|
+
const drag = {
|
|
3171
|
+
start(event, project) {
|
|
3172
|
+
if (!event) return
|
|
3173
|
+
dragPayload = { kind: 'project', path: project.key }
|
|
3174
|
+
try {
|
|
3175
|
+
event.dataTransfer.effectAllowed = 'move'
|
|
3176
|
+
event.dataTransfer.setData('text/orca-project', project.key)
|
|
3177
|
+
} catch {
|
|
3178
|
+
// Some browsers refuse custom drag data; the in-memory payload still works.
|
|
3179
|
+
}
|
|
3180
|
+
},
|
|
3181
|
+
startSession(event, session, project) {
|
|
3182
|
+
if (!event) return
|
|
3183
|
+
dragPayload = { kind: 'session', id: session.id, projectKey: project.key }
|
|
3184
|
+
try {
|
|
3185
|
+
event.dataTransfer.effectAllowed = 'move'
|
|
3186
|
+
event.dataTransfer.setData('text/orca-session', session.id)
|
|
3187
|
+
} catch {
|
|
3188
|
+
// The in-memory payload remains the source of truth.
|
|
3189
|
+
}
|
|
3190
|
+
},
|
|
3191
|
+
over(event, project) {
|
|
3192
|
+
if (dragPayload?.kind !== 'project') return
|
|
3193
|
+
if (dragPayload.path === project.key) return
|
|
3194
|
+
event.preventDefault()
|
|
3195
|
+
event.stopPropagation()
|
|
3196
|
+
const row = event.currentTarget.parentElement || event.currentTarget
|
|
3197
|
+
const rect = row.getBoundingClientRect()
|
|
3198
|
+
const position = event.clientY < rect.top + rect.height / 2 ? 'before' : 'after'
|
|
3199
|
+
setDropIndicator(row, position)
|
|
3200
|
+
},
|
|
3201
|
+
drop(event, project, groupId, siblings) {
|
|
3202
|
+
if (dragPayload?.kind !== 'project') return
|
|
3203
|
+
stopEvent(event)
|
|
3204
|
+
const rect = event.currentTarget.getBoundingClientRect()
|
|
3205
|
+
const position = event.clientY < rect.top + rect.height / 2 ? 'before' : 'after'
|
|
3206
|
+
const path = dragPayload.path
|
|
3207
|
+
dragPayload = null
|
|
3208
|
+
clearDropIndicators()
|
|
3209
|
+
if (path && path !== project.key)
|
|
3210
|
+
moveProject(path, groupId, siblings || [], project.key, position)
|
|
3211
|
+
},
|
|
3212
|
+
dropOnGroup(event, groupId, projectKeys) {
|
|
3213
|
+
if (dragPayload?.kind !== 'project') return
|
|
3214
|
+
stopEvent(event)
|
|
3215
|
+
const path = dragPayload.path
|
|
3216
|
+
dragPayload = null
|
|
3217
|
+
clearDropIndicators()
|
|
3218
|
+
if (path) moveProject(path, groupId, projectKeys || [], null, 'after')
|
|
3219
|
+
},
|
|
3220
|
+
overSession(event, session, project) {
|
|
3221
|
+
if (dragPayload?.kind !== 'session') return
|
|
3222
|
+
if (dragPayload.projectKey !== project.key) return
|
|
3223
|
+
if (dragPayload.id === session.id) return
|
|
3224
|
+
event.preventDefault()
|
|
3225
|
+
event.stopPropagation()
|
|
3226
|
+
const row = event.currentTarget.parentElement
|
|
3227
|
+
if (!row) return
|
|
3228
|
+
const rect = row.getBoundingClientRect()
|
|
3229
|
+
const position = event.clientY < rect.top + rect.height / 2 ? 'before' : 'after'
|
|
3230
|
+
setDropIndicator(row, position)
|
|
3231
|
+
},
|
|
3232
|
+
dropSession(event, session, project, orderedIds) {
|
|
3233
|
+
if (dragPayload?.kind !== 'session') return
|
|
3234
|
+
if (dragPayload.projectKey !== project.key) return
|
|
3235
|
+
stopEvent(event)
|
|
3236
|
+
const row = event.currentTarget.parentElement
|
|
3237
|
+
const rect = row ? row.getBoundingClientRect() : { top: 0, height: 0 }
|
|
3238
|
+
const position = event.clientY < rect.top + rect.height / 2 ? 'before' : 'after'
|
|
3239
|
+
const id = dragPayload.id
|
|
3240
|
+
dragPayload = null
|
|
3241
|
+
clearDropIndicators()
|
|
3242
|
+
if (id && id !== session.id)
|
|
3243
|
+
moveSession(project.key, id, orderedIds || [], session.id, position)
|
|
3244
|
+
},
|
|
3245
|
+
leave(event) {
|
|
3246
|
+
if (!event?.currentTarget) return
|
|
3247
|
+
if (event.currentTarget.contains(event.relatedTarget)) return
|
|
3248
|
+
if (event.currentTarget.dataset.orcaDrop) delete event.currentTarget.dataset.orcaDrop
|
|
3249
|
+
},
|
|
3250
|
+
end() {
|
|
3251
|
+
dragPayload = null
|
|
3252
|
+
clearDropIndicators()
|
|
3253
|
+
},
|
|
3254
|
+
}
|
|
3255
|
+
|
|
3256
|
+
const openSessionMenu = (event, session, pinned, archived, variant) => {
|
|
3257
|
+
const rect = event.currentTarget.getBoundingClientRect()
|
|
3258
|
+
const items = []
|
|
3259
|
+
if (!archived) {
|
|
3260
|
+
items.push({
|
|
3261
|
+
label: pinned ? t('pinned.unpin') : t('pinned.pin'),
|
|
3262
|
+
icon: pinned ? 'pinFilled' : 'pin',
|
|
3263
|
+
onSelect: () => (pinned ? unpin(session) : pin(session)),
|
|
3264
|
+
})
|
|
3265
|
+
}
|
|
3266
|
+
if (variant === 'pinned') {
|
|
3267
|
+
items.push({
|
|
3268
|
+
label: t('session.reveal'),
|
|
3269
|
+
icon: 'folderOpen',
|
|
3270
|
+
onSelect: () => revealSession(session),
|
|
3271
|
+
})
|
|
3272
|
+
}
|
|
3273
|
+
items.push({
|
|
3274
|
+
label: t('session.open'),
|
|
3275
|
+
icon: 'open',
|
|
3276
|
+
onSelect: () => openSession(session, variant),
|
|
3277
|
+
})
|
|
3278
|
+
items.push({ divider: true })
|
|
3279
|
+
items.push({ label: t('session.copyId'), icon: 'copy', onSelect: () => copy(session) })
|
|
3280
|
+
items.push(
|
|
3281
|
+
archived
|
|
3282
|
+
? { label: t('session.unarchive'), icon: 'restore', onSelect: () => unarchive(session) }
|
|
3283
|
+
: {
|
|
3284
|
+
label: t('session.archive'),
|
|
3285
|
+
icon: 'archive',
|
|
3286
|
+
danger: true,
|
|
3287
|
+
onSelect: () => archive(session),
|
|
3288
|
+
},
|
|
3289
|
+
)
|
|
3290
|
+
openMenuAtRect(rect, items)
|
|
3291
|
+
}
|
|
3292
|
+
|
|
3293
|
+
const openMoveMenu = (rect, project) => {
|
|
3294
|
+
const current = project.groupId
|
|
3295
|
+
const items = [
|
|
3296
|
+
{ section: t('group.drop') },
|
|
3297
|
+
{
|
|
3298
|
+
label: t('group.ungrouped'),
|
|
3299
|
+
checked: !current,
|
|
3300
|
+
onSelect: () => moveProjectToGroup(project.key, null),
|
|
3301
|
+
},
|
|
3302
|
+
...state.groups.map((group) => ({
|
|
3303
|
+
label: group.name,
|
|
3304
|
+
checked: current === group.id,
|
|
3305
|
+
onSelect: () => moveProjectToGroup(project.key, group.id),
|
|
3306
|
+
})),
|
|
3307
|
+
{ divider: true },
|
|
3308
|
+
{
|
|
3309
|
+
label: t('action.newGroup'),
|
|
3310
|
+
icon: 'groupAdd',
|
|
3311
|
+
onSelect: () => openNewGroupDialog(project.key),
|
|
3312
|
+
},
|
|
3313
|
+
]
|
|
3314
|
+
openMenuAtRect(rect, items)
|
|
3315
|
+
}
|
|
3316
|
+
|
|
3317
|
+
const openProjectMenu = (event, project) => {
|
|
3318
|
+
const rect = event.currentTarget.getBoundingClientRect()
|
|
3319
|
+
const worktrees = Array.isArray(project.worktrees) ? project.worktrees : []
|
|
3320
|
+
const items = []
|
|
3321
|
+
if (worktrees.length > 1) {
|
|
3322
|
+
items.push({ section: t('project.worktreesSection') })
|
|
3323
|
+
for (const worktree of worktrees) {
|
|
3324
|
+
items.push({
|
|
3325
|
+
label: t('project.newSessionIn', {
|
|
3326
|
+
name: worktree.label === 'main' ? t('project.worktreeMain') : worktree.label,
|
|
3327
|
+
}),
|
|
3328
|
+
icon: 'chat',
|
|
3329
|
+
onSelect: () => startSessionIn(worktree),
|
|
3330
|
+
})
|
|
3331
|
+
}
|
|
3332
|
+
} else {
|
|
3333
|
+
items.push({
|
|
3334
|
+
label: t('project.newSession'),
|
|
3335
|
+
icon: 'chat',
|
|
3336
|
+
onSelect: () => startSession(project),
|
|
3337
|
+
})
|
|
3338
|
+
}
|
|
3339
|
+
items.push(
|
|
3340
|
+
{ label: t('project.open'), icon: 'open', onSelect: () => openWorkspace(project) },
|
|
3341
|
+
{ divider: true },
|
|
3342
|
+
{
|
|
3343
|
+
label: t('project.move'),
|
|
3344
|
+
icon: 'groupAdd',
|
|
3345
|
+
onSelect: () => openMoveMenu(rect, project),
|
|
3346
|
+
},
|
|
3347
|
+
{
|
|
3348
|
+
label: t('project.rename'),
|
|
3349
|
+
icon: 'edit',
|
|
3350
|
+
onSelect: () => openRenameProjectDialog(project),
|
|
3351
|
+
},
|
|
3352
|
+
{
|
|
3353
|
+
label: t('project.delete'),
|
|
3354
|
+
icon: 'trash',
|
|
3355
|
+
danger: true,
|
|
3356
|
+
onSelect: () => openDeleteProjectDialog(project),
|
|
3357
|
+
},
|
|
3358
|
+
)
|
|
3359
|
+
openMenuAtRect(rect, items)
|
|
3360
|
+
}
|
|
3361
|
+
|
|
3362
|
+
const openGroupMenu = (event, group) => {
|
|
3363
|
+
const rect = event.currentTarget.getBoundingClientRect()
|
|
3364
|
+
openMenuAtRect(rect, [
|
|
3365
|
+
{ label: t('group.rename'), icon: 'edit', onSelect: () => openRenameGroupDialog(group) },
|
|
3366
|
+
{ label: t('action.addProject'), icon: 'plus', onSelect: () => addWorkspace(group.id) },
|
|
3367
|
+
{ divider: true },
|
|
3368
|
+
{
|
|
3369
|
+
label: t('group.delete'),
|
|
3370
|
+
icon: 'trash',
|
|
3371
|
+
danger: true,
|
|
3372
|
+
onSelect: () => openDeleteGroupDialog(group),
|
|
3373
|
+
},
|
|
3374
|
+
])
|
|
3375
|
+
}
|
|
3376
|
+
|
|
3377
|
+
const openAddMenu = (event, groupId) => {
|
|
3378
|
+
const rect = event.currentTarget.getBoundingClientRect()
|
|
3379
|
+
const items = [
|
|
3380
|
+
{
|
|
3381
|
+
label: state.mode === 'orca' ? t('action.addProject') : t('action.addWorkspace'),
|
|
3382
|
+
icon: 'plus',
|
|
3383
|
+
onSelect: () => addWorkspace(groupId),
|
|
3384
|
+
},
|
|
3385
|
+
]
|
|
3386
|
+
if (state.mode === 'orca') {
|
|
3387
|
+
items.push({
|
|
3388
|
+
label: t('action.newGroup'),
|
|
3389
|
+
icon: 'groupAdd',
|
|
3390
|
+
onSelect: () => openNewGroupDialog(),
|
|
3391
|
+
})
|
|
3392
|
+
}
|
|
3393
|
+
openMenuAtRect(rect, items)
|
|
3394
|
+
}
|
|
3395
|
+
|
|
3396
|
+
const openViewMenu = (event) => {
|
|
3397
|
+
const rect = event.currentTarget.getBoundingClientRect()
|
|
3398
|
+
const items = [
|
|
3399
|
+
{ section: t('section.groupBy') },
|
|
3400
|
+
{
|
|
3401
|
+
label: t('group.workspace'),
|
|
3402
|
+
checked: state.mode === 'workspace',
|
|
3403
|
+
onSelect: () => setMode('workspace'),
|
|
3404
|
+
},
|
|
3405
|
+
{
|
|
3406
|
+
label: t('group.workspaceTree'),
|
|
3407
|
+
checked: state.mode === 'workspace-tree',
|
|
3408
|
+
onSelect: () => setMode('workspace-tree'),
|
|
3409
|
+
},
|
|
3410
|
+
{
|
|
3411
|
+
label: t('group.flat'),
|
|
3412
|
+
checked: state.mode === 'flat',
|
|
3413
|
+
onSelect: () => setMode('flat'),
|
|
3414
|
+
},
|
|
3415
|
+
{
|
|
3416
|
+
label: t('group.orca'),
|
|
3417
|
+
checked: state.mode === 'orca',
|
|
3418
|
+
badge: t('new'),
|
|
3419
|
+
onSelect: () => setMode('orca'),
|
|
3420
|
+
},
|
|
3421
|
+
{ divider: true },
|
|
3422
|
+
{ section: t('order.label') },
|
|
3423
|
+
{
|
|
3424
|
+
label: t('order.manual'),
|
|
3425
|
+
checked: state.orderBy === 'manual',
|
|
3426
|
+
onSelect: () => setOrderBy('manual'),
|
|
3427
|
+
},
|
|
3428
|
+
{
|
|
3429
|
+
label: t('order.updated'),
|
|
3430
|
+
checked: state.orderBy === 'updated',
|
|
3431
|
+
onSelect: () => setOrderBy('updated'),
|
|
3432
|
+
},
|
|
3433
|
+
{ divider: true },
|
|
3434
|
+
{ section: t('filter.label') },
|
|
3435
|
+
{
|
|
3436
|
+
label: t('filter.hide'),
|
|
3437
|
+
checked: state.archivedFilter === 'hide',
|
|
3438
|
+
onSelect: () => setFilter('hide'),
|
|
3439
|
+
},
|
|
3440
|
+
{
|
|
3441
|
+
label: t('filter.all'),
|
|
3442
|
+
checked: state.archivedFilter === 'all',
|
|
3443
|
+
onSelect: () => setFilter('all'),
|
|
3444
|
+
},
|
|
3445
|
+
{
|
|
3446
|
+
label: t('filter.only'),
|
|
3447
|
+
checked: state.archivedFilter === 'only',
|
|
3448
|
+
onSelect: () => setFilter('only'),
|
|
3449
|
+
},
|
|
3450
|
+
]
|
|
3451
|
+
if (state.mode === 'orca') {
|
|
3452
|
+
items.push({ divider: true })
|
|
3453
|
+
items.push({
|
|
3454
|
+
label: t('filter.activeOnly'),
|
|
3455
|
+
icon: 'dot',
|
|
3456
|
+
checked: state.activeOnly === true,
|
|
3457
|
+
onSelect: () => setActiveOnly(!state.activeOnly),
|
|
3458
|
+
})
|
|
3459
|
+
items.push({ divider: true })
|
|
3460
|
+
items.push({
|
|
3461
|
+
label: t('migration.action'),
|
|
3462
|
+
icon: 'layers',
|
|
3463
|
+
disabled: (view.migration?.candidates.length || 0) === 0,
|
|
3464
|
+
onSelect: openMigrationDialog,
|
|
3465
|
+
})
|
|
3466
|
+
if (Object.keys(state.sessionProjects || {}).length > 0) {
|
|
3467
|
+
items.push({
|
|
3468
|
+
label: t('migration.revert'),
|
|
3469
|
+
icon: 'restore',
|
|
3470
|
+
onSelect: revertMigration,
|
|
3471
|
+
})
|
|
3472
|
+
}
|
|
3473
|
+
items.push({ divider: true })
|
|
3474
|
+
items.push({
|
|
3475
|
+
label: t('action.newGroup'),
|
|
3476
|
+
icon: 'groupAdd',
|
|
3477
|
+
onSelect: () => openNewGroupDialog(),
|
|
3478
|
+
})
|
|
3479
|
+
}
|
|
3480
|
+
openMenuAtRect(rect, items, 228)
|
|
3481
|
+
}
|
|
3482
|
+
|
|
3483
|
+
const openMigrationDialog = () => {
|
|
3484
|
+
const migration = view.migration || { candidates: [], unmatched: 0 }
|
|
3485
|
+
if (migration.candidates.length === 0) {
|
|
3486
|
+
showToast(t('migration.none'))
|
|
3487
|
+
return
|
|
3488
|
+
}
|
|
3489
|
+
const projects = new Set(migration.candidates.map((candidate) => candidate.projectId)).size
|
|
3490
|
+
const preview = migration.candidates.map(({ sessionId, projectId }) => ({
|
|
3491
|
+
sessionId,
|
|
3492
|
+
projectId,
|
|
3493
|
+
}))
|
|
3494
|
+
setDialog({
|
|
3495
|
+
key: `d${Date.now()}`,
|
|
3496
|
+
kind: 'migration-confirm',
|
|
3497
|
+
preview,
|
|
3498
|
+
unmatched: migration.unmatched,
|
|
3499
|
+
title: t('migration.title'),
|
|
3500
|
+
description: t('migration.description', {
|
|
3501
|
+
n: migration.candidates.length,
|
|
3502
|
+
projects,
|
|
3503
|
+
unmatched: migration.unmatched,
|
|
3504
|
+
}),
|
|
3505
|
+
confirm: t('migration.confirm', { n: migration.candidates.length }),
|
|
3506
|
+
})
|
|
3507
|
+
}
|
|
3508
|
+
const applyMigration = ({ preview, unmatched }) => {
|
|
3509
|
+
const migration = view.migration
|
|
3510
|
+
const current = new Map(
|
|
3511
|
+
migration?.candidates.map(({ sessionId, projectId }) => [sessionId, projectId]),
|
|
3512
|
+
)
|
|
3513
|
+
if (
|
|
3514
|
+
migration?.unmatched !== unmatched ||
|
|
3515
|
+
current.size !== preview.length ||
|
|
3516
|
+
!preview.every(({ sessionId, projectId }) => current.get(sessionId) === projectId)
|
|
3517
|
+
) {
|
|
3518
|
+
showToast(t('migration.changed'))
|
|
3519
|
+
return
|
|
3520
|
+
}
|
|
3521
|
+
setState((prev) => {
|
|
3522
|
+
const sessionProjects = { ...(prev.sessionProjects || {}) }
|
|
3523
|
+
for (const { sessionId, projectId } of preview) {
|
|
3524
|
+
sessionProjects[sessionId] = projectId
|
|
3525
|
+
}
|
|
3526
|
+
return { ...prev, sessionProjects }
|
|
3527
|
+
})
|
|
3528
|
+
showToast(t('migration.done', { n: preview.length }))
|
|
3529
|
+
}
|
|
3530
|
+
const revertMigration = () => {
|
|
3531
|
+
setState((prev) => ({ ...prev, sessionProjects: {} }))
|
|
3532
|
+
showToast(t('migration.reverted'))
|
|
3533
|
+
}
|
|
3534
|
+
|
|
3535
|
+
const openNewGroupDialog = (assignPath) => {
|
|
3536
|
+
setDialog({
|
|
3537
|
+
key: `d${Date.now()}`,
|
|
3538
|
+
kind: 'group-new',
|
|
3539
|
+
assignPath,
|
|
3540
|
+
title: t('action.newGroup'),
|
|
3541
|
+
input: true,
|
|
3542
|
+
value: '',
|
|
3543
|
+
placeholder: t('group.namePlaceholder'),
|
|
3544
|
+
confirm: t('dialog.create'),
|
|
3545
|
+
})
|
|
3546
|
+
}
|
|
3547
|
+
const openRenameGroupDialog = (group) => {
|
|
3548
|
+
setDialog({
|
|
3549
|
+
key: `d${Date.now()}`,
|
|
3550
|
+
kind: 'group-rename',
|
|
3551
|
+
id: group.id,
|
|
3552
|
+
title: t('group.rename'),
|
|
3553
|
+
input: true,
|
|
3554
|
+
value: group.name,
|
|
3555
|
+
placeholder: t('group.name'),
|
|
3556
|
+
confirm: t('dialog.save'),
|
|
3557
|
+
})
|
|
3558
|
+
}
|
|
3559
|
+
const openDeleteGroupDialog = (group) => {
|
|
3560
|
+
setDialog({
|
|
3561
|
+
key: `d${Date.now()}`,
|
|
3562
|
+
kind: 'group-delete',
|
|
3563
|
+
id: group.id,
|
|
3564
|
+
title: t('group.delete'),
|
|
3565
|
+
description: t('group.deleteConfirm', { name: group.name }),
|
|
3566
|
+
confirm: t('dialog.delete'),
|
|
3567
|
+
danger: true,
|
|
3568
|
+
})
|
|
3569
|
+
}
|
|
3570
|
+
const openRenameProjectDialog = (project) => {
|
|
3571
|
+
setDialog({
|
|
3572
|
+
key: `d${Date.now()}`,
|
|
3573
|
+
kind: 'project-rename',
|
|
3574
|
+
projectKey: project.key,
|
|
3575
|
+
title: t('project.rename'),
|
|
3576
|
+
input: true,
|
|
3577
|
+
value: project.title || '',
|
|
3578
|
+
placeholder: t('project.renamePlaceholder'),
|
|
3579
|
+
confirm: t('dialog.save'),
|
|
3580
|
+
})
|
|
3581
|
+
}
|
|
3582
|
+
const openDeleteProjectDialog = (project) => {
|
|
3583
|
+
const workspaceIds = Array.isArray(project.workspaceIds)
|
|
3584
|
+
? project.workspaceIds.filter(Boolean)
|
|
3585
|
+
: project.workspaceId
|
|
3586
|
+
? [project.workspaceId]
|
|
3587
|
+
: []
|
|
3588
|
+
const many = workspaceIds.length > 1
|
|
3589
|
+
setDialog({
|
|
3590
|
+
key: `d${Date.now()}`,
|
|
3591
|
+
kind: 'project-delete',
|
|
3592
|
+
workspaceIds,
|
|
3593
|
+
title: t('project.delete'),
|
|
3594
|
+
description: many
|
|
3595
|
+
? t('project.deleteConfirmMany', {
|
|
3596
|
+
name: project.title || t('project.ungrouped'),
|
|
3597
|
+
n: workspaceIds.length,
|
|
3598
|
+
})
|
|
3599
|
+
: t('project.deleteConfirm', {
|
|
3600
|
+
name: project.title || t('project.ungrouped'),
|
|
3601
|
+
}),
|
|
3602
|
+
confirm: t('dialog.delete'),
|
|
3603
|
+
danger: true,
|
|
3604
|
+
})
|
|
3605
|
+
}
|
|
3606
|
+
|
|
3607
|
+
const confirmDialog = (value) => {
|
|
3608
|
+
const current = dialog
|
|
3609
|
+
if (!current) return
|
|
3610
|
+
setDialog(null)
|
|
3611
|
+
if (current.kind === 'group-new') {
|
|
3612
|
+
createGroupNow(value, current.assignPath)
|
|
3613
|
+
} else if (current.kind === 'group-rename') {
|
|
3614
|
+
renameGroupNow(current.id, value)
|
|
3615
|
+
} else if (current.kind === 'group-delete') {
|
|
3616
|
+
deleteGroupNow(current.id)
|
|
3617
|
+
} else if (current.kind === 'project-rename') {
|
|
3618
|
+
setState((prev) => renameProject(prev, current.projectKey, value))
|
|
3619
|
+
} else if (current.kind === 'project-delete') {
|
|
3620
|
+
const workspaceIds = Array.isArray(current.workspaceIds)
|
|
3621
|
+
? current.workspaceIds
|
|
3622
|
+
: current.workspaceId
|
|
3623
|
+
? [current.workspaceId]
|
|
3624
|
+
: []
|
|
3625
|
+
Promise.all(workspaceIds.map((workspaceId) => deleteWorkspace(workspaceId))).catch(
|
|
3626
|
+
(error) => fail(error, 'toast.projectFailed'),
|
|
3627
|
+
)
|
|
3628
|
+
} else if (current.kind === 'migration-confirm') {
|
|
3629
|
+
applyMigration(current)
|
|
3630
|
+
} else if (current.kind === 'archive-confirm') {
|
|
3631
|
+
archiveById(current.sessionId, current.sessionTitle, true)
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3634
|
+
|
|
3635
|
+
const actions = {
|
|
3636
|
+
open: openSession,
|
|
3637
|
+
pin,
|
|
3638
|
+
unpin,
|
|
3639
|
+
archive,
|
|
3640
|
+
unarchive,
|
|
3641
|
+
copy,
|
|
3642
|
+
menu: openSessionMenu,
|
|
3643
|
+
startSession,
|
|
3644
|
+
openWorkspace,
|
|
3645
|
+
projectMenu: openProjectMenu,
|
|
3646
|
+
groupMenu: openGroupMenu,
|
|
3647
|
+
addMenu: openAddMenu,
|
|
3648
|
+
toggleGroup,
|
|
3649
|
+
toggleProject,
|
|
3650
|
+
setActiveOnly,
|
|
3651
|
+
moveProject,
|
|
3652
|
+
moveSession,
|
|
3653
|
+
migrateLoose: openMigrationDialog,
|
|
3654
|
+
revertLoose: revertMigration,
|
|
3655
|
+
}
|
|
3656
|
+
|
|
3657
|
+
if (wide === false) return null
|
|
3658
|
+
|
|
3659
|
+
const count = state.mode === 'orca' ? view.counts.projects : view.counts.sessions
|
|
3660
|
+
|
|
3661
|
+
const content = h(
|
|
3662
|
+
'div',
|
|
3663
|
+
{ ref: searchRoot, className: 'orca-root', 'data-mode': state.mode },
|
|
3664
|
+
h(Header, {
|
|
3665
|
+
t,
|
|
3666
|
+
mode: state.mode,
|
|
3667
|
+
query,
|
|
3668
|
+
searchOpen,
|
|
3669
|
+
count,
|
|
3670
|
+
onSearchToggle: toggleSearch,
|
|
3671
|
+
onQuery: setQuery,
|
|
3672
|
+
onViewMenu: openViewMenu,
|
|
3673
|
+
onAddMenu: (event) => openAddMenu(event, null),
|
|
3674
|
+
}),
|
|
3675
|
+
h(
|
|
3676
|
+
'div',
|
|
3677
|
+
{ className: 'orca-scroll' },
|
|
3678
|
+
query.trim()
|
|
3679
|
+
? h(SearchView, {
|
|
3680
|
+
view,
|
|
3681
|
+
t,
|
|
3682
|
+
actions,
|
|
3683
|
+
currentId: currentForView,
|
|
3684
|
+
archivedSet,
|
|
3685
|
+
query,
|
|
3686
|
+
onClear: () => {
|
|
3687
|
+
setQuery('')
|
|
3688
|
+
},
|
|
3689
|
+
})
|
|
3690
|
+
: state.mode === 'orca'
|
|
3691
|
+
? h(OrcaView, {
|
|
3692
|
+
view,
|
|
3693
|
+
state,
|
|
3694
|
+
t,
|
|
3695
|
+
actions,
|
|
3696
|
+
currentProjectKey,
|
|
3697
|
+
currentId: currentForView,
|
|
3698
|
+
pinnedSet,
|
|
3699
|
+
archivedSet,
|
|
3700
|
+
drag,
|
|
3701
|
+
})
|
|
3702
|
+
: state.mode === 'workspace'
|
|
3703
|
+
? h(WorkspaceView, {
|
|
3704
|
+
view,
|
|
3705
|
+
state,
|
|
3706
|
+
t,
|
|
3707
|
+
actions,
|
|
3708
|
+
currentProjectKey,
|
|
3709
|
+
currentId: currentForView,
|
|
3710
|
+
pinnedSet,
|
|
3711
|
+
archivedSet,
|
|
3712
|
+
})
|
|
3713
|
+
: state.mode === 'workspace-tree'
|
|
3714
|
+
? h(TreeView, {
|
|
3715
|
+
view,
|
|
3716
|
+
state,
|
|
3717
|
+
t,
|
|
3718
|
+
actions,
|
|
3719
|
+
currentId: currentForView,
|
|
3720
|
+
pinnedSet,
|
|
3721
|
+
archivedSet,
|
|
3722
|
+
})
|
|
3723
|
+
: h(FlatView, {
|
|
3724
|
+
view,
|
|
3725
|
+
t,
|
|
3726
|
+
actions,
|
|
3727
|
+
currentId: currentForView,
|
|
3728
|
+
archivedSet,
|
|
3729
|
+
}),
|
|
3730
|
+
),
|
|
3731
|
+
menu ? h(MenuLayer, { key: menu.key, menu, onClose: closeMenu }) : null,
|
|
3732
|
+
dialog
|
|
3733
|
+
? h(DialogLayer, {
|
|
3734
|
+
key: dialog.key,
|
|
3735
|
+
dialog,
|
|
3736
|
+
t,
|
|
3737
|
+
onCancel: closeDialog,
|
|
3738
|
+
onConfirm: confirmDialog,
|
|
3739
|
+
})
|
|
3740
|
+
: null,
|
|
3741
|
+
toast ? h(ToastLayer, { toast }) : null,
|
|
3742
|
+
)
|
|
3743
|
+
|
|
3744
|
+
return h(
|
|
3745
|
+
SessionStatusContext.Provider,
|
|
3746
|
+
{ value: statusMap },
|
|
3747
|
+
h(WorkspacePathContext.Provider, { value: view.workspaceBySession }, content),
|
|
3748
|
+
)
|
|
3749
|
+
}
|
|
3750
|
+
|
|
3751
|
+
const ORCA_CSS = `
|
|
3752
|
+
.orca-root,
|
|
3753
|
+
.orca-root *,
|
|
3754
|
+
.orca-root *::before,
|
|
3755
|
+
.orca-root *::after {
|
|
3756
|
+
box-sizing: border-box;
|
|
3757
|
+
}
|
|
3758
|
+
.orca-root {
|
|
3759
|
+
--orca-hover: color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);
|
|
3760
|
+
--orca-row: color-mix(in srgb, var(--dsw-alias-label-primary) 3%, transparent);
|
|
3761
|
+
--orca-row-border: color-mix(in srgb, var(--dsw-alias-label-primary) 8%, transparent);
|
|
3762
|
+
display: flex;
|
|
3763
|
+
flex-direction: column;
|
|
3764
|
+
min-width: 0;
|
|
3765
|
+
min-height: 0;
|
|
3766
|
+
height: 100%;
|
|
3767
|
+
color: var(--dsw-alias-label-primary);
|
|
3768
|
+
font-size: 14px;
|
|
3769
|
+
line-height: 1.4;
|
|
3770
|
+
-webkit-font-smoothing: antialiased;
|
|
3771
|
+
}
|
|
3772
|
+
.orca-header {
|
|
3773
|
+
flex: none;
|
|
3774
|
+
padding: 2px 3px 4px;
|
|
3775
|
+
}
|
|
3776
|
+
.orca-title-row {
|
|
3777
|
+
display: flex;
|
|
3778
|
+
align-items: center;
|
|
3779
|
+
gap: 6px;
|
|
3780
|
+
height: 30px;
|
|
3781
|
+
min-width: 0;
|
|
3782
|
+
}
|
|
3783
|
+
.orca-title {
|
|
3784
|
+
margin-left: 6px;
|
|
3785
|
+
color: var(--dsw-alias-label-secondary);
|
|
3786
|
+
font-size: 11px;
|
|
3787
|
+
font-weight: 600;
|
|
3788
|
+
letter-spacing: 0.08em;
|
|
3789
|
+
text-transform: uppercase;
|
|
3790
|
+
white-space: nowrap;
|
|
3791
|
+
}
|
|
3792
|
+
.orca-head-actions {
|
|
3793
|
+
display: flex;
|
|
3794
|
+
align-items: center;
|
|
3795
|
+
gap: 1px;
|
|
3796
|
+
margin-left: auto;
|
|
3797
|
+
}
|
|
3798
|
+
.orca-icon-button {
|
|
3799
|
+
display: inline-flex;
|
|
3800
|
+
align-items: center;
|
|
3801
|
+
justify-content: center;
|
|
3802
|
+
width: 26px;
|
|
3803
|
+
height: 26px;
|
|
3804
|
+
padding: 0;
|
|
3805
|
+
border: 0;
|
|
3806
|
+
border-radius: var(--dsw-radius-sm, 6px);
|
|
3807
|
+
background: transparent;
|
|
3808
|
+
color: var(--dsw-alias-label-secondary);
|
|
3809
|
+
cursor: pointer;
|
|
3810
|
+
flex: none;
|
|
3811
|
+
transition: background-color 120ms ease, color 120ms ease, transform 120ms ease;
|
|
3812
|
+
}
|
|
3813
|
+
.orca-icon-button:hover {
|
|
3814
|
+
background: var(--orca-hover);
|
|
3815
|
+
color: var(--dsw-alias-label-primary);
|
|
3816
|
+
}
|
|
3817
|
+
.orca-icon-button:active {
|
|
3818
|
+
transform: scale(0.92);
|
|
3819
|
+
}
|
|
3820
|
+
.orca-icon-button.is-active {
|
|
3821
|
+
color: var(--dsw-alias-brand-primary);
|
|
3822
|
+
background: color-mix(in srgb, var(--dsw-alias-brand-primary) 11%, transparent);
|
|
3823
|
+
}
|
|
3824
|
+
.orca-icon-button.is-danger {
|
|
3825
|
+
color: var(--dsw-alias-state-error-primary);
|
|
3826
|
+
}
|
|
3827
|
+
.orca-icon-button:disabled {
|
|
3828
|
+
opacity: 0.35;
|
|
3829
|
+
cursor: default;
|
|
3830
|
+
}
|
|
3831
|
+
.orca-icon-button:focus-visible,
|
|
3832
|
+
.orca-project-head:focus-visible,
|
|
3833
|
+
.orca-group-head:focus-visible,
|
|
3834
|
+
.orca-loose-workspace-head:focus-visible,
|
|
3835
|
+
.orca-session-main:focus-visible,
|
|
3836
|
+
.orca-text-button:focus-visible,
|
|
3837
|
+
.orca-show-more:focus-visible,
|
|
3838
|
+
.orca-menu-item:focus-visible,
|
|
3839
|
+
.orca-button:focus-visible {
|
|
3840
|
+
outline: 2px solid color-mix(in srgb, var(--dsw-alias-brand-primary) 75%, transparent);
|
|
3841
|
+
outline-offset: -2px;
|
|
3842
|
+
}
|
|
3843
|
+
.orca-search-field {
|
|
3844
|
+
display: flex;
|
|
3845
|
+
align-items: center;
|
|
3846
|
+
gap: 6px;
|
|
3847
|
+
height: 32px;
|
|
3848
|
+
margin: 3px 0 6px;
|
|
3849
|
+
padding: 0 4px 0 9px;
|
|
3850
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
3851
|
+
border-radius: var(--dsw-radius-sm, 6px);
|
|
3852
|
+
background: color-mix(in srgb, var(--dsw-alias-bg-base) 45%, transparent);
|
|
3853
|
+
}
|
|
3854
|
+
.orca-search-field:focus-within {
|
|
3855
|
+
border-color: color-mix(in srgb, var(--dsw-alias-brand-primary) 65%, transparent);
|
|
3856
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--dsw-alias-brand-primary) 9%, transparent);
|
|
3857
|
+
background: var(--dsw-alias-bg-base);
|
|
3858
|
+
}
|
|
3859
|
+
.orca-search-icon {
|
|
3860
|
+
flex: none;
|
|
3861
|
+
color: var(--dsw-alias-label-secondary);
|
|
3862
|
+
}
|
|
3863
|
+
.orca-search-field input {
|
|
3864
|
+
flex: 1;
|
|
3865
|
+
min-width: 0;
|
|
3866
|
+
height: 100%;
|
|
3867
|
+
padding: 0;
|
|
3868
|
+
border: 0;
|
|
3869
|
+
outline: 0;
|
|
3870
|
+
background: transparent;
|
|
3871
|
+
color: var(--dsw-alias-label-primary);
|
|
3872
|
+
font: inherit;
|
|
3873
|
+
font-size: 13px;
|
|
3874
|
+
}
|
|
3875
|
+
.orca-search-field input::placeholder {
|
|
3876
|
+
color: var(--dsw-alias-label-secondary);
|
|
3877
|
+
}
|
|
3878
|
+
.orca-scroll {
|
|
3879
|
+
flex: 1;
|
|
3880
|
+
min-height: 0;
|
|
3881
|
+
overflow-x: hidden;
|
|
3882
|
+
overflow-y: auto;
|
|
3883
|
+
padding: 2px 6px 18px;
|
|
3884
|
+
scrollbar-width: thin;
|
|
3885
|
+
scrollbar-color: var(--dsw-alias-scrollbar-bg-l2, transparent) transparent;
|
|
3886
|
+
}
|
|
3887
|
+
.orca-view {
|
|
3888
|
+
display: flex;
|
|
3889
|
+
flex-direction: column;
|
|
3890
|
+
gap: 2px;
|
|
3891
|
+
}
|
|
3892
|
+
.orca-view.orca-flat,
|
|
3893
|
+
.orca-view.orca-search {
|
|
3894
|
+
gap: 0;
|
|
3895
|
+
padding: 4px 5px;
|
|
3896
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
3897
|
+
border-radius: 10px;
|
|
3898
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
3899
|
+
}
|
|
3900
|
+
.orca-count {
|
|
3901
|
+
display: inline-flex;
|
|
3902
|
+
align-items: center;
|
|
3903
|
+
justify-content: center;
|
|
3904
|
+
min-width: 18px;
|
|
3905
|
+
height: 17px;
|
|
3906
|
+
padding: 0 5px;
|
|
3907
|
+
border-radius: 5px;
|
|
3908
|
+
background: color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);
|
|
3909
|
+
color: var(--dsw-alias-label-secondary);
|
|
3910
|
+
font-size: 10px;
|
|
3911
|
+
font-weight: 500;
|
|
3912
|
+
font-variant-numeric: tabular-nums;
|
|
3913
|
+
line-height: 1;
|
|
3914
|
+
flex: none;
|
|
3915
|
+
}
|
|
3916
|
+
.orca-project-worktrees {
|
|
3917
|
+
display: inline-flex;
|
|
3918
|
+
align-items: center;
|
|
3919
|
+
gap: 2px;
|
|
3920
|
+
flex: none;
|
|
3921
|
+
height: 16px;
|
|
3922
|
+
padding: 0 4px;
|
|
3923
|
+
border: 1px solid color-mix(in srgb, var(--dsw-alias-brand-primary) 24%, transparent);
|
|
3924
|
+
border-radius: 999px;
|
|
3925
|
+
background: color-mix(in srgb, var(--dsw-alias-brand-primary) 7%, transparent);
|
|
3926
|
+
color: var(--dsw-alias-brand-primary);
|
|
3927
|
+
font-size: 10px;
|
|
3928
|
+
font-weight: 500;
|
|
3929
|
+
line-height: 1;
|
|
3930
|
+
}
|
|
3931
|
+
.orca-chevron {
|
|
3932
|
+
display: inline-flex;
|
|
3933
|
+
align-items: center;
|
|
3934
|
+
justify-content: center;
|
|
3935
|
+
width: 13px;
|
|
3936
|
+
height: 13px;
|
|
3937
|
+
color: var(--dsw-alias-label-secondary);
|
|
3938
|
+
transform: rotate(0deg);
|
|
3939
|
+
transition: transform 120ms ease;
|
|
3940
|
+
flex: none;
|
|
3941
|
+
}
|
|
3942
|
+
.orca-chevron.is-open {
|
|
3943
|
+
transform: rotate(90deg);
|
|
3944
|
+
}
|
|
3945
|
+
.orca-pinned-group {
|
|
3946
|
+
margin: 0 0 11px;
|
|
3947
|
+
overflow: hidden;
|
|
3948
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
3949
|
+
border-radius: 11px;
|
|
3950
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
3951
|
+
box-shadow: 0 2px 7px color-mix(in srgb, var(--dsw-alias-label-primary) 3%, transparent);
|
|
3952
|
+
}
|
|
3953
|
+
.orca-pinned-group .orca-pinned-head {
|
|
3954
|
+
height: 33px;
|
|
3955
|
+
padding: 0 9px;
|
|
3956
|
+
border: 0;
|
|
3957
|
+
border-radius: 0;
|
|
3958
|
+
background: color-mix(in srgb, var(--dsw-alias-label-primary) 2%, transparent);
|
|
3959
|
+
}
|
|
3960
|
+
.orca-pinned-group:not(.is-collapsed) .orca-pinned-head {
|
|
3961
|
+
border-bottom: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);
|
|
3962
|
+
}
|
|
3963
|
+
.orca-pinned-icon {
|
|
3964
|
+
color: var(--dsw-alias-label-secondary);
|
|
3965
|
+
}
|
|
3966
|
+
.orca-pinned-body {
|
|
3967
|
+
display: flex;
|
|
3968
|
+
flex-direction: column;
|
|
3969
|
+
gap: 0;
|
|
3970
|
+
max-height: min(282px, 36vh);
|
|
3971
|
+
padding: 0 5px 4px;
|
|
3972
|
+
overflow-y: auto;
|
|
3973
|
+
overscroll-behavior: contain;
|
|
3974
|
+
scrollbar-width: thin;
|
|
3975
|
+
scrollbar-color: var(--dsw-alias-scrollbar-bg-l2, transparent) transparent;
|
|
3976
|
+
}
|
|
3977
|
+
.orca-group {
|
|
3978
|
+
border-radius: 8px;
|
|
3979
|
+
}
|
|
3980
|
+
.orca-group + .orca-group {
|
|
3981
|
+
margin-top: 7px;
|
|
3982
|
+
}
|
|
3983
|
+
.orca-group--loose {
|
|
3984
|
+
margin-top: 10px;
|
|
3985
|
+
padding-top: 7px;
|
|
3986
|
+
border-top: 1px solid var(--dsw-alias-border-l1);
|
|
3987
|
+
}
|
|
3988
|
+
.orca-loose-workspace {
|
|
3989
|
+
display: flex;
|
|
3990
|
+
flex-direction: column;
|
|
3991
|
+
gap: 1px;
|
|
3992
|
+
}
|
|
3993
|
+
.orca-loose-workspace + .orca-loose-workspace {
|
|
3994
|
+
margin-top: 2px;
|
|
3995
|
+
}
|
|
3996
|
+
.orca-loose-workspace-head {
|
|
3997
|
+
display: flex;
|
|
3998
|
+
align-items: center;
|
|
3999
|
+
gap: 5px;
|
|
4000
|
+
min-height: 28px;
|
|
4001
|
+
padding: 0 7px 0 9px;
|
|
4002
|
+
border-radius: 6px;
|
|
4003
|
+
color: var(--dsw-alias-label-secondary);
|
|
4004
|
+
font-size: 12px;
|
|
4005
|
+
font-weight: 500;
|
|
4006
|
+
cursor: pointer;
|
|
4007
|
+
user-select: none;
|
|
4008
|
+
transition: background-color 120ms ease, color 120ms ease;
|
|
4009
|
+
}
|
|
4010
|
+
.orca-loose-workspace-head:hover {
|
|
4011
|
+
background: var(--orca-hover);
|
|
4012
|
+
color: var(--dsw-alias-label-primary);
|
|
4013
|
+
}
|
|
4014
|
+
.orca-loose-workspace-icon {
|
|
4015
|
+
flex: none;
|
|
4016
|
+
opacity: 0.85;
|
|
4017
|
+
}
|
|
4018
|
+
.orca-loose-workspace-title {
|
|
4019
|
+
flex: 1;
|
|
4020
|
+
min-width: 0;
|
|
4021
|
+
overflow: hidden;
|
|
4022
|
+
text-overflow: ellipsis;
|
|
4023
|
+
white-space: nowrap;
|
|
4024
|
+
}
|
|
4025
|
+
.orca-loose-workspace-body {
|
|
4026
|
+
display: flex;
|
|
4027
|
+
flex-direction: column;
|
|
4028
|
+
gap: 0;
|
|
4029
|
+
margin: 2px 0 6px 8px;
|
|
4030
|
+
padding: 0 5px 4px;
|
|
4031
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
4032
|
+
border-radius: 8px;
|
|
4033
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
4034
|
+
}
|
|
4035
|
+
.orca-group-row {
|
|
4036
|
+
position: relative;
|
|
4037
|
+
}
|
|
4038
|
+
.orca-group-head {
|
|
4039
|
+
display: flex;
|
|
4040
|
+
align-items: center;
|
|
4041
|
+
gap: 6px;
|
|
4042
|
+
height: 31px;
|
|
4043
|
+
min-width: 0;
|
|
4044
|
+
padding: 0 8px;
|
|
4045
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
4046
|
+
border-radius: 7px;
|
|
4047
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
4048
|
+
box-shadow: 0 1px 2px color-mix(in srgb, var(--dsw-alias-label-primary) 2%, transparent);
|
|
4049
|
+
color: var(--dsw-alias-label-secondary);
|
|
4050
|
+
font-size: 12px;
|
|
4051
|
+
font-weight: 500;
|
|
4052
|
+
letter-spacing: 0.01em;
|
|
4053
|
+
cursor: pointer;
|
|
4054
|
+
user-select: none;
|
|
4055
|
+
transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
|
|
4056
|
+
}
|
|
4057
|
+
.orca-group-head:hover {
|
|
4058
|
+
border-color: var(--dsw-alias-border-l2);
|
|
4059
|
+
background: color-mix(in srgb, var(--dsw-alias-bg-layer-1) 92%, var(--orca-hover));
|
|
4060
|
+
color: var(--dsw-alias-label-primary);
|
|
4061
|
+
}
|
|
4062
|
+
.orca-group-icon {
|
|
4063
|
+
flex: none;
|
|
4064
|
+
opacity: 0.85;
|
|
4065
|
+
}
|
|
4066
|
+
.orca-group-title {
|
|
4067
|
+
flex: 1;
|
|
4068
|
+
min-width: 0;
|
|
4069
|
+
overflow: hidden;
|
|
4070
|
+
text-overflow: ellipsis;
|
|
4071
|
+
white-space: nowrap;
|
|
4072
|
+
}
|
|
4073
|
+
.orca-group-actions {
|
|
4074
|
+
position: absolute;
|
|
4075
|
+
top: 3px;
|
|
4076
|
+
right: 4px;
|
|
4077
|
+
display: none;
|
|
4078
|
+
align-items: center;
|
|
4079
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
4080
|
+
box-shadow: 0 1px 5px color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent);
|
|
4081
|
+
border-radius: var(--dsw-radius-sm, 6px);
|
|
4082
|
+
}
|
|
4083
|
+
.orca-group-row:hover .orca-group-actions,
|
|
4084
|
+
.orca-group-row:focus-within .orca-group-actions {
|
|
4085
|
+
display: flex;
|
|
4086
|
+
}
|
|
4087
|
+
.orca-group-body {
|
|
4088
|
+
display: flex;
|
|
4089
|
+
flex-direction: column;
|
|
4090
|
+
gap: 0;
|
|
4091
|
+
margin: 4px 0 0 8px;
|
|
4092
|
+
padding: 0 0 3px 5px;
|
|
4093
|
+
border-left: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 7%, transparent);
|
|
4094
|
+
}
|
|
4095
|
+
.orca-group--ungrouped {
|
|
4096
|
+
margin-top: 7px;
|
|
4097
|
+
}
|
|
4098
|
+
.orca-group--ungrouped .orca-group-head {
|
|
4099
|
+
height: 31px;
|
|
4100
|
+
padding-top: 0;
|
|
4101
|
+
}
|
|
4102
|
+
.orca-group--ungrouped .orca-group-head:hover {
|
|
4103
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
4104
|
+
}
|
|
4105
|
+
.orca-project {
|
|
4106
|
+
display: flex;
|
|
4107
|
+
flex-direction: column;
|
|
4108
|
+
gap: 0;
|
|
4109
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
4110
|
+
border-radius: 8px;
|
|
4111
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
4112
|
+
box-shadow: 0 1px 2px color-mix(in srgb, var(--dsw-alias-label-primary) 2%, transparent);
|
|
4113
|
+
}
|
|
4114
|
+
.orca-project + .orca-project {
|
|
4115
|
+
margin-top: 4px;
|
|
4116
|
+
}
|
|
4117
|
+
.orca-project-row {
|
|
4118
|
+
position: relative;
|
|
4119
|
+
}
|
|
4120
|
+
.orca-project-head {
|
|
4121
|
+
display: flex;
|
|
4122
|
+
align-items: center;
|
|
4123
|
+
gap: 6px;
|
|
4124
|
+
height: 33px;
|
|
4125
|
+
padding: 0 7px 0 5px;
|
|
4126
|
+
border-radius: 7px 7px 0 0;
|
|
4127
|
+
color: var(--dsw-alias-label-primary);
|
|
4128
|
+
font-size: 14px;
|
|
4129
|
+
font-weight: 500;
|
|
4130
|
+
line-height: 20px;
|
|
4131
|
+
cursor: pointer;
|
|
4132
|
+
user-select: none;
|
|
4133
|
+
transition: background-color 120ms ease, color 120ms ease;
|
|
4134
|
+
}
|
|
4135
|
+
.orca-project-head[aria-expanded='false'] {
|
|
4136
|
+
border-radius: 7px;
|
|
4137
|
+
}
|
|
4138
|
+
.orca-project-head:hover {
|
|
4139
|
+
background: var(--orca-hover);
|
|
4140
|
+
}
|
|
4141
|
+
.orca-project.has-current > .orca-project-row .orca-project-head {
|
|
4142
|
+
background: color-mix(in srgb, var(--dsw-alias-brand-primary) 5%, transparent);
|
|
4143
|
+
}
|
|
4144
|
+
.orca-project.has-current > .orca-project-row .orca-project-title {
|
|
4145
|
+
color: var(--dsw-alias-brand-primary);
|
|
4146
|
+
font-weight: 600;
|
|
4147
|
+
}
|
|
4148
|
+
.orca-project-folder {
|
|
4149
|
+
flex: none;
|
|
4150
|
+
color: var(--dsw-alias-label-secondary);
|
|
4151
|
+
}
|
|
4152
|
+
.orca-project-title {
|
|
4153
|
+
flex: 1;
|
|
4154
|
+
min-width: 0;
|
|
4155
|
+
overflow: hidden;
|
|
4156
|
+
text-overflow: ellipsis;
|
|
4157
|
+
white-space: nowrap;
|
|
4158
|
+
}
|
|
4159
|
+
.orca-project-actions {
|
|
4160
|
+
position: absolute;
|
|
4161
|
+
top: 3px;
|
|
4162
|
+
right: 4px;
|
|
4163
|
+
display: none;
|
|
4164
|
+
align-items: center;
|
|
4165
|
+
gap: 1px;
|
|
4166
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
4167
|
+
box-shadow: 0 1px 5px color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent);
|
|
4168
|
+
border-radius: var(--dsw-radius-sm, 6px);
|
|
4169
|
+
}
|
|
4170
|
+
.orca-project-row:hover .orca-project-actions,
|
|
4171
|
+
.orca-project-row:focus-within .orca-project-actions {
|
|
4172
|
+
display: flex;
|
|
4173
|
+
}
|
|
4174
|
+
.orca-project-body {
|
|
4175
|
+
display: flex;
|
|
4176
|
+
flex-direction: column;
|
|
4177
|
+
gap: 0;
|
|
4178
|
+
padding: 0 5px 4px;
|
|
4179
|
+
border-top: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);
|
|
4180
|
+
}
|
|
4181
|
+
.orca-project-body.is-guided {
|
|
4182
|
+
margin-left: 0;
|
|
4183
|
+
padding: 0 5px 4px;
|
|
4184
|
+
border-left: 0;
|
|
4185
|
+
}
|
|
4186
|
+
.orca-session {
|
|
4187
|
+
position: relative;
|
|
4188
|
+
display: flex;
|
|
4189
|
+
align-items: stretch;
|
|
4190
|
+
min-width: 0;
|
|
4191
|
+
min-height: 33px;
|
|
4192
|
+
margin: 0;
|
|
4193
|
+
border: 0;
|
|
4194
|
+
border-bottom: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);
|
|
4195
|
+
border-radius: 0;
|
|
4196
|
+
background: transparent;
|
|
4197
|
+
transition: background-color 120ms ease, box-shadow 120ms ease;
|
|
4198
|
+
}
|
|
4199
|
+
.orca-session.has-meta {
|
|
4200
|
+
min-height: 43px;
|
|
4201
|
+
background: transparent;
|
|
4202
|
+
}
|
|
4203
|
+
.orca-pinned-body > .orca-session:last-child,
|
|
4204
|
+
.orca-project-body > .orca-session:last-child,
|
|
4205
|
+
.orca-loose-workspace-body > .orca-session:last-child,
|
|
4206
|
+
.orca-flat > .orca-session:last-child,
|
|
4207
|
+
.orca-search > .orca-session:last-child {
|
|
4208
|
+
border-bottom-color: transparent;
|
|
4209
|
+
}
|
|
4210
|
+
.orca-session:hover {
|
|
4211
|
+
background: var(--orca-hover);
|
|
4212
|
+
}
|
|
4213
|
+
.orca-session.is-current {
|
|
4214
|
+
border-bottom-color: transparent;
|
|
4215
|
+
border-radius: 6px;
|
|
4216
|
+
background: color-mix(in srgb, var(--dsw-alias-brand-primary) 9%, transparent);
|
|
4217
|
+
box-shadow: inset 2px 0 0 var(--dsw-alias-brand-primary);
|
|
4218
|
+
}
|
|
4219
|
+
.orca-session-main {
|
|
4220
|
+
display: flex;
|
|
4221
|
+
flex-direction: column;
|
|
4222
|
+
justify-content: center;
|
|
4223
|
+
gap: 1px;
|
|
4224
|
+
min-width: 0;
|
|
4225
|
+
width: 100%;
|
|
4226
|
+
padding: 3px 8px;
|
|
4227
|
+
border-radius: 5px;
|
|
4228
|
+
color: var(--dsw-alias-label-primary);
|
|
4229
|
+
font-size: 14px;
|
|
4230
|
+
line-height: 18px;
|
|
4231
|
+
cursor: pointer;
|
|
4232
|
+
user-select: none;
|
|
4233
|
+
}
|
|
4234
|
+
.orca-session-line {
|
|
4235
|
+
display: flex;
|
|
4236
|
+
align-items: center;
|
|
4237
|
+
gap: 6px;
|
|
4238
|
+
min-width: 0;
|
|
4239
|
+
}
|
|
4240
|
+
.orca-session-subline {
|
|
4241
|
+
display: flex;
|
|
4242
|
+
align-items: center;
|
|
4243
|
+
gap: 4px;
|
|
4244
|
+
min-width: 0;
|
|
4245
|
+
padding-left: 15px;
|
|
4246
|
+
overflow: hidden;
|
|
4247
|
+
}
|
|
4248
|
+
.orca-session-subline:empty {
|
|
4249
|
+
display: none;
|
|
4250
|
+
}
|
|
4251
|
+
.orca-session-title {
|
|
4252
|
+
flex: 1;
|
|
4253
|
+
min-width: 0;
|
|
4254
|
+
overflow: hidden;
|
|
4255
|
+
text-overflow: ellipsis;
|
|
4256
|
+
white-space: nowrap;
|
|
4257
|
+
}
|
|
4258
|
+
.orca-session-pin {
|
|
4259
|
+
flex: none;
|
|
4260
|
+
color: var(--dsw-alias-brand-primary);
|
|
4261
|
+
}
|
|
4262
|
+
.orca-session-project {
|
|
4263
|
+
display: inline-flex;
|
|
4264
|
+
align-items: center;
|
|
4265
|
+
gap: 3px;
|
|
4266
|
+
flex: 0 1 auto;
|
|
4267
|
+
min-width: 0;
|
|
4268
|
+
max-width: 52%;
|
|
4269
|
+
height: 16px;
|
|
4270
|
+
padding: 0 5px;
|
|
4271
|
+
border: 0;
|
|
4272
|
+
border-radius: 4px;
|
|
4273
|
+
overflow: hidden;
|
|
4274
|
+
color: var(--dsw-alias-label-secondary);
|
|
4275
|
+
background: color-mix(in srgb, var(--dsw-alias-label-primary) 5%, transparent);
|
|
4276
|
+
font-size: 10.5px;
|
|
4277
|
+
line-height: 16px;
|
|
4278
|
+
}
|
|
4279
|
+
.orca-session-project-icon {
|
|
4280
|
+
flex: none;
|
|
4281
|
+
}
|
|
4282
|
+
.orca-session-meta {
|
|
4283
|
+
min-width: 0;
|
|
4284
|
+
overflow: hidden;
|
|
4285
|
+
text-overflow: ellipsis;
|
|
4286
|
+
white-space: nowrap;
|
|
4287
|
+
color: inherit;
|
|
4288
|
+
font-size: 10.5px;
|
|
4289
|
+
}
|
|
4290
|
+
.orca-worktree {
|
|
4291
|
+
display: inline-flex;
|
|
4292
|
+
align-items: center;
|
|
4293
|
+
flex: 0 1 auto;
|
|
4294
|
+
min-width: 0;
|
|
4295
|
+
max-width: 108px;
|
|
4296
|
+
height: 16px;
|
|
4297
|
+
padding: 0 5px;
|
|
4298
|
+
border: 0;
|
|
4299
|
+
border-radius: 4px;
|
|
4300
|
+
overflow: hidden;
|
|
4301
|
+
white-space: nowrap;
|
|
4302
|
+
color: var(--dsw-alias-label-secondary);
|
|
4303
|
+
background: color-mix(in srgb, var(--dsw-alias-label-primary) 5%, transparent);
|
|
4304
|
+
font-size: 10.5px;
|
|
4305
|
+
line-height: 16px;
|
|
4306
|
+
}
|
|
4307
|
+
.orca-worktree-label {
|
|
4308
|
+
min-width: 0;
|
|
4309
|
+
overflow: hidden;
|
|
4310
|
+
text-overflow: ellipsis;
|
|
4311
|
+
white-space: nowrap;
|
|
4312
|
+
}
|
|
4313
|
+
.orca-worktree.is-main {
|
|
4314
|
+
color: var(--dsw-alias-label-secondary);
|
|
4315
|
+
}
|
|
4316
|
+
.orca-worktree:not(.is-main) {
|
|
4317
|
+
color: var(--dsw-alias-brand-primary);
|
|
4318
|
+
background: color-mix(in srgb, var(--dsw-alias-brand-primary) 8%, transparent);
|
|
4319
|
+
}
|
|
4320
|
+
.orca-session-hint {
|
|
4321
|
+
display: inline-flex;
|
|
4322
|
+
align-items: center;
|
|
4323
|
+
gap: 2px;
|
|
4324
|
+
flex: none;
|
|
4325
|
+
height: 16px;
|
|
4326
|
+
padding: 0 4px;
|
|
4327
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
4328
|
+
border-radius: 999px;
|
|
4329
|
+
color: var(--dsw-alias-label-secondary);
|
|
4330
|
+
font-size: 10px;
|
|
4331
|
+
line-height: 1;
|
|
4332
|
+
}
|
|
4333
|
+
.orca-session-hint.is-archived {
|
|
4334
|
+
color: var(--dsw-alias-state-warn-primary);
|
|
4335
|
+
border-color: color-mix(in srgb, var(--dsw-alias-state-warn-primary) 35%, transparent);
|
|
4336
|
+
}
|
|
4337
|
+
.orca-session.is-pinned-ref:not(.is-current) {
|
|
4338
|
+
background: transparent;
|
|
4339
|
+
}
|
|
4340
|
+
.orca-session.is-pinned-ref .orca-session-title,
|
|
4341
|
+
.orca-session.is-pinned-ref .orca-session-subline,
|
|
4342
|
+
.orca-session.is-archived .orca-session-title,
|
|
4343
|
+
.orca-session.is-archived .orca-session-subline {
|
|
4344
|
+
opacity: 0.55;
|
|
4345
|
+
}
|
|
4346
|
+
.orca-session.is-pinned-ref:hover .orca-session-title,
|
|
4347
|
+
.orca-session.is-pinned-ref:focus-within .orca-session-title,
|
|
4348
|
+
.orca-session.is-pinned-ref:hover .orca-session-subline,
|
|
4349
|
+
.orca-session.is-pinned-ref:focus-within .orca-session-subline {
|
|
4350
|
+
opacity: 0.8;
|
|
4351
|
+
}
|
|
4352
|
+
.orca-session-actions {
|
|
4353
|
+
position: absolute;
|
|
4354
|
+
top: 5px;
|
|
4355
|
+
right: 4px;
|
|
4356
|
+
display: none;
|
|
4357
|
+
align-items: center;
|
|
4358
|
+
gap: 1px;
|
|
4359
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
4360
|
+
box-shadow: 0 1px 5px color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent);
|
|
4361
|
+
border-radius: var(--dsw-radius-sm, 6px);
|
|
4362
|
+
}
|
|
4363
|
+
.orca-project-actions .orca-icon-button,
|
|
4364
|
+
.orca-session-actions .orca-icon-button,
|
|
4365
|
+
.orca-group-actions .orca-icon-button {
|
|
4366
|
+
width: 24px;
|
|
4367
|
+
height: 24px;
|
|
4368
|
+
}
|
|
4369
|
+
.orca-session:hover .orca-session-actions,
|
|
4370
|
+
.orca-session:focus-within .orca-session-actions {
|
|
4371
|
+
display: flex;
|
|
4372
|
+
}
|
|
4373
|
+
.orca-status-dot {
|
|
4374
|
+
width: 7px;
|
|
4375
|
+
height: 7px;
|
|
4376
|
+
margin: 2.5px;
|
|
4377
|
+
border-radius: 50%;
|
|
4378
|
+
background: var(--dsw-alias-state-idle-primary);
|
|
4379
|
+
opacity: 0.42;
|
|
4380
|
+
flex: none;
|
|
4381
|
+
}
|
|
4382
|
+
.orca-status-dot.is-completed {
|
|
4383
|
+
background: var(--dsw-alias-state-success-primary);
|
|
4384
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--dsw-alias-state-success-primary) 16%, transparent);
|
|
4385
|
+
opacity: 1;
|
|
4386
|
+
}
|
|
4387
|
+
.orca-status-dot.is-pending {
|
|
4388
|
+
background: var(--dsw-alias-state-warn-primary);
|
|
4389
|
+
opacity: 1;
|
|
4390
|
+
}
|
|
4391
|
+
.orca-status-dot.is-archived {
|
|
4392
|
+
background: var(--dsw-alias-state-idle-primary);
|
|
4393
|
+
opacity: 0.35;
|
|
4394
|
+
}
|
|
4395
|
+
.orca-spinner {
|
|
4396
|
+
width: 12px;
|
|
4397
|
+
height: 12px;
|
|
4398
|
+
border: 2px solid color-mix(in srgb, var(--dsw-alias-state-warn-primary) 22%, transparent);
|
|
4399
|
+
border-top-color: var(--dsw-alias-state-warn-primary);
|
|
4400
|
+
border-radius: 50%;
|
|
4401
|
+
animation: orca-spin 0.85s linear infinite;
|
|
4402
|
+
flex: none;
|
|
4403
|
+
}
|
|
4404
|
+
@keyframes orca-spin {
|
|
4405
|
+
to { transform: rotate(360deg); }
|
|
4406
|
+
}
|
|
4407
|
+
.orca-empty-inline {
|
|
4408
|
+
padding: 8px 12px;
|
|
4409
|
+
color: var(--dsw-alias-label-secondary);
|
|
4410
|
+
font-size: 12px;
|
|
4411
|
+
line-height: 1.5;
|
|
4412
|
+
}
|
|
4413
|
+
.orca-show-more {
|
|
4414
|
+
align-self: flex-start;
|
|
4415
|
+
margin: 1px 0 3px;
|
|
4416
|
+
padding-top: 3px;
|
|
4417
|
+
padding-right: 8px;
|
|
4418
|
+
padding-bottom: 3px;
|
|
4419
|
+
border: 0;
|
|
4420
|
+
border-radius: var(--dsw-radius-sm, 6px);
|
|
4421
|
+
background: transparent;
|
|
4422
|
+
color: var(--dsw-alias-label-secondary);
|
|
4423
|
+
font: inherit;
|
|
4424
|
+
font-size: 12px;
|
|
4425
|
+
text-align: left;
|
|
4426
|
+
cursor: pointer;
|
|
4427
|
+
}
|
|
4428
|
+
.orca-show-more:hover {
|
|
4429
|
+
color: var(--dsw-alias-label-primary);
|
|
4430
|
+
background: color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);
|
|
4431
|
+
}
|
|
4432
|
+
.orca-empty {
|
|
4433
|
+
display: flex;
|
|
4434
|
+
flex-direction: column;
|
|
4435
|
+
align-items: center;
|
|
4436
|
+
gap: 6px;
|
|
4437
|
+
padding: 28px 12px;
|
|
4438
|
+
text-align: center;
|
|
4439
|
+
color: var(--dsw-alias-label-secondary);
|
|
4440
|
+
}
|
|
4441
|
+
.orca-empty-glyph {
|
|
4442
|
+
display: flex;
|
|
4443
|
+
align-items: center;
|
|
4444
|
+
justify-content: center;
|
|
4445
|
+
width: 40px;
|
|
4446
|
+
height: 40px;
|
|
4447
|
+
margin-bottom: 2px;
|
|
4448
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
4449
|
+
border-radius: 50%;
|
|
4450
|
+
color: var(--dsw-alias-label-secondary);
|
|
4451
|
+
}
|
|
4452
|
+
.orca-empty-title {
|
|
4453
|
+
color: var(--dsw-alias-label-primary);
|
|
4454
|
+
font-size: 14px;
|
|
4455
|
+
font-weight: 500;
|
|
4456
|
+
}
|
|
4457
|
+
.orca-empty-hint {
|
|
4458
|
+
max-width: 190px;
|
|
4459
|
+
font-size: 12px;
|
|
4460
|
+
line-height: 1.5;
|
|
4461
|
+
}
|
|
4462
|
+
.orca-text-button {
|
|
4463
|
+
margin-top: 2px;
|
|
4464
|
+
padding: 5px 9px;
|
|
4465
|
+
border: 0;
|
|
4466
|
+
border-radius: var(--dsw-radius-sm, 6px);
|
|
4467
|
+
background: transparent;
|
|
4468
|
+
color: var(--dsw-alias-brand-primary);
|
|
4469
|
+
font: inherit;
|
|
4470
|
+
font-size: 13px;
|
|
4471
|
+
cursor: pointer;
|
|
4472
|
+
}
|
|
4473
|
+
.orca-text-button:hover {
|
|
4474
|
+
background: color-mix(in srgb, var(--dsw-alias-brand-primary) 9%, transparent);
|
|
4475
|
+
}
|
|
4476
|
+
.orca-menu {
|
|
4477
|
+
position: fixed;
|
|
4478
|
+
z-index: 95;
|
|
4479
|
+
max-height: 72vh;
|
|
4480
|
+
overflow-y: auto;
|
|
4481
|
+
padding: 4px;
|
|
4482
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
4483
|
+
border-radius: 10px;
|
|
4484
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
4485
|
+
box-shadow: 0 10px 30px color-mix(in srgb, var(--dsw-alias-label-primary) 18%, transparent);
|
|
4486
|
+
font-size: 13px;
|
|
4487
|
+
scrollbar-width: thin;
|
|
4488
|
+
}
|
|
4489
|
+
.orca-menu-section {
|
|
4490
|
+
padding: 8px 8px 4px;
|
|
4491
|
+
color: var(--dsw-alias-label-secondary);
|
|
4492
|
+
font-size: 11px;
|
|
4493
|
+
font-weight: 600;
|
|
4494
|
+
letter-spacing: 0.04em;
|
|
4495
|
+
text-transform: uppercase;
|
|
4496
|
+
}
|
|
4497
|
+
.orca-menu-item {
|
|
4498
|
+
display: flex;
|
|
4499
|
+
align-items: center;
|
|
4500
|
+
gap: 8px;
|
|
4501
|
+
width: 100%;
|
|
4502
|
+
height: 32px;
|
|
4503
|
+
padding: 0 8px;
|
|
4504
|
+
border: 0;
|
|
4505
|
+
border-radius: var(--dsw-radius-sm, 6px);
|
|
4506
|
+
background: transparent;
|
|
4507
|
+
color: var(--dsw-alias-label-primary);
|
|
4508
|
+
font: inherit;
|
|
4509
|
+
font-size: 13px;
|
|
4510
|
+
text-align: left;
|
|
4511
|
+
cursor: pointer;
|
|
4512
|
+
}
|
|
4513
|
+
.orca-menu-item:hover {
|
|
4514
|
+
background: color-mix(in srgb, var(--dsw-alias-label-primary) 7%, transparent);
|
|
4515
|
+
}
|
|
4516
|
+
.orca-menu-item.is-danger {
|
|
4517
|
+
color: var(--dsw-alias-state-error-primary);
|
|
4518
|
+
}
|
|
4519
|
+
.orca-menu-item.is-disabled {
|
|
4520
|
+
opacity: 0.4;
|
|
4521
|
+
cursor: default;
|
|
4522
|
+
}
|
|
4523
|
+
.orca-menu-icon {
|
|
4524
|
+
display: inline-flex;
|
|
4525
|
+
align-items: center;
|
|
4526
|
+
justify-content: center;
|
|
4527
|
+
width: 15px;
|
|
4528
|
+
flex: none;
|
|
4529
|
+
color: var(--dsw-alias-label-secondary);
|
|
4530
|
+
}
|
|
4531
|
+
.orca-menu-item.is-danger .orca-menu-icon {
|
|
4532
|
+
color: inherit;
|
|
4533
|
+
}
|
|
4534
|
+
.orca-menu-label {
|
|
4535
|
+
flex: 1;
|
|
4536
|
+
min-width: 0;
|
|
4537
|
+
overflow: hidden;
|
|
4538
|
+
text-overflow: ellipsis;
|
|
4539
|
+
white-space: nowrap;
|
|
4540
|
+
}
|
|
4541
|
+
.orca-menu-badge {
|
|
4542
|
+
flex: none;
|
|
4543
|
+
padding: 0 4px;
|
|
4544
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
4545
|
+
border-radius: 999px;
|
|
4546
|
+
color: var(--dsw-alias-label-secondary);
|
|
4547
|
+
font-size: 9px;
|
|
4548
|
+
line-height: 14px;
|
|
4549
|
+
text-transform: none;
|
|
4550
|
+
letter-spacing: 0;
|
|
4551
|
+
}
|
|
4552
|
+
.orca-menu-check {
|
|
4553
|
+
flex: none;
|
|
4554
|
+
color: var(--dsw-alias-brand-primary);
|
|
4555
|
+
}
|
|
4556
|
+
.orca-menu-divider {
|
|
4557
|
+
height: 1px;
|
|
4558
|
+
margin: 4px 2px;
|
|
4559
|
+
background: var(--dsw-alias-border-l1);
|
|
4560
|
+
}
|
|
4561
|
+
.orca-dialog-overlay {
|
|
4562
|
+
position: fixed;
|
|
4563
|
+
inset: 0;
|
|
4564
|
+
z-index: 100;
|
|
4565
|
+
display: flex;
|
|
4566
|
+
align-items: center;
|
|
4567
|
+
justify-content: center;
|
|
4568
|
+
padding: 20px;
|
|
4569
|
+
background: color-mix(in srgb, var(--dsw-alias-label-primary) 24%, transparent);
|
|
4570
|
+
}
|
|
4571
|
+
.orca-dialog {
|
|
4572
|
+
width: min(340px, calc(100vw - 32px));
|
|
4573
|
+
padding: 16px;
|
|
4574
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
4575
|
+
border-radius: 12px;
|
|
4576
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
4577
|
+
box-shadow: 0 14px 40px color-mix(in srgb, var(--dsw-alias-label-primary) 22%, transparent);
|
|
4578
|
+
}
|
|
4579
|
+
.orca-dialog-title {
|
|
4580
|
+
color: var(--dsw-alias-label-primary);
|
|
4581
|
+
font-size: 14px;
|
|
4582
|
+
font-weight: 600;
|
|
4583
|
+
line-height: 1.4;
|
|
4584
|
+
}
|
|
4585
|
+
.orca-dialog-description {
|
|
4586
|
+
margin-top: 8px;
|
|
4587
|
+
color: var(--dsw-alias-label-secondary);
|
|
4588
|
+
font-size: 13px;
|
|
4589
|
+
line-height: 1.55;
|
|
4590
|
+
}
|
|
4591
|
+
.orca-dialog-input {
|
|
4592
|
+
width: 100%;
|
|
4593
|
+
height: 34px;
|
|
4594
|
+
margin-top: 13px;
|
|
4595
|
+
padding: 0 9px;
|
|
4596
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
4597
|
+
border-radius: var(--dsw-radius-sm, 6px);
|
|
4598
|
+
outline: 0;
|
|
4599
|
+
background: var(--dsw-alias-bg-base);
|
|
4600
|
+
color: var(--dsw-alias-label-primary);
|
|
4601
|
+
font: inherit;
|
|
4602
|
+
font-size: 14px;
|
|
4603
|
+
}
|
|
4604
|
+
.orca-dialog-input:focus {
|
|
4605
|
+
border-color: var(--dsw-alias-brand-primary);
|
|
4606
|
+
}
|
|
4607
|
+
.orca-dialog-actions {
|
|
4608
|
+
display: flex;
|
|
4609
|
+
justify-content: flex-end;
|
|
4610
|
+
gap: 8px;
|
|
4611
|
+
margin-top: 16px;
|
|
4612
|
+
}
|
|
4613
|
+
.orca-button {
|
|
4614
|
+
height: 30px;
|
|
4615
|
+
padding: 0 13px;
|
|
4616
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
4617
|
+
border-radius: var(--dsw-radius-sm, 6px);
|
|
4618
|
+
background: transparent;
|
|
4619
|
+
color: var(--dsw-alias-label-primary);
|
|
4620
|
+
font: inherit;
|
|
4621
|
+
font-size: 13px;
|
|
4622
|
+
cursor: pointer;
|
|
4623
|
+
}
|
|
4624
|
+
.orca-button:hover {
|
|
4625
|
+
background: color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);
|
|
4626
|
+
}
|
|
4627
|
+
.orca-button--primary {
|
|
4628
|
+
border-color: color-mix(in srgb, var(--dsw-alias-brand-primary) 35%, transparent);
|
|
4629
|
+
background: color-mix(in srgb, var(--dsw-alias-brand-primary) 12%, transparent);
|
|
4630
|
+
color: var(--dsw-alias-brand-primary);
|
|
4631
|
+
}
|
|
4632
|
+
.orca-button--danger {
|
|
4633
|
+
border-color: color-mix(in srgb, var(--dsw-alias-state-error-primary) 35%, transparent);
|
|
4634
|
+
background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 10%, transparent);
|
|
4635
|
+
color: var(--dsw-alias-state-error-primary);
|
|
4636
|
+
}
|
|
4637
|
+
.orca-button:disabled {
|
|
4638
|
+
opacity: 0.45;
|
|
4639
|
+
cursor: default;
|
|
4640
|
+
}
|
|
4641
|
+
.orca-toast {
|
|
4642
|
+
position: fixed;
|
|
4643
|
+
left: 12px;
|
|
4644
|
+
bottom: 14px;
|
|
4645
|
+
z-index: 110;
|
|
4646
|
+
display: flex;
|
|
4647
|
+
align-items: flex-start;
|
|
4648
|
+
gap: 7px;
|
|
4649
|
+
width: 244px;
|
|
4650
|
+
max-width: calc(100vw - 24px);
|
|
4651
|
+
padding: 9px 10px;
|
|
4652
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
4653
|
+
border-radius: 8px;
|
|
4654
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
4655
|
+
box-shadow: 0 8px 24px color-mix(in srgb, var(--dsw-alias-label-primary) 18%, transparent);
|
|
4656
|
+
color: var(--dsw-alias-label-primary);
|
|
4657
|
+
font-size: 12px;
|
|
4658
|
+
line-height: 1.45;
|
|
4659
|
+
}
|
|
4660
|
+
.orca-toast.is-error {
|
|
4661
|
+
color: var(--dsw-alias-state-error-primary);
|
|
4662
|
+
}
|
|
4663
|
+
.orca-project-row[data-orca-drop="before"]::before,
|
|
4664
|
+
.orca-project-row[data-orca-drop="after"]::after,
|
|
4665
|
+
.orca-session[data-orca-drop="before"]::before,
|
|
4666
|
+
.orca-session[data-orca-drop="after"]::after {
|
|
4667
|
+
content: "";
|
|
4668
|
+
position: absolute;
|
|
4669
|
+
left: 6px;
|
|
4670
|
+
right: 6px;
|
|
4671
|
+
z-index: 2;
|
|
4672
|
+
height: 2px;
|
|
4673
|
+
border-radius: 2px;
|
|
4674
|
+
background: var(--dsw-alias-brand-primary);
|
|
4675
|
+
pointer-events: none;
|
|
4676
|
+
}
|
|
4677
|
+
.orca-project-row[data-orca-drop="before"]::before,
|
|
4678
|
+
.orca-session[data-orca-drop="before"]::before {
|
|
4679
|
+
top: -1px;
|
|
4680
|
+
}
|
|
4681
|
+
.orca-project-row[data-orca-drop="after"]::after,
|
|
4682
|
+
.orca-session[data-orca-drop="after"]::after {
|
|
4683
|
+
bottom: -1px;
|
|
4684
|
+
}
|
|
4685
|
+
[data-orca-drop="group"] {
|
|
4686
|
+
background: color-mix(in srgb, var(--dsw-alias-brand-primary) 9%, transparent);
|
|
4687
|
+
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--dsw-alias-brand-primary) 45%, transparent);
|
|
4688
|
+
}
|
|
4689
|
+
@media (hover: none) {
|
|
4690
|
+
.orca-project-actions,
|
|
4691
|
+
.orca-session-actions,
|
|
4692
|
+
.orca-group-actions {
|
|
4693
|
+
display: flex;
|
|
4694
|
+
}
|
|
4695
|
+
}
|
|
4696
|
+
@media (prefers-reduced-motion: reduce) {
|
|
4697
|
+
.orca-chevron,
|
|
4698
|
+
.orca-spinner,
|
|
4699
|
+
.orca-icon-button,
|
|
4700
|
+
.orca-session,
|
|
4701
|
+
.orca-project-head,
|
|
4702
|
+
.orca-group-head,
|
|
4703
|
+
.orca-loose-workspace-head {
|
|
4704
|
+
transition: none;
|
|
4705
|
+
animation: none;
|
|
4706
|
+
}
|
|
4707
|
+
}
|
|
4708
|
+
`
|
|
4709
|
+
|
|
4710
|
+
function installStyles() {
|
|
4711
|
+
const existing = document.querySelector('style[data-orca-projects="styles"]')
|
|
4712
|
+
if (existing?.parentNode) existing.parentNode.removeChild(existing)
|
|
4713
|
+
const tag = document.createElement('style')
|
|
4714
|
+
tag.dataset.orcaProjects = 'styles'
|
|
4715
|
+
tag.textContent = ORCA_CSS
|
|
4716
|
+
document.head.appendChild(tag)
|
|
4717
|
+
return () => {
|
|
4718
|
+
if (tag.parentNode) tag.parentNode.removeChild(tag)
|
|
4719
|
+
}
|
|
4720
|
+
}
|
|
4721
|
+
|
|
4722
|
+
const inject = [
|
|
4723
|
+
'slots',
|
|
4724
|
+
'locale',
|
|
4725
|
+
'workspaces',
|
|
4726
|
+
'sessions',
|
|
4727
|
+
'uiSession',
|
|
4728
|
+
'uiWorkspace',
|
|
4729
|
+
'layout',
|
|
4730
|
+
'connection',
|
|
4731
|
+
]
|
|
4732
|
+
|
|
4733
|
+
function apply(ctx) {
|
|
4734
|
+
const workspaces = ctx.get('workspaces')
|
|
4735
|
+
const sessions = ctx.get('sessions')
|
|
4736
|
+
const uiSession = ctx.get('uiSession')
|
|
4737
|
+
const uiWorkspace = ctx.get('uiWorkspace')
|
|
4738
|
+
const layout = ctx.get('layout')
|
|
4739
|
+
|
|
4740
|
+
const workspaceSource = {
|
|
4741
|
+
getSnapshot: () => workspaces.list.getSnapshot(),
|
|
4742
|
+
subscribe: (listener) => workspaces.list.subscribe(listener),
|
|
4743
|
+
}
|
|
4744
|
+
const sessionSource = {
|
|
4745
|
+
getSnapshot: () => sessions.list.getSnapshot(),
|
|
4746
|
+
subscribe: (listener) => sessions.list.subscribe(listener),
|
|
4747
|
+
}
|
|
4748
|
+
const sessionStatusSource = uiSession?.sessionStatus
|
|
4749
|
+
? {
|
|
4750
|
+
getSnapshot: () => uiSession.sessionStatus.getSnapshot(),
|
|
4751
|
+
subscribe: (listener) => uiSession.sessionStatus.subscribe(listener),
|
|
4752
|
+
}
|
|
4753
|
+
: undefined
|
|
4754
|
+
const layoutSource = layout
|
|
4755
|
+
? {
|
|
4756
|
+
getSnapshot: () => layout.panelInfo.getSnapshot(),
|
|
4757
|
+
subscribe: (listener) => layout.panelInfo.subscribe(listener),
|
|
4758
|
+
}
|
|
4759
|
+
: undefined
|
|
4760
|
+
ctx.effect(() => ctx.locale.register(NS, { en, zh }), 'orca-projects: dictionaries')
|
|
4761
|
+
ctx.effect(() => installStyles(), 'orca-projects: styles')
|
|
4762
|
+
|
|
4763
|
+
let searchRequest = 0
|
|
4764
|
+
const searchListeners = new Set()
|
|
4765
|
+
const searchRequestSource = {
|
|
4766
|
+
getSnapshot: () => searchRequest,
|
|
4767
|
+
subscribe: (listener) => {
|
|
4768
|
+
searchListeners.add(listener)
|
|
4769
|
+
return () => searchListeners.delete(listener)
|
|
4770
|
+
},
|
|
4771
|
+
}
|
|
4772
|
+
ctx.effect(() => {
|
|
4773
|
+
let entry
|
|
4774
|
+
let unsubscribe = () => {}
|
|
4775
|
+
const reconcile = () => {
|
|
4776
|
+
// Raw entries retain the shadowed DSH browser's injected shortcut source.
|
|
4777
|
+
const next = ctx.slots
|
|
4778
|
+
.entries?.('sidebar.workspaces')
|
|
4779
|
+
.find(
|
|
4780
|
+
(candidate) =>
|
|
4781
|
+
candidate.locale === 'workspace' && typeof candidate.inject === 'function',
|
|
4782
|
+
)
|
|
4783
|
+
if (next === entry) return
|
|
4784
|
+
unsubscribe()
|
|
4785
|
+
unsubscribe = () => {}
|
|
4786
|
+
entry = next
|
|
4787
|
+
if (!entry) return
|
|
4788
|
+
try {
|
|
4789
|
+
const source = entry.inject().hooks?.workspaceShortcuts
|
|
4790
|
+
if (
|
|
4791
|
+
typeof source?.getSnapshot !== 'function' ||
|
|
4792
|
+
typeof source?.subscribe !== 'function'
|
|
4793
|
+
)
|
|
4794
|
+
return
|
|
4795
|
+
let lastRequest = source.getSnapshot().searchRequest
|
|
4796
|
+
unsubscribe = source.subscribe(() => {
|
|
4797
|
+
const request = source.getSnapshot().searchRequest
|
|
4798
|
+
if (request === lastRequest) return
|
|
4799
|
+
lastRequest = request
|
|
4800
|
+
if (!Number.isSafeInteger(request) || request <= 0) return
|
|
4801
|
+
searchRequest += 1
|
|
4802
|
+
for (const listener of searchListeners) listener()
|
|
4803
|
+
})
|
|
4804
|
+
} catch {
|
|
4805
|
+
// An unavailable/incompatible shipped entry must not break the replacement.
|
|
4806
|
+
}
|
|
4807
|
+
}
|
|
4808
|
+
const unsubscribeSlots = ctx.slots.subscribe?.('sidebar.workspaces', reconcile)
|
|
4809
|
+
reconcile()
|
|
4810
|
+
return () => {
|
|
4811
|
+
unsubscribeSlots?.()
|
|
4812
|
+
unsubscribe()
|
|
4813
|
+
searchListeners.clear()
|
|
4814
|
+
}
|
|
4815
|
+
}, 'orca-projects: search shortcuts')
|
|
4816
|
+
|
|
4817
|
+
ctx.slots.inject('sidebar.workspaces', () =>
|
|
4818
|
+
ctx.slots.register(
|
|
4819
|
+
{
|
|
4820
|
+
name: 'sidebar.workspaces',
|
|
4821
|
+
priority: -1,
|
|
4822
|
+
locale: NS,
|
|
4823
|
+
inject: () => ({
|
|
4824
|
+
workspaceSource,
|
|
4825
|
+
sessionSource,
|
|
4826
|
+
sessionStatusSource,
|
|
4827
|
+
layoutSource,
|
|
4828
|
+
searchRequestSource,
|
|
4829
|
+
resolveRepositories: fetchRepositories,
|
|
4830
|
+
openSession: (sessionId) => uiWorkspace.openSession(sessionId),
|
|
4831
|
+
startSession: (workspaceId) => uiWorkspace.startSession(workspaceId),
|
|
4832
|
+
openWorkspace: (workspaceId) => uiWorkspace.openWorkspace(workspaceId),
|
|
4833
|
+
pickDirectory: () => uiWorkspace.pickDirectory(),
|
|
4834
|
+
createWorkspace: (path) => workspaces.create({ path }),
|
|
4835
|
+
deleteWorkspace: (workspaceId) => workspaces.delete(workspaceId),
|
|
4836
|
+
pinSession: (sessionId) => workspaces.pinSession(sessionId),
|
|
4837
|
+
unpinSession: (sessionId) => workspaces.unpinSession(sessionId),
|
|
4838
|
+
archiveSession: (sessionId, options) => workspaces.archiveSession(sessionId, options),
|
|
4839
|
+
unarchiveSession: (sessionId) => workspaces.unarchiveSession(sessionId),
|
|
4840
|
+
}),
|
|
4841
|
+
},
|
|
4842
|
+
OrcaBrowser,
|
|
4843
|
+
),
|
|
4844
|
+
)
|
|
4845
|
+
}
|
|
4846
|
+
|
|
4847
|
+
const internals = {
|
|
4848
|
+
defaultState,
|
|
4849
|
+
sanitizeState,
|
|
4850
|
+
buildView,
|
|
4851
|
+
assignProject,
|
|
4852
|
+
renameProject,
|
|
4853
|
+
createGroup,
|
|
4854
|
+
deleteGroup,
|
|
4855
|
+
renameGroup,
|
|
4856
|
+
moveProjectInOrder,
|
|
4857
|
+
moveSessionInOrder,
|
|
4858
|
+
isCollapsed,
|
|
4859
|
+
normalizePath,
|
|
4860
|
+
isAncestor,
|
|
4861
|
+
worktreeFromPath,
|
|
4862
|
+
sessionWorktree,
|
|
4863
|
+
workspaceRepo,
|
|
4864
|
+
repoFromPathFallback,
|
|
4865
|
+
worktreeForSession,
|
|
4866
|
+
repositoryWorktree,
|
|
4867
|
+
isActiveSession,
|
|
4868
|
+
findCurrentId,
|
|
4869
|
+
sessionLabel,
|
|
4870
|
+
sortProjects,
|
|
4871
|
+
sortSessions,
|
|
4872
|
+
}
|
|
4873
|
+
|
|
4874
|
+
return {
|
|
4875
|
+
inject,
|
|
4876
|
+
apply,
|
|
4877
|
+
...(globalThis.__ORCA_PROJECTS_TEST__ ? { __internals: internals } : {}),
|
|
4878
|
+
}
|
|
4879
|
+
},
|
|
4880
|
+
})
|