@songsid/agend 2.4.0-beta.27 → 2.4.0-beta.28

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 (141) hide show
  1. package/dist/agent-cli-instructions.md +2 -1
  2. package/dist/agent-cli.js +6 -0
  3. package/dist/agent-cli.js.map +1 -1
  4. package/dist/build-provenance.json +1 -1
  5. package/dist/channel/mcp-tools.js +1 -1
  6. package/dist/channel/mcp-tools.js.map +1 -1
  7. package/dist/claude-turn-boundaries.d.ts +15 -0
  8. package/dist/claude-turn-boundaries.js +88 -0
  9. package/dist/claude-turn-boundaries.js.map +1 -0
  10. package/dist/contact-auth-service.js +3 -0
  11. package/dist/contact-auth-service.js.map +1 -1
  12. package/dist/contact-auth-store.d.ts +16 -0
  13. package/dist/contact-auth-store.js +61 -1
  14. package/dist/contact-auth-store.js.map +1 -1
  15. package/dist/daemon.d.ts +12 -1
  16. package/dist/daemon.js +130 -19
  17. package/dist/daemon.js.map +1 -1
  18. package/dist/delivery-outbox.d.ts +38 -0
  19. package/dist/delivery-outbox.js +81 -1
  20. package/dist/delivery-outbox.js.map +1 -1
  21. package/dist/fleet-manager.d.ts +17 -1
  22. package/dist/fleet-manager.js +239 -16
  23. package/dist/fleet-manager.js.map +1 -1
  24. package/dist/general-knowledge/skills/concepts/SKILL.md +5 -0
  25. package/dist/general-knowledge/skills/task-board/SKILL.md +14 -0
  26. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +1 -1
  27. package/dist/hub/group-policy/resources.d.ts +1 -1
  28. package/dist/hub/roles/clock.d.ts +1 -1
  29. package/dist/hub/roles/clock.js +3 -2
  30. package/dist/hub/roles/clock.js.map +1 -1
  31. package/dist/hub/roles/read.d.ts +2 -0
  32. package/dist/hub/roles/read.js +15 -6
  33. package/dist/hub/roles/read.js.map +1 -1
  34. package/dist/hub/settings-directory-decision.js +11 -5
  35. package/dist/hub/settings-directory-decision.js.map +1 -1
  36. package/dist/hub/settings-member-address-decision.js +1 -1
  37. package/dist/hub/settings-member-address-decision.js.map +1 -1
  38. package/dist/hub/store.d.ts +4 -0
  39. package/dist/hub/store.js +19 -4
  40. package/dist/hub/store.js.map +1 -1
  41. package/dist/locale.js +17 -1
  42. package/dist/locale.js.map +1 -1
  43. package/dist/outbound-schemas.d.ts +3 -0
  44. package/dist/outbound-schemas.js +4 -2
  45. package/dist/outbound-schemas.js.map +1 -1
  46. package/dist/request-context-activation.js +14 -3
  47. package/dist/request-context-activation.js.map +1 -1
  48. package/dist/request-context-call.d.ts +1 -0
  49. package/dist/request-context-call.js.map +1 -1
  50. package/dist/request-context-compatibility.js +10 -2
  51. package/dist/request-context-compatibility.js.map +1 -1
  52. package/dist/request-context-control-api.d.ts +18 -0
  53. package/dist/request-context-control-api.js +4 -2
  54. package/dist/request-context-control-api.js.map +1 -1
  55. package/dist/request-context-drain-projection.d.ts +8 -0
  56. package/dist/request-context-drain-projection.js +40 -0
  57. package/dist/request-context-drain-projection.js.map +1 -0
  58. package/dist/request-context-drain.d.ts +9 -0
  59. package/dist/request-context-drain.js +63 -4
  60. package/dist/request-context-drain.js.map +1 -1
  61. package/dist/request-context-human.d.ts +6 -0
  62. package/dist/request-context-human.js +24 -1
  63. package/dist/request-context-human.js.map +1 -1
  64. package/dist/request-context-migration.d.ts +11 -0
  65. package/dist/request-context-migration.js +16 -3
  66. package/dist/request-context-migration.js.map +1 -1
  67. package/dist/request-context-reply-pending.d.ts +16 -0
  68. package/dist/request-context-reply-pending.js +77 -0
  69. package/dist/request-context-reply-pending.js.map +1 -0
  70. package/dist/request-context-resolution.d.ts +35 -0
  71. package/dist/request-context-resolution.js +86 -0
  72. package/dist/request-context-resolution.js.map +1 -0
  73. package/dist/request-context-retirement.d.ts +2 -0
  74. package/dist/request-context-retirement.js.map +1 -1
  75. package/dist/runtime-build-info.js +1 -1
  76. package/dist/runtime-build-info.js.map +1 -1
  77. package/dist/scheduler/db.js +9 -0
  78. package/dist/scheduler/db.js.map +1 -1
  79. package/dist/scheduler/task-board-text.d.ts +3 -6
  80. package/dist/scheduler/task-board-text.js +15 -10
  81. package/dist/scheduler/task-board-text.js.map +1 -1
  82. package/dist/scheduler/task-board-unread.d.ts +90 -0
  83. package/dist/scheduler/task-board-unread.js +192 -0
  84. package/dist/scheduler/task-board-unread.js.map +1 -0
  85. package/dist/scheduler/task-board.d.ts +324 -6
  86. package/dist/scheduler/task-board.js +786 -47
  87. package/dist/scheduler/task-board.js.map +1 -1
  88. package/dist/settings-effect.js +17 -2
  89. package/dist/settings-effect.js.map +1 -1
  90. package/dist/task-board-tool.js +24 -3
  91. package/dist/task-board-tool.js.map +1 -1
  92. package/dist/task-board-waker.d.ts +53 -2
  93. package/dist/task-board-waker.js +183 -12
  94. package/dist/task-board-waker.js.map +1 -1
  95. package/dist/transcript-monitor.d.ts +6 -1
  96. package/dist/transcript-monitor.js +59 -4
  97. package/dist/transcript-monitor.js.map +1 -1
  98. package/dist/transcript-turns.d.ts +3 -0
  99. package/dist/transcript-turns.js +5 -0
  100. package/dist/transcript-turns.js.map +1 -1
  101. package/dist/ui/fleet-task-activity.js +164 -24
  102. package/dist/ui/fleet-task-card.js +77 -13
  103. package/dist/ui/fleet-task-common.js +14 -0
  104. package/dist/ui/fleet-task-flow.js +353 -0
  105. package/dist/ui/fleet-task-md.js +1 -1
  106. package/dist/ui/fleet-task-run.js +98 -22
  107. package/dist/ui/fleet-task-thread.js +245 -0
  108. package/dist/ui/fleet-task-unread.js +100 -0
  109. package/dist/ui/fleet-task-view.js +6 -5
  110. package/dist/ui/fleet-task-wake.js +140 -0
  111. package/dist/ui/fleet-tasks.js +13 -6
  112. package/dist/ui/panel-windows-cli.js +2 -2
  113. package/dist/ui/request-context-control.js +51 -13
  114. package/dist/ui/shared/access-overview.css +1 -1
  115. package/dist/ui/shared/app-i18n.js +2 -2
  116. package/dist/ui/shared/app-shell.js +4 -1
  117. package/dist/ui/shared/app-stream.js +3 -1
  118. package/dist/ui/shared/app.css +8 -2
  119. package/dist/ui/shared/app.js +3 -0
  120. package/dist/ui/shared/task-board.css +164 -0
  121. package/dist/ui/shared/ui-icons.js +3 -0
  122. package/dist/ui/task-unread.js +70 -0
  123. package/dist/ui/windows-cli-catalog.js +33 -6
  124. package/dist/update-goback.js +3 -1
  125. package/dist/update-goback.js.map +1 -1
  126. package/dist/web-api.d.ts +45 -1
  127. package/dist/web-api.js +184 -6
  128. package/dist/web-api.js.map +1 -1
  129. package/dist/windows-cli-api.js +4 -2
  130. package/dist/windows-cli-api.js.map +1 -1
  131. package/dist/windows-cli.d.ts +40 -1
  132. package/dist/windows-cli.js +93 -11
  133. package/dist/windows-cli.js.map +1 -1
  134. package/dist/windows-shortcuts.d.ts +3 -22
  135. package/dist/windows-shortcuts.js +5 -45
  136. package/dist/windows-shortcuts.js.map +1 -1
  137. package/dist/workflow-templates/default.md +3 -2
  138. package/dist/wsl-host.d.ts +52 -0
  139. package/dist/wsl-host.js +97 -0
  140. package/dist/wsl-host.js.map +1 -0
  141. package/package.json +1 -1
package/dist/web-api.js CHANGED
@@ -56,7 +56,7 @@ import { createHash, createHmac, randomUUID } from "node:crypto";
56
56
  import { CreateInstanceArgs, CreateScheduleArgs, UpdateScheduleArgs, validateArgs } from "./outbound-schemas.js";
57
57
  import { scheduleView } from "./web-schedules.js";
58
58
  import { DEFAULT_SCHEDULER_CONFIG } from "./scheduler/index.js";
59
- import { CARD_PRIORITIES, CARD_SIZES, CARD_STATUSES, TaskBoardError, archiveAfterDays, cardCode } from "./scheduler/task-board.js";
59
+ import { CARD_PRIORITIES, CARD_SIZES, CARD_STATUSES, MAX_RECIPIENTS, TaskBoardError, archiveAfterDays, cardCode } from "./scheduler/task-board.js";
60
60
  import { TASK_REF_SEPARATOR, cardsForRefs, taskReadWay, taskRefBlock, taskRefCodes, taskRefView } from "./chat-task-refs.js";
61
61
  import { readStatuslineModel, resolveInstanceContext } from "./topic-commands.js";
62
62
  import { z } from "zod";
@@ -161,7 +161,38 @@ const CardPatchSchema = z.object({
161
161
  projectId: z.number().int().nullable().optional(),
162
162
  log: z.string().max(BOARD_TEXT).optional(),
163
163
  comment: z.string().max(MAX_TEXT).optional(),
164
+ // Comment threads (docs/design/task-board.md): the comment this one answers, and whom it is for (the recipient chip).
165
+ replyTo: z.number().int().positive().optional(),
166
+ to: z.array(z.string().min(1).max(256)).max(MAX_RECIPIENTS).optional(),
164
167
  }).strict();
168
+ /**
169
+ * A card's comments as the public link may read them (docs/design/task-board.md, "Comment threads"): a reply to a comment kept
170
+ * out of sight reads as a comment of its own (nothing says what it answers), and an instance kept out of sight is not named as
171
+ * the one who reacted, resolved or deleted.
172
+ */
173
+ function threadsShown(comments, hiddenName) {
174
+ const ids = new Set(comments.map((e) => e.id));
175
+ return comments.map((e) => {
176
+ const { parentId, reactions, resolved, deleted, ...rest } = e;
177
+ const out = { ...rest };
178
+ if (parentId !== undefined && ids.has(parentId))
179
+ out.parentId = parentId;
180
+ const kept = (reactions ?? []).map((r) => ({ ...r, by: r.by.filter((b) => !hiddenName(b.name)) })).filter((r) => r.by.length);
181
+ if (kept.length)
182
+ out.reactions = kept;
183
+ if (resolved)
184
+ out.resolved = hiddenName(resolved.by) ? { at: resolved.at, by: "" } : resolved;
185
+ if (deleted)
186
+ out.deleted = hiddenName(deleted.by) ? { at: deleted.at, by: "" } : deleted;
187
+ return out;
188
+ });
189
+ }
190
+ /** A change to one comment of a card (docs/design/task-board.md, "Comment threads"), by the verb in the address. */
191
+ const CommentEditSchema = z.object({ text: z.string().max(MAX_TEXT) }).strict();
192
+ const CommentReactSchema = z.object({ emoji: z.string().min(1).max(64), on: z.boolean().optional() }).strict();
193
+ const CommentResolveSchema = z.object({ resolved: z.boolean().optional() }).strict();
194
+ const CommentDeleteSchema = z.object({}).strict();
195
+ const CardReadSchema = z.object({}).strict();
165
196
  const CardMoveSchema = z.object({
166
197
  to: z.enum(CARD_STATUSES),
167
198
  reason: z.string().max(BOARD_TEXT).optional(),
@@ -2613,7 +2644,7 @@ function webPersonOr401(req, res, url, ctx) {
2613
2644
  */
2614
2645
  function boardActor(req, url, ctx, p) {
2615
2646
  const v = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
2616
- return v.kind === "allow" && v.via === "session" ? { kind: "person", name: p.name } : { kind: "script", name: "web-token" };
2647
+ return v.kind === "allow" && v.via === "session" ? { kind: "person", name: p.name, key: p.key } : { kind: "script", name: "web-token" };
2617
2648
  }
2618
2649
  /**
2619
2650
  * A board refusal as the dashboard reads it: the board's sentence, its code and the status that fits, and — when the
@@ -2664,6 +2695,79 @@ async function serveCardFile(res, board, id, rules) {
2664
2695
  miss();
2665
2696
  }
2666
2697
  }
2698
+ /** A notice that has not been handed to delivery this long after its comment is lost (the fleet stopped while it was gathering it). */
2699
+ const WAKE_LOST_MS = 2 * 60_000;
2700
+ /** The person's unread, by card number (the board's `unreadFor`), without a card the viewer may not see. */
2701
+ function unreadBody(board, person, gone, hidden) {
2702
+ const cards = {};
2703
+ for (const u of board.unreadFor(person, gone).cards) {
2704
+ const card = board.findCard(u.id);
2705
+ if (!card || hidden(card))
2706
+ continue;
2707
+ cards[u.id] = { n: u.n, reasons: u.reasons, entries: u.entries, at: u.at, by: u.by };
2708
+ }
2709
+ return { total: Object.keys(cards).length, cards };
2710
+ }
2711
+ /** A card's comments with the status of those written for instances (`wakeViews`); a comment nobody was meant to hear is as it was. */
2712
+ function withWakeViews(comments, stored, ctx, hiddenName) {
2713
+ if (!stored.size)
2714
+ return comments;
2715
+ // Each notice once (a gathered window of comments shares one), and none whose comment shows a skip (wakeViews reads no key for it).
2716
+ const keys = [...new Set([...stored.values()].flat().flatMap((w) => (w.key && !w.skip ? [w.key] : [])))];
2717
+ const progress = keys.length ? ctx.taskWakeProgress?.(keys) ?? new Map() : new Map();
2718
+ const now = Date.now();
2719
+ return comments.map((e) => {
2720
+ const list = stored.get(e.id);
2721
+ if (!list || e.deleted)
2722
+ return e;
2723
+ const views = wakeViews(list.filter((w) => !hiddenName(w.to)), progress, now);
2724
+ return views.length ? { ...e, wakes: views } : e;
2725
+ });
2726
+ }
2727
+ /** How far one notice got, from what the board kept (`key` / `skip`, when it was routed) and what the delivery outbox says of it. */
2728
+ function noticeState(w, progress, now) {
2729
+ if (w.skip)
2730
+ return { state: "skipped", skip: w.skip };
2731
+ if (!w.key)
2732
+ return now - Date.parse(w.at) > WAKE_LOST_MS ? { state: "skipped", skip: "lost" } : { state: "sending" };
2733
+ const p = progress.get(w.key);
2734
+ if (!p)
2735
+ return { state: "unknown" };
2736
+ switch (p.state) {
2737
+ case "delivered": return p.consumedAt ? { state: "read", readAt: p.consumedAt } : { state: "delivered" };
2738
+ case "failed": return { state: "failed", ...(p.failure ? { failure: p.failure } : {}) };
2739
+ case "uncertain": return { state: "uncertain" };
2740
+ case "cancelled": return { state: "withdrawn" };
2741
+ default: return { state: "queued" };
2742
+ }
2743
+ }
2744
+ export function wakeViews(wakes, progress, now) {
2745
+ return wakes.map((w) => ({ to: w.to, why: w.why, at: w.at, ...noticeState(w, progress, now) }));
2746
+ }
2747
+ export function handoffViews(list, progress, now) {
2748
+ return list.map((h) => {
2749
+ // (M-3908's `failure` is the comment status's: a hand-over says only that it failed.)
2750
+ const { failure: _failure, ...state } = noticeState(h, progress, now);
2751
+ return { id: h.id, card: h.card, to: h.to, why: h.why, after: h.after, at: h.at, ...state };
2752
+ });
2753
+ }
2754
+ /**
2755
+ * A card's handoffs (its own and, for a main task, those of its sub tasks) with how far each notice got — for a session that can write, never of an
2756
+ * instance kept out of sight; the card whose finishing readied one (`after`) is numbered only if the viewer may see it (`hiddenCode`: a card kept out of
2757
+ * sight reads as none, and the page says "S-2 can start" instead of "S-1 done").
2758
+ */
2759
+ export function withHandoffViews(board, ref, children, ctx, hiddenName, hiddenCode = () => false) {
2760
+ // The card read already has its sub tasks (with their uuids): only the card itself is looked up.
2761
+ const own = board.findCard(ref);
2762
+ const uuids = [...(own ? [own.uuid] : []), ...children.map((c) => c.uuid)];
2763
+ const list = board.handoffsOf(uuids).filter((h) => !hiddenName(h.to)).map((h) => (h.after && hiddenCode(h.after) ? { ...h, after: null } : h));
2764
+ if (!list.length)
2765
+ return [];
2766
+ // Each notice once (one notice can carry several hand-overs), and none whose hand-over shows a skip (handoffViews reads no key for it), as withWakeViews.
2767
+ const keys = [...new Set(list.flatMap((h) => (h.key && !h.skip ? [h.key] : [])))];
2768
+ const progress = keys.length ? ctx.taskWakeProgress?.(keys) ?? new Map() : new Map();
2769
+ return handoffViews(list, progress, Date.now());
2770
+ }
2667
2771
  function boardError(res, err) {
2668
2772
  if (res.headersSent)
2669
2773
  return;
@@ -5501,11 +5605,18 @@ export function handleWebRequest(req, res, url, ctx) {
5501
5605
  }
5502
5606
  // ── Task board (scheduler/task-board.ts) ──────────────
5503
5607
  // Reads are the session's; every write is the signed-in person's, through the same rules an instance's tools use.
5504
- if (path === "/ui/tasks/board" || path === "/ui/tasks/search" || path === "/ui/tasks/refs" || path === "/ui/tasks/work" || path === "/ui/tasks/archive" || path.startsWith("/ui/tasks/cards") || path.startsWith("/ui/tasks/projects") || path.startsWith("/ui/tasks/files/")) {
5608
+ if (path === "/ui/tasks/board" || path === "/ui/tasks/search" || path === "/ui/tasks/refs" || path === "/ui/tasks/work" || path === "/ui/tasks/archive" || path === "/ui/tasks/unread" || path.startsWith("/ui/tasks/cards") || path.startsWith("/ui/tasks/projects") || path.startsWith("/ui/tasks/files/")) {
5505
5609
  const board = ctx.scheduler?.db.board;
5506
5610
  // M-3668: how many days after it finished a main task leaves the board (defaults.task_board.archive_after_days).
5507
5611
  const archiveDays = archiveAfterDays(ctx.fleetConfig?.defaults?.task_board?.archive_after_days);
5508
5612
  if (!board) {
5613
+ // The page asks for the person's unread on every admin page (task-unread.js), so a fleet with no task board answers it as it does a
5614
+ // session that has none — nothing — and not with an error the browser logs as one.
5615
+ if (method === "GET" && path === "/ui/tasks/unread") {
5616
+ res.setHeader("Cache-Control", "no-store");
5617
+ json(res, 200, { enabled: false, total: 0, cards: {} });
5618
+ return true;
5619
+ }
5509
5620
  json(res, 503, { error: "The task board is not available", code: "unavailable", key: "unavailable" });
5510
5621
  return true;
5511
5622
  }
@@ -5586,11 +5697,15 @@ export function handleWebRequest(req, res, url, ctx) {
5586
5697
  // A main task kept out of sight is not named here either: its watchers go with it (the `parent` above reads as none).
5587
5698
  inheritedWatchers: d.card.parentId && hiddenRef(d.card.parentId) ? [] : d.inheritedWatchers.filter((n) => !hiddenName(n)),
5588
5699
  leader: d.leader && hiddenName(d.leader.name) ? null : d.leader, // as a project's hidden lead: read as none
5589
- comments: d.comments.filter((e) => !hiddenName(e.author)),
5700
+ comments: threadsShown(d.comments.filter((e) => !hiddenName(e.author)), hiddenName),
5590
5701
  logs: d.logs.filter((e) => !hiddenName(e.author)),
5591
5702
  history: d.history.filter((e) => !hiddenName(e.actor) && !mentionsHidden(e.data)).flatMap((e) => unnumberedEvent(e) ?? []),
5703
+ // A sub task kept out of sight has no moves here, nor does one a hidden instance made.
5704
+ subEvents: d.subEvents.filter((e) => !hiddenCode(e.card) && !hiddenName(e.actor) && !mentionsHidden(e.data)),
5592
5705
  };
5593
5706
  const card = /^\/ui\/tasks\/cards\/([^/]+)(?:\/(move|reorder|watchers))?$/.exec(path);
5707
+ const comment = /^\/ui\/tasks\/cards\/([^/]+)\/comments\/(\d{1,12})\/(edit|react|resolve|delete)$/.exec(path);
5708
+ const opened = /^\/ui\/tasks\/cards\/([^/]+)\/read$/.exec(path);
5594
5709
  const project = /^\/ui\/tasks\/projects\/(\d+)$/.exec(path);
5595
5710
  try {
5596
5711
  const ref = card ? decodeURIComponent(card[1]) : "";
@@ -5632,6 +5747,30 @@ export function handleWebRequest(req, res, url, ctx) {
5632
5747
  jsonText(res, 200, body);
5633
5748
  return true;
5634
5749
  }
5750
+ // What is new for this person (docs/design/task-board.md, "Unread"): the cards someone answered, named them on or handed them to
5751
+ // confirm or answer. Theirs alone — an admin session's name; a read-only reader has no one, so no unread, no mark. Never cached
5752
+ // (it moves with every comment) and never carries a hidden instance's card.
5753
+ if (method === "GET" && path === "/ui/tasks/unread") {
5754
+ res.setHeader("Cache-Control", "no-store");
5755
+ const reader = adminAdmissionOf(req, url, ctx) ? webPersonOf(req, url, ctx) : null;
5756
+ const who = reader ? boardActor(req, url, ctx, reader) : null;
5757
+ if (!who || who.kind !== "person") {
5758
+ json(res, 200, { enabled: false, total: 0, cards: {} });
5759
+ return true;
5760
+ }
5761
+ json(res, 200, { enabled: true, ...unreadBody(board, who, ctx.dispatcherGone, hidden) });
5762
+ return true;
5763
+ }
5764
+ if (method === "POST" && opened) {
5765
+ // They opened the card: all of it so far is read. A card kept out of sight is "no such card", as everywhere.
5766
+ const cardRef = decodeURIComponent(opened[1]);
5767
+ if (hidden(board.getCard(cardRef))) {
5768
+ json(res, 404, { error: "no such card", code: "not_found" });
5769
+ return true;
5770
+ }
5771
+ boardWrite(req, res, url, ctx, board, CardReadSchema, (_body, person) => { board.markRead(person, cardRef); return { ok: true, ...unreadBody(board, person, ctx.dispatcherGone, hidden) }; });
5772
+ return true;
5773
+ }
5635
5774
  if (method === "GET" && path === "/ui/tasks/work") {
5636
5775
  // #2246 step 3: each instance's work on the board — what its `task mine` reads (myWork) — for the board's
5637
5776
  // Instance list and an instance's Details page (`?instance=`): the fleet's instances and anyone else a live
@@ -5712,7 +5851,22 @@ export function handleWebRequest(req, res, url, ctx) {
5712
5851
  json(res, 404, { error: "no such card", code: "not_found" });
5713
5852
  return true;
5714
5853
  }
5715
- json(res, 200, { ...shown(board.detail(ref, scope, ctx.dispatcherGone)), ...(board.isArchived(found, archiveDays) ? { archived: true, archiveAfterDays: archiveDays } : {}) });
5854
+ // `viewer`: who this request writes as — an admin session's person — so the page knows which comments are theirs to edit
5855
+ // (and that it may react, resolve and delete); none for a read-only session, the CLI's token or a guest.
5856
+ const viewerPerson = adminAdmissionOf(req, url, ctx) ? webPersonOf(req, url, ctx) : null;
5857
+ const viewer = viewerPerson ? boardActor(req, url, ctx, viewerPerson) : null;
5858
+ const read = shown(board.detail(ref, scope, ctx.dispatcherGone));
5859
+ // The comment status: only to a session that can write (it is the writer's feedback), and never of an instance kept out of sight.
5860
+ const withStatus = viewer ? withWakeViews(read.comments, board.entryWakes(ref), ctx, hiddenName) : read.comments;
5861
+ // Each comment says whether it is the viewer's (two people who are both "web-user" are told apart by their key, not their name).
5862
+ const mine = viewer && viewer.kind === "person" ? board.commentsWrittenBy(ref, viewer) : null;
5863
+ // And which reactions are theirs: by the same key, so two people with one name do not press each other's chip.
5864
+ const reacted = viewer && viewer.kind === "person" ? board.reactedBy(ref, viewer) : null;
5865
+ const shownComments = mine ? withStatus.map((e) => ({ ...e, mine: mine.has(e.id), ...(e.reactions ? { reactions: e.reactions.map((r) => ({ ...r, mine: !!reacted?.has(`${e.id}|${r.emoji}`) })) } : {}) })) : withStatus;
5866
+ // The handoffs, like the comment status, only to a session that can write (the delivery's state is the writer's feedback).
5867
+ const handoffs = viewer ? withHandoffViews(board, ref, read.children, ctx, hiddenName, hiddenCode) : [];
5868
+ json(res, 200, { ...read, comments: shownComments, ...(mine ? { viewer: { name: viewer.name, kind: viewer.kind } } : {}), ...(handoffs.length ? { handoffs } : {}),
5869
+ ...(board.isArchived(found, archiveDays) ? { archived: true, archiveAfterDays: archiveDays } : {}) });
5716
5870
  return true;
5717
5871
  }
5718
5872
  if (method === "GET" && path === "/ui/tasks/archive") {
@@ -5739,6 +5893,30 @@ export function handleWebRequest(req, res, url, ctx) {
5739
5893
  });
5740
5894
  return true;
5741
5895
  }
5896
+ if (method === "POST" && comment) {
5897
+ // One comment of a card: edit, react, resolve, delete. A card kept out of sight is "no such card"; over the link only an
5898
+ // admin session gets here (above), and it sees the board whole.
5899
+ const cardRef = decodeURIComponent(comment[1]), entryId = Number(comment[2]);
5900
+ const found = board.getCard(cardRef);
5901
+ if (hidden(found)) {
5902
+ json(res, 404, { error: "no such card", code: "not_found" });
5903
+ return true;
5904
+ }
5905
+ const answer = (done) => ({ card: board.view(done.card, {}, ctx.dispatcherGone), comment: done.entry, notes: done.said });
5906
+ switch (comment[3]) {
5907
+ case "edit":
5908
+ boardWrite(req, res, url, ctx, board, CommentEditSchema, ({ text }, person) => answer(board.editComment(person, cardRef, entryId, text)));
5909
+ break;
5910
+ case "react":
5911
+ boardWrite(req, res, url, ctx, board, CommentReactSchema, ({ emoji, on }, person) => answer(board.react(person, cardRef, entryId, emoji, on !== false)));
5912
+ break;
5913
+ case "resolve":
5914
+ boardWrite(req, res, url, ctx, board, CommentResolveSchema, ({ resolved }, person) => answer(board.resolveThread(person, cardRef, entryId, resolved !== false)));
5915
+ break;
5916
+ default: boardWrite(req, res, url, ctx, board, CommentDeleteSchema, (_body, person) => answer(board.deleteComment(person, cardRef, entryId)));
5917
+ }
5918
+ return true;
5919
+ }
5742
5920
  if (method === "POST" && card) {
5743
5921
  if (card[2] === "move") {
5744
5922
  boardWrite(req, res, url, ctx, board, CardMoveSchema, ({ to, ...move }, person) => {
@@ -7299,7 +7477,7 @@ export function shellPreload(mode, guest, path, workspace) {
7299
7477
  if (!guest) {
7300
7478
  if (panel && panel !== "chat" && panel !== "view" && PANEL_MODULES[panel])
7301
7479
  entries.push(PANEL_MODULES[panel]);
7302
- entries.push("/ui/js/backend-signin.js", "/ui/js/agent-proposals.js");
7480
+ entries.push("/ui/js/backend-signin.js", "/ui/js/agent-proposals.js", "/ui/js/task-unread.js");
7303
7481
  if (workspace)
7304
7482
  entries.push("/ui/js/chat-workspace.js", PANEL_MODULES.details, PANEL_MODULES.log, PANEL_MODULES.view);
7305
7483
  }