dsh-chat-groups 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +10 -19
  2. package/client.js +211 -61
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,32 +1,23 @@
1
1
  # dsh-chat-groups
2
2
 
3
- 在 DeepSeek Harness(DSH)工作区内按任务整理会话。分组由 Host 保存。会话标题、归档和对话内容仍由 DSH 管理。
3
+ 在 DeepSeek Harness(DSH)的侧栏中按任务整理会话:可创建分组、把会话加入/移动分组、在分组内新建会话。分组数据由 Host 保存,停用插件后恢复原生侧栏且数据保留。
4
4
 
5
- ## 安装与停用
5
+ ## 安装
6
6
 
7
- 已在 macOS 的 DSH Web `0.2.2-rc.5` 验证。可在仓库根目录或插件目录运行以下命令,将 Bundle 安装到 `web` profile。
7
+ ### Web
8
+
9
+ 在仓库根目录或插件目录运行:
8
10
 
9
11
  ```sh
10
12
  dsh plugin --profile web add "$(git rev-parse --show-toplevel)/dsh-chat-groups"
11
13
  dsh web
12
14
  ```
13
15
 
14
- 启动后,展开左侧栏,点工作区工具栏「添加工作区」右侧的「切换到会话分组视图」图标。点「返回默认视图」可回到原生工作区列表。要停用整个 Bundle,在 DSH 的「插件」页面关闭 `dsh-chat-groups`。停用会恢复原生侧栏并保留分组数据。启用了配置热重载的 profile 会立即应用停用,其他 profile 在重启后应用。
15
-
16
- ## 使用
17
-
18
- 将鼠标移到工作区、会话或分组行上,即可显示该行的操作图标。
19
-
20
- - 点工作区行末的「新增分组」图标。可以折叠、重命名或删除分组。确认删除后,成员会回到工作区直属列表,会话仍可打开。
21
- - 点会话行末的「调整分组」图标加入分组、移到同一工作区的其他组,或移回直属列表。工作区和会话各自保留原生操作。点击会话会打开 DSH 原生对话。
22
- - 点组旁的「新建会话」图标创建原生会话。工作区挂接或分组归属保存失败时,可点「重试保存」图标。刷新页面后重新进入分组视图,仍可继续处理同一条会话。
23
-
24
- 第一版的分组功能向 DSH Host 所有者开放。归档会话可以在默认视图里管理。
25
-
26
- ## 验收
16
+ ### Desktop
27
17
 
28
- 运行 `npm --prefix dsh-chat-groups test` 执行 10 项数据规则测试。
18
+ 在 DSH 的「插件」页面点「添加插件」:
29
19
 
30
- 在隔离的 DSH Web `0.2.2-rc.5` profile 安装真实 Bundle 后,验证了侧栏往返、会话加入/移动/移出、组内新建、取消和确认删除非空组、跨工作区拒绝、归档与失效会话过滤、Host 重启后保留分组,以及停用后恢复原生列表和搜索快捷键并保留当前会话。另模拟一次原生工作区挂接失败,确认刷新后仍能用原会话 ID 完成重试。分组归属写入失败由单元测试覆盖。Desktop 图形界面尚未单独验收。
20
+ - 输入插件包名 `dsh-chat-groups` 或 GitHub 仓库地址 `https://github.com/jiangliuhong/dsh-plugins` 进行安装;
21
+ - 或选择本地 `dsh-chat-groups` 目录进行安装。
31
22
 
32
- [初版离线交互原型](docs/prototype.html)可直接在浏览器中打开,用于查看分组操作。
23
+ 启动后在侧栏工作区工具栏点「切换到会话分组视图」即可使用;点「返回默认视图」回到原生列表。要停用,在 DSH「插件」页面关闭 `dsh-chat-groups`。
package/client.js CHANGED
@@ -2,10 +2,13 @@
2
2
  window.__ModuleLoader__.load({
3
3
  id: 'dsh-chat-groups',
4
4
  factory(require) {
5
- const { createElement: h, Fragment, useCallback, useEffect, useRef, useState, useSyncExternalStore } = require('react')
5
+ const {
6
+ createElement: h, Fragment, useCallback, useEffect, useId, useLayoutEffect, useRef, useState, useSyncExternalStore,
7
+ } = require('react')
6
8
  const { createPortal } = require('react-dom')
7
9
  const {
8
- Button, Modal, Tooltip, IconEllipsisOutlineRegular, IconFlatListOutlineRegular,
10
+ Button, Menu, MenuSurface, Modal, Tooltip, useDismissOnOutsidePointer,
11
+ IconEditOutlineRegular, IconEllipsisOutlineRegular, IconFlatListOutlineRegular, IconTrashOutlineRegular,
9
12
  IconFolderCloseRegular, IconFolderOpenRegular,
10
13
  IconNewChatOutlineRegular, IconProjectAddOutlineRegular, IconWorkspaceTreeOutlineRegular,
11
14
  } = require('@deepseek-ai/dsh-client-ui-primitives')
@@ -46,6 +49,12 @@ window.__ModuleLoader__.load({
46
49
  .dsh-chat-groups-row > .dsh-chat-groups-label { flex: 1; min-width: 0; display: flex; align-items: center; gap: 5px; }
47
50
  .dsh-chat-groups-label > svg { flex: none; }
48
51
  .dsh-chat-groups-label > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
52
+ .dsh-chat-groups-status-dot { box-sizing: border-box; flex: none; width: 8px; height: 8px; border-radius: 50%; }
53
+ .dsh-chat-groups-status-dot[data-state=warning] {
54
+ border-radius: 2px; background: var(--dsw-alias-state-warn-primary); transform: rotate(45deg) scale(.8);
55
+ }
56
+ .dsh-chat-groups-status-dot[data-state=ongoing] { border: 2px solid var(--dsw-alias-state-business-primary); }
57
+ .dsh-chat-groups-status-dot[data-state=done] { background: var(--dsw-alias-state-done-primary); }
49
58
  .dsh-chat-groups-actions { flex: none; display: flex; align-items: center; gap: 5px; padding-inline-end: 3px; }
50
59
  .dsh-chat-groups-icon { flex: none; display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; padding: 0; color: var(--dsw-alias-label-tertiary); }
51
60
  .dsh-chat-groups-icon svg { width: 14px; height: 14px; }
@@ -54,7 +63,7 @@ window.__ModuleLoader__.load({
54
63
  .dsh-chat-groups-note { margin: 3px 8px; opacity: .8; overflow-wrap: anywhere; }
55
64
  @media (hover: hover) {
56
65
  .dsh-chat-groups-row > .dsh-chat-groups-actions { display: none; }
57
- .dsh-chat-groups-row:is(:hover, :has(button[aria-haspopup=menu][aria-expanded=true])) > .dsh-chat-groups-actions,
66
+ .dsh-chat-groups-row:is(:hover, :has(button[aria-haspopup][aria-expanded=true])) > .dsh-chat-groups-actions,
58
67
  html[data-input-modality='keyboard'] .dsh-chat-groups-row:focus-within > .dsh-chat-groups-actions { display: flex; }
59
68
  }
60
69
  .dsh-chat-groups-field {
@@ -64,11 +73,54 @@ window.__ModuleLoader__.load({
64
73
  font-size: 14px; line-height: 22px;
65
74
  }
66
75
  .dsh-chat-groups-field:focus { outline: 1px solid var(--dsw-focus-ring-color, currentColor); }
67
- .dsh-chat-groups-menu { display: grid; gap: 8px; }
76
+ .dsh-chat-groups-popover {
77
+ position: fixed; inset: calc(anchor(bottom) + 4px) 8px 8px max(8px, anchor(left));
78
+ position-try-fallbacks: --dsh-chat-groups-above, --dsh-chat-groups-end, --dsh-chat-groups-above-end;
79
+ align-self: start; justify-self: start; z-index: 1100;
80
+ box-sizing: border-box; width: min(280px, calc(100vw - 16px)); max-height: calc(100dvh - 16px);
81
+ overflow: auto; padding: 12px;
82
+ }
83
+ @position-try --dsh-chat-groups-above {
84
+ top: 8px; bottom: calc(anchor(top) + 4px); align-self: end;
85
+ }
86
+ @position-try --dsh-chat-groups-end {
87
+ left: 8px; right: max(8px, anchor(right)); justify-self: end;
88
+ }
89
+ @position-try --dsh-chat-groups-above-end {
90
+ top: 8px; bottom: calc(anchor(top) + 4px); align-self: end;
91
+ left: 8px; right: max(8px, anchor(right)); justify-self: end;
92
+ }
93
+ .dsh-chat-groups-popover form { display: grid; gap: 10px; font-size: 13px; overflow-wrap: anywhere; }
94
+ .dsh-chat-groups-popover form p { margin: 0; }
95
+ .dsh-chat-groups-popover .dsh-chat-groups-field { height: 32px; padding: 4px 8px; font-size: inherit; }
96
+ .dsh-chat-groups-popover-footer { display: flex; justify-content: flex-end; gap: 6px; }
68
97
  .dsh-chat-groups-error { margin-top: 8px; font-size: 12px; color: var(--dsw-alias-state-error-primary); }
69
98
  .dsh-chat-groups-danger:not(:disabled) { color: var(--dsw-alias-state-error-primary); }
70
99
  `
71
100
 
101
+ const pendingStatusLabel = new Map([
102
+ ['approval', 'status.waitingApproval'],
103
+ ['plan-review', 'status.planReview'],
104
+ ['question', 'status.waitingAnswer'],
105
+ ])
106
+
107
+ function sessionRowStatus(session, catalog, statuses, t) {
108
+ if (session.blank) return undefined
109
+ const status = statuses.get(session.id)
110
+ const pending = pendingStatusLabel.get(status?.pendingInteraction?.kind)
111
+ if (pending !== undefined) return { state: 'warning', label: t(pending) }
112
+ if (status?.running ?? session.running) return { state: 'ongoing', label: t('status.running') }
113
+
114
+ const children = catalog.projectionsBySession[session.id]?.values.subagentCatalog ?? []
115
+ const runningChildren = children.filter(({ id }) => statuses.get(id)?.running ?? catalog.byId[id]?.running).length
116
+ if (runningChildren > 0) {
117
+ const key = runningChildren === 1 ? 'status.subagentsRunning.one' : 'status.subagentsRunning.other'
118
+ return { state: 'ongoing', label: t(key, { n: runningChildren }) }
119
+ }
120
+ if (status?.completionUnread) return { state: 'done', label: t('status.completed') }
121
+ return undefined
122
+ }
123
+
72
124
  function useSource(source) {
73
125
  return useSyncExternalStore(
74
126
  useCallback(listener => source.subscribe(listener), [source]),
@@ -82,13 +134,115 @@ window.__ModuleLoader__.load({
82
134
  type: 'button', className: 'dsh-chat-groups-label', onClick, ...attributes,
83
135
  }, label)
84
136
 
85
- function iconButton(Icon, label, onClick, disabled) {
86
- return h(Tooltip, { label, side: 'bottom', align: 'end', delayMs: 500, portal: true },
137
+ function iconButton(Icon, label, onClick, disabled, attributes = {}) {
138
+ return h(Tooltip, { label, side: 'bottom', align: 'end', delayMs: 500, portal: true, disabled: attributes['aria-expanded'] },
87
139
  h('button', {
88
- type: 'button', className: 'dsh-chat-groups-icon', 'aria-label': label, onClick, disabled,
140
+ type: 'button', className: 'dsh-chat-groups-icon', 'aria-label': label, onClick, disabled, ...attributes,
89
141
  }, h(Icon, { size: 14, 'aria-hidden': true })))
90
142
  }
91
143
 
144
+ function ActionMenu({ Icon, label, disabled, items, onSelect, panel, triggerRef, anchorName }) {
145
+ const [open, setOpen] = useState(false)
146
+ return h(Menu, {
147
+ open, items, portal: true, autoFocus: true, contextual: true,
148
+ onClose: () => setOpen(false),
149
+ onSelect(id) {
150
+ setOpen(false)
151
+ onSelect(id)
152
+ },
153
+ anchor: iconButton(Icon, label, event => {
154
+ event.stopPropagation()
155
+ event.currentTarget.focus({ preventScroll: true })
156
+ if (panel) panel.close()
157
+ else setOpen(!open)
158
+ }, disabled && !panel, {
159
+ ref: triggerRef,
160
+ style: anchorName ? { anchorName } : undefined,
161
+ 'aria-haspopup': panel ? 'dialog' : 'menu',
162
+ 'aria-expanded': open || !!panel,
163
+ 'aria-controls': panel?.id,
164
+ }),
165
+ })
166
+ }
167
+
168
+ const groupActions = [
169
+ { id: 'rename', label: '重命名分组', icon: h(IconEditOutlineRegular, { size: 14 }) },
170
+ { id: 'delete', label: '删除分组', icon: h(IconTrashOutlineRegular, { size: 14 }), danger: true },
171
+ ]
172
+
173
+ function GroupActionPanel({ id, anchorName, trigger, action, groupName, description, pending, close, save, error, t }) {
174
+ const [name, setName] = useState(groupName)
175
+ const surface = useRef(null)
176
+ const focusTarget = useRef(null)
177
+ const rename = action === 'rename'
178
+ const title = rename ? '重命名分组' : `删除「${groupName}」?`
179
+ const blocked = pending || (rename && (!name.trim() || name.trim() === groupName))
180
+ useDismissOnOutsidePointer(trigger, true, () => close(false), surface)
181
+ useLayoutEffect(() => {
182
+ focusTarget.current.focus({ preventScroll: true })
183
+ if (rename) focusTarget.current.select()
184
+ }, [rename])
185
+ return createPortal(h(MenuSurface, {
186
+ ref: surface, id, role: 'dialog', 'aria-label': title,
187
+ className: 'dsh-chat-groups-popover', style: { positionAnchor: anchorName },
188
+ onKeyDown(event) {
189
+ if (event.key === 'Escape' && !event.nativeEvent.isComposing && event.keyCode !== 229) {
190
+ event.preventDefault()
191
+ event.stopPropagation()
192
+ close()
193
+ }
194
+ },
195
+ }, h('form', {
196
+ onSubmit(event) {
197
+ event.preventDefault()
198
+ if (!blocked) save(name.trim())
199
+ },
200
+ },
201
+ h('strong', null, title),
202
+ rename ? h('input', {
203
+ ref: focusTarget, className: 'dsh-chat-groups-field', 'aria-label': '分组名称',
204
+ value: name, readOnly: pending, maxLength: 80, onChange: event => setName(event.target.value),
205
+ onKeyDown(event) {
206
+ if (event.key === 'Enter' && (event.nativeEvent.isComposing || event.keyCode === 229)) event.preventDefault()
207
+ },
208
+ }) : h('p', null, description),
209
+ error && h('div', { className: 'dsh-chat-groups-error', role: 'alert' }, error),
210
+ h('div', { className: 'dsh-chat-groups-popover-footer' },
211
+ h(Button, { ref: rename ? undefined : focusTarget, type: 'button', size: 'sm', variant: 'outline',
212
+ disabled: pending, onClick: () => close() }, t('cancel')),
213
+ h(Button, { type: 'submit', size: 'sm', variant: rename ? 'primary' : 'outline', disabled: blocked,
214
+ className: rename ? undefined : 'dsh-chat-groups-danger',
215
+ }, rename ? '保存' : '仅删除分组')),
216
+ )), document.body)
217
+ }
218
+
219
+ function GroupActions({ groupName, description, disabled, run, save, t }) {
220
+ const [action, setAction] = useState(null)
221
+ const [error, setError] = useState('')
222
+ const trigger = useRef(null)
223
+ const id = useId()
224
+ const anchorName = `--dsh-chat-groups-${id.replace(/[^a-zA-Z0-9_-]/g, '')}`
225
+ function dismiss(restoreFocus = true) {
226
+ if (restoreFocus) trigger.current?.focus({ preventScroll: true })
227
+ setAction(null)
228
+ }
229
+ const close = (restoreFocus) => { if (!disabled) dismiss(restoreFocus) }
230
+ return h(Fragment, null,
231
+ h(ActionMenu, {
232
+ Icon: IconEllipsisOutlineRegular, label: `${groupName}的操作`, disabled, items: groupActions,
233
+ triggerRef: trigger, anchorName, panel: action && { id, close },
234
+ onSelect(next) {
235
+ setError('')
236
+ setAction(next)
237
+ },
238
+ }),
239
+ action && h(GroupActionPanel, {
240
+ id, anchorName, trigger, action, groupName, description, pending: disabled, close, error, t,
241
+ save: name => { void run(signal => save(action, name, signal), { close: dismiss, onError: setError }) },
242
+ }),
243
+ )
244
+ }
245
+
92
246
  function RetryIcon() {
93
247
  return h('svg', {
94
248
  viewBox: '0 0 16 16', fill: 'none', stroke: 'currentColor',
@@ -97,7 +251,7 @@ window.__ModuleLoader__.load({
97
251
  }
98
252
 
99
253
  function Dialog({ dialog, pending, error, close, submit, t }) {
100
- const [value, setValue] = useState(dialog.input?.value ?? dialog.choices?.[0]?.[0] ?? '')
254
+ const [value, setValue] = useState(dialog.input?.value ?? '')
101
255
  const blocked = pending || (dialog.input && (!value.trim() || dialog.input.blocked?.(value.trim())))
102
256
  const field = {
103
257
  className: 'dsh-chat-groups-field', 'data-modal-autofocus': true, value, disabled: pending,
@@ -126,10 +280,6 @@ window.__ModuleLoader__.load({
126
280
  }
127
281
  },
128
282
  }),
129
- dialog.choices && h('select', { ...field, 'aria-label': '选择分组' },
130
- dialog.choices.map(([id, name]) => h('option', { key: id, value: id }, name))),
131
- dialog.actions && h('div', { className: 'dsh-chat-groups-menu' },
132
- dialog.actions.map(([label, run]) => h(Button, { key: label, variant: 'outline', onClick: run }, label))),
133
283
  error && h('div', { className: 'dsh-chat-groups-error', role: 'alert' }, error))
134
284
  }
135
285
 
@@ -209,10 +359,11 @@ window.__ModuleLoader__.load({
209
359
 
210
360
  function GroupedSidebar({
211
361
  wide, expandSidebar, useSectionScroller, useContextMenu, useSessionAccess, useWorkspaceAccess,
212
- renderFactorySlot, t,
362
+ renderFactorySlot, useSessionStatus, t,
213
363
  }) {
214
364
  const workspaceList = useSource(workspaces.list)
215
365
  const catalog = useSource(sessions.list)
366
+ const statuses = useSessionStatus(snapshot => snapshot)
216
367
  const generation = useSource(connection.generation)
217
368
  const workspaceAction = useSource(nativeWorkspace.hooks.workspaceActionRequest)
218
369
  const { bindScrollerRef } = useSectionScroller()
@@ -314,19 +465,19 @@ window.__ModuleLoader__.load({
314
465
  })
315
466
  }
316
467
 
317
- async function run(action, fromDialog = false) {
468
+ async function run(action, { close, onError = setStatus } = {}) {
318
469
  if (operation.current) return
319
470
  const { signal } = lifetime.current
320
471
  operation.current = true
321
472
  revision.current += 1
322
473
  setPending(true)
323
474
  setStatus('')
324
- setDialogError('')
475
+ onError('')
325
476
  try {
326
477
  await action(signal)
327
- if (!signal.aborted && fromDialog) closeDialog()
478
+ if (!signal.aborted) close?.()
328
479
  } catch (error) {
329
- if (!signal.aborted) (fromDialog ? setDialogError : setStatus)(message(error))
480
+ if (!signal.aborted) onError(message(error))
330
481
  } finally {
331
482
  operation.current = false
332
483
  if (!signal.aborted) setPending(false)
@@ -342,48 +493,23 @@ window.__ModuleLoader__.load({
342
493
  return change({ action: 'assign', workspaceId, sessionId, groupId }, signal)
343
494
  }
344
495
 
345
- function showName(workspace, groupId, group) {
496
+ function showCreateGroup(workspace) {
346
497
  openDialog({
347
- key: groupId ?? workspace.workspaceId,
348
- title: group ? '重命名分组' : `新增分组 · ${workspaceLabel(workspace.title)}`,
349
- input: { value: group?.name ?? '', maxLength: 80 },
498
+ key: workspace.workspaceId,
499
+ title: `新增分组 · ${workspaceLabel(workspace.title)}`,
500
+ input: { value: '', maxLength: 80 },
350
501
  submit: '保存',
351
- save: (name, signal) => change(group ? {
352
- action: 'rename', workspaceId: workspace.workspaceId, groupId, name,
353
- } : { action: 'create', workspaceId: workspace.workspaceId, name }, signal),
502
+ save: (name, signal) => change({ action: 'create', workspaceId: workspace.workspaceId, name }, signal),
354
503
  })
355
504
  }
356
505
 
357
- function showGroupMenu(workspace, groupId, group, count) {
358
- openDialog({ key: `group:${groupId}`, title: group.name, actions: [
359
- ['重命名分组', () => showName(workspace, groupId, group)],
360
- ['删除分组', () => openDialog({
361
- key: `delete:${groupId}`, title: `删除「${group.name}」?`,
362
- description: `组内可见的 ${count} 条会话将移回「${workspaceLabel(workspace.title)}」。删除分组会保留全部会话。`,
363
- submit: '仅删除分组',
364
- danger: true,
365
- save: async (_, signal) => {
366
- await change({ action: 'delete', workspaceId: workspace.workspaceId, groupId }, signal)
367
- viewFold(setCollapsedGroups, groupId, true)
368
- },
369
- })],
370
- ] })
371
- }
372
-
373
- function adjustSessionGroup(workspaceId, session, groupId, groups) {
374
- const choices = groups.filter(([id]) => id !== groupId).map(([id, group]) => [id, group.name])
375
- if (groupId !== undefined) choices.push(['', '移出分组,返回工作区'])
376
- openDialog({
377
- key: `assign:${session.id}`, title: '调整分组',
378
- ...(choices.length === 0 ? { description: '当前工作区暂无可选分组。' } : {
379
- choices,
380
- description: sessionLabel(session), submit: '确定',
381
- save: async (id, signal) => {
382
- await assign(workspaceId, session.id, id || null, signal)
383
- if (id && !signal.aborted) viewFold(setCollapsedGroups, id, true)
384
- },
385
- }),
386
- })
506
+ async function saveGroup(workspaceId, groupId, action, name, signal) {
507
+ if (action === 'rename') {
508
+ await change({ action, workspaceId, groupId, name }, signal)
509
+ } else {
510
+ await change({ action, workspaceId, groupId }, signal)
511
+ if (!signal.aborted) viewFold(setCollapsedGroups, groupId, true)
512
+ }
387
513
  }
388
514
 
389
515
  function createInGroup(workspaceId, groupId, retrySessionId) {
@@ -417,19 +543,32 @@ window.__ModuleLoader__.load({
417
543
  setStatus('会话当前不可打开。')
418
544
  return
419
545
  }
546
+ // DSH clears completionUnread when the session enters the main view.
420
547
  uiWorkspace.openSession(id)
421
548
  }
422
549
 
423
550
  function sessionRow(workspaceId, session, groupId, groups) {
424
551
  const displayTitle = sessionLabel(session)
552
+ const status = sessionRowStatus(session, catalog, statuses, t)
553
+ const titleWithStatus = status ? `${displayTitle} · ${status.label}` : displayTitle
425
554
  const target = session.blank ? undefined : {
426
555
  kind: 'session', value: { sessionId: session.id, displayTitle: session.title?.trim() ?? '' },
427
556
  }
557
+ const destinations = groups.filter(([id]) => id !== groupId).map(([id, group]) => ({ id, label: group.name }))
558
+ if (groupId !== undefined) {
559
+ if (destinations.length) destinations.push({ type: 'separator', id: 'ungroup-separator' })
560
+ destinations.push({ id: '', label: '移出分组,返回工作区' })
561
+ }
428
562
  return h('div', {
429
563
  key: session.id, className: 'dsh-chat-groups-row', 'data-session-id': session.id,
430
564
  'aria-current': session.id === active ? 'true' : undefined, ...getTriggerProps(target),
431
565
  },
432
- button(h('span', null, displayTitle), () => openSession(session.id), { title: displayTitle }),
566
+ button(h(Fragment, null,
567
+ h('span', {
568
+ className: 'dsh-chat-groups-status-dot', 'data-state': status?.state, 'aria-hidden': true,
569
+ }),
570
+ h('span', null, displayTitle),
571
+ ), () => openSession(session.id), { title: titleWithStatus, 'aria-label': titleWithStatus }),
433
572
  h('span', { className: 'dsh-chat-groups-actions' },
434
573
  target && h('span', { className: 'dsh-chat-groups-native-actions' },
435
574
  renderFactorySlot('contextMenu.button', {
@@ -441,8 +580,15 @@ window.__ModuleLoader__.load({
441
580
  usePinned: hooks.pinned && (selector => selector(useSource(hooks.pinned))),
442
581
  })),
443
582
  ),
444
- iconButton(IconWorkspaceTreeOutlineRegular, `调整「${displayTitle}」的分组`,
445
- () => adjustSessionGroup(workspaceId, session, groupId, groups), pending || data === null),
583
+ h(ActionMenu, {
584
+ Icon: IconWorkspaceTreeOutlineRegular, label: `调整「${displayTitle}」的分组`,
585
+ disabled: pending || data === null,
586
+ items: destinations.length ? destinations : [{ id: 'empty', label: '当前工作区暂无可选分组', disabled: true }],
587
+ onSelect: id => { void run(async signal => {
588
+ await assign(workspaceId, session.id, id || null, signal)
589
+ if (id && !signal.aborted) viewFold(setCollapsedGroups, id, true)
590
+ }) },
591
+ }),
446
592
  ))
447
593
  }
448
594
 
@@ -476,7 +622,7 @@ window.__ModuleLoader__.load({
476
622
  h('span', { className: 'dsh-chat-groups-actions' },
477
623
  h(NativeWorkspaceActions, { target, renderFactorySlot, useWorkspaceAccess, t }),
478
624
  iconButton(IconProjectAddOutlineRegular, `在「${title}」中新增分组`,
479
- () => showName(workspace), pending || data === null),
625
+ () => showCreateGroup(workspace), pending || data === null),
480
626
  ),
481
627
  ),
482
628
  expanded && h('div', { className: 'dsh-chat-groups-branch' },
@@ -493,8 +639,12 @@ window.__ModuleLoader__.load({
493
639
  iconButton(retrySessionId ? RetryIcon : IconNewChatOutlineRegular,
494
640
  retrySessionId ? `重试保存到${group.name}` : `在${group.name}新建会话`,
495
641
  () => createInGroup(id, groupId, retrySessionId), pending),
496
- iconButton(IconEllipsisOutlineRegular, `${group.name}的操作`,
497
- () => showGroupMenu(workspace, groupId, group, rows.length), pending),
642
+ h(GroupActions, {
643
+ groupName: group.name,
644
+ description: `组内可见的 ${rows.length} 条会话将移回「${title}」。删除分组会保留全部会话。`,
645
+ disabled: pending, run, t,
646
+ save: (action, name, signal) => saveGroup(id, groupId, action, name, signal),
647
+ }),
498
648
  ),
499
649
  ),
500
650
  open && h('div', { className: 'dsh-chat-groups-branch' }, rows.length
@@ -518,7 +668,7 @@ window.__ModuleLoader__.load({
518
668
  ),
519
669
  dialog && h(Dialog, { key: dialog.key, dialog, pending, error: dialogError, t,
520
670
  close: closeDialog,
521
- submit: value => { if (dialog.save) void run(signal => dialog.save(value, signal), true) },
671
+ submit: value => { void run(signal => dialog.save(value, signal), { close: closeDialog, onError: setDialogError }) },
522
672
  }),
523
673
  )
524
674
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-chat-groups",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "在 DSH 工作区内按任务整理会话",
6
6
  "main": "./host.js",