@songsid/agend 2.4.0-beta.27 → 2.4.0-beta.29
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/dist/agent-cli-instructions.md +2 -1
- package/dist/agent-cli.js +6 -0
- package/dist/agent-cli.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/adapters/discord.d.ts +13 -1
- package/dist/channel/adapters/discord.js +51 -21
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/mcp-tools.js +1 -1
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/claude-turn-boundaries.d.ts +15 -0
- package/dist/claude-turn-boundaries.js +88 -0
- package/dist/claude-turn-boundaries.js.map +1 -0
- package/dist/contact-auth-service.js +3 -0
- package/dist/contact-auth-service.js.map +1 -1
- package/dist/contact-auth-store.d.ts +16 -0
- package/dist/contact-auth-store.js +61 -1
- package/dist/contact-auth-store.js.map +1 -1
- package/dist/daemon.d.ts +12 -1
- package/dist/daemon.js +130 -19
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-outbox.d.ts +38 -0
- package/dist/delivery-outbox.js +81 -1
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/fleet-manager.d.ts +17 -1
- package/dist/fleet-manager.js +239 -16
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +5 -0
- package/dist/general-knowledge/skills/task-board/SKILL.md +14 -0
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +1 -1
- package/dist/host-memory.d.ts +21 -1
- package/dist/host-memory.js +30 -4
- package/dist/host-memory.js.map +1 -1
- package/dist/host-monitoring/linux/interpretation.js +1 -1
- package/dist/host-monitoring/linux/interpretation.js.map +1 -1
- package/dist/host-monitoring/wsl/interpretation.js +1 -1
- package/dist/host-monitoring/wsl/interpretation.js.map +1 -1
- package/dist/host-monitoring.d.ts +3 -1
- package/dist/hub/compose/server.js +1 -1
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/group-policy/resources.d.ts +1 -1
- package/dist/hub/http/compose.js +100 -56
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/core.d.ts +2 -0
- package/dist/hub/http/core.js +17 -7
- package/dist/hub/http/core.js.map +1 -1
- package/dist/hub/policy.js +56 -27
- package/dist/hub/policy.js.map +1 -1
- package/dist/hub/roles/clock.d.ts +1 -1
- package/dist/hub/roles/clock.js +8 -6
- package/dist/hub/roles/clock.js.map +1 -1
- package/dist/hub/roles/cutover-clock-facts.d.ts +13 -0
- package/dist/hub/roles/cutover-clock-facts.js +25 -0
- package/dist/hub/roles/cutover-clock-facts.js.map +1 -0
- package/dist/hub/roles/read.d.ts +2 -0
- package/dist/hub/roles/read.js +15 -6
- package/dist/hub/roles/read.js.map +1 -1
- package/dist/hub/rooms.d.ts +8 -4
- package/dist/hub/rooms.js +18 -5
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/send-timing.d.ts +6 -0
- package/dist/hub/send-timing.js +39 -0
- package/dist/hub/send-timing.js.map +1 -0
- package/dist/hub/settings-directory-decision.js +11 -5
- package/dist/hub/settings-directory-decision.js.map +1 -1
- package/dist/hub/settings-member-address-decision.js +1 -1
- package/dist/hub/settings-member-address-decision.js.map +1 -1
- package/dist/hub/store.d.ts +4 -0
- package/dist/hub/store.js +19 -4
- package/dist/hub/store.js.map +1 -1
- package/dist/locale.js +19 -1
- package/dist/locale.js.map +1 -1
- package/dist/memory-pressure.js +8 -1
- package/dist/memory-pressure.js.map +1 -1
- package/dist/outbound-schemas.d.ts +3 -0
- package/dist/outbound-schemas.js +4 -2
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/request-context-activation.js +14 -3
- package/dist/request-context-activation.js.map +1 -1
- package/dist/request-context-call.d.ts +1 -0
- package/dist/request-context-call.js.map +1 -1
- package/dist/request-context-compatibility.js +10 -2
- package/dist/request-context-compatibility.js.map +1 -1
- package/dist/request-context-control-api.d.ts +18 -0
- package/dist/request-context-control-api.js +4 -2
- package/dist/request-context-control-api.js.map +1 -1
- package/dist/request-context-drain-projection.d.ts +8 -0
- package/dist/request-context-drain-projection.js +40 -0
- package/dist/request-context-drain-projection.js.map +1 -0
- package/dist/request-context-drain.d.ts +9 -0
- package/dist/request-context-drain.js +63 -4
- package/dist/request-context-drain.js.map +1 -1
- package/dist/request-context-human.d.ts +6 -0
- package/dist/request-context-human.js +24 -1
- package/dist/request-context-human.js.map +1 -1
- package/dist/request-context-migration.d.ts +11 -0
- package/dist/request-context-migration.js +16 -3
- package/dist/request-context-migration.js.map +1 -1
- package/dist/request-context-reply-pending.d.ts +16 -0
- package/dist/request-context-reply-pending.js +77 -0
- package/dist/request-context-reply-pending.js.map +1 -0
- package/dist/request-context-resolution.d.ts +35 -0
- package/dist/request-context-resolution.js +86 -0
- package/dist/request-context-resolution.js.map +1 -0
- package/dist/request-context-retirement.d.ts +2 -0
- package/dist/request-context-retirement.js.map +1 -1
- package/dist/runtime-build-info.js +1 -1
- package/dist/runtime-build-info.js.map +1 -1
- package/dist/scheduler/db.js +9 -0
- package/dist/scheduler/db.js.map +1 -1
- package/dist/scheduler/task-board-text.d.ts +3 -6
- package/dist/scheduler/task-board-text.js +15 -10
- package/dist/scheduler/task-board-text.js.map +1 -1
- package/dist/scheduler/task-board-unread.d.ts +90 -0
- package/dist/scheduler/task-board-unread.js +192 -0
- package/dist/scheduler/task-board-unread.js.map +1 -0
- package/dist/scheduler/task-board.d.ts +324 -6
- package/dist/scheduler/task-board.js +786 -47
- package/dist/scheduler/task-board.js.map +1 -1
- package/dist/settings-effect.js +17 -2
- package/dist/settings-effect.js.map +1 -1
- package/dist/task-board-tool.js +24 -3
- package/dist/task-board-tool.js.map +1 -1
- package/dist/task-board-waker.d.ts +53 -2
- package/dist/task-board-waker.js +183 -12
- package/dist/task-board-waker.js.map +1 -1
- package/dist/transcript-monitor.d.ts +6 -1
- package/dist/transcript-monitor.js +59 -4
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/transcript-turns.d.ts +3 -0
- package/dist/transcript-turns.js +5 -0
- package/dist/transcript-turns.js.map +1 -1
- package/dist/ui/fleet-task-activity.js +164 -24
- package/dist/ui/fleet-task-card.js +77 -13
- package/dist/ui/fleet-task-common.js +14 -0
- package/dist/ui/fleet-task-flow.js +353 -0
- package/dist/ui/fleet-task-md.js +1 -1
- package/dist/ui/fleet-task-run.js +98 -22
- package/dist/ui/fleet-task-thread.js +245 -0
- package/dist/ui/fleet-task-unread.js +100 -0
- package/dist/ui/fleet-task-view.js +6 -5
- package/dist/ui/fleet-task-wake.js +140 -0
- package/dist/ui/fleet-tasks.js +13 -6
- package/dist/ui/host-health.js +3 -3
- package/dist/ui/host-monitoring-linux.js +2 -2
- package/dist/ui/host-monitoring-wsl.js +2 -2
- package/dist/ui/panel-windows-cli.js +2 -2
- package/dist/ui/request-context-control.js +51 -13
- package/dist/ui/shared/access-overview.css +1 -1
- package/dist/ui/shared/app-i18n.js +2 -2
- package/dist/ui/shared/app-shell.js +4 -1
- package/dist/ui/shared/app-stream.js +3 -1
- package/dist/ui/shared/app.css +8 -2
- package/dist/ui/shared/app.js +3 -0
- package/dist/ui/shared/task-board.css +164 -0
- package/dist/ui/shared/ui-icons.js +3 -0
- package/dist/ui/task-unread.js +70 -0
- package/dist/ui/windows-cli-catalog.js +33 -6
- package/dist/update-goback.js +3 -1
- package/dist/update-goback.js.map +1 -1
- package/dist/web-api.d.ts +45 -1
- package/dist/web-api.js +184 -6
- package/dist/web-api.js.map +1 -1
- package/dist/windows-cli-api.js +4 -2
- package/dist/windows-cli-api.js.map +1 -1
- package/dist/windows-cli.d.ts +40 -1
- package/dist/windows-cli.js +93 -11
- package/dist/windows-cli.js.map +1 -1
- package/dist/windows-shortcuts.d.ts +3 -22
- package/dist/windows-shortcuts.js +5 -45
- package/dist/windows-shortcuts.js.map +1 -1
- package/dist/workflow-templates/default.md +3 -2
- package/dist/wsl-host.d.ts +52 -0
- package/dist/wsl-host.js +97 -0
- package/dist/wsl-host.js.map +1 -0
- package/package.json +1 -1
|
@@ -19,8 +19,12 @@ import { ProgressBar, StatusPill, Who, answerBlocked, askText, boardApi, errorTe
|
|
|
19
19
|
import { StepButtons, movesFor } from "./fleet-task-menu.js";
|
|
20
20
|
import { Checklist, EditableText, InlineTitle, PropChip, QuickAdd } from "./fleet-task-edit.js";
|
|
21
21
|
import { Composer, Timeline } from "./fleet-task-activity.js";
|
|
22
|
+
import { defaultRecipient, holdsRecipient, recipientGroups } from "./fleet-task-thread.js";
|
|
22
23
|
import { FilesField } from "./fleet-task-files.js";
|
|
23
|
-
import { AgentRun } from "./fleet-task-run.js";
|
|
24
|
+
import { AgentRun, RunMark, instanceStates, runOf } from "./fleet-task-run.js";
|
|
25
|
+
import { FlowLines, SubRows, flowContext, handoffsMoving, hasFlow, subLine } from "./fleet-task-flow.js";
|
|
26
|
+
import { wakesMoving } from "./fleet-task-wake.js";
|
|
27
|
+
import { openedCard } from "./task-unread.js";
|
|
24
28
|
import { LeaderRow, WatchersRow } from "./fleet-task-follow.js";
|
|
25
29
|
|
|
26
30
|
register("taskcard", {
|
|
@@ -83,7 +87,7 @@ register("taskcard", {
|
|
|
83
87
|
mentionList: "可提及的 Agent", boardOffShort: "任務板已關閉",
|
|
84
88
|
rowMoved: "把狀態從 {0} 改成 {1}", rowAssigned: "把負責人從 {0} 改成 {1}", activities: "{0} 項動態", activity1: "1 項動態",
|
|
85
89
|
logTip: "agent 或成員記下的一行工作紀錄,不是留言",
|
|
86
|
-
evCreated: "
|
|
90
|
+
evCreated: "建立卡片", evMoved: "{0}→{1}", evAuto: "(自動)", evAssigned: "負責人 {0}→{1}", evUpdated: "修改{0}", evCommented: "留言", evLogged: "紀錄:{0}", evWatchers: "修改關注者:{0}",
|
|
87
91
|
fTitle: "標題", fGoal: "目標", fScope: "範圍", fContext: "背景", fState: "目前狀態", fResult: "產出", fBlockedReason: "卡住原因", fSize: "大小",
|
|
88
92
|
fPriority: "優先級", fNeedsReview: "需要確認", fDependsOn: "相依", fAcceptance: "驗收條件", fProjectId: "專案",
|
|
89
93
|
position: "位置", moveUp: "往上移", moveDown: "往下移", properties: "屬性", crumbs: "這張卡的位置", backBoard: "回到看板", backList: "回到清單",
|
|
@@ -96,6 +100,8 @@ register("taskcard", {
|
|
|
96
100
|
},
|
|
97
101
|
});
|
|
98
102
|
|
|
103
|
+
/** While a comment's notice is on its way the page reads the card again this often (the stream's ping is the first way); a card is read this long after it is shown. */
|
|
104
|
+
const WAKE_POLL_MS = 5000, READ_AFTER_MS = 1200;
|
|
99
105
|
const LIMIT = { title: 100, goal: 300, scope: 600, context: 1000, state: 500, result: 1000, blockedReason: 400, acceptanceItems: 10 };
|
|
100
106
|
const PRIORITY_CHOICES = ["urgent", "high", "normal", "low"];
|
|
101
107
|
|
|
@@ -104,7 +110,7 @@ export function describeEvent(ev) {
|
|
|
104
110
|
const d = ev.data || {};
|
|
105
111
|
switch (ev.type) {
|
|
106
112
|
case "created": return t("taskcard.evCreated");
|
|
107
|
-
case "moved": return `${t("taskcard.evMoved", t(`tasks.${d.from}`), t(`tasks.${d.to}`))}${d.auto ? t("taskcard.evAuto") : ""}${d.reason ? `: ${d.reason}` : ""}`;
|
|
113
|
+
case "moved": return `${ev.sub ? `${ev.sub.id} · ` : ""}${t("taskcard.evMoved", t(`tasks.${d.from}`), t(`tasks.${d.to}`))}${d.auto ? t("taskcard.evAuto") : ""}${d.reason ? `: ${d.reason}` : ""}`;
|
|
108
114
|
case "assigned": return t("taskcard.evAssigned", d.from || "—", d.to || "—");
|
|
109
115
|
case "updated": return t("taskcard.evUpdated", Object.keys(d.changes || {}).map((k) => fieldName(k)).join(", "));
|
|
110
116
|
case "commented": return t("taskcard.evCommented");
|
|
@@ -118,7 +124,8 @@ export function describeEvent(ev) {
|
|
|
118
124
|
*/
|
|
119
125
|
export function describeRow(ev) {
|
|
120
126
|
const d = ev.data || {};
|
|
121
|
-
|
|
127
|
+
// A move of one of a main task's sub tasks (`ev.sub`, from the card read's `subEvents`) names it: "S-2 · changed status from To do to In progress".
|
|
128
|
+
if (ev.type === "moved") return `${ev.sub ? `${ev.sub.id} · ` : ""}${t("taskcard.rowMoved", t(`tasks.${d.from}`), t(`tasks.${d.to}`))}${d.auto ? t("taskcard.evAuto") : ""}${d.reason ? `: ${d.reason}` : ""}`;
|
|
122
129
|
if (ev.type === "assigned") return t("taskcard.rowAssigned", d.from || "—", d.to || "—");
|
|
123
130
|
return describeEvent(ev);
|
|
124
131
|
}
|
|
@@ -176,6 +183,11 @@ export function dispatcherItems(card, names, act) {
|
|
|
176
183
|
/** The value the page sends for a dispatcher choice. */
|
|
177
184
|
export const dispatcherValue = (v) => (v === "\u0000none" ? null : v === "\u0000me" ? { kind: "person" } : { kind: "instance", name: v });
|
|
178
185
|
|
|
186
|
+
/** The comment box's recipient chip for a card: the groups to list, the name it starts with, and whether that name is held back (the card still waits on another card). */
|
|
187
|
+
const recipientsOf = (card, detail, fleet) => {
|
|
188
|
+
const initial = defaultRecipient({ card, fleet });
|
|
189
|
+
return { groups: recipientGroups({ card, detail, fleet }), initial, held: holdsRecipient({ card, initial }) };
|
|
190
|
+
};
|
|
179
191
|
const radioItems = (list, current, label, act) => list.map((v) => ({ key: String(v), label: label(v), checked: current === v, onSelect: () => act(v) }));
|
|
180
192
|
|
|
181
193
|
// ── The page ──────────────────────────────────────────────
|
|
@@ -184,10 +196,10 @@ const radioItems = (list, current, label, act) => list.map((v) => ({ key: String
|
|
|
184
196
|
* `writable`: false over a read-only link (the card is shown, nothing on it changes). `place`: up and down in its column,
|
|
185
197
|
* for touch and keyboard (null when it cannot move). `steps`: the previous and next card the page showed, and where this
|
|
186
198
|
* one is among them (null: nowhere to step). `where`: the project's name for the breadcrumb (null: none). `back`: what
|
|
187
|
-
* Back says. `onBack` returns to the board or list. `doing`: how many cards each instance has in progress (fleet-task-run.js).
|
|
199
|
+
* Back says. `onBack` returns to the board or list. `doing`: how many cards each instance has in progress, `ready`: the open cards it could start (fleet-task-run.js).
|
|
188
200
|
*/
|
|
189
|
-
export function CardPage({ id, tick, projects, cards = [], boardOff = [], doing = new Map(), writable = true, place = null, steps = null, where = null, back, onBack, onOpen, onStep, reloadBoard }) {
|
|
190
|
-
const { instances } = useStore(appStore);
|
|
201
|
+
export function CardPage({ id, tick, projects, cards = [], boardOff = [], doing = new Map(), ready = new Map(), writable = true, place = null, steps = null, where = null, back, onBack, onOpen, onStep, reloadBoard }) {
|
|
202
|
+
const { instances, taskUnread } = useStore(appStore);
|
|
191
203
|
const [detail, setDetail] = useState(null);
|
|
192
204
|
const [missing, setMissing] = useState(false);
|
|
193
205
|
const seq = useRef(0);
|
|
@@ -211,6 +223,40 @@ export function CardPage({ id, tick, projects, cards = [], boardOff = [], doing
|
|
|
211
223
|
}
|
|
212
224
|
}
|
|
213
225
|
useEffect(() => { void load(); }, [id, tick]);
|
|
226
|
+
// Where a comment stands moved (a notice was handed to delivery, delivered, read): the stream's `task_wakes` names the card, and the
|
|
227
|
+
// page reads it again (docs/design/task-board.md, "Comment status").
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
const sub = appStore.get().streamOn;
|
|
230
|
+
if (typeof sub !== "function") return undefined;
|
|
231
|
+
let timer = null;
|
|
232
|
+
const off = sub("task_wakes", (d) => {
|
|
233
|
+
if (!d || !Array.isArray(d.ids) || !d.ids.includes(id)) return;
|
|
234
|
+
if (timer) clearTimeout(timer);
|
|
235
|
+
timer = setTimeout(() => { timer = null; void load(); }, 150);
|
|
236
|
+
});
|
|
237
|
+
return () => { off(); if (timer) clearTimeout(timer); };
|
|
238
|
+
}, [id]);
|
|
239
|
+
// …and, while a notice is still on its way, now and then on its own: a page that polls, or one that missed the ping, still moves.
|
|
240
|
+
const onTheWay = detail ? wakesMoving(detail) || handoffsMoving(detail) : false;
|
|
241
|
+
useEffect(() => {
|
|
242
|
+
if (!onTheWay) return undefined;
|
|
243
|
+
const timer = setInterval(() => { if (!document.hidden) void load(); }, WAKE_POLL_MS);
|
|
244
|
+
return () => clearInterval(timer);
|
|
245
|
+
}, [onTheWay, id]);
|
|
246
|
+
// What is new for this person on this card (task-unread.js): its comments are tagged "New" for as long as the card is open, and the
|
|
247
|
+
// card is read a moment after it is shown — at once if it was hidden when it came, as the tab is shown (a mark moves only forward).
|
|
248
|
+
const mine = taskUnread && taskUnread.enabled && taskUnread.cards ? taskUnread.cards[id] : null;
|
|
249
|
+
const [fresh, setFresh] = useState({ id, entries: [] });
|
|
250
|
+
const freshEntries = fresh.id === id ? fresh.entries : [];
|
|
251
|
+
useEffect(() => {
|
|
252
|
+
if (!mine) return undefined;
|
|
253
|
+
setFresh((f) => ({ id, entries: [...new Set([...(f.id === id ? f.entries : []), ...(Array.isArray(mine.entries) ? mine.entries : [])])] }));
|
|
254
|
+
const mark = () => { if (!document.hidden) void openedCard(id); };
|
|
255
|
+
const timer = setTimeout(mark, READ_AFTER_MS);
|
|
256
|
+
const onShown = () => mark();
|
|
257
|
+
document.addEventListener("visibilitychange", onShown);
|
|
258
|
+
return () => { clearTimeout(timer); document.removeEventListener("visibilitychange", onShown); };
|
|
259
|
+
}, [id, mine ? mine.n : 0, mine ? mine.at : ""]);
|
|
214
260
|
// The page takes the keyboard's place from the tile or row that opened it (once per card: later reads leave the focus be).
|
|
215
261
|
const head = useRef(null);
|
|
216
262
|
const focused = useRef(null);
|
|
@@ -296,6 +342,17 @@ export function CardPage({ id, tick, projects, cards = [], boardOff = [], doing
|
|
|
296
342
|
const fleet = instances.map((i) => i.name);
|
|
297
343
|
const mentionNames = [...(fleet.includes(card.assignee) ? [card.assignee] : []), ...fleet.filter((n) => n !== card.assignee)].map((name) => ({ name, off: boardOff.includes(name) }));
|
|
298
344
|
|
|
345
|
+
// Comment threads: each is one write on one comment (the board's rules say who may), then the card and the board read again; a
|
|
346
|
+
// refusal is said in the page's words. `viewer` (the card read): who this page writes as — their own comments are theirs to edit.
|
|
347
|
+
const thread = {
|
|
348
|
+
writable, viewer: detail.viewer || null,
|
|
349
|
+
send: (text, extra) => run(() => boardApi.update(card.id, { comment: text, ...extra })),
|
|
350
|
+
edit: (entry, text) => run(() => boardApi.commentEdit(card.id, entry.id, text)),
|
|
351
|
+
react: (entry, emoji, on) => run(() => boardApi.commentReact(card.id, entry.id, emoji, on)),
|
|
352
|
+
resolve: (entry, resolved) => run(() => boardApi.commentResolve(card.id, entry.id, resolved)),
|
|
353
|
+
remove: (entry) => run(() => boardApi.commentDelete(card.id, entry.id)),
|
|
354
|
+
};
|
|
355
|
+
|
|
299
356
|
/** Who watches the card: no version (a watch is not an edit of the card), the card and the board read again after. */
|
|
300
357
|
const follow = (change) => run(() => boardApi.watchers(card.id, change));
|
|
301
358
|
|
|
@@ -365,17 +422,23 @@ export function CardPage({ id, tick, projects, cards = [], boardOff = [], doing
|
|
|
365
422
|
<h3>${t("taskcard.subs")}</h3>
|
|
366
423
|
<div class="tc-field-body">
|
|
367
424
|
${prog ? html`<div class="tp-subs-head"><span class="tp-subs-count" title=${t("taskcard.subsDone", prog.done, prog.total)}>${prog.done} / ${prog.total}</span><${ProgressBar} progress=${prog} wide /></div>` : null}
|
|
368
|
-
${children.length ? html
|
|
369
|
-
<${StatusPill} status=${c.status} card=${c} /><span class="tb-code">${c.id}</span><span class="tc-child-title">${c.title}</span><span class="tb-who">${c.assignee || ""}</span></button></li>`)}</ul>` : null}
|
|
425
|
+
${children.length ? html`<${SubRows} children=${children} handoffs=${detail.handoffs} doing=${doing} ready=${ready} onOpen=${onOpen} />` : null}
|
|
370
426
|
${finished || !can ? null : html`<${QuickAdd} placeholder=${t("taskcard.quickAdd")} limit=${LIMIT.title} onAdd=${(title) => run(() => boardApi.create({ parent: card.id, title }))} />`}
|
|
371
427
|
</div>
|
|
372
428
|
</section>` : null;
|
|
373
429
|
|
|
430
|
+
// What the agents are doing on this card (fleet-task-flow.js): a card in progress whose assignee is working — or, for a main task, whose sub
|
|
431
|
+
// task's is — is "Running" beside its status; a main task's "Agent activity" lists what each sub task is doing, and a sub task waiting to
|
|
432
|
+
// start says where its hand-over stands.
|
|
433
|
+
const runNow = runOf(card, { states: instanceStates(appStore.get(), [card.assignee, ...children.map((c) => c.assignee)].filter(Boolean)), doing, ready }, children);
|
|
434
|
+
const flowOn = derived && !finished && hasFlow(children, detail.handoffs, doing, ready);
|
|
435
|
+
const flow = flowOn ? html`<${FlowLines} subs=${children} handoffs=${detail.handoffs} doing=${doing} ready=${ready} onOpen=${onOpen} />` : null;
|
|
436
|
+
const batonLine = !isMain && card.status === "open" ? subLine(card, flowContext([card], detail.handoffs, doing, ready)) : null;
|
|
374
437
|
return html`<div class="tp" ref=${root} data-card=${card.id}>
|
|
375
438
|
${bar({ parent, actions: html`${copyBtn}${blockBtn}${more}` })}
|
|
376
439
|
<div class="tp-grid">
|
|
377
440
|
<div class="tp-head">
|
|
378
|
-
<div class="tp-idrow"><span class="tb-code tp-code">${card.id}</span><${StatusPill} status=${card.status} card=${card} />${detail.archived ? html`<span class="tb-tag" title=${t("tasksArchive.tagTip", detail.archiveAfterDays ?? "")}>${t("tasksArchive.tag")}</span>` : null}
|
|
441
|
+
<div class="tp-idrow"><span class="tb-code tp-code">${card.id}</span><${StatusPill} status=${card.status} card=${card} /><${RunMark} run=${runNow} />${detail.archived ? html`<span class="tb-tag" title=${t("tasksArchive.tagTip", detail.archiveAfterDays ?? "")}>${t("tasksArchive.tag")}</span>` : null}
|
|
379
442
|
${derived && !finished ? html`<span class="tp-derived">${t("taskcard.followsSubs")}</span>` : null}</div>
|
|
380
443
|
<div class="tc-head" ref=${head} tabindex="-1" role="heading" aria-level="2">
|
|
381
444
|
${can ? html`<${InlineTitle} value=${card.title} version=${card.version} limit=${LIMIT.title} onSave=${(title, base) => save({ title }, base)} />` : html`<h2 class="tc-title">${card.title}</h2>`}
|
|
@@ -395,7 +458,7 @@ export function CardPage({ id, tick, projects, cards = [], boardOff = [], doing
|
|
|
395
458
|
<${EditableText} readOnly=${!can} value=${card.blockedReason} limit=${LIMIT.blockedReason} version=${card.version} onSave=${(v, base) => save({ blockedReason: v }, base)} /></${Field}>` : null}
|
|
396
459
|
${spec.shown.length ? html`<div class="tp-spec">${spec.shown}</div>` : null}
|
|
397
460
|
${spec.adders.length ? html`<div class="tp-adders">${spec.adders}</div>` : null}
|
|
398
|
-
<${AgentRun} card=${card} detail=${detail} doing=${doing} derived=${derived} shown=${handoff.shown} adders=${handoff.adders} />
|
|
461
|
+
<${AgentRun} card=${card} detail=${detail} doing=${doing} ready=${ready} derived=${derived} shown=${handoff.shown} adders=${handoff.adders} flow=${flow} flowOn=${flowOn} baton=${batonLine ? batonLine.text : ""} />
|
|
399
462
|
<${FilesField} files=${(detail && detail.attachments) || []} />
|
|
400
463
|
${subs}
|
|
401
464
|
</div>
|
|
@@ -431,9 +494,10 @@ export function CardPage({ id, tick, projects, cards = [], boardOff = [], doing
|
|
|
431
494
|
</aside>
|
|
432
495
|
|
|
433
496
|
<div class="tp-activity">
|
|
434
|
-
<${Timeline} detail=${detail} describe=${describeRow} cards=${cards} lead=${((projects || []).find((x) => x.id === card.projectId) || {}).leadInstance || null} />
|
|
497
|
+
<${Timeline} detail=${detail} describe=${describeRow} cards=${cards} lead=${((projects || []).find((x) => x.id === card.projectId) || {}).leadInstance || null} names=${mentionNames} thread=${thread} fresh=${freshEntries} />
|
|
435
498
|
${can ? html`<${Composer} names=${mentionNames} assignee=${card.assignee} placeholder=${card.assignee ? t("taskcard.commentTo", card.assignee) : t("taskcard.commentHint")}
|
|
436
|
-
|
|
499
|
+
recipients=${recipientsOf(card, detail, mentionNames)}
|
|
500
|
+
onSend=${(text, to, held) => run(() => boardApi.update(card.id, { comment: text, ...(held ? {} : { to: to ? [to] : [] }) }))} />` : null}
|
|
437
501
|
</div>
|
|
438
502
|
</div>
|
|
439
503
|
</div>`;
|
|
@@ -82,6 +82,11 @@ register("tasks", {
|
|
|
82
82
|
// The watchers a card's page sets (fleet-task-follow.js)
|
|
83
83
|
"err.watcher_unknown": "“{0}” is not one of the fleet's instances", "err.watcher_board_off": "{0} has the task board switched off: it cannot read or move cards, so a notice would reach nothing it can act on",
|
|
84
84
|
"err.watchers_max": "{0} can have at most {1} watchers", "err.watch_not_board": "{0} is not a card on the board: only cards can be watched",
|
|
85
|
+
// Comment threads (fleet-task-thread.js)
|
|
86
|
+
"err.comment_not_found": "{0} has no comment {1}", "err.comment_deleted": "Comment {0} was deleted", "err.comment_not_yours": "Only its author can edit comment {0}",
|
|
87
|
+
"err.comment_empty": "A comment cannot be empty", "err.comment_delete_forbidden": "Only its author or a person can delete comment {0}",
|
|
88
|
+
"err.resolve_root_only": "{0} is a reply: resolve the thread by its first comment", "err.reaction_invalid": "A reaction is one emoji",
|
|
89
|
+
"err.reaction_limit": "Comment {0} already has {1} different reactions", "err.reply_needs_comment": "A reply or a recipient goes with a comment",
|
|
85
90
|
"note.review_waiting": "{0} “{1}”: every sub task is done — it waits for your confirmation",
|
|
86
91
|
"note.back_to": "{0} has unfinished sub tasks again: it is back to {1}", "note.deps_done": "{0}'s dependencies are all done: it can start",
|
|
87
92
|
"note.deps_unmet": "Note: {0} not done yet",
|
|
@@ -164,6 +169,10 @@ register("tasks", {
|
|
|
164
169
|
"err.assignee_board_off": "{0} 關閉了任務看板,讀不到也動不了卡片。請先替 {0} 開啟(設定 → 該 Agent → 網頁儀表板權限),或改在聊天中交辦",
|
|
165
170
|
"err.watcher_unknown": "「{0}」不是 fleet 裡的 Agent", "err.watcher_board_off": "{0} 關閉了任務看板,讀不到也動不了卡片,通知送過去它也沒辦法處理",
|
|
166
171
|
"err.watchers_max": "{0} 最多只能有 {1} 個關注者", "err.watch_not_board": "{0} 不是任務板上的卡片,只有任務板上的卡片可以關注",
|
|
172
|
+
"err.comment_not_found": "{0} 沒有留言 {1}", "err.comment_deleted": "留言 {0} 已刪除", "err.comment_not_yours": "留言 {0} 只有作者能編輯",
|
|
173
|
+
"err.comment_empty": "留言不能是空的", "err.comment_delete_forbidden": "留言 {0} 只有作者或人能刪除",
|
|
174
|
+
"err.resolve_root_only": "{0} 是回覆:請對討論串的第一則留言解決", "err.reaction_invalid": "反應只能是一個 emoji",
|
|
175
|
+
"err.reaction_limit": "留言 {0} 已經有 {1} 種不同的反應", "err.reply_needs_comment": "回覆或收件對象要和留言一起送",
|
|
167
176
|
"note.review_waiting": "{0}「{1}」的子任務都完成了,等你確認",
|
|
168
177
|
"note.back_to": "{0} 又有沒完成的子任務,已回到{1}", "note.deps_done": "{0} 的相依都完成了,可以開始",
|
|
169
178
|
"note.deps_unmet": "提醒:{0} 還沒完成",
|
|
@@ -419,6 +428,11 @@ export const boardApi = {
|
|
|
419
428
|
/** Starts and stops instances watching a card (`add`, `remove`: names); a watch is not an edit, so it carries no version. */
|
|
420
429
|
watchers: (id, change) => boardCall("POST", `/ui/tasks/cards/${enc(id)}/watchers`, change),
|
|
421
430
|
reorder: (id, after, before) => boardCall("POST", `/ui/tasks/cards/${enc(id)}/reorder`, { after, before }),
|
|
431
|
+
/** Comment threads: one comment of a card — its author's edit, a reaction (`on: false` takes it back), a thread resolved or opened, a deletion. */
|
|
432
|
+
commentEdit: (id, no, text) => boardCall("POST", `/ui/tasks/cards/${enc(id)}/comments/${no}/edit`, { text }),
|
|
433
|
+
commentReact: (id, no, emoji, on) => boardCall("POST", `/ui/tasks/cards/${enc(id)}/comments/${no}/react`, { emoji, on }),
|
|
434
|
+
commentResolve: (id, no, resolved) => boardCall("POST", `/ui/tasks/cards/${enc(id)}/comments/${no}/resolve`, { resolved }),
|
|
435
|
+
commentDelete: (id, no) => boardCall("POST", `/ui/tasks/cards/${enc(id)}/comments/${no}/delete`, {}),
|
|
422
436
|
search: (q) => boardCall("GET", `/ui/tasks/search?q=${enc(q)}`),
|
|
423
437
|
/** #2246 step 3: each instance's work (its `task mine`), or one instance's. */
|
|
424
438
|
work: (instance) => boardCall("GET", `/ui/tasks/work${instance ? `?instance=${enc(instance)}` : ""}`),
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
// Who has the baton on a main task (Fleet › Tasks › a card; docs/design/task-board.md, "Live state and handoffs"). A main task follows its
|
|
2
|
+
// sub tasks, so its own status says little: "In progress" is a status, not a sign that an agent is working. This page's pieces say what is
|
|
3
|
+
// really happening, one line per sub task, in the person's words (`subLine`: the whole sentence, and a short label for the sub tasks' rows):
|
|
4
|
+
// · a sub task its assignee is working on: what it is doing now — "dev · Edit src/game.js" (the chat's own activity feed, `tool_progress`,
|
|
5
|
+
// an admin only) or, without steps, the state alone — "dev · Running". In the sub tasks' list the row itself says it: its title shimmers
|
|
6
|
+
// (still with reduced motion) and the sentence is the row's tooltip; the steps are the main task's "Agent activity" block's to show;
|
|
7
|
+
// · one waiting for another: "Waits for S-1" — then, when S-1 is done, the baton: "Handed to dev" → "dev read it" → running;
|
|
8
|
+
// · one that cannot go on: blocked, the assignee waiting for the person, looking stuck, idle, offline or paused, or the hand-over that did
|
|
9
|
+
// not arrive (the task board is off, the notice was lost).
|
|
10
|
+
// The same lines summarise the main task's "Agent activity" block (the whole sentence), the other states are a short label in the sub task's own
|
|
11
|
+
// row (no second line), and a handoff is a row of the main task's activity ("S-1 done → handed to dev to start S-2" and how far it got).
|
|
12
|
+
//
|
|
13
|
+
// Nothing here is stored by the page. The state is the same inference as the card's "Running" (`runOf`, fleet-task-run.js — an agent is one
|
|
14
|
+
// continuing session, so "working" says it is busy, not that it is on this very card); the hand-over's delivery is what the card read carries
|
|
15
|
+
// (`handoffs`, only for a session that can write, never of an instance kept out of sight); the steps are the chat's own feed, held only while
|
|
16
|
+
// a sub task is running and the viewer is an admin whose agent has `tool_progress` on — otherwise the state alone. No style attribute (the CSP).
|
|
17
|
+
import { html, useEffect, useState } from "/assets/app-html.js";
|
|
18
|
+
import { t, register } from "/assets/app-i18n.js";
|
|
19
|
+
import { appStore, createStore, useStore } from "/assets/app-store.js";
|
|
20
|
+
import { Icon } from "/assets/ui-icons.js";
|
|
21
|
+
import { activityDrawCtx, activityOffered, activityPrefs, activitySnapshot, observeActivity } from "./chat-activity.js";
|
|
22
|
+
import { stepLine } from "./log-row.js";
|
|
23
|
+
import { StatusPill, relTime, waitsList, waitsOn } from "./fleet-task-common.js";
|
|
24
|
+
import { instanceStates, liveGroupOf, runOf, runUnclaimed } from "./fleet-task-run.js";
|
|
25
|
+
|
|
26
|
+
register("taskflow", {
|
|
27
|
+
en: {
|
|
28
|
+
running: "Running", needs: "waiting for you", stuck: "looks stuck", idle: "idle", busyN: "busy with {0} cards", busyTip: "{0} has {1} cards in progress, so what it is doing now may belong to another of them",
|
|
29
|
+
runningTip: "From {0}'s state: an agent is one continuing session, so it may be busy with something else",
|
|
30
|
+
waitsFor: "Waits for {0}", readyNobody: "Ready to start — nobody is assigned", readyFor: "Ready — {0} has not started it yet", blocked: "Blocked", blockedOn: "Blocked: {0}",
|
|
31
|
+
sending: "Handed to {0}", queued: "Waiting for {0} to take it", offline: "{0} is offline — it gets this when it is back", paused: "{0} is paused — it gets this when it is resumed",
|
|
32
|
+
delivered: "Delivered to {0} — waiting for it to start", read: "{0} read it — waiting for it to start",
|
|
33
|
+
unclaimed: "not claimed yet", unclaimedLate: "still not claimed", unclaimedTip: "{0} is working and this is the card it was given, but it has not moved it to In progress (claimed it): what it is doing now is probably this card.",
|
|
34
|
+
unclaimedLateTip: "{0} has been working for a while without claiming this card. Ask it to claim it (task claim), or move the card to In progress yourself — the board never moves it for an agent.",
|
|
35
|
+
failed: "Could not hand it to {0}", uncertain: "Not sure {0} got it", withdrawn: "The notice to {0} was withdrawn: the card changed again, and {0} hears its new state",
|
|
36
|
+
"skip.board_off": "{0}'s task board is off, so it was not told", "skip.not_taken": "The notice to {0} could not be queued", "skip.lost": "The notice to {0} was lost (AgEnD restarted before it was sent)",
|
|
37
|
+
"skip.other": "{0} was not told",
|
|
38
|
+
handedAfter: "{0} done → handed to {1} to start {2}", handedReady: "{2} can start → handed to {1}", handedAssigned: "{2} handed to {1}", started: "{0} started {1}", startedNeutral: "{0} started",
|
|
39
|
+
handoffLabel: "A sub task handed on", linesLabel: "What the sub tasks are doing", openCard: "Open {0}", more: "+{0} more", tipWorking: "{0} · {1}",
|
|
40
|
+
chipWaits: "Waits for {0}", chipReady: "Ready", chipBlocked: "Blocked", chipNeeds: "Waiting for you", chipStuck: "Looks stuck", chipIdle: "Idle", chipBusy: "Busy · {0} cards",
|
|
41
|
+
chipSending: "Handed to {0}", chipQueued: "Waiting", chipOffline: "{0} offline", chipPaused: "{0} paused", chipDelivered: "Delivered", chipRead: "Read",
|
|
42
|
+
chipFailed: "Not sent", chipUncertain: "Not sure it arrived", chipWithdrawn: "Withdrawn", chipNotTold: "Not told", chipUnclaimed: "Not claimed yet", chipUnclaimedLate: "Still not claimed",
|
|
43
|
+
},
|
|
44
|
+
"zh-TW": {
|
|
45
|
+
running: "執行中", needs: "等你回應", stuck: "似乎卡住", idle: "閒置", busyN: "忙碌中({0} 張卡)", busyTip: "{0} 同時有 {1} 張卡在進行中,目前的動作可能屬於其中另一張",
|
|
46
|
+
runningTip: "由 {0} 目前的狀態推論:Agent 只有一個連續的對話,可能在處理別的事",
|
|
47
|
+
waitsFor: "等 {0}", readyNobody: "可以開始,但還沒有人負責", readyFor: "可以開始,等 {0} 接手", blocked: "卡住了", blockedOn: "卡住:{0}",
|
|
48
|
+
sending: "已交給 {0}", queued: "等 {0} 接手", offline: "{0} 離線,上線後就會收到", paused: "{0} 已暫停,恢復後就會收到",
|
|
49
|
+
delivered: "已送達 {0},等它開始", read: "{0} 已讀,等它開始",
|
|
50
|
+
unclaimed: "尚未認領", unclaimedLate: "還是沒有認領", unclaimedTip: "{0} 正在執行,而這是交給它的卡,但它還沒有把卡片移到進行中(沒有認領):它現在做的很可能就是這張。",
|
|
51
|
+
unclaimedLateTip: "{0} 已經做了一陣子,卻還沒認領這張卡。請它認領(task claim),或你自己把卡片移到進行中——系統不會替 agent 改狀態。",
|
|
52
|
+
failed: "沒有送達 {0}", uncertain: "無法確認 {0} 是否收到", withdrawn: "給 {0} 的通知已撤回:卡片又有變動,{0} 會從新的通知得知最新狀態",
|
|
53
|
+
"skip.board_off": "{0} 的任務板是關閉的,沒有通知它", "skip.not_taken": "給 {0} 的通知沒能排入傳送", "skip.lost": "給 {0} 的通知遺失了(送出前 AgEnD 重新啟動)",
|
|
54
|
+
"skip.other": "沒有通知 {0}",
|
|
55
|
+
handedAfter: "{0} 完成 → 已交給 {1} 開始 {2}", handedReady: "{2} 可以開始 → 已交給 {1}", handedAssigned: "已把 {2} 交給 {1}", started: "{0} 已開始 {1}", startedNeutral: "{0} 已開始",
|
|
56
|
+
handoffLabel: "子任務的交接", linesLabel: "各子任務目前的狀況", openCard: "開啟 {0}", more: "還有 {0} 項", tipWorking: "{0} · {1}",
|
|
57
|
+
chipWaits: "等 {0}", chipReady: "可以開始", chipBlocked: "卡住了", chipNeeds: "等你回應", chipStuck: "似乎卡住", chipIdle: "閒置", chipBusy: "忙碌中({0} 張)",
|
|
58
|
+
chipSending: "已交給 {0}", chipQueued: "等它接手", chipOffline: "{0} 離線", chipPaused: "{0} 已暫停", chipDelivered: "已送達", chipRead: "已讀",
|
|
59
|
+
chipFailed: "沒送達", chipUncertain: "不確定是否送達", chipWithdrawn: "已撤回", chipNotTold: "沒通知到", chipUnclaimed: "尚未認領", chipUnclaimedLate: "還是沒認領",
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// ── What a line says (pure: tests import these) ───────────
|
|
64
|
+
|
|
65
|
+
/** The strongest first, for the main task's summary: working, then what needs a person, then what was handed on, then what is quiet. */
|
|
66
|
+
export const LINE_RANK = { running: 0, needs: 1, stuck: 2, busy: 3, blocked: 4, handed: 5, idle: 6, ready: 7, waiting: 8 };
|
|
67
|
+
/** The notices that are still on their way: the page reads the card again soon while any is. */
|
|
68
|
+
const MOVING = ["sending", "queued", "delivered"];
|
|
69
|
+
/** The reasons a hand-over was not sent that have words of their own; the rest read "{0} was not told". */
|
|
70
|
+
const SKIP_WORDS = new Set(["board_off", "not_taken", "lost"]);
|
|
71
|
+
|
|
72
|
+
/** A card's newest handoff to its current assignee (the page's `handoffs`), or null — an older one to someone else is not the baton now. */
|
|
73
|
+
export function latestHandoff(handoffs, card) {
|
|
74
|
+
let found = null;
|
|
75
|
+
for (const h of handoffs || []) if (h && h.card === card.id && h.to === card.assignee && (!found || h.id > found.id)) found = h;
|
|
76
|
+
return found;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The notice has been taken (or nothing is known of it), so a working instance may be on the card; one still on its way, failed or held back has not got it. */
|
|
80
|
+
export function handoffAllows(h) {
|
|
81
|
+
return !h || h.state === "delivered" || h.state === "read" || h.state === "unknown" || (h.state === "skipped" && h.skip === "not_waiting");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** An instance that has been working this long on a card it has not claimed is flagged: asked to claim, or the person moves it. */
|
|
85
|
+
export const UNCLAIMED_GRACE_MS = 90_000;
|
|
86
|
+
/** While a "not claimed yet" line is on the page it is looked at again this often, so it turns into the flagged one without waiting for the store to change. */
|
|
87
|
+
export const CLOCK_MS = 30_000;
|
|
88
|
+
|
|
89
|
+
/** Redraws the caller every `ms` while `on` — no timer at all otherwise. */
|
|
90
|
+
function useClock(on, ms = CLOCK_MS) {
|
|
91
|
+
const [, tick] = useState(0);
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (!on) return undefined;
|
|
94
|
+
const handle = setInterval(() => tick((n) => n + 1), ms);
|
|
95
|
+
return () => clearInterval(handle);
|
|
96
|
+
}, [on, ms]);
|
|
97
|
+
}
|
|
98
|
+
/** Whether a line says "not claimed yet" and may still turn into the flagged one. */
|
|
99
|
+
const turning = (line) => !!line && line.kind === "running" && !!line.unclaimed && !line.late;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A handoff in words: `{ tone, text, chip, tip? }`, or null when there is nothing to say (the card no longer waited on it, the delivery has no
|
|
103
|
+
* record any more). `chip`: the short label of the sub tasks' rows. `tone`: `wait` (on its way), `ok` (taken), `busy` (its instance is working), `bad` (not sent), `muted` (withdrawn).
|
|
104
|
+
* `states`: the instances' dot states by name (`instanceStates`): offline and paused are the page's inference, as under a comment.
|
|
105
|
+
*/
|
|
106
|
+
export function handoffText(h, states) {
|
|
107
|
+
if (!h) return null;
|
|
108
|
+
const to = h.to;
|
|
109
|
+
const state = states && states.get ? states.get(to) : undefined;
|
|
110
|
+
switch (h.state) {
|
|
111
|
+
case "skipped": return h.skip === "not_waiting" ? null : { tone: "bad", text: t(`taskflow.skip.${SKIP_WORDS.has(h.skip) ? h.skip : "other"}`, to), chip: t("taskflow.chipNotTold") };
|
|
112
|
+
case "failed": return { tone: "bad", text: t("taskflow.failed", to), chip: t("taskflow.chipFailed") };
|
|
113
|
+
case "uncertain": return { tone: "bad", text: t("taskflow.uncertain", to), chip: t("taskflow.chipUncertain") };
|
|
114
|
+
case "withdrawn": return { tone: "muted", text: t("taskflow.withdrawn", to), chip: t("taskflow.chipWithdrawn") };
|
|
115
|
+
case "sending": return { tone: "wait", text: t("taskflow.sending", to), chip: t("taskflow.chipSending", to) };
|
|
116
|
+
case "queued": {
|
|
117
|
+
const off = state === "stopped" || state === "crashed", paused = state === "paused";
|
|
118
|
+
return { tone: "wait", text: t(off ? "taskflow.offline" : paused ? "taskflow.paused" : "taskflow.queued", to), chip: off ? t("taskflow.chipOffline", to) : paused ? t("taskflow.chipPaused", to) : t("taskflow.chipQueued") };
|
|
119
|
+
}
|
|
120
|
+
// (An instance that is working is not "working on this card" here: when it probably is, the card says so as a running line — `subLine`,
|
|
121
|
+
// `runUnclaimed` — and when it cannot be known, the notice's own state is all that is said: never "working" beside "not started".)
|
|
122
|
+
case "delivered": case "read": return { tone: "ok", text: t(h.state === "read" ? "taskflow.read" : "taskflow.delivered", to), chip: t(h.state === "read" ? "taskflow.chipRead" : "taskflow.chipDelivered") };
|
|
123
|
+
default: return null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* What a sub task says, or null: `{ kind, tone, text, chip?, tip?, spin?, who }` — see this file's head. `text` is the whole sentence (the main task's block lists it, the
|
|
129
|
+
* row's tooltip starts with it); `chip` the short label of the row (none for a sub task that is running: its title shimmers); `tip` explains. `ctx`: { handoffs, states, doing, live(name) → the step line }.
|
|
130
|
+
*/
|
|
131
|
+
export function subLine(card, ctx) {
|
|
132
|
+
const who = card.assignee || "";
|
|
133
|
+
if (card.status === "claimed") {
|
|
134
|
+
const run = who ? runOf(card, { states: ctx.states, doing: ctx.doing }) : null;
|
|
135
|
+
if (!run) return null;
|
|
136
|
+
if (run.state === "working" && run.shared) { const text = `${who} · ${t("taskflow.busyN", run.shared)}`; return { kind: "busy", tone: "muted", who, text, chip: t("taskflow.chipBusy", run.shared), tip: `${text}\n${t("taskflow.busyTip", who, run.shared)}` }; }
|
|
137
|
+
if (run.state === "working") {
|
|
138
|
+
const doing = (ctx.live && ctx.live(who)) || "";
|
|
139
|
+
const text = `${who} · ${doing || t("taskflow.running")}`;
|
|
140
|
+
return { kind: "running", tone: "busy", who, spin: true, text, tip: `${text}\n${t("taskflow.runningTip", who)}` };
|
|
141
|
+
}
|
|
142
|
+
if (run.state === "needs") return { kind: "needs", tone: "warn", who, text: `${who} · ${t("taskflow.needs")}`, chip: t("taskflow.chipNeeds") };
|
|
143
|
+
if (run.state === "stuck") return { kind: "stuck", tone: "bad", who, text: `${who} · ${t("taskflow.stuck")}`, chip: t("taskflow.chipStuck") };
|
|
144
|
+
return { kind: "idle", tone: "muted", who, text: `${who} · ${t("taskflow.idle")}`, chip: t("taskflow.chipIdle") };
|
|
145
|
+
}
|
|
146
|
+
if (card.status === "blocked") return { kind: "blocked", tone: "bad", who, text: card.blockedReason ? t("taskflow.blockedOn", card.blockedReason) : t("taskflow.blocked"), chip: t("taskflow.chipBlocked") };
|
|
147
|
+
if (card.status !== "open") return null;
|
|
148
|
+
if (waitsOn(card)) { const list = waitsList(card, ", "); return { kind: "waiting", tone: "wait", who, text: t("taskflow.waitsFor", list), chip: t("taskflow.chipWaits", list) }; }
|
|
149
|
+
if (!who) return { kind: "ready", tone: "wait", who, text: t("taskflow.readyNobody"), chip: t("taskflow.chipReady") };
|
|
150
|
+
const latest = latestHandoff(ctx.handoffs, card);
|
|
151
|
+
// The card is still open, but its assignee is working and probably on it (it was given the card, can start, has nothing in progress): it did not
|
|
152
|
+
// claim it. A running line, with the step, marked "not claimed" — and flagged once it has gone on a while.
|
|
153
|
+
if (handoffAllows(latest) && runUnclaimed(card, ctx)) {
|
|
154
|
+
const doing = (ctx.live && ctx.live(who)) || "";
|
|
155
|
+
const since = Math.max(Date.parse(latest && latest.at) || 0, Date.parse(card.handedAt) || 0, Date.parse(card.updatedAt) || 0);
|
|
156
|
+
const late = since > 0 && (ctx.now || Date.now()) - since > UNCLAIMED_GRACE_MS;
|
|
157
|
+
const text = `${who} · ${doing || t("taskflow.running")} (${t(late ? "taskflow.unclaimedLate" : "taskflow.unclaimed")})`;
|
|
158
|
+
return { kind: "running", tone: late ? "warn" : "busy", who, spin: true, unclaimed: true, late, text, chip: t(late ? "taskflow.chipUnclaimedLate" : "taskflow.chipUnclaimed"),
|
|
159
|
+
tip: `${text}\n${t(late ? "taskflow.unclaimedLateTip" : "taskflow.unclaimedTip", who)}` };
|
|
160
|
+
}
|
|
161
|
+
const said = handoffText(latest, ctx.states);
|
|
162
|
+
return said ? { kind: "handed", who, ...said } : { kind: "ready", tone: "wait", who, text: t("taskflow.readyFor", who), chip: t("taskflow.chipReady") };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** What the main task's block lists: a sub task someone is on, something that needs a person, a hand-over on its way or failed. A sub task that only waits, or is ready with no record of a hand-over, is the list's row, not the block's. */
|
|
166
|
+
const SUMMARISED = new Set(["running", "needs", "stuck", "busy", "blocked", "handed", "idle"]);
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* The lines the main task's "Agent activity" block says: what its sub tasks are doing, the strongest first (running, waiting for you, stuck,
|
|
170
|
+
* busy, blocked, handed on, idle). At most `max`, and how many more there were. `{ lines: [{ card, line }], more }`; no line when nothing is going on
|
|
171
|
+
* (every sub task done, cancelled, waiting, or ready with nobody told) — the block is then its one quiet line.
|
|
172
|
+
*/
|
|
173
|
+
export function mainLines(subs, ctx, max = 4) {
|
|
174
|
+
const all = [];
|
|
175
|
+
for (const card of subs || []) {
|
|
176
|
+
if (card.status === "cancelled" || card.status === "done") continue;
|
|
177
|
+
const line = subLine(card, ctx);
|
|
178
|
+
if (line && SUMMARISED.has(line.kind)) all.push({ card, line });
|
|
179
|
+
}
|
|
180
|
+
const pick = all.map((x, i) => ({ ...x, i })).sort((a, b) => LINE_RANK[a.line.kind] - LINE_RANK[b.line.kind] || a.i - b.i);
|
|
181
|
+
return { lines: pick.slice(0, max).map(({ card, line }) => ({ card, line })), more: Math.max(0, pick.length - max) };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* How a handoff was followed by its card starting: the card's move to in progress at or after it (a sub task's, from the main task's sub events; its own,
|
|
186
|
+
* from its history) — `{ at, by }`, `by` the one who moved it (the instance it was handed to, or someone else) — or null.
|
|
187
|
+
*/
|
|
188
|
+
export function startedAfter(h, detail) {
|
|
189
|
+
const at = Date.parse(h.at) || 0;
|
|
190
|
+
const moves = [];
|
|
191
|
+
for (const e of (detail && detail.subEvents) || []) if (e.card === h.card) moves.push({ at: e.at, by: e.actor, to: e.data && e.data.to });
|
|
192
|
+
if (detail && detail.card && detail.card.id === h.card) for (const e of detail.history || []) if (e.type === "moved") moves.push({ at: e.at, by: e.actor, to: e.data && e.data.to });
|
|
193
|
+
const hit = moves.filter((m) => m.to === "claimed" && (Date.parse(m.at) || 0) >= at - 1000).sort((a, b) => (Date.parse(a.at) || 0) - (Date.parse(b.at) || 0))[0];
|
|
194
|
+
return hit ? { at: hit.at, by: hit.by || "" } : null;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* A handoff as the activity stream says it (pure: tests import it): the sentence — "S-1 done → handed to dev to start S-2" — and, under it,
|
|
199
|
+
* where it stands: the card started (`done`) — "dev started S-2", or just "S-2 started" when someone other than the instance it was handed to moved it
|
|
200
|
+
* (a person, another instance: the page does not say the baton-holder did what it did not) — or what `handoffText` says. `started`: `startedAfter`'s.
|
|
201
|
+
*/
|
|
202
|
+
export function batonOf(h, states, started) {
|
|
203
|
+
const lead = h.why === "assigned" ? t("taskflow.handedAssigned", "", h.to, h.card)
|
|
204
|
+
: h.after ? t("taskflow.handedAfter", h.after, h.to, h.card) : t("taskflow.handedReady", "", h.to, h.card);
|
|
205
|
+
const said = handoffText(h, states); // (its short label is the sub tasks' rows': not here)
|
|
206
|
+
const status = started ? { tone: "done", text: started.by === h.to ? t("taskflow.started", h.to, h.card) : t("taskflow.startedNeutral", h.card) } : said && { tone: said.tone, text: said.text, ...(said.tip ? { tip: said.tip } : {}) };
|
|
207
|
+
return { lead, status };
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Whether any handoff has a notice still on its way, so that the page reads the card again soon (see `wakesMoving`). */
|
|
211
|
+
export function handoffsMoving(detail, now = Date.now()) {
|
|
212
|
+
for (const h of (detail && detail.handoffs) || []) if (MOVING.includes(h.state) && now - (Date.parse(h.at) || 0) <= 3 * 60_000) return true;
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** The instances a card's handoffs were made to, for the page to read their states of. */
|
|
217
|
+
export const handoffNames = (detail) => [...new Set(((detail && detail.handoffs) || []).map((h) => h.to))];
|
|
218
|
+
|
|
219
|
+
// ── The steps of the sub tasks that are running ───────────
|
|
220
|
+
|
|
221
|
+
/** Bumped when a feed read something: what draws a step line redraws (the card page itself does not). */
|
|
222
|
+
export const liveFeeds = createStore({ n: 0 });
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* The line "what it is doing now" of an instance, from the steps the chat's feed holds (`observeActivity`): the newest step the way the chat's
|
|
226
|
+
* activity block says it ("Edit src/game.js"), or the backend's own phase ("Reasoning…") when no call is running. Empty — the state alone — when
|
|
227
|
+
* there is nothing to draw from: not an admin, the agent's tool_progress is off, its backend offers no steps, or nothing was written yet.
|
|
228
|
+
*/
|
|
229
|
+
export function liveLineOf(name) {
|
|
230
|
+
const snap = activitySnapshot(name);
|
|
231
|
+
const group = snap ? liveGroupOf(snap, { since: 0, busy: true }) : null;
|
|
232
|
+
if (!group) return "";
|
|
233
|
+
const draw = activityDrawCtx(name);
|
|
234
|
+
const items = group.items.filter((s) => draw.thinking || s.kind !== "thinking");
|
|
235
|
+
const last = items[items.length - 1];
|
|
236
|
+
const callRunning = !!last && last.kind === "tool" && last.status === "running";
|
|
237
|
+
if (group.phase && !callRunning) { const key = `act.ph_${group.phase}`; const word = t(key); if (word !== key) return word; }
|
|
238
|
+
return last ? stepLine(last, draw.paths) : "";
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Holds the feeds of these instances while they are running a sub task and the viewer may see steps; says nothing itself. */
|
|
242
|
+
export function FeedWatch({ names }) {
|
|
243
|
+
const key = [...new Set(names)].sort().join("\u0000");
|
|
244
|
+
useEffect(() => {
|
|
245
|
+
if (!key) return undefined;
|
|
246
|
+
const feeds = key.split("\u0000").map((name) => observeActivity(name, {
|
|
247
|
+
changed: () => liveFeeds.set((s) => ({ n: s.n + 1 })),
|
|
248
|
+
streamOn: appStore.get().streamOn,
|
|
249
|
+
polling: () => globalThis.document?.body?.dataset?.webTransport === "poll" || appStore.get().connection === "polling",
|
|
250
|
+
wantThinking: () => activityPrefs.get().thinking,
|
|
251
|
+
working: () => true,
|
|
252
|
+
}));
|
|
253
|
+
for (const f of feeds) f.start();
|
|
254
|
+
return () => { for (const f of feeds) f.stop(); };
|
|
255
|
+
}, [key]);
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* The context the lines are drawn from: the sub tasks' `handoffs`, their instances' states (read now: the page draws again with the store), how
|
|
261
|
+
* many cards each has in progress and which open cards it could start (`doing`, `ready`: the board's), and the step line of a running one (only when this viewer is offered steps).
|
|
262
|
+
*/
|
|
263
|
+
export function flowContext(subs, handoffs, doing, ready = null) {
|
|
264
|
+
const names = [...new Set((subs || []).map((c) => c.assignee).filter(Boolean))];
|
|
265
|
+
const offered = activityOffered() && activityPrefs.get().on;
|
|
266
|
+
return { handoffs: handoffs || [], states: instanceStates(appStore.get(), names), doing, ready, live: offered ? liveLineOf : () => "", now: Date.now() };
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** The instances whose steps this page should hold: those running a sub task (and not shared with another card), when steps are offered. */
|
|
270
|
+
export function watchedNames(subs, ctx) {
|
|
271
|
+
if (!(activityOffered() && activityPrefs.get().on)) return [];
|
|
272
|
+
return (subs || []).filter((c) => { const l = subLine(c, { ...ctx, live: () => "" }); return !!l && l.kind === "running"; }).map((c) => c.assignee);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// ── What is drawn ─────────────────────────────────────────
|
|
276
|
+
|
|
277
|
+
const ICON = { wait: "clock", ok: "check", done: "check", busy: "clock", bad: "alert", warn: "alert", muted: "info" };
|
|
278
|
+
|
|
279
|
+
/** One line's content: a turning ring while it is running, an icon otherwise, then the words (the whole text in the tooltip). */
|
|
280
|
+
export function LineBody({ line }) {
|
|
281
|
+
return html`${line.spin ? html`<span class="out-spin tf-spin" aria-hidden="true"></span>` : html`<${Icon} name=${line.kind === "handed" ? "forward" : ICON[line.tone] || "info"} size=${13} />`}<span class="tf-says">${line.text}</span>`;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** The short label beside a sub task's title (inside the row's button: the whole row opens the card); the whole sentence is the row's tooltip. */
|
|
285
|
+
export function RowChip({ line }) {
|
|
286
|
+
if (!line || !line.chip) return null;
|
|
287
|
+
return html`<span class=${`tf-chip tf-${line.tone}`}>${line.chip}</span>`;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* The sub tasks list: a row each of status, number, title and who. What is happening is in the row — no second line: a sub task its agent is running
|
|
292
|
+
* has its title shimmer (still with reduced motion; the row is tinted as a running board row is), any other state is a short label beside the title, and the
|
|
293
|
+
* whole sentence (with the step, for an admin whose agent has tool progress on) is the row's tooltip. While a sub task is running and steps are offered,
|
|
294
|
+
* the page holds its instance's feed (`FeedWatch`) — the main task's "Agent activity" block shows the steps. `children`: the card read's sub tasks; `handoffs`: the card read's.
|
|
295
|
+
*/
|
|
296
|
+
export function SubRows({ children, handoffs, doing, ready = null, onOpen }) {
|
|
297
|
+
useStore(appStore);
|
|
298
|
+
useStore(liveFeeds);
|
|
299
|
+
const ctx = flowContext(children, handoffs, doing, ready);
|
|
300
|
+
const lines = children.map((c) => subLine(c, ctx));
|
|
301
|
+
useClock(lines.some(turning));
|
|
302
|
+
return html`<${FeedWatch} names=${watchedNames(children, ctx)} />
|
|
303
|
+
<ul class="tc-children">${children.map((c, i) => {
|
|
304
|
+
const line = lines[i], running = !!line && line.kind === "running";
|
|
305
|
+
return html`<li key=${c.id}><button type="button" class=${running ? "is-running" : undefined} title=${line ? line.tip || line.text : undefined} data-line=${line ? line.kind : undefined} onClick=${() => onOpen(c.id)}>
|
|
306
|
+
<${StatusPill} status=${c.status} card=${c} /><span class="tb-code">${c.id}</span>
|
|
307
|
+
<span class="tc-child-title"><span class=${running ? "tf-shimmer" : undefined}>${c.title}</span><${RowChip} line=${line} /></span><span class="tb-who">${c.assignee || ""}</span></button></li>`;
|
|
308
|
+
})}</ul>`;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** The main task's "Agent activity" lines: one per sub task that has something going on, the sub task's number opens it. */
|
|
312
|
+
export function FlowLines({ subs, handoffs, doing, ready = null, onOpen }) {
|
|
313
|
+
useStore(liveFeeds);
|
|
314
|
+
const ctx = flowContext(subs, handoffs, doing, ready);
|
|
315
|
+
const { lines, more } = mainLines(subs, ctx);
|
|
316
|
+
useClock(lines.some((x) => turning(x.line)));
|
|
317
|
+
if (!lines.length) return null;
|
|
318
|
+
return html`<ul class="tf-lines" aria-label=${t("taskflow.linesLabel")}>${lines.map(({ card, line }) => html`<li key=${card.id} class=${`tf-item tf-${line.tone} tf-k-${line.kind}`} title=${line.tip || line.text}>
|
|
319
|
+
<${LineBody} line=${line} /><button type="button" class="tb-link tb-code tf-card" title=${t("taskflow.openCard", card.id)} onClick=${() => onOpen(card.id)}>${card.id}</button></li>`)}
|
|
320
|
+
${more ? html`<li class="tf-extra muted">${t("taskflow.more", more)}</li>` : null}</ul>`;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** Whether the main task has lines to show, for its block to open (the block itself draws `FlowLines`). */
|
|
324
|
+
export const hasFlow = (subs, handoffs, doing, ready = null) => mainLines(subs, flowContext(subs, handoffs, doing, ready)).lines.length > 0;
|
|
325
|
+
|
|
326
|
+
/** A handoff in the activity stream: a row that is never folded away — the sentence, its time, and where it stands under it. */
|
|
327
|
+
export function BatonEntry({ entry, states, runFor = null }) {
|
|
328
|
+
useStore(liveFeeds); // the step line moves with the feed: only this row redraws, not the stream
|
|
329
|
+
const run = runFor ? runFor(entry) : null;
|
|
330
|
+
useClock(turning(run));
|
|
331
|
+
const { lead, status: handed } = batonOf(entry.h, states, entry.started);
|
|
332
|
+
// The card is still open but its agent is running on it (not claimed): the row says so, with the step, instead of where the notice stands.
|
|
333
|
+
const status = !entry.started && run ? { tone: run.tone, text: run.text, tip: run.tip, spin: true } : handed;
|
|
334
|
+
return html`<li class="tl-item tl-baton" data-baton=${entry.h.card} aria-label=${t("taskflow.handoffLabel")}>
|
|
335
|
+
<div class="tl-line"><span class="tl-mark" aria-hidden="true"><${Icon} name="forward" size=${14} /></span>
|
|
336
|
+
<span class="tl-sentence">${lead}</span>
|
|
337
|
+
<time class="muted tl-time" dateTime=${entry.at}>${relTime(entry.at)}</time></div>
|
|
338
|
+
${status ? html`<ul class="tl-wakes tf-wakes"><li class=${`tl-wake wk-${status.tone}`} title=${status.tip || undefined}>${status.spin ? html`<span class="out-spin tf-spin" aria-hidden="true"></span>` : html`<${Icon} name=${ICON[status.tone] || "info"} size=${13} cls=${status.tone === "busy" ? "wk-spin" : ""} />`}<span>${status.text}</span></li></ul>` : null}
|
|
339
|
+
</li>`;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* The running line of the card a handoff row is about, when that is its newest handoff to its current assignee and the assignee is running on it
|
|
344
|
+
* without having claimed it (`subLine`'s running, unclaimed) — else null. The card is the card read's own or one of its children.
|
|
345
|
+
*/
|
|
346
|
+
export function batonRun(h, detail, doing, ready) {
|
|
347
|
+
const card = detail && (detail.card && detail.card.id === h.card ? detail.card : ((detail.children || []).find((c) => c.id === h.card) || null));
|
|
348
|
+
if (!card || card.status !== "open") return null;
|
|
349
|
+
const latest = latestHandoff(detail.handoffs, card);
|
|
350
|
+
if (!latest || latest.id !== h.id) return null;
|
|
351
|
+
const line = subLine(card, flowContext([card], detail.handoffs, doing, ready));
|
|
352
|
+
return line && line.kind === "running" && line.unclaimed ? line : null;
|
|
353
|
+
}
|
package/dist/ui/fleet-task-md.js
CHANGED
|
@@ -14,7 +14,7 @@ export const commentHtml = (text) => {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
/** The chat's copy: the clipboard, else a hidden text area (a plain-http page has no clipboard API). */
|
|
17
|
-
async function copyText(text) {
|
|
17
|
+
export async function copyText(text) {
|
|
18
18
|
try { if (navigator.clipboard && globalThis.isSecureContext) { await navigator.clipboard.writeText(text); return true; } } catch { /* fall back */ }
|
|
19
19
|
const ta = document.createElement("textarea"); ta.value = text; ta.setAttribute("readonly", ""); ta.className = "offscreen";
|
|
20
20
|
document.body.appendChild(ta); ta.select();
|