dsh-edge 0.1.0

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