@yankeguo/dsh-client-ui-devlead 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @yankeguo/dsh-client-ui-devlead
2
+
3
+ Browser half of the DevLead suite, loaded on the DSH **Web** platform.
4
+
5
+ - **Off state:** a compact ghost icon in the composer toolbar (`conversation.input.left`) sends
6
+ `/devlead on`.
7
+ - **On state:** a status strip above the composer (`conversation.input.dock`) shows the switch,
8
+ watched/running counts, and the latest retained notification; the switch sends `/devlead off`.
9
+ - **Sidebar marks:** enabled Sessions get a shield mark (`sidebar.session.row.trailing`) and a
10
+ line in the row hover card (`sidebar.session.row.hover`), read from the summary-sized
11
+ `devLeadMode` projection.
12
+
13
+ The browser bundle only registers into DSH client slots and sends `/devlead` commands. It has no
14
+ custom Remote API, no optimistic state flips, and no direct Host access; all durable state comes
15
+ from the `devLead` / `devLeadMode` projections. The locale namespace is `devlead` with `zh` and
16
+ `en` dictionaries.
17
+
18
+ Style injection is reference-counted across **module instances** (`Symbol.for(...)` key on `globalThis`):
19
+ HMR old/new instances can coexist without an old disposer removing the `<style>` tag a new instance
20
+ still uses. The two entry points and `useDevLeadAdmission` have React render tests using
21
+ `react-test-renderer` (devDependency only, pure node, no jsdom); the style-tag refcount is covered
22
+ by a second-module-instance test (`vi.resetModules()` + dynamic import).
23
+
24
+ Known UI limits: the mark is subject to the projection-cache backfill described in the repository
25
+ README, and DSH 0.2.2-rc.1 does not render the trailing seat on a blank (no-turn-yet) Session row.
26
+
27
+ ## Install
28
+
29
+ Normally installed as part of the bundle:
30
+
31
+ ```sh
32
+ dsh plugin --profile desktop add @yankeguo/dsh-devlead-bundle
33
+ ```
34
+
35
+ ## Related docs
36
+
37
+ - [Repository README (English)](https://github.com/yankeguo/dsh-devlead/blob/main/README.md) / [中文](https://github.com/yankeguo/dsh-devlead/blob/main/README.zh.md)
38
+ - [Design notes: browser UI, slots, locale and accessibility](https://github.com/yankeguo/dsh-devlead/blob/main/docs/DESIGN.md)
39
+ - [Optional-dependency audit: client inject ids](https://github.com/yankeguo/dsh-devlead/blob/main/docs/OPTIONAL-DEPENDENCIES.md)
40
+
41
+ ## 中文
42
+
43
+ `@yankeguo/dsh-client-ui-devlead` 是浏览器半边:未开启时的 composer 工具条图标、开启后的
44
+ DevLeadBar、侧边栏会话行标记;只读 `devLead`/`devLeadMode` projection 并发送 `/devlead`
45
+ 命令。0.2.0 起样式注入用跨模块实例引用计数(HMR 新旧实例交替不误删标签),两个入口与准入
46
+ hook 用 `react-test-renderer` 做渲染测试。已知 mark 回填与 blank 行限制见根 README。完整中文文档见
47
+ [根 README.zh.md](https://github.com/yankeguo/dsh-devlead/blob/main/README.zh.md)与[设计说明](https://github.com/yankeguo/dsh-devlead/blob/main/docs/DESIGN.md)。
package/lib/client.js CHANGED
@@ -31,9 +31,14 @@ window.__ModuleLoader__.load({
31
31
  module.exports = __toCommonJS(index_exports);
32
32
 
33
33
  // packages/client-ui/src/client/DevLeadBar.tsx
34
- var import_react = require("react");
35
34
  var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
36
35
 
36
+ // packages/protocol/src/types.ts
37
+ var DEVLEAD_PROJECTION_KEY = "devLead";
38
+ var DEVLEAD_MODE_PROJECTION_KEY = "devLeadMode";
39
+ var DEVLEAD_COMMAND_NAME = "devlead";
40
+ var DEVLEAD_ERROR_EXCERPT_MAX = 240;
41
+
37
42
  // packages/protocol/src/format.ts
38
43
  var DEVLEAD_TRANSITIONS = [
39
44
  "completed",
@@ -44,8 +49,18 @@ window.__ModuleLoader__.load({
44
49
  "interrupted",
45
50
  "forked"
46
51
  ];
52
+ var TRANSITION_SET = new Set(DEVLEAD_TRANSITIONS);
47
53
  function isDevLeadTransition(value) {
48
- return typeof value === "string" && DEVLEAD_TRANSITIONS.includes(value);
54
+ return typeof value === "string" && TRANSITION_SET.has(value);
55
+ }
56
+ function excerptLine(text, max) {
57
+ const collapsed = text.replace(/\s+/gu, " ").trim();
58
+ if (collapsed.length === 0) return void 0;
59
+ const budget = Number.isFinite(max) ? Math.floor(max) : Number.POSITIVE_INFINITY;
60
+ if (budget < 1) return void 0;
61
+ const points = Array.from(collapsed);
62
+ if (points.length <= budget) return collapsed;
63
+ return `${points.slice(0, budget - 1).join("")}\u2026`;
49
64
  }
50
65
  var TRANSITION_LABELS = {
51
66
  completed: "completed",
@@ -59,47 +74,45 @@ window.__ModuleLoader__.load({
59
74
  function transitionLabel(transition) {
60
75
  return TRANSITION_LABELS[transition];
61
76
  }
77
+ function presentLine(value) {
78
+ if (value === void 0) return void 0;
79
+ return excerptLine(value, DEVLEAD_ERROR_EXCERPT_MAX);
80
+ }
62
81
  function notificationLine(notification) {
63
- const who = notification.sessionTitle === void 0 ? notification.sessionId : `${notification.sessionTitle} (${notification.sessionId})`;
64
- const error = notification.error === void 0 ? "" : `: ${notification.error}`;
65
- const summary = notification.error === void 0 && notification.summary !== void 0 ? `: ${notification.summary}` : "";
66
- return `${who} \u2014 turn ${notification.turn} ${transitionLabel(notification.transition)}${error}${summary}`;
82
+ const title = presentLine(notification.sessionTitle);
83
+ const who = title === void 0 ? notification.sessionId : `${title} (${notification.sessionId})`;
84
+ const error = presentLine(notification.error);
85
+ const detail = error ?? presentLine(notification.summary);
86
+ const suffix = detail === void 0 ? "" : `: ${detail}`;
87
+ return `${who} \u2014 turn ${notification.turn} ${transitionLabel(notification.transition)}${suffix}`;
67
88
  }
68
89
 
69
90
  // packages/client-ui/src/client/format.ts
91
+ var TRANSITION_LABEL_KEYS = {
92
+ completed: "transition.completed",
93
+ error: "transition.error",
94
+ blocked: "transition.blocked",
95
+ aborted: "transition.aborted",
96
+ "max-tokens": "transition.max-tokens",
97
+ interrupted: "transition.interrupted",
98
+ forked: "transition.forked"
99
+ };
70
100
  function transitionLabelKey(transition) {
71
- switch (transition) {
72
- case "completed":
73
- return "transition.completed";
74
- case "error":
75
- return "transition.error";
76
- case "blocked":
77
- return "transition.blocked";
78
- case "aborted":
79
- return "transition.aborted";
80
- case "max-tokens":
81
- return "transition.max-tokens";
82
- case "interrupted":
83
- return "transition.interrupted";
84
- case "forked":
85
- return "transition.forked";
86
- default:
87
- return "transition.unknown";
88
- }
101
+ return isDevLeadTransition(transition) ? TRANSITION_LABEL_KEYS[transition] : "transition.unknown";
89
102
  }
90
103
  function notificationSummary(notification) {
91
- const rawTitle = typeof notification.sessionTitle === "string" ? notification.sessionTitle.trim() : "";
92
- const who = rawTitle.length > 0 ? rawTitle : notification.sessionId;
104
+ const title = typeof notification.sessionTitle === "string" ? excerptLine(notification.sessionTitle, DEVLEAD_ERROR_EXCERPT_MAX) : void 0;
105
+ const who = title ?? notification.sessionId;
93
106
  const turn = Number.isInteger(notification.turn) && notification.turn > 0 ? notification.turn : 0;
94
107
  const tooltip = isDevLeadTransition(notification.transition) ? notificationLine(notification) : `${who} \u2014 ${String(notification.transition)}`;
95
- const rawError = typeof notification.error === "string" ? notification.error.trim() : "";
108
+ const error = typeof notification.error === "string" ? excerptLine(notification.error, DEVLEAD_ERROR_EXCERPT_MAX) : void 0;
96
109
  return {
97
110
  tooltip,
98
111
  who,
99
112
  turn,
100
113
  transition: String(notification.transition),
101
114
  labelKey: transitionLabelKey(notification.transition),
102
- error: rawError.length > 0 ? rawError : void 0
115
+ error
103
116
  };
104
117
  }
105
118
  function latestNotification(notifications) {
@@ -122,40 +135,111 @@ window.__ModuleLoader__.load({
122
135
  }
123
136
 
124
137
  // packages/client-ui/src/client/results.ts
125
- var REJECTED_FALLBACK = "command rejected";
126
- var UNEXPECTED_FALLBACK = "unknown error";
138
+ function presentMessage(value) {
139
+ if (value === void 0) return void 0;
140
+ const trimmed = value.trim();
141
+ return trimmed.length === 0 ? void 0 : trimmed;
142
+ }
127
143
  function commandFailure(result) {
128
144
  if (!result.ok) {
129
- return { kind: "transport", message: result.error.message, code: result.error.code };
145
+ const message2 = presentMessage(result.error.message);
146
+ return {
147
+ kind: "transport",
148
+ ...message2 === void 0 ? {} : { message: message2 },
149
+ code: result.error.code
150
+ };
130
151
  }
131
152
  const outcome = result.value?.result;
132
153
  if (outcome === void 0 || outcome.kind !== "error") return void 0;
133
- return { kind: "rejected", message: outcome.text ?? REJECTED_FALLBACK };
154
+ const message = presentMessage(outcome.text);
155
+ return { kind: "rejected", ...message === void 0 ? {} : { message } };
134
156
  }
135
157
  function unexpectedFailure(error) {
136
- return { kind: "unexpected", message: error instanceof Error ? error.message : UNEXPECTED_FALLBACK };
158
+ const message = error instanceof Error ? presentMessage(error.message) : void 0;
159
+ return { kind: "unexpected", ...message === void 0 ? {} : { message } };
137
160
  }
138
161
  async function admitCommand(executeCommand, line) {
139
162
  try {
140
- return commandFailure(await executeCommand(line));
163
+ const result = await executeCommand(line);
164
+ if (result.ok && result.value === void 0) return { kind: "unresolved", line };
165
+ return commandFailure(result);
141
166
  } catch (error) {
142
167
  return unexpectedFailure(error);
143
168
  }
144
169
  }
145
- function failureMessage(failure) {
146
- return failure.message;
170
+ var FAILURE_FALLBACK_KEYS = {
171
+ transport: "error.fallback.transport",
172
+ rejected: "error.fallback.rejected",
173
+ unexpected: "error.fallback.unknown"
174
+ };
175
+ function failureMessage(failure, t) {
176
+ if (failure.kind === "unresolved") return t("error.fallback.unresolved");
177
+ return failure.message ?? t(FAILURE_FALLBACK_KEYS[failure.kind]);
147
178
  }
148
179
  function failureCopy(failure) {
149
180
  switch (failure.kind) {
150
181
  case "transport":
151
- return { key: "error.command", params: { message: failure.message, code: failure.code } };
182
+ return failure.message === void 0 ? { key: "error.fallback.transport", params: {} } : { key: "error.command", params: { message: failure.message, code: failure.code } };
152
183
  case "rejected":
153
- return { key: "error.rejected", params: { message: failure.message } };
184
+ return failure.message === void 0 ? { key: "error.fallback.rejected", params: {} } : { key: "error.rejected", params: { message: failure.message } };
154
185
  case "unexpected":
155
- return { key: "error.unknown", params: { message: failure.message } };
186
+ return failure.message === void 0 ? { key: "error.fallback.unknown", params: {} } : { key: "error.unknown", params: { message: failure.message } };
187
+ case "unresolved":
188
+ return { key: "error.unresolved", params: { line: failure.line } };
189
+ }
190
+ }
191
+ function createDevLeadAdmissionGate() {
192
+ let entered = false;
193
+ return {
194
+ tryEnter: () => {
195
+ if (entered) return false;
196
+ entered = true;
197
+ return true;
198
+ },
199
+ leave: () => {
200
+ entered = false;
201
+ }
202
+ };
203
+ }
204
+ var DEVLEAD_ADMISSION_IDLE = { pending: false, failure: null };
205
+ function devLeadAdmissionReducer(state, action) {
206
+ switch (action.type) {
207
+ case "begin":
208
+ return state.pending && state.failure === null ? state : { pending: true, failure: null };
209
+ case "settle":
210
+ return state.pending || state.failure !== action.failure ? { pending: false, failure: action.failure } : state;
211
+ case "reset":
212
+ return state.failure === null ? state : { pending: state.pending, failure: null };
156
213
  }
157
214
  }
158
215
 
216
+ // packages/client-ui/src/client/useDevLeadAdmission.ts
217
+ var import_react = require("react");
218
+ function useDevLeadAdmission(executeCommand, resetKey) {
219
+ const [state, dispatch] = (0, import_react.useReducer)(devLeadAdmissionReducer, DEVLEAD_ADMISSION_IDLE);
220
+ const [gate] = (0, import_react.useState)(createDevLeadAdmissionGate);
221
+ const aliveRef = (0, import_react.useRef)(true);
222
+ (0, import_react.useEffect)(() => {
223
+ aliveRef.current = true;
224
+ return () => {
225
+ aliveRef.current = false;
226
+ };
227
+ }, []);
228
+ (0, import_react.useEffect)(() => {
229
+ dispatch({ type: "reset" });
230
+ }, [resetKey]);
231
+ const run = (line) => {
232
+ if (!gate.tryEnter()) return;
233
+ dispatch({ type: "begin" });
234
+ void admitCommand(executeCommand, line).then((failure) => {
235
+ gate.leave();
236
+ if (!aliveRef.current) return;
237
+ dispatch({ type: "settle", failure: failure ?? null });
238
+ });
239
+ };
240
+ return { pending: state.pending, failure: state.failure, run };
241
+ }
242
+
159
243
  // packages/client-ui/src/client/DevLeadBar.tsx
160
244
  var import_jsx_runtime = require("react/jsx-runtime");
161
245
  function DevLeadBar({
@@ -165,16 +249,11 @@ window.__ModuleLoader__.load({
165
249
  executeCommand,
166
250
  t
167
251
  }) {
168
- const projection = useProjection("devLead");
252
+ const projection = useProjection(DEVLEAD_PROJECTION_KEY);
169
253
  const rows = useSessions((state) => state.byId);
170
254
  const statuses = useSessionStatus((current) => current);
171
255
  const enabled = projection?.enabled ?? false;
172
- const [pending, setPending] = (0, import_react.useState)(false);
173
- const [failure, setFailure] = (0, import_react.useState)(null);
174
- const pendingRef = (0, import_react.useRef)(false);
175
- (0, import_react.useEffect)(() => {
176
- setFailure(null);
177
- }, [enabled]);
256
+ const { pending, failure, run } = useDevLeadAdmission(executeCommand, enabled);
178
257
  if (projection === void 0 || !enabled) return null;
179
258
  const summary = summarizeWatched(projection.sessions, rows, statuses);
180
259
  const latest = latestNotification(projection.notifications);
@@ -182,15 +261,8 @@ window.__ModuleLoader__.load({
182
261
  const failureLine = failure === null ? null : failureCopy(failure);
183
262
  const switchTitle = pending ? t("switch.pending") : t("switch.disable");
184
263
  const toggle = (next) => {
185
- if (next || pendingRef.current) return;
186
- pendingRef.current = true;
187
- setPending(true);
188
- setFailure(null);
189
- void admitCommand(executeCommand, "/devlead off").then((rejected) => {
190
- pendingRef.current = false;
191
- setPending(false);
192
- if (rejected !== void 0) setFailure(rejected);
193
- });
264
+ if (next) return;
265
+ run(`/${DEVLEAD_COMMAND_NAME} off`);
194
266
  };
195
267
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
196
268
  "div",
@@ -236,24 +308,34 @@ window.__ModuleLoader__.load({
236
308
  ] }),
237
309
  summary.missing > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-missing", title: t("count.missing", { count: summary.missing }), children: t("count.missing", { count: summary.missing }) })
238
310
  ] }),
239
- notice === null ? (
240
- // An enabled Session with no retained notification keeps the help
241
- // hint visible instead of leaving the row visually empty.
242
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-hint", title: t("hint.enabled"), children: t("hint.enabled") })
243
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "devlead-notification", title: notice.tooltip, children: [
244
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
245
- "span",
246
- {
247
- className: "devlead-notification-dot",
248
- "data-transition": notice.transition,
249
- "aria-hidden": "true"
250
- }
251
- ),
252
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-notification-who", children: notice.who }),
253
- notice.turn > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-notification-turn", children: t("notification.turn", { turn: notice.turn }) }),
254
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-notification-label", children: t(notice.labelKey) }),
255
- notice.error !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-notification-error", children: notice.error })
256
- ] }),
311
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
312
+ "span",
313
+ {
314
+ className: "devlead-notice",
315
+ role: "status",
316
+ "aria-live": "polite",
317
+ "aria-atomic": "true",
318
+ title: notice === null ? t("hint.enabled") : notice.tooltip,
319
+ children: notice === null ? (
320
+ // An enabled Session with no retained notification keeps the help
321
+ // hint visible instead of leaving the row visually empty.
322
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-hint", children: t("hint.enabled") })
323
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "devlead-notification", children: [
324
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
325
+ "span",
326
+ {
327
+ className: "devlead-notification-dot",
328
+ "data-transition": notice.transition,
329
+ "aria-hidden": "true"
330
+ }
331
+ ),
332
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-notification-who", children: notice.who }),
333
+ notice.turn > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-notification-turn", children: t("notification.turn", { turn: notice.turn }) }),
334
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-notification-label", children: t(notice.labelKey) }),
335
+ notice.error !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-notification-error", children: notice.error })
336
+ ] })
337
+ }
338
+ ),
257
339
  failureLine !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-error", role: "alert", children: t(failureLine.key, failureLine.params) })
258
340
  ]
259
341
  }
@@ -263,52 +345,78 @@ window.__ModuleLoader__.load({
263
345
  }
264
346
 
265
347
  // packages/client-ui/src/client/DevLeadIconToggle.tsx
266
- var import_react2 = require("react");
267
348
  var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
268
349
  var import_jsx_runtime2 = require("react/jsx-runtime");
269
350
  function DevLeadIconToggle({ useProjection, executeCommand, t }) {
270
- const projection = useProjection("devLead");
351
+ const projection = useProjection(DEVLEAD_PROJECTION_KEY);
271
352
  const enabled = projection?.enabled ?? false;
272
- const [pending, setPending] = (0, import_react2.useState)(false);
273
- const [failure, setFailure] = (0, import_react2.useState)(null);
274
- const pendingRef = (0, import_react2.useRef)(false);
275
- (0, import_react2.useEffect)(() => {
276
- setFailure(null);
277
- }, [enabled]);
353
+ const { pending, failure, run } = useDevLeadAdmission(executeCommand, enabled);
278
354
  if (projection === void 0 || enabled) return null;
279
- const enable = () => {
280
- if (pendingRef.current) return;
281
- pendingRef.current = true;
282
- setPending(true);
283
- setFailure(null);
284
- void admitCommand(executeCommand, "/devlead on").then((rejected) => {
285
- pendingRef.current = false;
286
- setPending(false);
287
- if (rejected !== void 0) setFailure(rejected);
288
- });
289
- };
290
- const label = failure === null ? t("toggle.enable") : t("toggle.failed", { message: failureMessage(failure) });
291
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Tooltip, { label, side: "top", delayMs: 300, maxWidth: 300, portal: true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
292
- import_dsh_client_ui_primitives2.Button,
355
+ const label = failure === null ? t("toggle.enable") : t("toggle.failed", { message: failureMessage(failure, t) });
356
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
357
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Tooltip, { label, side: "top", delayMs: 300, maxWidth: 300, portal: true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
358
+ import_dsh_client_ui_primitives2.Button,
359
+ {
360
+ variant: "ghost",
361
+ size: "sm",
362
+ className: "devlead-toggle",
363
+ "aria-label": label,
364
+ "aria-busy": pending,
365
+ disabled: pending,
366
+ "data-devlead-toggle": "true",
367
+ "data-devlead-pending": pending ? "true" : "false",
368
+ "data-devlead-failed": failure === null ? "false" : "true",
369
+ onClick: () => {
370
+ run(`/${DEVLEAD_COMMAND_NAME} on`);
371
+ },
372
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconUsersOutlineRegular, { size: 16 })
373
+ }
374
+ ) }),
375
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "devlead-sr-only", role: "status", "aria-live": "polite", "aria-atomic": "true", children: failure === null ? null : t("toggle.failed.status", { message: failureMessage(failure, t) }) })
376
+ ] });
377
+ }
378
+
379
+ // packages/client-ui/src/client/DevLeadSessionHoverMark.tsx
380
+ var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
381
+
382
+ // packages/client-ui/src/client/sessionMark.ts
383
+ function devLeadRowEnabled(summary) {
384
+ return summary?.projectionValues?.[DEVLEAD_MODE_PROJECTION_KEY]?.enabled === true;
385
+ }
386
+
387
+ // packages/client-ui/src/client/DevLeadSessionHoverMark.tsx
388
+ var import_jsx_runtime3 = require("react/jsx-runtime");
389
+ function DevLeadSessionHoverMark({ sessionId, useSessions, t }) {
390
+ const enabled = useSessions((state) => devLeadRowEnabled(state.byId[sessionId]));
391
+ if (!enabled) return null;
392
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "devlead-row-hover", "data-devlead-row-hover": "true", children: [
393
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "devlead-row-hover-glyph", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.IconShieldOutlineRegular, { size: 14 }) }),
394
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: t("row.hover.enabled") })
395
+ ] });
396
+ }
397
+
398
+ // packages/client-ui/src/client/DevLeadSessionMark.tsx
399
+ var import_dsh_client_ui_primitives4 = require("@deepseek-ai/dsh-client-ui-primitives");
400
+ var import_jsx_runtime4 = require("react/jsx-runtime");
401
+ function DevLeadSessionMark({ sessionId, useSessions, t }) {
402
+ const enabled = useSessions((state) => devLeadRowEnabled(state.byId[sessionId]));
403
+ if (!enabled) return null;
404
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
405
+ "span",
293
406
  {
294
- variant: "ghost",
295
- size: "sm",
296
- className: "devlead-toggle",
297
- "aria-label": label,
298
- disabled: pending,
299
- "data-devlead-toggle": "true",
300
- "data-devlead-pending": pending ? "true" : "false",
301
- "data-devlead-failed": failure === null ? "false" : "true",
302
- onClick: enable,
303
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconUsersOutlineRegular, { size: 16, "aria-hidden": "true" })
407
+ className: "devlead-row-mark",
408
+ role: "img",
409
+ "aria-label": t("row.mark.aria"),
410
+ "data-devlead-row-mark": "true",
411
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.IconShieldOutlineRegular, { size: 13 })
304
412
  }
305
- ) });
413
+ );
306
414
  }
307
415
 
308
416
  // packages/client-ui/src/client/locales.ts
309
417
  var zh = {
310
418
  "meta.title": "DevLead \u6A21\u5F0F",
311
- "meta.description": "\u5728\u8F93\u5165\u6846\u5DE5\u5177\u6761\u4E2D\u5F00\u5173 DevLead \u6A21\u5F0F\uFF1B\u5F00\u542F\u540E\u5728\u8F93\u5165\u6846\u4E0A\u65B9\u663E\u793A\u72B6\u6001\u6761\u3001\u76D1\u7763\u4F1A\u8BDD\u72B6\u6001\u4E0E\u6700\u8FD1\u4E00\u6761\u901A\u77E5\u3002",
419
+ "meta.description": "\u5728\u8F93\u5165\u6846\u5DE5\u5177\u6761\u4E2D\u5F00\u5173 DevLead \u6A21\u5F0F\uFF1B\u5F00\u542F\u540E\u5728\u8F93\u5165\u6846\u4E0A\u65B9\u663E\u793A\u72B6\u6001\u6761\uFF0C\u5E76\u5728\u4FA7\u8FB9\u680F\u4F1A\u8BDD\u884C\u6807\u8BB0\u8BE5\u4F1A\u8BDD\u3002",
312
420
  "bar.aria": "DevLead \u72B6\u6001\u680F",
313
421
  "label": "DevLead",
314
422
  "switch.aria": "DevLead \u6A21\u5F0F",
@@ -318,8 +426,11 @@ window.__ModuleLoader__.load({
318
426
  "count.watched": "\u76D1\u7763 {count} \u4E2A\u4F1A\u8BDD",
319
427
  "count.running": "\u8FD0\u884C\u4E2D {count}",
320
428
  "count.missing": "{count} \u4E2A\u5DF2\u4E0D\u53EF\u7528",
429
+ "row.mark.aria": "DevLead \u6A21\u5F0F\u5DF2\u542F\u7528",
430
+ "row.hover.enabled": "DevLead \u6A21\u5F0F\u5DF2\u542F\u7528\uFF1A\u672C\u4F1A\u8BDD\u53EF\u8C03\u5EA6\u5E76\u76D1\u7763\u5176\u4ED6\u4F1A\u8BDD\u3002",
321
431
  "toggle.enable": "\u5F00\u542F DevLead \u6A21\u5F0F",
322
432
  "toggle.failed": "\u5F00\u542F DevLead \u6A21\u5F0F\u5931\u8D25\uFF1A{message}\uFF08\u60AC\u505C\u67E5\u770B\uFF0C\u53EF\u91CD\u8BD5\uFF09",
433
+ "toggle.failed.status": "\u5F00\u542F DevLead \u6A21\u5F0F\u5931\u8D25\uFF1A{message}",
323
434
  "notification.turn": "\u7B2C {turn} \u8F6E",
324
435
  "transition.completed": "\u5B8C\u6210",
325
436
  "transition.error": "\u5931\u8D25",
@@ -331,11 +442,16 @@ window.__ModuleLoader__.load({
331
442
  "transition.unknown": "\u672A\u77E5\u72B6\u6001",
332
443
  "error.command": "\u547D\u4EE4\u5931\u8D25\uFF1A{message}\uFF08{code}\uFF09",
333
444
  "error.rejected": "\u547D\u4EE4\u88AB\u62D2\u7EDD\uFF1A{message}",
334
- "error.unknown": "\u547D\u4EE4\u6267\u884C\u5931\u8D25\uFF1A{message}"
445
+ "error.unknown": "\u547D\u4EE4\u6267\u884C\u5931\u8D25\uFF1A{message}",
446
+ "error.unresolved": "\u547D\u4EE4\u672A\u6267\u884C\uFF1AHost \u672A\u8BC6\u522B {line}",
447
+ "error.fallback.transport": "\u547D\u4EE4\u5931\u8D25",
448
+ "error.fallback.rejected": "\u547D\u4EE4\u88AB\u62D2\u7EDD",
449
+ "error.fallback.unknown": "\u672A\u77E5\u9519\u8BEF",
450
+ "error.fallback.unresolved": "Host \u672A\u8BC6\u522B\u8BE5\u547D\u4EE4"
335
451
  };
336
452
  var en = {
337
453
  "meta.title": "DevLead mode",
338
- "meta.description": "Toggles DevLead mode from the composer toolbar; once enabled, a status strip above the composer shows watched sessions and the latest notification.",
454
+ "meta.description": "Toggles DevLead mode from the composer toolbar; once enabled, a status strip appears above the composer and the Session is marked in the sidebar list.",
339
455
  "bar.aria": "DevLead status bar",
340
456
  "label": "DevLead",
341
457
  "switch.aria": "DevLead mode",
@@ -345,8 +461,11 @@ window.__ModuleLoader__.load({
345
461
  "count.watched": "{count} watched",
346
462
  "count.running": "{count} running",
347
463
  "count.missing": "{count} unavailable",
464
+ "row.mark.aria": "DevLead mode is on",
465
+ "row.hover.enabled": "DevLead mode is on: this session can dispatch and watch other Sessions.",
348
466
  "toggle.enable": "Turn on DevLead mode",
349
467
  "toggle.failed": "Could not turn on DevLead mode: {message} (hover to read, then retry)",
468
+ "toggle.failed.status": "Could not turn on DevLead mode: {message}",
350
469
  "notification.turn": "turn {turn}",
351
470
  "transition.completed": "completed",
352
471
  "transition.error": "failed",
@@ -358,15 +477,26 @@ window.__ModuleLoader__.load({
358
477
  "transition.unknown": "unknown state",
359
478
  "error.command": "Command failed: {message} ({code})",
360
479
  "error.rejected": "Command rejected: {message}",
361
- "error.unknown": "Command failed: {message}"
480
+ "error.unknown": "Command failed: {message}",
481
+ "error.unresolved": "Command did not run: the Host did not recognize {line}",
482
+ "error.fallback.transport": "command failed",
483
+ "error.fallback.rejected": "command rejected",
484
+ "error.fallback.unknown": "unknown error",
485
+ "error.fallback.unresolved": "the Host did not recognize the command"
362
486
  };
363
487
 
364
488
  // packages/client-ui/src/client/styles.ts
365
489
  var STYLE_ATTRIBUTE = "data-plugin-css";
366
490
  var STYLE_KEY = "devlead";
367
491
  var styles = `
492
+ /* Composer-tool row control: the 28px round glyph seat of the shipped attach
493
+ and mode controls, so the off-state entry reads as one of them. */
368
494
  .devlead-toggle {
369
495
  flex: none;
496
+ width: 28px;
497
+ height: 28px;
498
+ padding: 0;
499
+ border-radius: 999px;
370
500
  color: var(--dsw-alias-label-tertiary, GrayText);
371
501
  }
372
502
 
@@ -386,17 +516,22 @@ window.__ModuleLoader__.load({
386
516
  100% -
387
517
  var(--dsh-composer-side-clearance, 16px) -
388
518
  var(--dsh-composer-side-clearance, 16px) -
389
- var(--dsh-composer-dock-inset, 4px) -
390
- var(--dsh-composer-dock-inset, 4px) -
391
- var(--dsh-composer-dock-inset, 4px) -
392
- var(--dsh-composer-dock-inset, 4px)
519
+ var(--dsh-composer-dock-inset, 8px) -
520
+ var(--dsh-composer-dock-inset, 8px) -
521
+ var(--dsh-composer-dock-inset, 8px) -
522
+ var(--dsh-composer-dock-inset, 8px)
393
523
  );
394
- max-width: calc(var(--dsh-composer-card-max-width, 960px) - 4 * var(--dsh-composer-dock-inset, 4px));
524
+ max-width: calc(var(--dsh-composer-card-max-width, 952px) - 4 * var(--dsh-composer-dock-inset, 8px));
395
525
  margin: 0 auto;
396
526
  }
397
527
 
528
+ /* Menu-surface card: the composer context-stack geometry and elevation triple
529
+ (stroke + soft light) rather than an extra CSS border, which would double the
530
+ hairline and add layout width; the blur needs the surface on a background
531
+ layer, so it is painted by the pseudo-element behind the content. */
398
532
  .devlead-bar {
399
533
  position: relative;
534
+ isolation: isolate;
400
535
  box-sizing: border-box;
401
536
  display: flex;
402
537
  align-items: center;
@@ -405,9 +540,9 @@ window.__ModuleLoader__.load({
405
540
  min-height: 34px;
406
541
  margin: 0 auto;
407
542
  padding: 4px 6px 4px 12px;
408
- border: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, 0.24));
543
+ border: 0;
544
+ --dsw-elevation-stroke-color: var(--dsw-alias-border-l1, rgba(127, 127, 127, 0.24));
409
545
  border-radius: var(--dsw-radius-md, 10px);
410
- background: var(--dsw-specific-menu, Canvas);
411
546
  box-shadow: var(--dsw-elevation-panel, 0 1px 2px rgba(0, 0, 0, 0.08));
412
547
  color: var(--dsw-alias-label-primary, CanvasText);
413
548
  font-size: 13px;
@@ -415,6 +550,17 @@ window.__ModuleLoader__.load({
415
550
  font-family: inherit;
416
551
  }
417
552
 
553
+ .devlead-bar::before {
554
+ position: absolute;
555
+ z-index: -1;
556
+ inset: 0;
557
+ border-radius: inherit;
558
+ background: var(--dsw-specific-menu, Canvas);
559
+ backdrop-filter: var(--dsw-menu-backdrop-filter, none);
560
+ content: '';
561
+ pointer-events: none;
562
+ }
563
+
418
564
  .devlead-glyph {
419
565
  display: inline-flex;
420
566
  flex: none;
@@ -469,6 +615,18 @@ window.__ModuleLoader__.load({
469
615
  color: var(--dsw-alias-state-warn-primary, #a15c00);
470
616
  }
471
617
 
618
+ /* One stable live region wrapping the hint or the latest-notification chip so
619
+ assistive technology announces a new notification as a content change of an
620
+ existing region, not as a freshly inserted one. */
621
+ .devlead-notice {
622
+ display: inline-flex;
623
+ flex: 1 1 auto;
624
+ align-items: center;
625
+ min-width: 0;
626
+ overflow: hidden;
627
+ white-space: nowrap;
628
+ }
629
+
472
630
  .devlead-hint {
473
631
  flex: 1 1 auto;
474
632
  min-width: 0;
@@ -542,22 +700,83 @@ window.__ModuleLoader__.load({
542
700
  text-overflow: ellipsis;
543
701
  white-space: nowrap;
544
702
  }
703
+
704
+ /* Visually hidden but announced: the compact toolbar surface has no inline
705
+ error seat, so its failure text is mirrored into a live region through this
706
+ class (the shipped visually-hidden idiom used by the chat surfaces). */
707
+ .devlead-sr-only {
708
+ position: absolute;
709
+ width: 1px;
710
+ height: 1px;
711
+ overflow: hidden;
712
+ clip: rect(0 0 0 0);
713
+ white-space: nowrap;
714
+ }
715
+
716
+ /* Sidebar Session-row mark: a non-interactive glyph after the row's time
717
+ label. The seat is inline inside the row's 20px line box, so the icon can
718
+ never change the row height or the title's ellipsis width. */
719
+ .devlead-row-mark {
720
+ display: inline-flex;
721
+ flex: none;
722
+ align-items: center;
723
+ color: var(--dsw-alias-label-secondary, GrayText);
724
+ }
725
+
726
+ /* Hover-card line explaining the mark; mirrors the shell's hover status rows
727
+ (12px text on a 20px line) so the card keeps one rhythm. */
728
+ .devlead-row-hover {
729
+ display: flex;
730
+ align-items: center;
731
+ gap: 8px;
732
+ font-size: 12px;
733
+ line-height: 20px;
734
+ color: var(--dsw-alias-label-secondary, GrayText);
735
+ }
736
+
737
+ .devlead-row-hover-glyph {
738
+ display: inline-flex;
739
+ flex: none;
740
+ align-items: center;
741
+ }
545
742
  `;
743
+ var STYLE_TAG_STATE = /* @__PURE__ */ Symbol.for("@yankeguo/dsh-client-ui-devlead.style-tag");
744
+ function styleTagState() {
745
+ const store = globalThis;
746
+ const existing = store[STYLE_TAG_STATE];
747
+ if (existing !== void 0) return existing;
748
+ const created = { refs: 0, element: void 0 };
749
+ store[STYLE_TAG_STATE] = created;
750
+ return created;
751
+ }
752
+ function resolveStyleTag(state) {
753
+ const known = state.element;
754
+ if (known !== void 0 && known.isConnected) return known;
755
+ const adopted = document.head.querySelector(
756
+ `style[${STYLE_ATTRIBUTE}="${STYLE_KEY}"]`
757
+ );
758
+ if (adopted !== null) return adopted;
759
+ const created = document.createElement("style");
760
+ created.setAttribute(STYLE_ATTRIBUTE, STYLE_KEY);
761
+ document.head.appendChild(created);
762
+ return created;
763
+ }
546
764
  function ensureStyleTag() {
547
765
  if (typeof document === "undefined") return () => {
548
766
  };
549
- const existing = document.head.querySelector(`style[${STYLE_ATTRIBUTE}="${STYLE_KEY}"]`);
550
- if (existing !== null) {
551
- if (existing.textContent !== styles) existing.textContent = styles;
552
- return () => {
553
- };
554
- }
555
- const element = document.createElement("style");
556
- element.setAttribute(STYLE_ATTRIBUTE, STYLE_KEY);
557
- element.textContent = styles;
558
- document.head.appendChild(element);
767
+ const state = styleTagState();
768
+ const element = resolveStyleTag(state);
769
+ state.element = element;
770
+ state.refs += 1;
771
+ if (element.textContent !== styles) element.textContent = styles;
772
+ let released = false;
559
773
  return () => {
774
+ if (released) return;
775
+ released = true;
776
+ state.refs = Math.max(0, state.refs - 1);
777
+ if (state.refs > 0) return;
560
778
  element.remove();
779
+ if (state.element === element) state.element = void 0;
561
780
  };
562
781
  }
563
782
 
@@ -573,6 +792,8 @@ window.__ModuleLoader__.load({
573
792
  ctx.slots.inject("conversation.input.left", () => ctx.slots.register({
574
793
  name: "conversation.input.left",
575
794
  id: "devlead",
795
+ // No shipped entry occupies this list; the order only sequences additive
796
+ // contributions, so the compact switch stays ahead of any later entry.
576
797
  order: 12,
577
798
  locale: NS,
578
799
  inject: face
@@ -580,10 +801,26 @@ window.__ModuleLoader__.load({
580
801
  ctx.slots.inject("conversation.input.dock", () => ctx.slots.register({
581
802
  name: "conversation.input.dock",
582
803
  id: "devlead",
804
+ // The shipped context stack orders Todo (0), Goal (10), and Queue (20):
805
+ // the DevLead strip sits directly below the goal card.
583
806
  order: 12,
584
807
  locale: NS,
585
808
  inject: face
586
809
  }, DevLeadBar));
810
+ ctx.slots.inject("sidebar.session.row.trailing", () => ctx.slots.register({
811
+ name: "sidebar.session.row.trailing",
812
+ id: "devlead",
813
+ // After the shipped/experimental trailing marks; no shipped entry occupies
814
+ // this id, so the order only sequences additive contributions.
815
+ order: 20,
816
+ locale: NS
817
+ }, DevLeadSessionMark));
818
+ ctx.slots.inject("sidebar.session.row.hover", () => ctx.slots.register({
819
+ name: "sidebar.session.row.hover",
820
+ id: "devlead",
821
+ order: 20,
822
+ locale: NS
823
+ }, DevLeadSessionHoverMark));
587
824
  }
588
825
 
589
826
  return module.exports;
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "DevLead mode",
4
- "description": "Toggles DevLead mode from the composer toolbar; once enabled, a status strip above the composer shows watched sessions and the latest notification."
4
+ "description": "Toggles DevLead mode from the composer toolbar; once enabled, a status strip appears above the composer and the Session is marked in the sidebar list."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "DevLead 模式",
4
- "description": "在输入框工具条中开关 DevLead 模式;开启后在输入框上方显示状态条、监督会话状态与最近一条通知。"
4
+ "description": "在输入框工具条中开关 DevLead 模式;开启后在输入框上方显示状态条,并在侧边栏会话行标记该会话。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yankeguo/dsh-client-ui-devlead",
3
- "version": "0.1.0",
4
- "description": "DevLead surfaces: a compact composer-toolbar switch while off, and the full status strip above the composer while the mode is on.",
3
+ "version": "0.2.0",
4
+ "description": "DevLead surfaces: a compact composer-toolbar switch while off, the full status strip above the composer while the mode is on, and a DevLead mark on the Session's sidebar row.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "lib/index.js",
@@ -13,7 +13,8 @@
13
13
  },
14
14
  "files": [
15
15
  "lib",
16
- "locale/*.json"
16
+ "locale/*.json",
17
+ "README.md"
17
18
  ],
18
19
  "dsh": {
19
20
  "client": {
@@ -24,7 +25,8 @@
24
25
  "@deepseek-ai/dsh-client-ui-conversation",
25
26
  "@deepseek-ai/dsh-client-ui-primitives",
26
27
  "@deepseek-ai/dsh-client-ui-renderer",
27
- "@deepseek-ai/dsh-client-ui-session"
28
+ "@deepseek-ai/dsh-client-ui-session",
29
+ "@deepseek-ai/dsh-client-ui-workspace"
28
30
  ],
29
31
  "platform": "web"
30
32
  }
@@ -33,7 +35,7 @@
33
35
  "@deepseek-ai/cordis": "~4.1.0"
34
36
  },
35
37
  "dependencies": {
36
- "@yankeguo/dsh-devlead-protocol": "0.1.0"
38
+ "@yankeguo/dsh-devlead-protocol": "0.2.0"
37
39
  },
38
40
  "engines": {
39
41
  "dsh": ">=0.2.2-rc.1 <0.3.0"