@songsid/agend 2.4.0-beta.22 → 2.4.0-beta.24
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 +4 -3
- package/dist/agent-cli.js +32 -2
- package/dist/agent-cli.js.map +1 -1
- package/dist/agent-file-read.js +2 -2
- package/dist/agent-file-read.js.map +1 -1
- package/dist/agent-whats-new.js +17 -1
- package/dist/agent-whats-new.js.map +1 -1
- package/dist/auth-api.d.ts +2 -0
- package/dist/auth-api.js +5 -2
- package/dist/auth-api.js.map +1 -1
- package/dist/authority/web-authority.d.ts +17 -3
- package/dist/authority/web-authority.js +56 -3
- package/dist/authority/web-authority.js.map +1 -1
- package/dist/backend/claude-code.d.ts +15 -0
- package/dist/backend/claude-code.js +8 -3
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/claude-mcp-carry.d.ts +63 -0
- package/dist/backend/claude-mcp-carry.js +242 -0
- package/dist/backend/claude-mcp-carry.js.map +1 -0
- package/dist/build-provenance.json +1 -1
- package/dist/channel/mcp-tools.js +15 -7
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/classic-channel-manager.d.ts +1 -1
- package/dist/classic-channel-manager.js +2 -2
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/config-validator.js +6 -0
- package/dist/config-validator.js.map +1 -1
- package/dist/contact-auth-api.js +3 -1
- package/dist/contact-auth-api.js.map +1 -1
- package/dist/contact-auth-service.js +1 -1
- package/dist/contact-auth-service.js.map +1 -1
- package/dist/contact-auth-store.d.ts +28 -2
- package/dist/contact-auth-store.js +72 -4
- package/dist/contact-auth-store.js.map +1 -1
- package/dist/contact-change-proposals.d.ts +18 -1
- package/dist/contact-change-proposals.js +38 -4
- package/dist/contact-change-proposals.js.map +1 -1
- package/dist/contact-state-view.d.ts +103 -0
- package/dist/contact-state-view.js +80 -0
- package/dist/contact-state-view.js.map +1 -0
- package/dist/daemon.d.ts +11 -0
- package/dist/daemon.js +66 -15
- package/dist/daemon.js.map +1 -1
- package/dist/dashboard-permissions.d.ts +8 -0
- package/dist/dashboard-permissions.js +8 -0
- package/dist/dashboard-permissions.js.map +1 -1
- package/dist/delivery-outbox.d.ts +15 -1
- package/dist/delivery-outbox.js +60 -2
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/fleet-manager.d.ts +157 -15
- package/dist/fleet-manager.js +522 -78
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/admin/SKILL.md +52 -0
- package/dist/general-knowledge/skills/concepts/SKILL.md +31 -21
- package/dist/general-knowledge/skills/credential-profiles/SKILL.md +6 -0
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +6 -3
- package/dist/general-knowledge/skills/fleet-config/SKILL.md +3 -3
- package/dist/general-knowledge/skills/hub/SKILL.md +6 -1
- package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +1 -1
- package/dist/general-knowledge/skills/task-board/SKILL.md +17 -0
- package/dist/general-knowledge/skills/web-appearance/SKILL.md +4 -0
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +75 -12
- package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +1 -1
- package/dist/general-role.d.ts +1 -1
- package/dist/general-role.js +1 -0
- package/dist/general-role.js.map +1 -1
- package/dist/hub/client.js +6 -1
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.d.ts +2 -1
- package/dist/hub/compose/member.js +3 -2
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.js +2 -1
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/http/compose.js +5 -0
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/protocol.d.ts +21 -0
- package/dist/hub/protocol.js +3 -0
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/question-close-model.d.ts +17 -0
- package/dist/hub/question-close-model.js +7 -0
- package/dist/hub/question-close-model.js.map +1 -0
- package/dist/hub/representative.d.ts +5 -0
- package/dist/hub/representative.js +51 -1
- package/dist/hub/representative.js.map +1 -1
- package/dist/hub/rooms/direct-view.js +1 -0
- package/dist/hub/rooms/direct-view.js.map +1 -1
- package/dist/hub/rooms/types.d.ts +1 -1
- package/dist/hub/rooms.d.ts +3 -0
- package/dist/hub/rooms.js +27 -1
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/server.js +6 -1
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/types.d.ts +2 -2
- package/dist/human-delivery-receipts.d.ts +12 -2
- package/dist/human-delivery-receipts.js +19 -4
- package/dist/human-delivery-receipts.js.map +1 -1
- package/dist/instance-lifecycle.d.ts +2 -0
- package/dist/instance-lifecycle.js +29 -1
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instructions.d.ts +1 -1
- package/dist/instructions.js +1 -1
- package/dist/instructions.js.map +1 -1
- package/dist/locale.js +110 -12
- package/dist/locale.js.map +1 -1
- package/dist/needs-you-hub.d.ts +3 -0
- package/dist/needs-you-hub.js +31 -5
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +16 -1
- package/dist/needs-you.js +7 -1
- package/dist/needs-you.js.map +1 -1
- package/dist/office-share-page.js +2 -2
- package/dist/office-share-page.js.map +1 -1
- package/dist/office-share.js +2 -1
- package/dist/office-share.js.map +1 -1
- package/dist/outbound-handlers.d.ts +4 -0
- package/dist/outbound-handlers.js +69 -11
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +5 -1
- package/dist/outbound-schemas.js +10 -7
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/public-web-gateway.js +21 -0
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/reply-buttons-controller.d.ts +2 -1
- package/dist/reply-buttons-controller.js +1 -1
- package/dist/reply-buttons-controller.js.map +1 -1
- package/dist/request-context-compatibility.d.ts +20 -0
- package/dist/request-context-compatibility.js +74 -0
- package/dist/request-context-compatibility.js.map +1 -0
- package/dist/request-context-protocol.d.ts +137 -0
- package/dist/request-context-protocol.js +38 -0
- package/dist/request-context-protocol.js.map +1 -0
- package/dist/request-context-store.d.ts +25 -0
- package/dist/request-context-store.js +137 -0
- package/dist/request-context-store.js.map +1 -0
- package/dist/scheduler/db.js +26 -0
- package/dist/scheduler/db.js.map +1 -1
- package/dist/scheduler/task-board-text.d.ts +2 -0
- package/dist/scheduler/task-board-text.js +12 -0
- package/dist/scheduler/task-board-text.js.map +1 -1
- package/dist/scheduler/task-board.d.ts +102 -2
- package/dist/scheduler/task-board.js +242 -24
- package/dist/scheduler/task-board.js.map +1 -1
- package/dist/scheduler/task-files.d.ts +80 -0
- package/dist/scheduler/task-files.js +357 -0
- package/dist/scheduler/task-files.js.map +1 -0
- package/dist/settings-api.d.ts +2 -0
- package/dist/settings-api.js +6 -1
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-baseline.d.ts +1 -0
- package/dist/settings-baseline.js +1 -1
- package/dist/settings-baseline.js.map +1 -1
- package/dist/settings-effect.d.ts +2 -0
- package/dist/settings-effect.js +5 -1
- package/dist/settings-effect.js.map +1 -1
- package/dist/task-attach-client.d.ts +43 -0
- package/dist/task-attach-client.js +125 -0
- package/dist/task-attach-client.js.map +1 -0
- package/dist/task-board-tool.d.ts +12 -0
- package/dist/task-board-tool.js +107 -6
- package/dist/task-board-tool.js.map +1 -1
- package/dist/task-file-limits.d.ts +15 -0
- package/dist/task-file-limits.js +21 -0
- package/dist/task-file-limits.js.map +1 -0
- package/dist/tool-permissions.d.ts +32 -0
- package/dist/tool-permissions.js +64 -1
- package/dist/tool-permissions.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/ui/accounts-keepalive.js +2 -1
- package/dist/ui/agent-details-settings.js +7 -5
- package/dist/ui/agent-who-can-use-strings.js +125 -0
- package/dist/ui/agent-who-can-use.js +238 -0
- package/dist/ui/chat-activity.js +2 -1
- package/dist/ui/chat-pins.js +2 -1
- package/dist/ui/claude-credentials.js +2 -1
- package/dist/ui/contact-auth-strings.js +28 -17
- package/dist/ui/contact-authorizations.js +6 -4
- package/dist/ui/contact-needs.js +6 -1
- package/dist/ui/contact-permissions.js +6 -4
- package/dist/ui/contact-tool-groups.js +1 -1
- package/dist/ui/contact-verify-need.js +46 -0
- package/dist/ui/fleet-cache.js +2 -1
- package/dist/ui/fleet-office-card.js +23 -5
- package/dist/ui/fleet-office-editor.js +5 -5
- package/dist/ui/fleet-office-pack.d.ts +10 -0
- package/dist/ui/fleet-office-pack.js +65 -2
- package/dist/ui/fleet-office-skin.js +52 -14
- package/dist/ui/fleet-office-store.js +33 -2
- package/dist/ui/fleet-office-vehicles.js +130 -0
- package/dist/ui/fleet-office-zones.js +27 -10
- package/dist/ui/fleet-office.js +128 -40
- package/dist/ui/fleet-org.js +6 -1
- package/dist/ui/fleet-tab-icons.js +19 -0
- package/dist/ui/fleet-task-activity.js +11 -83
- package/dist/ui/fleet-task-archive.js +111 -0
- package/dist/ui/fleet-task-card.js +6 -4
- package/dist/ui/fleet-task-common.js +2 -2
- package/dist/ui/fleet-task-edit.js +8 -1
- package/dist/ui/fleet-task-files.js +196 -0
- package/dist/ui/fleet-task-md.js +98 -0
- package/dist/ui/fleet-task-menu.js +1 -1
- package/dist/ui/fleet-task-stats.js +2 -2
- package/dist/ui/fleet-task-view.js +14 -9
- package/dist/ui/fleet-tasks.js +42 -18
- package/dist/ui/fleet-usage.js +2 -1
- package/dist/ui/hub-admin-overview.js +2 -1
- package/dist/ui/hub-agent-intro.js +2 -1
- package/dist/ui/hub-assistant-admin.js +2 -1
- package/dist/ui/hub-directory-notices.js +2 -1
- package/dist/ui/hub-enrolment-code.js +2 -1
- package/dist/ui/hub-my-agents.js +2 -1
- package/dist/ui/hub-quick-pairing.js +2 -1
- package/dist/ui/hub-role-audit.js +2 -1
- package/dist/ui/hub-role-forms.js +3 -2
- package/dist/ui/hub-role-view.js +3 -2
- package/dist/ui/hub-roles.js +2 -1
- package/dist/ui/hub-room-agent-strings.js +2 -1
- package/dist/ui/hub-room-list.js +2 -1
- package/dist/ui/hub-room-owner-requests.js +2 -1
- package/dist/ui/hub-room-pins.js +2 -1
- package/dist/ui/hub-room-strings.js +2 -2
- package/dist/ui/hub-room-thread.js +1 -1
- package/dist/ui/log-row.js +4 -3
- package/dist/ui/office-share-dialog.js +2 -1
- package/dist/ui/office-share-page.js +2 -1
- package/dist/ui/page-share-dialog.js +3 -2
- package/dist/ui/panel-chat.js +2 -1
- package/dist/ui/panel-details.js +5 -2
- package/dist/ui/panel-fleet.js +10 -5
- package/dist/ui/panel-hub.js +2 -1
- package/dist/ui/panel-needs.js +34 -6
- package/dist/ui/panel-notices.js +2 -1
- package/dist/ui/panel-runtimes.js +2 -1
- package/dist/ui/panel-settings.js +15 -1
- package/dist/ui/panel-windows-cli.js +3 -2
- package/dist/ui/runtime-cli-install.js +2 -1
- package/dist/ui/settings-appearance.js +2 -1
- package/dist/ui/settings-guests.js +4 -3
- package/dist/ui/settings-hub-member-address.js +2 -1
- package/dist/ui/settings-hub-setup.js +2 -1
- package/dist/ui/settings-hub-web-address.js +2 -1
- package/dist/ui/settings-hub.js +2 -1
- package/dist/ui/settings-registry.js +1 -0
- package/dist/ui/settings-shared-strings.js +9 -0
- package/dist/ui/settings-shared.js +6 -1
- package/dist/ui/settings-update.js +2 -1
- package/dist/ui/settings-web-authority.js +2 -1
- package/dist/ui/shared/agent-sheet.js +2 -1
- package/dist/ui/shared/app-i18n.js +2 -2
- package/dist/ui/shared/app-needs.js +8 -1
- package/dist/ui/shared/app-session.js +4 -3
- package/dist/ui/shared/app-shell.js +6 -2
- package/dist/ui/shared/app.css +93 -11
- package/dist/ui/shared/chat-strings.js +4 -4
- package/dist/ui/shared/chat-time.js +7 -4
- package/dist/ui/shared/clock-text.js +57 -0
- package/dist/ui/shared/device-roles.js +6 -5
- package/dist/ui/shared/instance-nav.js +17 -22
- package/dist/ui/shared/task-board.css +64 -0
- package/dist/ui/shared/usage-dialog.js +2 -1
- package/dist/ui/shared/view-strings.js +0 -14
- package/dist/ui/shared/web-authorize.js +3 -2
- package/dist/ui/subagent-row.js +2 -1
- package/dist/web-api.d.ts +18 -2
- package/dist/web-api.js +159 -27
- package/dist/web-api.js.map +1 -1
- package/dist/web-login.d.ts +6 -1
- package/dist/web-login.js +8 -3
- package/dist/web-login.js.map +1 -1
- package/dist/web-office-acts.d.ts +16 -0
- package/dist/web-office-acts.js +27 -9
- package/dist/web-office-acts.js.map +1 -1
- package/dist/web-office-pack-read.js +1 -1
- package/dist/web-office-pack-read.js.map +1 -1
- package/dist/web-office-skins.d.ts +5 -3
- package/dist/web-office-skins.js +20 -16
- package/dist/web-office-skins.js.map +1 -1
- package/dist/web-session-authorization.d.ts +3 -0
- package/dist/web-session-authorization.js +1 -1
- package/dist/web-session-authorization.js.map +1 -1
- package/dist/web-settings-patch.d.ts +27 -0
- package/dist/web-settings-patch.js +67 -0
- package/dist/web-settings-patch.js.map +1 -1
- package/dist/workflow-templates/default.md +1 -0
- package/package.json +1 -1
|
@@ -19,6 +19,12 @@ import { BoardOffNote, boardOffTargets, relTime } from "./fleet-task-common.js";
|
|
|
19
19
|
import { AgentTag } from "./fleet-task-run.js";
|
|
20
20
|
import { WhoCard } from "./fleet-task-owner.js";
|
|
21
21
|
import { insertAtTrigger, triggerAt, withoutCode } from "./trigger-complete.js";
|
|
22
|
+
import { dateTimeText } from "/assets/clock-text.js";
|
|
23
|
+
import { FileList } from "./fleet-task-files.js";
|
|
24
|
+
import { MdBody, commentHtml, decorateCode, storedWrap } from "./fleet-task-md.js";
|
|
25
|
+
|
|
26
|
+
// The Markdown pieces moved to fleet-task-md.js (the card's fields draw them too); these stay importable from here.
|
|
27
|
+
export { MdBody, commentHtml, decorateCode };
|
|
22
28
|
|
|
23
29
|
export const TIMELINE_FILTERS = ["all", "comments", "log", "history"];
|
|
24
30
|
const RANK = { event: 0, log: 1, comment: 2 }; // at one instant: the move first, then the words that came with it
|
|
@@ -33,7 +39,8 @@ const when = (iso) => { const n = Date.parse(iso); return Number.isFinite(n) ? n
|
|
|
33
39
|
*/
|
|
34
40
|
export function timelineOf(detail) {
|
|
35
41
|
const out = [];
|
|
36
|
-
|
|
42
|
+
const files = (detail && detail.attachments) || [];
|
|
43
|
+
for (const e of (detail && detail.comments) || []) out.push({ key: `c${e.id}`, type: "comment", at: e.at, who: e.author, by: e.authorKind || "", text: e.text, kind: e.kind, authorKind: e.authorKind, files: files.filter((f) => f.entryId === e.id) });
|
|
37
44
|
for (const e of (detail && detail.logs) || []) out.push({ key: `l${e.id}`, type: "log", at: e.at, who: e.author, by: e.authorKind || "", text: e.text });
|
|
38
45
|
for (const ev of (detail && detail.history) || []) {
|
|
39
46
|
if (ev.type === "commented" || ev.type === "reordered") continue;
|
|
@@ -77,7 +84,7 @@ export const insertMention = (text, m, caret, name, names = []) => insertAtTrigg
|
|
|
77
84
|
|
|
78
85
|
// ── The timeline ──────────────────────────────────────────
|
|
79
86
|
|
|
80
|
-
const fullTime = (iso) => { const d = new Date(iso); return Number.isFinite(d.getTime()) ? d
|
|
87
|
+
const fullTime = (iso) => { const d = new Date(iso); return Number.isFinite(d.getTime()) ? dateTimeText(d) : ""; };
|
|
81
88
|
|
|
82
89
|
/**
|
|
83
90
|
* A run of the same history line from the same hand ("web-user changed acceptance" three times in a row) is one entry with a
|
|
@@ -115,12 +122,6 @@ export function dayLabel(iso, now = Date.now()) {
|
|
|
115
122
|
return d.toLocaleDateString(lang() === "zh-TW" ? "zh-TW" : "en-US", { weekday: "short", month: "short", day: "numeric", ...(sameYear ? {} : { year: "numeric" }) });
|
|
116
123
|
}
|
|
117
124
|
|
|
118
|
-
/** A comment's text as the chat draws a message (Markdown, escaped first); the plain text when the renderer is not there. */
|
|
119
|
-
const commentHtml = (text) => {
|
|
120
|
-
const r = globalThis.AgendChatRender;
|
|
121
|
-
return r && typeof r.renderMarkdown === "function" ? { __html: r.renderMarkdown(text) } : null;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
125
|
/**
|
|
125
126
|
* The stream's items (pure: tests import it): what people and agents SAY — a comment, a progress note — is a card each; the
|
|
126
127
|
* system's lines (history) between two cards are a run, of any length, and a run is folded into one "› N activities" row at first
|
|
@@ -142,80 +143,6 @@ export function streamOf(entries, group = true) {
|
|
|
142
143
|
|
|
143
144
|
const timeOf = (entry) => html`<time class="muted tl-time" dateTime=${entry.at} title=${fullTime(entry.at)}>${relTime(entry.at)}</time>`;
|
|
144
145
|
|
|
145
|
-
// ── A comment's text as the chat draws a message ─────────────
|
|
146
|
-
|
|
147
|
-
/** The chat's copy: the clipboard, else a hidden text area (a plain-http page has no clipboard API). */
|
|
148
|
-
async function copyText(text) {
|
|
149
|
-
try { if (navigator.clipboard && globalThis.isSecureContext) { await navigator.clipboard.writeText(text); return true; } } catch { /* fall back */ }
|
|
150
|
-
const ta = document.createElement("textarea"); ta.value = text; ta.setAttribute("readonly", ""); ta.className = "offscreen";
|
|
151
|
-
document.body.appendChild(ta); ta.select();
|
|
152
|
-
let ok = false; try { ok = document.execCommand("copy"); } catch { ok = false; }
|
|
153
|
-
ta.remove();
|
|
154
|
-
return ok;
|
|
155
|
-
}
|
|
156
|
-
const storedWrap = () => { try { return localStorage.getItem("agend_code_wrap") === "1"; } catch { return false; } };
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Code blocks as the chat's thread draws them (chat-thread.js `decorateCode`, the same classes, so the same sheet styles them):
|
|
160
|
-
* a header with the language, Wrap and Copy, and a block of more than CODE_FOLD_LINES lines folded until opened. Built from nodes.
|
|
161
|
-
*/
|
|
162
|
-
export function decorateCode(root) {
|
|
163
|
-
if (!root || typeof root.querySelectorAll !== "function") return;
|
|
164
|
-
const doc = root.ownerDocument;
|
|
165
|
-
const R = globalThis.AgendChatRender;
|
|
166
|
-
const limit = R && Number.isFinite(R.CODE_FOLD_LINES) ? R.CODE_FOLD_LINES : 30;
|
|
167
|
-
const lineCount = R && typeof R.lineCount === "function" ? R.lineCount : (c) => String(c).split("\n").length;
|
|
168
|
-
for (const pre of root.querySelectorAll("pre")) {
|
|
169
|
-
if (pre.parentNode && pre.parentNode.classList && pre.parentNode.classList.contains("codeblock")) continue;
|
|
170
|
-
const box = doc.createElement("div"); box.className = "codeblock";
|
|
171
|
-
const head = doc.createElement("div"); head.className = "cb-head";
|
|
172
|
-
const lang = doc.createElement("span"); lang.className = "cb-lang"; lang.textContent = pre.dataset.lang || "text";
|
|
173
|
-
const wrap = doc.createElement("button"); wrap.type = "button"; wrap.className = "chip-btn"; wrap.dataset.act = "toggleWrap"; wrap.textContent = t("chat.wrap");
|
|
174
|
-
const copy = doc.createElement("button"); copy.type = "button"; copy.className = "chip-btn"; copy.dataset.act = "copyCode"; copy.textContent = t("chat.copy");
|
|
175
|
-
head.append(lang, wrap, copy);
|
|
176
|
-
pre.replaceWith(box); box.append(head, pre);
|
|
177
|
-
const lines = lineCount(pre.textContent);
|
|
178
|
-
if (lines > limit) {
|
|
179
|
-
box.classList.add("folded");
|
|
180
|
-
const more = doc.createElement("button"); more.type = "button"; more.className = "cb-more"; more.dataset.act = "toggleFold";
|
|
181
|
-
more.dataset.lines = String(lines); more.textContent = t("chat.showAll", lines);
|
|
182
|
-
box.append(more);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/** A click on one of a decorated block's buttons (Copy, Wrap, Show all), as the chat's thread answers it. */
|
|
188
|
-
async function onCodeClick(e) {
|
|
189
|
-
const el = e.target && e.target.closest ? e.target.closest("[data-act]") : null;
|
|
190
|
-
if (!el) return;
|
|
191
|
-
const act = el.dataset.act;
|
|
192
|
-
if (act === "copyCode") {
|
|
193
|
-
const pre = el.closest(".codeblock") && el.closest(".codeblock").querySelector("pre");
|
|
194
|
-
if (!pre) return;
|
|
195
|
-
const ok = await copyText(pre.textContent);
|
|
196
|
-
const was = el.dataset.label || el.textContent; el.dataset.label = was;
|
|
197
|
-
el.textContent = t(ok ? "chat.copied" : "chat.copyFailed");
|
|
198
|
-
setTimeout(() => { el.textContent = was; }, 1200);
|
|
199
|
-
} else if (act === "toggleWrap") {
|
|
200
|
-
const stream = el.closest(".tl");
|
|
201
|
-
if (!stream) return;
|
|
202
|
-
const on = stream.classList.toggle("wrap-code");
|
|
203
|
-
try { localStorage.setItem("agend_code_wrap", on ? "1" : "0"); } catch { /* this page only */ }
|
|
204
|
-
} else if (act === "toggleFold") {
|
|
205
|
-
const box = el.closest(".codeblock");
|
|
206
|
-
if (!box) return;
|
|
207
|
-
const folded = box.classList.toggle("folded");
|
|
208
|
-
el.textContent = !folded ? t("chat.showLess") : t("chat.showAll", el.dataset.lines);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/** A comment's body: the chat's Markdown, its code blocks decorated as the chat's are. */
|
|
213
|
-
function MdBody({ body }) {
|
|
214
|
-
const ref = useRef(null);
|
|
215
|
-
useEffect(() => { decorateCode(ref.current); });
|
|
216
|
-
return html`<div class="tl-body md" ref=${ref} onClick=${onCodeClick} dangerouslySetInnerHTML=${body}></div>`;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
146
|
/**
|
|
220
147
|
* One entry. A comment and a progress note are each a card (the same: a head with the avatar — an instance's with its state
|
|
221
148
|
* dot —, the name, an "Agent" badge, a tag for what it is, and the time; the text under the name); a history line is a thin row
|
|
@@ -235,7 +162,8 @@ function Entry({ entry, describe, who }) {
|
|
|
235
162
|
${entry.kind === "reject" ? html`<span class="tb-tag st-blocked">${t("taskcard.rejectTag")}</span>` : null}
|
|
236
163
|
${entry.kind === "approve" ? html`<span class="tb-tag st-done">${t("taskcard.approveTag")}</span>` : null}
|
|
237
164
|
${time}</div>
|
|
238
|
-
${body ? html`<${MdBody} body=${body} />` : html`<div class="tl-body">${entry.text}</div>`}
|
|
165
|
+
${body ? html`<${MdBody} body=${body} />` : html`<div class="tl-body">${entry.text}</div>`}
|
|
166
|
+
${entry.files && entry.files.length ? html`<${FileList} files=${entry.files} cls="tl-files" />` : null}</li>`;
|
|
239
167
|
}
|
|
240
168
|
if (entry.type === "log") {
|
|
241
169
|
return html`<li class=${`tl-item tl-card tl-log${mark}`}>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// M-3668 (the user, 11-24): finished main tasks leave a project's board some days after they finish (the server's
|
|
2
|
+
// defaults.task_board.archive_after_days, default 3) and wait in its Archive list here — newest first, a page at a time,
|
|
3
|
+
// filtered by who had them; a card opens from it as from the board, and moving it to To do reopens it. The Done column
|
|
4
|
+
// shows its newest 20 at a time. A module of its own (a new URL): a tab holding an older fleet-tasks.js or
|
|
5
|
+
// fleet-task-common.js is never linked against a name it lacks.
|
|
6
|
+
import { html, useEffect, useRef, useState } from "/assets/app-html.js";
|
|
7
|
+
import { lang, register, t } from "/assets/app-i18n.js";
|
|
8
|
+
import { Dialog } from "/assets/ui-dialog.js";
|
|
9
|
+
import { Empty, ErrorState, Skeleton } from "/assets/ui-states.js";
|
|
10
|
+
import { StatusPill, Who, relTime } from "./fleet-task-common.js";
|
|
11
|
+
|
|
12
|
+
register("tasksArchive", {
|
|
13
|
+
en: {
|
|
14
|
+
link: "Archived · {0}", linkTip: "Finished more than {0} days ago: off the board, still found by search and by their number",
|
|
15
|
+
title: "{0} · archived", lead: "Main tasks finished more than {0} days ago. Search finds them too, and a card's number opens it; move one to To do to reopen it.",
|
|
16
|
+
who: "Assigned to", everyone: "Everyone", more: "Show more", none: "Nothing archived here.", noneWho: "Nothing archived for {0}.", failed: "The archive could not be read.",
|
|
17
|
+
done: "Done {0}", cancelled: "Cancelled {0}", count: "{0} of {1}",
|
|
18
|
+
week: "{0} done this week", weekArchived: "{0} archived", weekTip: "Main tasks done in the last 7 days. The archived ones are off the board: the header's Archived link lists them",
|
|
19
|
+
showMore: "Show {0} more", doneShow: "Show", tag: "Archived", tagTip: "Finished more than {0} days ago: off the board, not deleted", tile: "{0} archived",
|
|
20
|
+
},
|
|
21
|
+
"zh-TW": {
|
|
22
|
+
link: "已封存 · {0}", linkTip: "完成超過 {0} 天:已離開看板,仍可用搜尋或卡片編號找到",
|
|
23
|
+
title: "{0} · 已封存", lead: "完成超過 {0} 天的主任務。搜尋也找得到,用卡片編號也能開啟;移回「待辦」即可重新開啟。",
|
|
24
|
+
who: "負責", everyone: "所有人", more: "顯示更多", none: "這裡沒有封存的卡片。", noneWho: "{0} 沒有封存的卡片。", failed: "無法讀取封存清單。",
|
|
25
|
+
done: "{0} 完成", cancelled: "{0} 取消", count: "{0} / {1}",
|
|
26
|
+
week: "本週完成 {0} 張", weekArchived: "其中 {0} 張已封存", weekTip: "近 7 天完成的主任務。已封存的不在看板上,可從標題列的「已封存」查看",
|
|
27
|
+
showMore: "再顯示 {0} 張", doneShow: "顯示", tag: "已封存", tagTip: "完成超過 {0} 天:已離開看板,沒有刪除", tile: "已封存 {0} 張",
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/** The Done column's page: its newest finished cards, this many more at a time. */
|
|
32
|
+
export const DONE_PAGE = 20;
|
|
33
|
+
/** Finished cards, the most recently finished first (when they finished, else their last change). */
|
|
34
|
+
export const newestDone = (cards) => [...cards].sort((a, b) => String(b.doneAt || b.updatedAt || "").localeCompare(String(a.doneAt || a.updatedAt || "")) || String(b.id).localeCompare(String(a.id)));
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The Done column's "this week" line: how many main tasks were done in the last 7 days, and how many of them are
|
|
38
|
+
* archived ("48 done this week · 11 archived"). Two unbreakable parts: a narrow column wraps it only at the "·".
|
|
39
|
+
*/
|
|
40
|
+
export function weekLabel(stats) {
|
|
41
|
+
const done = html`<span class="tb-nowrap">${t("tasksArchive.week", (stats && stats.doneWeek) || 0)}</span>`;
|
|
42
|
+
return stats && stats.archivedWeek > 0 ? html`${done} · <span class="tb-nowrap">${t("tasksArchive.weekArchived", stats.archivedWeek)}</span>` : done;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A finish time as the Archive shows it: "Nov 21, 14:05" / "11月21日 14:05" (with the year when it isn't this year's). */
|
|
46
|
+
export function finishedAt(iso, now = new Date()) {
|
|
47
|
+
const d = new Date(iso);
|
|
48
|
+
if (Number.isNaN(d.getTime())) return "";
|
|
49
|
+
const opts = { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", hour12: false, ...(d.getFullYear() !== now.getFullYear() ? { year: "numeric" } : {}) };
|
|
50
|
+
return new Intl.DateTimeFormat(lang() === "zh-TW" ? "zh-TW" : "en", opts).format(d);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The board header's way to the Archive list (none when nothing is archived). */
|
|
54
|
+
export function ArchivedLink({ count, days, onOpen }) {
|
|
55
|
+
if (!count) return null;
|
|
56
|
+
return html`<button type="button" class="tb-link tb-archived-link" title=${t("tasksArchive.linkTip", days)} onClick=${onOpen}>${t("tasksArchive.link", count)}</button>`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A search hit's or a card page's mark: the board has archived it. */
|
|
60
|
+
export function ArchivedTag({ days }) {
|
|
61
|
+
return html`<span class="tb-tag" title=${t("tasksArchive.tagTip", days)}>${t("tasksArchive.tag")}</span>`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A project's archived main tasks (`project`: its id, or "none"), the most recently finished first; `fetchJson(url)`
|
|
66
|
+
* reads the server's page (GET /ui/tasks/archive). Picking one opens it (`onOpen(card)`), as from the board.
|
|
67
|
+
*/
|
|
68
|
+
export function ArchiveDialog({ project, name, days, onOpen, onClose, fetchJson }) {
|
|
69
|
+
const [who, setWho] = useState("");
|
|
70
|
+
const [state, setState] = useState({ phase: "loading", cards: [], next: null, total: 0, assignees: [] });
|
|
71
|
+
const seq = useRef(0);
|
|
72
|
+
const load = async (before = null) => {
|
|
73
|
+
const mine = ++seq.current;
|
|
74
|
+
const q = new URLSearchParams({ project: String(project), limit: "50" });
|
|
75
|
+
if (before) q.set("before", before);
|
|
76
|
+
if (who) q.set("assignee", who);
|
|
77
|
+
try {
|
|
78
|
+
const d = await fetchJson(`/ui/tasks/archive?${q}`);
|
|
79
|
+
if (mine !== seq.current) return;
|
|
80
|
+
setState((s) => ({ phase: "ready", cards: before ? [...s.cards, ...d.cards] : d.cards, next: d.next || null, total: d.total || 0,
|
|
81
|
+
assignees: Array.isArray(d.assignees) ? d.assignees : s.assignees }));
|
|
82
|
+
} catch { if (mine === seq.current) setState((s) => ({ ...s, phase: "failed" })); }
|
|
83
|
+
};
|
|
84
|
+
useEffect(() => { setState((s) => ({ ...s, phase: "loading", cards: [], next: null })); void load(); }, [project, who]);
|
|
85
|
+
// When it finished, as a date and time (#4428 capture check: a relative "3 days ago" rounds 3.3 days down, which read as
|
|
86
|
+
// contradicting "more than 3 days"); the relative time is its tooltip.
|
|
87
|
+
const at = (c) => c.doneAt || c.updatedAt;
|
|
88
|
+
const finished = (c) => t(c.status === "cancelled" ? "tasksArchive.cancelled" : "tasksArchive.done", finishedAt(at(c)));
|
|
89
|
+
const body = state.phase === "failed" ? html`<${ErrorState} message=${t("tasksArchive.failed")} onRetry=${() => load()} />`
|
|
90
|
+
: state.phase === "loading" && !state.cards.length ? html`<${Skeleton} variant="list" lines=${4} />`
|
|
91
|
+
: !state.cards.length ? html`<${Empty} icon="tasks" title=${who ? t("tasksArchive.noneWho", who) : t("tasksArchive.none")} />`
|
|
92
|
+
: html`<div class="tb-list"><ul class="tb-rows">${state.cards.map((c) => html`<li key=${c.id} class="tb-row" onClick=${() => onOpen(c)}>
|
|
93
|
+
<div class="tb-row-line">
|
|
94
|
+
<span class="tb-row-main">${c.id}</span>
|
|
95
|
+
<span class="tb-row-text"><button type="button" class="tb-row-title" title=${c.title} onClick=${(e) => { e.stopPropagation(); onOpen(c); }}>${c.title}</button></span>
|
|
96
|
+
<${StatusPill} status=${c.status} card=${c} />
|
|
97
|
+
<span class="tb-row-who"><${Who} name=${c.assignee} /></span>
|
|
98
|
+
<span class="tb-row-time muted" title=${relTime(at(c))}>${finished(c)}</span>
|
|
99
|
+
</div></li>`)}</ul></div>`;
|
|
100
|
+
const tools = state.assignees.length > 1 || who ? html`<label class="tb-archive-who">${t("tasksArchive.who")}
|
|
101
|
+
<select class="tb-select" value=${who} onChange=${(e) => setWho(e.target.value)}>
|
|
102
|
+
<option value="">${t("tasksArchive.everyone")}</option>${state.assignees.map((n) => html`<option key=${n} value=${n}>${n}</option>`)}
|
|
103
|
+
</select></label>` : null;
|
|
104
|
+
const actions = html`${state.cards.length ? html`<span class="muted">${t("tasksArchive.count", state.cards.length, state.total)}</span>` : null}
|
|
105
|
+
${state.next ? html`<button type="button" class="btn" onClick=${() => load(state.next)}>${t("tasksArchive.more")}</button>` : null}`;
|
|
106
|
+
return html`<${Dialog} title=${t("tasksArchive.title", name)} onClose=${onClose} wide=${true} actions=${actions} cls="tb-archive">
|
|
107
|
+
<p class="muted">${t("tasksArchive.lead", days)}</p>
|
|
108
|
+
${tools}
|
|
109
|
+
${body}
|
|
110
|
+
<//>`;
|
|
111
|
+
}
|
|
@@ -19,6 +19,7 @@ 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 { FilesField } from "./fleet-task-files.js";
|
|
22
23
|
import { AgentRun } from "./fleet-task-run.js";
|
|
23
24
|
import { LeaderRow, WatchersRow } from "./fleet-task-follow.js";
|
|
24
25
|
|
|
@@ -62,9 +63,9 @@ register("taskcard", {
|
|
|
62
63
|
loading: "載入中…", missing: "找不到 {0}", version: "v{0}", copyLink: "複製這張卡的連結", linkCopied: "已複製連結",
|
|
63
64
|
conflict: "{0} 在你編輯時被改過了。已載入最新內容,你的修改還在,再存一次就會覆蓋。",
|
|
64
65
|
followsSubs: "有子任務,狀態會跟著子任務自動變化",
|
|
65
|
-
reopen: "
|
|
66
|
+
reopen: "重新開啟", cancelCard: "取消這張卡", confirmMain: "確認主任務", moreActions: "更多動作",
|
|
66
67
|
assignee: "負責人", nobody: "沒人負責", unassign: "沒人負責", other: "其他…", otherTitle: "指派給其他 Agent", otherLabel: "Agent 名稱",
|
|
67
|
-
status: "狀態", project: "專案", priority: "
|
|
68
|
+
status: "狀態", project: "專案", priority: "優先級", size: "大小", review: "待我確認", reviewBox: "做完要停在待確認,等我確認", reviewShort: "完成前停在待確認",
|
|
68
69
|
reviewOn: "做完會停在待確認,等你確認", reviewOff: "做完直接完成,不等你確認",
|
|
69
70
|
parent: "主任務", deps: "相依卡片", none: "沒有", edit: "編輯", depsTitle: "{0} 的相依", depsLabel: "要先完成的卡號,用逗號或空白分開(留空=沒有相依)",
|
|
70
71
|
depWaiting: "還沒完成", depDone: "已完成", opened: "{0} 開的 · {1} · 最後更新 {2}",
|
|
@@ -84,7 +85,7 @@ register("taskcard", {
|
|
|
84
85
|
logTip: "agent 或成員記下的一行工作紀錄,不是留言",
|
|
85
86
|
evCreated: "開卡", evMoved: "{0}→{1}", evAuto: "(自動)", evAssigned: "負責人 {0}→{1}", evUpdated: "修改{0}", evCommented: "留言", evLogged: "紀錄:{0}", evWatchers: "修改關注者:{0}",
|
|
86
87
|
fTitle: "標題", fGoal: "目標", fScope: "範圍", fContext: "背景", fState: "目前狀態", fResult: "產出", fBlockedReason: "卡住原因", fSize: "大小",
|
|
87
|
-
fPriority: "
|
|
88
|
+
fPriority: "優先級", fNeedsReview: "需要確認", fDependsOn: "相依", fAcceptance: "驗收條件", fProjectId: "專案",
|
|
88
89
|
position: "位置", moveUp: "往上移", moveDown: "往下移", properties: "屬性", crumbs: "這張卡的位置", backBoard: "回到看板", backList: "回到清單",
|
|
89
90
|
dispatcher: "派工", dispatcherHint: "卡住要決定的事會先通知派工者", dispatcherMe: "我", dispatcherNone: "(沒有)",
|
|
90
91
|
dispatcherPerson: "{0}(人)", fDispatcher: "派工者",
|
|
@@ -374,7 +375,7 @@ export function CardPage({ id, tick, projects, cards = [], boardOff = [], doing
|
|
|
374
375
|
${bar({ parent, actions: html`${copyBtn}${blockBtn}${more}` })}
|
|
375
376
|
<div class="tp-grid">
|
|
376
377
|
<div class="tp-head">
|
|
377
|
-
<div class="tp-idrow"><span class="tb-code tp-code">${card.id}</span><${StatusPill} status=${card.status} card=${card}
|
|
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}
|
|
378
379
|
${derived && !finished ? html`<span class="tp-derived">${t("taskcard.followsSubs")}</span>` : null}</div>
|
|
379
380
|
<div class="tc-head" ref=${head} tabindex="-1" role="heading" aria-level="2">
|
|
380
381
|
${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,6 +396,7 @@ export function CardPage({ id, tick, projects, cards = [], boardOff = [], doing
|
|
|
395
396
|
${spec.shown.length ? html`<div class="tp-spec">${spec.shown}</div>` : null}
|
|
396
397
|
${spec.adders.length ? html`<div class="tp-adders">${spec.adders}</div>` : null}
|
|
397
398
|
<${AgentRun} card=${card} detail=${detail} doing=${doing} derived=${derived} shown=${handoff.shown} adders=${handoff.adders} />
|
|
399
|
+
<${FilesField} files=${(detail && detail.attachments) || []} />
|
|
398
400
|
${subs}
|
|
399
401
|
</div>
|
|
400
402
|
|
|
@@ -127,7 +127,7 @@ register("tasks", {
|
|
|
127
127
|
goal: "目標", goalHint: "為什麼做、做完是什麼樣子", scope: "範圍", scopeHint: "做:…/不做:…",
|
|
128
128
|
definitionHint: "一行一項:能客觀判斷是否達成的條件", acceptanceHint: "一行一項",
|
|
129
129
|
context: "背景", contextHint: "檔案路徑、相關卡號、已經做的決定(只放指引)",
|
|
130
|
-
assignee: "負責人", assigneeHint: "交給哪個 Agent", project: "專案", size: "大小", priority: "
|
|
130
|
+
assignee: "負責人", assigneeHint: "交給哪個 Agent", project: "專案", size: "大小", priority: "優先級",
|
|
131
131
|
boardOffNote: "{0} 的任務板是關閉的:不能指派卡片給它,留言和 @ 也叫不醒它,它也收不到 [Task board] 通知。",
|
|
132
132
|
boardOffCommentNote: "{0} 的任務板是關閉的,這則留言不會叫醒它。",
|
|
133
133
|
boardOffWhere: "要打開:{0}(所有 Agent),或這個 Agent 自己的設定 → 進階 → 網頁儀表板權限。", boardOffWhereLink: "設定 → Agent 共用設定",
|
|
@@ -175,7 +175,7 @@ register("tasks", {
|
|
|
175
175
|
workOutside: "不在 fleet 裡", workFailed: "讀不到工作清單:{0}", workJoin: "、",
|
|
176
176
|
detailsBoard: "任務看板",
|
|
177
177
|
// 快速建立(fleet-task-create.js)
|
|
178
|
-
quickHint: "只要標題就能建立,其他欄位建立後在卡片上補。", moreOptions: "更多選項", createMore: "
|
|
178
|
+
quickHint: "只要標題就能建立,其他欄位建立後在卡片上補。", moreOptions: "更多選項", createMore: "專案、負責人與優先級",
|
|
179
179
|
},
|
|
180
180
|
});
|
|
181
181
|
|
|
@@ -8,6 +8,7 @@ import { html, useLayoutEffect, useRef, useState } from "/assets/app-html.js";
|
|
|
8
8
|
import { t } from "/assets/app-i18n.js";
|
|
9
9
|
import { Icon } from "/assets/ui-icons.js";
|
|
10
10
|
import { Menu } from "/assets/ui-menu.js";
|
|
11
|
+
import { MdBody, commentHtml } from "./fleet-task-md.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Which version an edit started from: a save sends it, so an agent's newer write is caught (409). After a conflict
|
|
@@ -135,8 +136,14 @@ export function InlineTitle({ value, version, limit, onSave }) {
|
|
|
135
136
|
/** A longer text: a block that opens as a box on a click. Its own limit counts as you type. */
|
|
136
137
|
export function EditableText({ value, limit, placeholder, version, readOnly = false, onSave, open = false, onClose }) {
|
|
137
138
|
const edit = useInlineEdit({ value, version, onSave, valid: (v) => [...v].length <= limit, open: open && !readOnly, onClose });
|
|
138
|
-
|
|
139
|
+
// a text that is there is read as Markdown (the chat's renderer: lines, lists, headings, code blocks, links; escaped first).
|
|
140
|
+
// The stored text is the same; the box that edits it is still plain text.
|
|
141
|
+
const md = value ? commentHtml(value) : null;
|
|
142
|
+
if (readOnly) return md ? html`<${MdBody} body=${md} cls="tc-text tc-md tl-body md" />` : html`<p class=${`tc-text${value ? "" : " empty"}`}>${value || "—"}</p>`;
|
|
139
143
|
if (edit.draft === null) {
|
|
144
|
+
// A click on the text (not on a link or a code block's buttons) opens the box, as it always did; the button is the keyboard's way in.
|
|
145
|
+
if (md) return html`<div class="tc-md-wrap"><${MdBody} body=${md} cls="tc-text tc-md tl-body md" title=${t("taskcard.clickToEdit")} onActivate=${() => edit.start()} />
|
|
146
|
+
<button type="button" class="btn btn-ghost btn-sm tc-md-edit" onClick=${() => edit.start()}>${t("taskcard.edit")}</button></div>`;
|
|
140
147
|
return html`<button type="button" class=${`tc-text${value ? "" : " empty"}`} title=${t("taskcard.clickToEdit")} onClick=${() => edit.start()}>${value || placeholder || t("taskcard.empty")}</button>`;
|
|
141
148
|
}
|
|
142
149
|
const length = [...edit.draft].length;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
// Files on a card: what an agent made and put on the card, under the comment it came with and, together, in the
|
|
2
|
+
// card's Files field. Each file is a download (GET /ui/tasks/files/<id>: an image as an image, the rest as an opaque download — never
|
|
3
|
+
// a page of the dashboard's own origin); what the page shows of it is read here, on a click, and drawn by the chat's own pieces:
|
|
4
|
+
// - a picture: the picture;
|
|
5
|
+
// - Markdown: the chat's Markdown renderer (escapes first; code blocks decorated); text, CSV, JSON, code: plain text in a block
|
|
6
|
+
// (textContent — nothing in the file is ever run);
|
|
7
|
+
// - an .html file: the chat's sandboxed preview frame (AgendPreview: this device must allow previews; a frame of an opaque
|
|
8
|
+
// origin with scripts only, no cookies, no network of the dashboard). Not offered over the public link (as in the chat), except
|
|
9
|
+
// to an admin session there. A file the page cannot show is still a download.
|
|
10
|
+
// No style attribute anywhere (the CSP).
|
|
11
|
+
import { html, useEffect, useRef, useState } from "/assets/app-html.js";
|
|
12
|
+
import { register, t } from "/assets/app-i18n.js";
|
|
13
|
+
import "/assets/chat-render.js";
|
|
14
|
+
import "/assets/chat-strings.js";
|
|
15
|
+
import { Icon } from "/assets/ui-icons.js";
|
|
16
|
+
import { loadHtmlAttachment, sizeLabel } from "/assets/html-attachment.js";
|
|
17
|
+
import { MdBody, commentHtml } from "./fleet-task-md.js";
|
|
18
|
+
import { relTime } from "./fleet-task-common.js";
|
|
19
|
+
|
|
20
|
+
register("taskfiles", {
|
|
21
|
+
en: {
|
|
22
|
+
title: "Files", count: "{0}", download: "Download", show: "Show", hide: "Hide", preview: "Preview", stop: "Stop preview", live: "This is a preview", loading: "Loading…",
|
|
23
|
+
large: "This file is large ({0}). Preview anyway?", anyway: "Preview anyway", over: "This file is too large to show here. Download it.",
|
|
24
|
+
gone: "This file is no longer available.", failed: "The file could not be read.", allow: "Allow previews on this device",
|
|
25
|
+
optin: "Previews are off on this device. Allow them to run this file here, or download it.", lines: "Show all {0} lines", plain: "Shown as plain text.",
|
|
26
|
+
by: "{0} · {1}", openImage: "Open the picture", fileOf: "File {0}, {1}",
|
|
27
|
+
},
|
|
28
|
+
"zh-TW": {
|
|
29
|
+
title: "檔案", count: "{0}", download: "下載", show: "顯示", hide: "收合", preview: "預覽", stop: "停止預覽", live: "這是預覽", loading: "讀取中…",
|
|
30
|
+
large: "這個檔案很大({0})。還是要預覽嗎?", anyway: "仍要預覽", over: "這個檔案太大,無法在這裡顯示,請下載。",
|
|
31
|
+
gone: "這個檔案已經不存在。", failed: "無法讀取這個檔案。", allow: "在這台裝置允許預覽",
|
|
32
|
+
optin: "這台裝置沒有開啟預覽。允許後可以直接在這裡執行這個檔案,或直接下載。", lines: "顯示全部 {0} 行", plain: "以純文字顯示。",
|
|
33
|
+
by: "{0} · {1}", openImage: "開啟圖片", fileOf: "檔案 {0},{1}",
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/** Where a card's file is read: the board's own route, by the id the fleet issued (32 hex — nothing else becomes a URL). */
|
|
38
|
+
export const fileUrl = (f) => `/ui/tasks/files/${f.id}`;
|
|
39
|
+
const att = (f) => ({ id: f.id, kind: f.kind, name: f.name, size: f.size, mime: f.mime, url: fileUrl(f) });
|
|
40
|
+
const validId = (f) => !!f && typeof f.id === "string" && /^[0-9a-f]{32}$/.test(f.id);
|
|
41
|
+
|
|
42
|
+
/** The most a text file is read for display (as the chat's text cards), and the lines shown before "Show all". */
|
|
43
|
+
export const TEXT_MAX = 1024 * 1024;
|
|
44
|
+
export const TEXT_LINES = 200;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* How the page shows a file (pure: tests import it): "image" | "md" | "text" | "html" | null (a download only). The chat's own
|
|
48
|
+
* classification by name (`attachmentPreviewType`), so a card and a chat agree about what a file is; media is a download here.
|
|
49
|
+
*/
|
|
50
|
+
export function previewKind(f) {
|
|
51
|
+
if (!validId(f)) return null;
|
|
52
|
+
if (f.kind === "photo") return "image";
|
|
53
|
+
const R = globalThis.AgendChatRender;
|
|
54
|
+
if (R && typeof R.isHtmlAttachment === "function" && R.isHtmlAttachment(f)) return "html";
|
|
55
|
+
const type = R && typeof R.attachmentPreviewType === "function" ? R.attachmentPreviewType(f) : null;
|
|
56
|
+
if (!type || type === "video" || type === "audio") return null;
|
|
57
|
+
return type === "md" ? "md" : "text";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** HTML is run only where the chat would run it: not over the public link, unless an admin session there (data-link-media). */
|
|
61
|
+
function htmlOffered() {
|
|
62
|
+
const d = (globalThis.document && globalThis.document.body && globalThis.document.body.dataset) || {};
|
|
63
|
+
return d.publicLink !== "1" || d.linkMedia === "1";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** A file's size as the chat words it ("812 B", "12 KB", "1.4 MB"); the preview questions' own "MB" wording when that renderer is not there. */
|
|
67
|
+
const sizeText = (n) => {
|
|
68
|
+
if (typeof n !== "number") return "";
|
|
69
|
+
const R = globalThis.AgendChatRender;
|
|
70
|
+
return R && typeof R.formatSize === "function" ? R.formatSize(n) : sizeLabel(n);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** A text file's body: Markdown through the chat's renderer, anything else as plain text in a block; long ones folded. */
|
|
74
|
+
function TextBody({ text, kind }) {
|
|
75
|
+
const [all, setAll] = useState(false);
|
|
76
|
+
const lines = text.split(/\r?\n/);
|
|
77
|
+
const cut = !all && lines.length > TEXT_LINES;
|
|
78
|
+
const shown = cut ? lines.slice(0, TEXT_LINES).join("\n") : text;
|
|
79
|
+
const md = kind === "md" ? commentHtml(shown) : null;
|
|
80
|
+
return html`<div class="tf-body">
|
|
81
|
+
${md ? html`<${MdBody} body=${md} cls="tf-md tl-body md" />` : html`<pre class="tf-pre"><code>${shown}</code></pre>`}
|
|
82
|
+
${cut ? html`<button type="button" class="btn btn-sm tf-more" onClick=${() => setAll(true)}>${t("taskfiles.lines", lines.length)}</button>` : null}
|
|
83
|
+
</div>`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** An .html file in the chat's sandbox frame (AgendPreview), started by a click, stopped when the card leaves the page. */
|
|
87
|
+
function HtmlPreview({ f }) {
|
|
88
|
+
const P = globalThis.AgendPreview;
|
|
89
|
+
const holder = useRef(null);
|
|
90
|
+
const [state, setState] = useState("idle");
|
|
91
|
+
const [note, setNote] = useState("");
|
|
92
|
+
const [large, setLarge] = useState(null);
|
|
93
|
+
const [, redraw] = useState(0);
|
|
94
|
+
const key = `taskfile:${f.id}`;
|
|
95
|
+
useEffect(() => () => { try { if (P) P.stop(key, "stopped", ""); } catch { /* not running */ } }, [key]);
|
|
96
|
+
// "I understand" is kept by the preview module (per sign-in), not by this component, so a press changes nothing this component holds:
|
|
97
|
+
// it draws again on the press itself (below) and whenever the module says the acknowledgement changed (the chat's, another card's or
|
|
98
|
+
// another tab's press — the chat's own panel listens the same way).
|
|
99
|
+
useEffect(() => (P && typeof P.onChange === "function" ? P.onChange(() => redraw((n) => n + 1)) : undefined), [P]);
|
|
100
|
+
if (!P || !htmlOffered()) return null;
|
|
101
|
+
const going = state === "starting" || state === "running";
|
|
102
|
+
// A reason no click can change (the server offers no preview at this address, the page is behind a proxy that rewrites its Host, this
|
|
103
|
+
// session switched previews off) is said up front, with no button to press; only "this device has not allowed previews" is asked on the click.
|
|
104
|
+
const here = P.availability();
|
|
105
|
+
const blocked = !here.ok && here.why !== "optin" && !going;
|
|
106
|
+
const ui = { state: (name, reason) => { setState(name === "starting" || name === "running" ? name : "idle"); if (name === "large") { setLarge(true); } setNote(reason || ""); } };
|
|
107
|
+
async function run(anyway) {
|
|
108
|
+
let a = P.availability();
|
|
109
|
+
if (!a.ok && a.why === "optin") {
|
|
110
|
+
// The chat's own question (what a preview means for this device), asked once; no answer, no preview.
|
|
111
|
+
try { const m = await import("./panel-chat.js"); await m.setPreviewOptIn(true); } catch { /* the note below says it is off */ }
|
|
112
|
+
a = P.availability();
|
|
113
|
+
}
|
|
114
|
+
if (!a.ok) { setNote(a.reason); return; }
|
|
115
|
+
setLarge(null); setNote(t("taskfiles.loading"));
|
|
116
|
+
const r = await loadHtmlAttachment(att(f), undefined, { anyway });
|
|
117
|
+
if (!r.ok) {
|
|
118
|
+
if (r.reason === "large") { setLarge(true); setNote(t("taskfiles.large", sizeText(r.size))); return; }
|
|
119
|
+
setNote(t(r.reason === "over" ? "taskfiles.over" : r.reason === "gone" ? "taskfiles.gone" : "taskfiles.failed"));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
setNote("");
|
|
123
|
+
// `fill`: the frame fills the holder's box (fleet-task-files in task-board.css gives it a fixed height), not the strip a page that lays itself out by the window's height reports.
|
|
124
|
+
P.start(key, holder.current, r.code, ui, { fill: true, ...(anyway ? { anyway: true } : {}) });
|
|
125
|
+
}
|
|
126
|
+
return html`<div class="tf-html">
|
|
127
|
+
<div class=${`tf-actions${going ? " tf-live" : ""}`}>
|
|
128
|
+
${going ? html`<button type="button" class="btn btn-sm tf-stop" onClick=${() => P.stop(key, "stopped", "")}>${t("taskfiles.stop")}</button>
|
|
129
|
+
<span class="tf-live-mark">${t("taskfiles.live")}</span>`
|
|
130
|
+
: large ? html`<button type="button" class="btn btn-sm" onClick=${() => void run(true)}>${t("taskfiles.anyway")}</button>`
|
|
131
|
+
: blocked ? null
|
|
132
|
+
: html`<button type="button" class="btn btn-sm btn-primary" onClick=${() => void run(false)}><${Icon} name="play" size=${14} />${t("taskfiles.preview")}</button>`}
|
|
133
|
+
</div>
|
|
134
|
+
<div class="pv-note tf-note" role="status">${note || (blocked ? here.reason : "")}</div>
|
|
135
|
+
${going && !P.bannerAcked() ? html`<div class="pv-banner" role="note"><span class="pv-banner-text">${P.banner()}</span>
|
|
136
|
+
<button type="button" class="btn btn-sm btn-ghost pv-ack" title=${P.bannerAckTitle()} onClick=${() => { P.ackBanner(); redraw((n) => n + 1); }}>${P.bannerAckLabel()}</button></div>` : null}
|
|
137
|
+
<div class="pv-holder tf-holder" ref=${holder}></div>
|
|
138
|
+
</div>`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** A text file's "Show": read once (capped), then drawn; "Hide" folds it again. */
|
|
142
|
+
function TextPreview({ f, kind }) {
|
|
143
|
+
const [text, setText] = useState(null);
|
|
144
|
+
const [open, setOpen] = useState(false);
|
|
145
|
+
const [note, setNote] = useState("");
|
|
146
|
+
async function toggle() {
|
|
147
|
+
if (text !== null) { setOpen(!open); return; }
|
|
148
|
+
setNote(t("taskfiles.loading"));
|
|
149
|
+
const r = await loadHtmlAttachment(att(f), undefined, { ask: TEXT_MAX, max: TEXT_MAX });
|
|
150
|
+
if (!r.ok) { setNote(t(r.reason === "over" || r.reason === "large" ? "taskfiles.over" : r.reason === "gone" ? "taskfiles.gone" : "taskfiles.failed")); return; }
|
|
151
|
+
let body = r.code;
|
|
152
|
+
if (/\.json$/i.test(f.name)) { try { body = JSON.stringify(JSON.parse(body), null, 2); } catch { /* shown as written */ } }
|
|
153
|
+
setNote(""); setText(body); setOpen(true);
|
|
154
|
+
}
|
|
155
|
+
return html`<div class="tf-text">
|
|
156
|
+
<div class="tf-actions"><button type="button" class="btn btn-sm" aria-expanded=${open ? "true" : "false"} onClick=${() => void toggle()}>${t(open ? "taskfiles.hide" : "taskfiles.show")}</button></div>
|
|
157
|
+
<div class="pv-note tf-note" role="status">${note}</div>
|
|
158
|
+
${open && text !== null ? html`<${TextBody} text=${text} kind=${kind} />` : null}
|
|
159
|
+
</div>`;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** One file: its name (the download), its size, who and when, and what the page can show of it. */
|
|
163
|
+
export function FileRow({ f, showWho = false }) {
|
|
164
|
+
if (!validId(f)) return null;
|
|
165
|
+
const kind = previewKind(f);
|
|
166
|
+
const url = fileUrl(f);
|
|
167
|
+
return html`<li class=${`tf-row tf-k-${kind || "other"}`} data-file=${f.id}>
|
|
168
|
+
<div class="tf-head">
|
|
169
|
+
<span class="tf-icon" aria-hidden="true"><${Icon} name="attach" size=${14} /></span>
|
|
170
|
+
<a class="tf-name" href=${url} download=${f.name} title=${t("taskfiles.download")}>${f.name}</a>
|
|
171
|
+
<span class="tf-meta">${sizeText(f.size)}${showWho && f.author ? ` · ${t("taskfiles.by", f.author, relTime(f.at))}` : ""}</span>
|
|
172
|
+
<span class="tf-grow"></span>
|
|
173
|
+
<a class="btn btn-sm btn-ghost tf-dl" href=${url} download=${f.name} aria-label=${`${t("taskfiles.download")}: ${f.name}`}><${Icon} name="download" size=${14} />${t("taskfiles.download")}</a>
|
|
174
|
+
</div>
|
|
175
|
+
${kind === "image" ? html`<a class="tf-img" href=${url} target="_blank" rel="noopener noreferrer" title=${t("taskfiles.openImage")}><img src=${url} alt=${f.name} loading="lazy" /></a>` : null}
|
|
176
|
+
${kind === "md" || kind === "text" ? html`<${TextPreview} f=${f} kind=${kind} />` : null}
|
|
177
|
+
${kind === "html" ? html`<${HtmlPreview} f=${f} />` : null}
|
|
178
|
+
</li>`;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** The files under a comment. */
|
|
182
|
+
export function FileList({ files, cls = "", showWho = false }) {
|
|
183
|
+
const list = (files || []).filter(validId);
|
|
184
|
+
if (!list.length) return null;
|
|
185
|
+
return html`<ul class=${`tf-list${cls ? ` ${cls}` : ""}`}>${list.map((f) => html`<${FileRow} key=${f.id} f=${f} showWho=${showWho} />`)}</ul>`;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** The card's Files field: every file on the card, newest last, with who put it there. Nothing when there are none. */
|
|
189
|
+
export function FilesField({ files }) {
|
|
190
|
+
const list = (files || []).filter(validId);
|
|
191
|
+
if (!list.length) return null;
|
|
192
|
+
return html`<section class="tc-field tp-files" aria-label=${t("taskfiles.title")} data-files=${list.length}>
|
|
193
|
+
<h3>${t("taskfiles.title")} <span class="tf-count">${t("taskfiles.count", list.length)}</span></h3>
|
|
194
|
+
<div class="tc-field-body"><${FileList} files=${list} showWho /></div>
|
|
195
|
+
</section>`;
|
|
196
|
+
}
|