dsh-taskbridge 1.7.0 → 1.8.0
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/CHANGELOG.md +18 -0
- package/LICENSE +21 -21
- package/README.md +150 -289
- package/THIRD_PARTY_NOTICES.txt +23 -23
- package/antigravity/agents/dsh-taskbridge.md +31 -0
- package/antigravity/skills/dsh-taskbridge/SKILL.md +51 -0
- package/codex/dsh-taskbridge.toml +170 -627
- package/cordis.patch.yml +6 -6
- package/docs/INTRODUCTION.md +119 -295
- package/docs/INTRODUCTION.zh.md +134 -279
- package/docs/antigravity-integration.md +42 -0
- package/docs/auth-contract.md +138 -138
- package/docs/claude-code.md +6 -11
- package/docs/codex-integration.md +13 -2
- package/docs/contracts-stage-b.md +443 -443
- package/docs/plugin-market.md +30 -30
- package/docs/redaction-contract.md +170 -170
- package/docs/releases/1.7.0.zh.md +11 -11
- package/docs/releases/1.8.0.zh.md +16 -0
- package/docs/runtime-compatibility.md +1 -1
- package/docs/taskbridge-upgrade.md +28 -28
- package/docs/taskdispatch-upgrade.md +25 -25
- package/docs/workspace-contract.md +538 -538
- package/docs/workspace-grouping.md +126 -126
- package/icon.svg +1 -1
- package/lib/client.d.ts +733 -699
- package/lib/client.js +7 -7
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +149 -144
- package/src/antigravity/installer.js +1046 -0
- package/src/antigravity/seam.js +142 -0
- package/src/auth/fence.js +361 -361
- package/src/auth/grants.js +789 -789
- package/src/client/api.js +143 -0
- package/src/client/index.jsx +113 -3
- package/src/client/sidebar.jsx +862 -862
- package/src/client/styles.js +624 -624
- package/src/client/task-cleanup.js +304 -304
- package/src/client/task-records-table.jsx +217 -217
- package/src/client/task-view.js +307 -307
- package/src/client/workspace-groups.js +482 -482
- package/src/client/workspaces-browser.jsx +770 -770
- package/src/codex/agent-ownership.js +270 -270
- package/src/codex/installer.js +6 -0
- package/src/codex/toml.js +784 -784
- package/src/config/redact.js +245 -245
- package/src/config/store.js +186 -186
- package/src/credentials/seam.js +202 -202
- package/src/http/respond.js +6 -5
- package/src/http/user-plane.js +72 -0
- package/src/index.js +25 -0
- package/src/jobs/diagnostics.js +15 -15
- package/src/jobs/plan-store.js +1020 -1020
- package/src/jobs/review-note.js +63 -63
- package/src/jobs/task-descriptions.js +82 -82
- package/src/jobs/task-display.js +73 -73
- package/src/jobs/task-tree.js +786 -786
- package/src/jobs/title.js +134 -134
- package/src/mcp/continuation.js +317 -317
- package/src/mcp/server.js +12 -5
- package/src/model/connectivity.js +371 -371
- package/src/model/discovery.js +582 -582
- package/src/model/native-catalog.js +68 -68
- package/src/model/openai-adapter.js +671 -671
- package/src/model/probe.js +264 -264
- package/src/model/providers.js +756 -756
- package/src/model/routing.js +321 -321
- package/src/runtime/permissions.js +1619 -1619
- package/src/runtime/question-call.js +162 -162
- package/src/runtime/questions.js +909 -909
- package/src/runtime/worker-prompt.js +60 -53
- package/src/workspace/audit.js +775 -775
- package/src/workspace/preflight.js +424 -424
- package/src/workspace/worktrees.js +679 -679
|
@@ -1,770 +1,770 @@
|
|
|
1
|
-
// dsh-delegate — how the TaskBridge section appears in the sidebar's workspace area.
|
|
2
|
-
//
|
|
3
|
-
// WHAT THE HOST ACTUALLY OFFERS (verified in the shipped 0.2.2-rc.5 client bundle)
|
|
4
|
-
// --------------------------------------------------------------------------------
|
|
5
|
-
// `@deepseek-ai/dsh-client-ui-workspace/lib/client.js` registers the workspace browser like this:
|
|
6
|
-
//
|
|
7
|
-
// ctx.slots.inject('sidebar.workspaces', () => ctx.slots.register({
|
|
8
|
-
// name: 'sidebar.workspaces', children: {
|
|
9
|
-
// 'sidebar.workspaces.directoryFlow': { kind: 'single', scope: 'root' },
|
|
10
|
-
// 'sidebar.workspaces.session.row.action': { kind: 'list', scope: 'root' },
|
|
11
|
-
// 'sidebar.session.row.leading': { kind: 'list', scope: 'root', inline: true },
|
|
12
|
-
// 'sidebar.session.row.trailing': { kind: 'list', scope: 'root', inline: true },
|
|
13
|
-
// 'sidebar.session.row.hover': { kind: 'list', scope: 'root' },
|
|
14
|
-
// }, ... }, WorkspaceBrowser))
|
|
15
|
-
//
|
|
16
|
-
// So the region is a SINGLE slot with no published way to render a sibling section above the
|
|
17
|
-
// shipped browser, and its rows are the host's own. What IS published, and what this plugin
|
|
18
|
-
// uses, is the set of CHILD slots:
|
|
19
|
-
//
|
|
20
|
-
// * `sidebar.workspaces.session.row.action` — a list rendered INSIDE every native session row,
|
|
21
|
-
// next to the host's own archive/pin buttons. This is the supported seam for a per-session
|
|
22
|
-
// affordance and it never replaces a native row;
|
|
23
|
-
// * `sidebar.session.row.leading` / `.trailing` / `.hover` — inline material for a row.
|
|
24
|
-
//
|
|
25
|
-
// The consequence for the requirement is stated plainly in `docs/workspace-grouping.md`: a
|
|
26
|
-
// vertical section ABOVE the native browser, inside the same cell, is not expressible through a
|
|
27
|
-
// published slot. This module therefore does NOT take the region over (the earlier build did,
|
|
28
|
-
// which is why the native rows disappeared from an acceptance run). Instead it:
|
|
29
|
-
//
|
|
30
|
-
// 1. keeps the shipped browser exactly as the host renders it — its names, order, search,
|
|
31
|
-
// menus, actions — by *not registering on `sidebar.workspaces` at all* from `apply()`;
|
|
32
|
-
// 2. annotates each native session row through the published row-action slot with a TaskBridge
|
|
33
|
-
// marker for conversations this plugin dispatched (proven by the identity map), so an
|
|
34
|
-
// operator can tell them apart in the native tree without a second tree;
|
|
35
|
-
// 3. offers the TaskBridge grouping — TaskBridge → 任务工作区 → 对话, one row per dispatched
|
|
36
|
-
// chain — through the plugin's own surfaces, where it can be rendered safely and completely:
|
|
37
|
-
// the task records page (`delegate records`) and its existing content panel. Those are this
|
|
38
|
-
// plugin's own slots, so the grouping costs the host nothing and cannot disturb a native row.
|
|
39
|
-
//
|
|
40
|
-
// Nothing here patches the DOM, imports a host package, reads a React private field, or invents a
|
|
41
|
-
// Workspace/path. A row's identity is its real `(workspaceId, sessionId)` pair, and every action
|
|
42
|
-
// goes through an official service with those real ids.
|
|
43
|
-
|
|
44
|
-
import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
45
|
-
|
|
46
|
-
import { createApi } from './api.js';
|
|
47
|
-
import {
|
|
48
|
-
GROUP_KINDS,
|
|
49
|
-
readWorkspacesSnapshot,
|
|
50
|
-
sessionIndex,
|
|
51
|
-
workspaceGroups,
|
|
52
|
-
} from './workspace-groups.js';
|
|
53
|
-
|
|
54
|
-
/** The host's singleton slot for its own workspace/session browser. */
|
|
55
|
-
export const WORKSPACES_SLOT = 'sidebar.workspaces';
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* The published CHILD slot the host renders inside every native session row. This is the seam
|
|
59
|
-
* this plugin uses for a per-row affordance; the parent slot itself is never registered on.
|
|
60
|
-
*/
|
|
61
|
-
export const SESSION_ROW_ACTION_SLOT = 'sidebar.workspaces.session.row.action';
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* The plugin's row marker: placed AFTER the host's own actions (the host's are 100 = archive and
|
|
65
|
-
* 200 = pin), so it never comes between the operator and a native control.
|
|
66
|
-
*/
|
|
67
|
-
export const SESSION_ROW_ACTION_ORDER = 900;
|
|
68
|
-
|
|
69
|
-
/** The id of this plugin's row-action registration, namespaced against other plugins. */
|
|
70
|
-
export const SESSION_ROW_ACTION_ID = 'dsh-taskbridge:dispatched';
|
|
71
|
-
|
|
72
|
-
/** How the plugin's own grouping can present itself. */
|
|
73
|
-
export const WORKSPACE_VIEWS = Object.freeze({
|
|
74
|
-
/** Conversations this plugin dispatched were proven: the grouping is shown. */
|
|
75
|
-
grouped: 'grouped',
|
|
76
|
-
/** Nothing proven: the grouping is not invented. */
|
|
77
|
-
passthrough: 'passthrough',
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
/** How many times one mount may re-read the identity map after a record showed a new placement. */
|
|
81
|
-
const IDENTITY_REFRESH_LIMIT = 2;
|
|
82
|
-
|
|
83
|
-
/** The session id a row is rendered with: shortened, never guessed. */
|
|
84
|
-
export function shortId(sessionId) {
|
|
85
|
-
if (typeof sessionId !== 'string' || sessionId === '') return '';
|
|
86
|
-
return sessionId.length <= 14 ? sessionId : `${sessionId.slice(0, 8)}…${sessionId.slice(-4)}`;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Resolve one host service lazily. An absent service is a capability gap, never an error.
|
|
91
|
-
* @param {object | null | undefined} ctx - client context.
|
|
92
|
-
* @param {string} name - service name.
|
|
93
|
-
* @returns {object | null} the service, or null.
|
|
94
|
-
*/
|
|
95
|
-
export function hostService(ctx, name) {
|
|
96
|
-
const get = ctx !== null && typeof ctx === 'object' ? ctx.get : null;
|
|
97
|
-
if (typeof get !== 'function') return null;
|
|
98
|
-
try {
|
|
99
|
-
const service = get.call(ctx, name);
|
|
100
|
-
return service !== null && typeof service === 'object' ? service : null;
|
|
101
|
-
} catch {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** The object carrying the shell's dialogs (`window` when there is one). */
|
|
107
|
-
function shellDialog() {
|
|
108
|
-
const shell = globalThis.window ?? null;
|
|
109
|
-
return shell !== null && typeof shell === 'object' ? shell : globalThis;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Ask the operator for one line of text, or answer null. A host without `prompt` answers null.
|
|
114
|
-
* @param {string} message - the question.
|
|
115
|
-
* @param {string} initial - the current value.
|
|
116
|
-
* @param {object} [shell] - the object carrying the dialog.
|
|
117
|
-
* @returns {string | null} the operator's text, or null.
|
|
118
|
-
*/
|
|
119
|
-
export function askText(message, initial, shell = undefined) {
|
|
120
|
-
const host = shell ?? shellDialog();
|
|
121
|
-
const ask = typeof host?.prompt === 'function' ? host.prompt : null;
|
|
122
|
-
if (ask === null) return null;
|
|
123
|
-
try {
|
|
124
|
-
return ask.call(host, message, initial);
|
|
125
|
-
} catch {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Ask the operator to confirm one destructive action. A host without `confirm` answers NO.
|
|
132
|
-
* @param {string} message - the question.
|
|
133
|
-
* @param {object} [shell] - the object carrying the dialog.
|
|
134
|
-
* @returns {boolean} the operator's answer.
|
|
135
|
-
*/
|
|
136
|
-
export function askConfirm(message, shell = undefined) {
|
|
137
|
-
const host = shell ?? shellDialog();
|
|
138
|
-
const ask = typeof host?.confirm === 'function' ? host.confirm : null;
|
|
139
|
-
if (ask === null) return false;
|
|
140
|
-
try {
|
|
141
|
-
return ask.call(host, message) === true;
|
|
142
|
-
} catch {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Register the per-session row marker into the host's published child slot.
|
|
149
|
-
*
|
|
150
|
-
* This is deliberately the ONLY thing this module does to the shell's workspace region: the
|
|
151
|
-
* parent slot stays the host's, so every native row, name, order, search box, menu and action is
|
|
152
|
-
* exactly as shipped. A host that does not declare the child slot simply never runs this.
|
|
153
|
-
* @param {object} ctx - client Cordis context.
|
|
154
|
-
* @param {object} [options] - `store` (the page store), `sessionMap` (an identity loader), `api`.
|
|
155
|
-
* @returns {() => void} disposer releasing the registration.
|
|
156
|
-
*/
|
|
157
|
-
export function registerSessionRowMarker(ctx, options = {}) {
|
|
158
|
-
const slots = ctx?.slots;
|
|
159
|
-
if (slots === null || slots === undefined || typeof slots.inject !== 'function') return () => {};
|
|
160
|
-
const store = options.store ?? null;
|
|
161
|
-
const api = options.api ?? createApi();
|
|
162
|
-
const loadIdentity = typeof options.sessionMap === 'function' ? options.sessionMap : () => loadSessionMap(api);
|
|
163
|
-
const services = {
|
|
164
|
-
workspaces: () => hostService(ctx, 'workspaces'),
|
|
165
|
-
uiWorkspace: () => hostService(ctx, 'uiWorkspace'),
|
|
166
|
-
};
|
|
167
|
-
const rowProps = Object.freeze({ store, services, loadIdentity });
|
|
168
|
-
const Marker = (props) => DispatchedSessionMarker({ ...props, ...rowProps });
|
|
169
|
-
|
|
170
|
-
try {
|
|
171
|
-
return slots.inject(SESSION_ROW_ACTION_SLOT, () => slots.register({
|
|
172
|
-
name: SESSION_ROW_ACTION_SLOT,
|
|
173
|
-
id: SESSION_ROW_ACTION_ID,
|
|
174
|
-
order: SESSION_ROW_ACTION_ORDER,
|
|
175
|
-
}, Marker));
|
|
176
|
-
} catch {
|
|
177
|
-
return () => {};
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/** @deprecated Removed: this plugin no longer registers on `sidebar.workspaces` itself. */
|
|
182
|
-
export function registerWorkspacesBrowser() {
|
|
183
|
-
return () => {};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/** @deprecated The region is the host's; kept only so an older import resolves. */
|
|
187
|
-
export const WORKSPACES_PRIORITY = -200;
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Read the plugin's identity map from the operator plane. A refusal answers an empty list.
|
|
191
|
-
* @param {object} api - user-plane transport.
|
|
192
|
-
* @returns {Promise<object[]>} identity rows (possibly empty).
|
|
193
|
-
*/
|
|
194
|
-
export async function loadSessionMap(api) {
|
|
195
|
-
try {
|
|
196
|
-
const body = await api.getSessionMap();
|
|
197
|
-
return Array.isArray(body?.sessions) ? body.sessions : [];
|
|
198
|
-
} catch {
|
|
199
|
-
return [];
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* A stable snapshot from a host source, safe for `useSyncExternalStore`.
|
|
205
|
-
* @param {object | null} snapshot - raw host snapshot.
|
|
206
|
-
* @param {{ key: string | null, value: object | null }} [cache] - the caller's cache slot.
|
|
207
|
-
* @returns {object | null} stable snapshot.
|
|
208
|
-
*/
|
|
209
|
-
export function stableSnapshot(snapshot, cache = { key: null, value: null }) {
|
|
210
|
-
if (snapshot === null || typeof snapshot !== 'object') return null;
|
|
211
|
-
const key = JSON.stringify({
|
|
212
|
-
phase: snapshot.phase ?? null,
|
|
213
|
-
items: (Array.isArray(snapshot.items) ? snapshot.items : []).map((item) => [
|
|
214
|
-
item?.workspaceId ?? null, item?.title ?? null, item?.path ?? null,
|
|
215
|
-
Array.isArray(item?.sessionIds) ? item.sessionIds : [],
|
|
216
|
-
]),
|
|
217
|
-
archived: Array.isArray(snapshot.archivedSessionIds) ? snapshot.archivedSessionIds : [],
|
|
218
|
-
ungrouped: Array.isArray(snapshot.ungroupedSessionIds) ? snapshot.ungroupedSessionIds : [],
|
|
219
|
-
});
|
|
220
|
-
if (cache.key === key && cache.value !== null) return cache.value;
|
|
221
|
-
cache.key = key;
|
|
222
|
-
cache.value = snapshot;
|
|
223
|
-
return snapshot;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Which presentation the plugin's own grouping calls for.
|
|
228
|
-
* @param {object} input - `ownCount`.
|
|
229
|
-
* @returns {'grouped'|'passthrough'} the mode.
|
|
230
|
-
*/
|
|
231
|
-
export function workspacesViewMode(input = {}) {
|
|
232
|
-
return typeof input.ownCount === 'number' && input.ownCount > 0
|
|
233
|
-
? WORKSPACE_VIEWS.grouped
|
|
234
|
-
: WORKSPACE_VIEWS.passthrough;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* The identity map narrowed to a session → proof lookup, memoised by content.
|
|
239
|
-
*
|
|
240
|
-
* The row marker receives only a `sessionId` from the host, so it needs the map (read once) plus
|
|
241
|
-
* the task records (which also prove a NEW dispatch). Both are turned into one lookup here.
|
|
242
|
-
* @param {object[] | null} identities - `/session-map` rows, or null while unread.
|
|
243
|
-
* @param {object[]} tasks - `/tasks` rows.
|
|
244
|
-
* @returns {{ bySession: Map<string, object>, ready: boolean }} the lookup.
|
|
245
|
-
*/
|
|
246
|
-
export function dispatchProof(identities, tasks) {
|
|
247
|
-
const records = sessionIndex(tasks);
|
|
248
|
-
const bySession = new Map();
|
|
249
|
-
// The record list also carries TITLES, and a title is display evidence, not placement: a
|
|
250
|
-
// session named by a record with no Workspace still tells the marker what it is called.
|
|
251
|
-
for (const [sessionId, title] of records.titles) bySession.set(sessionId, { sessionId, title });
|
|
252
|
-
for (const row of identities ?? []) {
|
|
253
|
-
if (row === null || typeof row !== 'object') continue;
|
|
254
|
-
const sessionId = typeof row.sessionId === 'string' ? row.sessionId.trim() : '';
|
|
255
|
-
if (sessionId === '') continue;
|
|
256
|
-
const previous = bySession.get(sessionId);
|
|
257
|
-
bySession.set(sessionId, { ...previous, ...row });
|
|
258
|
-
}
|
|
259
|
-
for (const [sessionId, pair] of records.pairs) {
|
|
260
|
-
const previous = bySession.get(sessionId);
|
|
261
|
-
bySession.set(sessionId, { ...previous, ...pair });
|
|
262
|
-
}
|
|
263
|
-
return { bySession, ready: identities !== null };
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// ---------------------------------------------------------------------------
|
|
267
|
-
// The per-row marker
|
|
268
|
-
// ---------------------------------------------------------------------------
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* The marker the host renders inside one native session row.
|
|
272
|
-
*
|
|
273
|
-
* It is additive and quiet: a small badge naming the isolation ("派工" for a shared run, "派工·
|
|
274
|
-
* 隔离" for a worktree run), with the TaskBridge title as its tooltip. A session this plugin did
|
|
275
|
-
* not dispatch renders NOTHING, so the native row is unchanged.
|
|
276
|
-
* @param {object} props - the slot's own props (`sessionId` among them) plus the injection.
|
|
277
|
-
* @returns {object | null} the badge, or null.
|
|
278
|
-
*/
|
|
279
|
-
export function DispatchedSessionMarker(props) {
|
|
280
|
-
const sessionId = typeof props?.sessionId === 'string' ? props.sessionId.trim() : '';
|
|
281
|
-
if (sessionId === '') return null;
|
|
282
|
-
const store = props?.store ?? null;
|
|
283
|
-
|
|
284
|
-
const [identities, setIdentities] = useState(null);
|
|
285
|
-
const identityLoader = useRef(props?.loadIdentity);
|
|
286
|
-
if (typeof props?.loadIdentity === 'function') identityLoader.current = props.loadIdentity;
|
|
287
|
-
useEffect(() => {
|
|
288
|
-
let live = true;
|
|
289
|
-
(async () => {
|
|
290
|
-
try {
|
|
291
|
-
const rows = await identityLoader.current?.();
|
|
292
|
-
if (live) setIdentities(Array.isArray(rows) ? rows : []);
|
|
293
|
-
} catch {
|
|
294
|
-
if (live) setIdentities([]);
|
|
295
|
-
}
|
|
296
|
-
})();
|
|
297
|
-
return () => { live = false; };
|
|
298
|
-
// The mount read is the point of this effect.
|
|
299
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
300
|
-
}, []);
|
|
301
|
-
|
|
302
|
-
const emptyRecords = useRef({ tasks: [] });
|
|
303
|
-
const recordCache = useRef({ key: '', value: emptyRecords.current });
|
|
304
|
-
const getRecords = useCallback(() => {
|
|
305
|
-
const raw = typeof store?.getSnapshot === 'function' ? store.getSnapshot() : null;
|
|
306
|
-
const tasks = Array.isArray(raw?.tasks) ? raw.tasks : (Array.isArray(props?.tasks) ? props.tasks : []);
|
|
307
|
-
const key = JSON.stringify(tasks.map((task) => [
|
|
308
|
-
task?.taskId ?? null, task?.sessionId ?? null,
|
|
309
|
-
task?.execution?.sessionId ?? null, task?.execution?.workspaceId ?? null,
|
|
310
|
-
]));
|
|
311
|
-
const cache = recordCache.current;
|
|
312
|
-
if (key === cache.key) return cache.value;
|
|
313
|
-
cache.key = key;
|
|
314
|
-
cache.value = { tasks };
|
|
315
|
-
return cache.value;
|
|
316
|
-
}, [store, props?.tasks]);
|
|
317
|
-
const subscribeRecords = useCallback((listener) => {
|
|
318
|
-
if (typeof store?.subscribe !== 'function') return () => {};
|
|
319
|
-
let dispose = null;
|
|
320
|
-
try {
|
|
321
|
-
dispose = store.subscribe(listener);
|
|
322
|
-
} catch {
|
|
323
|
-
return () => {};
|
|
324
|
-
}
|
|
325
|
-
return typeof dispose === 'function' ? dispose : () => {};
|
|
326
|
-
}, [store]);
|
|
327
|
-
const records = useSyncExternalStore(subscribeRecords, getRecords, getRecords);
|
|
328
|
-
|
|
329
|
-
const proof = useMemo(() => dispatchProof(identities, records.tasks), [identities, records]);
|
|
330
|
-
const identity = proof.bySession.get(sessionId) ?? null;
|
|
331
|
-
if (identity === null) return null;
|
|
332
|
-
|
|
333
|
-
const isolated = identity.isolation === 'worktree';
|
|
334
|
-
const label = isolated ? '派工 · 隔离' : '派工';
|
|
335
|
-
const title = identity.title ?? identity.taskId ?? '';
|
|
336
|
-
return (
|
|
337
|
-
<span
|
|
338
|
-
className="dshdg-row-marker"
|
|
339
|
-
data-dshdg-row-marker={sessionId}
|
|
340
|
-
data-dshdg-row-marker-isolation={identity.isolation ?? 'shared'}
|
|
341
|
-
title={title === '' ? '这是一个 TaskBridge 派出的对话' : `TaskBridge 派工:${title}`}
|
|
342
|
-
>
|
|
343
|
-
{label}
|
|
344
|
-
</span>
|
|
345
|
-
);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// ---------------------------------------------------------------------------
|
|
349
|
-
// The plugin's own grouping surface
|
|
350
|
-
// ---------------------------------------------------------------------------
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* The plugin's OWN grouping surface: TaskBridge → 任务工作区 → 对话.
|
|
354
|
-
*
|
|
355
|
-
* This is the part the host cannot give the shell (a section above its browser), so it lives
|
|
356
|
-
* here, on this plugin's own panel, where it is rendered completely and disturb no native row.
|
|
357
|
-
* Strictly three levels, one task-workspace row per dispatched CHAIN.
|
|
358
|
-
* @param {object} props - `store`, `services`, `loadIdentity`.
|
|
359
|
-
* @returns {object | null} the grouping, or null when nothing is proven.
|
|
360
|
-
*/
|
|
361
|
-
export function TaskbridgeGrouping(props) {
|
|
362
|
-
const store = props?.store ?? null;
|
|
363
|
-
const services = props?.services ?? {};
|
|
364
|
-
const [identities, setIdentities] = useState(null);
|
|
365
|
-
const [collapsed, setCollapsed] = useState(() => new Set());
|
|
366
|
-
const [busy, setBusy] = useState(false);
|
|
367
|
-
const [feedback, setFeedback] = useState(null);
|
|
368
|
-
const identityLoader = useRef(props?.loadIdentity);
|
|
369
|
-
if (typeof props?.loadIdentity === 'function') identityLoader.current = props.loadIdentity;
|
|
370
|
-
|
|
371
|
-
useEffect(() => {
|
|
372
|
-
let live = true;
|
|
373
|
-
(async () => {
|
|
374
|
-
try {
|
|
375
|
-
const rows = await identityLoader.current?.();
|
|
376
|
-
if (live) setIdentities(Array.isArray(rows) ? rows : []);
|
|
377
|
-
} catch {
|
|
378
|
-
if (live) setIdentities([]);
|
|
379
|
-
}
|
|
380
|
-
})();
|
|
381
|
-
return () => { live = false; };
|
|
382
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
383
|
-
}, []);
|
|
384
|
-
|
|
385
|
-
const snapshotCache = useRef({ key: null, value: null });
|
|
386
|
-
const subscribe = useCallback((listener) => {
|
|
387
|
-
const source = services.workspaces?.()?.list;
|
|
388
|
-
if (source === null || source === undefined || typeof source.subscribe !== 'function') return () => {};
|
|
389
|
-
let dispose = null;
|
|
390
|
-
try {
|
|
391
|
-
dispose = source.subscribe(listener);
|
|
392
|
-
} catch {
|
|
393
|
-
return () => {};
|
|
394
|
-
}
|
|
395
|
-
return typeof dispose === 'function' ? dispose : () => {};
|
|
396
|
-
}, [services]);
|
|
397
|
-
const getSnapshot = useCallback(
|
|
398
|
-
() => stableSnapshot(readWorkspacesSnapshot(services.workspaces?.() ?? null), snapshotCache.current),
|
|
399
|
-
[services],
|
|
400
|
-
);
|
|
401
|
-
const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
402
|
-
|
|
403
|
-
const emptyRecords = useRef({ tasks: [] });
|
|
404
|
-
const recordCache = useRef({ key: '', value: emptyRecords.current });
|
|
405
|
-
const getRecords = useCallback(() => {
|
|
406
|
-
const raw = typeof store?.getSnapshot === 'function' ? store.getSnapshot() : null;
|
|
407
|
-
const tasks = Array.isArray(raw?.tasks) ? raw.tasks : (Array.isArray(props?.tasks) ? props.tasks : []);
|
|
408
|
-
const key = JSON.stringify(tasks.map((task) => [
|
|
409
|
-
task?.taskId ?? null, task?.title ?? null, task?.sessionId ?? null, task?.continueFromTaskId ?? null,
|
|
410
|
-
task?.execution?.sessionId ?? null, task?.execution?.workspaceId ?? null, task?.execution?.sourcePath ?? null,
|
|
411
|
-
]));
|
|
412
|
-
const cache = recordCache.current;
|
|
413
|
-
if (key === cache.key) return cache.value;
|
|
414
|
-
cache.key = key;
|
|
415
|
-
cache.value = { tasks };
|
|
416
|
-
return cache.value;
|
|
417
|
-
}, [store, props?.tasks]);
|
|
418
|
-
const subscribeRecords = useCallback((listener) => {
|
|
419
|
-
if (typeof store?.subscribe !== 'function') return () => {};
|
|
420
|
-
let dispose = null;
|
|
421
|
-
try {
|
|
422
|
-
dispose = store.subscribe(listener);
|
|
423
|
-
} catch {
|
|
424
|
-
return () => {};
|
|
425
|
-
}
|
|
426
|
-
return typeof dispose === 'function' ? dispose : () => {};
|
|
427
|
-
}, [store]);
|
|
428
|
-
const records = useSyncExternalStore(subscribeRecords, getRecords, getRecords);
|
|
429
|
-
|
|
430
|
-
const view = useMemo(() => workspaceGroups({
|
|
431
|
-
snapshot,
|
|
432
|
-
identities: identities ?? [],
|
|
433
|
-
tasks: records.tasks,
|
|
434
|
-
}), [snapshot, identities, records]);
|
|
435
|
-
|
|
436
|
-
const run = useCallback(async (label, work) => {
|
|
437
|
-
setBusy(true);
|
|
438
|
-
setFeedback(null);
|
|
439
|
-
try {
|
|
440
|
-
await work();
|
|
441
|
-
} catch (error) {
|
|
442
|
-
const detail = typeof error?.message === 'string' && error.message !== '' ? error.message.slice(0, 160) : '';
|
|
443
|
-
setFeedback({ ok: false, message: `${label}失败${detail === '' ? '' : `:${detail}`}` });
|
|
444
|
-
} finally {
|
|
445
|
-
setBusy(false);
|
|
446
|
-
}
|
|
447
|
-
}, []);
|
|
448
|
-
const onToggle = useCallback((key) => {
|
|
449
|
-
setCollapsed((previous) => {
|
|
450
|
-
const next = new Set(previous);
|
|
451
|
-
if (next.has(key)) next.delete(key);
|
|
452
|
-
else next.add(key);
|
|
453
|
-
return next;
|
|
454
|
-
});
|
|
455
|
-
}, []);
|
|
456
|
-
const onOpenSession = useCallback((sessionId) => {
|
|
457
|
-
const ui = services.uiWorkspace?.() ?? null;
|
|
458
|
-
if (typeof ui?.openSession !== 'function') {
|
|
459
|
-
setFeedback({ ok: false, message: '当前宿主没有提供打开会话的接口,未跳转。' });
|
|
460
|
-
return;
|
|
461
|
-
}
|
|
462
|
-
run('打开会话', () => ui.openSession(sessionId));
|
|
463
|
-
}, [services, run]);
|
|
464
|
-
const onStartSession = useCallback((workspaceId) => {
|
|
465
|
-
const ui = services.uiWorkspace?.() ?? null;
|
|
466
|
-
if (typeof ui?.startSession !== 'function') {
|
|
467
|
-
setFeedback({ ok: false, message: '当前宿主没有提供新建会话的接口,未新建。' });
|
|
468
|
-
return;
|
|
469
|
-
}
|
|
470
|
-
run('新建会话', () => ui.startSession(workspaceId));
|
|
471
|
-
}, [services, run]);
|
|
472
|
-
const onArchive = useCallback((sessionId) => {
|
|
473
|
-
const registry = services.workspaces?.() ?? null;
|
|
474
|
-
if (typeof registry?.archiveSession !== 'function') {
|
|
475
|
-
setFeedback({ ok: false, message: '当前宿主没有提供归档接口,未改变任何会话状态。' });
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
run('归档会话', () => registry.archiveSession(sessionId));
|
|
479
|
-
}, [services, run]);
|
|
480
|
-
const onRestore = useCallback((sessionId) => {
|
|
481
|
-
const registry = services.workspaces?.() ?? null;
|
|
482
|
-
if (typeof registry?.unarchiveSession !== 'function') {
|
|
483
|
-
setFeedback({ ok: false, message: '当前宿主没有提供恢复接口,会话仍保持归档。' });
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
run('恢复会话', () => registry.unarchiveSession(sessionId));
|
|
487
|
-
}, [services, run]);
|
|
488
|
-
const openRename = useCallback((workspace) => {
|
|
489
|
-
const registry = services.workspaces?.() ?? null;
|
|
490
|
-
if (workspace === null || typeof registry?.rename !== 'function') {
|
|
491
|
-
setFeedback({ ok: false, message: '当前宿主没有提供重命名工作区的接口,未改名。' });
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
// A Workspace that also holds the operator's own conversations must never be renamed as a
|
|
495
|
-
// whole: the rename would move that conversation too.
|
|
496
|
-
if (workspace.sharedWithOrdinary === true) {
|
|
497
|
-
setFeedback({ ok: false, message: '这个工作区里也有你自己的普通对话,不能整项重命名。' });
|
|
498
|
-
return;
|
|
499
|
-
}
|
|
500
|
-
const next = askText('工作区名称', workspace.title);
|
|
501
|
-
if (next === null) return;
|
|
502
|
-
const title = String(next).trim();
|
|
503
|
-
if (title === '' || title === workspace.title) return;
|
|
504
|
-
run('重命名工作区', () => registry.rename(workspace.workspaceId, title));
|
|
505
|
-
}, [services, run]);
|
|
506
|
-
const openRemove = useCallback((workspace) => {
|
|
507
|
-
const registry = services.workspaces?.() ?? null;
|
|
508
|
-
if (workspace === null || typeof registry?.delete !== 'function') {
|
|
509
|
-
setFeedback({ ok: false, message: '当前宿主没有提供移除工作区的接口,未移除。' });
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
512
|
-
if (workspace.sharedWithOrdinary === true) {
|
|
513
|
-
setFeedback({ ok: false, message: '这个工作区里也有你自己的普通对话,不能整项移除。' });
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
if (!askConfirm(`从 DSH 移除工作区「${workspace.title}」?目录和记录都会保留。`)) return;
|
|
517
|
-
run('移除工作区', () => registry.delete(workspace.workspaceId));
|
|
518
|
-
}, [services, run]);
|
|
519
|
-
|
|
520
|
-
const uiWorkspace = services.uiWorkspace?.() ?? null;
|
|
521
|
-
const registry = services.workspaces?.() ?? null;
|
|
522
|
-
const canOpen = typeof uiWorkspace?.openSession === 'function';
|
|
523
|
-
const canStartSession = typeof uiWorkspace?.startSession === 'function';
|
|
524
|
-
const canRename = typeof registry?.rename === 'function';
|
|
525
|
-
const canRemove = typeof registry?.delete === 'function';
|
|
526
|
-
const canArchive = typeof registry?.archiveSession === 'function';
|
|
527
|
-
const canRestore = typeof registry?.unarchiveSession === 'function';
|
|
528
|
-
|
|
529
|
-
const mode = workspacesViewMode({ ownCount: view.ownCount });
|
|
530
|
-
if (mode === WORKSPACE_VIEWS.passthrough) {
|
|
531
|
-
return (
|
|
532
|
-
<p className="dshdg-ws-hint" data-dshdg-ws-empty="">
|
|
533
|
-
{identities === null ? '正在读取 TaskBridge 的会话归属…' : '还没有可核实的 TaskBridge 派工对话。'}
|
|
534
|
-
</p>
|
|
535
|
-
);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
const section = view.groups[0] ?? null;
|
|
539
|
-
const sectionOpen = section === null || !collapsed.has(section.key);
|
|
540
|
-
return (
|
|
541
|
-
<section className="dshdg-ws" data-dshdg-ws-grouping={mode} aria-label="TaskBridge 派工对话">
|
|
542
|
-
<ul className="dshdg-ws-tree">
|
|
543
|
-
<li className="dshdg-ws-root" data-dshdg-ws-root="">
|
|
544
|
-
<div className="dshdg-ws-row dshdg-ws-root-row">
|
|
545
|
-
<Caret open={sectionOpen} onToggle={() => onToggle(section.key)} label={`${sectionOpen ? '收起' : '展开'} TaskBridge`} />
|
|
546
|
-
<span className="dshdg-ws-title">
|
|
547
|
-
<span className="dshdg-ws-root-name">TaskBridge</span>
|
|
548
|
-
</span>
|
|
549
|
-
<span className="dshdg-ws-count">
|
|
550
|
-
{`${section.workspaceCount} 个任务工作区 · ${section.conversationCount} 个对话`}
|
|
551
|
-
</span>
|
|
552
|
-
</div>
|
|
553
|
-
{sectionOpen ? (
|
|
554
|
-
<ul className="dshdg-ws-projects">
|
|
555
|
-
{section.projects.map((project) => (
|
|
556
|
-
<ProjectNode
|
|
557
|
-
key={project.key}
|
|
558
|
-
project={project}
|
|
559
|
-
open={!collapsed.has(`project:${project.key}`)}
|
|
560
|
-
onToggle={() => onToggle(`project:${project.key}`)}
|
|
561
|
-
>
|
|
562
|
-
{project.workspaces.map((workspace) => (
|
|
563
|
-
<TaskWorkspaceNode
|
|
564
|
-
key={workspace.chainId ?? workspace.workspaceId}
|
|
565
|
-
workspace={workspace}
|
|
566
|
-
open={!collapsed.has(`chain:${workspace.chainId ?? workspace.workspaceId}`)}
|
|
567
|
-
onToggle={() => onToggle(`chain:${workspace.chainId ?? workspace.workspaceId}`)}
|
|
568
|
-
busy={busy}
|
|
569
|
-
canStartSession={canStartSession}
|
|
570
|
-
canRename={canRename}
|
|
571
|
-
canRemove={canRemove}
|
|
572
|
-
onStartSession={onStartSession}
|
|
573
|
-
openRename={openRename}
|
|
574
|
-
openRemove={openRemove}
|
|
575
|
-
onOpen={canOpen ? onOpenSession : null}
|
|
576
|
-
onArchive={canArchive ? onArchive : null}
|
|
577
|
-
/>
|
|
578
|
-
))}
|
|
579
|
-
</ProjectNode>
|
|
580
|
-
))}
|
|
581
|
-
</ul>
|
|
582
|
-
) : null}
|
|
583
|
-
</li>
|
|
584
|
-
</ul>
|
|
585
|
-
{view.archived.length > 0 ? (
|
|
586
|
-
<details className="dshdg-ws-archived" data-dshdg-ws-archived="">
|
|
587
|
-
<summary>{`TaskBridge 已归档(${view.archived.length})`}</summary>
|
|
588
|
-
<p className="dshdg-ws-hint">这些会话在 DSH 里已经归档,只能在 DSH 的归档里恢复。</p>
|
|
589
|
-
<ul className="dshdg-ws-tree">
|
|
590
|
-
{view.archived.map((session) => (
|
|
591
|
-
<li className="dshdg-ws-session" key={session.sessionId} data-dshdg-ws-archived-session={session.sessionId}>
|
|
592
|
-
<span className="dshdg-ws-session-title">{session.title !== '' ? session.title : shortId(session.sessionId)}</span>
|
|
593
|
-
<button
|
|
594
|
-
type="button"
|
|
595
|
-
className="dshdg-ws-session-action"
|
|
596
|
-
data-dshdg-ws-action="restore-session"
|
|
597
|
-
disabled={busy === true || !canRestore}
|
|
598
|
-
title={canRestore ? '在 DSH 中把这个会话移出归档' : '当前宿主没有提供恢复接口'}
|
|
599
|
-
onClick={() => onRestore(session.sessionId)}
|
|
600
|
-
>
|
|
601
|
-
恢复
|
|
602
|
-
</button>
|
|
603
|
-
</li>
|
|
604
|
-
))}
|
|
605
|
-
</ul>
|
|
606
|
-
</details>
|
|
607
|
-
) : null}
|
|
608
|
-
{feedback === null ? null : (
|
|
609
|
-
<p className={feedback.ok ? 'dshdg-ws-hint' : 'dshdg-ws-warn'} role="status" aria-live="polite" data-dshdg-ws-feedback="refused">
|
|
610
|
-
{feedback.message}
|
|
611
|
-
</p>
|
|
612
|
-
)}
|
|
613
|
-
</section>
|
|
614
|
-
);
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
/** One row's caret: expand / collapse, with the state announced. */
|
|
618
|
-
function Caret({ open, onToggle, label }) {
|
|
619
|
-
return (
|
|
620
|
-
<button
|
|
621
|
-
type="button"
|
|
622
|
-
className="dshdg-ws-caret"
|
|
623
|
-
aria-expanded={open}
|
|
624
|
-
aria-label={label}
|
|
625
|
-
onClick={(event) => {
|
|
626
|
-
event.stopPropagation();
|
|
627
|
-
onToggle();
|
|
628
|
-
}}
|
|
629
|
-
>
|
|
630
|
-
{open ? '▾' : '▸'}
|
|
631
|
-
</button>
|
|
632
|
-
);
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
/** One conversation row: the native ids it opens, its isolation and its archive action. */
|
|
636
|
-
function SessionRow({ session, onOpen, onArchive, busy }) {
|
|
637
|
-
const title = session.title !== '' ? session.title : shortId(session.sessionId);
|
|
638
|
-
const isolation = session.isolation === 'worktree' ? '隔离副本' : (session.isolation === 'shared' ? '原目录' : '');
|
|
639
|
-
return (
|
|
640
|
-
<li
|
|
641
|
-
className="dshdg-ws-session"
|
|
642
|
-
data-dshdg-ws-session={session.sessionId}
|
|
643
|
-
data-dshdg-ws-session-workspace={session.workspaceId ?? ''}
|
|
644
|
-
>
|
|
645
|
-
<button
|
|
646
|
-
type="button"
|
|
647
|
-
className="dshdg-ws-open"
|
|
648
|
-
title={`${session.sessionId}${session.workspaceId ? `\n工作区:${session.workspaceId}` : ''}`}
|
|
649
|
-
disabled={busy === true || typeof onOpen !== 'function'}
|
|
650
|
-
onClick={() => onOpen(session.sessionId)}
|
|
651
|
-
>
|
|
652
|
-
<span className="dshdg-ws-session-title">{title}</span>
|
|
653
|
-
{isolation !== '' ? <span className="dshdg-ws-faint">{isolation}</span> : null}
|
|
654
|
-
</button>
|
|
655
|
-
<button
|
|
656
|
-
type="button"
|
|
657
|
-
className="dshdg-ws-session-action"
|
|
658
|
-
data-dshdg-ws-action="archive-session"
|
|
659
|
-
disabled={busy === true || typeof onArchive !== 'function'}
|
|
660
|
-
title={typeof onArchive === 'function' ? '在 DSH 中归档这个会话' : '当前宿主没有提供归档接口'}
|
|
661
|
-
onClick={() => onArchive?.(session.sessionId)}
|
|
662
|
-
>
|
|
663
|
-
归档
|
|
664
|
-
</button>
|
|
665
|
-
</li>
|
|
666
|
-
);
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
/** One task workspace: the native Workspace one dispatched chain lives in. */
|
|
670
|
-
function TaskWorkspaceNode(props) {
|
|
671
|
-
const {
|
|
672
|
-
workspace, open, onToggle, busy,
|
|
673
|
-
canStartSession, canRename, canRemove,
|
|
674
|
-
onStartSession, openRename, openRemove, onOpen, onArchive,
|
|
675
|
-
} = props;
|
|
676
|
-
const bodyId = `dshdg-ws-body-${encodeURIComponent(workspace.chainId ?? workspace.workspaceId)}`;
|
|
677
|
-
const refusedAsWhole = workspace.sharedWithOrdinary === true;
|
|
678
|
-
return (
|
|
679
|
-
<li
|
|
680
|
-
className="dshdg-ws-workspace"
|
|
681
|
-
data-dshdg-ws-workspace={workspace.workspaceId}
|
|
682
|
-
data-dshdg-ws-chain={workspace.chainId ?? ''}
|
|
683
|
-
data-dshdg-ws-shared={refusedAsWhole ? '' : undefined}
|
|
684
|
-
>
|
|
685
|
-
<div className="dshdg-ws-row">
|
|
686
|
-
<Caret open={open} onToggle={onToggle} label={`${open ? '收起' : '展开'}任务工作区 ${workspace.title}`} />
|
|
687
|
-
<button
|
|
688
|
-
type="button"
|
|
689
|
-
className="dshdg-ws-title"
|
|
690
|
-
title={workspace.path !== '' ? workspace.path : workspace.workspaceId}
|
|
691
|
-
onClick={onToggle}
|
|
692
|
-
aria-expanded={open}
|
|
693
|
-
aria-controls={bodyId}
|
|
694
|
-
>
|
|
695
|
-
{workspace.title}
|
|
696
|
-
</button>
|
|
697
|
-
<span className="dshdg-ws-count">{`${workspace.conversations.length} 个对话`}</span>
|
|
698
|
-
<span className="dshdg-ws-spacer" />
|
|
699
|
-
<span className="dshdg-ws-actions">
|
|
700
|
-
<button
|
|
701
|
-
type="button"
|
|
702
|
-
data-dshdg-ws-action="new-session"
|
|
703
|
-
disabled={busy === true || !canStartSession}
|
|
704
|
-
title={canStartSession ? '在这个任务工作区里新建会话' : '当前宿主没有提供新建会话的接口'}
|
|
705
|
-
onClick={() => onStartSession?.(workspace.workspaceId)}
|
|
706
|
-
>
|
|
707
|
-
新会话
|
|
708
|
-
</button>
|
|
709
|
-
<button
|
|
710
|
-
type="button"
|
|
711
|
-
data-dshdg-ws-action="rename"
|
|
712
|
-
disabled={busy === true || !canRename}
|
|
713
|
-
title={refusedAsWhole
|
|
714
|
-
? '这个工作区里也有你自己的普通对话,不能整项重命名'
|
|
715
|
-
: (canRename ? '重命名这个任务工作区' : '当前宿主没有提供重命名工作区的接口')}
|
|
716
|
-
onClick={() => openRename?.(workspace)}
|
|
717
|
-
>
|
|
718
|
-
重命名
|
|
719
|
-
</button>
|
|
720
|
-
<button
|
|
721
|
-
type="button"
|
|
722
|
-
data-dshdg-ws-action="remove"
|
|
723
|
-
disabled={busy === true || !canRemove || refusedAsWhole}
|
|
724
|
-
title={refusedAsWhole
|
|
725
|
-
? '这个工作区里也有你自己的普通对话,不能整项移除'
|
|
726
|
-
: (canRemove ? '从 DSH 移除这个任务工作区(目录与会话保留)' : '当前宿主没有提供移除工作区的接口')}
|
|
727
|
-
onClick={() => openRemove?.(workspace)}
|
|
728
|
-
>
|
|
729
|
-
移除
|
|
730
|
-
</button>
|
|
731
|
-
</span>
|
|
732
|
-
</div>
|
|
733
|
-
{open ? (
|
|
734
|
-
<ul id={bodyId} className="dshdg-ws-conversations" role="group" aria-label={`${workspace.title} 的对话`}>
|
|
735
|
-
{workspace.conversations.map((session) => (
|
|
736
|
-
<SessionRow key={session.sessionId} session={session} onOpen={onOpen} onArchive={onArchive} busy={busy} />
|
|
737
|
-
))}
|
|
738
|
-
</ul>
|
|
739
|
-
) : null}
|
|
740
|
-
</li>
|
|
741
|
-
);
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
/** One project: a real source, holding its task workspaces. */
|
|
745
|
-
function ProjectNode(props) {
|
|
746
|
-
const { project, open, onToggle, children } = props;
|
|
747
|
-
const bodyId = `dshdg-ws-project-body-${encodeURIComponent(project.key)}`;
|
|
748
|
-
return (
|
|
749
|
-
<li className="dshdg-ws-project" data-dshdg-ws-project={project.key} data-dshdg-ws-project-name={project.name}>
|
|
750
|
-
<div className="dshdg-ws-row dshdg-ws-project-row">
|
|
751
|
-
<Caret open={open} onToggle={onToggle} label={`${open ? '收起' : '展开'}项目 ${project.name}`} />
|
|
752
|
-
<button
|
|
753
|
-
type="button"
|
|
754
|
-
className="dshdg-ws-title"
|
|
755
|
-
title={project.path}
|
|
756
|
-
onClick={onToggle}
|
|
757
|
-
aria-expanded={open}
|
|
758
|
-
aria-controls={bodyId}
|
|
759
|
-
>
|
|
760
|
-
{project.name}
|
|
761
|
-
</button>
|
|
762
|
-
<span className="dshdg-ws-count">
|
|
763
|
-
{`${project.workspaceCount} 个任务工作区 · ${project.conversationCount} 个对话`}
|
|
764
|
-
</span>
|
|
765
|
-
</div>
|
|
766
|
-
{open ? <ul id={bodyId} className="dshdg-ws-workspaces">{children}</ul> : null}
|
|
767
|
-
</li>
|
|
768
|
-
);
|
|
769
|
-
}
|
|
770
|
-
|
|
1
|
+
// dsh-delegate — how the TaskBridge section appears in the sidebar's workspace area.
|
|
2
|
+
//
|
|
3
|
+
// WHAT THE HOST ACTUALLY OFFERS (verified in the shipped 0.2.2-rc.5 client bundle)
|
|
4
|
+
// --------------------------------------------------------------------------------
|
|
5
|
+
// `@deepseek-ai/dsh-client-ui-workspace/lib/client.js` registers the workspace browser like this:
|
|
6
|
+
//
|
|
7
|
+
// ctx.slots.inject('sidebar.workspaces', () => ctx.slots.register({
|
|
8
|
+
// name: 'sidebar.workspaces', children: {
|
|
9
|
+
// 'sidebar.workspaces.directoryFlow': { kind: 'single', scope: 'root' },
|
|
10
|
+
// 'sidebar.workspaces.session.row.action': { kind: 'list', scope: 'root' },
|
|
11
|
+
// 'sidebar.session.row.leading': { kind: 'list', scope: 'root', inline: true },
|
|
12
|
+
// 'sidebar.session.row.trailing': { kind: 'list', scope: 'root', inline: true },
|
|
13
|
+
// 'sidebar.session.row.hover': { kind: 'list', scope: 'root' },
|
|
14
|
+
// }, ... }, WorkspaceBrowser))
|
|
15
|
+
//
|
|
16
|
+
// So the region is a SINGLE slot with no published way to render a sibling section above the
|
|
17
|
+
// shipped browser, and its rows are the host's own. What IS published, and what this plugin
|
|
18
|
+
// uses, is the set of CHILD slots:
|
|
19
|
+
//
|
|
20
|
+
// * `sidebar.workspaces.session.row.action` — a list rendered INSIDE every native session row,
|
|
21
|
+
// next to the host's own archive/pin buttons. This is the supported seam for a per-session
|
|
22
|
+
// affordance and it never replaces a native row;
|
|
23
|
+
// * `sidebar.session.row.leading` / `.trailing` / `.hover` — inline material for a row.
|
|
24
|
+
//
|
|
25
|
+
// The consequence for the requirement is stated plainly in `docs/workspace-grouping.md`: a
|
|
26
|
+
// vertical section ABOVE the native browser, inside the same cell, is not expressible through a
|
|
27
|
+
// published slot. This module therefore does NOT take the region over (the earlier build did,
|
|
28
|
+
// which is why the native rows disappeared from an acceptance run). Instead it:
|
|
29
|
+
//
|
|
30
|
+
// 1. keeps the shipped browser exactly as the host renders it — its names, order, search,
|
|
31
|
+
// menus, actions — by *not registering on `sidebar.workspaces` at all* from `apply()`;
|
|
32
|
+
// 2. annotates each native session row through the published row-action slot with a TaskBridge
|
|
33
|
+
// marker for conversations this plugin dispatched (proven by the identity map), so an
|
|
34
|
+
// operator can tell them apart in the native tree without a second tree;
|
|
35
|
+
// 3. offers the TaskBridge grouping — TaskBridge → 任务工作区 → 对话, one row per dispatched
|
|
36
|
+
// chain — through the plugin's own surfaces, where it can be rendered safely and completely:
|
|
37
|
+
// the task records page (`delegate records`) and its existing content panel. Those are this
|
|
38
|
+
// plugin's own slots, so the grouping costs the host nothing and cannot disturb a native row.
|
|
39
|
+
//
|
|
40
|
+
// Nothing here patches the DOM, imports a host package, reads a React private field, or invents a
|
|
41
|
+
// Workspace/path. A row's identity is its real `(workspaceId, sessionId)` pair, and every action
|
|
42
|
+
// goes through an official service with those real ids.
|
|
43
|
+
|
|
44
|
+
import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
45
|
+
|
|
46
|
+
import { createApi } from './api.js';
|
|
47
|
+
import {
|
|
48
|
+
GROUP_KINDS,
|
|
49
|
+
readWorkspacesSnapshot,
|
|
50
|
+
sessionIndex,
|
|
51
|
+
workspaceGroups,
|
|
52
|
+
} from './workspace-groups.js';
|
|
53
|
+
|
|
54
|
+
/** The host's singleton slot for its own workspace/session browser. */
|
|
55
|
+
export const WORKSPACES_SLOT = 'sidebar.workspaces';
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The published CHILD slot the host renders inside every native session row. This is the seam
|
|
59
|
+
* this plugin uses for a per-row affordance; the parent slot itself is never registered on.
|
|
60
|
+
*/
|
|
61
|
+
export const SESSION_ROW_ACTION_SLOT = 'sidebar.workspaces.session.row.action';
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The plugin's row marker: placed AFTER the host's own actions (the host's are 100 = archive and
|
|
65
|
+
* 200 = pin), so it never comes between the operator and a native control.
|
|
66
|
+
*/
|
|
67
|
+
export const SESSION_ROW_ACTION_ORDER = 900;
|
|
68
|
+
|
|
69
|
+
/** The id of this plugin's row-action registration, namespaced against other plugins. */
|
|
70
|
+
export const SESSION_ROW_ACTION_ID = 'dsh-taskbridge:dispatched';
|
|
71
|
+
|
|
72
|
+
/** How the plugin's own grouping can present itself. */
|
|
73
|
+
export const WORKSPACE_VIEWS = Object.freeze({
|
|
74
|
+
/** Conversations this plugin dispatched were proven: the grouping is shown. */
|
|
75
|
+
grouped: 'grouped',
|
|
76
|
+
/** Nothing proven: the grouping is not invented. */
|
|
77
|
+
passthrough: 'passthrough',
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
/** How many times one mount may re-read the identity map after a record showed a new placement. */
|
|
81
|
+
const IDENTITY_REFRESH_LIMIT = 2;
|
|
82
|
+
|
|
83
|
+
/** The session id a row is rendered with: shortened, never guessed. */
|
|
84
|
+
export function shortId(sessionId) {
|
|
85
|
+
if (typeof sessionId !== 'string' || sessionId === '') return '';
|
|
86
|
+
return sessionId.length <= 14 ? sessionId : `${sessionId.slice(0, 8)}…${sessionId.slice(-4)}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Resolve one host service lazily. An absent service is a capability gap, never an error.
|
|
91
|
+
* @param {object | null | undefined} ctx - client context.
|
|
92
|
+
* @param {string} name - service name.
|
|
93
|
+
* @returns {object | null} the service, or null.
|
|
94
|
+
*/
|
|
95
|
+
export function hostService(ctx, name) {
|
|
96
|
+
const get = ctx !== null && typeof ctx === 'object' ? ctx.get : null;
|
|
97
|
+
if (typeof get !== 'function') return null;
|
|
98
|
+
try {
|
|
99
|
+
const service = get.call(ctx, name);
|
|
100
|
+
return service !== null && typeof service === 'object' ? service : null;
|
|
101
|
+
} catch {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The object carrying the shell's dialogs (`window` when there is one). */
|
|
107
|
+
function shellDialog() {
|
|
108
|
+
const shell = globalThis.window ?? null;
|
|
109
|
+
return shell !== null && typeof shell === 'object' ? shell : globalThis;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Ask the operator for one line of text, or answer null. A host without `prompt` answers null.
|
|
114
|
+
* @param {string} message - the question.
|
|
115
|
+
* @param {string} initial - the current value.
|
|
116
|
+
* @param {object} [shell] - the object carrying the dialog.
|
|
117
|
+
* @returns {string | null} the operator's text, or null.
|
|
118
|
+
*/
|
|
119
|
+
export function askText(message, initial, shell = undefined) {
|
|
120
|
+
const host = shell ?? shellDialog();
|
|
121
|
+
const ask = typeof host?.prompt === 'function' ? host.prompt : null;
|
|
122
|
+
if (ask === null) return null;
|
|
123
|
+
try {
|
|
124
|
+
return ask.call(host, message, initial);
|
|
125
|
+
} catch {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Ask the operator to confirm one destructive action. A host without `confirm` answers NO.
|
|
132
|
+
* @param {string} message - the question.
|
|
133
|
+
* @param {object} [shell] - the object carrying the dialog.
|
|
134
|
+
* @returns {boolean} the operator's answer.
|
|
135
|
+
*/
|
|
136
|
+
export function askConfirm(message, shell = undefined) {
|
|
137
|
+
const host = shell ?? shellDialog();
|
|
138
|
+
const ask = typeof host?.confirm === 'function' ? host.confirm : null;
|
|
139
|
+
if (ask === null) return false;
|
|
140
|
+
try {
|
|
141
|
+
return ask.call(host, message) === true;
|
|
142
|
+
} catch {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Register the per-session row marker into the host's published child slot.
|
|
149
|
+
*
|
|
150
|
+
* This is deliberately the ONLY thing this module does to the shell's workspace region: the
|
|
151
|
+
* parent slot stays the host's, so every native row, name, order, search box, menu and action is
|
|
152
|
+
* exactly as shipped. A host that does not declare the child slot simply never runs this.
|
|
153
|
+
* @param {object} ctx - client Cordis context.
|
|
154
|
+
* @param {object} [options] - `store` (the page store), `sessionMap` (an identity loader), `api`.
|
|
155
|
+
* @returns {() => void} disposer releasing the registration.
|
|
156
|
+
*/
|
|
157
|
+
export function registerSessionRowMarker(ctx, options = {}) {
|
|
158
|
+
const slots = ctx?.slots;
|
|
159
|
+
if (slots === null || slots === undefined || typeof slots.inject !== 'function') return () => {};
|
|
160
|
+
const store = options.store ?? null;
|
|
161
|
+
const api = options.api ?? createApi();
|
|
162
|
+
const loadIdentity = typeof options.sessionMap === 'function' ? options.sessionMap : () => loadSessionMap(api);
|
|
163
|
+
const services = {
|
|
164
|
+
workspaces: () => hostService(ctx, 'workspaces'),
|
|
165
|
+
uiWorkspace: () => hostService(ctx, 'uiWorkspace'),
|
|
166
|
+
};
|
|
167
|
+
const rowProps = Object.freeze({ store, services, loadIdentity });
|
|
168
|
+
const Marker = (props) => DispatchedSessionMarker({ ...props, ...rowProps });
|
|
169
|
+
|
|
170
|
+
try {
|
|
171
|
+
return slots.inject(SESSION_ROW_ACTION_SLOT, () => slots.register({
|
|
172
|
+
name: SESSION_ROW_ACTION_SLOT,
|
|
173
|
+
id: SESSION_ROW_ACTION_ID,
|
|
174
|
+
order: SESSION_ROW_ACTION_ORDER,
|
|
175
|
+
}, Marker));
|
|
176
|
+
} catch {
|
|
177
|
+
return () => {};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** @deprecated Removed: this plugin no longer registers on `sidebar.workspaces` itself. */
|
|
182
|
+
export function registerWorkspacesBrowser() {
|
|
183
|
+
return () => {};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** @deprecated The region is the host's; kept only so an older import resolves. */
|
|
187
|
+
export const WORKSPACES_PRIORITY = -200;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Read the plugin's identity map from the operator plane. A refusal answers an empty list.
|
|
191
|
+
* @param {object} api - user-plane transport.
|
|
192
|
+
* @returns {Promise<object[]>} identity rows (possibly empty).
|
|
193
|
+
*/
|
|
194
|
+
export async function loadSessionMap(api) {
|
|
195
|
+
try {
|
|
196
|
+
const body = await api.getSessionMap();
|
|
197
|
+
return Array.isArray(body?.sessions) ? body.sessions : [];
|
|
198
|
+
} catch {
|
|
199
|
+
return [];
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* A stable snapshot from a host source, safe for `useSyncExternalStore`.
|
|
205
|
+
* @param {object | null} snapshot - raw host snapshot.
|
|
206
|
+
* @param {{ key: string | null, value: object | null }} [cache] - the caller's cache slot.
|
|
207
|
+
* @returns {object | null} stable snapshot.
|
|
208
|
+
*/
|
|
209
|
+
export function stableSnapshot(snapshot, cache = { key: null, value: null }) {
|
|
210
|
+
if (snapshot === null || typeof snapshot !== 'object') return null;
|
|
211
|
+
const key = JSON.stringify({
|
|
212
|
+
phase: snapshot.phase ?? null,
|
|
213
|
+
items: (Array.isArray(snapshot.items) ? snapshot.items : []).map((item) => [
|
|
214
|
+
item?.workspaceId ?? null, item?.title ?? null, item?.path ?? null,
|
|
215
|
+
Array.isArray(item?.sessionIds) ? item.sessionIds : [],
|
|
216
|
+
]),
|
|
217
|
+
archived: Array.isArray(snapshot.archivedSessionIds) ? snapshot.archivedSessionIds : [],
|
|
218
|
+
ungrouped: Array.isArray(snapshot.ungroupedSessionIds) ? snapshot.ungroupedSessionIds : [],
|
|
219
|
+
});
|
|
220
|
+
if (cache.key === key && cache.value !== null) return cache.value;
|
|
221
|
+
cache.key = key;
|
|
222
|
+
cache.value = snapshot;
|
|
223
|
+
return snapshot;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Which presentation the plugin's own grouping calls for.
|
|
228
|
+
* @param {object} input - `ownCount`.
|
|
229
|
+
* @returns {'grouped'|'passthrough'} the mode.
|
|
230
|
+
*/
|
|
231
|
+
export function workspacesViewMode(input = {}) {
|
|
232
|
+
return typeof input.ownCount === 'number' && input.ownCount > 0
|
|
233
|
+
? WORKSPACE_VIEWS.grouped
|
|
234
|
+
: WORKSPACE_VIEWS.passthrough;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* The identity map narrowed to a session → proof lookup, memoised by content.
|
|
239
|
+
*
|
|
240
|
+
* The row marker receives only a `sessionId` from the host, so it needs the map (read once) plus
|
|
241
|
+
* the task records (which also prove a NEW dispatch). Both are turned into one lookup here.
|
|
242
|
+
* @param {object[] | null} identities - `/session-map` rows, or null while unread.
|
|
243
|
+
* @param {object[]} tasks - `/tasks` rows.
|
|
244
|
+
* @returns {{ bySession: Map<string, object>, ready: boolean }} the lookup.
|
|
245
|
+
*/
|
|
246
|
+
export function dispatchProof(identities, tasks) {
|
|
247
|
+
const records = sessionIndex(tasks);
|
|
248
|
+
const bySession = new Map();
|
|
249
|
+
// The record list also carries TITLES, and a title is display evidence, not placement: a
|
|
250
|
+
// session named by a record with no Workspace still tells the marker what it is called.
|
|
251
|
+
for (const [sessionId, title] of records.titles) bySession.set(sessionId, { sessionId, title });
|
|
252
|
+
for (const row of identities ?? []) {
|
|
253
|
+
if (row === null || typeof row !== 'object') continue;
|
|
254
|
+
const sessionId = typeof row.sessionId === 'string' ? row.sessionId.trim() : '';
|
|
255
|
+
if (sessionId === '') continue;
|
|
256
|
+
const previous = bySession.get(sessionId);
|
|
257
|
+
bySession.set(sessionId, { ...previous, ...row });
|
|
258
|
+
}
|
|
259
|
+
for (const [sessionId, pair] of records.pairs) {
|
|
260
|
+
const previous = bySession.get(sessionId);
|
|
261
|
+
bySession.set(sessionId, { ...previous, ...pair });
|
|
262
|
+
}
|
|
263
|
+
return { bySession, ready: identities !== null };
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// ---------------------------------------------------------------------------
|
|
267
|
+
// The per-row marker
|
|
268
|
+
// ---------------------------------------------------------------------------
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* The marker the host renders inside one native session row.
|
|
272
|
+
*
|
|
273
|
+
* It is additive and quiet: a small badge naming the isolation ("派工" for a shared run, "派工·
|
|
274
|
+
* 隔离" for a worktree run), with the TaskBridge title as its tooltip. A session this plugin did
|
|
275
|
+
* not dispatch renders NOTHING, so the native row is unchanged.
|
|
276
|
+
* @param {object} props - the slot's own props (`sessionId` among them) plus the injection.
|
|
277
|
+
* @returns {object | null} the badge, or null.
|
|
278
|
+
*/
|
|
279
|
+
export function DispatchedSessionMarker(props) {
|
|
280
|
+
const sessionId = typeof props?.sessionId === 'string' ? props.sessionId.trim() : '';
|
|
281
|
+
if (sessionId === '') return null;
|
|
282
|
+
const store = props?.store ?? null;
|
|
283
|
+
|
|
284
|
+
const [identities, setIdentities] = useState(null);
|
|
285
|
+
const identityLoader = useRef(props?.loadIdentity);
|
|
286
|
+
if (typeof props?.loadIdentity === 'function') identityLoader.current = props.loadIdentity;
|
|
287
|
+
useEffect(() => {
|
|
288
|
+
let live = true;
|
|
289
|
+
(async () => {
|
|
290
|
+
try {
|
|
291
|
+
const rows = await identityLoader.current?.();
|
|
292
|
+
if (live) setIdentities(Array.isArray(rows) ? rows : []);
|
|
293
|
+
} catch {
|
|
294
|
+
if (live) setIdentities([]);
|
|
295
|
+
}
|
|
296
|
+
})();
|
|
297
|
+
return () => { live = false; };
|
|
298
|
+
// The mount read is the point of this effect.
|
|
299
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
300
|
+
}, []);
|
|
301
|
+
|
|
302
|
+
const emptyRecords = useRef({ tasks: [] });
|
|
303
|
+
const recordCache = useRef({ key: '', value: emptyRecords.current });
|
|
304
|
+
const getRecords = useCallback(() => {
|
|
305
|
+
const raw = typeof store?.getSnapshot === 'function' ? store.getSnapshot() : null;
|
|
306
|
+
const tasks = Array.isArray(raw?.tasks) ? raw.tasks : (Array.isArray(props?.tasks) ? props.tasks : []);
|
|
307
|
+
const key = JSON.stringify(tasks.map((task) => [
|
|
308
|
+
task?.taskId ?? null, task?.sessionId ?? null,
|
|
309
|
+
task?.execution?.sessionId ?? null, task?.execution?.workspaceId ?? null,
|
|
310
|
+
]));
|
|
311
|
+
const cache = recordCache.current;
|
|
312
|
+
if (key === cache.key) return cache.value;
|
|
313
|
+
cache.key = key;
|
|
314
|
+
cache.value = { tasks };
|
|
315
|
+
return cache.value;
|
|
316
|
+
}, [store, props?.tasks]);
|
|
317
|
+
const subscribeRecords = useCallback((listener) => {
|
|
318
|
+
if (typeof store?.subscribe !== 'function') return () => {};
|
|
319
|
+
let dispose = null;
|
|
320
|
+
try {
|
|
321
|
+
dispose = store.subscribe(listener);
|
|
322
|
+
} catch {
|
|
323
|
+
return () => {};
|
|
324
|
+
}
|
|
325
|
+
return typeof dispose === 'function' ? dispose : () => {};
|
|
326
|
+
}, [store]);
|
|
327
|
+
const records = useSyncExternalStore(subscribeRecords, getRecords, getRecords);
|
|
328
|
+
|
|
329
|
+
const proof = useMemo(() => dispatchProof(identities, records.tasks), [identities, records]);
|
|
330
|
+
const identity = proof.bySession.get(sessionId) ?? null;
|
|
331
|
+
if (identity === null) return null;
|
|
332
|
+
|
|
333
|
+
const isolated = identity.isolation === 'worktree';
|
|
334
|
+
const label = isolated ? '派工 · 隔离' : '派工';
|
|
335
|
+
const title = identity.title ?? identity.taskId ?? '';
|
|
336
|
+
return (
|
|
337
|
+
<span
|
|
338
|
+
className="dshdg-row-marker"
|
|
339
|
+
data-dshdg-row-marker={sessionId}
|
|
340
|
+
data-dshdg-row-marker-isolation={identity.isolation ?? 'shared'}
|
|
341
|
+
title={title === '' ? '这是一个 TaskBridge 派出的对话' : `TaskBridge 派工:${title}`}
|
|
342
|
+
>
|
|
343
|
+
{label}
|
|
344
|
+
</span>
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// ---------------------------------------------------------------------------
|
|
349
|
+
// The plugin's own grouping surface
|
|
350
|
+
// ---------------------------------------------------------------------------
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* The plugin's OWN grouping surface: TaskBridge → 任务工作区 → 对话.
|
|
354
|
+
*
|
|
355
|
+
* This is the part the host cannot give the shell (a section above its browser), so it lives
|
|
356
|
+
* here, on this plugin's own panel, where it is rendered completely and disturb no native row.
|
|
357
|
+
* Strictly three levels, one task-workspace row per dispatched CHAIN.
|
|
358
|
+
* @param {object} props - `store`, `services`, `loadIdentity`.
|
|
359
|
+
* @returns {object | null} the grouping, or null when nothing is proven.
|
|
360
|
+
*/
|
|
361
|
+
export function TaskbridgeGrouping(props) {
|
|
362
|
+
const store = props?.store ?? null;
|
|
363
|
+
const services = props?.services ?? {};
|
|
364
|
+
const [identities, setIdentities] = useState(null);
|
|
365
|
+
const [collapsed, setCollapsed] = useState(() => new Set());
|
|
366
|
+
const [busy, setBusy] = useState(false);
|
|
367
|
+
const [feedback, setFeedback] = useState(null);
|
|
368
|
+
const identityLoader = useRef(props?.loadIdentity);
|
|
369
|
+
if (typeof props?.loadIdentity === 'function') identityLoader.current = props.loadIdentity;
|
|
370
|
+
|
|
371
|
+
useEffect(() => {
|
|
372
|
+
let live = true;
|
|
373
|
+
(async () => {
|
|
374
|
+
try {
|
|
375
|
+
const rows = await identityLoader.current?.();
|
|
376
|
+
if (live) setIdentities(Array.isArray(rows) ? rows : []);
|
|
377
|
+
} catch {
|
|
378
|
+
if (live) setIdentities([]);
|
|
379
|
+
}
|
|
380
|
+
})();
|
|
381
|
+
return () => { live = false; };
|
|
382
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
383
|
+
}, []);
|
|
384
|
+
|
|
385
|
+
const snapshotCache = useRef({ key: null, value: null });
|
|
386
|
+
const subscribe = useCallback((listener) => {
|
|
387
|
+
const source = services.workspaces?.()?.list;
|
|
388
|
+
if (source === null || source === undefined || typeof source.subscribe !== 'function') return () => {};
|
|
389
|
+
let dispose = null;
|
|
390
|
+
try {
|
|
391
|
+
dispose = source.subscribe(listener);
|
|
392
|
+
} catch {
|
|
393
|
+
return () => {};
|
|
394
|
+
}
|
|
395
|
+
return typeof dispose === 'function' ? dispose : () => {};
|
|
396
|
+
}, [services]);
|
|
397
|
+
const getSnapshot = useCallback(
|
|
398
|
+
() => stableSnapshot(readWorkspacesSnapshot(services.workspaces?.() ?? null), snapshotCache.current),
|
|
399
|
+
[services],
|
|
400
|
+
);
|
|
401
|
+
const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
402
|
+
|
|
403
|
+
const emptyRecords = useRef({ tasks: [] });
|
|
404
|
+
const recordCache = useRef({ key: '', value: emptyRecords.current });
|
|
405
|
+
const getRecords = useCallback(() => {
|
|
406
|
+
const raw = typeof store?.getSnapshot === 'function' ? store.getSnapshot() : null;
|
|
407
|
+
const tasks = Array.isArray(raw?.tasks) ? raw.tasks : (Array.isArray(props?.tasks) ? props.tasks : []);
|
|
408
|
+
const key = JSON.stringify(tasks.map((task) => [
|
|
409
|
+
task?.taskId ?? null, task?.title ?? null, task?.sessionId ?? null, task?.continueFromTaskId ?? null,
|
|
410
|
+
task?.execution?.sessionId ?? null, task?.execution?.workspaceId ?? null, task?.execution?.sourcePath ?? null,
|
|
411
|
+
]));
|
|
412
|
+
const cache = recordCache.current;
|
|
413
|
+
if (key === cache.key) return cache.value;
|
|
414
|
+
cache.key = key;
|
|
415
|
+
cache.value = { tasks };
|
|
416
|
+
return cache.value;
|
|
417
|
+
}, [store, props?.tasks]);
|
|
418
|
+
const subscribeRecords = useCallback((listener) => {
|
|
419
|
+
if (typeof store?.subscribe !== 'function') return () => {};
|
|
420
|
+
let dispose = null;
|
|
421
|
+
try {
|
|
422
|
+
dispose = store.subscribe(listener);
|
|
423
|
+
} catch {
|
|
424
|
+
return () => {};
|
|
425
|
+
}
|
|
426
|
+
return typeof dispose === 'function' ? dispose : () => {};
|
|
427
|
+
}, [store]);
|
|
428
|
+
const records = useSyncExternalStore(subscribeRecords, getRecords, getRecords);
|
|
429
|
+
|
|
430
|
+
const view = useMemo(() => workspaceGroups({
|
|
431
|
+
snapshot,
|
|
432
|
+
identities: identities ?? [],
|
|
433
|
+
tasks: records.tasks,
|
|
434
|
+
}), [snapshot, identities, records]);
|
|
435
|
+
|
|
436
|
+
const run = useCallback(async (label, work) => {
|
|
437
|
+
setBusy(true);
|
|
438
|
+
setFeedback(null);
|
|
439
|
+
try {
|
|
440
|
+
await work();
|
|
441
|
+
} catch (error) {
|
|
442
|
+
const detail = typeof error?.message === 'string' && error.message !== '' ? error.message.slice(0, 160) : '';
|
|
443
|
+
setFeedback({ ok: false, message: `${label}失败${detail === '' ? '' : `:${detail}`}` });
|
|
444
|
+
} finally {
|
|
445
|
+
setBusy(false);
|
|
446
|
+
}
|
|
447
|
+
}, []);
|
|
448
|
+
const onToggle = useCallback((key) => {
|
|
449
|
+
setCollapsed((previous) => {
|
|
450
|
+
const next = new Set(previous);
|
|
451
|
+
if (next.has(key)) next.delete(key);
|
|
452
|
+
else next.add(key);
|
|
453
|
+
return next;
|
|
454
|
+
});
|
|
455
|
+
}, []);
|
|
456
|
+
const onOpenSession = useCallback((sessionId) => {
|
|
457
|
+
const ui = services.uiWorkspace?.() ?? null;
|
|
458
|
+
if (typeof ui?.openSession !== 'function') {
|
|
459
|
+
setFeedback({ ok: false, message: '当前宿主没有提供打开会话的接口,未跳转。' });
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
run('打开会话', () => ui.openSession(sessionId));
|
|
463
|
+
}, [services, run]);
|
|
464
|
+
const onStartSession = useCallback((workspaceId) => {
|
|
465
|
+
const ui = services.uiWorkspace?.() ?? null;
|
|
466
|
+
if (typeof ui?.startSession !== 'function') {
|
|
467
|
+
setFeedback({ ok: false, message: '当前宿主没有提供新建会话的接口,未新建。' });
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
run('新建会话', () => ui.startSession(workspaceId));
|
|
471
|
+
}, [services, run]);
|
|
472
|
+
const onArchive = useCallback((sessionId) => {
|
|
473
|
+
const registry = services.workspaces?.() ?? null;
|
|
474
|
+
if (typeof registry?.archiveSession !== 'function') {
|
|
475
|
+
setFeedback({ ok: false, message: '当前宿主没有提供归档接口,未改变任何会话状态。' });
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
run('归档会话', () => registry.archiveSession(sessionId));
|
|
479
|
+
}, [services, run]);
|
|
480
|
+
const onRestore = useCallback((sessionId) => {
|
|
481
|
+
const registry = services.workspaces?.() ?? null;
|
|
482
|
+
if (typeof registry?.unarchiveSession !== 'function') {
|
|
483
|
+
setFeedback({ ok: false, message: '当前宿主没有提供恢复接口,会话仍保持归档。' });
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
run('恢复会话', () => registry.unarchiveSession(sessionId));
|
|
487
|
+
}, [services, run]);
|
|
488
|
+
const openRename = useCallback((workspace) => {
|
|
489
|
+
const registry = services.workspaces?.() ?? null;
|
|
490
|
+
if (workspace === null || typeof registry?.rename !== 'function') {
|
|
491
|
+
setFeedback({ ok: false, message: '当前宿主没有提供重命名工作区的接口,未改名。' });
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
// A Workspace that also holds the operator's own conversations must never be renamed as a
|
|
495
|
+
// whole: the rename would move that conversation too.
|
|
496
|
+
if (workspace.sharedWithOrdinary === true) {
|
|
497
|
+
setFeedback({ ok: false, message: '这个工作区里也有你自己的普通对话,不能整项重命名。' });
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
const next = askText('工作区名称', workspace.title);
|
|
501
|
+
if (next === null) return;
|
|
502
|
+
const title = String(next).trim();
|
|
503
|
+
if (title === '' || title === workspace.title) return;
|
|
504
|
+
run('重命名工作区', () => registry.rename(workspace.workspaceId, title));
|
|
505
|
+
}, [services, run]);
|
|
506
|
+
const openRemove = useCallback((workspace) => {
|
|
507
|
+
const registry = services.workspaces?.() ?? null;
|
|
508
|
+
if (workspace === null || typeof registry?.delete !== 'function') {
|
|
509
|
+
setFeedback({ ok: false, message: '当前宿主没有提供移除工作区的接口,未移除。' });
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
if (workspace.sharedWithOrdinary === true) {
|
|
513
|
+
setFeedback({ ok: false, message: '这个工作区里也有你自己的普通对话,不能整项移除。' });
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
if (!askConfirm(`从 DSH 移除工作区「${workspace.title}」?目录和记录都会保留。`)) return;
|
|
517
|
+
run('移除工作区', () => registry.delete(workspace.workspaceId));
|
|
518
|
+
}, [services, run]);
|
|
519
|
+
|
|
520
|
+
const uiWorkspace = services.uiWorkspace?.() ?? null;
|
|
521
|
+
const registry = services.workspaces?.() ?? null;
|
|
522
|
+
const canOpen = typeof uiWorkspace?.openSession === 'function';
|
|
523
|
+
const canStartSession = typeof uiWorkspace?.startSession === 'function';
|
|
524
|
+
const canRename = typeof registry?.rename === 'function';
|
|
525
|
+
const canRemove = typeof registry?.delete === 'function';
|
|
526
|
+
const canArchive = typeof registry?.archiveSession === 'function';
|
|
527
|
+
const canRestore = typeof registry?.unarchiveSession === 'function';
|
|
528
|
+
|
|
529
|
+
const mode = workspacesViewMode({ ownCount: view.ownCount });
|
|
530
|
+
if (mode === WORKSPACE_VIEWS.passthrough) {
|
|
531
|
+
return (
|
|
532
|
+
<p className="dshdg-ws-hint" data-dshdg-ws-empty="">
|
|
533
|
+
{identities === null ? '正在读取 TaskBridge 的会话归属…' : '还没有可核实的 TaskBridge 派工对话。'}
|
|
534
|
+
</p>
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
const section = view.groups[0] ?? null;
|
|
539
|
+
const sectionOpen = section === null || !collapsed.has(section.key);
|
|
540
|
+
return (
|
|
541
|
+
<section className="dshdg-ws" data-dshdg-ws-grouping={mode} aria-label="TaskBridge 派工对话">
|
|
542
|
+
<ul className="dshdg-ws-tree">
|
|
543
|
+
<li className="dshdg-ws-root" data-dshdg-ws-root="">
|
|
544
|
+
<div className="dshdg-ws-row dshdg-ws-root-row">
|
|
545
|
+
<Caret open={sectionOpen} onToggle={() => onToggle(section.key)} label={`${sectionOpen ? '收起' : '展开'} TaskBridge`} />
|
|
546
|
+
<span className="dshdg-ws-title">
|
|
547
|
+
<span className="dshdg-ws-root-name">TaskBridge</span>
|
|
548
|
+
</span>
|
|
549
|
+
<span className="dshdg-ws-count">
|
|
550
|
+
{`${section.workspaceCount} 个任务工作区 · ${section.conversationCount} 个对话`}
|
|
551
|
+
</span>
|
|
552
|
+
</div>
|
|
553
|
+
{sectionOpen ? (
|
|
554
|
+
<ul className="dshdg-ws-projects">
|
|
555
|
+
{section.projects.map((project) => (
|
|
556
|
+
<ProjectNode
|
|
557
|
+
key={project.key}
|
|
558
|
+
project={project}
|
|
559
|
+
open={!collapsed.has(`project:${project.key}`)}
|
|
560
|
+
onToggle={() => onToggle(`project:${project.key}`)}
|
|
561
|
+
>
|
|
562
|
+
{project.workspaces.map((workspace) => (
|
|
563
|
+
<TaskWorkspaceNode
|
|
564
|
+
key={workspace.chainId ?? workspace.workspaceId}
|
|
565
|
+
workspace={workspace}
|
|
566
|
+
open={!collapsed.has(`chain:${workspace.chainId ?? workspace.workspaceId}`)}
|
|
567
|
+
onToggle={() => onToggle(`chain:${workspace.chainId ?? workspace.workspaceId}`)}
|
|
568
|
+
busy={busy}
|
|
569
|
+
canStartSession={canStartSession}
|
|
570
|
+
canRename={canRename}
|
|
571
|
+
canRemove={canRemove}
|
|
572
|
+
onStartSession={onStartSession}
|
|
573
|
+
openRename={openRename}
|
|
574
|
+
openRemove={openRemove}
|
|
575
|
+
onOpen={canOpen ? onOpenSession : null}
|
|
576
|
+
onArchive={canArchive ? onArchive : null}
|
|
577
|
+
/>
|
|
578
|
+
))}
|
|
579
|
+
</ProjectNode>
|
|
580
|
+
))}
|
|
581
|
+
</ul>
|
|
582
|
+
) : null}
|
|
583
|
+
</li>
|
|
584
|
+
</ul>
|
|
585
|
+
{view.archived.length > 0 ? (
|
|
586
|
+
<details className="dshdg-ws-archived" data-dshdg-ws-archived="">
|
|
587
|
+
<summary>{`TaskBridge 已归档(${view.archived.length})`}</summary>
|
|
588
|
+
<p className="dshdg-ws-hint">这些会话在 DSH 里已经归档,只能在 DSH 的归档里恢复。</p>
|
|
589
|
+
<ul className="dshdg-ws-tree">
|
|
590
|
+
{view.archived.map((session) => (
|
|
591
|
+
<li className="dshdg-ws-session" key={session.sessionId} data-dshdg-ws-archived-session={session.sessionId}>
|
|
592
|
+
<span className="dshdg-ws-session-title">{session.title !== '' ? session.title : shortId(session.sessionId)}</span>
|
|
593
|
+
<button
|
|
594
|
+
type="button"
|
|
595
|
+
className="dshdg-ws-session-action"
|
|
596
|
+
data-dshdg-ws-action="restore-session"
|
|
597
|
+
disabled={busy === true || !canRestore}
|
|
598
|
+
title={canRestore ? '在 DSH 中把这个会话移出归档' : '当前宿主没有提供恢复接口'}
|
|
599
|
+
onClick={() => onRestore(session.sessionId)}
|
|
600
|
+
>
|
|
601
|
+
恢复
|
|
602
|
+
</button>
|
|
603
|
+
</li>
|
|
604
|
+
))}
|
|
605
|
+
</ul>
|
|
606
|
+
</details>
|
|
607
|
+
) : null}
|
|
608
|
+
{feedback === null ? null : (
|
|
609
|
+
<p className={feedback.ok ? 'dshdg-ws-hint' : 'dshdg-ws-warn'} role="status" aria-live="polite" data-dshdg-ws-feedback="refused">
|
|
610
|
+
{feedback.message}
|
|
611
|
+
</p>
|
|
612
|
+
)}
|
|
613
|
+
</section>
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/** One row's caret: expand / collapse, with the state announced. */
|
|
618
|
+
function Caret({ open, onToggle, label }) {
|
|
619
|
+
return (
|
|
620
|
+
<button
|
|
621
|
+
type="button"
|
|
622
|
+
className="dshdg-ws-caret"
|
|
623
|
+
aria-expanded={open}
|
|
624
|
+
aria-label={label}
|
|
625
|
+
onClick={(event) => {
|
|
626
|
+
event.stopPropagation();
|
|
627
|
+
onToggle();
|
|
628
|
+
}}
|
|
629
|
+
>
|
|
630
|
+
{open ? '▾' : '▸'}
|
|
631
|
+
</button>
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/** One conversation row: the native ids it opens, its isolation and its archive action. */
|
|
636
|
+
function SessionRow({ session, onOpen, onArchive, busy }) {
|
|
637
|
+
const title = session.title !== '' ? session.title : shortId(session.sessionId);
|
|
638
|
+
const isolation = session.isolation === 'worktree' ? '隔离副本' : (session.isolation === 'shared' ? '原目录' : '');
|
|
639
|
+
return (
|
|
640
|
+
<li
|
|
641
|
+
className="dshdg-ws-session"
|
|
642
|
+
data-dshdg-ws-session={session.sessionId}
|
|
643
|
+
data-dshdg-ws-session-workspace={session.workspaceId ?? ''}
|
|
644
|
+
>
|
|
645
|
+
<button
|
|
646
|
+
type="button"
|
|
647
|
+
className="dshdg-ws-open"
|
|
648
|
+
title={`${session.sessionId}${session.workspaceId ? `\n工作区:${session.workspaceId}` : ''}`}
|
|
649
|
+
disabled={busy === true || typeof onOpen !== 'function'}
|
|
650
|
+
onClick={() => onOpen(session.sessionId)}
|
|
651
|
+
>
|
|
652
|
+
<span className="dshdg-ws-session-title">{title}</span>
|
|
653
|
+
{isolation !== '' ? <span className="dshdg-ws-faint">{isolation}</span> : null}
|
|
654
|
+
</button>
|
|
655
|
+
<button
|
|
656
|
+
type="button"
|
|
657
|
+
className="dshdg-ws-session-action"
|
|
658
|
+
data-dshdg-ws-action="archive-session"
|
|
659
|
+
disabled={busy === true || typeof onArchive !== 'function'}
|
|
660
|
+
title={typeof onArchive === 'function' ? '在 DSH 中归档这个会话' : '当前宿主没有提供归档接口'}
|
|
661
|
+
onClick={() => onArchive?.(session.sessionId)}
|
|
662
|
+
>
|
|
663
|
+
归档
|
|
664
|
+
</button>
|
|
665
|
+
</li>
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/** One task workspace: the native Workspace one dispatched chain lives in. */
|
|
670
|
+
function TaskWorkspaceNode(props) {
|
|
671
|
+
const {
|
|
672
|
+
workspace, open, onToggle, busy,
|
|
673
|
+
canStartSession, canRename, canRemove,
|
|
674
|
+
onStartSession, openRename, openRemove, onOpen, onArchive,
|
|
675
|
+
} = props;
|
|
676
|
+
const bodyId = `dshdg-ws-body-${encodeURIComponent(workspace.chainId ?? workspace.workspaceId)}`;
|
|
677
|
+
const refusedAsWhole = workspace.sharedWithOrdinary === true;
|
|
678
|
+
return (
|
|
679
|
+
<li
|
|
680
|
+
className="dshdg-ws-workspace"
|
|
681
|
+
data-dshdg-ws-workspace={workspace.workspaceId}
|
|
682
|
+
data-dshdg-ws-chain={workspace.chainId ?? ''}
|
|
683
|
+
data-dshdg-ws-shared={refusedAsWhole ? '' : undefined}
|
|
684
|
+
>
|
|
685
|
+
<div className="dshdg-ws-row">
|
|
686
|
+
<Caret open={open} onToggle={onToggle} label={`${open ? '收起' : '展开'}任务工作区 ${workspace.title}`} />
|
|
687
|
+
<button
|
|
688
|
+
type="button"
|
|
689
|
+
className="dshdg-ws-title"
|
|
690
|
+
title={workspace.path !== '' ? workspace.path : workspace.workspaceId}
|
|
691
|
+
onClick={onToggle}
|
|
692
|
+
aria-expanded={open}
|
|
693
|
+
aria-controls={bodyId}
|
|
694
|
+
>
|
|
695
|
+
{workspace.title}
|
|
696
|
+
</button>
|
|
697
|
+
<span className="dshdg-ws-count">{`${workspace.conversations.length} 个对话`}</span>
|
|
698
|
+
<span className="dshdg-ws-spacer" />
|
|
699
|
+
<span className="dshdg-ws-actions">
|
|
700
|
+
<button
|
|
701
|
+
type="button"
|
|
702
|
+
data-dshdg-ws-action="new-session"
|
|
703
|
+
disabled={busy === true || !canStartSession}
|
|
704
|
+
title={canStartSession ? '在这个任务工作区里新建会话' : '当前宿主没有提供新建会话的接口'}
|
|
705
|
+
onClick={() => onStartSession?.(workspace.workspaceId)}
|
|
706
|
+
>
|
|
707
|
+
新会话
|
|
708
|
+
</button>
|
|
709
|
+
<button
|
|
710
|
+
type="button"
|
|
711
|
+
data-dshdg-ws-action="rename"
|
|
712
|
+
disabled={busy === true || !canRename}
|
|
713
|
+
title={refusedAsWhole
|
|
714
|
+
? '这个工作区里也有你自己的普通对话,不能整项重命名'
|
|
715
|
+
: (canRename ? '重命名这个任务工作区' : '当前宿主没有提供重命名工作区的接口')}
|
|
716
|
+
onClick={() => openRename?.(workspace)}
|
|
717
|
+
>
|
|
718
|
+
重命名
|
|
719
|
+
</button>
|
|
720
|
+
<button
|
|
721
|
+
type="button"
|
|
722
|
+
data-dshdg-ws-action="remove"
|
|
723
|
+
disabled={busy === true || !canRemove || refusedAsWhole}
|
|
724
|
+
title={refusedAsWhole
|
|
725
|
+
? '这个工作区里也有你自己的普通对话,不能整项移除'
|
|
726
|
+
: (canRemove ? '从 DSH 移除这个任务工作区(目录与会话保留)' : '当前宿主没有提供移除工作区的接口')}
|
|
727
|
+
onClick={() => openRemove?.(workspace)}
|
|
728
|
+
>
|
|
729
|
+
移除
|
|
730
|
+
</button>
|
|
731
|
+
</span>
|
|
732
|
+
</div>
|
|
733
|
+
{open ? (
|
|
734
|
+
<ul id={bodyId} className="dshdg-ws-conversations" role="group" aria-label={`${workspace.title} 的对话`}>
|
|
735
|
+
{workspace.conversations.map((session) => (
|
|
736
|
+
<SessionRow key={session.sessionId} session={session} onOpen={onOpen} onArchive={onArchive} busy={busy} />
|
|
737
|
+
))}
|
|
738
|
+
</ul>
|
|
739
|
+
) : null}
|
|
740
|
+
</li>
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/** One project: a real source, holding its task workspaces. */
|
|
745
|
+
function ProjectNode(props) {
|
|
746
|
+
const { project, open, onToggle, children } = props;
|
|
747
|
+
const bodyId = `dshdg-ws-project-body-${encodeURIComponent(project.key)}`;
|
|
748
|
+
return (
|
|
749
|
+
<li className="dshdg-ws-project" data-dshdg-ws-project={project.key} data-dshdg-ws-project-name={project.name}>
|
|
750
|
+
<div className="dshdg-ws-row dshdg-ws-project-row">
|
|
751
|
+
<Caret open={open} onToggle={onToggle} label={`${open ? '收起' : '展开'}项目 ${project.name}`} />
|
|
752
|
+
<button
|
|
753
|
+
type="button"
|
|
754
|
+
className="dshdg-ws-title"
|
|
755
|
+
title={project.path}
|
|
756
|
+
onClick={onToggle}
|
|
757
|
+
aria-expanded={open}
|
|
758
|
+
aria-controls={bodyId}
|
|
759
|
+
>
|
|
760
|
+
{project.name}
|
|
761
|
+
</button>
|
|
762
|
+
<span className="dshdg-ws-count">
|
|
763
|
+
{`${project.workspaceCount} 个任务工作区 · ${project.conversationCount} 个对话`}
|
|
764
|
+
</span>
|
|
765
|
+
</div>
|
|
766
|
+
{open ? <ul id={bodyId} className="dshdg-ws-workspaces">{children}</ul> : null}
|
|
767
|
+
</li>
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
|