@yankeguo/dsh-client-ui-devlead 0.2.6 → 0.3.0-rc.1

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 (2) hide show
  1. package/lib/client.js +78 -37
  2. package/package.json +2 -2
package/lib/client.js CHANGED
@@ -39,7 +39,13 @@ window.__ModuleLoader__.load({
39
39
  var DEVLEAD_WATCH_PROJECTION_KEY = "devLeadWatch";
40
40
  var DEVLEAD_COMMAND_NAME = "devlead";
41
41
  var DEVLEAD_ERROR_EXCERPT_MAX = 240;
42
- var DEVLEAD_REPORT_KINDS = ["progress", "blocked", "decision", "fyi"];
42
+ var DEVLEAD_REPORT_KINDS = [
43
+ "progress",
44
+ "blocked",
45
+ "decision",
46
+ "question",
47
+ "fyi"
48
+ ];
43
49
 
44
50
  // packages/protocol/src/format.ts
45
51
  var DEVLEAD_TRANSITIONS = [
@@ -77,12 +83,15 @@ window.__ModuleLoader__.load({
77
83
  return TRANSITION_LABELS[transition];
78
84
  }
79
85
  function presentLine(value) {
80
- if (value === void 0) return void 0;
86
+ if (typeof value !== "string") return void 0;
81
87
  return excerptLine(value, DEVLEAD_ERROR_EXCERPT_MAX);
82
88
  }
89
+ function sessionRefLabel(sessionId, title) {
90
+ const line = presentLine(title);
91
+ return line === void 0 ? sessionId : `${line} (${sessionId})`;
92
+ }
83
93
  function notificationLine(notification) {
84
- const title = presentLine(notification.sessionTitle);
85
- const who = title === void 0 ? notification.sessionId : `${title} (${notification.sessionId})`;
94
+ const who = sessionRefLabel(notification.sessionId, notification.sessionTitle);
86
95
  const error = presentLine(notification.error);
87
96
  const detail = error ?? presentLine(notification.summary);
88
97
  const suffix = detail === void 0 ? "" : `: ${detail}`;
@@ -92,17 +101,18 @@ window.__ModuleLoader__.load({
92
101
  progress: "progress",
93
102
  blocked: "blocked",
94
103
  decision: "decision needed",
104
+ question: "question",
95
105
  fyi: "fyi"
96
106
  };
97
107
  function isDevLeadReportKind(value) {
98
108
  return typeof value === "string" && DEVLEAD_REPORT_KINDS.includes(value);
99
109
  }
100
110
  function reportLine(report) {
101
- const title = presentLine(report.senderSessionTitle);
102
- const who = title === void 0 ? report.senderSessionId : `${title} (${report.senderSessionId})`;
103
- const detail = presentLine(report.summary) ?? excerptLine(report.message, DEVLEAD_ERROR_EXCERPT_MAX);
111
+ const who = sessionRefLabel(report.senderSessionId, report.senderSessionTitle);
112
+ const detail = presentLine(report.summary) ?? presentLine(report.message);
104
113
  const suffix = detail === void 0 ? "" : `: ${detail}`;
105
- return `${who} \u2014 report ${REPORT_KIND_LABELS[report.kind]}${suffix}`;
114
+ const kind = REPORT_KIND_LABELS[report.kind] ?? String(report.kind);
115
+ return `${who} \u2014 report ${kind}${suffix}`;
106
116
  }
107
117
 
108
118
  // packages/client-ui/src/client/format.ts
@@ -144,7 +154,7 @@ window.__ModuleLoader__.load({
144
154
  if (typeof candidate !== "string" || candidate.length === 0) continue;
145
155
  if (seen.has(candidate)) continue;
146
156
  seen.add(candidate);
147
- const row = rows[candidate];
157
+ const row = Object.hasOwn(rows, candidate) ? rows[candidate] : void 0;
148
158
  if (row === void 0) missing += 1;
149
159
  const status = statuses?.get(candidate);
150
160
  if (status?.running ?? row?.running ?? false) running += 1;
@@ -155,11 +165,15 @@ window.__ModuleLoader__.load({
155
165
  progress: "report.kind.progress",
156
166
  blocked: "report.kind.blocked",
157
167
  decision: "report.kind.decision",
168
+ question: "report.kind.question",
158
169
  fyi: "report.kind.fyi"
159
170
  };
160
171
  function reportLabelKey(kind) {
161
172
  return isDevLeadReportKind(kind) ? REPORT_LABEL_KEYS[kind] : "report.kind.unknown";
162
173
  }
174
+ function epochMillis(value) {
175
+ return typeof value === "number" && Number.isFinite(value) ? value : 0;
176
+ }
163
177
  function reportSummary(report) {
164
178
  const title = typeof report.senderSessionTitle === "string" ? excerptLine(report.senderSessionTitle, DEVLEAD_ERROR_EXCERPT_MAX) : void 0;
165
179
  const who = title ?? report.senderSessionId;
@@ -170,7 +184,7 @@ window.__ModuleLoader__.load({
170
184
  kind: String(report.kind),
171
185
  labelKey: reportLabelKey(report.kind),
172
186
  detail,
173
- at: typeof report.at === "number" ? report.at : 0
187
+ at: epochMillis(report.at)
174
188
  };
175
189
  }
176
190
  function latestReport(reports) {
@@ -193,7 +207,7 @@ window.__ModuleLoader__.load({
193
207
  const summary = summarizeWatched(projection.sessions, rows, statuses);
194
208
  const latest = latestNotification(projection.notifications);
195
209
  const latestRep = latestReport(projection.reports ?? []);
196
- const showReport = latestRep !== null && (latest === null || latestRep.at >= latest.at);
210
+ const showReport = latestRep !== null && (latest === null || epochMillis(latestRep.at) >= epochMillis(latest.at));
197
211
  const notice = !showReport && latest !== null ? notificationSummary(latest) : null;
198
212
  const reportNotice = showReport && latestRep !== null ? reportSummary(latestRep) : null;
199
213
  const tooltip = reportNotice?.tooltip ?? notice?.tooltip ?? t("hint.enabled");
@@ -246,7 +260,7 @@ window.__ModuleLoader__.load({
246
260
  ),
247
261
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-notification-who", children: reportNotice.who }),
248
262
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-notification-label", children: t(reportNotice.labelKey) }),
249
- reportNotice.detail !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-notification-error", children: reportNotice.detail })
263
+ reportNotice.detail !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "devlead-notification-detail", children: reportNotice.detail })
250
264
  ] }) : notice === null ? (
251
265
  // An enabled Session with no retained notification keeps the help
252
266
  // hint visible instead of leaving the row visually empty.
@@ -318,23 +332,20 @@ window.__ModuleLoader__.load({
318
332
  };
319
333
  var ALREADY_ACTIVE_PREFIX = "Another Session is already in DevLead mode: ";
320
334
  var ALREADY_ACTIVE_INSTRUCTION = ". Run /devlead off there first";
321
- var ALREADY_ACTIVE_ARCHIVED_INSTRUCTION = ". That Session is archived and could not be released automatically;";
322
335
  function alreadyActiveDetails(message) {
323
336
  if (!message.startsWith(ALREADY_ACTIVE_PREFIX)) return void 0;
324
337
  const rest = message.slice(ALREADY_ACTIVE_PREFIX.length);
325
- const archived = rest.includes(ALREADY_ACTIVE_ARCHIVED_INSTRUCTION);
326
- const marker = archived ? ALREADY_ACTIVE_ARCHIVED_INSTRUCTION : ALREADY_ACTIVE_INSTRUCTION;
327
- const end = rest.indexOf(marker);
338
+ const end = rest.indexOf(ALREADY_ACTIVE_INSTRUCTION);
328
339
  if (end <= 0) return void 0;
329
340
  const session = rest.slice(0, end).trim();
330
- return session.length === 0 ? void 0 : { session, archived };
341
+ return session.length === 0 ? void 0 : { session };
331
342
  }
332
343
  function failureMessage(failure, t) {
333
344
  if (failure.kind === "unresolved") return t("error.fallback.unresolved");
334
345
  if (failure.kind === "rejected" && failure.message !== void 0) {
335
346
  const active = alreadyActiveDetails(failure.message);
336
347
  if (active !== void 0) {
337
- return t(active.archived ? "error.alreadyActive.archived" : "error.alreadyActive", { session: active.session });
348
+ return t("error.alreadyActive", { session: active.session });
338
349
  }
339
350
  }
340
351
  return failure.message ?? t(FAILURE_FALLBACK_KEYS[failure.kind]);
@@ -376,16 +387,20 @@ window.__ModuleLoader__.load({
376
387
  aliveRef.current = false;
377
388
  };
378
389
  }, []);
390
+ const resetKeyRef = (0, import_react.useRef)(resetKey);
379
391
  (0, import_react.useEffect)(() => {
392
+ resetKeyRef.current = resetKey;
380
393
  dispatch({ type: "reset" });
381
394
  }, [resetKey]);
382
395
  const run = (line) => {
383
396
  if (!gate.tryEnter()) return;
397
+ const admittedKey = resetKeyRef.current;
384
398
  dispatch({ type: "begin" });
385
399
  void admitCommand(executeCommand, line).then((failure) => {
386
400
  gate.leave();
387
401
  if (!aliveRef.current) return;
388
- dispatch({ type: "settle", failure: failure ?? null });
402
+ const stale = resetKeyRef.current !== admittedKey;
403
+ dispatch({ type: "settle", failure: stale ? null : failure ?? null });
389
404
  });
390
405
  };
391
406
  return { pending: state.pending, failure: state.failure, run };
@@ -458,21 +473,35 @@ window.__ModuleLoader__.load({
458
473
  function devLeadRowEnabled(summary) {
459
474
  return summary?.projectionValues?.[DEVLEAD_MODE_PROJECTION_KEY]?.enabled === true;
460
475
  }
461
- function devLeadRowWatched(sessionId, byId) {
462
- const own = byId[sessionId];
463
- if (devLeadRowEnabled(own)) return false;
476
+ function devLeadRowSummaryOf(byId, sessionId) {
477
+ return Object.hasOwn(byId, sessionId) ? byId[sessionId] : void 0;
478
+ }
479
+ var watchedIdsCache = /* @__PURE__ */ new WeakMap();
480
+ function watchedIdsOf(byId) {
481
+ const cached = watchedIdsCache.get(byId);
482
+ if (cached !== void 0) return cached;
483
+ const watched = /* @__PURE__ */ new Set();
464
484
  for (const [leadId, lead] of Object.entries(byId)) {
465
- if (leadId === sessionId || !devLeadRowEnabled(lead)) continue;
485
+ if (!devLeadRowEnabled(lead)) continue;
466
486
  const sessions = lead?.projectionValues?.[DEVLEAD_WATCH_PROJECTION_KEY]?.sessions;
467
- if (Array.isArray(sessions) && sessions.includes(sessionId)) return true;
487
+ if (!Array.isArray(sessions)) continue;
488
+ for (const candidate of sessions) {
489
+ if (typeof candidate !== "string" || candidate.length === 0 || candidate === leadId) continue;
490
+ watched.add(candidate);
491
+ }
468
492
  }
469
- return false;
493
+ watchedIdsCache.set(byId, watched);
494
+ return watched;
495
+ }
496
+ function devLeadRowWatched(sessionId, byId) {
497
+ if (devLeadRowEnabled(devLeadRowSummaryOf(byId, sessionId))) return false;
498
+ return watchedIdsOf(byId).has(sessionId);
470
499
  }
471
500
 
472
501
  // packages/client-ui/src/client/DevLeadSessionHoverMark.tsx
473
502
  var import_jsx_runtime3 = require("react/jsx-runtime");
474
503
  function DevLeadSessionHoverMark({ sessionId, useSessions, t }) {
475
- const enabled = useSessions((state) => devLeadRowEnabled(state.byId[sessionId]));
504
+ const enabled = useSessions((state) => devLeadRowEnabled(devLeadRowSummaryOf(state.byId, sessionId)));
476
505
  const watched = useSessions((state) => devLeadRowWatched(sessionId, state.byId));
477
506
  if (enabled) {
478
507
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "devlead-row-hover", "data-devlead-row-hover": "true", children: [
@@ -491,7 +520,7 @@ window.__ModuleLoader__.load({
491
520
  var import_dsh_client_ui_primitives4 = require("@deepseek-ai/dsh-client-ui-primitives");
492
521
  var import_jsx_runtime4 = require("react/jsx-runtime");
493
522
  function DevLeadSessionMark({ sessionId, useSessions, t }) {
494
- const enabled = useSessions((state) => devLeadRowEnabled(state.byId[sessionId]));
523
+ const enabled = useSessions((state) => devLeadRowEnabled(devLeadRowSummaryOf(state.byId, sessionId)));
495
524
  const watched = useSessions((state) => devLeadRowWatched(sessionId, state.byId));
496
525
  if (enabled) {
497
526
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
@@ -523,14 +552,14 @@ window.__ModuleLoader__.load({
523
552
  "meta.description": "DevLead \u6A21\u5F0F\u7684 Web \u754C\u9762\uFF1A\u8F93\u5165\u6846\u5DE5\u5177\u6761\u7684 DevLead \u5F00\u5173\uFF08\u4E24\u6001\u5747\u53EF\u5207\u6362\uFF09\u3001\u6A21\u5F0F\u5F00\u542F\u540E\u663E\u793A\u7684\u72B6\u6001\u6761\uFF0C\u4EE5\u53CA\u4FA7\u8FB9\u680F\u4E2D\u6FC0\u6D3B DevLead \u884C\u4E0E\u5DF2\u5173\u6CE8\u4F1A\u8BDD\u7684\u6807\u8BB0\u3002",
524
553
  "bar.aria": "DevLead \u72B6\u6001\u680F",
525
554
  "label": "DevLead",
526
- "hint.enabled": "DevLead \u5DF2\u5F00\u542F\uFF1A\u5DF2\u5173\u6CE8\u4F1A\u8BDD\u7684\u8F6E\u6B21\u7ED3\u675F\u4F1A\u901A\u77E5\u5E76\u5524\u9192\u672C\u4F1A\u8BDD\u3002",
555
+ "hint.enabled": "DevLead \u5DF2\u5F00\u542F\uFF1A\u5DF2\u5173\u6CE8\u4F1A\u8BDD\u7684\u8F6E\u6B21\u7ED3\u675F\u4E0E\u4E2D\u9014\u6C47\u62A5\uFF08\u542B\u63D0\u95EE\uFF09\u4F1A\u901A\u77E5\u5E76\u5524\u9192\u672C\u4F1A\u8BDD\u3002",
527
556
  "count.watched": "\u5DF2\u5173\u6CE8 {count} \u4E2A\u4F1A\u8BDD",
528
557
  "count.running": "\u8FD0\u884C\u4E2D {count}",
529
558
  "count.missing": "{count} \u4E2A\u5DF2\u4E0D\u53EF\u7528",
530
559
  "row.mark.aria": "\u5F53\u524D\u6FC0\u6D3B\u7684 DevLead \u4F1A\u8BDD",
531
560
  "row.watched.aria": "\u88AB\u5F53\u524D DevLead \u5173\u6CE8",
532
561
  "row.hover.enabled": "\u5F53\u524D\u6FC0\u6D3B\u7684 DevLead \u4F1A\u8BDD\uFF1A\u53EF\u8C03\u5EA6\u5E76\u5173\u6CE8\u5176\u4ED6\u4F1A\u8BDD\u3002",
533
- "row.hover.watched": "\u88AB\u5F53\u524D DevLead \u5173\u6CE8\uFF1A\u5B83\u7684\u8F6E\u6B21\u7ED3\u675F\u4F1A\u901A\u77E5\u5E76\u5524\u9192 lead\u3002",
562
+ "row.hover.watched": "\u88AB\u5F53\u524D DevLead \u5173\u6CE8\uFF1A\u5B83\u7684\u8F6E\u6B21\u7ED3\u675F\u4E0E\u4E2D\u9014\u6C47\u62A5\uFF08\u542B\u63D0\u95EE\uFF09\u4F1A\u901A\u77E5\u5E76\u5524\u9192 lead\u3002",
534
563
  "toggle.label": "DevLead",
535
564
  "toggle.enable": "\u5F00\u542F DevLead \u6A21\u5F0F",
536
565
  "toggle.disable": "\u5173\u95ED DevLead \u6A21\u5F0F",
@@ -543,6 +572,7 @@ window.__ModuleLoader__.load({
543
572
  "report.kind.progress": "\u8FDB\u5EA6",
544
573
  "report.kind.blocked": "\u963B\u585E",
545
574
  "report.kind.decision": "\u5F85\u51B3\u7B56",
575
+ "report.kind.question": "\u63D0\u95EE",
546
576
  "report.kind.fyi": "\u544A\u77E5",
547
577
  "report.kind.unknown": "\u62A5\u544A",
548
578
  "transition.completed": "\u5B8C\u6210",
@@ -554,7 +584,6 @@ window.__ModuleLoader__.load({
554
584
  "transition.forked": "\u5DF2\u5206\u53C9",
555
585
  "transition.unknown": "\u672A\u77E5\u72B6\u6001",
556
586
  "error.alreadyActive": "\u53E6\u4E00\u4E2A\u4F1A\u8BDD\u5DF2\u5904\u4E8E DevLead \u6A21\u5F0F\uFF1A{session}\u3002\u8BF7\u5148\u5728\u90A3\u91CC\u6267\u884C /devlead off\uFF0C\u518D\u5F00\u542F\u672C\u4F1A\u8BDD\u3002",
557
- "error.alreadyActive.archived": "\u53E6\u4E00\u4E2A\u4F1A\u8BDD\u5DF2\u5904\u4E8E DevLead \u6A21\u5F0F\uFF1A{session}\u3002\u8BE5\u4F1A\u8BDD\u5DF2\u5F52\u6863\u4E14\u65E0\u6CD5\u81EA\u52A8\u91CA\u653E\uFF1B\u8BF7\u6253\u5F00\u5B83\uFF0C\u6267\u884C /devlead off \u540E\u91CD\u8BD5\u3002",
558
587
  "error.fallback.transport": "\u547D\u4EE4\u5931\u8D25",
559
588
  "error.fallback.rejected": "\u547D\u4EE4\u88AB\u62D2\u7EDD",
560
589
  "error.fallback.unknown": "\u672A\u77E5\u9519\u8BEF",
@@ -565,14 +594,14 @@ window.__ModuleLoader__.load({
565
594
  "meta.description": "Web UI for DevLead mode: the composer-toolbar toggle that switches the mode on or off, the status strip shown while the mode is on, and the active-DevLead and watched-session marks in the sidebar.",
566
595
  "bar.aria": "DevLead status bar",
567
596
  "label": "DevLead",
568
- "hint.enabled": "DevLead is on: watched-session turn changes notify and wake this session.",
597
+ "hint.enabled": "DevLead is on: watched-session turn ends and mid-turn reports (including questions) notify and wake this session.",
569
598
  "count.watched": "{count} watched",
570
599
  "count.running": "{count} running",
571
600
  "count.missing": "{count} unavailable",
572
601
  "row.mark.aria": "Active DevLead Session",
573
602
  "row.watched.aria": "Watched by the active DevLead",
574
603
  "row.hover.enabled": "Active DevLead Session: this session can dispatch and watch other Sessions.",
575
- "row.hover.watched": "Watched by the active DevLead: its turn changes notify and wake the lead.",
604
+ "row.hover.watched": "Watched by the active DevLead: its turn ends and mid-turn reports (including questions) notify and wake the lead.",
576
605
  "toggle.label": "DevLead",
577
606
  "toggle.enable": "Turn on DevLead mode",
578
607
  "toggle.disable": "Turn off DevLead mode",
@@ -585,6 +614,7 @@ window.__ModuleLoader__.load({
585
614
  "report.kind.progress": "progress",
586
615
  "report.kind.blocked": "blocked",
587
616
  "report.kind.decision": "decision",
617
+ "report.kind.question": "question",
588
618
  "report.kind.fyi": "fyi",
589
619
  "report.kind.unknown": "report",
590
620
  "transition.completed": "completed",
@@ -596,7 +626,6 @@ window.__ModuleLoader__.load({
596
626
  "transition.forked": "forked",
597
627
  "transition.unknown": "unknown state",
598
628
  "error.alreadyActive": "Another Session is already in DevLead mode: {session}. Run /devlead off there first, then enable this Session.",
599
- "error.alreadyActive.archived": "Another Session is already in DevLead mode: {session}. That Session is archived and could not be released automatically; open it, run /devlead off, then retry.",
600
629
  "error.fallback.transport": "command failed",
601
630
  "error.fallback.rejected": "command rejected",
602
631
  "error.fallback.unknown": "unknown error",
@@ -850,7 +879,8 @@ window.__ModuleLoader__.load({
850
879
  background: var(--dsw-alias-state-error-primary, #c0392b);
851
880
  }
852
881
 
853
- .devlead-notification-dot[data-report-kind="decision"] {
882
+ .devlead-notification-dot[data-report-kind="decision"],
883
+ .devlead-notification-dot[data-report-kind="question"] {
854
884
  background: var(--dsw-alias-state-warn-primary, #a15c00);
855
885
  }
856
886
 
@@ -867,15 +897,26 @@ window.__ModuleLoader__.load({
867
897
  flex: none;
868
898
  }
869
899
 
870
- .devlead-notification-error {
900
+ /* A turn failure excerpt keeps the error ink; a report's summary/message
901
+ detail is neutral copy \u2014 the kind dot and localized label carry the
902
+ semantics, so progress/fyi/question text must not read as a failure. */
903
+ .devlead-notification-error,
904
+ .devlead-notification-detail {
871
905
  flex: 0 1 auto;
872
906
  min-width: 0;
873
907
  overflow: hidden;
874
- color: var(--dsw-alias-label-error, #c0392b);
875
908
  font-size: 12px;
876
909
  text-overflow: ellipsis;
877
910
  }
878
911
 
912
+ .devlead-notification-error {
913
+ color: var(--dsw-alias-label-error, #c0392b);
914
+ }
915
+
916
+ .devlead-notification-detail {
917
+ color: var(--dsw-alias-label-secondary, GrayText);
918
+ }
919
+
879
920
  /* Visually hidden but announced: the compact toolbar surface has no inline
880
921
  error seat, so its failure text is mirrored into a live region through this
881
922
  class (the shipped visually-hidden idiom used by the chat surfaces). */
@@ -916,7 +957,7 @@ window.__ModuleLoader__.load({
916
957
  [data-row-key^="session:"]:has([data-devlead-active-mark="true"])::after {
917
958
  content: '';
918
959
  position: absolute;
919
- inset: 0 calc(-1 * var(--dsh-sidebar-paint-inset));
960
+ inset: 0 calc(-1 * var(--dsh-sidebar-paint-inset, 3px));
920
961
  border: 1px solid var(--dsw-alias-state-business-primary, #4176e6);
921
962
  border-radius: inherit;
922
963
  box-shadow: 0 0 0 2px var(--dsw-alias-state-business-tertiary, rgba(65, 118, 230, 0.12));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yankeguo/dsh-client-ui-devlead",
3
- "version": "0.2.6",
3
+ "version": "0.3.0-rc.1",
4
4
  "description": "DevLead surfaces: the composer-toolbar toggle that switches the mode on or off, the 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",
@@ -35,7 +35,7 @@
35
35
  "@deepseek-ai/cordis": "~4.1.0"
36
36
  },
37
37
  "dependencies": {
38
- "@yankeguo/dsh-devlead-protocol": "0.2.6"
38
+ "@yankeguo/dsh-devlead-protocol": "0.3.0-rc.1"
39
39
  },
40
40
  "engines": {
41
41
  "dsh": ">=0.2.2-rc.1 <0.3.0"