dsh-sidebar-shelves 0.1.0 → 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/README.md +10 -6
- package/client.js +531 -77
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,9 +5,11 @@ English | [中文](#中文)
|
|
|
5
5
|
Two-line session cards for the [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) sidebar.
|
|
6
6
|
|
|
7
7
|
- **Project tiles** — every Workspace gets a tile: a name-derived monogram and color, or the emoji, color, or square image file you pick. Icon Composer `.icon` packages work too.
|
|
8
|
-
- **Pinning** — pinned sessions lead the list; pinning
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
8
|
+
- **Pinning** — pinned sessions lead the list; pinning applies to active sessions, and archiving clears the pin.
|
|
9
|
+
- **Context menu** — right-click a card to pin, rename, fork, copy the Session ID, archive it, or remove its project; Shift+F10 opens the same menu from the keyboard.
|
|
10
|
+
- **Project menu** — right-click a card's project tile or name to change its icon or remove the project; removal only unregisters the workspace and keeps its folder and sessions.
|
|
11
|
+
- **Archiving** — archive a session by hand, or let cards archive themselves after 3, 7, 14, or 30 days. Archived sessions drop to the Archived shelf at the bottom; expanding it scrolls within a capped area.
|
|
12
|
+
- **Status markers** — running and waiting markers; a running session's time takes the brand accent, and a terminal marker flags sessions that own one.
|
|
11
13
|
- **Activity counts** — running background jobs and subagents per session, folded on the Host from the Session's own job records.
|
|
12
14
|
- **Recency sorting** — newest input first, and the composer's Workspace menu reuses the same tiles and the same order.
|
|
13
15
|
- **Header tile** — the open session's Workspace tile sits just before its title in the conversation header.
|
|
@@ -53,9 +55,11 @@ MIT
|
|
|
53
55
|
DeepSeek Harness 侧边栏的会话卡片:每个会话是一张两行卡片。
|
|
54
56
|
|
|
55
57
|
- **项目图标** — 每个工作区一个图标:按名称生成的字母块与配色,或你选的 emoji、颜色、方形图片;也支持 Icon Composer 的 `.icon` 图标包。
|
|
56
|
-
- **置顶** —
|
|
57
|
-
-
|
|
58
|
-
-
|
|
58
|
+
- **置顶** — 置顶会话排在最前,仅适用于活跃会话;归档时会自动取消置顶。
|
|
59
|
+
- **右键菜单** — 在会话卡片上右键可置顶、重命名、分叉、复制会话 ID、归档或移除所属项目;键盘上 Shift+F10 打开同一菜单。
|
|
60
|
+
- **项目菜单** — 在卡片的项目图标或项目名上右键,可更改项目图标或移除项目;移除只取消工作区注册,文件夹和会话都会保留。
|
|
61
|
+
- **归档** — 手动归档,或按 3、7、14、30 天自动归档;归档的会话收进底部的「已归档」,展开后在限定高度内滚动。
|
|
62
|
+
- **状态标记** — 运行中、等待中标记;运行中会话的时间改用品牌色高亮,带终端会话另显示终端标记。
|
|
59
63
|
- **活动计数** — 每个会话运行中的后台任务与子代理数量,由 Host 端从会话自身的任务记录折叠得出。
|
|
60
64
|
- **按最近输入排序** — 输入框的工作区菜单复用同一套图标和同一套顺序。
|
|
61
65
|
- **标题前图标** — 打开的会话在标题前显示所属工作区的图标。
|
package/client.js
CHANGED
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
* session leaves the list only when the user archives it. Pinning is local and
|
|
14
14
|
* independent of archiving.
|
|
15
15
|
*
|
|
16
|
+
* A card's context menu mirrors the native Session menu where the running DSH
|
|
17
|
+
* offers the same verbs: pin, rename, fork, copy the Session id, and archive.
|
|
18
|
+
*
|
|
16
19
|
* The composer's workspace menu is the second occupant: it draws each Workspace
|
|
17
20
|
* with the same project tile and orders them by their newest session, so the
|
|
18
21
|
* sidebar and the picker share one icon set and one recency rule. The third is
|
|
@@ -23,7 +26,7 @@ window.__ModuleLoader__.load({
|
|
|
23
26
|
id: 'dsh-sidebar-shelves',
|
|
24
27
|
factory(require) {
|
|
25
28
|
const React = require('react');
|
|
26
|
-
const { Button, IconPlusOutlineRegular, Menu, Modal } = require('@deepseek-ai/dsh-client-ui-primitives');
|
|
29
|
+
const { Button, IconPlusOutlineRegular, Menu, Modal, Toast, writeClipboard } = require('@deepseek-ai/dsh-client-ui-primitives');
|
|
27
30
|
const h = React.createElement;
|
|
28
31
|
const NS = 'dsh.sidebarShelves';
|
|
29
32
|
|
|
@@ -36,6 +39,9 @@ window.__ModuleLoader__.load({
|
|
|
36
39
|
// Mirrors the Host half's projection key; the Host folds owned jobs there.
|
|
37
40
|
const JOB_ACTIVITY_KEY = 'sidebarShelvesJobActivity';
|
|
38
41
|
const AUTO_ARCHIVE_CHOICES = [3, 7, 14, 30];
|
|
42
|
+
// The settings panel floats over the column instead of joining its flow, so
|
|
43
|
+
// its box is placed from the gear's own rect.
|
|
44
|
+
const SETTINGS_POPOVER_WIDTH = 232;
|
|
39
45
|
|
|
40
46
|
// t3code's project palette: the same name always lands on the same slot, so a
|
|
41
47
|
// project keeps its color without anything being stored. Light mode uses the
|
|
@@ -100,6 +106,23 @@ window.__ModuleLoader__.load({
|
|
|
100
106
|
'action.unarchive': '取消归档',
|
|
101
107
|
'action.pin': '置顶会话',
|
|
102
108
|
'action.unpin': '取消置顶',
|
|
109
|
+
'action.rename': '重命名…',
|
|
110
|
+
'action.fork': '分叉会话',
|
|
111
|
+
'action.copyId': '复制会话 ID',
|
|
112
|
+
'action.copyIdDone': '已复制会话 ID',
|
|
113
|
+
'action.copyIdFailed': '复制会话 ID 失败',
|
|
114
|
+
'action.forkFailed': '无法分叉会话',
|
|
115
|
+
'action.removeProject': '移除项目',
|
|
116
|
+
'remove.title': '移除项目',
|
|
117
|
+
'remove.desc': '将把“{name}”从侧边栏的项目中移除。文件夹与会话记录会保留,其会话将显示为未分组。',
|
|
118
|
+
'remove.pending': '正在移除项目…',
|
|
119
|
+
'remove.confirm': '移除',
|
|
120
|
+
'remove.cancel': '取消',
|
|
121
|
+
'remove.done': '已移除项目',
|
|
122
|
+
'rename.title': '重命名会话',
|
|
123
|
+
'rename.confirm': '确定',
|
|
124
|
+
'rename.cancel': '取消',
|
|
125
|
+
'rename.empty': '标题不能为空',
|
|
103
126
|
'menu.addWorkspace': '添加工作区…',
|
|
104
127
|
'menu.addFailed': '无法添加工作区',
|
|
105
128
|
'menu.addRetry': '重试',
|
|
@@ -145,6 +168,23 @@ window.__ModuleLoader__.load({
|
|
|
145
168
|
'action.unarchive': 'Unarchive session',
|
|
146
169
|
'action.pin': 'Pin session',
|
|
147
170
|
'action.unpin': 'Unpin session',
|
|
171
|
+
'action.rename': 'Rename…',
|
|
172
|
+
'action.fork': 'Fork session',
|
|
173
|
+
'action.copyId': 'Copy Session ID',
|
|
174
|
+
'action.copyIdDone': 'Session ID copied',
|
|
175
|
+
'action.copyIdFailed': 'Could not copy Session ID',
|
|
176
|
+
'action.forkFailed': 'Could not fork session',
|
|
177
|
+
'action.removeProject': 'Remove project',
|
|
178
|
+
'remove.title': 'Remove project',
|
|
179
|
+
'remove.desc': 'This removes “{name}” from the sidebar projects. The folder and its sessions are kept; its sessions become ungrouped.',
|
|
180
|
+
'remove.pending': 'Removing project…',
|
|
181
|
+
'remove.confirm': 'Remove',
|
|
182
|
+
'remove.cancel': 'Cancel',
|
|
183
|
+
'remove.done': 'Project removed',
|
|
184
|
+
'rename.title': 'Rename session',
|
|
185
|
+
'rename.confirm': 'Rename',
|
|
186
|
+
'rename.cancel': 'Cancel',
|
|
187
|
+
'rename.empty': 'Title cannot be empty',
|
|
148
188
|
'menu.addWorkspace': 'Add workspace…',
|
|
149
189
|
'menu.addFailed': 'Could not add workspace',
|
|
150
190
|
'menu.addRetry': 'Try again',
|
|
@@ -182,7 +222,9 @@ window.__ModuleLoader__.load({
|
|
|
182
222
|
'.dsh-shelves-scroll{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;overflow-y:auto;scrollbar-width:none;-ms-overflow-style:none}',
|
|
183
223
|
'.dsh-shelves-scroll::-webkit-scrollbar{display:none;width:0;height:0}',
|
|
184
224
|
'.dsh-shelves-stack{display:flex;flex:1 1 auto;flex-direction:column;gap:2px;padding:6px 4px 10px}',
|
|
185
|
-
'.dsh-shelves-bottom{display:flex;flex-direction:column;gap:2px;margin-top:auto}',
|
|
225
|
+
'.dsh-shelves-bottom{display:flex;flex-direction:column;gap:2px;margin-top:auto;padding-top:6px;border-top:1px solid var(--dsw-alias-border-l1)}',
|
|
226
|
+
'.dsh-shelves-archived-list{display:flex;flex-direction:column;gap:2px;max-height:min(360px,42vh);overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none;-ms-overflow-style:none}',
|
|
227
|
+
'.dsh-shelves-archived-list::-webkit-scrollbar{display:none;width:0;height:0}',
|
|
186
228
|
'.dsh-shelves-headrow{display:flex;align-items:center;gap:2px;margin-top:6px}',
|
|
187
229
|
'.dsh-shelves-head{display:flex;flex:1 1 auto;align-items:center;gap:6px;box-sizing:border-box;height:32px;padding:0 6px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;font-weight:500;text-align:left;cursor:pointer}',
|
|
188
230
|
'.dsh-shelves-head:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover,var(--dsw-alias-bg-layer-2))}',
|
|
@@ -193,7 +235,7 @@ window.__ModuleLoader__.load({
|
|
|
193
235
|
'.dsh-shelves-gear{display:inline-flex;flex:none;align-items:center;justify-content:center;box-sizing:border-box;width:26px;height:26px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer;opacity:.6}',
|
|
194
236
|
'.dsh-shelves-gear:hover,.dsh-shelves-gear[aria-expanded="true"]{opacity:1;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover,var(--dsw-alias-bg-layer-2))}',
|
|
195
237
|
'.dsh-shelves-gear:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}',
|
|
196
|
-
'.dsh-shelves-settings{
|
|
238
|
+
'.dsh-shelves-settings{position:fixed;z-index:60;display:flex;flex-direction:column;box-sizing:border-box;padding:8px 10px 10px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-overlay);box-shadow:0 10px 28px #00000033}',
|
|
197
239
|
'.dsh-shelves-settings-title{margin-bottom:2px;font-size:11px;font-weight:500;letter-spacing:.03em;color:var(--dsw-alias-label-secondary)}',
|
|
198
240
|
'.dsh-shelves-setting{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:28px;font-size:12px;color:var(--dsw-alias-label-primary)}',
|
|
199
241
|
'.dsh-shelves-select{position:relative;display:inline-flex;align-items:center}',
|
|
@@ -217,6 +259,9 @@ window.__ModuleLoader__.load({
|
|
|
217
259
|
'.dsh-shelves-badge-n{color:var(--dsw-alias-label-secondary)}',
|
|
218
260
|
'.dsh-shelves-term{display:inline-flex;flex:none;align-items:center;color:var(--dsw-alias-state-business-primary)}',
|
|
219
261
|
'.dsh-shelves-time{margin-left:auto;flex:none;font-size:12px;font-variant-numeric:tabular-nums;opacity:.7;transition:opacity .12s ease}',
|
|
262
|
+
// A working session's time carries the same brand color as its spinner, so
|
|
263
|
+
// the row reads as live without a second kind of accent.
|
|
264
|
+
'.dsh-shelves-time-running{color:var(--dsw-alias-brand-primary);font-weight:500;opacity:1}',
|
|
220
265
|
'.dsh-shelves-status{display:inline-flex;align-items:center;justify-content:center;transition:opacity .12s ease}',
|
|
221
266
|
'.dsh-shelves-status-working{color:var(--dsw-alias-brand-primary)}',
|
|
222
267
|
'.dsh-shelves-status-warn{color:var(--dsw-alias-state-warn-primary)}',
|
|
@@ -307,6 +352,14 @@ window.__ModuleLoader__.load({
|
|
|
307
352
|
'.dsh-shelves-files-btn:disabled{opacity:.45;cursor:default}',
|
|
308
353
|
'.dsh-shelves-files-btn-primary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-base)}',
|
|
309
354
|
'.dsh-shelves-files-btn-primary:hover{background:color-mix(in srgb,var(--dsw-alias-label-primary) 86%,var(--dsw-alias-bg-base))}',
|
|
355
|
+
'.dsh-shelves-rename{display:flex;flex-direction:column;gap:6px}',
|
|
356
|
+
'.dsh-shelves-rename input{box-sizing:border-box;width:100%;height:34px;padding:0 10px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;outline:none}',
|
|
357
|
+
'.dsh-shelves-rename input:focus{border-color:var(--dsw-alias-brand-primary)}',
|
|
358
|
+
'.dsh-shelves-rename-error{font-size:12px;color:var(--dsw-alias-state-error-primary)}',
|
|
359
|
+
'.dsh-shelves-remove{display:flex;flex-direction:column;gap:8px;font-size:13px;line-height:1.5;color:var(--dsw-alias-label-primary)}',
|
|
360
|
+
'.dsh-shelves-remove-pending{font-size:12px;color:var(--dsw-alias-label-secondary)}',
|
|
361
|
+
'.dsh-shelves-remove-error{font-size:12px;color:var(--dsw-alias-state-error-primary)}',
|
|
362
|
+
'.dsh-shelves-danger{color:var(--dsw-alias-state-error-primary)}',
|
|
310
363
|
'.dsh-shelves-row:hover .dsh-shelves-time,.dsh-shelves-row:focus-within .dsh-shelves-time{opacity:0}',
|
|
311
364
|
'.dsh-shelves-empty{padding:16px 10px;color:var(--dsw-alias-label-secondary);font-size:12px}',
|
|
312
365
|
'.dsh-shelves-rail{display:inline-flex;flex:none;align-items:center;justify-content:center;box-sizing:border-box;width:36px;height:36px;margin:0 auto;border:0;border-radius:10px;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:11px;font-variant-numeric:tabular-nums;cursor:pointer}',
|
|
@@ -335,8 +388,12 @@ window.__ModuleLoader__.load({
|
|
|
335
388
|
gear: 'M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-2.9 1.2v.2a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-2.9-1.2l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1A1.7 1.7 0 0 0 3 15H2.9a2 2 0 1 1 0-4H3a1.7 1.7 0 0 0 1.2-2.9l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1A1.7 1.7 0 0 0 10 4.1V4a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 2.9 1.2l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1A1.7 1.7 0 0 0 21 11h.1a2 2 0 1 1 0 4H21a1.7 1.7 0 0 0-1.6 1z',
|
|
336
389
|
pin: 'M12 17v5M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z',
|
|
337
390
|
unarchive: 'M3.5 5.5h17v3.5h-17zM5.5 9v9.5h13V9M12 15.5V10M9.5 12.5l2.5-2.5 2.5 2.5',
|
|
391
|
+
rename: 'M4 20h4l9.5-9.5a2.1 2.1 0 0 0-3-3L5 17v3zM13.5 6.5l4 4',
|
|
392
|
+
fork: 'M6 4v9M6 19a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zM18 9a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zM18 9c0 4.5-4 5-8 5.5',
|
|
393
|
+
copy: 'M9 9h10v10H9zM5 15V5h10',
|
|
338
394
|
image: 'M3.5 5.5h17v13h-17zM7 14.5l3.5-3.5 3 3 2-2 2 2M8 9.5h.01',
|
|
339
395
|
search: 'M10.5 17a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13zM15.5 15.5L20 20',
|
|
396
|
+
trash: 'M4 7h16M9.5 7V5h5v2M6.5 7l.8 12.5h9.4L17.5 7M10 11v5M14 11v5',
|
|
340
397
|
};
|
|
341
398
|
|
|
342
399
|
function glyph(name, size) {
|
|
@@ -777,7 +834,7 @@ window.__ModuleLoader__.load({
|
|
|
777
834
|
icon: workspace === undefined ? null : projectIcon(workspaceIconName(workspace), icons[workspace.workspaceId]),
|
|
778
835
|
updatedAtMs,
|
|
779
836
|
archived: archived.has(id),
|
|
780
|
-
pinned: pinned[id] !== undefined,
|
|
837
|
+
pinned: pinned[id] !== undefined && !archived.has(id),
|
|
781
838
|
pending,
|
|
782
839
|
completed,
|
|
783
840
|
running,
|
|
@@ -806,6 +863,37 @@ window.__ModuleLoader__.load({
|
|
|
806
863
|
return undefined;
|
|
807
864
|
}
|
|
808
865
|
|
|
866
|
+
// A floating panel closes on a click outside it, Escape, scroll or resize;
|
|
867
|
+
// Escape also returns focus to the control that opened it. `inside` names the
|
|
868
|
+
// panel and its trigger, so a click on either keeps the panel's own handler in
|
|
869
|
+
// charge of toggling it.
|
|
870
|
+
function useDismissFloating(open, setOpen, inside, openerRef) {
|
|
871
|
+
React.useEffect(() => {
|
|
872
|
+
if (!open) return undefined;
|
|
873
|
+
const close = () => setOpen(null);
|
|
874
|
+
const onPointerDown = (event) => {
|
|
875
|
+
const target = event.target;
|
|
876
|
+
if (target instanceof Element && target.closest(inside) !== null) return;
|
|
877
|
+
close();
|
|
878
|
+
};
|
|
879
|
+
const onKeyDown = (event) => {
|
|
880
|
+
if (event.key !== 'Escape') return;
|
|
881
|
+
close();
|
|
882
|
+
if (openerRef !== undefined) openerRef.current?.focus();
|
|
883
|
+
};
|
|
884
|
+
document.addEventListener('pointerdown', onPointerDown, true);
|
|
885
|
+
document.addEventListener('keydown', onKeyDown);
|
|
886
|
+
window.addEventListener('scroll', close, true);
|
|
887
|
+
window.addEventListener('resize', close);
|
|
888
|
+
return () => {
|
|
889
|
+
document.removeEventListener('pointerdown', onPointerDown, true);
|
|
890
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
891
|
+
window.removeEventListener('scroll', close, true);
|
|
892
|
+
window.removeEventListener('resize', close);
|
|
893
|
+
};
|
|
894
|
+
}, [open, setOpen, inside, openerRef]);
|
|
895
|
+
}
|
|
896
|
+
|
|
809
897
|
function useIconUrl(key, load) {
|
|
810
898
|
const [url, setUrl] = React.useState(() => (key === null ? null : (ICON_URLS.get(key) ?? null)));
|
|
811
899
|
React.useEffect(() => {
|
|
@@ -863,9 +951,10 @@ window.__ModuleLoader__.load({
|
|
|
863
951
|
);
|
|
864
952
|
}
|
|
865
953
|
|
|
866
|
-
// One row's Workspace tile: the face above, with the picker opening from it
|
|
954
|
+
// One row's Workspace tile: the face above, with the picker opening from it
|
|
955
|
+
// and the project menu on the context-menu gesture.
|
|
867
956
|
function ProjectTile(props) {
|
|
868
|
-
const { icon, label, onOpen } = props;
|
|
957
|
+
const { icon, label, onOpen, onMenu } = props;
|
|
869
958
|
return h(
|
|
870
959
|
'button',
|
|
871
960
|
{
|
|
@@ -877,6 +966,17 @@ window.__ModuleLoader__.load({
|
|
|
877
966
|
event.stopPropagation();
|
|
878
967
|
onOpen(event);
|
|
879
968
|
},
|
|
969
|
+
onContextMenu: (event) => {
|
|
970
|
+
event.preventDefault();
|
|
971
|
+
event.stopPropagation();
|
|
972
|
+
onMenu(event);
|
|
973
|
+
},
|
|
974
|
+
onKeyDown: (event) => {
|
|
975
|
+
if (event.key !== 'ContextMenu' && !(event.shiftKey && event.key === 'F10')) return;
|
|
976
|
+
event.preventDefault();
|
|
977
|
+
event.stopPropagation();
|
|
978
|
+
onMenu(event);
|
|
979
|
+
},
|
|
880
980
|
},
|
|
881
981
|
h(ProjectFace, props),
|
|
882
982
|
);
|
|
@@ -1368,7 +1468,7 @@ window.__ModuleLoader__.load({
|
|
|
1368
1468
|
}
|
|
1369
1469
|
|
|
1370
1470
|
function Shelves(props) {
|
|
1371
|
-
const { wide, expandSidebar, useSessions, useSessionStatus, useWorkspaces, usePanelInfo, openSession, archiveSession, unarchiveSession, getOpenTabs, listFiles, readFileBytes, t } = props;
|
|
1471
|
+
const { wide, expandSidebar, useSessions, useSessionStatus, useWorkspaces, usePanelInfo, useWorkspaceAccess, openSession, archiveSession, unarchiveSession, forkSession, renameSession, deleteWorkspace, getOpenTabs, listFiles, readFileBytes, t } = props;
|
|
1372
1472
|
const list = useSessions((state) => state) ?? EMPTY_LIST;
|
|
1373
1473
|
const statuses = useSessionStatus((state) => state);
|
|
1374
1474
|
const items = useWorkspaces((state) => state.items);
|
|
@@ -1395,17 +1495,47 @@ window.__ModuleLoader__.load({
|
|
|
1395
1495
|
const [settings, setSettings] = React.useState(() => normalizeSettings(readJson(SETTINGS_KEY, {})));
|
|
1396
1496
|
const [pinned, setPinned] = React.useState(() => normalizeMap(readJson(PINNED_KEY, {})));
|
|
1397
1497
|
const icons = React.useSyncExternalStore(iconsStore.subscribe, iconsStore.get);
|
|
1398
|
-
|
|
1498
|
+
// The settings panel floats over the column, so it keeps only its fixed
|
|
1499
|
+
// box; the gear is the control it is anchored to and returns focus to.
|
|
1500
|
+
const [settingsPopover, setSettingsPopover] = React.useState(null);
|
|
1501
|
+
const settingsGearRef = React.useRef(null);
|
|
1399
1502
|
const [archivedOpen, setArchivedOpen] = React.useState(false);
|
|
1400
1503
|
const [iconPicker, setIconPicker] = React.useState(null);
|
|
1401
1504
|
const [filePicker, setFilePicker] = React.useState(null);
|
|
1505
|
+
// One card menu at a time, anchored at the gesture point. `row` is the
|
|
1506
|
+
// occurrence snapshot; the element restores focus after a keyboard open.
|
|
1507
|
+
// A project menu rides the same slot with `kind: 'project'`.
|
|
1508
|
+
const [cardMenu, setCardMenu] = React.useState(null);
|
|
1509
|
+
const cardMenuRef = React.useRef(null);
|
|
1510
|
+
cardMenuRef.current = cardMenu;
|
|
1511
|
+
// A rename request owns its draft so a rejected write keeps the dialog.
|
|
1512
|
+
const [rename, setRename] = React.useState(null);
|
|
1513
|
+
// Removal keeps its target and failure text so a rejected write stays visible.
|
|
1514
|
+
const [removeProject, setRemoveProject] = React.useState(null);
|
|
1515
|
+
const [toast, setToast] = React.useState(null);
|
|
1402
1516
|
const [clock, bumpClock] = React.useReducer((n) => n + 1, 0);
|
|
1517
|
+
// The pointer point is a zero-size rect; the Menu primitive clamps it to
|
|
1518
|
+
// the viewport and follows scroll and resize while open.
|
|
1519
|
+
const cardMenuRect = React.useCallback(() => {
|
|
1520
|
+
const menu = cardMenuRef.current;
|
|
1521
|
+
if (menu === null) return null;
|
|
1522
|
+
return { left: menu.x, right: menu.x, top: menu.y, bottom: menu.y, width: 0, height: 0 };
|
|
1523
|
+
}, []);
|
|
1403
1524
|
|
|
1404
1525
|
React.useEffect(() => {
|
|
1405
1526
|
const id = window.setInterval(bumpClock, 60000);
|
|
1406
1527
|
return () => window.clearInterval(id);
|
|
1407
1528
|
}, []);
|
|
1408
1529
|
|
|
1530
|
+
// The rail renders no cards, so a pending menu or panel must not survive a
|
|
1531
|
+
// collapse.
|
|
1532
|
+
React.useEffect(() => {
|
|
1533
|
+
if (!wide) {
|
|
1534
|
+
setCardMenu(null);
|
|
1535
|
+
setSettingsPopover(null);
|
|
1536
|
+
}
|
|
1537
|
+
}, [wide]);
|
|
1538
|
+
|
|
1409
1539
|
const updateSettings = (patch) =>
|
|
1410
1540
|
setSettings((prev) => {
|
|
1411
1541
|
const next = { ...prev, ...patch };
|
|
@@ -1426,8 +1556,8 @@ window.__ModuleLoader__.load({
|
|
|
1426
1556
|
iconsStore.set(next);
|
|
1427
1557
|
};
|
|
1428
1558
|
|
|
1429
|
-
const openIconPicker = (row,
|
|
1430
|
-
const rect =
|
|
1559
|
+
const openIconPicker = (row, element) => {
|
|
1560
|
+
const rect = element.getBoundingClientRect();
|
|
1431
1561
|
const left = Math.max(8, Math.min(rect.left, window.innerWidth - 208));
|
|
1432
1562
|
const height = 200;
|
|
1433
1563
|
const top = rect.bottom + 6 + height > window.innerHeight ? Math.max(8, rect.top - height - 6) : rect.bottom + 6;
|
|
@@ -1453,28 +1583,24 @@ window.__ModuleLoader__.load({
|
|
|
1453
1583
|
setIconPicker(null);
|
|
1454
1584
|
};
|
|
1455
1585
|
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
const
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
window.removeEventListener('scroll', close, true);
|
|
1475
|
-
window.removeEventListener('resize', close);
|
|
1476
|
-
};
|
|
1477
|
-
}, [iconPicker]);
|
|
1586
|
+
// The shelf sits at the bottom of the column, so the panel grows upward from
|
|
1587
|
+
// the gear: anchoring its bottom edge needs no height estimate.
|
|
1588
|
+
const openSettings = (element) => {
|
|
1589
|
+
const rect = element.getBoundingClientRect();
|
|
1590
|
+
const left = Math.max(
|
|
1591
|
+
8,
|
|
1592
|
+
Math.min(rect.right - SETTINGS_POPOVER_WIDTH, window.innerWidth - SETTINGS_POPOVER_WIDTH - 8),
|
|
1593
|
+
);
|
|
1594
|
+
setSettingsPopover({ left, bottom: Math.max(8, window.innerHeight - rect.top + 6) });
|
|
1595
|
+
};
|
|
1596
|
+
|
|
1597
|
+
useDismissFloating(iconPicker !== null, setIconPicker, '.dsh-shelves-iconpicker, .dsh-shelves-proj');
|
|
1598
|
+
useDismissFloating(
|
|
1599
|
+
settingsPopover !== null,
|
|
1600
|
+
setSettingsPopover,
|
|
1601
|
+
'.dsh-shelves-settings, .dsh-shelves-gear',
|
|
1602
|
+
settingsGearRef,
|
|
1603
|
+
);
|
|
1478
1604
|
|
|
1479
1605
|
const currentId = React.useMemo(() => {
|
|
1480
1606
|
const byId = list.byId ?? {};
|
|
@@ -1489,6 +1615,27 @@ window.__ModuleLoader__.load({
|
|
|
1489
1615
|
() => deriveRows(list, statuses, workspaceIndex(items), currentId, archived, pinned, icons),
|
|
1490
1616
|
[list, statuses, items, currentId, archived, pinned, icons],
|
|
1491
1617
|
);
|
|
1618
|
+
// The gear leaves with the last card, so its panel must not outlive it.
|
|
1619
|
+
React.useEffect(() => {
|
|
1620
|
+
if (rows.length === 0) setSettingsPopover(null);
|
|
1621
|
+
}, [rows.length]);
|
|
1622
|
+
// Archiving drops the pin with the session, so unarchiving never brings
|
|
1623
|
+
// back a pin that could not be seen or cleared while it was archived.
|
|
1624
|
+
React.useEffect(() => {
|
|
1625
|
+
setPinned((prev) => {
|
|
1626
|
+
const next = {};
|
|
1627
|
+
let dropped = false;
|
|
1628
|
+
for (const [id, at] of Object.entries(prev)) {
|
|
1629
|
+
if (archived.has(id)) dropped = true;
|
|
1630
|
+
else next[id] = at;
|
|
1631
|
+
}
|
|
1632
|
+
if (!dropped) return prev;
|
|
1633
|
+
writeJson(PINNED_KEY, next);
|
|
1634
|
+
return next;
|
|
1635
|
+
});
|
|
1636
|
+
}, [archived]);
|
|
1637
|
+
// Owner-only; a shared page never receives a project removal row.
|
|
1638
|
+
const canRemoveProject = useWorkspaceAccess(cardMenu?.row.workspaceId ?? '', 'workspace/delete');
|
|
1492
1639
|
|
|
1493
1640
|
// A run that ends stays marked "Done" until the row is opened. DSH's own
|
|
1494
1641
|
// `completionUnread` only fires for a session that is not the main view and
|
|
@@ -1633,6 +1780,142 @@ window.__ModuleLoader__.load({
|
|
|
1633
1780
|
updatePinned(next);
|
|
1634
1781
|
};
|
|
1635
1782
|
|
|
1783
|
+
const showToast = (text, tone) => setToast({ text, tone, key: Date.now() });
|
|
1784
|
+
|
|
1785
|
+
// The card menu mirrors the native Session menu: same verbs, same order.
|
|
1786
|
+
// It never opens the Session, so a background row keeps the selection.
|
|
1787
|
+
const openCardMenu = (row, point, keyboard, element) => {
|
|
1788
|
+
if (row.blank) return;
|
|
1789
|
+
setCardMenu({ kind: 'session', row, x: point.x, y: point.y, keyboard, element });
|
|
1790
|
+
};
|
|
1791
|
+
|
|
1792
|
+
// A project menu hangs off a Workspace tile or name: change its tile or
|
|
1793
|
+
// remove its registration. Sessions and files stay untouched.
|
|
1794
|
+
const openProjectMenu = (row, point, keyboard, element) => {
|
|
1795
|
+
if (row.workspaceId === undefined) return;
|
|
1796
|
+
setIconPicker(null);
|
|
1797
|
+
setCardMenu({ kind: 'project', row, x: point.x, y: point.y, keyboard, element });
|
|
1798
|
+
};
|
|
1799
|
+
|
|
1800
|
+
const closeCardMenu = () => {
|
|
1801
|
+
const menu = cardMenuRef.current;
|
|
1802
|
+
setCardMenu(null);
|
|
1803
|
+
// A keyboard menu owns focus while open; hand it back to its row.
|
|
1804
|
+
if (menu?.keyboard) {
|
|
1805
|
+
Promise.resolve().then(() => {
|
|
1806
|
+
if (menu.element?.isConnected) menu.element.focus();
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
};
|
|
1810
|
+
|
|
1811
|
+
const cardMenuItems = (row) => {
|
|
1812
|
+
const items = [];
|
|
1813
|
+
if (!row.archived) {
|
|
1814
|
+
items.push({ id: 'pin', label: row.pinned ? t('action.unpin') : t('action.pin'), icon: glyph('pin', 16) });
|
|
1815
|
+
}
|
|
1816
|
+
items.push({ id: 'rename', label: t('action.rename'), icon: glyph('rename', 16) });
|
|
1817
|
+
items.push({ id: 'fork', label: t('action.fork'), icon: glyph('fork', 16) });
|
|
1818
|
+
items.push({ type: 'separator', id: 'card-menu-copy' });
|
|
1819
|
+
items.push({ id: 'copyId', label: t('action.copyId'), icon: glyph('copy', 16) });
|
|
1820
|
+
items.push({ type: 'separator', id: 'card-menu-archive' });
|
|
1821
|
+
items.push({
|
|
1822
|
+
id: 'archive',
|
|
1823
|
+
label: row.archived ? t('action.unarchive') : t('action.archive'),
|
|
1824
|
+
icon: glyph(row.archived ? 'unarchive' : 'archive', 16),
|
|
1825
|
+
});
|
|
1826
|
+
if (row.workspaceId !== undefined && canRemoveProject) {
|
|
1827
|
+
items.push({ type: 'separator', id: 'card-menu-project' });
|
|
1828
|
+
items.push({ id: 'removeProject', label: t('action.removeProject'), icon: glyph('trash', 16), danger: true });
|
|
1829
|
+
}
|
|
1830
|
+
return items;
|
|
1831
|
+
};
|
|
1832
|
+
|
|
1833
|
+
const projectMenuItems = () => {
|
|
1834
|
+
const items = [{ id: 'projectIcon', label: t('icon.edit'), icon: glyph('image', 16) }];
|
|
1835
|
+
if (canRemoveProject) {
|
|
1836
|
+
items.push({ type: 'separator', id: 'project-menu-remove' });
|
|
1837
|
+
items.push({ id: 'removeProject', label: t('action.removeProject'), icon: glyph('trash', 16), danger: true });
|
|
1838
|
+
}
|
|
1839
|
+
return items;
|
|
1840
|
+
};
|
|
1841
|
+
|
|
1842
|
+
const selectCardMenuItem = (id) => {
|
|
1843
|
+
const menu = cardMenuRef.current;
|
|
1844
|
+
if (menu === null) return;
|
|
1845
|
+
closeCardMenu();
|
|
1846
|
+
// Read the live row: pin and archive state may have moved since opening.
|
|
1847
|
+
const row = rows.find((candidate) => candidate.id === menu.row.id) ?? menu.row;
|
|
1848
|
+
if (menu.kind === 'project') {
|
|
1849
|
+
if (id === 'projectIcon') {
|
|
1850
|
+
if (menu.element?.isConnected) openIconPicker(row, menu.element);
|
|
1851
|
+
} else if (id === 'removeProject' && row.workspaceId !== undefined) {
|
|
1852
|
+
setRemoveProject({ workspaceId: row.workspaceId, name: row.workspace, busy: false, error: null });
|
|
1853
|
+
}
|
|
1854
|
+
return;
|
|
1855
|
+
}
|
|
1856
|
+
if (id === 'pin') togglePin(row);
|
|
1857
|
+
else if (id === 'rename') setRename({ id: row.id, draft: row.title || '', busy: false, error: null });
|
|
1858
|
+
else if (id === 'fork') {
|
|
1859
|
+
Promise.resolve()
|
|
1860
|
+
.then(() => forkSession(row.id))
|
|
1861
|
+
.catch((reason) => {
|
|
1862
|
+
console.warn('sidebar-shelves: fork failed', reason);
|
|
1863
|
+
showToast(t('action.forkFailed'), 'error');
|
|
1864
|
+
});
|
|
1865
|
+
} else if (id === 'copyId') {
|
|
1866
|
+
Promise.resolve()
|
|
1867
|
+
.then(() => writeClipboard(row.id))
|
|
1868
|
+
.then((ok) => showToast(ok ? t('action.copyIdDone') : t('action.copyIdFailed'), ok ? 'success' : 'error'))
|
|
1869
|
+
.catch(() => showToast(t('action.copyIdFailed'), 'error'));
|
|
1870
|
+
} else if (id === 'archive') toggleArchive(row);
|
|
1871
|
+
else if (id === 'removeProject' && row.workspaceId !== undefined) {
|
|
1872
|
+
setRemoveProject({ workspaceId: row.workspaceId, name: row.workspace, busy: false, error: null });
|
|
1873
|
+
}
|
|
1874
|
+
};
|
|
1875
|
+
|
|
1876
|
+
const submitRename = () => {
|
|
1877
|
+
const target = rename;
|
|
1878
|
+
if (target === null || target.busy) return;
|
|
1879
|
+
const title = target.draft.trim();
|
|
1880
|
+
if (title === '') {
|
|
1881
|
+
setRename({ ...target, error: t('rename.empty') });
|
|
1882
|
+
return;
|
|
1883
|
+
}
|
|
1884
|
+
setRename({ ...target, busy: true, error: null });
|
|
1885
|
+
Promise.resolve()
|
|
1886
|
+
.then(() => renameSession(target.id, title))
|
|
1887
|
+
.then(() => setRename(null))
|
|
1888
|
+
.catch((reason) => {
|
|
1889
|
+
const message = reason instanceof Error ? reason.message : String(reason);
|
|
1890
|
+
setRename((current) =>
|
|
1891
|
+
current !== null && current.id === target.id ? { ...current, busy: false, error: message } : current,
|
|
1892
|
+
);
|
|
1893
|
+
});
|
|
1894
|
+
};
|
|
1895
|
+
|
|
1896
|
+
// Removing a project only deletes the Workspace registration; the folder
|
|
1897
|
+
// and every Session stay. A successful delete also drops the local tile choice.
|
|
1898
|
+
const confirmRemoveProject = () => {
|
|
1899
|
+
const target = removeProject;
|
|
1900
|
+
if (target === null || target.busy) return;
|
|
1901
|
+
setRemoveProject({ ...target, busy: true, error: null });
|
|
1902
|
+
Promise.resolve()
|
|
1903
|
+
.then(() => deleteWorkspace(target.workspaceId))
|
|
1904
|
+
.then(() => {
|
|
1905
|
+
updateIcon(target.workspaceId, null);
|
|
1906
|
+
setRemoveProject(null);
|
|
1907
|
+
showToast(t('remove.done'), 'success');
|
|
1908
|
+
})
|
|
1909
|
+
.catch((reason) => {
|
|
1910
|
+
const message = reason instanceof Error ? reason.message : String(reason);
|
|
1911
|
+
setRemoveProject((current) =>
|
|
1912
|
+
current !== null && current.workspaceId === target.workspaceId
|
|
1913
|
+
? { ...current, busy: false, error: message }
|
|
1914
|
+
: current,
|
|
1915
|
+
);
|
|
1916
|
+
});
|
|
1917
|
+
};
|
|
1918
|
+
|
|
1636
1919
|
// The Workspace's tile: its chosen image, an emoji, or a two-letter monogram
|
|
1637
1920
|
// in its own color. Clicking it opens the picker; an ungrouped Session has none.
|
|
1638
1921
|
const renderProjectIcon = (row) => {
|
|
@@ -1645,7 +1928,17 @@ window.__ModuleLoader__.load({
|
|
|
1645
1928
|
workspacePath: row.workspacePath,
|
|
1646
1929
|
sessionId: row.id,
|
|
1647
1930
|
readFileBytes,
|
|
1648
|
-
onOpen: (event) => openIconPicker(row, event),
|
|
1931
|
+
onOpen: (event) => openIconPicker(row, event.currentTarget),
|
|
1932
|
+
onMenu: (event) => {
|
|
1933
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
1934
|
+
const keyboard = event.type !== 'contextmenu';
|
|
1935
|
+
openProjectMenu(
|
|
1936
|
+
row,
|
|
1937
|
+
keyboard ? { x: rect.left + 10, y: rect.bottom - 6 } : { x: event.clientX, y: event.clientY },
|
|
1938
|
+
keyboard,
|
|
1939
|
+
event.currentTarget,
|
|
1940
|
+
);
|
|
1941
|
+
},
|
|
1649
1942
|
});
|
|
1650
1943
|
};
|
|
1651
1944
|
|
|
@@ -1679,6 +1972,7 @@ window.__ModuleLoader__.load({
|
|
|
1679
1972
|
const title = row.blank ? t('session.new') : row.title || t('session.untitled');
|
|
1680
1973
|
const status = row.archived ? undefined : statusOf(row, unseen.has(row.id), t);
|
|
1681
1974
|
const time = relativeTime(row.updatedAtMs, Date.now(), t);
|
|
1975
|
+
const timeClass = status?.tone === 'working' ? 'dsh-shelves-time dsh-shelves-time-running' : 'dsh-shelves-time';
|
|
1682
1976
|
const classes = ['dsh-shelves-row'];
|
|
1683
1977
|
if (selected) classes.push('dsh-shelves-row-selected');
|
|
1684
1978
|
if (row.archived) classes.push('dsh-shelves-row-archived');
|
|
@@ -1693,9 +1987,21 @@ window.__ModuleLoader__.load({
|
|
|
1693
1987
|
'aria-disabled': row.archived ? 'true' : undefined,
|
|
1694
1988
|
title,
|
|
1695
1989
|
onClick: () => open(row),
|
|
1990
|
+
onContextMenu: (event) => {
|
|
1991
|
+
event.preventDefault();
|
|
1992
|
+
event.stopPropagation();
|
|
1993
|
+
openCardMenu(row, { x: event.clientX, y: event.clientY }, false, event.currentTarget);
|
|
1994
|
+
},
|
|
1696
1995
|
onKeyDown: (event) => {
|
|
1697
1996
|
// Keys pressed inside the row's own buttons belong to those buttons.
|
|
1698
1997
|
if (event.target !== event.currentTarget) return;
|
|
1998
|
+
// The platform context-menu gesture opens the same menu as the pointer.
|
|
1999
|
+
if (event.key === 'ContextMenu' || (event.shiftKey && event.key === 'F10')) {
|
|
2000
|
+
event.preventDefault();
|
|
2001
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
2002
|
+
openCardMenu(row, { x: rect.left + 10, y: rect.bottom - 6 }, true, event.currentTarget);
|
|
2003
|
+
return;
|
|
2004
|
+
}
|
|
1699
2005
|
if (event.key !== 'Enter' && event.key !== ' ') return;
|
|
1700
2006
|
event.preventDefault();
|
|
1701
2007
|
open(row);
|
|
@@ -1718,7 +2024,7 @@ window.__ModuleLoader__.load({
|
|
|
1718
2024
|
glyph(status.key, 13),
|
|
1719
2025
|
),
|
|
1720
2026
|
h('span', { className: status?.key === 'done' ? 'dsh-shelves-title dsh-shelves-title-done' : 'dsh-shelves-title' }, title),
|
|
1721
|
-
time === '' ? null : h('span', { className:
|
|
2027
|
+
time === '' ? null : h('span', { className: timeClass }, time),
|
|
1722
2028
|
),
|
|
1723
2029
|
h(
|
|
1724
2030
|
'span',
|
|
@@ -1731,7 +2037,22 @@ window.__ModuleLoader__.load({
|
|
|
1731
2037
|
glyph('pin', 12),
|
|
1732
2038
|
)
|
|
1733
2039
|
: null,
|
|
1734
|
-
h(
|
|
2040
|
+
h(
|
|
2041
|
+
'span',
|
|
2042
|
+
{
|
|
2043
|
+
className: 'dsh-shelves-ws',
|
|
2044
|
+
title: row.workspace || undefined,
|
|
2045
|
+
onContextMenu:
|
|
2046
|
+
row.workspaceId === undefined
|
|
2047
|
+
? undefined
|
|
2048
|
+
: (event) => {
|
|
2049
|
+
event.preventDefault();
|
|
2050
|
+
event.stopPropagation();
|
|
2051
|
+
openProjectMenu(row, { x: event.clientX, y: event.clientY }, false, event.currentTarget);
|
|
2052
|
+
},
|
|
2053
|
+
},
|
|
2054
|
+
row.workspace,
|
|
2055
|
+
),
|
|
1735
2056
|
renderActivityBadge('jobs', row.jobsRunning, row.jobsLabels),
|
|
1736
2057
|
renderActivityBadge('subagents', row.subagentsRunning, row.subagentLabels),
|
|
1737
2058
|
terminalSessions.has(row.id)
|
|
@@ -1745,20 +2066,22 @@ window.__ModuleLoader__.load({
|
|
|
1745
2066
|
h(
|
|
1746
2067
|
'span',
|
|
1747
2068
|
{ className: 'dsh-shelves-actions' },
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
2069
|
+
row.archived
|
|
2070
|
+
? null
|
|
2071
|
+
: h(
|
|
2072
|
+
'button',
|
|
2073
|
+
{
|
|
2074
|
+
type: 'button',
|
|
2075
|
+
className: row.pinned ? 'dsh-shelves-action dsh-shelves-action-pinned' : 'dsh-shelves-action',
|
|
2076
|
+
'aria-label': row.pinned ? t('action.unpin') : t('action.pin'),
|
|
2077
|
+
title: row.pinned ? t('action.unpin') : t('action.pin'),
|
|
2078
|
+
onClick: (event) => {
|
|
2079
|
+
event.stopPropagation();
|
|
2080
|
+
togglePin(row);
|
|
2081
|
+
},
|
|
2082
|
+
},
|
|
2083
|
+
glyph('pin', 15),
|
|
2084
|
+
),
|
|
1762
2085
|
h(
|
|
1763
2086
|
'button',
|
|
1764
2087
|
{
|
|
@@ -1809,47 +2132,28 @@ window.__ModuleLoader__.load({
|
|
|
1809
2132
|
'button',
|
|
1810
2133
|
{
|
|
1811
2134
|
type: 'button',
|
|
2135
|
+
ref: settingsGearRef,
|
|
1812
2136
|
className: 'dsh-shelves-gear',
|
|
1813
2137
|
'aria-label': t('settings.label'),
|
|
1814
|
-
'aria-expanded':
|
|
2138
|
+
'aria-expanded': settingsPopover !== null ? 'true' : 'false',
|
|
2139
|
+
'aria-haspopup': 'dialog',
|
|
1815
2140
|
title: t('settings.label'),
|
|
1816
|
-
onClick: () =>
|
|
2141
|
+
onClick: (event) =>
|
|
2142
|
+
settingsPopover === null ? openSettings(event.currentTarget) : setSettingsPopover(null),
|
|
1817
2143
|
},
|
|
1818
2144
|
glyph('gear', 14),
|
|
1819
2145
|
),
|
|
1820
2146
|
),
|
|
1821
2147
|
);
|
|
1822
|
-
if (
|
|
2148
|
+
if (archivedOpen) {
|
|
1823
2149
|
bottom.push(
|
|
1824
2150
|
h(
|
|
1825
2151
|
'div',
|
|
1826
|
-
{ key: '
|
|
1827
|
-
|
|
1828
|
-
h(
|
|
1829
|
-
'div',
|
|
1830
|
-
{ className: 'dsh-shelves-setting' },
|
|
1831
|
-
h('span', null, t('settings.autoArchive')),
|
|
1832
|
-
h(
|
|
1833
|
-
'span',
|
|
1834
|
-
{ className: 'dsh-shelves-select' },
|
|
1835
|
-
h(
|
|
1836
|
-
'select',
|
|
1837
|
-
{
|
|
1838
|
-
'aria-label': t('settings.autoArchive'),
|
|
1839
|
-
value: settings.autoArchiveDays === null ? '' : String(settings.autoArchiveDays),
|
|
1840
|
-
onChange: (event) =>
|
|
1841
|
-
updateSettings({ autoArchiveDays: event.target.value === '' ? null : Number(event.target.value) }),
|
|
1842
|
-
},
|
|
1843
|
-
h('option', { value: '' }, t('settings.off')),
|
|
1844
|
-
AUTO_ARCHIVE_CHOICES.map((days) => h('option', { key: days, value: String(days) }, t('settings.days', { n: days }))),
|
|
1845
|
-
),
|
|
1846
|
-
h('span', { className: 'dsh-shelves-select-chevron' }, glyph('chevron', 12)),
|
|
1847
|
-
),
|
|
1848
|
-
),
|
|
2152
|
+
{ key: 'archived-list', className: 'dsh-shelves-archived-list' },
|
|
2153
|
+
archivedRows.map((row) => renderRow(row)),
|
|
1849
2154
|
),
|
|
1850
2155
|
);
|
|
1851
2156
|
}
|
|
1852
|
-
if (archivedOpen) for (const row of archivedRows) bottom.push(renderRow(row));
|
|
1853
2157
|
|
|
1854
2158
|
stack.push(h('div', { key: 'bottom', className: 'dsh-shelves-bottom' }, bottom));
|
|
1855
2159
|
}
|
|
@@ -1923,6 +2227,43 @@ window.__ModuleLoader__.load({
|
|
|
1923
2227
|
);
|
|
1924
2228
|
};
|
|
1925
2229
|
|
|
2230
|
+
// Anchored above the gear, so opening it never reflows the column.
|
|
2231
|
+
const renderSettingsPopover = () => {
|
|
2232
|
+
if (settingsPopover === null) return null;
|
|
2233
|
+
return h(
|
|
2234
|
+
'div',
|
|
2235
|
+
{
|
|
2236
|
+
className: 'dsh-shelves-settings',
|
|
2237
|
+
style: { left: settingsPopover.left, bottom: settingsPopover.bottom, width: SETTINGS_POPOVER_WIDTH },
|
|
2238
|
+
role: 'dialog',
|
|
2239
|
+
'aria-label': t('settings.label'),
|
|
2240
|
+
},
|
|
2241
|
+
h('div', { className: 'dsh-shelves-settings-title' }, t('settings.label')),
|
|
2242
|
+
h(
|
|
2243
|
+
'div',
|
|
2244
|
+
{ className: 'dsh-shelves-setting' },
|
|
2245
|
+
h('span', null, t('settings.autoArchive')),
|
|
2246
|
+
h(
|
|
2247
|
+
'span',
|
|
2248
|
+
{ className: 'dsh-shelves-select' },
|
|
2249
|
+
h(
|
|
2250
|
+
'select',
|
|
2251
|
+
{
|
|
2252
|
+
'aria-label': t('settings.autoArchive'),
|
|
2253
|
+
autoFocus: true,
|
|
2254
|
+
value: settings.autoArchiveDays === null ? '' : String(settings.autoArchiveDays),
|
|
2255
|
+
onChange: (event) =>
|
|
2256
|
+
updateSettings({ autoArchiveDays: event.target.value === '' ? null : Number(event.target.value) }),
|
|
2257
|
+
},
|
|
2258
|
+
h('option', { value: '' }, t('settings.off')),
|
|
2259
|
+
AUTO_ARCHIVE_CHOICES.map((days) => h('option', { key: days, value: String(days) }, t('settings.days', { n: days }))),
|
|
2260
|
+
),
|
|
2261
|
+
h('span', { className: 'dsh-shelves-select-chevron' }, glyph('chevron', 12)),
|
|
2262
|
+
),
|
|
2263
|
+
),
|
|
2264
|
+
);
|
|
2265
|
+
};
|
|
2266
|
+
|
|
1926
2267
|
return h(
|
|
1927
2268
|
React.Fragment,
|
|
1928
2269
|
null,
|
|
@@ -1932,6 +2273,7 @@ window.__ModuleLoader__.load({
|
|
|
1932
2273
|
{ key: 'root', className: 'dsh-shelves-root' },
|
|
1933
2274
|
h('div', { className: 'dsh-shelves-scroll' }, h('div', { className: 'dsh-shelves-stack' }, stack)),
|
|
1934
2275
|
renderIconPicker(),
|
|
2276
|
+
renderSettingsPopover(),
|
|
1935
2277
|
filePicker === null
|
|
1936
2278
|
? null
|
|
1937
2279
|
: h(FileDialog, {
|
|
@@ -1945,6 +2287,108 @@ window.__ModuleLoader__.load({
|
|
|
1945
2287
|
setFilePicker(null);
|
|
1946
2288
|
},
|
|
1947
2289
|
}),
|
|
2290
|
+
h(Menu, {
|
|
2291
|
+
open: cardMenu !== null,
|
|
2292
|
+
anchor: null,
|
|
2293
|
+
items:
|
|
2294
|
+
cardMenu === null
|
|
2295
|
+
? []
|
|
2296
|
+
: cardMenu.kind === 'project'
|
|
2297
|
+
? projectMenuItems()
|
|
2298
|
+
: cardMenuItems(cardMenu.row),
|
|
2299
|
+
onSelect: selectCardMenuItem,
|
|
2300
|
+
onClose: closeCardMenu,
|
|
2301
|
+
side: 'bottom',
|
|
2302
|
+
portal: true,
|
|
2303
|
+
autoFocus: cardMenu?.keyboard === true,
|
|
2304
|
+
getAnchorRect: cardMenuRect,
|
|
2305
|
+
}),
|
|
2306
|
+
toast === null
|
|
2307
|
+
? null
|
|
2308
|
+
: h(Toast, {
|
|
2309
|
+
key: toast.key,
|
|
2310
|
+
text: toast.text,
|
|
2311
|
+
tone: toast.tone,
|
|
2312
|
+
onDone: () => setToast(null),
|
|
2313
|
+
}),
|
|
2314
|
+
h(
|
|
2315
|
+
Modal,
|
|
2316
|
+
{
|
|
2317
|
+
open: rename !== null,
|
|
2318
|
+
onClose: () => {
|
|
2319
|
+
if (rename === null || rename.busy) return;
|
|
2320
|
+
setRename(null);
|
|
2321
|
+
},
|
|
2322
|
+
closeLabel: t('rename.cancel'),
|
|
2323
|
+
title: t('rename.title'),
|
|
2324
|
+
footer: [
|
|
2325
|
+
h(Button, { key: 'cancel', onClick: () => (rename?.busy ? undefined : setRename(null)) }, t('rename.cancel')),
|
|
2326
|
+
h(
|
|
2327
|
+
Button,
|
|
2328
|
+
{ key: 'confirm', variant: 'primary', disabled: rename?.busy === true, onClick: submitRename },
|
|
2329
|
+
t('rename.confirm'),
|
|
2330
|
+
),
|
|
2331
|
+
],
|
|
2332
|
+
},
|
|
2333
|
+
h(
|
|
2334
|
+
'div',
|
|
2335
|
+
{ className: 'dsh-shelves-rename' },
|
|
2336
|
+
h('input', {
|
|
2337
|
+
type: 'text',
|
|
2338
|
+
value: rename?.draft ?? '',
|
|
2339
|
+
placeholder: t('session.untitled'),
|
|
2340
|
+
autoFocus: true,
|
|
2341
|
+
'aria-label': t('rename.title'),
|
|
2342
|
+
onChange: (event) => {
|
|
2343
|
+
const value = event.target.value;
|
|
2344
|
+
setRename((current) => (current === null ? current : { ...current, draft: value, error: null }));
|
|
2345
|
+
},
|
|
2346
|
+
onKeyDown: (event) => {
|
|
2347
|
+
if (event.key !== 'Enter') return;
|
|
2348
|
+
event.preventDefault();
|
|
2349
|
+
submitRename();
|
|
2350
|
+
},
|
|
2351
|
+
}),
|
|
2352
|
+
rename?.error ? h('div', { className: 'dsh-shelves-rename-error', role: 'alert' }, rename.error) : null,
|
|
2353
|
+
),
|
|
2354
|
+
),
|
|
2355
|
+
h(
|
|
2356
|
+
Modal,
|
|
2357
|
+
{
|
|
2358
|
+
open: removeProject !== null,
|
|
2359
|
+
onClose: () => {
|
|
2360
|
+
if (removeProject === null || removeProject.busy) return;
|
|
2361
|
+
setRemoveProject(null);
|
|
2362
|
+
},
|
|
2363
|
+
closeLabel: t('remove.cancel'),
|
|
2364
|
+
title: t('remove.title'),
|
|
2365
|
+
footer: [
|
|
2366
|
+
h(
|
|
2367
|
+
Button,
|
|
2368
|
+
{ key: 'cancel', onClick: () => (removeProject?.busy ? undefined : setRemoveProject(null)) },
|
|
2369
|
+
t('remove.cancel'),
|
|
2370
|
+
),
|
|
2371
|
+
h(
|
|
2372
|
+
Button,
|
|
2373
|
+
{
|
|
2374
|
+
key: 'confirm',
|
|
2375
|
+
variant: 'outline',
|
|
2376
|
+
className: 'dsh-shelves-danger',
|
|
2377
|
+
disabled: removeProject?.busy === true,
|
|
2378
|
+
onClick: confirmRemoveProject,
|
|
2379
|
+
},
|
|
2380
|
+
t('remove.confirm'),
|
|
2381
|
+
),
|
|
2382
|
+
],
|
|
2383
|
+
},
|
|
2384
|
+
h(
|
|
2385
|
+
'div',
|
|
2386
|
+
{ className: 'dsh-shelves-remove' },
|
|
2387
|
+
h('div', null, t('remove.desc', { name: removeProject?.name ?? '' })),
|
|
2388
|
+
removeProject?.busy ? h('div', { className: 'dsh-shelves-remove-pending', role: 'status' }, t('remove.pending')) : null,
|
|
2389
|
+
removeProject?.error ? h('div', { className: 'dsh-shelves-remove-error', role: 'alert' }, removeProject.error) : null,
|
|
2390
|
+
),
|
|
2391
|
+
),
|
|
1948
2392
|
),
|
|
1949
2393
|
);
|
|
1950
2394
|
}
|
|
@@ -2060,7 +2504,7 @@ window.__ModuleLoader__.load({
|
|
|
2060
2504
|
}
|
|
2061
2505
|
|
|
2062
2506
|
return {
|
|
2063
|
-
inject: ['slots', 'locale', 'uiWorkspace', 'remote', 'remote.workspaceFiles', 'workspaces'],
|
|
2507
|
+
inject: ['slots', 'locale', 'uiWorkspace', 'remote', 'remote.workspaceFiles', 'workspaces', 'sessions'],
|
|
2064
2508
|
apply(ctx) {
|
|
2065
2509
|
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'sidebar-shelves: dictionaries');
|
|
2066
2510
|
const readFileBytes = (sessionId, path, length, signal) =>
|
|
@@ -2075,6 +2519,16 @@ window.__ModuleLoader__.load({
|
|
|
2075
2519
|
openSession: (id) => ctx.uiWorkspace.openSession(id),
|
|
2076
2520
|
archiveSession: (id) => ctx.uiWorkspace.archiveSession(id),
|
|
2077
2521
|
unarchiveSession: (id) => ctx.uiWorkspace.unarchiveSession(id),
|
|
2522
|
+
// Workspace-level removal: unregisters the project, keeps its files and sessions.
|
|
2523
|
+
deleteWorkspace: (workspaceId) => ctx.workspaces.delete(workspaceId),
|
|
2524
|
+
// Same Host paths the native Session menu uses.
|
|
2525
|
+
forkSession: (id) => ctx.uiWorkspace.forkSession(id, undefined, { allowMigration: false }),
|
|
2526
|
+
renameSession: async (id, title) => {
|
|
2527
|
+
const result = await ctx.sessions.using(id, { source: 'workspaceOperation' }, (reference) =>
|
|
2528
|
+
reference.binding.session.rename(title),
|
|
2529
|
+
);
|
|
2530
|
+
if (!result.ok) throw new Error(result.error.message);
|
|
2531
|
+
},
|
|
2078
2532
|
getOpenTabs: () => ctx.get('sidebarRight')?.openTabs,
|
|
2079
2533
|
listFiles: (sessionId, path, signal) => ctx.remote.workspaceFiles.list(sessionId, path, signal),
|
|
2080
2534
|
readFileBytes,
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Sidebar Session Cards",
|
|
4
|
-
"description": "Replaces the sidebar session list with two-line cards: a project icon per workspace (a monogram, an emoji, a square image, or an Icon Composer .icon package), pinning, manual or after-N-days archiving, running and waiting status markers, running background-job and subagent counts, a terminal marker,
|
|
4
|
+
"description": "Replaces the sidebar session list with two-line cards: a project icon per workspace (a monogram, an emoji, a square image, or an Icon Composer .icon package), pinning, manual or after-N-days archiving, running and waiting status markers, running background-job and subagent counts, a terminal marker, automatic sorting by the latest input, a right-click context menu on each card, and a project menu on the tile or name with project removal."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "侧边栏会话卡片",
|
|
4
|
-
"description": "把侧边栏的会话列表换成两行卡片:每个工作区一个项目图标(字母块、emoji、方形图片或 Icon Composer 的 .icon
|
|
4
|
+
"description": "把侧边栏的会话列表换成两行卡片:每个工作区一个项目图标(字母块、emoji、方形图片或 Icon Composer 的 .icon 图标包)、置顶、手动或按天数自动归档、运行与等待状态标记、运行中的后台任务与子代理计数、终端标记,并按最近一次输入自动排序;会话卡片支持右键菜单,项目图标与项目名支持右键管理(含移除项目)。"
|
|
5
5
|
}
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-sidebar-shelves",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Two-line session cards for the DSH sidebar: per-workspace project icons, pinning, archiving, status markers, job counts, and recency sorting",
|
|
5
|
+
"description": "Two-line session cards for the DSH sidebar: per-workspace project icons, pinning, archiving, project removal, status markers, job counts, and recency sorting",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Han (https://github.com/YL404)",
|
|
8
8
|
"repository": {
|