@cnzgray/dsh-mattpocock-workflow 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/lib/client.js +102 -15
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -17,6 +17,7 @@
17
17
  “+ to-spec 需求”注入 `/to-spec` 和一个“需求描述:”槽位,不先入池:需求已经清楚时由技能直接建一张带规格、
18
18
  带 `ready-for-agent` 的需求票,之后按需拆票、实现;建票与打标签都在技能正文里,面板不代为执行。
19
19
  点击工单行打开详情;列表行与详情头部的技能徽标共用同一套判定,点击才填入对应技能的提示词;不可开工的票显示原因徽标,不提供注入入口。
20
+ 详情头部有手动刷新按钮:重读这张票并同步列表快照,失败时保留旧内容、在头部下方说明原因,不把详情切成错误页。
20
21
  工单提示词只有技能手势和工单引用(如 `/implement #40`),取票、实现、验证与复审都写在技能正文里,面板不复述。
21
22
  顶部三个按钮与工单技能徽标都是分裂动作:主键填进当前会话,右侧小箭头用同一段提示词直接开一个新会话
22
23
  (沿用当前工作区,草稿策略是追加,不自动发送)。环境检查的会话动作仍然只填当前会话。
package/lib/client.js CHANGED
@@ -515,6 +515,9 @@ var zh = {
515
515
  "detail.comments": "{count} \u6761\u8BC4\u8BBA",
516
516
  "detail.loading": "\u6B63\u5728\u8BFB\u53D6\u5DE5\u5355\u8BE6\u60C5\u2026",
517
517
  "detail.loadFailed": "\u8BFB\u53D6\u5DE5\u5355\u8BE6\u60C5\u5931\u8D25\u3002",
518
+ "detail.refresh": "\u5237\u65B0\u5DE5\u5355",
519
+ "detail.refreshing": "\u6B63\u5728\u5237\u65B0\u5DE5\u5355\u2026",
520
+ "detail.refreshFailed": "\u5237\u65B0\u5931\u8D25\uFF1A{detail}",
518
521
  "detail.bodyLabel": "\u6B63\u6587",
519
522
  "detail.noBody": "\u8FD9\u5F20\u5DE5\u5355\u6CA1\u6709\u6B63\u6587\u3002",
520
523
  "detail.attachment.loading": "\u6B63\u5728\u52A0\u8F7D\u56FE\u7247\uFF1A{name}",
@@ -976,6 +979,9 @@ var en = {
976
979
  "detail.comments": "{count} comments",
977
980
  "detail.loading": "Loading ticket details\u2026",
978
981
  "detail.loadFailed": "Failed to load ticket details.",
982
+ "detail.refresh": "Refresh ticket",
983
+ "detail.refreshing": "Refreshing ticket\u2026",
984
+ "detail.refreshFailed": "Refresh failed: {detail}",
979
985
  "detail.bodyLabel": "Body",
980
986
  "detail.noBody": "This ticket has no body.",
981
987
  "detail.attachment.loading": "Loading image: {name}",
@@ -6090,6 +6096,10 @@ var DETAIL_ERROR_STYLE = {
6090
6096
  color: COLORS.error,
6091
6097
  fontSize: 12
6092
6098
  };
6099
+ var DETAIL_REFRESH_ERROR_STYLE = {
6100
+ ...DETAIL_ERROR_STYLE,
6101
+ margin: "8px 12px 0"
6102
+ };
6093
6103
  var HEADER_TEXT_BUTTON_STYLE = {
6094
6104
  ...DETAIL_BACK_STYLE,
6095
6105
  padding: "3px 8px"
@@ -6736,6 +6746,7 @@ function HeaderActions(props) {
6736
6746
  const { detail, busy } = props;
6737
6747
  const next = detail.state === "open" ? "closed" : "open";
6738
6748
  const copied = props.copy.status === "copied";
6749
+ const refreshLabel = props.refreshing ? t2("detail.refreshing") : t2("detail.refresh");
6739
6750
  return /* @__PURE__ */ React23.createElement(React23.Fragment, null, detail.capabilities.state ? /* @__PURE__ */ React23.createElement(
6740
6751
  "button",
6741
6752
  {
@@ -6749,7 +6760,20 @@ function HeaderActions(props) {
6749
6760
  style: next === "closed" ? HEADER_CLOSE_STYLE : HEADER_TEXT_BUTTON_STYLE
6750
6761
  },
6751
6762
  t2(next === "closed" ? "detail.close" : "detail.reopen")
6752
- ) : null, detail.url === null ? null : /* @__PURE__ */ React23.createElement(
6763
+ ) : null, /* @__PURE__ */ React23.createElement(
6764
+ "button",
6765
+ {
6766
+ type: "button",
6767
+ "data-testid": "detail-refresh",
6768
+ "data-hover": "soft",
6769
+ disabled: props.refreshDisabled,
6770
+ "aria-label": refreshLabel,
6771
+ title: refreshLabel,
6772
+ onClick: props.onRefresh,
6773
+ style: { ...HEADER_ICON_BUTTON_STYLE, opacity: props.refreshDisabled ? 0.6 : 1 }
6774
+ },
6775
+ /* @__PURE__ */ React23.createElement(RefreshIcon, null)
6776
+ ), detail.url === null ? null : /* @__PURE__ */ React23.createElement(
6753
6777
  "button",
6754
6778
  {
6755
6779
  type: "button",
@@ -6971,11 +6995,19 @@ function useDetailRequest(client, workspaceRoot, ref, number) {
6971
6995
  const [error, setError] = React24.useState(null);
6972
6996
  const [phase, setPhase] = React24.useState("loading");
6973
6997
  const [attempt, setAttempt] = React24.useState(0);
6998
+ const [refreshing, setRefreshing] = React24.useState(false);
6999
+ const [refreshError, setRefreshError] = React24.useState(null);
7000
+ const readId = React24.useRef(0);
7001
+ const readRunning = React24.useRef(false);
6974
7002
  React24.useEffect(() => {
6975
7003
  let active = true;
7004
+ readId.current += 1;
7005
+ readRunning.current = false;
6976
7006
  setDetail(null);
6977
7007
  setError(null);
6978
7008
  setPhase("loading");
7009
+ setRefreshing(false);
7010
+ setRefreshError(null);
6979
7011
  void client.getDetail(workspaceRoot, ref, number).then((result) => {
6980
7012
  if (!active) return;
6981
7013
  if (result.ok) {
@@ -6988,8 +7020,27 @@ function useDetailRequest(client, workspaceRoot, ref, number) {
6988
7020
  });
6989
7021
  return () => {
6990
7022
  active = false;
7023
+ readId.current += 1;
6991
7024
  };
6992
7025
  }, [client, workspaceRoot, ref, number, attempt]);
7026
+ const refresh = () => {
7027
+ if (readRunning.current) return;
7028
+ readRunning.current = true;
7029
+ const current = readId.current + 1;
7030
+ readId.current = current;
7031
+ setRefreshing(true);
7032
+ void client.getDetail(workspaceRoot, ref, number).then((result) => {
7033
+ if (readId.current !== current) return;
7034
+ readRunning.current = false;
7035
+ setRefreshing(false);
7036
+ if (result.ok) {
7037
+ setDetail(result.result);
7038
+ setRefreshError(null);
7039
+ return;
7040
+ }
7041
+ setRefreshError(result.error);
7042
+ });
7043
+ };
6993
7044
  return {
6994
7045
  detail,
6995
7046
  error,
@@ -6997,7 +7048,10 @@ function useDetailRequest(client, workspaceRoot, ref, number) {
6997
7048
  reload: () => {
6998
7049
  setAttempt((value) => value + 1);
6999
7050
  },
7000
- replace: setDetail
7051
+ replace: setDetail,
7052
+ refresh,
7053
+ refreshing,
7054
+ refreshError
7001
7055
  };
7002
7056
  }
7003
7057
  function useTicketMutation(client, options) {
@@ -10480,19 +10534,13 @@ function TicketDetailView(props) {
10480
10534
  [client, workspaceRoot]
10481
10535
  );
10482
10536
  const detail = request.detail;
10483
- const [currentTicket, setCurrentTicket] = React27.useState(ticket);
10484
- React27.useEffect(() => {
10485
- setCurrentTicket(ticket);
10486
- }, [ticket]);
10537
+ const { current: currentTicket, updateFromSnapshot } = useCurrentTicket(ticket);
10487
10538
  const mutation = useTicketMutation(client, {
10488
10539
  workspaceRoot,
10489
10540
  ref,
10490
10541
  number,
10491
10542
  onUpdated: request.replace,
10492
- onSnapshot: (snapshot) => {
10493
- const next = snapshot.tickets.find((item) => item.ref === ref);
10494
- if (next !== void 0) setCurrentTicket(next);
10495
- }
10543
+ onSnapshot: updateFromSnapshot
10496
10544
  });
10497
10545
  const deletion = useTicketDeletion(client, {
10498
10546
  workspaceRoot,
@@ -10503,7 +10551,11 @@ function TicketDetailView(props) {
10503
10551
  const options = useTicketOptions(client, workspaceRoot, detail?.capabilities.labels === true);
10504
10552
  const { injected, notice, onSkillAction } = useTicketActions(workspaceRoot, props.injection);
10505
10553
  const link = useCopyLink(detail?.url ?? null, t2);
10506
- const busy = mutation.busy || deletion.deleting;
10554
+ const { busy, refreshDisabled, onRefresh } = refreshControls(request, {
10555
+ onRefreshSnapshot: props.onRefreshSnapshot,
10556
+ writeBusy: mutation.busy || deletion.deleting,
10557
+ confirming: deletion.confirming
10558
+ });
10507
10559
  useEscapeKey(props.onBack);
10508
10560
  return /* @__PURE__ */ React27.createElement("div", { "data-testid": "ticket-detail", style: DETAIL_ROOT_STYLE }, /* @__PURE__ */ React27.createElement(DetailHeader, { refText: ref, detail, onBack: props.onBack }, /* @__PURE__ */ React27.createElement(
10509
10561
  SkillActionBadge,
@@ -10520,9 +10572,12 @@ function TicketDetailView(props) {
10520
10572
  busy,
10521
10573
  onApply: mutation.apply,
10522
10574
  copy: link.copy,
10523
- onCopy: link.onCopy
10575
+ onCopy: link.onCopy,
10576
+ onRefresh,
10577
+ refreshing: request.refreshing,
10578
+ refreshDisabled
10524
10579
  }
10525
- ), detail?.capabilities.delete === true ? /* @__PURE__ */ React27.createElement(MoreMenu, { onDelete: deletion.open }) : null), detail !== null ? /* @__PURE__ */ React27.createElement(
10580
+ ), detail?.capabilities.delete === true ? /* @__PURE__ */ React27.createElement(MoreMenu, { onDelete: deletion.open }) : null), /* @__PURE__ */ React27.createElement(RefreshFailure, { error: request.refreshError }), detail !== null ? /* @__PURE__ */ React27.createElement(
10526
10581
  DetailContent,
10527
10582
  {
10528
10583
  detail,
@@ -10537,6 +10592,35 @@ function TicketDetailView(props) {
10537
10592
  }
10538
10593
  ) : request.phase === "error" ? /* @__PURE__ */ React27.createElement(LoadError, { error: request.error, onRetry: request.reload }) : /* @__PURE__ */ React27.createElement("div", { "data-testid": "detail-loading", style: EMPTY_STYLE }, t2("detail.loading")));
10539
10594
  }
10595
+ function useCurrentTicket(ticket) {
10596
+ const [current, setCurrent] = React27.useState(ticket);
10597
+ React27.useEffect(() => {
10598
+ setCurrent(ticket);
10599
+ }, [ticket]);
10600
+ return {
10601
+ current,
10602
+ updateFromSnapshot: (snapshot) => {
10603
+ const next = snapshot.tickets.find((item) => item.ref === ticket.ref);
10604
+ if (next !== void 0) setCurrent(next);
10605
+ }
10606
+ };
10607
+ }
10608
+ function refreshControls(request, options) {
10609
+ const busy = options.writeBusy || request.refreshing;
10610
+ return {
10611
+ busy,
10612
+ refreshDisabled: busy || options.confirming,
10613
+ onRefresh: () => {
10614
+ request.refresh();
10615
+ options.onRefreshSnapshot();
10616
+ }
10617
+ };
10618
+ }
10619
+ function RefreshFailure(props) {
10620
+ const { t: t2 } = useI18n();
10621
+ if (props.error === null) return null;
10622
+ return /* @__PURE__ */ React27.createElement("div", { role: "alert", "data-testid": "detail-refresh-error", style: DETAIL_REFRESH_ERROR_STYLE }, t2("detail.refreshFailed", { detail: errorText(props.error, t2) }));
10623
+ }
10540
10624
  function DetailHeader(props) {
10541
10625
  const { t: t2 } = useI18n();
10542
10626
  const { detail } = props;
@@ -12379,14 +12463,17 @@ function OverviewPane(props) {
12379
12463
  }
12380
12464
  function TicketsPane(props) {
12381
12465
  if (props.workspaceRoot !== void 0 && props.open !== null) {
12466
+ const open = props.open;
12467
+ const current = props.request.snapshot?.tickets.find((item) => item.ref === open.ticket.ref) ?? open.ticket;
12382
12468
  return /* @__PURE__ */ React42.createElement(
12383
12469
  TicketDetailView,
12384
12470
  {
12385
12471
  client: props.client,
12386
12472
  workspaceRoot: props.workspaceRoot,
12387
- ticket: props.open.ticket,
12473
+ ticket: current,
12388
12474
  injection: props.injection,
12389
- onBack: props.onCloseDetail
12475
+ onBack: props.onCloseDetail,
12476
+ onRefreshSnapshot: props.request.refresh
12390
12477
  }
12391
12478
  );
12392
12479
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cnzgray/dsh-mattpocock-workflow",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "在 DSH 里运行 mattpocock/skills 工作流的 MattWorkflow 任务面板插件。",
5
5
  "license": "MIT",
6
6
  "type": "module",