dsh-better-ask-user 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  <p align="center">
13
13
  <a href="https://www.npmjs.com/package/dsh-better-ask-user"><img src="https://img.shields.io/npm/v/dsh-better-ask-user.svg" alt="npm 版本"></a>
14
14
  <a href="LICENSE"><img alt="Apache-2.0" src="https://img.shields.io/github/license/omdsh-dev/dsh-better-ask-user?color=blue"></a>
15
- <a href="package.json"><img alt="DSH 0.2.2-rc.1" src="https://img.shields.io/badge/DSH-0.2.2--rc.1-4B32C3"></a>
15
+ <a href="package.json"><img alt="DSH 0.2.2-rc.2" src="https://img.shields.io/badge/DSH-0.2.2--rc.2-4B32C3"></a>
16
16
  <a href="https://github.com/omdsh-dev/dsh-better-dsh"><img alt="Part of Better DSH" src="https://img.shields.io/badge/part%20of-dsh--better--dsh-2F80B7"></a>
17
17
  </p>
18
18
 
@@ -42,7 +42,7 @@
42
42
 
43
43
  ```sh
44
44
  # 只安装这个插件
45
- dsh plugin --profile <profile> add dsh-better-ask-user@0.3.1 dsh-better-ptc@0.2.0
45
+ dsh plugin --profile <profile> add dsh-better-ask-user@0.3.4 dsh-better-ptc@0.2.1
46
46
 
47
47
  # 或安装 Better DSH(会自动带上所有独立插件)
48
48
  dsh plugin --profile <profile> add dsh-better-dsh@0.10.0
@@ -57,7 +57,7 @@ dsh plugin --profile <profile> add dsh-better-dsh@0.10.0
57
57
  | 稳定行 id | `dsh-better-ask-user` |
58
58
  | 入口 / 工具 | `ask_user_question` · 问题卡片 / 等待时间线 · 提问设置页 |
59
59
  | 设置 | 等待时长、输入续期、普通 / Goal 超时行为 |
60
- | npm 包 | `dsh-better-ask-user@0.3.1` |
60
+ | npm 包 | `dsh-better-ask-user@0.3.4` |
61
61
  | 仓库 | https://github.com/omdsh-dev/dsh-better-ask-user |
62
62
 
63
63
  ## 设置
package/lib/client.js CHANGED
@@ -25,6 +25,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
25
25
  var index_exports = {};
26
26
  __export(index_exports, {
27
27
  PendingQuestion: () => PendingQuestion,
28
+ QuestionCards: () => QuestionCards,
28
29
  SettingsEntry: () => SettingsEntry,
29
30
  apply: () => apply,
30
31
  inject: () => inject
@@ -501,7 +502,7 @@ var import_react = require("react");
501
502
  var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
502
503
 
503
504
  // src/client/AskHistoryRow.module.css
504
- var css = "/* src/client/AskHistoryRow.module.css */\n.AskHistoryRow_frame {\n --cfg-line: var(--dsw-alias-border-l2);\n --cfg-ink: var(--dsw-alias-label-primary);\n --cfg-muted: var(--dsw-alias-label-secondary);\n --cfg-accent: var(--dsw-alias-state-business-primary, #3388bb);\n --cfg-accent-text: color-mix(in srgb, var(--cfg-accent) 70%, var(--cfg-ink));\n --cfg-hover: var(--dsw-alias-interactive-bg-hover);\n min-width: 0;\n}\n.AskHistoryRow_row {\n appearance: none;\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n min-height: 32px;\n min-width: 0;\n padding: 4px 8px;\n border: 0;\n border-radius: 8px;\n background: transparent;\n color: var(--cfg-muted);\n font: inherit;\n line-height: 20px;\n text-align: left;\n}\nbutton.AskHistoryRow_row {\n cursor: pointer;\n}\nbutton.AskHistoryRow_row:hover {\n background: var(--cfg-hover);\n color: var(--cfg-ink);\n}\nbutton.AskHistoryRow_row:active {\n background: color-mix(in srgb, var(--cfg-accent) 9%, transparent);\n}\nbutton.AskHistoryRow_row:focus-visible {\n outline: 2px solid var(--cfg-accent);\n outline-offset: -2px;\n}\n.AskHistoryRow_icon {\n display: inline-flex;\n flex: none;\n color: var(--dsw-alias-label-tertiary);\n}\n.AskHistoryRow_icon svg {\n width: 14px;\n height: 14px;\n}\n.AskHistoryRow_summary {\n min-width: 0;\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.AskHistoryRow_open {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n flex: none;\n color: var(--cfg-muted);\n font-size: 12px;\n}\n.AskHistoryRow_error {\n display: block;\n padding: 4px 8px 4px 30px;\n color: var(--dsw-alias-state-error-primary);\n font-size: 12px;\n line-height: 18px;\n overflow-wrap: anywhere;\n}\n@media (max-width: 640px) {\n .AskHistoryRow_row {\n min-height: 44px;\n align-items: flex-start;\n padding-block: 10px;\n }\n .AskHistoryRow_summary {\n white-space: normal;\n overflow-wrap: anywhere;\n }\n .AskHistoryRow_open {\n align-self: center;\n }\n}\n@media (pointer: coarse) {\n .AskHistoryRow_row {\n min-height: 44px;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n button.AskHistoryRow_row {\n transition: none;\n }\n}\n[data-ds-dark-theme] .AskHistoryRow_frame {\n --cfg-accent: var(--dsw-alias-state-business-primary, #4eb0e8);\n --cfg-accent-text: color-mix(in srgb, var(--cfg-accent) 70%, var(--cfg-ink));\n}\n";
505
+ var css = "/* src/client/AskHistoryRow.module.css */\n.AskHistoryRow_frame {\n --cfg-line: var(--dsw-alias-border-l2);\n --cfg-ink: var(--dsw-alias-label-primary);\n --cfg-muted: var(--dsw-alias-label-secondary);\n --cfg-accent: var(--dsw-alias-state-business-primary, #3388bb);\n --cfg-accent-text: color-mix(in srgb, var(--cfg-accent) 70%, var(--cfg-ink));\n --cfg-hover: var(--dsw-alias-interactive-bg-hover);\n min-width: 0;\n}\n.AskHistoryRow_row {\n appearance: none;\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n min-height: 32px;\n min-width: 0;\n padding: 4px 8px;\n border: 0;\n border-radius: 8px;\n background: transparent;\n color: var(--cfg-muted);\n font: inherit;\n line-height: 20px;\n text-align: left;\n}\nbutton.AskHistoryRow_row {\n cursor: pointer;\n}\nbutton.AskHistoryRow_row:hover {\n background: var(--cfg-hover);\n color: var(--cfg-ink);\n}\nbutton.AskHistoryRow_row:active {\n background: color-mix(in srgb, var(--cfg-accent) 9%, transparent);\n}\nbutton.AskHistoryRow_row:focus-visible {\n outline: 2px solid var(--cfg-accent);\n outline-offset: -2px;\n}\n.AskHistoryRow_icon {\n display: inline-flex;\n flex: none;\n color: var(--dsw-alias-label-tertiary);\n}\n.AskHistoryRow_icon svg {\n width: 14px;\n height: 14px;\n}\n.AskHistoryRow_summary {\n min-width: 0;\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.AskHistoryRow_open {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n flex: none;\n color: var(--cfg-muted);\n font-size: 12px;\n}\n.AskHistoryRow_state {\n flex: none;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n}\n.AskHistoryRow_error {\n display: block;\n padding: 4px 8px 4px 30px;\n color: var(--dsw-alias-state-error-primary);\n font-size: 12px;\n line-height: 18px;\n overflow-wrap: anywhere;\n}\n@media (max-width: 640px) {\n .AskHistoryRow_row {\n min-height: 44px;\n align-items: flex-start;\n padding-block: 10px;\n }\n .AskHistoryRow_summary {\n white-space: normal;\n overflow-wrap: anywhere;\n }\n .AskHistoryRow_open {\n align-self: center;\n }\n}\n@media (pointer: coarse) {\n .AskHistoryRow_row {\n min-height: 44px;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n button.AskHistoryRow_row {\n transition: none;\n }\n}\n[data-ds-dark-theme] .AskHistoryRow_frame {\n --cfg-accent: var(--dsw-alias-state-business-primary, #4eb0e8);\n --cfg-accent-text: color-mix(in srgb, var(--cfg-accent) 70%, var(--cfg-ink));\n}\n";
505
506
  var id = "dsh-better-ask-user/AskHistoryRow.module.css";
506
507
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(id) + "]") === null) {
507
508
  const tag = document.createElement("style");
@@ -516,6 +517,7 @@ var AskHistoryRow_default = {
516
517
  icon: "AskHistoryRow_icon",
517
518
  summary: "AskHistoryRow_summary",
518
519
  open: "AskHistoryRow_open",
520
+ state: "AskHistoryRow_state",
519
521
  error: "AskHistoryRow_error"
520
522
  };
521
523
  var css_modules_entry_default = AskHistoryRow_default;
@@ -577,36 +579,40 @@ function answerList(text) {
577
579
  }
578
580
  return answers;
579
581
  }
580
- function isPending(text) {
581
- if (text === void 0) return false;
582
- const parsed = parseJson(text);
583
- return isRecord(parsed) && parsed.pending === true;
584
- }
585
582
  function AskHistoryRow({
586
583
  callId,
587
584
  block,
588
585
  phase,
586
+ useProjection,
587
+ useQuestionPanelLive,
589
588
  revealPanel,
590
589
  reviewPanel,
591
590
  t
592
591
  }) {
593
592
  const [failedAction, setFailedAction] = (0, import_react.useState)(null);
594
- const argsRaw = "kind" in block ? block.call?.argsRaw ?? "" : block.argsRaw;
593
+ const argsRaw = "kind" in block ? block.call?.argsRaw ?? "" : "argsRaw" in block ? block.argsRaw : "";
595
594
  const output = "kind" in block ? resultText(block.content) : void 0;
596
595
  const questions = questionList(argsRaw);
597
- const answers = answerList(output);
598
- const record = questions !== void 0 && answers !== void 0 ? { questions, answers } : void 0;
596
+ const settled = useProjection("userQuestions", (view) => view?.settled.find((row) => row.callId === callId));
597
+ const answers = settled?.answers ?? answerList(output) ?? [];
598
+ const record = questions !== void 0 && phase === "result" ? { questions, answers } : void 0;
599
+ const live = useQuestionPanelLive(callId, (present) => present === true);
600
+ const errorCode = "kind" in block ? block.error?.code : void 0;
601
+ const status = live ? void 0 : errorCode === "ASK_ABORTED" || errorCode === "interrupted" ? t("history.interrupted") : errorCode === "ASK_CANCELLED" ? t("history.cancelled") : void 0;
599
602
  const summary = questions?.[0]?.question.split("\n").find((line) => line.trim() !== "")?.trim() ?? t("history.title");
600
- const review = record !== void 0;
601
- const action = review ? () => reviewPanel(callId, record) : isPending(output) || phase === "start" ? () => revealPanel(callId) : void 0;
603
+ const action = live ? () => revealPanel(callId) : record === void 0 ? void 0 : () => reviewPanel(callId, record);
604
+ const review = !live && record !== void 0;
602
605
  const actionKey = `${callId}-${review ? "review" : "open"}`;
606
+ const actionLabel = review ? t("history.review") : t("history.reopen");
607
+ const trailing = action === void 0 ? status === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css_modules_entry_default.state, children: status }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: css_modules_entry_default.open, children: [
608
+ status !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css_modules_entry_default.state, children: status }),
609
+ actionLabel,
610
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { size: 14 })
611
+ ] });
603
612
  const content = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
604
613
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css_modules_entry_default.icon, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconQuestionOutlineRegular, {}) }),
605
614
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css_modules_entry_default.summary, title: summary, children: summary }),
606
- action !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: css_modules_entry_default.open, children: [
607
- review ? t("history.review") : t("history.reopen"),
608
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { size: 14 })
609
- ] })
615
+ trailing
610
616
  ] });
611
617
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css_modules_entry_default.frame, role: "group", "aria-label": t("history.title"), children: [
612
618
  action === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: css_modules_entry_default.row, "data-question-history": callId, children: content }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -619,7 +625,7 @@ function AskHistoryRow({
619
625
  onClick: () => {
620
626
  setFailedAction(action() ? null : actionKey);
621
627
  },
622
- "aria-label": `${review ? t("history.review") : t("history.reopen")} \xB7 ${summary}`,
628
+ "aria-label": `${actionLabel}${status === void 0 ? "" : ` \xB7 ${status}`} \xB7 ${summary}`,
623
629
  children: content
624
630
  }
625
631
  ),
@@ -1293,7 +1299,7 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }) {
1293
1299
  ] })
1294
1300
  ] }),
1295
1301
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(QuestionWaitBar, { card, t, busy: busy !== null, onTakeTime: takeTime }),
1296
- review !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: css_modules_entry_default4.reviewStatus, children: t("review.status") }),
1302
+ review !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: css_modules_entry_default4.reviewStatus, children: review.length === 0 ? t("review.unanswered") : t("review.status") }),
1297
1303
  !minimized && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1298
1304
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1299
1305
  "div",
@@ -1706,7 +1712,9 @@ var zh = {
1706
1712
  "history.title": "\u95EE\u9898",
1707
1713
  "history.review": "\u67E5\u770B",
1708
1714
  "history.reopen": "\u6253\u5F00",
1709
- "history.unavailable": "\u95EE\u9898\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\uFF0C\u8BF7\u91CD\u8BD5\u3002",
1715
+ "history.interrupted": "\u5DF2\u4E2D\u65AD",
1716
+ "history.cancelled": "\u5DF2\u53D6\u6D88",
1717
+ "history.unavailable": "\u8FD9\u4E2A\u95EE\u9898\u5DF2\u7ED3\u675F\uFF0C\u65E0\u6CD5\u6253\u5F00\u3002",
1710
1718
  "reply.copyFailed": "\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002",
1711
1719
  "wait.takeTime": "\u6162\u6162\u56DE\u7B54",
1712
1720
  "wait.countdown": "{seconds} \u79D2\u540E\u7EE7\u7EED\u5DE5\u4F5C",
@@ -1718,6 +1726,7 @@ var zh = {
1718
1726
  "wait.auto": "\u5230\u70B9\u5C06\u81EA\u52A8\u9009\u62E9\u9ED8\u8BA4\u9879",
1719
1727
  "wait.continued": "\u5DF2\u7EE7\u7EED\u5DE5\u4F5C\uFF0C\u4ECD\u53EF\u56DE\u7B54",
1720
1728
  "review.status": "\u5DF2\u56DE\u7B54",
1729
+ "review.unanswered": "\u672A\u6536\u5230\u56DE\u7B54",
1721
1730
  "review.skipped": "\u8FD9\u9053\u95EE\u9898\u5F53\u65F6\u88AB\u8DF3\u8FC7\u3002",
1722
1731
  "reply.label": "\u95EE\u9898\u56DE\u590D",
1723
1732
  "reply.open": "\u5C55\u5F00\u95EE\u9898\u8BE6\u60C5",
@@ -1748,7 +1757,9 @@ var en = {
1748
1757
  "history.title": "Question",
1749
1758
  "history.review": "Review",
1750
1759
  "history.reopen": "Open",
1751
- "history.unavailable": "Cannot open this question right now. Try again.",
1760
+ "history.interrupted": "Interrupted",
1761
+ "history.cancelled": "Cancelled",
1762
+ "history.unavailable": "This question has ended and cannot be reopened.",
1752
1763
  "reply.copyFailed": "Copy failed. Try again.",
1753
1764
  "wait.takeTime": "Take time",
1754
1765
  "wait.countdown": "Continuing in {seconds}s",
@@ -1760,6 +1771,7 @@ var en = {
1760
1771
  "wait.auto": "Auto-selects defaults at timeout",
1761
1772
  "wait.continued": "Work continued \u2014 you can still answer",
1762
1773
  "review.status": "Answered",
1774
+ "review.unanswered": "No answer recorded",
1763
1775
  "review.skipped": "This question was skipped.",
1764
1776
  "reply.label": "Question reply",
1765
1777
  "reply.open": "Open question details",
@@ -2235,6 +2247,8 @@ var QuestionCards = class {
2235
2247
  this.publish = publish;
2236
2248
  }
2237
2249
  #cards = /* @__PURE__ */ new Map();
2250
+ #presenceSources = /* @__PURE__ */ new Map();
2251
+ #presenceListeners = /* @__PURE__ */ new Set();
2238
2252
  byCallId(sessionId, callId) {
2239
2253
  return this.#cards.get(PendingQuestion.keyOf(sessionId, callId));
2240
2254
  }
@@ -2242,6 +2256,34 @@ var QuestionCards = class {
2242
2256
  source(key) {
2243
2257
  return this.#cards.get(key)?.pending;
2244
2258
  }
2259
+ /**
2260
+ * Observable existence of one tool call's card. The transcript row offers
2261
+ * reopening only while the registry still holds that card; a removed card
2262
+ * flips the snapshot so the stale affordance disappears with it.
2263
+ * @param sessionId - owning Session.
2264
+ * @param callId - tool call identity as the transcript row spells it.
2265
+ * @returns a stable source that notifies when the card is added or removed.
2266
+ */
2267
+ presence(sessionId, callId) {
2268
+ const key = PendingQuestion.keyOf(sessionId, callId);
2269
+ let source = this.#presenceSources.get(key);
2270
+ if (source === void 0) {
2271
+ source = {
2272
+ getSnapshot: () => this.#cards.has(key),
2273
+ subscribe: (listener) => {
2274
+ this.#presenceListeners.add(listener);
2275
+ return () => {
2276
+ this.#presenceListeners.delete(listener);
2277
+ };
2278
+ }
2279
+ };
2280
+ this.#presenceSources.set(key, source);
2281
+ }
2282
+ return source;
2283
+ }
2284
+ #publishPresence() {
2285
+ for (const listener of [...this.#presenceListeners]) listener();
2286
+ }
2245
2287
  values() {
2246
2288
  return [...this.#cards.values()];
2247
2289
  }
@@ -2284,6 +2326,7 @@ var QuestionCards = class {
2284
2326
  remove: () => {
2285
2327
  if (this.#cards.get(pending.key) !== card) return;
2286
2328
  this.#cards.delete(pending.key);
2329
+ this.#publishPresence();
2287
2330
  pending.close();
2288
2331
  unpublish?.();
2289
2332
  unpublish = void 0;
@@ -2298,6 +2341,7 @@ var QuestionCards = class {
2298
2341
  };
2299
2342
  pending.attachSeat({ hide: pending.review === void 0 ? card.hide : card.remove });
2300
2343
  this.#cards.set(pending.key, card);
2344
+ this.#publishPresence();
2301
2345
  return card;
2302
2346
  }
2303
2347
  /**
@@ -2529,7 +2573,10 @@ function apply(ctx) {
2529
2573
  priority: -1,
2530
2574
  inject: (sessionId) => ({
2531
2575
  revealPanel: (callId) => ctx.get("userQuestionPanels")?.reveal(sessionId, callId) ?? false,
2532
- reviewPanel: (callId, record) => ctx.get("userQuestionPanels")?.review(sessionId, callId, record) ?? false
2576
+ reviewPanel: (callId, record) => ctx.get("userQuestionPanels")?.review(sessionId, callId, record) ?? false,
2577
+ keyedHooks: {
2578
+ questionPanelLive: (callId) => cards.presence(sessionId, callId)
2579
+ }
2533
2580
  })
2534
2581
  }, AskHistoryRow));
2535
2582
  ctx.slots.inject("conversation.composer", () => ctx.slots.register(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-better-ask-user",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Independent ask_user_question plugin: configurable wait, input-extended countdown, markdown/mobile card, native or default timeout behavior, and PTC deadline exemption.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "engines": {
18
18
  "node": ">=24.9.0",
19
- "dsh": "0.2.2-rc.1"
19
+ "dsh": "0.2.2-rc.2"
20
20
  },
21
21
  "scripts": {
22
22
  "pretest": "node scripts/build-client.mjs",
@@ -25,16 +25,16 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@deepseek-ai/schemastery": "~3.19.0",
28
- "dsh-better-ptc": "0.2.0"
28
+ "dsh-better-ptc": "0.2.1"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@deepseek-ai/cordis": "~4.1.0",
32
- "@deepseek-ai/dsh-agent": "0.2.2-rc.1",
33
- "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
34
- "@deepseek-ai/dsh-session": "0.2.2-rc.1",
35
- "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.1",
36
- "@deepseek-ai/dsh-tools": "0.2.2-rc.1",
37
- "@deepseek-ai/dsh-user-questions": "0.2.2-rc.1",
32
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.2",
33
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.2",
34
+ "@deepseek-ai/dsh-session": "0.2.2-rc.2",
35
+ "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.2",
36
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.2",
37
+ "@deepseek-ai/dsh-user-questions": "0.2.2-rc.2",
38
38
  "react": "^18.2.0"
39
39
  },
40
40
  "devDependencies": {
@@ -16,6 +16,7 @@ button.row:focus-visible { outline: 2px solid var(--cfg-accent); outline-offset:
16
16
  .icon svg { width: 14px; height: 14px; }
17
17
  .summary { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
18
18
  .open { display: inline-flex; align-items: center; gap: 4px; flex: none; color: var(--cfg-muted); font-size: 12px; }
19
+ .state { flex: none; color: var(--dsw-alias-label-tertiary); font-size: 12px; }
19
20
  .error { display: block; padding: 4px 8px 4px 30px; color: var(--dsw-alias-state-error-primary); font-size: 12px; line-height: 18px; overflow-wrap: anywhere; }
20
21
  @media (max-width: 640px) { .row { min-height: 44px; align-items: flex-start; padding-block: 10px; } .summary { white-space: normal; overflow-wrap: anywhere; } .open { align-self: center; } }
21
22
  @media (pointer: coarse) { .row { min-height: 44px; } }
@@ -1,15 +1,16 @@
1
- /** History row for ask_user_question: compact summary plus a replay button. */
1
+ /** History row for ask_user_question: compact summary plus a live or review action. */
2
2
  import { useState } from 'react'
3
3
  import { IconChevronRightOutlineRegular, IconQuestionOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
4
- import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
4
+ import type { HostObservable, InjectFace, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
5
5
  import type { ToolCallViewProps, UserQuestionRecord } from '@deepseek-ai/dsh-client-ui-tool/client'
6
6
  import type { AskUserQuestionItem } from '@deepseek-ai/dsh-user-questions/types'
7
7
  import css from './AskHistoryRow.module.css'
8
8
 
9
- type AskHistoryRowProps = ToolCallViewProps & PropsLocale<'question'> & {
9
+ type AskHistoryRowProps = ToolCallViewProps & PropsLocale<'question'> & InjectFace<{
10
10
  revealPanel: (callId: string) => boolean
11
11
  reviewPanel: (callId: string, record: UserQuestionRecord) => boolean
12
- }
12
+ keyedHooks: { questionPanelLive: (callId: string) => HostObservable<boolean> }
13
+ }>
13
14
 
14
15
  interface AnswerEntry {
15
16
  id: string
@@ -85,44 +86,71 @@ function answerList(text: string | undefined): AnswerEntry[] | undefined {
85
86
  return answers
86
87
  }
87
88
 
88
- function isPending(text: string | undefined): boolean {
89
- if (text === undefined) return false
90
- const parsed = parseJson(text)
91
- return isRecord(parsed) && parsed.pending === true
92
- }
93
-
94
- /** The compact history re-entry for one ask call, top-level or nested. */
89
+ /**
90
+ * The compact history re-entry for one ask call, top-level or nested.
91
+ *
92
+ * The action follows what is actually reachable, not a guess from the result
93
+ * shape: a card still in the plugin registry opens the live panel, and a
94
+ * settled call opens a read-only review built from its recorded answers. A
95
+ * finished question therefore stays inspectable even when it recorded no
96
+ * answers, and never offers a reopen that cannot succeed.
97
+ */
95
98
  export function AskHistoryRow({
96
99
  callId,
97
100
  block,
98
101
  phase,
102
+ useProjection,
103
+ useQuestionPanelLive,
99
104
  revealPanel,
100
105
  reviewPanel,
101
106
  t,
102
107
  }: AskHistoryRowProps): React.JSX.Element {
103
108
  const [failedAction, setFailedAction] = useState<string | null>(null)
104
- const argsRaw = 'kind' in block ? block.call?.argsRaw ?? '' : block.argsRaw
109
+ const argsRaw = 'kind' in block ? block.call?.argsRaw ?? '' : 'argsRaw' in block ? block.argsRaw : ''
105
110
  const output = 'kind' in block ? resultText(block.content) : undefined
106
111
  const questions = questionList(argsRaw)
107
- const answers = answerList(output)
108
- const record: UserQuestionRecord | undefined = questions !== undefined && answers !== undefined
112
+ // A late reply settles through the projection, not through a second tool result.
113
+ const settled = useProjection('userQuestions', view => view?.settled.find(row => row.callId === callId))
114
+ const answers = settled?.answers ?? answerList(output) ?? []
115
+ // Every settled call with readable questions can be reviewed; an empty answer
116
+ // batch still shows the question and its "no answer recorded" state.
117
+ const record: UserQuestionRecord | undefined = questions !== undefined && phase === 'result'
109
118
  ? { questions, answers }
110
119
  : undefined
120
+ const live = useQuestionPanelLive(callId, present => present === true)
121
+ const errorCode = 'kind' in block ? block.error?.code : undefined
122
+ // A live card is the truth; a terminal label belongs only to the settled view.
123
+ const status = live
124
+ ? undefined
125
+ : errorCode === 'ASK_ABORTED' || errorCode === 'interrupted'
126
+ ? t('history.interrupted')
127
+ : errorCode === 'ASK_CANCELLED'
128
+ ? t('history.cancelled')
129
+ : undefined
111
130
  const summary = questions?.[0]?.question.split('\n').find(line => line.trim() !== '')?.trim() ?? t('history.title')
112
- const review = record !== undefined
113
- const action = review
114
- ? () => reviewPanel(callId, record)
115
- : isPending(output) || phase === 'start'
116
- ? () => revealPanel(callId)
117
- : undefined
118
-
131
+ const action = live
132
+ ? () => revealPanel(callId)
133
+ : record === undefined
134
+ ? undefined
135
+ : () => reviewPanel(callId, record)
136
+ const review = !live && record !== undefined
119
137
  const actionKey = `${callId}-${review ? 'review' : 'open'}`
138
+ const actionLabel = review ? t('history.review') : t('history.reopen')
139
+
140
+ const trailing = action === undefined
141
+ ? status === undefined ? null : <span className={css.state}>{status}</span>
142
+ : (
143
+ <span className={css.open}>
144
+ {status !== undefined && <span className={css.state}>{status}</span>}
145
+ {actionLabel}<IconChevronRightOutlineRegular size={14} />
146
+ </span>
147
+ )
120
148
 
121
149
  const content = (
122
150
  <>
123
151
  <span className={css.icon} aria-hidden="true"><IconQuestionOutlineRegular /></span>
124
152
  <span className={css.summary} title={summary}>{summary}</span>
125
- {action !== undefined && <span className={css.open}>{review ? t('history.review') : t('history.reopen')}<IconChevronRightOutlineRegular size={14} /></span>}
153
+ {trailing}
126
154
  </>
127
155
  )
128
156
  return (
@@ -132,7 +160,7 @@ export function AskHistoryRow({
132
160
  : <button
133
161
  type="button" className={css.row} data-question-history={callId} data-history-action={review ? 'review' : 'open'}
134
162
  onClick={() => { setFailedAction(action() ? null : actionKey) }}
135
- aria-label={`${review ? t('history.review') : t('history.reopen')} · ${summary}`}
163
+ aria-label={`${actionLabel}${status === undefined ? '' : ` · ${status}`} · ${summary}`}
136
164
  >{content}</button>}
137
165
  {failedAction === actionKey && <span className={css.error} role="alert">{t('history.unavailable')}</span>}
138
166
  </div>
@@ -494,7 +494,7 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
494
494
  </div>
495
495
  </header>
496
496
  <QuestionWaitBar card={card} t={t} busy={busy !== null} onTakeTime={takeTime} />
497
- {review !== undefined && <div className={css.reviewStatus}>{t('review.status')}</div>}
497
+ {review !== undefined && <div className={css.reviewStatus}>{review.length === 0 ? t('review.unanswered') : t('review.status')}</div>}
498
498
 
499
499
  {!minimized && (
500
500
  <>
@@ -18,6 +18,7 @@ import type {} from '@deepseek-ai/dsh-client-ui-chat/client'
18
18
  import type { ComposerChainProps } from '@deepseek-ai/dsh-client-ui-conversation/client'
19
19
  import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
20
20
  import type { PendingInteractionPublisher } from '@deepseek-ai/dsh-client-ui-session/client'
21
+ import type { HostObservable } from '@deepseek-ai/dsh-client-ui-slots'
21
22
  import type { TypertClientEventListener } from '@deepseek-ai/dsh-typert-protocol'
22
23
  import type { AskUserQuestionItem, PendingUserQuestion, UserQuestionProjectionView } from '@deepseek-ai/dsh-user-questions/types'
23
24
  // Type-only: pulls the locale plugin's Context merge (ctx.locale).
@@ -84,6 +85,8 @@ interface QuestionCard {
84
85
  */
85
86
  class QuestionCards {
86
87
  readonly #cards = new Map<string, QuestionCard>()
88
+ readonly #presenceSources = new Map<string, HostObservable<boolean>>()
89
+ readonly #presenceListeners = new Set<() => void>()
87
90
 
88
91
  constructor(private readonly publish: PendingInteractionPublisher<PendingQuestion>) {}
89
92
 
@@ -96,6 +99,34 @@ class QuestionCards {
96
99
  return this.#cards.get(key)?.pending
97
100
  }
98
101
 
102
+ /**
103
+ * Observable existence of one tool call's card. The transcript row offers
104
+ * reopening only while the registry still holds that card; a removed card
105
+ * flips the snapshot so the stale affordance disappears with it.
106
+ * @param sessionId - owning Session.
107
+ * @param callId - tool call identity as the transcript row spells it.
108
+ * @returns a stable source that notifies when the card is added or removed.
109
+ */
110
+ presence(sessionId: SessionId, callId: string): HostObservable<boolean> {
111
+ const key = PendingQuestion.keyOf(sessionId, callId)
112
+ let source = this.#presenceSources.get(key)
113
+ if (source === undefined) {
114
+ source = {
115
+ getSnapshot: () => this.#cards.has(key),
116
+ subscribe: (listener) => {
117
+ this.#presenceListeners.add(listener)
118
+ return () => { this.#presenceListeners.delete(listener) }
119
+ },
120
+ }
121
+ this.#presenceSources.set(key, source)
122
+ }
123
+ return source
124
+ }
125
+
126
+ #publishPresence(): void {
127
+ for (const listener of [...this.#presenceListeners]) listener()
128
+ }
129
+
99
130
  values(): readonly QuestionCard[] {
100
131
  return [...this.#cards.values()]
101
132
  }
@@ -149,6 +180,7 @@ class QuestionCards {
149
180
  /* v8 ignore next -- a card leaves the registry once; no caller holds a card the registry already replaced. */
150
181
  if (this.#cards.get(pending.key) !== card) return
151
182
  this.#cards.delete(pending.key)
183
+ this.#publishPresence()
152
184
  pending.close()
153
185
  unpublish?.()
154
186
  unpublish = undefined
@@ -163,6 +195,7 @@ class QuestionCards {
163
195
  // the tool call row builds another one from the same transcript record.
164
196
  pending.attachSeat({ hide: pending.review === undefined ? card.hide : card.remove })
165
197
  this.#cards.set(pending.key, card)
198
+ this.#publishPresence()
166
199
  return card
167
200
  }
168
201
 
@@ -428,6 +461,9 @@ export function apply(ctx: ClientContext): void {
428
461
  inject: (sessionId: SessionId) => ({
429
462
  revealPanel: (callId: string) => ctx.get('userQuestionPanels')?.reveal(sessionId, callId) ?? false,
430
463
  reviewPanel: (callId: string, record: UserQuestionRecord) => ctx.get('userQuestionPanels')?.review(sessionId, callId, record) ?? false,
464
+ keyedHooks: {
465
+ questionPanelLive: (callId: string) => cards.presence(sessionId, callId),
466
+ },
431
467
  }),
432
468
  }, AskHistoryRow))
433
469
  ctx.slots.inject('conversation.composer', () => ctx.slots.register(
@@ -454,4 +490,4 @@ export function apply(ctx: ClientContext): void {
454
490
  }
455
491
 
456
492
  // Exported for the built-closure behavior tests; the client loader ignores it.
457
- export { PendingQuestion, SettingsEntry }
493
+ export { PendingQuestion, QuestionCards, SettingsEntry }
@@ -10,7 +10,9 @@ export const zh = {
10
10
  'history.title': '问题',
11
11
  'history.review': '查看',
12
12
  'history.reopen': '打开',
13
- 'history.unavailable': '问题暂时无法打开,请重试。',
13
+ 'history.interrupted': '已中断',
14
+ 'history.cancelled': '已取消',
15
+ 'history.unavailable': '这个问题已结束,无法打开。',
14
16
  'reply.copyFailed': '复制失败,请重试。',
15
17
  'wait.takeTime': '慢慢回答',
16
18
  'wait.countdown': '{seconds} 秒后继续工作',
@@ -22,6 +24,7 @@ export const zh = {
22
24
  'wait.auto': '到点将自动选择默认项',
23
25
  'wait.continued': '已继续工作,仍可回答',
24
26
  'review.status': '已回答',
27
+ 'review.unanswered': '未收到回答',
25
28
  'review.skipped': '这道问题当时被跳过。',
26
29
  'reply.label': '问题回复',
27
30
  'reply.open': '展开问题详情',
@@ -57,7 +60,9 @@ export const en = {
57
60
  'history.title': 'Question',
58
61
  'history.review': 'Review',
59
62
  'history.reopen': 'Open',
60
- 'history.unavailable': 'Cannot open this question right now. Try again.',
63
+ 'history.interrupted': 'Interrupted',
64
+ 'history.cancelled': 'Cancelled',
65
+ 'history.unavailable': 'This question has ended and cannot be reopened.',
61
66
  'reply.copyFailed': 'Copy failed. Try again.',
62
67
  'wait.takeTime': 'Take time',
63
68
  'wait.countdown': 'Continuing in {seconds}s',
@@ -69,6 +74,7 @@ export const en = {
69
74
  'wait.auto': 'Auto-selects defaults at timeout',
70
75
  'wait.continued': 'Work continued — you can still answer',
71
76
  'review.status': 'Answered',
77
+ 'review.unanswered': 'No answer recorded',
72
78
  'review.skipped': 'This question was skipped.',
73
79
  'reply.label': 'Question reply',
74
80
  'reply.open': 'Open question details',