dsh-chat-groups 0.1.2 → 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 (4) hide show
  1. package/client.js +211 -70
  2. package/groups.js +2 -2
  3. package/host.js +1 -1
  4. package/package.json +1 -1
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,19 +73,52 @@ 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
 
72
- function orderedWorkspaceRows(groups, members) {
73
- const entries = (members.get(undefined) ?? []).map(session => ({ session, time: session.updatedAt }))
74
- for (const [groupId, group] of groups) {
75
- const rows = members.get(groupId) ?? []
76
- const time = rows.reduce((latest, session) => Math.max(latest, session.updatedAt), group.createdAt ?? 0)
77
- entries.push({ groupId, group, rows, time })
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 }) }
78
119
  }
79
- return entries.sort((left, right) => right.time - left.time)
120
+ if (status?.completionUnread) return { state: 'done', label: t('status.completed') }
121
+ return undefined
80
122
  }
81
123
 
82
124
  function useSource(source) {
@@ -92,13 +134,115 @@ window.__ModuleLoader__.load({
92
134
  type: 'button', className: 'dsh-chat-groups-label', onClick, ...attributes,
93
135
  }, label)
94
136
 
95
- function iconButton(Icon, label, onClick, disabled) {
96
- 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'] },
97
139
  h('button', {
98
- 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,
99
141
  }, h(Icon, { size: 14, 'aria-hidden': true })))
100
142
  }
101
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
+
102
246
  function RetryIcon() {
103
247
  return h('svg', {
104
248
  viewBox: '0 0 16 16', fill: 'none', stroke: 'currentColor',
@@ -107,7 +251,7 @@ window.__ModuleLoader__.load({
107
251
  }
108
252
 
109
253
  function Dialog({ dialog, pending, error, close, submit, t }) {
110
- const [value, setValue] = useState(dialog.input?.value ?? dialog.choices?.[0]?.[0] ?? '')
254
+ const [value, setValue] = useState(dialog.input?.value ?? '')
111
255
  const blocked = pending || (dialog.input && (!value.trim() || dialog.input.blocked?.(value.trim())))
112
256
  const field = {
113
257
  className: 'dsh-chat-groups-field', 'data-modal-autofocus': true, value, disabled: pending,
@@ -136,10 +280,6 @@ window.__ModuleLoader__.load({
136
280
  }
137
281
  },
138
282
  }),
139
- dialog.choices && h('select', { ...field, 'aria-label': '选择分组' },
140
- dialog.choices.map(([id, name]) => h('option', { key: id, value: id }, name))),
141
- dialog.actions && h('div', { className: 'dsh-chat-groups-menu' },
142
- dialog.actions.map(([label, run]) => h(Button, { key: label, variant: 'outline', onClick: run }, label))),
143
283
  error && h('div', { className: 'dsh-chat-groups-error', role: 'alert' }, error))
144
284
  }
145
285
 
@@ -219,10 +359,11 @@ window.__ModuleLoader__.load({
219
359
 
220
360
  function GroupedSidebar({
221
361
  wide, expandSidebar, useSectionScroller, useContextMenu, useSessionAccess, useWorkspaceAccess,
222
- renderFactorySlot, t,
362
+ renderFactorySlot, useSessionStatus, t,
223
363
  }) {
224
364
  const workspaceList = useSource(workspaces.list)
225
365
  const catalog = useSource(sessions.list)
366
+ const statuses = useSessionStatus(snapshot => snapshot)
226
367
  const generation = useSource(connection.generation)
227
368
  const workspaceAction = useSource(nativeWorkspace.hooks.workspaceActionRequest)
228
369
  const { bindScrollerRef } = useSectionScroller()
@@ -324,19 +465,19 @@ window.__ModuleLoader__.load({
324
465
  })
325
466
  }
326
467
 
327
- async function run(action, fromDialog = false) {
468
+ async function run(action, { close, onError = setStatus } = {}) {
328
469
  if (operation.current) return
329
470
  const { signal } = lifetime.current
330
471
  operation.current = true
331
472
  revision.current += 1
332
473
  setPending(true)
333
474
  setStatus('')
334
- setDialogError('')
475
+ onError('')
335
476
  try {
336
477
  await action(signal)
337
- if (!signal.aborted && fromDialog) closeDialog()
478
+ if (!signal.aborted) close?.()
338
479
  } catch (error) {
339
- if (!signal.aborted) (fromDialog ? setDialogError : setStatus)(message(error))
480
+ if (!signal.aborted) onError(message(error))
340
481
  } finally {
341
482
  operation.current = false
342
483
  if (!signal.aborted) setPending(false)
@@ -352,48 +493,23 @@ window.__ModuleLoader__.load({
352
493
  return change({ action: 'assign', workspaceId, sessionId, groupId }, signal)
353
494
  }
354
495
 
355
- function showName(workspace, groupId, group) {
496
+ function showCreateGroup(workspace) {
356
497
  openDialog({
357
- key: groupId ?? workspace.workspaceId,
358
- title: group ? '重命名分组' : `新增分组 · ${workspaceLabel(workspace.title)}`,
359
- input: { value: group?.name ?? '', maxLength: 80 },
498
+ key: workspace.workspaceId,
499
+ title: `新增分组 · ${workspaceLabel(workspace.title)}`,
500
+ input: { value: '', maxLength: 80 },
360
501
  submit: '保存',
361
- save: (name, signal) => change(group ? {
362
- action: 'rename', workspaceId: workspace.workspaceId, groupId, name,
363
- } : { action: 'create', workspaceId: workspace.workspaceId, name }, signal),
502
+ save: (name, signal) => change({ action: 'create', workspaceId: workspace.workspaceId, name }, signal),
364
503
  })
365
504
  }
366
505
 
367
- function showGroupMenu(workspace, groupId, group, count) {
368
- openDialog({ key: `group:${groupId}`, title: group.name, actions: [
369
- ['重命名分组', () => showName(workspace, groupId, group)],
370
- ['删除分组', () => openDialog({
371
- key: `delete:${groupId}`, title: `删除「${group.name}」?`,
372
- description: `组内可见的 ${count} 条会话将移回「${workspaceLabel(workspace.title)}」。删除分组会保留全部会话。`,
373
- submit: '仅删除分组',
374
- danger: true,
375
- save: async (_, signal) => {
376
- await change({ action: 'delete', workspaceId: workspace.workspaceId, groupId }, signal)
377
- viewFold(setCollapsedGroups, groupId, true)
378
- },
379
- })],
380
- ] })
381
- }
382
-
383
- function adjustSessionGroup(workspaceId, session, groupId, groups) {
384
- const choices = groups.filter(([id]) => id !== groupId).map(([id, group]) => [id, group.name])
385
- if (groupId !== undefined) choices.push(['', '移出分组,返回工作区'])
386
- openDialog({
387
- key: `assign:${session.id}`, title: '调整分组',
388
- ...(choices.length === 0 ? { description: '当前工作区暂无可选分组。' } : {
389
- choices,
390
- description: sessionLabel(session), submit: '确定',
391
- save: async (id, signal) => {
392
- await assign(workspaceId, session.id, id || null, signal)
393
- if (id && !signal.aborted) viewFold(setCollapsedGroups, id, true)
394
- },
395
- }),
396
- })
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
+ }
397
513
  }
398
514
 
399
515
  function createInGroup(workspaceId, groupId, retrySessionId) {
@@ -427,19 +543,32 @@ window.__ModuleLoader__.load({
427
543
  setStatus('会话当前不可打开。')
428
544
  return
429
545
  }
546
+ // DSH clears completionUnread when the session enters the main view.
430
547
  uiWorkspace.openSession(id)
431
548
  }
432
549
 
433
550
  function sessionRow(workspaceId, session, groupId, groups) {
434
551
  const displayTitle = sessionLabel(session)
552
+ const status = sessionRowStatus(session, catalog, statuses, t)
553
+ const titleWithStatus = status ? `${displayTitle} · ${status.label}` : displayTitle
435
554
  const target = session.blank ? undefined : {
436
555
  kind: 'session', value: { sessionId: session.id, displayTitle: session.title?.trim() ?? '' },
437
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
+ }
438
562
  return h('div', {
439
563
  key: session.id, className: 'dsh-chat-groups-row', 'data-session-id': session.id,
440
564
  'aria-current': session.id === active ? 'true' : undefined, ...getTriggerProps(target),
441
565
  },
442
- 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 }),
443
572
  h('span', { className: 'dsh-chat-groups-actions' },
444
573
  target && h('span', { className: 'dsh-chat-groups-native-actions' },
445
574
  renderFactorySlot('contextMenu.button', {
@@ -451,8 +580,15 @@ window.__ModuleLoader__.load({
451
580
  usePinned: hooks.pinned && (selector => selector(useSource(hooks.pinned))),
452
581
  })),
453
582
  ),
454
- iconButton(IconWorkspaceTreeOutlineRegular, `调整「${displayTitle}」的分组`,
455
- () => 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
+ }),
456
592
  ))
457
593
  }
458
594
 
@@ -486,12 +622,13 @@ window.__ModuleLoader__.load({
486
622
  h('span', { className: 'dsh-chat-groups-actions' },
487
623
  h(NativeWorkspaceActions, { target, renderFactorySlot, useWorkspaceAccess, t }),
488
624
  iconButton(IconProjectAddOutlineRegular, `在「${title}」中新增分组`,
489
- () => showName(workspace), pending || data === null),
625
+ () => showCreateGroup(workspace), pending || data === null),
490
626
  ),
491
627
  ),
492
628
  expanded && h('div', { className: 'dsh-chat-groups-branch' },
493
- orderedWorkspaceRows(groups, members).map(({ session, groupId, group, rows }) => {
494
- if (session) return sessionRow(id, session, undefined, groups)
629
+ members.get(undefined)?.map(session => sessionRow(id, session, undefined, groups)),
630
+ groups.map(([groupId, group]) => {
631
+ const rows = members.get(groupId) ?? []
495
632
  const open = !collapsedGroups.has(groupId)
496
633
  const retrySessionId = data.pendingSessions[groupId]
497
634
  return h('section', { key: groupId },
@@ -502,8 +639,12 @@ window.__ModuleLoader__.load({
502
639
  iconButton(retrySessionId ? RetryIcon : IconNewChatOutlineRegular,
503
640
  retrySessionId ? `重试保存到${group.name}` : `在${group.name}新建会话`,
504
641
  () => createInGroup(id, groupId, retrySessionId), pending),
505
- iconButton(IconEllipsisOutlineRegular, `${group.name}的操作`,
506
- () => 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
+ }),
507
648
  ),
508
649
  ),
509
650
  open && h('div', { className: 'dsh-chat-groups-branch' }, rows.length
@@ -527,7 +668,7 @@ window.__ModuleLoader__.load({
527
668
  ),
528
669
  dialog && h(Dialog, { key: dialog.key, dialog, pending, error: dialogError, t,
529
670
  close: closeDialog,
530
- 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 }) },
531
672
  }),
532
673
  )
533
674
  }
package/groups.js CHANGED
@@ -24,14 +24,14 @@ function updateGroups(state, request) {
24
24
  if (action === 'create') {
25
25
  return {
26
26
  ...state,
27
- groups: { ...state.groups, [randomUUID()]: { workspaceId, name: request.name, createdAt: Date.now() } },
27
+ groups: { ...state.groups, [randomUUID()]: { workspaceId, name: request.name } },
28
28
  }
29
29
  }
30
30
  if (groupId !== null) requireGroup(state, workspaceId, groupId)
31
31
  if (action === 'rename') {
32
32
  return {
33
33
  ...state,
34
- groups: { ...state.groups, [groupId]: { ...state.groups[groupId], name: request.name } },
34
+ groups: { ...state.groups, [groupId]: { workspaceId, name: request.name } },
35
35
  }
36
36
  }
37
37
  if (action === 'delete') {
package/host.js CHANGED
@@ -7,7 +7,7 @@ import { createGroupOperations, emptyGroups, GroupError } from './groups.js'
7
7
  const id = z.string().min(1).max(256)
8
8
  const nameSchema = z.string().trim().min(1).max(80)
9
9
  const stateSchema = z.object({
10
- groups: z.record(z.uuid(), z.object({ workspaceId: id, name: nameSchema, createdAt: z.number().int().nonnegative().optional() })),
10
+ groups: z.record(z.uuid(), z.object({ workspaceId: id, name: nameSchema })),
11
11
  membership: z.record(id, z.uuid()),
12
12
  pendingSessions: z.record(z.uuid(), id).default({}),
13
13
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-chat-groups",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "在 DSH 工作区内按任务整理会话",
6
6
  "main": "./host.js",