dsh-native-session-delete 1.0.4
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/AGENTS.md +137 -0
- package/LICENSE +21 -0
- package/README.en.md +142 -0
- package/README.md +128 -0
- package/SECURITY.md +15 -0
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/compatibility.json +12 -0
- package/cordis.patch.yml +7 -0
- package/lib/client.js +2532 -0
- package/package.json +132 -0
- package/scripts/build-client.mjs +170 -0
- package/scripts/smoke-ui.mjs +216 -0
- package/src/host/delete-session.mjs +405 -0
- package/src/index.js +43 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,2532 @@
|
|
|
1
|
+
// Modified from @deepseek-ai/dsh-client-ui-workspace 0.1.0-rc.8 by DSH Native Session Delete. See THIRD_PARTY_NOTICES.md.
|
|
2
|
+
window.__ModuleLoader__.load({
|
|
3
|
+
id: "dsh-native-session-delete",
|
|
4
|
+
factory: (require) => {
|
|
5
|
+
var module = { exports: {} };
|
|
6
|
+
var exports = module.exports;
|
|
7
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
+
let _deepseek_ai_dsh_client_runtime_client = require("@deepseek-ai/dsh-client-runtime/client");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
let react = require("react");
|
|
11
|
+
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
12
|
+
//#region lib/types/client/stores.js
|
|
13
|
+
/**
|
|
14
|
+
* The workspace browser's viewing store: the session-list grouping mode,
|
|
15
|
+
* persisted across reloads. Module level exports the factory only (a
|
|
16
|
+
* module-level handle would pin the store identity across plugin reloads);
|
|
17
|
+
* register() receives the factory and the browser derives its PropsStore
|
|
18
|
+
* share from the return type.
|
|
19
|
+
*/
|
|
20
|
+
/** Browser-local order account for the hierarchy-free flat Session list. */
|
|
21
|
+
const FLAT_SESSION_ORDER_KEY = "__flat_session_order__";
|
|
22
|
+
/**
|
|
23
|
+
* Create the workspace browser viewing store handle.
|
|
24
|
+
* @returns the store handle (spec + type + identity + factory in one).
|
|
25
|
+
*/
|
|
26
|
+
function createWorkspaceViewStore() {
|
|
27
|
+
return (0, _deepseek_ai_dsh_client_runtime_client.defineStore)({
|
|
28
|
+
init: () => ({
|
|
29
|
+
groupBy: "workspace",
|
|
30
|
+
orderBy: "updated",
|
|
31
|
+
groupExpansion: {},
|
|
32
|
+
sessionOrderByAccount: {},
|
|
33
|
+
sessionUpdatedAtByAccount: {}
|
|
34
|
+
}),
|
|
35
|
+
persist: "dsh.workspace.view.v5",
|
|
36
|
+
actions: {
|
|
37
|
+
setGroupBy: (d, mode) => {
|
|
38
|
+
d.groupBy = mode;
|
|
39
|
+
},
|
|
40
|
+
setOrderBy: (d, mode) => {
|
|
41
|
+
d.orderBy = mode;
|
|
42
|
+
},
|
|
43
|
+
setGroupExpanded: (d, key, expanded) => {
|
|
44
|
+
d.groupExpansion[key] = expanded;
|
|
45
|
+
},
|
|
46
|
+
retainAccountKeys: (d, workspaceKeys) => {
|
|
47
|
+
const retained = new Set(workspaceKeys);
|
|
48
|
+
d.groupExpansion = Object.fromEntries(Object.entries(d.groupExpansion).filter(([key]) => retained.has(key)));
|
|
49
|
+
d.sessionOrderByAccount = Object.fromEntries(Object.entries(d.sessionOrderByAccount).filter(([key]) => retained.has(key)));
|
|
50
|
+
d.sessionUpdatedAtByAccount = Object.fromEntries(Object.entries(d.sessionUpdatedAtByAccount).filter(([key]) => retained.has(key)));
|
|
51
|
+
},
|
|
52
|
+
syncSessionOrderAccount: (d, accountKey, order, updatedAt) => {
|
|
53
|
+
d.sessionOrderByAccount[accountKey] = order;
|
|
54
|
+
d.sessionUpdatedAtByAccount[accountKey] = updatedAt;
|
|
55
|
+
},
|
|
56
|
+
setSessionOrder: (d, accountKey, order) => {
|
|
57
|
+
d.sessionOrderByAccount[accountKey] = order;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region ../../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
|
|
64
|
+
function r(e) {
|
|
65
|
+
var t, f, n = "";
|
|
66
|
+
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
67
|
+
else if ("object" == typeof e) if (Array.isArray(e)) {
|
|
68
|
+
var o = e.length;
|
|
69
|
+
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
70
|
+
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
71
|
+
return n;
|
|
72
|
+
}
|
|
73
|
+
function clsx() {
|
|
74
|
+
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
75
|
+
return n;
|
|
76
|
+
}
|
|
77
|
+
/** Display label for the ungrouped bucket row. */
|
|
78
|
+
const UNGROUPED_LABEL = "Ungrouped";
|
|
79
|
+
/**
|
|
80
|
+
* Directory display label: basename of the path (both separators accepted).
|
|
81
|
+
* Ungrouped-bucket fallback for surfaces without a workspace title.
|
|
82
|
+
* @param cwd - directory path, or undefined for the ungrouped bucket.
|
|
83
|
+
* @returns basename, the raw cwd when it has no basename, or the ungrouped label.
|
|
84
|
+
*/
|
|
85
|
+
function workspaceLabel(cwd) {
|
|
86
|
+
if (cwd === void 0 || cwd === "") return UNGROUPED_LABEL;
|
|
87
|
+
const base = cwd.replace(/[/\\]+$/, "").split(/[/\\]/).pop();
|
|
88
|
+
return base !== void 0 && base !== "" ? base : cwd;
|
|
89
|
+
}
|
|
90
|
+
/** Recency comparator: newest first, id as the deterministic tiebreak (ids are unique per group). */
|
|
91
|
+
function byRecency(a, b) {
|
|
92
|
+
if (b.updatedAt !== a.updatedAt) return b.updatedAt - a.updatedAt;
|
|
93
|
+
return a.id < b.id ? -1 : 1;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Ordinary sessions are visible; among blank sessions, only the current one
|
|
97
|
+
* is visible. Subagent children use their parent header catalog; archived
|
|
98
|
+
* sessions are visible nowhere, while their accounting slots remain so
|
|
99
|
+
* unarchiving restores position.
|
|
100
|
+
*/
|
|
101
|
+
function sessionVisible(session, current, archived) {
|
|
102
|
+
return session.origin !== "subagent" && !archived.has(session.id) && (!session.blank || session.id === current);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* A blank session is the selected Workspace's provisional New Session row;
|
|
106
|
+
* its canonical title never enters search (blank rows are query-excluded)
|
|
107
|
+
* and the renderer localizes its display label.
|
|
108
|
+
*/
|
|
109
|
+
function sessionTitle(session) {
|
|
110
|
+
return session.blank ? "New Session" : session.displayTitle;
|
|
111
|
+
}
|
|
112
|
+
/** Build one group without projecting session lineage into presentation. */
|
|
113
|
+
function buildGroup(key, workspaceId, cwd, createdAt, label, members, order) {
|
|
114
|
+
const sessions = [...members];
|
|
115
|
+
if (order === "recency") sessions.sort(byRecency);
|
|
116
|
+
return {
|
|
117
|
+
key,
|
|
118
|
+
workspaceId,
|
|
119
|
+
cwd,
|
|
120
|
+
createdAt,
|
|
121
|
+
label,
|
|
122
|
+
sessions
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/** Apply a stored Ungrouped order and append newly loose Sessions by recency. */
|
|
126
|
+
function orderedUngrouped(members, stored) {
|
|
127
|
+
const byId = new Map(members.map((session) => [session.id, session]));
|
|
128
|
+
const included = /* @__PURE__ */ new Set();
|
|
129
|
+
const ordered = [];
|
|
130
|
+
for (const key of stored) {
|
|
131
|
+
const session = byId.get(key);
|
|
132
|
+
if (session === void 0 || included.has(key)) continue;
|
|
133
|
+
ordered.push(session);
|
|
134
|
+
included.add(key);
|
|
135
|
+
}
|
|
136
|
+
for (const session of [...members].sort(byRecency)) {
|
|
137
|
+
if (included.has(session.id)) continue;
|
|
138
|
+
ordered.push(session);
|
|
139
|
+
}
|
|
140
|
+
return ordered;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Group Sessions by Host Workspace: one group per entity in stable Host
|
|
144
|
+
* order, with members resolved from sessionIds in their stored order. Sessions
|
|
145
|
+
* outside every Workspace trail in the browser-local Ungrouped order, which
|
|
146
|
+
* falls back to recency before that order is initialized.
|
|
147
|
+
*/
|
|
148
|
+
function groupByWorkspace(list, workspaces, archived, ungroupedOrder) {
|
|
149
|
+
const groups = [];
|
|
150
|
+
const accounted = /* @__PURE__ */ new Set();
|
|
151
|
+
for (const workspace of workspaces) {
|
|
152
|
+
const members = [];
|
|
153
|
+
for (const id of workspace.sessionIds) {
|
|
154
|
+
const summary = list.byId[id];
|
|
155
|
+
if (summary === void 0) continue;
|
|
156
|
+
accounted.add(id);
|
|
157
|
+
if (!sessionVisible(summary, list.current, archived)) continue;
|
|
158
|
+
members.push(summary);
|
|
159
|
+
}
|
|
160
|
+
groups.push(buildGroup(workspace.workspaceId, workspace.workspaceId, workspace.path, Date.parse(workspace.createdAt), workspace.title, members, "account"));
|
|
161
|
+
}
|
|
162
|
+
const stray = list.ids.map((id) => list.byId[id]).filter((s) => s !== void 0 && !accounted.has(s.id) && sessionVisible(s, list.current, archived));
|
|
163
|
+
if (stray.length > 0) groups.push(buildGroup("", void 0, void 0, void 0, UNGROUPED_LABEL, ungroupedOrder === void 0 ? stray : orderedUngrouped(stray, ungroupedOrder), ungroupedOrder === void 0 ? "recency" : "account"));
|
|
164
|
+
return groups;
|
|
165
|
+
}
|
|
166
|
+
function sessionNode(s, descendants) {
|
|
167
|
+
return {
|
|
168
|
+
id: s.id,
|
|
169
|
+
title: sessionTitle(s),
|
|
170
|
+
blank: s.blank,
|
|
171
|
+
running: s.running,
|
|
172
|
+
runningSubagentCount: descendants.get(s.id)?.runningCount ?? 0,
|
|
173
|
+
completed: s.completed === true,
|
|
174
|
+
updatedAt: s.updatedAt,
|
|
175
|
+
...s.pendingInteraction === void 0 ? {} : { pendingInteraction: s.pendingInteraction }
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Derive the workspace browser groups with every session as a top-level row.
|
|
180
|
+
*
|
|
181
|
+
* Every group shows; sessions populate under expanded groups in the selected
|
|
182
|
+
* local order. Blank sessions are excluded except for the selected
|
|
183
|
+
* provisional New Session row; archived sessions are excluded everywhere.
|
|
184
|
+
* Content search lives outside this derivation
|
|
185
|
+
* (see {@link deriveSearchResults}).
|
|
186
|
+
* @param list - sessions list snapshot (`current` feeds containsCurrent).
|
|
187
|
+
* @param workspaces - real workspaces in stable Host order.
|
|
188
|
+
* @param archivedSessionIds - registry-global archive set.
|
|
189
|
+
* @param view - local expansion arrays.
|
|
190
|
+
* @returns group sections in render order.
|
|
191
|
+
*/
|
|
192
|
+
function deriveGroups(list, workspaces, archivedSessionIds, view) {
|
|
193
|
+
const archived = new Set(archivedSessionIds);
|
|
194
|
+
const expandedGroups = new Set(view.expandedGroups);
|
|
195
|
+
const descendants = (0, _deepseek_ai_dsh_client_runtime_client.indexSubagentDescendants)(list.byId);
|
|
196
|
+
const currentGroup = list.current === void 0 ? void 0 : workspaces.find((w) => w.sessionIds.includes(list.current))?.workspaceId ?? "";
|
|
197
|
+
const groups = [];
|
|
198
|
+
for (const g of groupByWorkspace(list, workspaces, archived, view.ungroupedOrder)) {
|
|
199
|
+
const expanded = expandedGroups.has(g.key);
|
|
200
|
+
groups.push({
|
|
201
|
+
key: g.key,
|
|
202
|
+
workspaceId: g.workspaceId,
|
|
203
|
+
cwd: g.cwd,
|
|
204
|
+
createdAt: g.createdAt,
|
|
205
|
+
label: g.label,
|
|
206
|
+
sessionCount: g.sessions.length,
|
|
207
|
+
expanded,
|
|
208
|
+
containsCurrent: g.key === currentGroup,
|
|
209
|
+
sessions: expanded ? g.sessions.map((session) => sessionNode(session, descendants)) : []
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
return groups;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Derive the flat session list ("In one list" mode): every session — fork
|
|
216
|
+
* children included — as a top-level row, strictly newest-first. No grouping,
|
|
217
|
+
* no parent/child adjacency. Content search lives outside this derivation
|
|
218
|
+
* (see {@link deriveSearchResults}).
|
|
219
|
+
* @param list - sessions list snapshot.
|
|
220
|
+
* @param archivedSessionIds - registry-global archive set.
|
|
221
|
+
* @returns flat rows in render order.
|
|
222
|
+
*/
|
|
223
|
+
function deriveFlat(list, archivedSessionIds) {
|
|
224
|
+
const archived = new Set(archivedSessionIds);
|
|
225
|
+
const descendants = (0, _deepseek_ai_dsh_client_runtime_client.indexSubagentDescendants)(list.byId);
|
|
226
|
+
const rows = [];
|
|
227
|
+
for (const id of list.ids) {
|
|
228
|
+
const s = list.byId[id];
|
|
229
|
+
if (s === void 0 || !sessionVisible(s, list.current, archived)) continue;
|
|
230
|
+
rows.push(s);
|
|
231
|
+
}
|
|
232
|
+
rows.sort(byRecency);
|
|
233
|
+
return rows.map((session) => sessionNode(session, descendants));
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Merge immediate title/Workspace substring matches with ranked Host content
|
|
237
|
+
* matches. Local rows lead newest-first, content-only rows retain backend
|
|
238
|
+
* order, and duplicate sessions receive the backend snippet in place.
|
|
239
|
+
* @param list - session metadata authority.
|
|
240
|
+
* @param workspaces - Workspace membership and display labels.
|
|
241
|
+
* @param query - caller text; surrounding whitespace is ignored.
|
|
242
|
+
* @param archivedSessionIds - registry-global archive set (members never match).
|
|
243
|
+
* @param content - ranked Host content-search page.
|
|
244
|
+
* @param limit - protocol-owned maximum merged row count.
|
|
245
|
+
* @returns bounded deduplicated flat rows and a refine-query hint bit.
|
|
246
|
+
*/
|
|
247
|
+
function deriveSearchResults(list, workspaces, query, archivedSessionIds, content, limit) {
|
|
248
|
+
const q = query.trim().toLowerCase();
|
|
249
|
+
if (q === "") return {
|
|
250
|
+
items: [],
|
|
251
|
+
hasMore: false
|
|
252
|
+
};
|
|
253
|
+
const archived = new Set(archivedSessionIds);
|
|
254
|
+
const descendants = (0, _deepseek_ai_dsh_client_runtime_client.indexSubagentDescendants)(list.byId);
|
|
255
|
+
const workspaceBySession = /* @__PURE__ */ new Map();
|
|
256
|
+
for (const workspace of workspaces) for (const sessionId of workspace.sessionIds) if (!workspaceBySession.has(sessionId)) workspaceBySession.set(sessionId, workspace.title);
|
|
257
|
+
const labelOf = (summary) => workspaceBySession.get(summary.id) ?? workspaceLabel(summary.cwd);
|
|
258
|
+
const contentBySession = /* @__PURE__ */ new Map();
|
|
259
|
+
for (const item of content.items) if (!contentBySession.has(item.sessionId)) contentBySession.set(item.sessionId, item);
|
|
260
|
+
const local = [];
|
|
261
|
+
for (const id of list.ids) {
|
|
262
|
+
const summary = list.byId[id];
|
|
263
|
+
if (summary === void 0 || summary.blank || !sessionVisible(summary, list.current, archived)) continue;
|
|
264
|
+
if (sessionTitle(summary).toLowerCase().includes(q) || labelOf(summary).toLowerCase().includes(q)) local.push(summary);
|
|
265
|
+
}
|
|
266
|
+
local.sort(byRecency);
|
|
267
|
+
const ordered = [];
|
|
268
|
+
const included = /* @__PURE__ */ new Set();
|
|
269
|
+
const include = (summary) => {
|
|
270
|
+
if (included.has(summary.id)) return;
|
|
271
|
+
included.add(summary.id);
|
|
272
|
+
ordered.push(summary);
|
|
273
|
+
};
|
|
274
|
+
for (const summary of local) include(summary);
|
|
275
|
+
for (const item of content.items) {
|
|
276
|
+
const summary = list.byId[item.sessionId];
|
|
277
|
+
if (summary !== void 0 && !summary.blank && sessionVisible(summary, list.current, archived)) include(summary);
|
|
278
|
+
}
|
|
279
|
+
return {
|
|
280
|
+
items: ordered.slice(0, limit).map((summary) => {
|
|
281
|
+
const match = contentBySession.get(summary.id);
|
|
282
|
+
return {
|
|
283
|
+
id: summary.id,
|
|
284
|
+
title: sessionTitle(summary),
|
|
285
|
+
workspace: labelOf(summary),
|
|
286
|
+
running: summary.running,
|
|
287
|
+
runningSubagentCount: descendants.get(summary.id)?.runningCount ?? 0,
|
|
288
|
+
...summary.pendingInteraction === void 0 ? {} : { pendingInteraction: summary.pendingInteraction },
|
|
289
|
+
completed: summary.completed === true,
|
|
290
|
+
...match === void 0 ? {} : { snippet: match.snippet }
|
|
291
|
+
};
|
|
292
|
+
}),
|
|
293
|
+
hasMore: content.hasMore || ordered.length > limit
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Compact relative time for session rows, as a structured bucket the
|
|
298
|
+
* renderer localizes ("now"/"5min"/"3h"/"2d"/"4mo"/"1y" in en).
|
|
299
|
+
* @param updatedAt - epoch ms of the session's last activity.
|
|
300
|
+
* @param now - current epoch ms (injected for pure rendering).
|
|
301
|
+
* @returns the row's trailing time bucket and magnitude.
|
|
302
|
+
*/
|
|
303
|
+
function relativeTime(updatedAt, now) {
|
|
304
|
+
const MIN = 6e4;
|
|
305
|
+
const HOUR = 36e5;
|
|
306
|
+
const DAY = 864e5;
|
|
307
|
+
const diff = Math.max(0, now - updatedAt);
|
|
308
|
+
if (diff < MIN) return {
|
|
309
|
+
unit: "now",
|
|
310
|
+
n: 0
|
|
311
|
+
};
|
|
312
|
+
if (diff < HOUR) return {
|
|
313
|
+
unit: "minutes",
|
|
314
|
+
n: Math.floor(diff / MIN)
|
|
315
|
+
};
|
|
316
|
+
if (diff < DAY) return {
|
|
317
|
+
unit: "hours",
|
|
318
|
+
n: Math.floor(diff / HOUR)
|
|
319
|
+
};
|
|
320
|
+
if (diff < 30 * DAY) return {
|
|
321
|
+
unit: "days",
|
|
322
|
+
n: Math.floor(diff / DAY)
|
|
323
|
+
};
|
|
324
|
+
if (diff < 365 * DAY) return {
|
|
325
|
+
unit: "months",
|
|
326
|
+
n: Math.floor(diff / (30 * DAY))
|
|
327
|
+
};
|
|
328
|
+
return {
|
|
329
|
+
unit: "years",
|
|
330
|
+
n: Math.floor(diff / (365 * DAY))
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
//#endregion
|
|
334
|
+
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/ui-workspace/src/client/rows/Rows.module.css.mjs
|
|
335
|
+
const css$2 = ".YDXeBa_projectRow,.YDXeBa_sessionRow{cursor:pointer;user-select:none;color:var(--dsw-alias-label-primary);border-radius:8px;align-items:center;gap:6px;padding:0 8px;display:flex}.YDXeBa_projectRow:hover,.YDXeBa_sessionRow:hover,.YDXeBa_sessionRow.YDXeBa_selected{background:var(--dsw-alias-interactive-bg-hover)}.YDXeBa_searchResultRow{box-sizing:border-box;cursor:pointer;text-align:left;width:100%;min-height:48px;color:var(--dsw-alias-label-primary);background:0 0;border:none;border-radius:8px;flex-direction:column;align-items:stretch;padding:4px 8px;display:flex}.YDXeBa_searchResultRow:hover,.YDXeBa_searchResultRow.YDXeBa_selected{background:var(--dsw-alias-interactive-bg-hover)}.YDXeBa_searchResultHeading{align-items:center;min-width:0;display:flex}.YDXeBa_searchResultTitle{text-overflow:ellipsis;white-space:nowrap;min-width:0;margin-left:4px;font-size:14px;line-height:20px;overflow:hidden}.YDXeBa_searchResultMeta{align-items:center;gap:6px;min-width:0;margin-left:20px;display:flex}.YDXeBa_searchResultWorkspace,.YDXeBa_searchResultSnippet{text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:17px;overflow:hidden}.YDXeBa_searchResultWorkspace{max-width:40%;color:var(--dsw-alias-label-tertiary);flex:none}.YDXeBa_searchResultSnippet{min-width:0;color:var(--dsw-alias-label-secondary);flex:1}.YDXeBa_projectRow{box-sizing:border-box;align-items:center;height:34px}.YDXeBa_projectRow .YDXeBa_rowActions{height:20px}.YDXeBa_sessionRow{height:32px;animation:YDXeBa_row-in .15s var(--ds-ease-in-out);gap:0}.YDXeBa_sessionRow .YDXeBa_title{margin:0 6px 0 4px}.YDXeBa_flatSessionRowWithoutStatus .YDXeBa_title{margin-left:0}@keyframes YDXeBa_row-in{0%{opacity:0}}.YDXeBa_slot{width:16px;height:20px;color:var(--dsw-alias-label-tertiary);flex:none;justify-content:center;align-items:center;display:inline-flex}.YDXeBa_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}.YDXeBa_folderActive{color:var(--dsw-alias-state-business-primary)}.YDXeBa_projectRow .YDXeBa_chevron{display:none}.YDXeBa_projectRow:hover .YDXeBa_chevron{display:inline-flex}.YDXeBa_projectRow:hover .YDXeBa_folder{display:none}.YDXeBa_arrow{transition:transform .15s var(--ds-ease-in-out)}.YDXeBa_arrowOpen{transform:rotate(90deg)}.YDXeBa_projectText{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.YDXeBa_title{text-overflow:ellipsis;white-space:nowrap;min-width:0;font-size:14px;line-height:20px;overflow:hidden}.YDXeBa_renameInput{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-button-elevated-fill);min-width:0;color:inherit;border-radius:4px;outline:none;padding:0 2px;font-size:14px;line-height:20px}.YDXeBa_sessionRow .YDXeBa_title{flex:1}.YDXeBa_meta{text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:20px;overflow:hidden}.YDXeBa_time{color:var(--dsw-alias-label-tertiary);flex:none;font-size:12px;line-height:20px}.YDXeBa_dot{flex:none}.YDXeBa_rowActions{flex:none;align-items:center;gap:12px;display:none}.YDXeBa_projectRow:hover .YDXeBa_rowActions,.YDXeBa_sessionRow:hover .YDXeBa_rowActions,.YDXeBa_projectRow.YDXeBa_menuOpen .YDXeBa_rowActions,.YDXeBa_sessionRow.YDXeBa_menuOpen .YDXeBa_rowActions{display:inline-flex}.YDXeBa_sessionRow:hover .YDXeBa_time,.YDXeBa_sessionRow.YDXeBa_menuOpen .YDXeBa_time{display:none}.YDXeBa_projectRow.YDXeBa_menuOpen,.YDXeBa_sessionRow.YDXeBa_menuOpen{background:var(--dsw-alias-interactive-bg-hover)}.YDXeBa_sessionRow.YDXeBa_dropBefore,.YDXeBa_sessionRow.YDXeBa_dropAfter{position:relative}.YDXeBa_sessionRow.YDXeBa_dropBefore:before,.YDXeBa_sessionRow.YDXeBa_dropAfter:after{content:\"\";z-index:1;background:linear-gradient(55deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 0 / 5px 7px no-repeat, linear-gradient(125deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 5px / 5px 7px no-repeat, linear-gradient(var(--dsw-alias-state-business-primary) 0 0) 4px 5px / calc(100% - 4px) 2px no-repeat;pointer-events:none;height:12px;position:absolute;left:0;right:4px}.YDXeBa_sessionRow.YDXeBa_dropBefore:before{top:-7px}.YDXeBa_sessionRow.YDXeBa_dropAfter:after{bottom:-7px}.YDXeBa_hoverContent{flex-direction:column;gap:8px;display:flex}.YDXeBa_hoverTitle{color:#fff;overflow-wrap:break-word;font-size:14px;line-height:20px}.YDXeBa_hoverPath{color:#cfd3d6;word-break:break-all;font-size:12px;line-height:16px}.YDXeBa_hoverTime{color:#cfd3d6;font-size:12px;line-height:16px}.YDXeBa_hoverStatus{color:#adb2b8;align-items:center;gap:8px;font-size:12px;line-height:20px;display:flex}.YDXeBa_iconButton{cursor:pointer;width:16px;height:16px;color:var(--dsw-alias-label-tertiary);background:0 0;border:none;border-radius:4px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.YDXeBa_iconButton:hover{color:var(--dsw-alias-label-primary)}.YDXeBa_chevron{color:var(--dsw-alias-label-caption)}@media (prefers-reduced-motion:reduce){.YDXeBa_sessionRow,.YDXeBa_arrow{transition:none;animation:none}}";
|
|
336
|
+
const tagId$2 = "@deepseek-ai/dsh-client-ui-workspace/Rows.module.css";
|
|
337
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$2) + "]") === null) {
|
|
338
|
+
const tag = document.createElement("style");
|
|
339
|
+
tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-workspace";
|
|
340
|
+
tag.dataset.pluginCss = tagId$2;
|
|
341
|
+
tag.textContent = css$2;
|
|
342
|
+
document.head.appendChild(tag);
|
|
343
|
+
}
|
|
344
|
+
var Rows_module_css_default = {
|
|
345
|
+
"arrow": "YDXeBa_arrow",
|
|
346
|
+
"arrowOpen": "YDXeBa_arrowOpen",
|
|
347
|
+
"chevron": "YDXeBa_chevron",
|
|
348
|
+
"dot": "YDXeBa_dot",
|
|
349
|
+
"dropAfter": "YDXeBa_dropAfter",
|
|
350
|
+
"dropBefore": "YDXeBa_dropBefore",
|
|
351
|
+
"flatSessionRowWithoutStatus": "YDXeBa_flatSessionRowWithoutStatus",
|
|
352
|
+
"folder": "YDXeBa_folder",
|
|
353
|
+
"folderActive": "YDXeBa_folderActive",
|
|
354
|
+
"hoverContent": "YDXeBa_hoverContent",
|
|
355
|
+
"hoverPath": "YDXeBa_hoverPath",
|
|
356
|
+
"hoverStatus": "YDXeBa_hoverStatus",
|
|
357
|
+
"hoverTime": "YDXeBa_hoverTime",
|
|
358
|
+
"hoverTitle": "YDXeBa_hoverTitle",
|
|
359
|
+
"iconButton": "YDXeBa_iconButton",
|
|
360
|
+
"menuOpen": "YDXeBa_menuOpen",
|
|
361
|
+
"meta": "YDXeBa_meta",
|
|
362
|
+
"projectRow": "YDXeBa_projectRow",
|
|
363
|
+
"projectText": "YDXeBa_projectText",
|
|
364
|
+
"renameInput": "YDXeBa_renameInput",
|
|
365
|
+
"row-in": "YDXeBa_row-in",
|
|
366
|
+
"rowActions": "YDXeBa_rowActions",
|
|
367
|
+
"searchResultHeading": "YDXeBa_searchResultHeading",
|
|
368
|
+
"searchResultMeta": "YDXeBa_searchResultMeta",
|
|
369
|
+
"searchResultRow": "YDXeBa_searchResultRow",
|
|
370
|
+
"searchResultSnippet": "YDXeBa_searchResultSnippet",
|
|
371
|
+
"searchResultTitle": "YDXeBa_searchResultTitle",
|
|
372
|
+
"searchResultWorkspace": "YDXeBa_searchResultWorkspace",
|
|
373
|
+
"selected": "YDXeBa_selected",
|
|
374
|
+
"sessionRow": "YDXeBa_sessionRow",
|
|
375
|
+
"slot": "YDXeBa_slot",
|
|
376
|
+
"time": "YDXeBa_time",
|
|
377
|
+
"title": "YDXeBa_title",
|
|
378
|
+
"visuallyHidden": "YDXeBa_visuallyHidden"
|
|
379
|
+
};
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region lib/types/client/rows/Rows.js
|
|
382
|
+
/**
|
|
383
|
+
* Workspace browser tree row components (figma Cell set 14:3080): pure presentational —
|
|
384
|
+
* all data and callbacks arrive via props. Hover swaps (folder->chevron,
|
|
385
|
+
* time->ellipsis, action buttons) are CSS-only. Row ... menus are visual-only
|
|
386
|
+
* except workspace Rename/Delete and session Rename/Fork/Archive; the session
|
|
387
|
+
* and workspace hover cards are suppressed while a menu is open.
|
|
388
|
+
*/
|
|
389
|
+
/** Row display title: blank rows show the localized New Session label. */
|
|
390
|
+
function displayTitle(node, t) {
|
|
391
|
+
return node.blank ? t("session.new") : node.title;
|
|
392
|
+
}
|
|
393
|
+
/** Localized compact relative time ("刚刚"/"5分钟" in zh, "now"/"5min" in en). */
|
|
394
|
+
function timeLabel(updatedAt, now, t) {
|
|
395
|
+
const { unit, n } = relativeTime(updatedAt, now);
|
|
396
|
+
return unit === "now" ? t("time.now") : t(`time.${unit}`, { n });
|
|
397
|
+
}
|
|
398
|
+
/** Hover-card variant: distances wrap in the ago template; the now bucket stays bare (no "now ago"). */
|
|
399
|
+
function hoverTimeLabel(updatedAt, now, t) {
|
|
400
|
+
const { unit, n } = relativeTime(updatedAt, now);
|
|
401
|
+
return unit === "now" ? t("time.now") : t("time.ago", { t: t(`time.${unit}`, { n }) });
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Absolute creation time through the dictionary's date template (the message
|
|
405
|
+
* clock pattern): `toLocaleString` would follow the browser language, not the
|
|
406
|
+
* app locale, and produce mixed-language text after a switch.
|
|
407
|
+
*/
|
|
408
|
+
function createdLabel(createdAt, t) {
|
|
409
|
+
const d = new Date(createdAt);
|
|
410
|
+
const pad2 = (v) => String(v).padStart(2, "0");
|
|
411
|
+
return t("hover.created", { time: `${t("date.ymd", {
|
|
412
|
+
y: d.getFullYear(),
|
|
413
|
+
m: d.getMonth() + 1,
|
|
414
|
+
d: d.getDate()
|
|
415
|
+
})} ${pad2(d.getHours())}:${pad2(d.getMinutes())}` });
|
|
416
|
+
}
|
|
417
|
+
/** Hover-card body: workspace title, display directory path, absolute creation time. */
|
|
418
|
+
function WorkspaceHoverContent({ label, cwd, createdAt, t }) {
|
|
419
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
420
|
+
className: Rows_module_css_default.hoverContent,
|
|
421
|
+
children: [
|
|
422
|
+
(0, react_jsx_runtime.jsx)("div", {
|
|
423
|
+
className: Rows_module_css_default.hoverTitle,
|
|
424
|
+
children: label
|
|
425
|
+
}),
|
|
426
|
+
(0, react_jsx_runtime.jsx)("div", {
|
|
427
|
+
className: Rows_module_css_default.hoverPath,
|
|
428
|
+
children: cwd
|
|
429
|
+
}),
|
|
430
|
+
(0, react_jsx_runtime.jsx)("div", {
|
|
431
|
+
className: Rows_module_css_default.hoverTime,
|
|
432
|
+
children: createdLabel(createdAt, t)
|
|
433
|
+
})
|
|
434
|
+
]
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
/** Pointer-position half of a row (insert line above or below). */
|
|
438
|
+
function rowHalf(e) {
|
|
439
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
440
|
+
return e.clientY < rect.top + rect.height / 2 ? "before" : "after";
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Project (workspace) header row: folder + title;
|
|
444
|
+
* hover reveals the chevron and create button, and dwelling on a real
|
|
445
|
+
* Workspace shows its hover card (the ungrouped bucket has none).
|
|
446
|
+
* `containsCurrent` arrives on the node (derivation fact, no renderer scan).
|
|
447
|
+
* @param props.group - derived group node.
|
|
448
|
+
* @param props.onToggle - expand/collapse the group.
|
|
449
|
+
* @param props.onCreate - start a frontend Session inside this Workspace.
|
|
450
|
+
* @param props.drag - optional workspace-row drag wiring.
|
|
451
|
+
* @param props.home - host account home for POSIX hover-path abbreviation.
|
|
452
|
+
* @param props.t - the browser root's locale seat.
|
|
453
|
+
* @returns the row element.
|
|
454
|
+
*/
|
|
455
|
+
function ProjectRowItem({ group, onToggle, onCreate, actions, drag, home, t }) {
|
|
456
|
+
const row = group;
|
|
457
|
+
const label = row.workspaceId === void 0 ? t("group.ungrouped") : row.label;
|
|
458
|
+
const active = group.expanded && group.containsCurrent;
|
|
459
|
+
const [menuOpen, setMenuOpen] = (0, react.useState)(false);
|
|
460
|
+
const workspaceMenuItems = [{
|
|
461
|
+
id: "rename",
|
|
462
|
+
label: t("rename"),
|
|
463
|
+
icon: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconEditOutline16, {})
|
|
464
|
+
}, {
|
|
465
|
+
id: "delete",
|
|
466
|
+
label: t("delete.workspace"),
|
|
467
|
+
icon: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTrashOutline16, {}),
|
|
468
|
+
danger: true
|
|
469
|
+
}];
|
|
470
|
+
const ownRow = (0, react_jsx_runtime.jsxs)("div", {
|
|
471
|
+
className: clsx(Rows_module_css_default.projectRow, menuOpen && Rows_module_css_default.menuOpen),
|
|
472
|
+
role: "treeitem",
|
|
473
|
+
"aria-expanded": row.expanded,
|
|
474
|
+
onClick: onToggle,
|
|
475
|
+
draggable: drag !== void 0,
|
|
476
|
+
onDragStart: drag === void 0 ? void 0 : (e) => {
|
|
477
|
+
e.dataTransfer.effectAllowed = "move";
|
|
478
|
+
e.dataTransfer.setData("text/plain", row.key);
|
|
479
|
+
drag.start();
|
|
480
|
+
},
|
|
481
|
+
onDragEnd: drag?.end,
|
|
482
|
+
children: [
|
|
483
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
484
|
+
className: clsx(Rows_module_css_default.slot, Rows_module_css_default.folder, active && Rows_module_css_default.folderActive),
|
|
485
|
+
children: row.expanded ? (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderOpen16, {}) : (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderClose16, {})
|
|
486
|
+
}),
|
|
487
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
488
|
+
className: clsx(Rows_module_css_default.slot, Rows_module_css_default.chevron),
|
|
489
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTriangleRightFill14, { className: clsx(Rows_module_css_default.arrow, row.expanded && Rows_module_css_default.arrowOpen) })
|
|
490
|
+
}),
|
|
491
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
492
|
+
className: Rows_module_css_default.projectText,
|
|
493
|
+
children: (0, react_jsx_runtime.jsx)("span", {
|
|
494
|
+
className: Rows_module_css_default.title,
|
|
495
|
+
children: label
|
|
496
|
+
})
|
|
497
|
+
}),
|
|
498
|
+
(0, react_jsx_runtime.jsxs)("span", {
|
|
499
|
+
className: Rows_module_css_default.rowActions,
|
|
500
|
+
children: [actions !== void 0 && (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
|
|
501
|
+
open: menuOpen,
|
|
502
|
+
onClose: () => {
|
|
503
|
+
setMenuOpen(false);
|
|
504
|
+
},
|
|
505
|
+
items: workspaceMenuItems,
|
|
506
|
+
onSelect: (id) => {
|
|
507
|
+
setMenuOpen(false);
|
|
508
|
+
/* v8 ignore next -- workspaceMenuItems carries exactly these two rows today. */
|
|
509
|
+
if (id !== "rename" && id !== "delete") return;
|
|
510
|
+
if (id === "rename") actions.rename();
|
|
511
|
+
else actions.delete();
|
|
512
|
+
},
|
|
513
|
+
portal: true,
|
|
514
|
+
closeOnPointerLeave: true,
|
|
515
|
+
anchor: (0, react_jsx_runtime.jsx)("button", {
|
|
516
|
+
type: "button",
|
|
517
|
+
className: Rows_module_css_default.iconButton,
|
|
518
|
+
"aria-label": t("actions.workspace.aria", { name: label }),
|
|
519
|
+
onClick: (e) => {
|
|
520
|
+
e.stopPropagation();
|
|
521
|
+
setMenuOpen((v) => !v);
|
|
522
|
+
},
|
|
523
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconEllipsisOutline16, {})
|
|
524
|
+
})
|
|
525
|
+
}), (0, react_jsx_runtime.jsx)("button", {
|
|
526
|
+
type: "button",
|
|
527
|
+
className: Rows_module_css_default.iconButton,
|
|
528
|
+
"aria-label": t("actions.newSession.aria", { name: label }),
|
|
529
|
+
onClick: (e) => {
|
|
530
|
+
e.stopPropagation();
|
|
531
|
+
onCreate();
|
|
532
|
+
},
|
|
533
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlusOutline16, {})
|
|
534
|
+
})]
|
|
535
|
+
})
|
|
536
|
+
]
|
|
537
|
+
});
|
|
538
|
+
if (row.createdAt === void 0) return ownRow;
|
|
539
|
+
return (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.HoverCard, {
|
|
540
|
+
anchor: ownRow,
|
|
541
|
+
content: (0, react_jsx_runtime.jsx)(WorkspaceHoverContent, {
|
|
542
|
+
label: row.label,
|
|
543
|
+
cwd: row.cwd === void 0 ? void 0 : typeof _deepseek_ai_dsh_client_runtime_client.abbreviateHomePath === "function" ? (0, _deepseek_ai_dsh_client_runtime_client.abbreviateHomePath)(row.cwd, home) : row.cwd,
|
|
544
|
+
createdAt: row.createdAt,
|
|
545
|
+
t
|
|
546
|
+
}),
|
|
547
|
+
disabled: menuOpen,
|
|
548
|
+
copyText: row.cwd,
|
|
549
|
+
copyLabel: t("copy"),
|
|
550
|
+
copiedLabel: t("hover.copied")
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
/* v8 ignore next 3 -- closed-union backstop; only reached if the status is forged */
|
|
554
|
+
function assertNever(value) {
|
|
555
|
+
throw new Error(`unknown pending interaction: ${String(value)}`);
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Session status presentation; pending interaction is primary and live activity
|
|
559
|
+
* outranks completion reminders.
|
|
560
|
+
*/
|
|
561
|
+
function sessionStatuses(node, t) {
|
|
562
|
+
const subagents = node.runningSubagentCount === 0 ? void 0 : {
|
|
563
|
+
state: "ongoing",
|
|
564
|
+
label: t(node.runningSubagentCount === 1 ? "status.subagentsRunning.one" : "status.subagentsRunning.other", { n: node.runningSubagentCount })
|
|
565
|
+
};
|
|
566
|
+
let pending;
|
|
567
|
+
switch (node.pendingInteraction) {
|
|
568
|
+
case "approval":
|
|
569
|
+
pending = {
|
|
570
|
+
state: "warning",
|
|
571
|
+
label: t("status.waitingApproval")
|
|
572
|
+
};
|
|
573
|
+
break;
|
|
574
|
+
case "plan-review":
|
|
575
|
+
pending = {
|
|
576
|
+
state: "warning",
|
|
577
|
+
label: t("status.planReview")
|
|
578
|
+
};
|
|
579
|
+
break;
|
|
580
|
+
case "question":
|
|
581
|
+
pending = {
|
|
582
|
+
state: "warning",
|
|
583
|
+
label: t("status.waitingAnswer")
|
|
584
|
+
};
|
|
585
|
+
break;
|
|
586
|
+
case void 0: break;
|
|
587
|
+
/* v8 ignore next -- closed PendingInteractionStatus union */
|
|
588
|
+
default: return assertNever(node.pendingInteraction);
|
|
589
|
+
}
|
|
590
|
+
if (pending !== void 0) return subagents === void 0 ? [pending] : [pending, subagents];
|
|
591
|
+
if (node.running) {
|
|
592
|
+
const primary = {
|
|
593
|
+
state: "ongoing",
|
|
594
|
+
label: t("status.running")
|
|
595
|
+
};
|
|
596
|
+
return subagents === void 0 ? [primary] : [primary, subagents];
|
|
597
|
+
}
|
|
598
|
+
if (subagents !== void 0) return [subagents];
|
|
599
|
+
if (node.completed) return [{
|
|
600
|
+
state: "done",
|
|
601
|
+
label: t("status.completed")
|
|
602
|
+
}];
|
|
603
|
+
return [{
|
|
604
|
+
state: "done",
|
|
605
|
+
label: t("status.idle")
|
|
606
|
+
}];
|
|
607
|
+
}
|
|
608
|
+
/** Primary status dot plus every status's screen-reader label, shared by the search and session rows. */
|
|
609
|
+
function SessionStatusDots({ statuses }) {
|
|
610
|
+
return (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: statuses[0].state }), statuses.map((status) => (0, react_jsx_runtime.jsx)("span", {
|
|
611
|
+
className: Rows_module_css_default.visuallyHidden,
|
|
612
|
+
children: status.label
|
|
613
|
+
}, status.label))] });
|
|
614
|
+
}
|
|
615
|
+
/** Hover-card body: full title, relative time, and every relevant live status. */
|
|
616
|
+
function SessionHoverContent({ node, now, t }) {
|
|
617
|
+
const statuses = sessionStatuses(node, t);
|
|
618
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
619
|
+
className: Rows_module_css_default.hoverContent,
|
|
620
|
+
children: [
|
|
621
|
+
(0, react_jsx_runtime.jsx)("div", {
|
|
622
|
+
className: Rows_module_css_default.hoverTitle,
|
|
623
|
+
children: displayTitle(node, t)
|
|
624
|
+
}),
|
|
625
|
+
!node.blank && (0, react_jsx_runtime.jsx)("div", {
|
|
626
|
+
className: Rows_module_css_default.hoverTime,
|
|
627
|
+
children: hoverTimeLabel(node.updatedAt, now, t)
|
|
628
|
+
}),
|
|
629
|
+
statuses.map((status) => (0, react_jsx_runtime.jsxs)("div", {
|
|
630
|
+
className: Rows_module_css_default.hoverStatus,
|
|
631
|
+
children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: status.state }), (0, react_jsx_runtime.jsx)("span", { children: status.label })]
|
|
632
|
+
}, status.label))
|
|
633
|
+
]
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* One flat search result: title, Workspace context, and optional content
|
|
638
|
+
* excerpt. Search navigation opens the session only; it does not address an
|
|
639
|
+
* event inside the conversation.
|
|
640
|
+
* @param props.result - merged local/content search row.
|
|
641
|
+
* @param props.currentId - selected session id.
|
|
642
|
+
* @param props.onOpen - open the selected session.
|
|
643
|
+
* @param props.t - Workspace-browser translation seat.
|
|
644
|
+
* @returns the result button.
|
|
645
|
+
*/
|
|
646
|
+
function SearchResultItem({ result, currentId, onOpen, t }) {
|
|
647
|
+
const selected = result.id === currentId;
|
|
648
|
+
const statuses = sessionStatuses(result, t);
|
|
649
|
+
const primaryStatus = statuses[0];
|
|
650
|
+
return (0, react_jsx_runtime.jsxs)("button", {
|
|
651
|
+
type: "button",
|
|
652
|
+
className: clsx(Rows_module_css_default.searchResultRow, selected && Rows_module_css_default.selected),
|
|
653
|
+
role: "treeitem",
|
|
654
|
+
"aria-selected": selected,
|
|
655
|
+
onClick: () => {
|
|
656
|
+
onOpen(result.id);
|
|
657
|
+
},
|
|
658
|
+
children: [(0, react_jsx_runtime.jsxs)("span", {
|
|
659
|
+
className: Rows_module_css_default.searchResultHeading,
|
|
660
|
+
children: [(0, react_jsx_runtime.jsx)("span", {
|
|
661
|
+
className: Rows_module_css_default.slot,
|
|
662
|
+
children: (primaryStatus.state !== "done" || result.completed) && (0, react_jsx_runtime.jsx)(SessionStatusDots, { statuses })
|
|
663
|
+
}), (0, react_jsx_runtime.jsx)("span", {
|
|
664
|
+
className: Rows_module_css_default.searchResultTitle,
|
|
665
|
+
children: result.title
|
|
666
|
+
})]
|
|
667
|
+
}), (0, react_jsx_runtime.jsxs)("span", {
|
|
668
|
+
className: Rows_module_css_default.searchResultMeta,
|
|
669
|
+
children: [(0, react_jsx_runtime.jsx)("span", {
|
|
670
|
+
className: Rows_module_css_default.searchResultWorkspace,
|
|
671
|
+
children: result.workspace
|
|
672
|
+
}), result.snippet !== void 0 && (0, react_jsx_runtime.jsx)("span", {
|
|
673
|
+
className: Rows_module_css_default.searchResultSnippet,
|
|
674
|
+
children: result.snippet
|
|
675
|
+
})]
|
|
676
|
+
})]
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* One top-level 34px session row: status dot (pending user interaction outranks
|
|
681
|
+
* own or descendant activity), title, relative time, and the row actions menu.
|
|
682
|
+
* @param props.node - derived session node.
|
|
683
|
+
* @param props.currentId - selected session id (row highlight).
|
|
684
|
+
* @param props.now - epoch ms for relative-time formatting.
|
|
685
|
+
* @param props.onOpen - open a session by id.
|
|
686
|
+
* @param props.onRename - open the session rename dialog (id + current title).
|
|
687
|
+
* @param props.onFork - fork a session at its last completed turn.
|
|
688
|
+
* @param props.onArchive - archive a session by id.
|
|
689
|
+
* @param props.drag - optional draggable-row wiring.
|
|
690
|
+
* @param props.flat - omit the empty status slot in the hierarchy-free flat list.
|
|
691
|
+
* @param props.t - the browser root's locale seat.
|
|
692
|
+
* @returns the session row.
|
|
693
|
+
*/
|
|
694
|
+
function SessionNodeItem({ node, currentId, now, onOpen, onRename, onFork, onArchive, onDelete, drag, flat = false, t }) {
|
|
695
|
+
const row = node;
|
|
696
|
+
const title = displayTitle(node, t);
|
|
697
|
+
const selected = node.id === currentId;
|
|
698
|
+
const statuses = sessionStatuses(node, t);
|
|
699
|
+
const showStatus = statuses[0].state !== "done" || row.completed;
|
|
700
|
+
const [menuOpen, setMenuOpen] = (0, react.useState)(false);
|
|
701
|
+
const sessionMenuItems = [
|
|
702
|
+
{
|
|
703
|
+
id: "rename",
|
|
704
|
+
label: t("rename"),
|
|
705
|
+
icon: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconEditOutline16, {})
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
id: "fork",
|
|
709
|
+
label: t("menu.fork"),
|
|
710
|
+
icon: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconBranchOutline16, {})
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
id: "archive",
|
|
714
|
+
label: t("menu.archiveSession"),
|
|
715
|
+
icon: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconArchiveOutline20, { size: 16 })
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
id: "delete-session",
|
|
719
|
+
label: t("menu.deleteSession"),
|
|
720
|
+
icon: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTrashOutline16, {}),
|
|
721
|
+
danger: true
|
|
722
|
+
}
|
|
723
|
+
];
|
|
724
|
+
return (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.HoverCard, {
|
|
725
|
+
anchor: (0, react_jsx_runtime.jsxs)("div", {
|
|
726
|
+
className: clsx(Rows_module_css_default.sessionRow, selected && Rows_module_css_default.selected, menuOpen && Rows_module_css_default.menuOpen, flat && !showStatus && Rows_module_css_default.flatSessionRowWithoutStatus, drag?.marker === "before" && Rows_module_css_default.dropBefore, drag?.marker === "after" && Rows_module_css_default.dropAfter),
|
|
727
|
+
role: "treeitem",
|
|
728
|
+
"aria-selected": selected,
|
|
729
|
+
onClick: () => {
|
|
730
|
+
onOpen(node.id);
|
|
731
|
+
},
|
|
732
|
+
draggable: drag !== void 0,
|
|
733
|
+
onDragStart: drag === void 0 ? void 0 : (e) => {
|
|
734
|
+
e.dataTransfer.effectAllowed = "move";
|
|
735
|
+
e.dataTransfer.setData("text/plain", node.id);
|
|
736
|
+
drag.start();
|
|
737
|
+
},
|
|
738
|
+
onDragEnd: drag?.end,
|
|
739
|
+
onDragOver: drag === void 0 ? void 0 : (e) => {
|
|
740
|
+
if (!drag.active) return;
|
|
741
|
+
e.preventDefault();
|
|
742
|
+
e.dataTransfer.dropEffect = "move";
|
|
743
|
+
drag.hover(rowHalf(e));
|
|
744
|
+
},
|
|
745
|
+
onDrop: drag === void 0 ? void 0 : (e) => {
|
|
746
|
+
if (!drag.active) return;
|
|
747
|
+
e.preventDefault();
|
|
748
|
+
drag.drop(rowHalf(e));
|
|
749
|
+
},
|
|
750
|
+
children: [
|
|
751
|
+
(!flat || showStatus) && (0, react_jsx_runtime.jsx)("span", {
|
|
752
|
+
className: Rows_module_css_default.slot,
|
|
753
|
+
children: showStatus && (0, react_jsx_runtime.jsx)(SessionStatusDots, { statuses })
|
|
754
|
+
}),
|
|
755
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
756
|
+
className: Rows_module_css_default.title,
|
|
757
|
+
children: title
|
|
758
|
+
}),
|
|
759
|
+
!row.blank && (0, react_jsx_runtime.jsx)("span", {
|
|
760
|
+
className: Rows_module_css_default.time,
|
|
761
|
+
children: timeLabel(row.updatedAt, now, t)
|
|
762
|
+
}),
|
|
763
|
+
!row.blank && (0, react_jsx_runtime.jsx)("span", {
|
|
764
|
+
className: Rows_module_css_default.rowActions,
|
|
765
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
|
|
766
|
+
open: menuOpen,
|
|
767
|
+
onClose: () => {
|
|
768
|
+
setMenuOpen(false);
|
|
769
|
+
},
|
|
770
|
+
items: sessionMenuItems,
|
|
771
|
+
onSelect: (id) => {
|
|
772
|
+
setMenuOpen(false);
|
|
773
|
+
if (id === "rename") onRename(node.id, row.title);
|
|
774
|
+
if (id === "fork") onFork(node.id);
|
|
775
|
+
if (id === "archive") onArchive(node.id);
|
|
776
|
+
if (id === "delete-session") onDelete(node.id, title);
|
|
777
|
+
},
|
|
778
|
+
portal: true,
|
|
779
|
+
closeOnPointerLeave: true,
|
|
780
|
+
anchor: (0, react_jsx_runtime.jsx)("button", {
|
|
781
|
+
type: "button",
|
|
782
|
+
className: Rows_module_css_default.iconButton,
|
|
783
|
+
"aria-label": t("actions.session.aria", { name: title }),
|
|
784
|
+
onClick: (e) => {
|
|
785
|
+
e.stopPropagation();
|
|
786
|
+
setMenuOpen((v) => !v);
|
|
787
|
+
},
|
|
788
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconEllipsisOutline16, {})
|
|
789
|
+
})
|
|
790
|
+
})
|
|
791
|
+
})
|
|
792
|
+
]
|
|
793
|
+
}),
|
|
794
|
+
content: (0, react_jsx_runtime.jsx)(SessionHoverContent, {
|
|
795
|
+
node,
|
|
796
|
+
now,
|
|
797
|
+
t
|
|
798
|
+
}),
|
|
799
|
+
disabled: menuOpen || drag?.active === true,
|
|
800
|
+
copyText: row.blank ? void 0 : row.title,
|
|
801
|
+
copyLabel: t("copy"),
|
|
802
|
+
copiedLabel: t("hover.copied")
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
//#endregion
|
|
806
|
+
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/ui-workspace/src/client/WorkspacePicker.module.css.mjs
|
|
807
|
+
const css$1 = "._G5b-a_modalAction{min-width:72px}._G5b-a_modalError,._G5b-a_menuStatus{margin-top:8px;font-size:12px;line-height:18px}._G5b-a_modalError{color:var(--dsw-alias-state-error-primary)}._G5b-a_menuStatus{color:var(--dsw-alias-label-secondary)}";
|
|
808
|
+
const tagId$1 = "@deepseek-ai/dsh-client-ui-workspace/WorkspacePicker.module.css";
|
|
809
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
|
|
810
|
+
const tag = document.createElement("style");
|
|
811
|
+
tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-workspace";
|
|
812
|
+
tag.dataset.pluginCss = tagId$1;
|
|
813
|
+
tag.textContent = css$1;
|
|
814
|
+
document.head.appendChild(tag);
|
|
815
|
+
}
|
|
816
|
+
var WorkspacePicker_module_css_default = {
|
|
817
|
+
"menuStatus": "_G5b-a_menuStatus",
|
|
818
|
+
"modalAction": "_G5b-a_modalAction",
|
|
819
|
+
"modalError": "_G5b-a_modalError"
|
|
820
|
+
};
|
|
821
|
+
//#endregion
|
|
822
|
+
//#region lib/types/client/WorkspacePicker.js
|
|
823
|
+
const ADD_WORKSPACE = "::add-workspace";
|
|
824
|
+
/**
|
|
825
|
+
* Render the pick menu plus the adoption error dialog.
|
|
826
|
+
* @param props - owner-controlled flow props.
|
|
827
|
+
* @returns menu + dialog elements.
|
|
828
|
+
*/
|
|
829
|
+
function WorkspacePickFlow({ t, open, anchorRef, useWorkspaces, createWorkspace, useDirectoryFlow, renderDirectoryFlow, onPick, onClose, addOnly = false, side = "bottom", selectedId }) {
|
|
830
|
+
const workspaceSnapshot = useWorkspaces((state) => state);
|
|
831
|
+
const workspaces = workspaceSnapshot.items;
|
|
832
|
+
const getAnchorRect = (0, react.useCallback)(() => anchorRef?.current?.getBoundingClientRect() ?? null, [anchorRef]);
|
|
833
|
+
const [errorOpen, setErrorOpen] = (0, react.useState)(false);
|
|
834
|
+
const [modalError, setModalError] = (0, react.useState)(null);
|
|
835
|
+
const [flowOpen, setFlowOpen] = (0, react.useState)(false);
|
|
836
|
+
const [pickingFolder, setPickingFolder] = (0, react.useState)(false);
|
|
837
|
+
const flowBusy = flowOpen || pickingFolder;
|
|
838
|
+
const flowAvailable = useDirectoryFlow((occupied) => occupied);
|
|
839
|
+
(0, react.useEffect)(() => {
|
|
840
|
+
if (flowOpen && !flowAvailable) setFlowOpen(false);
|
|
841
|
+
}, [flowOpen, flowAvailable]);
|
|
842
|
+
const addEntries = flowAvailable ? [{
|
|
843
|
+
id: ADD_WORKSPACE,
|
|
844
|
+
label: t("menu.addWorkspace"),
|
|
845
|
+
icon: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlusOutline16, { size: 16 }),
|
|
846
|
+
disabled: flowBusy
|
|
847
|
+
}] : [];
|
|
848
|
+
const pinAdd = !addOnly && workspaces.length > 0;
|
|
849
|
+
const items = pinAdd ? workspaces.map((workspace) => ({
|
|
850
|
+
id: workspace.workspaceId,
|
|
851
|
+
label: workspace.title,
|
|
852
|
+
icon: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderClose16, { size: 16 }),
|
|
853
|
+
disabled: flowBusy
|
|
854
|
+
})) : addEntries;
|
|
855
|
+
const menuIsEmpty = items.length === 0;
|
|
856
|
+
const closeModal = () => {
|
|
857
|
+
setErrorOpen(false);
|
|
858
|
+
setModalError(null);
|
|
859
|
+
};
|
|
860
|
+
/** Adopt a picked directory; failures land in the folder-error dialog (Choose again reopens the flow). */
|
|
861
|
+
const adoptDirectory = (path) => createWorkspace({ path }).then((workspace) => {
|
|
862
|
+
setFlowOpen(false);
|
|
863
|
+
onPick(workspace.workspaceId);
|
|
864
|
+
}).catch((reason) => {
|
|
865
|
+
setModalError(reason instanceof Error ? reason.message : String(reason));
|
|
866
|
+
setFlowOpen(false);
|
|
867
|
+
setErrorOpen(true);
|
|
868
|
+
});
|
|
869
|
+
const openDirectoryFlow = (0, react.useCallback)(() => {
|
|
870
|
+
onClose();
|
|
871
|
+
setErrorOpen(false);
|
|
872
|
+
setModalError(null);
|
|
873
|
+
setFlowOpen(true);
|
|
874
|
+
}, [onClose]);
|
|
875
|
+
const listSettled = addOnly || workspaceSnapshot.phase === "ready";
|
|
876
|
+
const addIsTheOnlyEntry = !pinAdd && listSettled && addEntries.length === 1;
|
|
877
|
+
(0, react.useEffect)(() => {
|
|
878
|
+
if (open && addIsTheOnlyEntry && !flowBusy) openDirectoryFlow();
|
|
879
|
+
}, [
|
|
880
|
+
open,
|
|
881
|
+
addIsTheOnlyEntry,
|
|
882
|
+
flowBusy,
|
|
883
|
+
openDirectoryFlow
|
|
884
|
+
]);
|
|
885
|
+
/** Owner side of the flow conversation: adopt keeps the flow open (busy) until the Host answers. */
|
|
886
|
+
const flowOwner = {
|
|
887
|
+
open: flowOpen,
|
|
888
|
+
busy: pickingFolder,
|
|
889
|
+
onPicked: (path) => {
|
|
890
|
+
setPickingFolder(true);
|
|
891
|
+
adoptDirectory(path).finally(() => {
|
|
892
|
+
setPickingFolder(false);
|
|
893
|
+
});
|
|
894
|
+
},
|
|
895
|
+
onCancel: () => {
|
|
896
|
+
setFlowOpen(false);
|
|
897
|
+
},
|
|
898
|
+
onError: (message) => {
|
|
899
|
+
setFlowOpen(false);
|
|
900
|
+
setModalError(message);
|
|
901
|
+
setErrorOpen(true);
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
const handleSelect = (id) => {
|
|
905
|
+
if (id === ADD_WORKSPACE) {
|
|
906
|
+
openDirectoryFlow();
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
onPick(id);
|
|
910
|
+
};
|
|
911
|
+
return (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
912
|
+
(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
|
|
913
|
+
open: open && !addIsTheOnlyEntry && !menuIsEmpty,
|
|
914
|
+
anchor: null,
|
|
915
|
+
items,
|
|
916
|
+
...pinAdd ? { footer: addEntries } : {},
|
|
917
|
+
selectedId,
|
|
918
|
+
onSelect: handleSelect,
|
|
919
|
+
onClose,
|
|
920
|
+
side,
|
|
921
|
+
portal: true,
|
|
922
|
+
getAnchorRect
|
|
923
|
+
}),
|
|
924
|
+
open && !addIsTheOnlyEntry && !menuIsEmpty && workspaceSnapshot.phase === "pending" && (0, react_jsx_runtime.jsx)("div", {
|
|
925
|
+
className: WorkspacePicker_module_css_default.menuStatus,
|
|
926
|
+
role: "status",
|
|
927
|
+
children: t("picker.loading")
|
|
928
|
+
}),
|
|
929
|
+
renderDirectoryFlow(flowOwner),
|
|
930
|
+
(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
931
|
+
open: errorOpen,
|
|
932
|
+
onClose: closeModal,
|
|
933
|
+
closeLabel: t("close"),
|
|
934
|
+
title: t("folderError.title"),
|
|
935
|
+
footer: (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
936
|
+
variant: "outline",
|
|
937
|
+
className: WorkspacePicker_module_css_default.modalAction,
|
|
938
|
+
onClick: closeModal,
|
|
939
|
+
children: t("cancel")
|
|
940
|
+
}), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
941
|
+
variant: "primary",
|
|
942
|
+
className: WorkspacePicker_module_css_default.modalAction,
|
|
943
|
+
disabled: !flowAvailable,
|
|
944
|
+
onClick: openDirectoryFlow,
|
|
945
|
+
children: t("folderError.retry")
|
|
946
|
+
})] }),
|
|
947
|
+
children: (0, react_jsx_runtime.jsx)("div", {
|
|
948
|
+
className: WorkspacePicker_module_css_default.modalError,
|
|
949
|
+
role: "alert",
|
|
950
|
+
children: modalError
|
|
951
|
+
})
|
|
952
|
+
})
|
|
953
|
+
] });
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* The conversation empty-state registration: adapts the owner share to the
|
|
957
|
+
* core flow (all state and semantics live in the flow / the owner).
|
|
958
|
+
* @param props - empty-state slot props (owner share + injected creation callback).
|
|
959
|
+
* @returns the flow element.
|
|
960
|
+
*/
|
|
961
|
+
function WorkspacePicker({ open, anchorRef, useWorkspaces, selectedId, onPick, onClose, createWorkspace, useDirectoryFlow, renderSlot, t }) {
|
|
962
|
+
return (0, react_jsx_runtime.jsx)(WorkspacePickFlow, {
|
|
963
|
+
t,
|
|
964
|
+
open,
|
|
965
|
+
anchorRef,
|
|
966
|
+
useWorkspaces,
|
|
967
|
+
createWorkspace,
|
|
968
|
+
useDirectoryFlow,
|
|
969
|
+
renderDirectoryFlow: (owner) => renderSlot("conversation.hero.workspace.directoryFlow", owner),
|
|
970
|
+
selectedId,
|
|
971
|
+
onPick,
|
|
972
|
+
onClose
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
//#endregion
|
|
976
|
+
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/ui-workspace/src/client/WorkspaceBrowser.module.css.mjs
|
|
977
|
+
const css = ".qDHVXG_root{--dsh-session-list-edge-inset:var(--dsh-sidebar-inline-padding);--dsh-session-list-scrollbar-width:8px;--dsh-session-list-scrollbar-offset:2px;box-sizing:border-box;min-height:0;padding-right:var(--dsh-session-list-edge-inset);flex-direction:column;flex:1;display:flex}.qDHVXG_root.qDHVXG_rail{padding-right:0}.qDHVXG_iconButton{cursor:pointer;width:28px;height:28px;color:var(--dsw-alias-label-secondary);background:0 0;border:none;border-radius:50%;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.qDHVXG_iconButton:hover{background:var(--dsw-alias-interactive-bg-hover)}.qDHVXG_sectionHeader{box-sizing:border-box;height:36px;color:var(--dsw-alias-label-tertiary);border-radius:12px;flex:none;justify-content:flex-end;align-items:center;gap:4px;margin-bottom:4px;padding-left:4px;display:flex;overflow:hidden}.qDHVXG_root:not(.qDHVXG_rail) .qDHVXG_sectionHeader{margin-top:2px;margin-right:-4px}.qDHVXG_sectionLabel{white-space:nowrap;opacity:1;visibility:visible;min-width:0;max-width:45%;transition:max-width .18s var(--ds-ease-in-out), margin-right .18s var(--ds-ease-in-out), opacity .12s var(--ds-ease-in-out), transform .18s var(--ds-ease-in-out), visibility 0s linear;flex:none;line-height:20px;overflow:hidden}.qDHVXG_sectionLabelHidden{opacity:0;visibility:hidden;max-width:0;margin-right:-4px;transition-delay:0s,0s,0s,0s,.18s;transform:translate(-4px)}.qDHVXG_searchSlot{box-sizing:border-box;min-width:0;max-width:28px;transition:max-width .18s var(--ds-ease-in-out), padding-left .18s var(--ds-ease-in-out);flex:1;align-items:center;margin-left:auto;padding-left:0;display:flex}.qDHVXG_searchSlotExpanded{max-width:100%;padding-left:0}.qDHVXG_headerActions{opacity:1;visibility:visible;max-width:60px;transition:max-width .18s var(--ds-ease-in-out), opacity .12s var(--ds-ease-in-out), transform .18s var(--ds-ease-in-out), visibility 0s linear;flex:none;align-items:center;gap:4px;display:flex;overflow:hidden}.qDHVXG_headerActionsHidden{opacity:0;visibility:hidden;pointer-events:none;max-width:0;transition-delay:0s,0s,0s,.18s;transform:translate(4px)}.qDHVXG_search{box-sizing:border-box;cursor:text;width:100%;height:28px;color:var(--dsw-alias-label-secondary);transition:width .18s var(--ds-ease-in-out), padding .18s var(--ds-ease-in-out), border-color .18s var(--ds-ease-in-out), background-color .18s var(--ds-ease-in-out);background:0 0;border:none;border-radius:50%;flex:none;align-items:center;gap:0;margin:0;padding:0;display:flex;overflow:hidden}.qDHVXG_searchExpanded{border:1px solid var(--dsw-alias-border-l2);width:calc(100% + 4px);height:30px;color:var(--dsw-alias-label-caption);background:0 0;border-radius:10px;margin-inline:-2px;padding:0 4px 0 0}.qDHVXG_searchButton{cursor:pointer;width:28px;height:28px;color:inherit;background:0 0;border:none;border-radius:50%;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.qDHVXG_searchExpanded .qDHVXG_searchButton{width:28px;height:30px}.qDHVXG_searchButton:hover{background:var(--dsw-alias-interactive-bg-hover)}.qDHVXG_searchExpanded .qDHVXG_searchButton:hover{background:0 0}.qDHVXG_searchInput{opacity:0;pointer-events:none;width:0;min-width:0;color:var(--dsw-alias-label-primary);transition:opacity .12s var(--ds-ease-in-out);background:0 0;border:none;outline:none;flex:1;font-size:13px;line-height:18px}.qDHVXG_searchExpanded .qDHVXG_searchInput{opacity:1;pointer-events:auto;margin-left:-2px}.qDHVXG_searchInput::placeholder{color:var(--dsw-alias-label-tertiary)}.qDHVXG_clearButton{cursor:pointer;width:24px;height:24px;color:var(--dsw-alias-label-secondary);background:0 0;border:none;border-radius:50%;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.qDHVXG_clearButton:hover{background:var(--dsw-alias-interactive-bg-hover)}.qDHVXG_rail .qDHVXG_sectionHeader{justify-content:flex-start;gap:0;margin-bottom:12px;padding-left:0}.qDHVXG_rail .qDHVXG_headerActions{max-width:none}.qDHVXG_rail .qDHVXG_iconButton{width:36px;height:36px;color:var(--dsw-alias-label-primary)}.qDHVXG_rail .qDHVXG_search{background:0 0;border-color:#0000;gap:0;width:36px;height:36px;margin:0 0 12px;padding:0}.qDHVXG_rail .qDHVXG_searchButton{width:36px;height:36px;color:var(--dsw-alias-label-primary)}.qDHVXG_rail .qDHVXG_searchButton:hover{background:var(--dsw-alias-interactive-bg-hover)}.qDHVXG_listArea{min-height:0;margin-left:-4px;margin-right:calc(-1 * var(--dsh-session-list-edge-inset));flex-direction:column;flex:1;padding-left:4px;display:flex;overflow:visible}.qDHVXG_rail .qDHVXG_listArea{margin-left:0;margin-right:0;padding-left:0}.qDHVXG_treeBody{flex-direction:column;flex:1;min-height:0;display:flex;position:relative}.qDHVXG_fade{left:0;right:var(--dsh-session-list-edge-inset);background:linear-gradient(to bottom, transparent, var(--dsw-specific-sidebar-fill));pointer-events:none;height:24px;position:absolute;bottom:0}.qDHVXG_wide{animation:qDHVXG_wide-in .2s var(--ds-ease-in-out)}@keyframes qDHVXG_wide-in{0%{opacity:0}}.qDHVXG_list{min-height:0;margin-left:-4px;margin-right:var(--dsh-session-list-scrollbar-offset);padding-left:4px;padding-right:calc(var(--dsh-session-list-edge-inset) - var(--dsh-session-list-scrollbar-width) - var(--dsh-session-list-scrollbar-offset));scrollbar-gutter:stable;flex:1;padding-bottom:16px;overflow-y:auto}.qDHVXG_flatList>*+*,.qDHVXG_searchTree>[role=treeitem]+[role=treeitem],.qDHVXG_groupSection>*+*{margin-top:2px}.qDHVXG_searchStatus,.qDHVXG_searchWarning{color:var(--dsw-alias-label-tertiary);padding:10px 12px;font-size:12px;line-height:18px}.qDHVXG_searchWarning{color:var(--dsw-alias-label-secondary)}.qDHVXG_groupSection{position:relative}.qDHVXG_groupSection+.qDHVXG_groupSection{margin-top:4px}.qDHVXG_listTopDropIndicator,.qDHVXG_workspaceDropBefore:before,.qDHVXG_workspaceDropAfter:after{content:\"\";z-index:1;background:linear-gradient(55deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 0 / 5px 7px no-repeat, linear-gradient(125deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 5px / 5px 7px no-repeat, linear-gradient(var(--dsw-alias-state-business-primary) 0 0) 4px 5px / calc(100% - 4px) 2px no-repeat;pointer-events:none;height:12px;position:absolute;left:0;right:0}.qDHVXG_listTopDropIndicator{top:-8px;left:0;right:var(--dsh-session-list-edge-inset)}.qDHVXG_listTopDropActive>.qDHVXG_workspaceDropBefore:first-child:before{display:none}.qDHVXG_workspaceDropBefore:before{top:-8px}.qDHVXG_workspaceDropAfter:after{bottom:-8px}.qDHVXG_sessionOverflowButton{cursor:pointer;text-align:left;width:100%;height:28px;color:var(--dsw-alias-label-tertiary);background:0 0;border:none;border-radius:8px;padding:0 12px 0 28px;font-size:12px}.qDHVXG_groupSection>.qDHVXG_sessionOverflowButton{margin-top:0}.qDHVXG_sessionOverflowButton:hover{color:var(--dsw-alias-label-secondary);background:0 0}.qDHVXG_empty{color:var(--dsw-alias-label-tertiary);padding:16px 12px;font-size:13px}.qDHVXG_renameInput{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);width:100%;height:44px;color:var(--dsw-alias-label-primary);background:0 0;border-radius:22px;outline:none;padding:7px 14px;font-size:14px;font-weight:400;line-height:22px}.qDHVXG_renameInput:disabled{color:var(--dsw-alias-label-dimmed)}.qDHVXG_renameError{color:var(--dsw-alias-state-error-primary);margin-top:8px;font-size:12px;line-height:18px}.qDHVXG_deleteAction:not(:disabled){color:var(--dsw-alias-state-error-primary)}.qDHVXG_deleteStatus{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}@media (prefers-reduced-motion:reduce){.qDHVXG_wide{animation:none}.qDHVXG_search,.qDHVXG_sectionLabel,.qDHVXG_searchSlot,.qDHVXG_searchInput,.qDHVXG_headerActions{transition:none}}";
|
|
978
|
+
const tagId = "@deepseek-ai/dsh-client-ui-workspace/WorkspaceBrowser.module.css";
|
|
979
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
980
|
+
const tag = document.createElement("style");
|
|
981
|
+
tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-workspace";
|
|
982
|
+
tag.dataset.pluginCss = tagId;
|
|
983
|
+
tag.textContent = css;
|
|
984
|
+
document.head.appendChild(tag);
|
|
985
|
+
}
|
|
986
|
+
var WorkspaceBrowser_module_css_default = {
|
|
987
|
+
"clearButton": "qDHVXG_clearButton",
|
|
988
|
+
"deleteAction": "qDHVXG_deleteAction",
|
|
989
|
+
"deleteStatus": "qDHVXG_deleteStatus",
|
|
990
|
+
"empty": "qDHVXG_empty",
|
|
991
|
+
"fade": "qDHVXG_fade",
|
|
992
|
+
"flatList": "qDHVXG_flatList",
|
|
993
|
+
"groupSection": "qDHVXG_groupSection",
|
|
994
|
+
"headerActions": "qDHVXG_headerActions",
|
|
995
|
+
"headerActionsHidden": "qDHVXG_headerActionsHidden",
|
|
996
|
+
"iconButton": "qDHVXG_iconButton",
|
|
997
|
+
"list": "qDHVXG_list",
|
|
998
|
+
"listArea": "qDHVXG_listArea",
|
|
999
|
+
"listTopDropActive": "qDHVXG_listTopDropActive",
|
|
1000
|
+
"listTopDropIndicator": "qDHVXG_listTopDropIndicator",
|
|
1001
|
+
"rail": "qDHVXG_rail",
|
|
1002
|
+
"renameError": "qDHVXG_renameError",
|
|
1003
|
+
"renameInput": "qDHVXG_renameInput",
|
|
1004
|
+
"root": "qDHVXG_root",
|
|
1005
|
+
"search": "qDHVXG_search",
|
|
1006
|
+
"searchButton": "qDHVXG_searchButton",
|
|
1007
|
+
"searchExpanded": "qDHVXG_searchExpanded",
|
|
1008
|
+
"searchInput": "qDHVXG_searchInput",
|
|
1009
|
+
"searchSlot": "qDHVXG_searchSlot",
|
|
1010
|
+
"searchSlotExpanded": "qDHVXG_searchSlotExpanded",
|
|
1011
|
+
"searchStatus": "qDHVXG_searchStatus",
|
|
1012
|
+
"searchTree": "qDHVXG_searchTree",
|
|
1013
|
+
"searchWarning": "qDHVXG_searchWarning",
|
|
1014
|
+
"sectionHeader": "qDHVXG_sectionHeader",
|
|
1015
|
+
"sectionLabel": "qDHVXG_sectionLabel",
|
|
1016
|
+
"sectionLabelHidden": "qDHVXG_sectionLabelHidden",
|
|
1017
|
+
"sessionOverflowButton": "qDHVXG_sessionOverflowButton",
|
|
1018
|
+
"treeBody": "qDHVXG_treeBody",
|
|
1019
|
+
"wide": "qDHVXG_wide",
|
|
1020
|
+
"wide-in": "qDHVXG_wide-in",
|
|
1021
|
+
"workspaceDropAfter": "qDHVXG_workspaceDropAfter",
|
|
1022
|
+
"workspaceDropBefore": "qDHVXG_workspaceDropBefore"
|
|
1023
|
+
};
|
|
1024
|
+
//#endregion
|
|
1025
|
+
//#region lib/types/client/WorkspaceBrowser.js
|
|
1026
|
+
/**
|
|
1027
|
+
* The workspace/session browsing region filling the sidebar shell's
|
|
1028
|
+
* `sidebar.workspaces` hole: section header (title + view options + add
|
|
1029
|
+
* workspace), search, the grouped tree or flat list, and the workspace
|
|
1030
|
+
* dialogs. Wide state renders the full browser; rail state renders the two
|
|
1031
|
+
* region icons (search / add workspace) as 36px controls on the shell's shared
|
|
1032
|
+
* rail entry path, each requesting expansion through the owner share. Adding
|
|
1033
|
+
* is the header button's one action, so it raises the directory flow with no
|
|
1034
|
+
* menu in between; the flow and its error dialog live in WorkspacePicker
|
|
1035
|
+
* (same package — direct composition, no slot between them).
|
|
1036
|
+
*/
|
|
1037
|
+
/**
|
|
1038
|
+
* Column slide length (--ds-transition-duration-slow): rail-search focus waits it out —
|
|
1039
|
+
* focus() forces a synchronous layout and would jank the slide.
|
|
1040
|
+
*/
|
|
1041
|
+
const EXPAND_SLIDE_MS = 300;
|
|
1042
|
+
/** Pause between the latest keystroke and a Host content-search request. */
|
|
1043
|
+
const SEARCH_DEBOUNCE_MS = 250;
|
|
1044
|
+
/** `session.search` wire bound, measured in JavaScript UTF-16 code units. */
|
|
1045
|
+
const SEARCH_QUERY_MAX_CODE_UNITS = 500;
|
|
1046
|
+
/** Session rows visible per Workspace before the local overflow control. */
|
|
1047
|
+
const COLLAPSED_SESSION_LIMIT = 5;
|
|
1048
|
+
/** Keep controlled input and RPC payload inside the session.search wire contract. */
|
|
1049
|
+
function sanitizeSearchQuery(value) {
|
|
1050
|
+
const withoutNul = value.replaceAll("\0", "");
|
|
1051
|
+
if (withoutNul.length <= SEARCH_QUERY_MAX_CODE_UNITS) return withoutNul;
|
|
1052
|
+
let end = SEARCH_QUERY_MAX_CODE_UNITS;
|
|
1053
|
+
const last = withoutNul.charCodeAt(end - 1);
|
|
1054
|
+
const next = withoutNul.charCodeAt(end);
|
|
1055
|
+
if (last >= 55296 && last <= 56319 && next >= 56320 && next <= 57343) end--;
|
|
1056
|
+
return withoutNul.slice(0, end);
|
|
1057
|
+
}
|
|
1058
|
+
/** Immutable membership toggle for the local expand-all array. */
|
|
1059
|
+
function toggled(list, key) {
|
|
1060
|
+
return list.includes(key) ? list.filter((k) => k !== key) : [...list, key];
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Accept the native drag at document level while a row drag is active: row
|
|
1064
|
+
* hover still owns the insertion marker, and releasing outside the list must
|
|
1065
|
+
* not be rendered as a rejected drop before dragend commits that last marker.
|
|
1066
|
+
*/
|
|
1067
|
+
function useNativeDragAcceptance(active) {
|
|
1068
|
+
(0, react.useEffect)(() => {
|
|
1069
|
+
if (!active) return;
|
|
1070
|
+
const acceptDrag = (event) => {
|
|
1071
|
+
event.preventDefault();
|
|
1072
|
+
if (event.dataTransfer !== null) event.dataTransfer.dropEffect = "move";
|
|
1073
|
+
};
|
|
1074
|
+
const acceptDrop = (event) => {
|
|
1075
|
+
event.preventDefault();
|
|
1076
|
+
};
|
|
1077
|
+
document.addEventListener("dragover", acceptDrag);
|
|
1078
|
+
document.addEventListener("drop", acceptDrop);
|
|
1079
|
+
return () => {
|
|
1080
|
+
document.removeEventListener("dragover", acceptDrag);
|
|
1081
|
+
document.removeEventListener("drop", acceptDrop);
|
|
1082
|
+
};
|
|
1083
|
+
}, [active]);
|
|
1084
|
+
}
|
|
1085
|
+
/** Reconcile a stored view order with the Workspace's current session account. */
|
|
1086
|
+
function reconciledSessionOrder(sessionIds, stored) {
|
|
1087
|
+
if (stored === void 0) return [...sessionIds];
|
|
1088
|
+
const byId = new Map(sessionIds.map((id) => [id, id]));
|
|
1089
|
+
const ordered = [];
|
|
1090
|
+
const included = /* @__PURE__ */ new Set();
|
|
1091
|
+
for (const key of stored) {
|
|
1092
|
+
const id = byId.get(key);
|
|
1093
|
+
if (id === void 0 || included.has(key)) continue;
|
|
1094
|
+
ordered.push(id);
|
|
1095
|
+
included.add(key);
|
|
1096
|
+
}
|
|
1097
|
+
for (const id of sessionIds) {
|
|
1098
|
+
if (included.has(id)) continue;
|
|
1099
|
+
ordered.push(id);
|
|
1100
|
+
}
|
|
1101
|
+
return ordered;
|
|
1102
|
+
}
|
|
1103
|
+
/** Newest update first with stable Session identity as the tie-break. */
|
|
1104
|
+
function compareSessionRecency(a, b, byId) {
|
|
1105
|
+
const aUpdatedAt = byId[a]?.updatedAt ?? Number.NEGATIVE_INFINITY;
|
|
1106
|
+
const bUpdatedAt = byId[b]?.updatedAt ?? Number.NEGATIVE_INFINITY;
|
|
1107
|
+
if (aUpdatedAt !== bUpdatedAt) return bUpdatedAt - aUpdatedAt;
|
|
1108
|
+
return a < b ? -1 : 1;
|
|
1109
|
+
}
|
|
1110
|
+
/** Reconcile one editable order account and apply its activity-promotion policy. */
|
|
1111
|
+
function nextSessionOrderAccount({ sessionIds, previousOrder, previousUpdatedAt, list, orderBy, sortByRecency }) {
|
|
1112
|
+
let order = reconciledSessionOrder(sessionIds, previousOrder);
|
|
1113
|
+
if (sortByRecency) order.sort((a, b) => compareSessionRecency(a, b, list.byId));
|
|
1114
|
+
else if (orderBy === "updated") {
|
|
1115
|
+
const promoted = sessionIds.filter((id) => {
|
|
1116
|
+
const session = list.byId[id];
|
|
1117
|
+
return session !== void 0 && (previousUpdatedAt[id] === void 0 || session.updatedAt > previousUpdatedAt[id]);
|
|
1118
|
+
}).sort((a, b) => compareSessionRecency(a, b, list.byId));
|
|
1119
|
+
if (promoted.length > 0) {
|
|
1120
|
+
const promotedIds = new Set(promoted);
|
|
1121
|
+
order = [...promoted, ...order.filter((id) => !promotedIds.has(id))];
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
const updatedAt = {};
|
|
1125
|
+
for (const id of sessionIds) {
|
|
1126
|
+
const session = list.byId[id];
|
|
1127
|
+
if (session !== void 0) updatedAt[id] = session.updatedAt;
|
|
1128
|
+
}
|
|
1129
|
+
const orderChanged = previousOrder === void 0 || order.length !== previousOrder.length || order.some((id, index) => id !== previousOrder[index]);
|
|
1130
|
+
const timestampsChanged = Object.keys(updatedAt).length !== Object.keys(previousUpdatedAt).length || Object.entries(updatedAt).some(([id, timestamp]) => previousUpdatedAt[id] !== timestamp);
|
|
1131
|
+
return {
|
|
1132
|
+
order,
|
|
1133
|
+
updatedAt,
|
|
1134
|
+
changed: orderChanged || timestampsChanged
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
/** Grouping and ordering menu; own open state so it resets with the wide chrome. */
|
|
1138
|
+
function ViewOptionsMenu({ groupBy, orderBy, onGroupPick, onOrderPick, t }) {
|
|
1139
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
1140
|
+
return (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
|
|
1141
|
+
open,
|
|
1142
|
+
onClose: () => {
|
|
1143
|
+
setOpen(false);
|
|
1144
|
+
},
|
|
1145
|
+
items: [
|
|
1146
|
+
{
|
|
1147
|
+
type: "label",
|
|
1148
|
+
id: "group-by",
|
|
1149
|
+
text: t("groupBy.label")
|
|
1150
|
+
},
|
|
1151
|
+
{
|
|
1152
|
+
id: "workspace",
|
|
1153
|
+
label: t("groupBy.workspace")
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
id: "flat",
|
|
1157
|
+
label: t("groupBy.flat")
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
type: "separator",
|
|
1161
|
+
id: "order-by-separator"
|
|
1162
|
+
},
|
|
1163
|
+
{
|
|
1164
|
+
type: "label",
|
|
1165
|
+
id: "order-by",
|
|
1166
|
+
text: t("orderBy.label")
|
|
1167
|
+
},
|
|
1168
|
+
{
|
|
1169
|
+
id: "manual",
|
|
1170
|
+
label: t("orderBy.manual")
|
|
1171
|
+
},
|
|
1172
|
+
{
|
|
1173
|
+
id: "updated",
|
|
1174
|
+
label: t("orderBy.updated")
|
|
1175
|
+
}
|
|
1176
|
+
],
|
|
1177
|
+
selectedIds: [groupBy, orderBy],
|
|
1178
|
+
onSelect: (id) => {
|
|
1179
|
+
if (id === "workspace" || id === "flat") onGroupPick(id);
|
|
1180
|
+
else if (id === "manual" || id === "updated") onOrderPick(id);
|
|
1181
|
+
setOpen(false);
|
|
1182
|
+
},
|
|
1183
|
+
align: "end",
|
|
1184
|
+
dense: true,
|
|
1185
|
+
portal: true,
|
|
1186
|
+
anchor: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
1187
|
+
label: t("viewOptions.label"),
|
|
1188
|
+
side: "bottom",
|
|
1189
|
+
delayMs: 500,
|
|
1190
|
+
children: (0, react_jsx_runtime.jsx)("button", {
|
|
1191
|
+
type: "button",
|
|
1192
|
+
className: clsx(WorkspaceBrowser_module_css_default.iconButton, WorkspaceBrowser_module_css_default.wide),
|
|
1193
|
+
"aria-label": t("viewOptions.label"),
|
|
1194
|
+
onClick: () => {
|
|
1195
|
+
setOpen((v) => !v);
|
|
1196
|
+
},
|
|
1197
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPersonalizationOutline16, {})
|
|
1198
|
+
})
|
|
1199
|
+
})
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
/** Resolve an insertion side from the full rendered workspace group. */
|
|
1203
|
+
function workspaceGroupHalf(e) {
|
|
1204
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
1205
|
+
return e.clientY < rect.top + rect.height / 2 ? "before" : "after";
|
|
1206
|
+
}
|
|
1207
|
+
/** The scrolling session tree; unmounting drops the sessions subscription and expand-all state. */
|
|
1208
|
+
function SessionTree({ useSessions, startSession, open, forkSession, workspaces, archivedSessionIds, onRenameRequest, onDeleteRequest, onSessionRename, onSessionArchive, onSessionDelete, insertWorkspaceBefore, insertSessionBefore, orderBy, groupExpansion, setGroupExpanded, sessionOrderByAccount, sessionUpdatedAtByAccount, syncSessionOrderAccount, setSessionOrder, home, t }) {
|
|
1209
|
+
const list = useSessions((s) => s);
|
|
1210
|
+
const current = list.current;
|
|
1211
|
+
const [expandedSessionGroups, setExpandedSessionGroups] = (0, react.useState)([]);
|
|
1212
|
+
const [drag, setDrag] = (0, react.useState)(null);
|
|
1213
|
+
const sessionDropCommitted = (0, react.useRef)(false);
|
|
1214
|
+
const [workspaceDrag, setWorkspaceDrag] = (0, react.useState)(null);
|
|
1215
|
+
const workspaceDropCommitted = (0, react.useRef)(false);
|
|
1216
|
+
const previousOrderBy = (0, react.useRef)(orderBy);
|
|
1217
|
+
useNativeDragAcceptance(drag !== null || workspaceDrag !== null);
|
|
1218
|
+
const currentGroup = current === void 0 ? void 0 : workspaces.find((w) => w.sessionIds.includes(current))?.workspaceId ?? "";
|
|
1219
|
+
(0, react.useEffect)(() => {
|
|
1220
|
+
if (current === void 0 || currentGroup === void 0 || Object.hasOwn(groupExpansion, currentGroup)) return;
|
|
1221
|
+
setGroupExpanded(currentGroup, true);
|
|
1222
|
+
}, [
|
|
1223
|
+
current,
|
|
1224
|
+
currentGroup,
|
|
1225
|
+
setGroupExpanded,
|
|
1226
|
+
groupExpansion
|
|
1227
|
+
]);
|
|
1228
|
+
const expandedGroups = (0, react.useMemo)(() => Object.entries(groupExpansion).filter(([, expanded]) => expanded).map(([key]) => key), [groupExpansion]);
|
|
1229
|
+
const ungroupedSessionIds = (0, react.useMemo)(() => {
|
|
1230
|
+
const accounted = new Set(workspaces.flatMap((workspace) => workspace.sessionIds));
|
|
1231
|
+
return list.ids.filter((id) => list.byId[id] !== void 0 && !accounted.has(id));
|
|
1232
|
+
}, [list, workspaces]);
|
|
1233
|
+
(0, react.useEffect)(() => {
|
|
1234
|
+
if (list.phase !== "ready") return;
|
|
1235
|
+
const switchedToUpdated = previousOrderBy.current !== "updated" && orderBy === "updated";
|
|
1236
|
+
previousOrderBy.current = orderBy;
|
|
1237
|
+
const accounts = [...workspaces.map((workspace) => ({
|
|
1238
|
+
key: workspace.workspaceId,
|
|
1239
|
+
sessionIds: workspace.sessionIds.filter((id) => list.byId[id] !== void 0)
|
|
1240
|
+
})), {
|
|
1241
|
+
key: "",
|
|
1242
|
+
sessionIds: ungroupedSessionIds
|
|
1243
|
+
}];
|
|
1244
|
+
for (const { key, sessionIds } of accounts) {
|
|
1245
|
+
const previousOrder = sessionOrderByAccount[key];
|
|
1246
|
+
const next = nextSessionOrderAccount({
|
|
1247
|
+
sessionIds,
|
|
1248
|
+
previousOrder,
|
|
1249
|
+
previousUpdatedAt: sessionUpdatedAtByAccount[key] ?? {},
|
|
1250
|
+
list,
|
|
1251
|
+
orderBy,
|
|
1252
|
+
sortByRecency: orderBy === "updated" && (previousOrder === void 0 || switchedToUpdated)
|
|
1253
|
+
});
|
|
1254
|
+
if (next.changed) syncSessionOrderAccount(key, next.order.map((id) => id), next.updatedAt);
|
|
1255
|
+
}
|
|
1256
|
+
}, [
|
|
1257
|
+
list,
|
|
1258
|
+
orderBy,
|
|
1259
|
+
sessionOrderByAccount,
|
|
1260
|
+
sessionUpdatedAtByAccount,
|
|
1261
|
+
syncSessionOrderAccount,
|
|
1262
|
+
ungroupedSessionIds,
|
|
1263
|
+
workspaces
|
|
1264
|
+
]);
|
|
1265
|
+
const orderedWorkspaces = (0, react.useMemo)(() => {
|
|
1266
|
+
return workspaces.map((workspace) => {
|
|
1267
|
+
const stored = sessionOrderByAccount[workspace.workspaceId];
|
|
1268
|
+
const sessionIds = reconciledSessionOrder(workspace.sessionIds, stored);
|
|
1269
|
+
return {
|
|
1270
|
+
...workspace,
|
|
1271
|
+
sessionIds
|
|
1272
|
+
};
|
|
1273
|
+
});
|
|
1274
|
+
}, [sessionOrderByAccount, workspaces]);
|
|
1275
|
+
const orderedUngroupedSessionIds = (0, react.useMemo)(() => reconciledSessionOrder(ungroupedSessionIds, sessionOrderByAccount[""]), [sessionOrderByAccount, ungroupedSessionIds]);
|
|
1276
|
+
const groups = (0, react.useMemo)(() => deriveGroups(list, orderedWorkspaces, archivedSessionIds, {
|
|
1277
|
+
expandedGroups,
|
|
1278
|
+
...sessionOrderByAccount[""] === void 0 ? {} : { ungroupedOrder: sessionOrderByAccount[""] }
|
|
1279
|
+
}), [
|
|
1280
|
+
list,
|
|
1281
|
+
orderedWorkspaces,
|
|
1282
|
+
archivedSessionIds,
|
|
1283
|
+
expandedGroups,
|
|
1284
|
+
sessionOrderByAccount
|
|
1285
|
+
]);
|
|
1286
|
+
const now = Date.now();
|
|
1287
|
+
const commitSessionDrag = (activeDrag, over) => {
|
|
1288
|
+
if (sessionDropCommitted.current) return;
|
|
1289
|
+
sessionDropCommitted.current = true;
|
|
1290
|
+
setDrag(null);
|
|
1291
|
+
const group = groups.find((candidate) => candidate.key === activeDrag.accountKey);
|
|
1292
|
+
if (group === void 0) return;
|
|
1293
|
+
const targetIndex = group.sessions.findIndex((session) => session.id === over.id);
|
|
1294
|
+
if (targetIndex === -1) return;
|
|
1295
|
+
const anchor = over.half === "before" ? over.id : group.sessions[targetIndex + 1]?.id;
|
|
1296
|
+
if (anchor === activeDrag.sessionId) return;
|
|
1297
|
+
const sourceIndex = group.sessions.findIndex((session) => session.id === activeDrag.sessionId);
|
|
1298
|
+
const anchorIndex = anchor === void 0 ? group.sessions.length : group.sessions.findIndex((session) => session.id === anchor);
|
|
1299
|
+
if (sourceIndex !== -1 && (anchorIndex === sourceIndex || anchorIndex === sourceIndex + 1)) return;
|
|
1300
|
+
const accountSessionIds = activeDrag.accountKey === "" ? orderedUngroupedSessionIds : orderedWorkspaces.find((workspace) => workspace.workspaceId === activeDrag.accountKey)?.sessionIds;
|
|
1301
|
+
if (accountSessionIds === void 0) return;
|
|
1302
|
+
const nextOrder = accountSessionIds.filter((id) => id !== activeDrag.sessionId);
|
|
1303
|
+
const insertAt = anchor === void 0 ? nextOrder.length : nextOrder.indexOf(anchor);
|
|
1304
|
+
nextOrder.splice(insertAt === -1 ? nextOrder.length : insertAt, 0, activeDrag.sessionId);
|
|
1305
|
+
setSessionOrder(activeDrag.accountKey, nextOrder.map((id) => id));
|
|
1306
|
+
if (orderBy === "updated" || activeDrag.accountKey === "") return;
|
|
1307
|
+
insertSessionBefore(activeDrag.accountKey, activeDrag.sessionId, anchor).catch((reason) => {
|
|
1308
|
+
console.warn("session reorder rejected:", reason);
|
|
1309
|
+
});
|
|
1310
|
+
};
|
|
1311
|
+
const commitWorkspaceDrag = (activeDrag, over) => {
|
|
1312
|
+
if (workspaceDropCommitted.current) return;
|
|
1313
|
+
workspaceDropCommitted.current = true;
|
|
1314
|
+
setWorkspaceDrag(null);
|
|
1315
|
+
const rowIndex = workspaces.findIndex((workspace) => workspace.workspaceId === over.id);
|
|
1316
|
+
if (rowIndex === -1) return;
|
|
1317
|
+
const anchor = over.half === "before" ? over.id : workspaces[rowIndex + 1]?.workspaceId;
|
|
1318
|
+
if (anchor === activeDrag.workspaceId) return;
|
|
1319
|
+
const sourceIndex = workspaces.findIndex((workspace) => workspace.workspaceId === activeDrag.workspaceId);
|
|
1320
|
+
const anchorIndex = anchor === void 0 ? workspaces.length : workspaces.findIndex((workspace) => workspace.workspaceId === anchor);
|
|
1321
|
+
if (sourceIndex !== -1 && (anchorIndex === sourceIndex || anchorIndex === sourceIndex + 1)) return;
|
|
1322
|
+
insertWorkspaceBefore(activeDrag.workspaceId, anchor).catch((reason) => {
|
|
1323
|
+
console.warn("workspace reorder rejected:", reason);
|
|
1324
|
+
});
|
|
1325
|
+
};
|
|
1326
|
+
const workspaceDropAtListStart = groups[0]?.workspaceId !== void 0 && workspaceDrag?.over?.id === groups[0].workspaceId && workspaceDrag.over.half === "before";
|
|
1327
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
1328
|
+
className: clsx(WorkspaceBrowser_module_css_default.treeBody, WorkspaceBrowser_module_css_default.wide),
|
|
1329
|
+
children: [
|
|
1330
|
+
workspaceDropAtListStart && (0, react_jsx_runtime.jsx)("span", {
|
|
1331
|
+
className: WorkspaceBrowser_module_css_default.listTopDropIndicator,
|
|
1332
|
+
"aria-hidden": "true"
|
|
1333
|
+
}),
|
|
1334
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
1335
|
+
className: clsx(WorkspaceBrowser_module_css_default.list, workspaceDropAtListStart && WorkspaceBrowser_module_css_default.listTopDropActive),
|
|
1336
|
+
role: "tree",
|
|
1337
|
+
"aria-label": t("section.sessions"),
|
|
1338
|
+
children: [groups.length === 0 && (0, react_jsx_runtime.jsx)("div", {
|
|
1339
|
+
className: WorkspaceBrowser_module_css_default.empty,
|
|
1340
|
+
children: t("empty.none")
|
|
1341
|
+
}), groups.map((group) => {
|
|
1342
|
+
const workspaceId = group.workspaceId;
|
|
1343
|
+
const workspaceMarker = workspaceId !== void 0 && workspaceDrag?.over?.id === workspaceId ? workspaceDrag.over.half : null;
|
|
1344
|
+
const workspaceDragProps = workspaceId === void 0 ? void 0 : {
|
|
1345
|
+
start: () => {
|
|
1346
|
+
workspaceDropCommitted.current = false;
|
|
1347
|
+
setWorkspaceDrag({
|
|
1348
|
+
workspaceId,
|
|
1349
|
+
over: null
|
|
1350
|
+
});
|
|
1351
|
+
},
|
|
1352
|
+
end: () => {
|
|
1353
|
+
if (workspaceDrag?.over !== null && workspaceDrag?.over !== void 0) commitWorkspaceDrag(workspaceDrag, workspaceDrag.over);
|
|
1354
|
+
else setWorkspaceDrag(null);
|
|
1355
|
+
workspaceDropCommitted.current = false;
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
const hoverWorkspace = workspaceId === void 0 ? void 0 : (half) => {
|
|
1359
|
+
setWorkspaceDrag((active) => active === null ? active : {
|
|
1360
|
+
...active,
|
|
1361
|
+
over: {
|
|
1362
|
+
id: workspaceId,
|
|
1363
|
+
half
|
|
1364
|
+
}
|
|
1365
|
+
});
|
|
1366
|
+
};
|
|
1367
|
+
const dropWorkspace = workspaceId === void 0 ? void 0 : (half) => {
|
|
1368
|
+
if (workspaceDrag === null) return;
|
|
1369
|
+
commitWorkspaceDrag(workspaceDrag, {
|
|
1370
|
+
id: workspaceId,
|
|
1371
|
+
half
|
|
1372
|
+
});
|
|
1373
|
+
};
|
|
1374
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
1375
|
+
className: clsx(WorkspaceBrowser_module_css_default.groupSection, workspaceMarker === "before" && WorkspaceBrowser_module_css_default.workspaceDropBefore, workspaceMarker === "after" && WorkspaceBrowser_module_css_default.workspaceDropAfter),
|
|
1376
|
+
onDragOver: workspaceDrag === null || hoverWorkspace === void 0 ? void 0 : (e) => {
|
|
1377
|
+
e.preventDefault();
|
|
1378
|
+
e.dataTransfer.dropEffect = "move";
|
|
1379
|
+
hoverWorkspace(workspaceGroupHalf(e));
|
|
1380
|
+
},
|
|
1381
|
+
onDrop: workspaceDrag === null || dropWorkspace === void 0 ? void 0 : (e) => {
|
|
1382
|
+
e.preventDefault();
|
|
1383
|
+
dropWorkspace(workspaceGroupHalf(e));
|
|
1384
|
+
},
|
|
1385
|
+
children: [
|
|
1386
|
+
(0, react_jsx_runtime.jsx)(ProjectRowItem, {
|
|
1387
|
+
group,
|
|
1388
|
+
home,
|
|
1389
|
+
t,
|
|
1390
|
+
onToggle: () => {
|
|
1391
|
+
if (group.expanded) setExpandedSessionGroups((keys) => keys.filter((key) => key !== group.key));
|
|
1392
|
+
setGroupExpanded(group.key, !group.expanded);
|
|
1393
|
+
},
|
|
1394
|
+
onCreate: () => {
|
|
1395
|
+
if (group.workspaceId !== void 0) {
|
|
1396
|
+
setGroupExpanded(group.key, true);
|
|
1397
|
+
startSession(group.workspaceId);
|
|
1398
|
+
}
|
|
1399
|
+
},
|
|
1400
|
+
drag: workspaceDragProps,
|
|
1401
|
+
actions: group.workspaceId === void 0 ? void 0 : {
|
|
1402
|
+
rename: () => {
|
|
1403
|
+
/* v8 ignore next -- narrowing guard: the actions object exists only for real-workspace groups. */
|
|
1404
|
+
if (group.workspaceId !== void 0) onRenameRequest(group.workspaceId, group.label);
|
|
1405
|
+
},
|
|
1406
|
+
delete: () => {
|
|
1407
|
+
/* v8 ignore next -- narrowing guard: the actions object exists only for real-workspace groups. */
|
|
1408
|
+
if (group.workspaceId !== void 0) onDeleteRequest(group.workspaceId, group.label);
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
}),
|
|
1412
|
+
(expandedSessionGroups.includes(group.key) ? group.sessions : group.sessions.slice(0, COLLAPSED_SESSION_LIMIT)).map((node) => {
|
|
1413
|
+
const sameGroupDrag = drag !== null && drag.accountKey === group.key;
|
|
1414
|
+
return (0, react_jsx_runtime.jsx)(SessionNodeItem, {
|
|
1415
|
+
node,
|
|
1416
|
+
currentId: current,
|
|
1417
|
+
now,
|
|
1418
|
+
onOpen: open,
|
|
1419
|
+
onRename: onSessionRename,
|
|
1420
|
+
onFork: forkSession,
|
|
1421
|
+
onArchive: onSessionArchive,
|
|
1422
|
+
onDelete: onSessionDelete,
|
|
1423
|
+
drag: {
|
|
1424
|
+
start: () => {
|
|
1425
|
+
sessionDropCommitted.current = false;
|
|
1426
|
+
setDrag({
|
|
1427
|
+
accountKey: group.key,
|
|
1428
|
+
sessionId: node.id,
|
|
1429
|
+
over: null
|
|
1430
|
+
});
|
|
1431
|
+
},
|
|
1432
|
+
active: sameGroupDrag,
|
|
1433
|
+
marker: sameGroupDrag && drag.over?.id === node.id ? drag.over.half : null,
|
|
1434
|
+
hover: (half) => {
|
|
1435
|
+
/* v8 ignore next -- narrowing guard: Rows gates hover on `active`, which is false while the drag state is null. */
|
|
1436
|
+
setDrag((d) => d === null ? d : {
|
|
1437
|
+
...d,
|
|
1438
|
+
over: {
|
|
1439
|
+
id: node.id,
|
|
1440
|
+
half
|
|
1441
|
+
}
|
|
1442
|
+
});
|
|
1443
|
+
},
|
|
1444
|
+
drop: (half) => {
|
|
1445
|
+
/* v8 ignore next -- narrowing guard: Rows gates drop on `active`, which is false while the drag state is null. */
|
|
1446
|
+
if (drag === null) return;
|
|
1447
|
+
commitSessionDrag(drag, {
|
|
1448
|
+
id: node.id,
|
|
1449
|
+
half
|
|
1450
|
+
});
|
|
1451
|
+
},
|
|
1452
|
+
end: () => {
|
|
1453
|
+
if (drag?.over !== null && drag?.over !== void 0) commitSessionDrag(drag, drag.over);
|
|
1454
|
+
else setDrag(null);
|
|
1455
|
+
sessionDropCommitted.current = false;
|
|
1456
|
+
}
|
|
1457
|
+
},
|
|
1458
|
+
t
|
|
1459
|
+
}, node.id);
|
|
1460
|
+
}),
|
|
1461
|
+
group.sessions.length > COLLAPSED_SESSION_LIMIT && (0, react_jsx_runtime.jsx)("button", {
|
|
1462
|
+
type: "button",
|
|
1463
|
+
className: WorkspaceBrowser_module_css_default.sessionOverflowButton,
|
|
1464
|
+
"aria-expanded": expandedSessionGroups.includes(group.key),
|
|
1465
|
+
onClick: () => {
|
|
1466
|
+
setExpandedSessionGroups((keys) => toggled(keys, group.key));
|
|
1467
|
+
},
|
|
1468
|
+
children: expandedSessionGroups.includes(group.key) ? t("sessions.collapse") : t("sessions.expand", { n: group.sessions.length - COLLAPSED_SESSION_LIMIT })
|
|
1469
|
+
})
|
|
1470
|
+
]
|
|
1471
|
+
}, group.key);
|
|
1472
|
+
})]
|
|
1473
|
+
}),
|
|
1474
|
+
(0, react_jsx_runtime.jsx)("span", { className: WorkspaceBrowser_module_css_default.fade })
|
|
1475
|
+
]
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
/** The flat "In one list" body: every session is one draggable top-level row. */
|
|
1479
|
+
function FlatList({ useSessions, open, forkSession, onSessionRename, onSessionArchive, onSessionDelete, archivedSessionIds, orderBy, sessionOrderByAccount, sessionUpdatedAtByAccount, syncSessionOrderAccount, setSessionOrder, t }) {
|
|
1480
|
+
const list = useSessions((s) => s);
|
|
1481
|
+
const baseRows = (0, react.useMemo)(() => deriveFlat(list, archivedSessionIds), [list, archivedSessionIds]);
|
|
1482
|
+
const sessionIds = (0, react.useMemo)(() => baseRows.map((row) => row.id), [baseRows]);
|
|
1483
|
+
const previousOrderBy = (0, react.useRef)(orderBy);
|
|
1484
|
+
(0, react.useEffect)(() => {
|
|
1485
|
+
if (list.phase !== "ready") return;
|
|
1486
|
+
const previousOrder = sessionOrderByAccount[FLAT_SESSION_ORDER_KEY];
|
|
1487
|
+
const previousUpdatedAt = sessionUpdatedAtByAccount["__flat_session_order__"] ?? {};
|
|
1488
|
+
const switchedToUpdated = previousOrderBy.current !== "updated" && orderBy === "updated";
|
|
1489
|
+
previousOrderBy.current = orderBy;
|
|
1490
|
+
const next = nextSessionOrderAccount({
|
|
1491
|
+
sessionIds,
|
|
1492
|
+
previousOrder,
|
|
1493
|
+
previousUpdatedAt,
|
|
1494
|
+
list,
|
|
1495
|
+
orderBy,
|
|
1496
|
+
sortByRecency: orderBy === "updated" && (previousOrder === void 0 || switchedToUpdated)
|
|
1497
|
+
});
|
|
1498
|
+
if (next.changed) syncSessionOrderAccount(FLAT_SESSION_ORDER_KEY, next.order.map((id) => id), next.updatedAt);
|
|
1499
|
+
}, [
|
|
1500
|
+
list,
|
|
1501
|
+
orderBy,
|
|
1502
|
+
sessionOrderByAccount,
|
|
1503
|
+
sessionUpdatedAtByAccount,
|
|
1504
|
+
sessionIds,
|
|
1505
|
+
syncSessionOrderAccount
|
|
1506
|
+
]);
|
|
1507
|
+
const rows = (0, react.useMemo)(() => {
|
|
1508
|
+
const byId = new Map(baseRows.map((row) => [row.id, row]));
|
|
1509
|
+
return reconciledSessionOrder(sessionIds, sessionOrderByAccount[FLAT_SESSION_ORDER_KEY]).flatMap((id) => {
|
|
1510
|
+
const row = byId.get(id);
|
|
1511
|
+
return row === void 0 ? [] : [row];
|
|
1512
|
+
});
|
|
1513
|
+
}, [
|
|
1514
|
+
baseRows,
|
|
1515
|
+
sessionOrderByAccount,
|
|
1516
|
+
sessionIds
|
|
1517
|
+
]);
|
|
1518
|
+
const [drag, setDrag] = (0, react.useState)(null);
|
|
1519
|
+
const dropCommitted = (0, react.useRef)(false);
|
|
1520
|
+
useNativeDragAcceptance(drag !== null);
|
|
1521
|
+
const commitDrag = (activeDrag, over) => {
|
|
1522
|
+
if (dropCommitted.current) return;
|
|
1523
|
+
dropCommitted.current = true;
|
|
1524
|
+
setDrag(null);
|
|
1525
|
+
const targetIndex = rows.findIndex((row) => row.id === over.id);
|
|
1526
|
+
if (targetIndex === -1) return;
|
|
1527
|
+
const anchor = over.half === "before" ? over.id : rows[targetIndex + 1]?.id;
|
|
1528
|
+
if (anchor === activeDrag.sessionId) return;
|
|
1529
|
+
const sourceIndex = rows.findIndex((row) => row.id === activeDrag.sessionId);
|
|
1530
|
+
const anchorIndex = anchor === void 0 ? rows.length : rows.findIndex((row) => row.id === anchor);
|
|
1531
|
+
if (sourceIndex !== -1 && (anchorIndex === sourceIndex || anchorIndex === sourceIndex + 1)) return;
|
|
1532
|
+
const nextOrder = rows.map((row) => row.id).filter((id) => id !== activeDrag.sessionId);
|
|
1533
|
+
const insertAt = anchor === void 0 ? nextOrder.length : nextOrder.indexOf(anchor);
|
|
1534
|
+
nextOrder.splice(insertAt === -1 ? nextOrder.length : insertAt, 0, activeDrag.sessionId);
|
|
1535
|
+
setSessionOrder(FLAT_SESSION_ORDER_KEY, nextOrder.map((id) => id));
|
|
1536
|
+
};
|
|
1537
|
+
const now = Date.now();
|
|
1538
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
1539
|
+
className: clsx(WorkspaceBrowser_module_css_default.treeBody, WorkspaceBrowser_module_css_default.wide),
|
|
1540
|
+
children: [(0, react_jsx_runtime.jsxs)("div", {
|
|
1541
|
+
className: clsx(WorkspaceBrowser_module_css_default.list, WorkspaceBrowser_module_css_default.flatList),
|
|
1542
|
+
role: "tree",
|
|
1543
|
+
"aria-label": t("section.sessions"),
|
|
1544
|
+
children: [rows.length === 0 && (0, react_jsx_runtime.jsx)("div", {
|
|
1545
|
+
className: WorkspaceBrowser_module_css_default.empty,
|
|
1546
|
+
children: t("empty.none")
|
|
1547
|
+
}), rows.map((node) => {
|
|
1548
|
+
const active = drag !== null;
|
|
1549
|
+
return (0, react_jsx_runtime.jsx)(SessionNodeItem, {
|
|
1550
|
+
node,
|
|
1551
|
+
currentId: list.current,
|
|
1552
|
+
now,
|
|
1553
|
+
onOpen: open,
|
|
1554
|
+
onRename: onSessionRename,
|
|
1555
|
+
onFork: forkSession,
|
|
1556
|
+
onArchive: onSessionArchive,
|
|
1557
|
+
onDelete: onSessionDelete,
|
|
1558
|
+
flat: true,
|
|
1559
|
+
drag: {
|
|
1560
|
+
start: () => {
|
|
1561
|
+
dropCommitted.current = false;
|
|
1562
|
+
setDrag({
|
|
1563
|
+
accountKey: FLAT_SESSION_ORDER_KEY,
|
|
1564
|
+
sessionId: node.id,
|
|
1565
|
+
over: null
|
|
1566
|
+
});
|
|
1567
|
+
},
|
|
1568
|
+
active,
|
|
1569
|
+
marker: active && drag.over?.id === node.id ? drag.over.half : null,
|
|
1570
|
+
hover: (half) => {
|
|
1571
|
+
setDrag((current) => current === null ? current : {
|
|
1572
|
+
...current,
|
|
1573
|
+
over: {
|
|
1574
|
+
id: node.id,
|
|
1575
|
+
half
|
|
1576
|
+
}
|
|
1577
|
+
});
|
|
1578
|
+
},
|
|
1579
|
+
drop: (half) => {
|
|
1580
|
+
if (drag !== null) commitDrag(drag, {
|
|
1581
|
+
id: node.id,
|
|
1582
|
+
half
|
|
1583
|
+
});
|
|
1584
|
+
},
|
|
1585
|
+
end: () => {
|
|
1586
|
+
if (drag?.over !== null && drag?.over !== void 0) commitDrag(drag, drag.over);
|
|
1587
|
+
else setDrag(null);
|
|
1588
|
+
dropCommitted.current = false;
|
|
1589
|
+
}
|
|
1590
|
+
},
|
|
1591
|
+
t
|
|
1592
|
+
}, node.id);
|
|
1593
|
+
})]
|
|
1594
|
+
}), (0, react_jsx_runtime.jsx)("span", { className: WorkspaceBrowser_module_css_default.fade })]
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
/** Flat search body: local metadata matches plus the current Host result page. */
|
|
1598
|
+
function SearchResults({ useSessions, open, workspaces, archivedSessionIds, query, remote, resultLimit, t }) {
|
|
1599
|
+
const list = useSessions((s) => s);
|
|
1600
|
+
const currentRemote = remote.query === query ? remote : {
|
|
1601
|
+
query,
|
|
1602
|
+
status: "loading",
|
|
1603
|
+
items: [],
|
|
1604
|
+
hasMore: false
|
|
1605
|
+
};
|
|
1606
|
+
const results = (0, react.useMemo)(() => deriveSearchResults(list, workspaces, query, archivedSessionIds, currentRemote, resultLimit), [
|
|
1607
|
+
list,
|
|
1608
|
+
workspaces,
|
|
1609
|
+
query,
|
|
1610
|
+
archivedSessionIds,
|
|
1611
|
+
currentRemote,
|
|
1612
|
+
resultLimit
|
|
1613
|
+
]);
|
|
1614
|
+
const pending = currentRemote.status === "loading";
|
|
1615
|
+
const failed = currentRemote.status === "error";
|
|
1616
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
1617
|
+
className: clsx(WorkspaceBrowser_module_css_default.treeBody, WorkspaceBrowser_module_css_default.wide),
|
|
1618
|
+
children: [(0, react_jsx_runtime.jsxs)("div", {
|
|
1619
|
+
className: WorkspaceBrowser_module_css_default.list,
|
|
1620
|
+
children: [
|
|
1621
|
+
(0, react_jsx_runtime.jsx)("div", {
|
|
1622
|
+
className: WorkspaceBrowser_module_css_default.searchTree,
|
|
1623
|
+
role: "tree",
|
|
1624
|
+
"aria-label": t("search.results.aria"),
|
|
1625
|
+
children: results.items.map((result) => (0, react_jsx_runtime.jsx)(SearchResultItem, {
|
|
1626
|
+
result,
|
|
1627
|
+
currentId: list.current,
|
|
1628
|
+
onOpen: open,
|
|
1629
|
+
t
|
|
1630
|
+
}, result.id))
|
|
1631
|
+
}),
|
|
1632
|
+
pending && (0, react_jsx_runtime.jsx)("div", {
|
|
1633
|
+
className: WorkspaceBrowser_module_css_default.searchStatus,
|
|
1634
|
+
role: "status",
|
|
1635
|
+
children: t("search.pending")
|
|
1636
|
+
}),
|
|
1637
|
+
failed && (0, react_jsx_runtime.jsx)("div", {
|
|
1638
|
+
className: WorkspaceBrowser_module_css_default.searchWarning,
|
|
1639
|
+
role: "status",
|
|
1640
|
+
children: t("search.unavailable")
|
|
1641
|
+
}),
|
|
1642
|
+
!pending && results.items.length === 0 && (0, react_jsx_runtime.jsx)("div", {
|
|
1643
|
+
className: WorkspaceBrowser_module_css_default.empty,
|
|
1644
|
+
children: t("search.noMatches")
|
|
1645
|
+
}),
|
|
1646
|
+
results.hasMore && (0, react_jsx_runtime.jsx)("div", {
|
|
1647
|
+
className: WorkspaceBrowser_module_css_default.searchStatus,
|
|
1648
|
+
children: t("search.hasMore", { n: resultLimit })
|
|
1649
|
+
})
|
|
1650
|
+
]
|
|
1651
|
+
}), (0, react_jsx_runtime.jsx)("span", { className: WorkspaceBrowser_module_css_default.fade })]
|
|
1652
|
+
});
|
|
1653
|
+
}
|
|
1654
|
+
/**
|
|
1655
|
+
* Render the browsing region.
|
|
1656
|
+
* @param props - composed slot props (shell owner share + store + injected actions).
|
|
1657
|
+
* @returns the region element tree.
|
|
1658
|
+
*/
|
|
1659
|
+
function WorkspaceBrowser({ wide, expandSidebar, useSessions, useWorkspaces, useStore, actions, startSession, open, renameSession, forkSession, renameWorkspace, deleteWorkspace, insertWorkspaceBefore, archiveSession, deleteSession, insertSessionBefore, createWorkspace, searchSessions, searchResultLimit, useDirectoryFlow, useHostDescription, renderSlot, t }) {
|
|
1660
|
+
const home = useHostDescription((description) => description?.home);
|
|
1661
|
+
const workspaces = useWorkspaces((state) => state.items);
|
|
1662
|
+
const workspacePhase = useWorkspaces((state) => state.phase);
|
|
1663
|
+
const archivedSessionIds = useWorkspaces((state) => state.archivedSessionIds);
|
|
1664
|
+
const directoryFlowAvailable = useDirectoryFlow((occupied) => occupied);
|
|
1665
|
+
const groupBy = useStore((s) => s.groupBy);
|
|
1666
|
+
const orderBy = useStore((s) => s.orderBy);
|
|
1667
|
+
const groupExpansion = useStore((s) => s.groupExpansion);
|
|
1668
|
+
const sessionOrderByAccount = useStore((s) => s.sessionOrderByAccount);
|
|
1669
|
+
const sessionUpdatedAtByAccount = useStore((s) => s.sessionUpdatedAtByAccount);
|
|
1670
|
+
(0, react.useEffect)(() => {
|
|
1671
|
+
if (workspacePhase !== "ready") return;
|
|
1672
|
+
actions.retainAccountKeys([
|
|
1673
|
+
"",
|
|
1674
|
+
FLAT_SESSION_ORDER_KEY,
|
|
1675
|
+
...workspaces.map((workspace) => workspace.workspaceId)
|
|
1676
|
+
]);
|
|
1677
|
+
}, [
|
|
1678
|
+
actions.retainAccountKeys,
|
|
1679
|
+
workspacePhase,
|
|
1680
|
+
workspaces
|
|
1681
|
+
]);
|
|
1682
|
+
const [query, setQuery] = (0, react.useState)("");
|
|
1683
|
+
const [searchExpanded, setSearchExpanded] = (0, react.useState)(false);
|
|
1684
|
+
const normalizedQuery = sanitizeSearchQuery(query).trim();
|
|
1685
|
+
const [remoteSearch, setRemoteSearch] = (0, react.useState)({
|
|
1686
|
+
query: "",
|
|
1687
|
+
status: "idle",
|
|
1688
|
+
items: [],
|
|
1689
|
+
hasMore: false
|
|
1690
|
+
});
|
|
1691
|
+
const searchRoot = (0, react.useRef)(null);
|
|
1692
|
+
const searchInput = (0, react.useRef)(null);
|
|
1693
|
+
const [wsPickerOpen, setWsPickerOpen] = (0, react.useState)(false);
|
|
1694
|
+
const wsPlusRef = (0, react.useRef)(null);
|
|
1695
|
+
const composingRef = (0, react.useRef)(false);
|
|
1696
|
+
const [searchOnExpand, setSearchOnExpand] = (0, react.useState)(false);
|
|
1697
|
+
(0, react.useEffect)(() => {
|
|
1698
|
+
if (wide && searchOnExpand) {
|
|
1699
|
+
const timer = window.setTimeout(() => {
|
|
1700
|
+
searchInput.current?.focus({ preventScroll: true });
|
|
1701
|
+
setSearchOnExpand(false);
|
|
1702
|
+
}, EXPAND_SLIDE_MS);
|
|
1703
|
+
return () => {
|
|
1704
|
+
window.clearTimeout(timer);
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
}, [wide, searchOnExpand]);
|
|
1708
|
+
(0, react.useEffect)(() => {
|
|
1709
|
+
if (!wide || !searchExpanded || searchOnExpand) return;
|
|
1710
|
+
searchInput.current?.focus({ preventScroll: true });
|
|
1711
|
+
}, [
|
|
1712
|
+
wide,
|
|
1713
|
+
searchExpanded,
|
|
1714
|
+
searchOnExpand
|
|
1715
|
+
]);
|
|
1716
|
+
(0, react.useEffect)(() => {
|
|
1717
|
+
if (!wide || !searchExpanded || searchOnExpand) return;
|
|
1718
|
+
const onClick = (event) => {
|
|
1719
|
+
if (!(event.target instanceof Node) || searchRoot.current?.contains(event.target) === true) return;
|
|
1720
|
+
searchInput.current?.blur();
|
|
1721
|
+
if (normalizedQuery !== "") return;
|
|
1722
|
+
setSearchExpanded(false);
|
|
1723
|
+
};
|
|
1724
|
+
document.addEventListener("click", onClick);
|
|
1725
|
+
return () => {
|
|
1726
|
+
document.removeEventListener("click", onClick);
|
|
1727
|
+
};
|
|
1728
|
+
}, [
|
|
1729
|
+
normalizedQuery,
|
|
1730
|
+
wide,
|
|
1731
|
+
searchExpanded,
|
|
1732
|
+
searchOnExpand
|
|
1733
|
+
]);
|
|
1734
|
+
(0, react.useEffect)(() => {
|
|
1735
|
+
if (normalizedQuery === "") {
|
|
1736
|
+
setRemoteSearch({
|
|
1737
|
+
query: "",
|
|
1738
|
+
status: "idle",
|
|
1739
|
+
items: [],
|
|
1740
|
+
hasMore: false
|
|
1741
|
+
});
|
|
1742
|
+
return;
|
|
1743
|
+
}
|
|
1744
|
+
const controller = new AbortController();
|
|
1745
|
+
setRemoteSearch({
|
|
1746
|
+
query: normalizedQuery,
|
|
1747
|
+
status: "loading",
|
|
1748
|
+
items: [],
|
|
1749
|
+
hasMore: false
|
|
1750
|
+
});
|
|
1751
|
+
const timer = window.setTimeout(() => {
|
|
1752
|
+
searchSessions(normalizedQuery, controller.signal).then((result) => {
|
|
1753
|
+
if (controller.signal.aborted) return;
|
|
1754
|
+
setRemoteSearch({
|
|
1755
|
+
query: normalizedQuery,
|
|
1756
|
+
status: "ready",
|
|
1757
|
+
items: result.items,
|
|
1758
|
+
hasMore: result.hasMore
|
|
1759
|
+
});
|
|
1760
|
+
}).catch(() => {
|
|
1761
|
+
if (controller.signal.aborted) return;
|
|
1762
|
+
setRemoteSearch({
|
|
1763
|
+
query: normalizedQuery,
|
|
1764
|
+
status: "error",
|
|
1765
|
+
items: [],
|
|
1766
|
+
hasMore: false
|
|
1767
|
+
});
|
|
1768
|
+
});
|
|
1769
|
+
}, SEARCH_DEBOUNCE_MS);
|
|
1770
|
+
return () => {
|
|
1771
|
+
window.clearTimeout(timer);
|
|
1772
|
+
controller.abort();
|
|
1773
|
+
};
|
|
1774
|
+
}, [normalizedQuery, searchSessions]);
|
|
1775
|
+
const [renameTarget, setRenameTarget] = (0, react.useState)(null);
|
|
1776
|
+
const [renameDraft, setRenameDraft] = (0, react.useState)("");
|
|
1777
|
+
const [renaming, setRenaming] = (0, react.useState)(false);
|
|
1778
|
+
const [renameError, setRenameError] = (0, react.useState)(null);
|
|
1779
|
+
const renameTrimmed = renameDraft.trim();
|
|
1780
|
+
const renameDuplicate = renameTarget !== null && renameTrimmed !== "" && renameTrimmed !== renameTarget.currentTitle && workspaces.some((w) => w.title === renameTrimmed);
|
|
1781
|
+
const renameBlocked = renaming || renameTrimmed === "" || renameTarget === null || renameTrimmed === renameTarget.currentTitle || renameDuplicate;
|
|
1782
|
+
const closeRename = () => {
|
|
1783
|
+
if (renaming) return;
|
|
1784
|
+
setRenameTarget(null);
|
|
1785
|
+
setRenameError(null);
|
|
1786
|
+
};
|
|
1787
|
+
const confirmRename = () => {
|
|
1788
|
+
if (renameBlocked) return;
|
|
1789
|
+
setRenaming(true);
|
|
1790
|
+
setRenameError(null);
|
|
1791
|
+
renameWorkspace(renameTarget.workspaceId, renameTrimmed).then(() => {
|
|
1792
|
+
setRenaming(false);
|
|
1793
|
+
setRenameTarget(null);
|
|
1794
|
+
}).catch((reason) => {
|
|
1795
|
+
setRenaming(false);
|
|
1796
|
+
setRenameError(reason instanceof Error ? reason.message : String(reason));
|
|
1797
|
+
});
|
|
1798
|
+
};
|
|
1799
|
+
const [sessionRenameTarget, setSessionRenameTarget] = (0, react.useState)(null);
|
|
1800
|
+
const [sessionRenameDraft, setSessionRenameDraft] = (0, react.useState)("");
|
|
1801
|
+
const [sessionRenaming, setSessionRenaming] = (0, react.useState)(false);
|
|
1802
|
+
const [sessionRenameError, setSessionRenameError] = (0, react.useState)(null);
|
|
1803
|
+
const sessionRenameTrimmed = sessionRenameDraft.trim();
|
|
1804
|
+
const sessionRenameBlocked = sessionRenaming || sessionRenameTrimmed === "" || sessionRenameTarget === null;
|
|
1805
|
+
const closeSessionRename = () => {
|
|
1806
|
+
if (sessionRenaming) return;
|
|
1807
|
+
setSessionRenameTarget(null);
|
|
1808
|
+
setSessionRenameError(null);
|
|
1809
|
+
};
|
|
1810
|
+
const confirmSessionRename = () => {
|
|
1811
|
+
if (sessionRenameBlocked) return;
|
|
1812
|
+
setSessionRenaming(true);
|
|
1813
|
+
setSessionRenameError(null);
|
|
1814
|
+
renameSession(sessionRenameTarget.sessionId, sessionRenameTrimmed).then(() => {
|
|
1815
|
+
setSessionRenaming(false);
|
|
1816
|
+
setSessionRenameTarget(null);
|
|
1817
|
+
}).catch((reason) => {
|
|
1818
|
+
setSessionRenaming(false);
|
|
1819
|
+
setSessionRenameError(reason instanceof Error ? reason.message : String(reason));
|
|
1820
|
+
});
|
|
1821
|
+
};
|
|
1822
|
+
const onSessionRename = (sessionId, currentTitle) => {
|
|
1823
|
+
setSessionRenameTarget({
|
|
1824
|
+
sessionId,
|
|
1825
|
+
currentTitle
|
|
1826
|
+
});
|
|
1827
|
+
setSessionRenameDraft(currentTitle);
|
|
1828
|
+
setSessionRenameError(null);
|
|
1829
|
+
};
|
|
1830
|
+
const onSessionArchive = (sessionId) => {
|
|
1831
|
+
archiveSession(sessionId).catch((reason) => {
|
|
1832
|
+
console.warn("session archive rejected:", reason);
|
|
1833
|
+
});
|
|
1834
|
+
};
|
|
1835
|
+
const [sessionDeleteTarget, setSessionDeleteTarget] = (0, react.useState)(null);
|
|
1836
|
+
const [sessionDeleting, setSessionDeleting] = (0, react.useState)(false);
|
|
1837
|
+
const [sessionDeleteError, setSessionDeleteError] = (0, react.useState)(null);
|
|
1838
|
+
const onSessionDelete = (sessionId, title) => {
|
|
1839
|
+
setSessionDeleteTarget({ sessionId, title });
|
|
1840
|
+
setSessionDeleteError(null);
|
|
1841
|
+
};
|
|
1842
|
+
const closeSessionDelete = () => {
|
|
1843
|
+
if (sessionDeleting) return;
|
|
1844
|
+
setSessionDeleteTarget(null);
|
|
1845
|
+
setSessionDeleteError(null);
|
|
1846
|
+
};
|
|
1847
|
+
const confirmSessionDelete = () => {
|
|
1848
|
+
if (sessionDeleting || sessionDeleteTarget === null) return;
|
|
1849
|
+
setSessionDeleting(true);
|
|
1850
|
+
setSessionDeleteError(null);
|
|
1851
|
+
deleteSession(sessionDeleteTarget.sessionId).then(() => {
|
|
1852
|
+
setSessionDeleting(false);
|
|
1853
|
+
setSessionDeleteTarget(null);
|
|
1854
|
+
setSessionDeleteError(null);
|
|
1855
|
+
}).catch((reason) => {
|
|
1856
|
+
setSessionDeleting(false);
|
|
1857
|
+
setSessionDeleteError(reason instanceof Error ? reason.message : String(reason));
|
|
1858
|
+
});
|
|
1859
|
+
};
|
|
1860
|
+
const [deleteTarget, setDeleteTarget] = (0, react.useState)(null);
|
|
1861
|
+
const [deleting, setDeleting] = (0, react.useState)(false);
|
|
1862
|
+
const [deleteCommittedId, setDeleteCommittedId] = (0, react.useState)(null);
|
|
1863
|
+
const [deleteError, setDeleteError] = (0, react.useState)(null);
|
|
1864
|
+
(0, react.useEffect)(() => {
|
|
1865
|
+
if (deleteCommittedId === null || workspaces.some((workspace) => workspace.workspaceId === deleteCommittedId)) return;
|
|
1866
|
+
setDeleting(false);
|
|
1867
|
+
setDeleteCommittedId(null);
|
|
1868
|
+
setDeleteTarget(null);
|
|
1869
|
+
}, [deleteCommittedId, workspaces]);
|
|
1870
|
+
const closeDelete = () => {
|
|
1871
|
+
if (deleting) return;
|
|
1872
|
+
setDeleteTarget(null);
|
|
1873
|
+
setDeleteError(null);
|
|
1874
|
+
};
|
|
1875
|
+
const confirmDelete = () => {
|
|
1876
|
+
/* v8 ignore next -- the Modal is absent without a target and its button is disabled while deleting. */
|
|
1877
|
+
if (deleting || deleteTarget === null) return;
|
|
1878
|
+
setDeleting(true);
|
|
1879
|
+
setDeleteCommittedId(null);
|
|
1880
|
+
setDeleteError(null);
|
|
1881
|
+
deleteWorkspace(deleteTarget.workspaceId).then(() => {
|
|
1882
|
+
setDeleteCommittedId(deleteTarget.workspaceId);
|
|
1883
|
+
}).catch((reason) => {
|
|
1884
|
+
setDeleting(false);
|
|
1885
|
+
setDeleteError(reason instanceof Error ? reason.message : String(reason));
|
|
1886
|
+
});
|
|
1887
|
+
};
|
|
1888
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
1889
|
+
className: clsx(WorkspaceBrowser_module_css_default.root, !wide && WorkspaceBrowser_module_css_default.rail),
|
|
1890
|
+
children: [
|
|
1891
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
1892
|
+
className: WorkspaceBrowser_module_css_default.sectionHeader,
|
|
1893
|
+
children: [
|
|
1894
|
+
wide && (0, react_jsx_runtime.jsx)("span", {
|
|
1895
|
+
className: clsx(WorkspaceBrowser_module_css_default.sectionLabel, WorkspaceBrowser_module_css_default.wide, searchExpanded && WorkspaceBrowser_module_css_default.sectionLabelHidden),
|
|
1896
|
+
children: groupBy === "flat" ? t("section.sessions") : t("section.workspaces")
|
|
1897
|
+
}),
|
|
1898
|
+
wide && (0, react_jsx_runtime.jsx)("div", {
|
|
1899
|
+
className: clsx(WorkspaceBrowser_module_css_default.searchSlot, searchExpanded && WorkspaceBrowser_module_css_default.searchSlotExpanded),
|
|
1900
|
+
children: (0, react_jsx_runtime.jsxs)("div", {
|
|
1901
|
+
ref: searchRoot,
|
|
1902
|
+
className: clsx(WorkspaceBrowser_module_css_default.search, searchExpanded && WorkspaceBrowser_module_css_default.searchExpanded),
|
|
1903
|
+
onClick: () => {
|
|
1904
|
+
setWsPickerOpen(false);
|
|
1905
|
+
setSearchExpanded(true);
|
|
1906
|
+
searchInput.current?.focus();
|
|
1907
|
+
},
|
|
1908
|
+
children: [
|
|
1909
|
+
(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
1910
|
+
label: t("search"),
|
|
1911
|
+
side: "bottom",
|
|
1912
|
+
delayMs: 500,
|
|
1913
|
+
disabled: searchExpanded,
|
|
1914
|
+
children: (0, react_jsx_runtime.jsx)("button", {
|
|
1915
|
+
type: "button",
|
|
1916
|
+
className: WorkspaceBrowser_module_css_default.searchButton,
|
|
1917
|
+
"aria-label": t("search.sessions.aria"),
|
|
1918
|
+
"aria-expanded": searchExpanded,
|
|
1919
|
+
onClick: () => {
|
|
1920
|
+
setWsPickerOpen(false);
|
|
1921
|
+
setSearchExpanded(true);
|
|
1922
|
+
},
|
|
1923
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconSearchOutline16, { size: searchExpanded ? 11 : 14 })
|
|
1924
|
+
})
|
|
1925
|
+
}),
|
|
1926
|
+
(0, react_jsx_runtime.jsx)("input", {
|
|
1927
|
+
ref: searchInput,
|
|
1928
|
+
className: WorkspaceBrowser_module_css_default.searchInput,
|
|
1929
|
+
type: "text",
|
|
1930
|
+
placeholder: t("search.placeholder"),
|
|
1931
|
+
maxLength: SEARCH_QUERY_MAX_CODE_UNITS,
|
|
1932
|
+
value: query,
|
|
1933
|
+
tabIndex: searchExpanded ? 0 : -1,
|
|
1934
|
+
onChange: (e) => {
|
|
1935
|
+
setQuery(sanitizeSearchQuery(e.target.value));
|
|
1936
|
+
},
|
|
1937
|
+
onKeyDown: (e) => {
|
|
1938
|
+
if (e.key !== "Escape") return;
|
|
1939
|
+
setQuery("");
|
|
1940
|
+
setSearchExpanded(false);
|
|
1941
|
+
}
|
|
1942
|
+
}),
|
|
1943
|
+
searchExpanded && (0, react_jsx_runtime.jsx)("button", {
|
|
1944
|
+
type: "button",
|
|
1945
|
+
className: WorkspaceBrowser_module_css_default.clearButton,
|
|
1946
|
+
"aria-label": t("search.clear"),
|
|
1947
|
+
onClick: (e) => {
|
|
1948
|
+
e.stopPropagation();
|
|
1949
|
+
setQuery("");
|
|
1950
|
+
setSearchExpanded(false);
|
|
1951
|
+
},
|
|
1952
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCloseFill14, {})
|
|
1953
|
+
})
|
|
1954
|
+
]
|
|
1955
|
+
})
|
|
1956
|
+
}),
|
|
1957
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
1958
|
+
className: clsx(WorkspaceBrowser_module_css_default.headerActions, wide && searchExpanded && WorkspaceBrowser_module_css_default.headerActionsHidden),
|
|
1959
|
+
children: [wide && (0, react_jsx_runtime.jsx)(ViewOptionsMenu, {
|
|
1960
|
+
groupBy,
|
|
1961
|
+
orderBy,
|
|
1962
|
+
onGroupPick: (mode) => {
|
|
1963
|
+
actions.setGroupBy(mode);
|
|
1964
|
+
},
|
|
1965
|
+
onOrderPick: (mode) => {
|
|
1966
|
+
actions.setOrderBy(mode);
|
|
1967
|
+
},
|
|
1968
|
+
t
|
|
1969
|
+
}), directoryFlowAvailable && (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
1970
|
+
label: t("workspace.add"),
|
|
1971
|
+
side: "bottom",
|
|
1972
|
+
delayMs: 500,
|
|
1973
|
+
children: (0, react_jsx_runtime.jsx)("button", {
|
|
1974
|
+
ref: wsPlusRef,
|
|
1975
|
+
type: "button",
|
|
1976
|
+
className: WorkspaceBrowser_module_css_default.iconButton,
|
|
1977
|
+
"aria-label": t("workspace.add"),
|
|
1978
|
+
onClick: () => {
|
|
1979
|
+
setWsPickerOpen((v) => !v);
|
|
1980
|
+
},
|
|
1981
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconProjectAddOutline16, { size: wide ? 16 : 18 })
|
|
1982
|
+
})
|
|
1983
|
+
})]
|
|
1984
|
+
}),
|
|
1985
|
+
(0, react_jsx_runtime.jsx)(WorkspacePickFlow, {
|
|
1986
|
+
t,
|
|
1987
|
+
open: wsPickerOpen,
|
|
1988
|
+
anchorRef: wsPlusRef,
|
|
1989
|
+
useWorkspaces,
|
|
1990
|
+
createWorkspace,
|
|
1991
|
+
useDirectoryFlow,
|
|
1992
|
+
renderDirectoryFlow: (owner) => renderSlot("sidebar.workspaces.directoryFlow", owner),
|
|
1993
|
+
addOnly: true,
|
|
1994
|
+
side: "right",
|
|
1995
|
+
onPick: (workspaceId) => {
|
|
1996
|
+
setWsPickerOpen(false);
|
|
1997
|
+
startSession(workspaceId);
|
|
1998
|
+
},
|
|
1999
|
+
onClose: () => {
|
|
2000
|
+
setWsPickerOpen(false);
|
|
2001
|
+
}
|
|
2002
|
+
})
|
|
2003
|
+
]
|
|
2004
|
+
}),
|
|
2005
|
+
!wide && (0, react_jsx_runtime.jsx)("div", {
|
|
2006
|
+
className: WorkspaceBrowser_module_css_default.search,
|
|
2007
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
2008
|
+
label: t("search"),
|
|
2009
|
+
children: (0, react_jsx_runtime.jsx)("button", {
|
|
2010
|
+
type: "button",
|
|
2011
|
+
className: WorkspaceBrowser_module_css_default.searchButton,
|
|
2012
|
+
"aria-label": t("search.sessions.aria"),
|
|
2013
|
+
onClick: () => {
|
|
2014
|
+
setSearchExpanded(true);
|
|
2015
|
+
setSearchOnExpand(true);
|
|
2016
|
+
expandSidebar();
|
|
2017
|
+
},
|
|
2018
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconSearchOutline16, { size: 18 })
|
|
2019
|
+
})
|
|
2020
|
+
})
|
|
2021
|
+
}),
|
|
2022
|
+
(0, react_jsx_runtime.jsx)("div", {
|
|
2023
|
+
className: WorkspaceBrowser_module_css_default.listArea,
|
|
2024
|
+
children: wide && (normalizedQuery !== "" ? (0, react_jsx_runtime.jsx)(SearchResults, {
|
|
2025
|
+
useSessions,
|
|
2026
|
+
open,
|
|
2027
|
+
workspaces,
|
|
2028
|
+
archivedSessionIds,
|
|
2029
|
+
query: normalizedQuery,
|
|
2030
|
+
remote: remoteSearch,
|
|
2031
|
+
resultLimit: searchResultLimit,
|
|
2032
|
+
t
|
|
2033
|
+
}) : groupBy === "flat" ? (0, react_jsx_runtime.jsx)(FlatList, {
|
|
2034
|
+
useSessions,
|
|
2035
|
+
open,
|
|
2036
|
+
forkSession,
|
|
2037
|
+
onSessionRename,
|
|
2038
|
+
onSessionArchive,
|
|
2039
|
+
onSessionDelete,
|
|
2040
|
+
archivedSessionIds,
|
|
2041
|
+
orderBy,
|
|
2042
|
+
sessionOrderByAccount,
|
|
2043
|
+
sessionUpdatedAtByAccount,
|
|
2044
|
+
syncSessionOrderAccount: actions.syncSessionOrderAccount,
|
|
2045
|
+
setSessionOrder: actions.setSessionOrder,
|
|
2046
|
+
t
|
|
2047
|
+
}) : (0, react_jsx_runtime.jsx)(SessionTree, {
|
|
2048
|
+
useSessions,
|
|
2049
|
+
onSessionRename,
|
|
2050
|
+
onSessionArchive,
|
|
2051
|
+
onSessionDelete,
|
|
2052
|
+
forkSession,
|
|
2053
|
+
workspaces,
|
|
2054
|
+
groupExpansion,
|
|
2055
|
+
setGroupExpanded: actions.setGroupExpanded,
|
|
2056
|
+
sessionOrderByAccount,
|
|
2057
|
+
sessionUpdatedAtByAccount,
|
|
2058
|
+
syncSessionOrderAccount: actions.syncSessionOrderAccount,
|
|
2059
|
+
setSessionOrder: actions.setSessionOrder,
|
|
2060
|
+
archivedSessionIds,
|
|
2061
|
+
startSession,
|
|
2062
|
+
open,
|
|
2063
|
+
insertWorkspaceBefore,
|
|
2064
|
+
insertSessionBefore,
|
|
2065
|
+
orderBy,
|
|
2066
|
+
home,
|
|
2067
|
+
t,
|
|
2068
|
+
onRenameRequest: (workspaceId, currentTitle) => {
|
|
2069
|
+
setRenameTarget({
|
|
2070
|
+
workspaceId,
|
|
2071
|
+
currentTitle
|
|
2072
|
+
});
|
|
2073
|
+
setRenameDraft(currentTitle);
|
|
2074
|
+
setRenameError(null);
|
|
2075
|
+
},
|
|
2076
|
+
onDeleteRequest: (workspaceId, title) => {
|
|
2077
|
+
setDeleteTarget({
|
|
2078
|
+
workspaceId,
|
|
2079
|
+
title
|
|
2080
|
+
});
|
|
2081
|
+
setDeleteError(null);
|
|
2082
|
+
}
|
|
2083
|
+
}))
|
|
2084
|
+
}),
|
|
2085
|
+
(0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
2086
|
+
open: renameTarget !== null,
|
|
2087
|
+
onClose: closeRename,
|
|
2088
|
+
closeLabel: t("close"),
|
|
2089
|
+
title: t("rename.workspace.title"),
|
|
2090
|
+
footer: (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2091
|
+
variant: "outline",
|
|
2092
|
+
disabled: renaming,
|
|
2093
|
+
onClick: closeRename,
|
|
2094
|
+
children: t("cancel")
|
|
2095
|
+
}), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2096
|
+
variant: "primary",
|
|
2097
|
+
disabled: renameBlocked,
|
|
2098
|
+
onClick: confirmRename,
|
|
2099
|
+
children: t("rename")
|
|
2100
|
+
})] }),
|
|
2101
|
+
children: [
|
|
2102
|
+
(0, react_jsx_runtime.jsx)("input", {
|
|
2103
|
+
className: WorkspaceBrowser_module_css_default.renameInput,
|
|
2104
|
+
value: renameDraft,
|
|
2105
|
+
"aria-label": t("field.workspaceName"),
|
|
2106
|
+
autoFocus: true,
|
|
2107
|
+
disabled: renaming,
|
|
2108
|
+
onFocus: (e) => {
|
|
2109
|
+
e.target.select();
|
|
2110
|
+
},
|
|
2111
|
+
onChange: (e) => {
|
|
2112
|
+
setRenameDraft(e.target.value);
|
|
2113
|
+
setRenameError(null);
|
|
2114
|
+
},
|
|
2115
|
+
onCompositionStart: () => {
|
|
2116
|
+
composingRef.current = true;
|
|
2117
|
+
},
|
|
2118
|
+
onCompositionEnd: () => {
|
|
2119
|
+
composingRef.current = false;
|
|
2120
|
+
},
|
|
2121
|
+
onKeyDown: (e) => {
|
|
2122
|
+
if (e.key === "Enter" && !composingRef.current) {
|
|
2123
|
+
e.preventDefault();
|
|
2124
|
+
confirmRename();
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
}),
|
|
2128
|
+
renameDuplicate && (0, react_jsx_runtime.jsx)("div", {
|
|
2129
|
+
className: WorkspaceBrowser_module_css_default.renameError,
|
|
2130
|
+
role: "alert",
|
|
2131
|
+
children: t("conflict.named", { name: renameTrimmed })
|
|
2132
|
+
}),
|
|
2133
|
+
renameError !== null && (0, react_jsx_runtime.jsx)("div", {
|
|
2134
|
+
className: WorkspaceBrowser_module_css_default.renameError,
|
|
2135
|
+
role: "alert",
|
|
2136
|
+
children: renameError
|
|
2137
|
+
})
|
|
2138
|
+
]
|
|
2139
|
+
}),
|
|
2140
|
+
(0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
2141
|
+
open: sessionRenameTarget !== null,
|
|
2142
|
+
onClose: closeSessionRename,
|
|
2143
|
+
closeLabel: t("close"),
|
|
2144
|
+
title: t("rename.session.title"),
|
|
2145
|
+
footer: (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2146
|
+
variant: "outline",
|
|
2147
|
+
disabled: sessionRenaming,
|
|
2148
|
+
onClick: closeSessionRename,
|
|
2149
|
+
children: t("cancel")
|
|
2150
|
+
}), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2151
|
+
variant: "primary",
|
|
2152
|
+
disabled: sessionRenameBlocked,
|
|
2153
|
+
onClick: confirmSessionRename,
|
|
2154
|
+
children: t("rename")
|
|
2155
|
+
})] }),
|
|
2156
|
+
children: [(0, react_jsx_runtime.jsx)("input", {
|
|
2157
|
+
className: WorkspaceBrowser_module_css_default.renameInput,
|
|
2158
|
+
value: sessionRenameDraft,
|
|
2159
|
+
"aria-label": t("field.sessionName"),
|
|
2160
|
+
autoFocus: true,
|
|
2161
|
+
disabled: sessionRenaming,
|
|
2162
|
+
onFocus: (e) => {
|
|
2163
|
+
e.target.select();
|
|
2164
|
+
},
|
|
2165
|
+
onChange: (e) => {
|
|
2166
|
+
setSessionRenameDraft(e.target.value);
|
|
2167
|
+
setSessionRenameError(null);
|
|
2168
|
+
},
|
|
2169
|
+
onCompositionStart: () => {
|
|
2170
|
+
composingRef.current = true;
|
|
2171
|
+
},
|
|
2172
|
+
onCompositionEnd: () => {
|
|
2173
|
+
composingRef.current = false;
|
|
2174
|
+
},
|
|
2175
|
+
onKeyDown: (e) => {
|
|
2176
|
+
if (e.key === "Enter" && !composingRef.current) {
|
|
2177
|
+
e.preventDefault();
|
|
2178
|
+
confirmSessionRename();
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
}), sessionRenameError !== null && (0, react_jsx_runtime.jsx)("div", {
|
|
2182
|
+
className: WorkspaceBrowser_module_css_default.renameError,
|
|
2183
|
+
role: "alert",
|
|
2184
|
+
children: sessionRenameError
|
|
2185
|
+
})]
|
|
2186
|
+
}),
|
|
2187
|
+
(0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
2188
|
+
open: sessionDeleteTarget !== null,
|
|
2189
|
+
onClose: closeSessionDelete,
|
|
2190
|
+
closeLabel: t("close"),
|
|
2191
|
+
title: t("delete.session.title"),
|
|
2192
|
+
...sessionDeleteTarget === null ? {} : { description: t("delete.session.desc", { name: sessionDeleteTarget.title }) },
|
|
2193
|
+
footer: (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2194
|
+
variant: "outline",
|
|
2195
|
+
disabled: sessionDeleting,
|
|
2196
|
+
onClick: closeSessionDelete,
|
|
2197
|
+
children: t("cancel")
|
|
2198
|
+
}), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2199
|
+
variant: "outline",
|
|
2200
|
+
className: WorkspaceBrowser_module_css_default.deleteAction,
|
|
2201
|
+
disabled: sessionDeleting,
|
|
2202
|
+
onClick: confirmSessionDelete,
|
|
2203
|
+
children: t("delete.session.confirm")
|
|
2204
|
+
})] }),
|
|
2205
|
+
children: [sessionDeleting && (0, react_jsx_runtime.jsx)("div", {
|
|
2206
|
+
className: WorkspaceBrowser_module_css_default.deleteStatus,
|
|
2207
|
+
role: "status",
|
|
2208
|
+
children: t("delete.session.pending")
|
|
2209
|
+
}), sessionDeleteError !== null && (0, react_jsx_runtime.jsx)("div", {
|
|
2210
|
+
className: WorkspaceBrowser_module_css_default.renameError,
|
|
2211
|
+
role: "alert",
|
|
2212
|
+
children: sessionDeleteError
|
|
2213
|
+
})]
|
|
2214
|
+
}),
|
|
2215
|
+
(0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
2216
|
+
open: deleteTarget !== null,
|
|
2217
|
+
onClose: closeDelete,
|
|
2218
|
+
closeLabel: t("close"),
|
|
2219
|
+
title: t("delete.workspace"),
|
|
2220
|
+
...deleteTarget === null ? {} : { description: t("delete.desc", { name: deleteTarget.title }) },
|
|
2221
|
+
footer: (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2222
|
+
variant: "outline",
|
|
2223
|
+
disabled: deleting,
|
|
2224
|
+
onClick: closeDelete,
|
|
2225
|
+
children: t("cancel")
|
|
2226
|
+
}), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2227
|
+
variant: "outline",
|
|
2228
|
+
className: WorkspaceBrowser_module_css_default.deleteAction,
|
|
2229
|
+
disabled: deleting,
|
|
2230
|
+
onClick: confirmDelete,
|
|
2231
|
+
children: t("delete.workspace")
|
|
2232
|
+
})] }),
|
|
2233
|
+
children: [deleting && (0, react_jsx_runtime.jsx)("div", {
|
|
2234
|
+
className: WorkspaceBrowser_module_css_default.deleteStatus,
|
|
2235
|
+
role: "status",
|
|
2236
|
+
children: t("delete.pending")
|
|
2237
|
+
}), deleteError !== null && (0, react_jsx_runtime.jsx)("div", {
|
|
2238
|
+
className: WorkspaceBrowser_module_css_default.renameError,
|
|
2239
|
+
role: "alert",
|
|
2240
|
+
children: deleteError
|
|
2241
|
+
})]
|
|
2242
|
+
})
|
|
2243
|
+
]
|
|
2244
|
+
});
|
|
2245
|
+
}
|
|
2246
|
+
//#endregion
|
|
2247
|
+
//#region lib/types/client/locales.js
|
|
2248
|
+
/**
|
|
2249
|
+
* `workspace` namespace dictionaries: the browsing region (section header,
|
|
2250
|
+
* search, tree rows, dialogs) and the pick/add flow. Runtime failure
|
|
2251
|
+
* messages (wire error strings) pass through untranslated by policy.
|
|
2252
|
+
*/
|
|
2253
|
+
/** Simplified Chinese dictionary (the key-set source of truth). */
|
|
2254
|
+
const zh = {
|
|
2255
|
+
"group.ungrouped": "未分组",
|
|
2256
|
+
"session.new": "新会话",
|
|
2257
|
+
"section.workspaces": "工作区",
|
|
2258
|
+
"section.sessions": "会话",
|
|
2259
|
+
"viewOptions.label": "视图选项",
|
|
2260
|
+
"groupBy.label": "分组方式",
|
|
2261
|
+
"groupBy.workspace": "按工作区",
|
|
2262
|
+
"groupBy.flat": "单列表",
|
|
2263
|
+
"orderBy.label": "排序方式",
|
|
2264
|
+
"orderBy.manual": "手动排序",
|
|
2265
|
+
"orderBy.updated": "最近更新",
|
|
2266
|
+
"sessions.expand": "展开其余 {n} 个会话",
|
|
2267
|
+
"sessions.collapse": "收起",
|
|
2268
|
+
"empty.none": "暂无会话",
|
|
2269
|
+
"empty.noMatches": "无匹配结果",
|
|
2270
|
+
"workspace.add": "添加工作区",
|
|
2271
|
+
"search.sessions.aria": "搜索会话",
|
|
2272
|
+
"search.placeholder": "搜索会话…",
|
|
2273
|
+
"search.clear": "清除搜索",
|
|
2274
|
+
"search.results.aria": "搜索结果",
|
|
2275
|
+
"search.pending": "正在搜索会话历史…",
|
|
2276
|
+
"search.unavailable": "内容搜索暂不可用,仅显示名称匹配。",
|
|
2277
|
+
"search.noMatches": "无匹配会话",
|
|
2278
|
+
"search.hasMore": "仅显示前 {n} 条结果,请缩小搜索范围。",
|
|
2279
|
+
"menu.addWorkspace": "添加工作区…",
|
|
2280
|
+
"picker.loading": "正在加载工作区…",
|
|
2281
|
+
"conflict.named": "已存在名为“{name}”的工作区。",
|
|
2282
|
+
"folderError.title": "无法打开文件夹",
|
|
2283
|
+
"folderError.retry": "重新选择",
|
|
2284
|
+
"rename": "重命名",
|
|
2285
|
+
"rename.workspace.title": "重命名工作区",
|
|
2286
|
+
"rename.session.title": "重命名会话",
|
|
2287
|
+
"field.workspaceName": "工作区名称",
|
|
2288
|
+
"field.sessionName": "会话名称",
|
|
2289
|
+
"delete.workspace": "删除工作区",
|
|
2290
|
+
"delete.desc": "将把“{name}”从工作区列表中移除。文件夹与会话记录会保留,其会话将显示在“未分组”下。",
|
|
2291
|
+
"delete.pending": "正在删除工作区…",
|
|
2292
|
+
"menu.fork": "分叉会话",
|
|
2293
|
+
"menu.archiveSession": "归档会话",
|
|
2294
|
+
"menu.deleteSession": "删除会话",
|
|
2295
|
+
"delete.session.title": "永久删除会话?",
|
|
2296
|
+
"delete.session.desc": "“{name}”的会话记录将从本机永久删除,且无法恢复。正在运行的任务会先安全停止。",
|
|
2297
|
+
"delete.session.confirm": "永久删除",
|
|
2298
|
+
"delete.session.pending": "正在永久删除会话…",
|
|
2299
|
+
"sessions.count.one": "{n} 个会话",
|
|
2300
|
+
"sessions.count.other": "{n} 个会话",
|
|
2301
|
+
"actions.workspace.aria": "工作区“{name}”的操作",
|
|
2302
|
+
"actions.session.aria": "会话“{name}”的操作",
|
|
2303
|
+
"actions.newSession.aria": "在“{name}”中新建会话",
|
|
2304
|
+
"status.running": "进行中",
|
|
2305
|
+
"status.subagentsRunning.one": "{n} 个子代理运行中",
|
|
2306
|
+
"status.subagentsRunning.other": "{n} 个子代理运行中",
|
|
2307
|
+
"status.idle": "空闲",
|
|
2308
|
+
"status.waitingApproval": "等待审批",
|
|
2309
|
+
"status.planReview": "计划待审",
|
|
2310
|
+
"status.waitingAnswer": "等待回答",
|
|
2311
|
+
"status.completed": "已完成",
|
|
2312
|
+
"hover.created": "创建于 {time}",
|
|
2313
|
+
"hover.copied": "已复制",
|
|
2314
|
+
"date.ymd": "{y}年{m}月{d}日",
|
|
2315
|
+
"time.now": "刚刚",
|
|
2316
|
+
"time.minutes": "{n}分钟",
|
|
2317
|
+
"time.hours": "{n}小时",
|
|
2318
|
+
"time.days": "{n}天",
|
|
2319
|
+
"time.months": "{n}个月",
|
|
2320
|
+
"time.years": "{n}年",
|
|
2321
|
+
"time.ago": "{t}前"
|
|
2322
|
+
};
|
|
2323
|
+
/** English dictionary, checked complete against the zh key set. */
|
|
2324
|
+
const en = {
|
|
2325
|
+
"group.ungrouped": "Ungrouped",
|
|
2326
|
+
"session.new": "New Session",
|
|
2327
|
+
"section.workspaces": "Workspaces",
|
|
2328
|
+
"section.sessions": "Sessions",
|
|
2329
|
+
"viewOptions.label": "View options",
|
|
2330
|
+
"groupBy.label": "Group by",
|
|
2331
|
+
"groupBy.workspace": "WorkSpace",
|
|
2332
|
+
"groupBy.flat": "In one list",
|
|
2333
|
+
"orderBy.label": "Order by",
|
|
2334
|
+
"orderBy.manual": "Manual",
|
|
2335
|
+
"orderBy.updated": "Last updated",
|
|
2336
|
+
"sessions.expand": "Show {n} more sessions",
|
|
2337
|
+
"sessions.collapse": "Show less",
|
|
2338
|
+
"empty.none": "No sessions yet",
|
|
2339
|
+
"empty.noMatches": "No matches",
|
|
2340
|
+
"workspace.add": "Add workspace",
|
|
2341
|
+
"search.sessions.aria": "Search sessions",
|
|
2342
|
+
"search.placeholder": "Search sessions...",
|
|
2343
|
+
"search.clear": "Clear search",
|
|
2344
|
+
"search.results.aria": "Search results",
|
|
2345
|
+
"search.pending": "Searching session history…",
|
|
2346
|
+
"search.unavailable": "Content search is temporarily unavailable. Showing name matches.",
|
|
2347
|
+
"search.noMatches": "No matching sessions",
|
|
2348
|
+
"search.hasMore": "Showing the first {n} results. Narrow your search.",
|
|
2349
|
+
"menu.addWorkspace": "Add workspace…",
|
|
2350
|
+
"picker.loading": "Loading workspaces…",
|
|
2351
|
+
"conflict.named": "A workspace named “{name}” already exists.",
|
|
2352
|
+
"folderError.title": "Couldn’t open folder",
|
|
2353
|
+
"folderError.retry": "Choose again",
|
|
2354
|
+
"rename": "Rename",
|
|
2355
|
+
"rename.workspace.title": "Rename workspace",
|
|
2356
|
+
"rename.session.title": "Rename session",
|
|
2357
|
+
"field.workspaceName": "Workspace name",
|
|
2358
|
+
"field.sessionName": "Session name",
|
|
2359
|
+
"delete.workspace": "Delete workspace",
|
|
2360
|
+
"delete.desc": "This removes “{name}” from the workspace list. The folder and session logs will be kept. Its sessions will appear under Ungrouped.",
|
|
2361
|
+
"delete.pending": "Deleting workspace…",
|
|
2362
|
+
"menu.fork": "Fork session",
|
|
2363
|
+
"menu.archiveSession": "Archive session",
|
|
2364
|
+
"menu.deleteSession": "Delete session",
|
|
2365
|
+
"delete.session.title": "Permanently delete session?",
|
|
2366
|
+
"delete.session.desc": "The local record for “{name}” will be permanently deleted and cannot be recovered. Running work will be stopped safely before deletion.",
|
|
2367
|
+
"delete.session.confirm": "Delete permanently",
|
|
2368
|
+
"delete.session.pending": "Permanently deleting session…",
|
|
2369
|
+
"sessions.count.one": "{n} session",
|
|
2370
|
+
"sessions.count.other": "{n} sessions",
|
|
2371
|
+
"actions.workspace.aria": "Workspace actions for {name}",
|
|
2372
|
+
"actions.session.aria": "Session actions for {name}",
|
|
2373
|
+
"actions.newSession.aria": "New session in {name}",
|
|
2374
|
+
"status.running": "Running",
|
|
2375
|
+
"status.subagentsRunning.one": "{n} subagent running",
|
|
2376
|
+
"status.subagentsRunning.other": "{n} subagents running",
|
|
2377
|
+
"status.idle": "Idle",
|
|
2378
|
+
"status.waitingApproval": "Waiting for approval",
|
|
2379
|
+
"status.planReview": "Plan awaiting review",
|
|
2380
|
+
"status.waitingAnswer": "Waiting for answer",
|
|
2381
|
+
"status.completed": "Completed",
|
|
2382
|
+
"hover.created": "Created {time}",
|
|
2383
|
+
"hover.copied": "Copied",
|
|
2384
|
+
"date.ymd": "{y}-{m}-{d}",
|
|
2385
|
+
"time.now": "now",
|
|
2386
|
+
"time.minutes": "{n}min",
|
|
2387
|
+
"time.hours": "{n}h",
|
|
2388
|
+
"time.days": "{n}d",
|
|
2389
|
+
"time.months": "{n}mo",
|
|
2390
|
+
"time.years": "{n}y",
|
|
2391
|
+
"time.ago": "{t} ago"
|
|
2392
|
+
};
|
|
2393
|
+
//#endregion
|
|
2394
|
+
//#region lib/types/client/index.js
|
|
2395
|
+
/** Dictionary namespace owned by this plugin. */
|
|
2396
|
+
const NS = "workspace";
|
|
2397
|
+
/**
|
|
2398
|
+
* Required services (cordis fiber inject). The target slots are declared by
|
|
2399
|
+
* the ui-sidebar / ui-conversation applies, whose activation order relative
|
|
2400
|
+
* to this one is NOT constrained: dsh.client.inject edges are informational
|
|
2401
|
+
* (loading/prefetch metadata, never apply sequencing) and neither owner
|
|
2402
|
+
* provides a waitable service. apply therefore depends on each slot
|
|
2403
|
+
* declaration through `slots.inject()` instead of assuming order.
|
|
2404
|
+
*/
|
|
2405
|
+
const inject = [
|
|
2406
|
+
"slots",
|
|
2407
|
+
"sessions",
|
|
2408
|
+
"workspaces",
|
|
2409
|
+
"locale",
|
|
2410
|
+
"connection"
|
|
2411
|
+
];
|
|
2412
|
+
/**
|
|
2413
|
+
* Register the browser and picker once their slot declarations are on the
|
|
2414
|
+
* ledger. Inject factories return plain callbacks; data reads use the
|
|
2415
|
+
* framework's global hooks.
|
|
2416
|
+
* @param ctx - client root context.
|
|
2417
|
+
*/
|
|
2418
|
+
function apply(ctx) {
|
|
2419
|
+
const hostDescription = ctx.get("connection").hostDescription;
|
|
2420
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
2421
|
+
zh,
|
|
2422
|
+
en
|
|
2423
|
+
}), "ui-workspace: dictionaries");
|
|
2424
|
+
const searchSessions = async (query, signal) => {
|
|
2425
|
+
const result = await ctx.sessions.search(query, signal);
|
|
2426
|
+
if (!result.ok) throw new Error(result.error.message);
|
|
2427
|
+
return result.value;
|
|
2428
|
+
};
|
|
2429
|
+
const flowSource = (hole) => ({
|
|
2430
|
+
getSnapshot: () => ctx.slots.entries(hole).length > 0,
|
|
2431
|
+
subscribe: (listener) => ctx.slots.subscribe(hole, listener)
|
|
2432
|
+
});
|
|
2433
|
+
const browserFlowSource = flowSource("sidebar.workspaces.directoryFlow");
|
|
2434
|
+
const pickerFlowSource = flowSource("conversation.hero.workspace.directoryFlow");
|
|
2435
|
+
const browserInjected = () => ({
|
|
2436
|
+
startSession: (workspaceId) => {
|
|
2437
|
+
ctx.workspaces.startSession(workspaceId);
|
|
2438
|
+
},
|
|
2439
|
+
open: (sessionId) => {
|
|
2440
|
+
ctx.sessions.open(sessionId);
|
|
2441
|
+
},
|
|
2442
|
+
searchSessions,
|
|
2443
|
+
searchResultLimit: ctx.sessions.searchResultLimit,
|
|
2444
|
+
renameSession: async (sessionId, title) => {
|
|
2445
|
+
const session = ctx.sessions.binding(sessionId)?.session;
|
|
2446
|
+
if (session === void 0) throw new Error(`unknown session "${sessionId}"`);
|
|
2447
|
+
const result = await session.rename(title);
|
|
2448
|
+
if (!result.ok) throw new Error(result.error.message);
|
|
2449
|
+
},
|
|
2450
|
+
forkSession: (sessionId) => {
|
|
2451
|
+
ctx.sessions.fork({
|
|
2452
|
+
sessionId,
|
|
2453
|
+
increaseTitle: true
|
|
2454
|
+
}).then((childId) => {
|
|
2455
|
+
ctx.sessions.open(childId);
|
|
2456
|
+
}).catch(() => {});
|
|
2457
|
+
},
|
|
2458
|
+
renameWorkspace: async (workspaceId, title) => {
|
|
2459
|
+
await ctx.workspaces.rename(workspaceId, title);
|
|
2460
|
+
},
|
|
2461
|
+
deleteWorkspace: async (workspaceId) => {
|
|
2462
|
+
await ctx.workspaces.delete(workspaceId);
|
|
2463
|
+
},
|
|
2464
|
+
insertWorkspaceBefore: async (workspaceId, beforeWorkspaceId) => {
|
|
2465
|
+
await ctx.workspaces.insertBefore(workspaceId, beforeWorkspaceId);
|
|
2466
|
+
},
|
|
2467
|
+
archiveSession: async (sessionId) => {
|
|
2468
|
+
await ctx.workspaces.archiveSession(sessionId);
|
|
2469
|
+
},
|
|
2470
|
+
deleteSession: async (sessionId) => {
|
|
2471
|
+
const response = await fetch("/plugins/dsh-session-delete/delete", {
|
|
2472
|
+
method: "POST",
|
|
2473
|
+
headers: {
|
|
2474
|
+
"content-type": "application/json",
|
|
2475
|
+
"x-dsh-session-delete-confirmation": "delete-session"
|
|
2476
|
+
},
|
|
2477
|
+
body: JSON.stringify({ sessionId })
|
|
2478
|
+
});
|
|
2479
|
+
const payload = await response.json().catch(() => null);
|
|
2480
|
+
if (!response.ok || payload?.ok !== true) {
|
|
2481
|
+
throw new Error(payload?.error?.message ?? `Delete failed (HTTP ${response.status})`);
|
|
2482
|
+
}
|
|
2483
|
+
if (ctx.sessions.list.getSnapshot().current === sessionId) ctx.sessions.clear();
|
|
2484
|
+
const refreshes = await Promise.allSettled([
|
|
2485
|
+
ctx.sessions.refresh(),
|
|
2486
|
+
ctx.workspaces.refresh()
|
|
2487
|
+
]);
|
|
2488
|
+
for (const refresh of refreshes) {
|
|
2489
|
+
if (refresh.status === "rejected") console.warn("session deletion succeeded but runtime refresh failed:", refresh.reason);
|
|
2490
|
+
}
|
|
2491
|
+
},
|
|
2492
|
+
insertSessionBefore: async (workspaceId, sessionId, beforeSessionId) => {
|
|
2493
|
+
await ctx.workspaces.insertSessionBefore(workspaceId, sessionId, beforeSessionId);
|
|
2494
|
+
},
|
|
2495
|
+
createWorkspace: (input) => ctx.workspaces.create(input),
|
|
2496
|
+
hooks: {
|
|
2497
|
+
directoryFlow: browserFlowSource,
|
|
2498
|
+
hostDescription
|
|
2499
|
+
}
|
|
2500
|
+
});
|
|
2501
|
+
const pickerInjected = () => ({
|
|
2502
|
+
createWorkspace: (input) => ctx.workspaces.create(input),
|
|
2503
|
+
hooks: { directoryFlow: pickerFlowSource }
|
|
2504
|
+
});
|
|
2505
|
+
ctx.slots.inject("sidebar.workspaces", () => ctx.slots.register({
|
|
2506
|
+
name: "sidebar.workspaces",
|
|
2507
|
+
children: { "sidebar.workspaces.directoryFlow": {
|
|
2508
|
+
kind: "single",
|
|
2509
|
+
scope: "root"
|
|
2510
|
+
} },
|
|
2511
|
+
store: createWorkspaceViewStore(),
|
|
2512
|
+
inject: browserInjected,
|
|
2513
|
+
locale: NS
|
|
2514
|
+
}, WorkspaceBrowser));
|
|
2515
|
+
ctx.slots.inject("conversation.hero.workspace", () => ctx.slots.register({
|
|
2516
|
+
name: "conversation.hero.workspace",
|
|
2517
|
+
children: { "conversation.hero.workspace.directoryFlow": {
|
|
2518
|
+
kind: "single",
|
|
2519
|
+
scope: "root"
|
|
2520
|
+
} },
|
|
2521
|
+
inject: pickerInjected,
|
|
2522
|
+
locale: NS
|
|
2523
|
+
}, WorkspacePicker));
|
|
2524
|
+
}
|
|
2525
|
+
//#endregion
|
|
2526
|
+
exports.apply = apply;
|
|
2527
|
+
exports.inject = inject;
|
|
2528
|
+
return module.exports;
|
|
2529
|
+
}
|
|
2530
|
+
});
|
|
2531
|
+
|
|
2532
|
+
//# sourceMappingURL=client.js.map
|