@songsid/agend 2.4.0-beta.11 → 2.4.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/dist/accounts-view.d.ts +29 -0
  2. package/dist/accounts-view.js +2 -14
  3. package/dist/accounts-view.js.map +1 -1
  4. package/dist/agent-endpoint.d.ts +1 -0
  5. package/dist/agent-endpoint.js +4 -2
  6. package/dist/agent-endpoint.js.map +1 -1
  7. package/dist/auth-api.d.ts +2 -0
  8. package/dist/auth-api.js +33 -2
  9. package/dist/auth-api.js.map +1 -1
  10. package/dist/backend/codex.js +11 -0
  11. package/dist/backend/codex.js.map +1 -1
  12. package/dist/backend/types.d.ts +1 -1
  13. package/dist/build-provenance.json +1 -1
  14. package/dist/channel/mcp-server.js +1 -1
  15. package/dist/channel/mcp-server.js.map +1 -1
  16. package/dist/channel/mcp-tools.js +3 -1
  17. package/dist/channel/mcp-tools.js.map +1 -1
  18. package/dist/claude-install-kind.d.ts +19 -0
  19. package/dist/claude-install-kind.js +54 -0
  20. package/dist/claude-install-kind.js.map +1 -0
  21. package/dist/daemon.d.ts +13 -1
  22. package/dist/daemon.js +54 -9
  23. package/dist/daemon.js.map +1 -1
  24. package/dist/dispatcher-liveness.js +2 -2
  25. package/dist/dispatcher-liveness.js.map +1 -1
  26. package/dist/fleet-manager.d.ts +110 -1
  27. package/dist/fleet-manager.js +387 -25
  28. package/dist/fleet-manager.js.map +1 -1
  29. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +7 -0
  30. package/dist/general-knowledge/skills/hub/SKILL.md +25 -0
  31. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +6 -0
  32. package/dist/hub/agent-intro-model.d.ts +38 -0
  33. package/dist/hub/agent-intro-model.js +14 -0
  34. package/dist/hub/agent-intro-model.js.map +1 -0
  35. package/dist/hub/agent-intro-tool.d.ts +35 -0
  36. package/dist/hub/agent-intro-tool.js +83 -0
  37. package/dist/hub/agent-intro-tool.js.map +1 -0
  38. package/dist/hub/client.d.ts +1 -0
  39. package/dist/hub/client.js +26 -0
  40. package/dist/hub/client.js.map +1 -1
  41. package/dist/hub/compose/member.d.ts +13 -5
  42. package/dist/hub/compose/member.js +28 -5
  43. package/dist/hub/compose/member.js.map +1 -1
  44. package/dist/hub/compose/server.d.ts +1 -0
  45. package/dist/hub/compose/server.js +5 -1
  46. package/dist/hub/compose/server.js.map +1 -1
  47. package/dist/hub/http/compose.d.ts +1 -0
  48. package/dist/hub/http/compose.js +28 -5
  49. package/dist/hub/http/compose.js.map +1 -1
  50. package/dist/hub/http/schema.js +6 -0
  51. package/dist/hub/http/schema.js.map +1 -1
  52. package/dist/hub/member/agent-intro.d.ts +28 -0
  53. package/dist/hub/member/agent-intro.js +66 -0
  54. package/dist/hub/member/agent-intro.js.map +1 -0
  55. package/dist/hub/member/room-ask.d.ts +10 -0
  56. package/dist/hub/member/room-ask.js +70 -7
  57. package/dist/hub/member/room-ask.js.map +1 -1
  58. package/dist/hub/member/room-notification.d.ts +1 -1
  59. package/dist/hub/member/room-post.d.ts +6 -3
  60. package/dist/hub/member/room-post.js +9 -3
  61. package/dist/hub/member/room-post.js.map +1 -1
  62. package/dist/hub/protocol.d.ts +172 -4
  63. package/dist/hub/protocol.js +10 -5
  64. package/dist/hub/protocol.js.map +1 -1
  65. package/dist/hub/room-answer-status-model.d.ts +3 -0
  66. package/dist/hub/room-answer-status-model.js +4 -0
  67. package/dist/hub/room-answer-status-model.js.map +1 -0
  68. package/dist/hub/room-brief-model.d.ts +30 -0
  69. package/dist/hub/room-brief-model.js +37 -0
  70. package/dist/hub/room-brief-model.js.map +1 -0
  71. package/dist/hub/room-context-model.d.ts +2 -0
  72. package/dist/hub/room-context-model.js +2 -2
  73. package/dist/hub/room-context-model.js.map +1 -1
  74. package/dist/hub/room-members-model.d.ts +63 -0
  75. package/dist/hub/room-members-model.js +7 -0
  76. package/dist/hub/room-members-model.js.map +1 -0
  77. package/dist/hub/rooms/agents.js +50 -10
  78. package/dist/hub/rooms/agents.js.map +1 -1
  79. package/dist/hub/rooms/brief.d.ts +18 -0
  80. package/dist/hub/rooms/brief.js +39 -0
  81. package/dist/hub/rooms/brief.js.map +1 -0
  82. package/dist/hub/rooms/members-page.d.ts +33 -0
  83. package/dist/hub/rooms/members-page.js +37 -0
  84. package/dist/hub/rooms/members-page.js.map +1 -0
  85. package/dist/hub/rooms/purpose.d.ts +7 -0
  86. package/dist/hub/rooms/purpose.js +14 -0
  87. package/dist/hub/rooms/purpose.js.map +1 -0
  88. package/dist/hub/rooms/service.d.ts +11 -0
  89. package/dist/hub/rooms/service.js +56 -12
  90. package/dist/hub/rooms/service.js.map +1 -1
  91. package/dist/hub/rooms/types.d.ts +6 -2
  92. package/dist/hub/runtime.d.ts +1 -1
  93. package/dist/hub/server.js +27 -1
  94. package/dist/hub/server.js.map +1 -1
  95. package/dist/hub/types.d.ts +9 -5
  96. package/dist/hub-room-reply-warning.d.ts +2 -0
  97. package/dist/hub-room-reply-warning.js +16 -0
  98. package/dist/hub-room-reply-warning.js.map +1 -0
  99. package/dist/instance-lifecycle.d.ts +18 -0
  100. package/dist/instance-lifecycle.js +43 -4
  101. package/dist/instance-lifecycle.js.map +1 -1
  102. package/dist/locale.js +26 -0
  103. package/dist/locale.js.map +1 -1
  104. package/dist/login-controller.d.ts +26 -0
  105. package/dist/login-controller.js +72 -2
  106. package/dist/login-controller.js.map +1 -1
  107. package/dist/native-mcp.js +1 -1
  108. package/dist/native-mcp.js.map +1 -1
  109. package/dist/needs-you-hub.js +1 -1
  110. package/dist/needs-you-hub.js.map +1 -1
  111. package/dist/needs-you.d.ts +12 -1
  112. package/dist/needs-you.js +9 -0
  113. package/dist/needs-you.js.map +1 -1
  114. package/dist/office-share-page.js +1 -1
  115. package/dist/office-share-page.js.map +1 -1
  116. package/dist/outbound-handlers.d.ts +2 -1
  117. package/dist/outbound-handlers.js +19 -4
  118. package/dist/outbound-handlers.js.map +1 -1
  119. package/dist/outbound-schemas.d.ts +10 -0
  120. package/dist/outbound-schemas.js +3 -1
  121. package/dist/outbound-schemas.js.map +1 -1
  122. package/dist/pause-marker.d.ts +1 -1
  123. package/dist/pause-marker.js +1 -1
  124. package/dist/pause-marker.js.map +1 -1
  125. package/dist/public-web-gateway.d.ts +20 -0
  126. package/dist/public-web-gateway.js +66 -5
  127. package/dist/public-web-gateway.js.map +1 -1
  128. package/dist/restart-progress.d.ts +6 -0
  129. package/dist/restart-progress.js +5 -0
  130. package/dist/restart-progress.js.map +1 -1
  131. package/dist/settings-effect.js +17 -1
  132. package/dist/settings-effect.js.map +1 -1
  133. package/dist/tool-permissions.js +3 -3
  134. package/dist/tool-permissions.js.map +1 -1
  135. package/dist/ui/accounts-keepalive.js +2 -1
  136. package/dist/ui/accounts-view.js +2 -1
  137. package/dist/ui/chat-quote.js +3 -261
  138. package/dist/ui/fleet-canvas.js +3 -1
  139. package/dist/ui/fleet-office-skin.js +4 -3
  140. package/dist/ui/fleet-route.js +44 -6
  141. package/dist/ui/fleet-task-view.js +2 -1
  142. package/dist/ui/host-install.js +82 -5
  143. package/dist/ui/hub-agent-intro.js +15 -6
  144. package/dist/ui/hub-ai-apps.js +2 -1
  145. package/dist/ui/hub-attachments.js +81 -3
  146. package/dist/ui/hub-chat-strings.js +2 -1
  147. package/dist/ui/hub-client.js +4 -0
  148. package/dist/ui/hub-grant-picker.js +2 -1
  149. package/dist/ui/hub-group-strings.js +2 -1
  150. package/dist/ui/hub-intro-notice.js +16 -0
  151. package/dist/ui/hub-my-agents.js +7 -3
  152. package/dist/ui/hub-owner-strings.js +2 -1
  153. package/dist/ui/hub-personal-agent.js +2 -1
  154. package/dist/ui/hub-quota.js +2 -1
  155. package/dist/ui/hub-roles-strings.js +2 -1
  156. package/dist/ui/hub-room-composer.js +10 -2
  157. package/dist/ui/hub-room-list.js +1 -1
  158. package/dist/ui/hub-room-members.js +2 -0
  159. package/dist/ui/hub-room-new-strings.js +2 -1
  160. package/dist/ui/hub-room-new.js +7 -4
  161. package/dist/ui/hub-room-purpose.js +19 -0
  162. package/dist/ui/hub-room-search.js +1 -1
  163. package/dist/ui/hub-room-settings.js +9 -0
  164. package/dist/ui/hub-room-source.js +2 -1
  165. package/dist/ui/hub-room-strings.js +6 -4
  166. package/dist/ui/hub-room-thread.js +68 -17
  167. package/dist/ui/hub-strings.js +2 -1
  168. package/dist/ui/hub-teams.js +2 -1
  169. package/dist/ui/model-picker.js +3 -2
  170. package/dist/ui/panel-chat.js +25 -7
  171. package/dist/ui/panel-hub.js +67 -20
  172. package/dist/ui/panel-needs.js +3 -2
  173. package/dist/ui/panel-runtimes.js +2 -1
  174. package/dist/ui/reply-file-preview.js +2 -1
  175. package/dist/ui/settings-access-overview.js +2 -1
  176. package/dist/ui/settings-connector.js +2 -1
  177. package/dist/ui/shared/agent-sheet.js +2 -1
  178. package/dist/ui/shared/app-i18n.js +2 -2
  179. package/dist/ui/shared/app-shell.js +39 -9
  180. package/dist/ui/shared/app.css +11 -0
  181. package/dist/ui/shared/app.js +3 -1
  182. package/dist/ui/shared/asset-url.d.ts +2 -0
  183. package/dist/ui/shared/asset-url.js +20 -0
  184. package/dist/ui/shared/chat-msg-actions.js +3 -1
  185. package/dist/ui/shared/chat-quote.js +261 -0
  186. package/dist/ui/shared/chat-table-select.js +175 -0
  187. package/dist/ui/shared/hub-chat.css +28 -0
  188. package/dist/ui/shared/hub-rooms-u2.css +5 -0
  189. package/dist/ui/shared/image-annotate.js +2 -1
  190. package/dist/ui/shared/module-warm.d.ts +3 -0
  191. package/dist/ui/shared/module-warm.js +39 -0
  192. package/dist/ui/shared/ui-states.js +3 -2
  193. package/dist/ui/shared/view-history.js +2 -1
  194. package/dist/ui/subagent-row.js +3 -2
  195. package/dist/ui/usage-pool.js +2 -1
  196. package/dist/ui/workspace-panel.js +2 -1
  197. package/dist/wake-coordinator.js +3 -2
  198. package/dist/wake-coordinator.js.map +1 -1
  199. package/dist/web-api.d.ts +17 -4
  200. package/dist/web-api.js +83 -6
  201. package/dist/web-api.js.map +1 -1
  202. package/dist/web-asset-version.d.ts +65 -0
  203. package/dist/web-asset-version.js +259 -0
  204. package/dist/web-asset-version.js.map +1 -0
  205. package/dist/web-host-guard.js +3 -1
  206. package/dist/web-host-guard.js.map +1 -1
  207. package/dist/web-host-install.d.ts +30 -3
  208. package/dist/web-host-install.js +50 -4
  209. package/dist/web-host-install.js.map +1 -1
  210. package/dist/web-terminal.d.ts +5 -0
  211. package/dist/web-terminal.js +11 -0
  212. package/dist/web-terminal.js.map +1 -1
  213. package/launcher/agend-install.cjs +48 -7
  214. package/package.json +1 -1
@@ -22,6 +22,7 @@ import { t } from "./app-i18n.js";
22
22
  import { initTextSize, initUsageRail } from "./header-tools.js";
23
23
  import { installOwnerCss } from "./owner-css.js";
24
24
  import { startThemes } from "./app-themes.js";
25
+ import { warmModules } from "./module-warm.js";
25
26
 
26
27
  const boot = document.body.dataset;
27
28
  const workspaceLanding = location.pathname === "/ui";
@@ -43,7 +44,8 @@ const hubPage = mode === "full" && !guest && String(boot.hub || "").split(/\s+/)
43
44
 
44
45
  // A failed load can be retried (the panel's Retry): each retry asks for a fresh URL, since a browser may keep a failed
45
46
  // module import cached under the first one. boot() runs once, whichever attempt succeeds.
46
- const retryUrl = (path, attempt) => (attempt ? `${path}?retry=${attempt}` : path);
47
+ // M-3314: and before the first try, the module's whole graph is asked for at once (module-warm.js).
48
+ const retryUrl = (path, attempt) => (attempt ? `${path}?retry=${attempt}` : (warmModules(path), path));
47
49
  // View is public (it is what an anonymous reader may open), so it lives under /assets/ beside this file.
48
50
  const loadView = retryable((a) => import(retryUrl("/assets/panel-view.js", a)));
49
51
  const panels = new Map([["view", { load: () => loadView().then((m) => m.ViewPanel) }]]);
@@ -0,0 +1,2 @@
1
+ export function createAssetUrl(url: string): (path: string) => string;
2
+ export const assetUrl: (path: string) => string;
@@ -0,0 +1,20 @@
1
+ // M-3328 (measured in M-3316): a stylesheet or picture a module adds to the page later (a panel's own CSS, the office
2
+ // backgrounds) under the same version as the module itself. The import map (M-3314) versions only imports, so a
3
+ // `<link href="/assets/hub.css">` or `<img src="/assets/office-cozy.png">` stayed a plain, `no-store` request on every
4
+ // open — and, after an update, a newer stylesheet in an older tab. This module is loaded through the import map, so its
5
+ // own URL carries the page's version (`/assets/v-<V>/asset-url.js`): assetUrl() puts the same <V> in front of an
6
+ // `/assets/<name>`. A tab older than the server then asks for its own <V> and gets a 404, never a newer file. Anywhere
7
+ // it is loaded by its plain path (the Hub's pages, the office share page, tests) it changes nothing.
8
+
9
+ const VERSIONED = /\/(?:assets|ui\/js)\/(v-[0-9a-f]{12})\/[^/?#]+(?:[?#].*)?$/;
10
+ const PLAIN_ASSET = /^\/assets\/[A-Za-z0-9._-]+$/;
11
+
12
+ /** assetUrl for a module loaded at `url`: `/assets/<name>` under that URL's version, or unchanged when it has none. */
13
+ export function createAssetUrl(url) {
14
+ const m = VERSIONED.exec(String(url || ""));
15
+ const version = m ? m[1] : null;
16
+ return (path) => (version && PLAIN_ASSET.test(path) ? `/assets/${version}/${path.slice("/assets/".length)}` : path);
17
+ }
18
+
19
+ /** `/assets/<name>` under this page's version (unchanged where there is none). */
20
+ export const assetUrl = createAssetUrl(import.meta.url);
@@ -108,7 +108,9 @@ export function installMessageActions(list, deps) {
108
108
  // M-3127: a Hub room's messages take a reaction (deps.react: the thread's quick picker under that message); the Fleet passes none.
109
109
  if (typeof deps.react === "function" && deps.canReact?.(row) !== false) items.push(["react", deps.reactLabel || "React", () => deps.react(row)]);
110
110
  items.push(["copyText", deps.t("chat.copyText"), async () => { const ok = await deps.copyText(String(row.click?.label ?? row.text ?? "")); deps.notice(deps.t(ok ? "chat.copied" : "chat.copyFailed"), ok); }]);
111
- if (typeof deps.linkOf === "function") items.push(["copyLink", deps.t("chat.copyLink"), async () => { const ok = await deps.copyText(deps.linkOf(row)); deps.notice(deps.t(ok ? "chat.copied" : "chat.copyFailed"), ok); }]);
111
+ // M-3311 (#4159 review): Copy link only for a message that has an address (linkOf → null: none, e.g. one still sending).
112
+ const link = typeof deps.linkOf === "function" ? deps.linkOf(row) : null;
113
+ if (link) items.push(["copyLink", deps.t("chat.copyLink"), async () => { const ok = await deps.copyText(link); deps.notice(deps.t(ok ? "chat.copied" : "chat.copyFailed"), ok); }]);
112
114
  menu = doc.createElement("div");
113
115
  menu.className = "msg-menu";
114
116
  menu.setAttribute("role", "menu");
@@ -0,0 +1,261 @@
1
+ // M-2789 (the user, 11-09): answer a long, multi-part message passage by passage. Select text in ONE message of the thread
2
+ // → a small 「引用」 pill → the passage goes into the composer as a Markdown quote ("> …") at the caret, on its own lines,
3
+ // the caret left on the next line for the answer. Repeatable: quote, answer, quote the next passage, answer…
4
+ //
5
+ // - Desktop: the pill is anchored to where the selection ends (a pointer at the exact spot), below that line — clear of
6
+ // the browser's own menu above a selection (Edge's mini menu sits there, and a page can't turn it off; M-2872) — and
7
+ // above it only when there is no room below in the thread's visible box. After a quote the composer takes the focus.
8
+ // - Phone (a coarse pointer): the pill 「引用選取的文字」 docks above the composer's whole box inside the 16-px gutter — clear
9
+ // of the system's own copy toolbar (above a selection) and of the finger — or at the top of the thread when the
10
+ // passage sits there. The keyboard does NOT open after a quote (the user's choice): more passages can be selected;
11
+ // the composer's own scroller shows the caret and the newest quote.
12
+ // - No pill for a selection across messages, outside the thread, or on a page that can't send; no keyboard shortcut
13
+ // (the user's choice). The whole-message Reply (#2272) is unchanged, and so is the browser's menu on selected text.
14
+ // - What is sent is the composer's text as typed: the agent reads the "> " lines as written; the web renders them as
15
+ // blockquotes (chat-render.js); Discord's mirror shows them as quotes, Telegram's as the same plain lines.
16
+ //
17
+ // Its own words and drawing (a page that loaded an older chat-strings.js or ui-icons.js still draws it), CSSOM only
18
+ // (no style attribute: #1300), the shared popover look (.msg-menu) with the shared border and shadow tokens.
19
+ import { register, t } from "/assets/app-i18n.js";
20
+
21
+ register("chatQuote", {
22
+ en: { quote: "Quote", quotePhone: "Quote selection", label: "Quote the selected text in your message" },
23
+ "zh-TW": { quote: "引用", quotePhone: "引用選取的文字", label: "把選取的文字引用到你的訊息裡" },
24
+ });
25
+ const tq = (k) => t(`chatQuote.${k}`);
26
+
27
+ /**
28
+ * Where the person's caret was in the composer when it last lost the focus — what a quote goes in at. A field's own
29
+ * selectionStart can't be trusted after the page's selection moved into the thread (Chrome resets it), so it is kept
30
+ * here, with the text it belongs to (a caret for another text is no caret).
31
+ */
32
+ const remembered = new WeakMap();
33
+ export function composerCaret(field, value) {
34
+ if (!field) return value.length;
35
+ const r = remembered.get(field);
36
+ if (r && r.value === value) return r.caret;
37
+ const doc = field.ownerDocument;
38
+ if (doc && doc.activeElement === field && field.value === value) return field.selectionStart ?? value.length;
39
+ return value.length;
40
+ }
41
+
42
+ /** The passage as Markdown quote lines: each line "> line" (an empty one "> " keeps the quote one block). */
43
+ export function quoteBlock(text) {
44
+ const lines = String(text ?? "").replace(/\r\n?/g, "\n").replace(/ /g, " ").split("\n").map((l) => l.replace(/\s+$/, ""));
45
+ while (lines.length && !lines[0].trim()) lines.shift();
46
+ while (lines.length && !lines[lines.length - 1].trim()) lines.pop();
47
+ // A run of empty lines inside the passage becomes one quoted empty line.
48
+ const out = [];
49
+ for (const l of lines) { if (!l.trim() && out.length && out[out.length - 1] === ">") continue; out.push(l.trim() ? `> ${l}` : ">"); }
50
+ return out.join("\n");
51
+ }
52
+
53
+ /**
54
+ * Put the passage into `value` at `caret`, on its own lines: a blank line before it when text precedes on the line or
55
+ * just above, the caret on the line after it (for the answer), and a line break before any text that follows.
56
+ * Returns { value, caret }, or null for a passage with nothing to quote.
57
+ */
58
+ export function insertQuote(value, caret, text) {
59
+ const block = quoteBlock(text);
60
+ if (!block) return null;
61
+ const v = String(value ?? "");
62
+ const at = Math.max(0, Math.min(Number.isInteger(caret) ? caret : v.length, v.length));
63
+ const before = v.slice(0, at), after = v.slice(at);
64
+ const lead = !before ? "" : before.endsWith("\n\n") ? "" : before.endsWith("\n") ? "\n" : "\n\n";
65
+ const head = before + lead + block + "\n";
66
+ // Text after the caret starts its own line below the answer's (its leading spaces dropped with the break).
67
+ const tail = after && !after.startsWith("\n") ? "\n" + after.replace(/^[ \t]+/, "") : after;
68
+ return { value: head + tail, caret: head.length };
69
+ }
70
+
71
+ /** The selected passage when it lies inside one message's text of `list`, else null. { text, el, rects }. */
72
+ export function selectedPassage(list, sel) {
73
+ if (!sel || sel.isCollapsed || !sel.rangeCount) return null;
74
+ const text = String(sel.toString() || "");
75
+ if (!text.trim()) return null;
76
+ const msg = (n) => { const e = n && (n.nodeType === 1 ? n : n.parentElement); return e && e.closest ? e.closest(".msg[data-key]") : null; };
77
+ // The message's own words, not its header (sender, time) or its action strip.
78
+ const inBody = (n) => { const e = n && (n.nodeType === 1 ? n : n.parentElement); return !!(e && e.closest && e.closest(".body, .md") && !e.closest(".meta, .msg-actions")); };
79
+ // Every range of the selection (a browser may keep several: #3555 review P3) in the same message's words — what is
80
+ // quoted is the whole selection's text.
81
+ const range = sel.getRangeAt(0), a = msg(range.startContainer);
82
+ if (!a || !list.contains(a)) return null;
83
+ for (let i = 0; i < sel.rangeCount; i++) {
84
+ const rg = sel.getRangeAt(i);
85
+ if (msg(rg.startContainer) !== a || msg(rg.endContainer) !== a || !inBody(rg.startContainer) || !inBody(rg.endContainer)) return null;
86
+ }
87
+ return { text, el: a, range };
88
+ }
89
+
90
+ /**
91
+ * Where the composer's caret sits, in px from the top of its text (a mirror of the field's text box up to the caret).
92
+ * Used to show the caret without focusing the field (a phone: the keyboard stays down).
93
+ */
94
+ export function caretTop(field, pos) {
95
+ const doc = field.ownerDocument, win = doc.defaultView;
96
+ if (!win || !win.getComputedStyle) return 0;
97
+ const cs = win.getComputedStyle(field);
98
+ const m = doc.createElement("div");
99
+ for (const p of ["box-sizing", "width", "padding-top", "padding-right", "padding-bottom", "padding-left", "border-top-width", "border-right-width",
100
+ "border-bottom-width", "border-left-width", "font-family", "font-size", "font-weight", "font-style", "line-height", "letter-spacing", "word-spacing", "tab-size"]) {
101
+ m.style.setProperty(p, cs.getPropertyValue(p));
102
+ }
103
+ for (const [k, v] of [["position", "absolute"], ["visibility", "hidden"], ["top", "0"], ["left", "-9999px"], ["white-space", "pre-wrap"], ["overflow-wrap", "break-word"], ["height", "auto"]]) m.style.setProperty(k, v);
104
+ m.textContent = field.value.slice(0, pos);
105
+ const mark = doc.createElement("span"); mark.textContent = "​"; m.append(mark);
106
+ doc.body.append(m);
107
+ const y = mark.offsetTop, h = mark.offsetHeight;
108
+ m.remove();
109
+ return { y, h };
110
+ }
111
+
112
+ /** Scroll the field's own scroller so the caret (and the lines just above it: the newest quote) are in view. */
113
+ export function showCaret(field, pos) {
114
+ // At the end (the usual case: the newest quote is the last thing in the box): the bottom.
115
+ if (pos >= field.value.length) { field.scrollTop = field.scrollHeight; return; }
116
+ const c = caretTop(field, pos);
117
+ if (!c || typeof c !== "object") { field.scrollTop = field.scrollHeight; return; }
118
+ const view = field.clientHeight;
119
+ if (c.y + c.h > field.scrollTop + view) field.scrollTop = Math.max(0, c.y + c.h - view + 4);
120
+ else if (c.y < field.scrollTop) field.scrollTop = Math.max(0, c.y - 4);
121
+ }
122
+
123
+ // The quote mark: two marks on the shared 24-px grid, 2-px stroke, currentColor (as ui-icons.js draws).
124
+ const ICON = "M4 11h5v6H4v-6zm0 0c0-3 1.5-5 4-6M14 11h5v6h-5v-6zm0 0c0-3 1.5-5 4-6";
125
+ function iconEl(doc) {
126
+ const NS = "http://www.w3.org/2000/svg";
127
+ const svg = doc.createElementNS(NS, "svg");
128
+ for (const [k, v] of [["class", "icon"], ["width", "16"], ["height", "16"], ["viewBox", "0 0 24 24"], ["fill", "none"], ["stroke", "currentColor"], ["stroke-width", "2"],
129
+ ["stroke-linecap", "round"], ["stroke-linejoin", "round"], ["aria-hidden", "true"], ["focusable", "false"]]) svg.setAttribute(k, v);
130
+ const p = doc.createElementNS(NS, "path"); p.setAttribute("d", ICON); svg.append(p);
131
+ return svg;
132
+ }
133
+
134
+ const overlap = (a, z) => Math.max(0, Math.min(a.right, z.right) - Math.max(a.left, z.left)) * Math.max(0, Math.min(a.bottom, z.bottom) - Math.max(a.top, z.top));
135
+
136
+ /**
137
+ * Install the pill on `list` (the thread element). `deps`:
138
+ * field() → the composer's text field (marked data-touched once it has had the focus: its caret is the person's);
139
+ * canQuote() → boolean (a page that can send); insert(text) (the composer's side: see panel-chat.js);
140
+ * phone() → boolean (a coarse pointer); composerBox() → the composer's whole box (Element) or null; threadBox() → Element.
141
+ * Returns a function that removes everything.
142
+ */
143
+ export function installQuoteSelection(list, deps) {
144
+ const doc = list.ownerDocument, win = doc.defaultView;
145
+ let pop = null, timer = null, down = false, current = null, drawnFor = "";
146
+
147
+ function hide() {
148
+ current = null; drawnFor = "";
149
+ if (!pop) return;
150
+ pop.remove(); pop = null;
151
+ }
152
+ function place(passage) {
153
+ const phone = !!deps.phone?.();
154
+ if (!pop) {
155
+ pop = doc.createElement("div");
156
+ pop.className = "msg-menu quote-pop";
157
+ pop.setAttribute("role", "toolbar"); pop.setAttribute("data-trust", "menu"); pop.setAttribute("aria-label", tq("label"));
158
+ const b = doc.createElement("button");
159
+ b.type = "button"; b.className = "menu-item quote-pick";
160
+ b.append(iconEl(doc));
161
+ const span = doc.createElement("span"); b.append(span);
162
+ // A press on the pill must not collapse the selection it is about (mousedown's default does, pointerdown's
163
+ // preventDefault alone doesn't); the passage is the one the pill was drawn for, whatever the selection did since.
164
+ b.addEventListener("pointerdown", (e) => { e.preventDefault(); });
165
+ b.addEventListener("mousedown", (e) => { e.preventDefault(); });
166
+ b.addEventListener("click", (e) => { e.preventDefault(); const text = drawnFor; hide(); if (text) { deps.insert(text); doc.getSelection?.()?.removeAllRanges?.(); } });
167
+ pop.append(b);
168
+ doc.body.append(pop);
169
+ }
170
+ pop.classList.toggle("is-phone", phone);
171
+ const label = pop.querySelector(".quote-pick span"); label.textContent = tq(phone ? "quotePhone" : "quote");
172
+ for (const old of pop.querySelectorAll(".quote-other")) old.remove();
173
+ for (const target of deps.targets?.() || []) {
174
+ const b = doc.createElement("button"); b.type = "button"; b.className = "menu-item quote-pick quote-other";
175
+ b.append(iconEl(doc));
176
+ const span = doc.createElement("span"); span.textContent = target.label; b.append(span); b.title = target.label;
177
+ b.addEventListener("pointerdown", e => e.preventDefault()); b.addEventListener("mousedown", e => e.preventDefault());
178
+ b.addEventListener("click", e => { e.preventDefault(); const text = drawnFor; hide(); if (text) target.insert(text); });
179
+ pop.append(b);
180
+ }
181
+ pop.querySelector(".quote-tip")?.remove();
182
+ const pr = pop.getBoundingClientRect();
183
+ const vw = win?.innerWidth ?? 1024;
184
+ const rects = [...(passage.range.getClientRects?.() ?? [])].filter((x) => x.width > 0);
185
+ if (!rects.length) { hide(); return; }
186
+ const last = rects[rects.length - 1];
187
+ let left, top, tip = null;
188
+ if (!phone) {
189
+ // Room is the thread's visible box (the chat scroller, above the composer), within the window.
190
+ const th = deps.threadBox?.()?.getBoundingClientRect?.();
191
+ const vh = win?.innerHeight ?? 800;
192
+ const box = th && th.bottom > th.top ? th : { top: 0, bottom: vh };
193
+ const floor = Math.min(vh, box.bottom) - 4, ceil = Math.max(0, box.top) + 4;
194
+ left = Math.max(8, Math.min(last.right - pr.width / 2, vw - pr.width - 8));
195
+ const aboveTop = last.top - pr.height - 10, belowTop = last.bottom + 10;
196
+ // Below unless it would run out of the box and above fits (with no room either side, below).
197
+ const under = belowTop + pr.height <= floor || aboveTop < ceil;
198
+ top = under ? belowTop : aboveTop;
199
+ tip = { side: under ? "up" : "down", x: Math.max(10, Math.min(last.right - left - 5, pr.width - 20)) };
200
+ } else {
201
+ const box = deps.composerBox?.()?.getBoundingClientRect?.();
202
+ left = Math.max(16, vw - 16 - pr.width);
203
+ top = box ? box.top - pr.height - 12 : (win?.innerHeight ?? 800) - pr.height - 120;
204
+ const at = { left, right: left + pr.width, top: top - 8, bottom: top + pr.height + 8 };
205
+ if (rects.some((q) => overlap(at, q) > 0)) {
206
+ const th = deps.threadBox?.()?.getBoundingClientRect?.();
207
+ top = Math.max(th ? th.top : 0, 0) + 12;
208
+ }
209
+ }
210
+ if (tip) {
211
+ const s = doc.createElement("span"); s.className = `quote-tip ${tip.side}`; s.setAttribute("aria-hidden", "true");
212
+ s.style.setProperty("left", `${tip.x}px`);
213
+ pop.append(s);
214
+ }
215
+ pop.style.setProperty("left", `${Math.round(left)}px`);
216
+ pop.style.setProperty("top", `${Math.round(top)}px`);
217
+ }
218
+ function check() {
219
+ timer = null;
220
+ if (down || deps.canQuote?.() === false) { hide(); return; }
221
+ const passage = selectedPassage(list, doc.getSelection?.());
222
+ if (!passage) { hide(); return; }
223
+ current = passage; drawnFor = passage.text;
224
+ place(passage);
225
+ }
226
+ function soon() { if (timer) clearTimeout(timer); timer = setTimeout(check, 120); }
227
+ const onSelection = () => soon();
228
+ const onDown = (e) => { if (pop && pop.contains(e.target)) return; down = true; hide(); };
229
+ // A gesture the browser took over (a touch scroll: pointerdown → pointercancel, no pointerup — #3555 review P2-1)
230
+ // ends the press as a pointerup does; the selection then decides.
231
+ const onUp = () => { if (!down) return; down = false; soon(); };
232
+ const onKey = (e) => { if (e.key === "Escape" && pop) { hide(); } };
233
+ const onScroll = () => { if (pop && current) place(current); };
234
+ const onFocusIn = (e) => { const f = deps.field?.(); if (f && e.target === f) f.dataset.touched = "1"; };
235
+ // The caret as the person leaves it: kept on every move inside the composer and when it loses the focus.
236
+ const keep = (e) => { const f = deps.field?.(); if (f && e.target === f) remembered.set(f, { value: f.value, caret: f.selectionStart ?? f.value.length }); };
237
+ const KEEP = ["focusout", "input", "keyup", "mouseup", "select"];
238
+ doc.addEventListener("focusin", onFocusIn);
239
+ for (const k of KEEP) doc.addEventListener(k, keep, true);
240
+ doc.addEventListener("selectionchange", onSelection);
241
+ list.addEventListener("pointerdown", onDown);
242
+ doc.addEventListener("pointerup", onUp);
243
+ doc.addEventListener("pointercancel", onUp);
244
+ doc.addEventListener("keydown", onKey);
245
+ win?.addEventListener("scroll", onScroll, true);
246
+ win?.addEventListener("resize", onScroll);
247
+ return () => {
248
+ if (timer) clearTimeout(timer);
249
+ hide();
250
+ doc.removeEventListener("focusin", onFocusIn);
251
+ for (const k of KEEP) doc.removeEventListener(k, keep, true);
252
+ doc.removeEventListener("selectionchange", onSelection);
253
+ list.removeEventListener("pointerdown", onDown);
254
+ doc.removeEventListener("pointerup", onUp);
255
+ doc.removeEventListener("pointercancel", onUp);
256
+ doc.removeEventListener("keydown", onKey);
257
+ win?.removeEventListener("scroll", onScroll, true);
258
+ win?.removeEventListener("resize", onScroll);
259
+ };
260
+ }
261
+ installQuoteSelection.workspaceVersion = 1;
@@ -0,0 +1,175 @@
1
+ // M-3326 (the user, 11-18): a chat table's cells are selected as a spreadsheet's (Outline's tables), not as the
2
+ // browser's text selection that runs across whole rows. On a desk, press in a cell of a message's table and drag:
3
+ //
4
+ // - within that one cell, nothing changes — the browser's own text selection (and 「引用」 on it, #4155) as before;
5
+ // - into another cell of the same table, the selection becomes cells: the rectangle between the cell pressed and the
6
+ // cell under the pointer (straight down: one column; diagonally: a block), drawn as selected; the browser's text
7
+ // selection is dropped while it lasts. Shift+click on a cell of that table moves the far corner there.
8
+ // - Ctrl/Cmd+C copies those cells as TSV (a row per line, cells by tabs: a spreadsheet pastes it as cells); a cell that
9
+ // starts with = or @ gets a leading ' so it pastes as text, never as a live formula.
10
+ // - Esc, a press anywhere else, or a new press in a cell clears it. The thread drawing the table again clears it too.
11
+ //
12
+ // The Fleet chat and a Hub conversation install it on their thread (panel-chat.js, panel-hub.js). A phone (a coarse
13
+ // pointer) and a touch or pen press are left alone: there the press is the long-press menu and the system's own
14
+ // selection. The message menu, Reply and Copy text are untouched (they act on the whole message).
15
+ //
16
+ // CSSOM only (classes; no style attribute: #1300); app.css draws `.cell-sel` and `.cells-on`.
17
+
18
+ /** The tables whose cells can be selected: a message's Markdown table, and a csv/tsv text card's. */
19
+ const TABLES = ".msg .md table, .msg .tc-table";
20
+ const SEL = "cell-sel", ON = "cells-on";
21
+
22
+ const elOf = (n) => (n && (n.nodeType === 1 ? n : n.parentElement)) || null;
23
+
24
+ /** The cell (td/th) `node` is in, when that cell belongs to a selectable table inside `list`; else null. */
25
+ export function cellOf(list, node) {
26
+ const e = elOf(node);
27
+ const cell = e && e.closest ? e.closest("td, th") : null;
28
+ if (!cell) return null;
29
+ const table = cell.closest("table");
30
+ if (!table || !list.contains(table) || !table.matches(TABLES)) return null;
31
+ return cell;
32
+ }
33
+
34
+ /** The table's rows as arrays of cells (head rows first). Markdown and csv tables have no spans: a plain grid. */
35
+ export function grid(table) {
36
+ const rows = [];
37
+ for (const part of table.children) {
38
+ const trs = part.tagName === "TR" ? [part] : [...part.children].filter((r) => r.tagName === "TR");
39
+ for (const tr of trs) rows.push([...tr.children].filter((c) => c.tagName === "TD" || c.tagName === "TH"));
40
+ }
41
+ return rows;
42
+ }
43
+
44
+ /** Where a cell sits in its table's grid: { r, c }, or null. */
45
+ export function cellPos(rows, cell) {
46
+ for (let r = 0; r < rows.length; r++) { const c = rows[r].indexOf(cell); if (c >= 0) return { r, c }; }
47
+ return null;
48
+ }
49
+
50
+ /** The cells of the rectangle between two cells of one table, as rows of cells (a short row: the cells it has). */
51
+ export function rectCells(table, a, b) {
52
+ const rows = grid(table), pa = cellPos(rows, a), pb = cellPos(rows, b);
53
+ if (!pa || !pb) return [];
54
+ const [r0, r1] = [Math.min(pa.r, pb.r), Math.max(pa.r, pb.r)], [c0, c1] = [Math.min(pa.c, pb.c), Math.max(pa.c, pb.c)];
55
+ const out = [];
56
+ for (let r = r0; r <= r1; r++) out.push(rows[r].slice(c0, c1 + 1));
57
+ return out;
58
+ }
59
+
60
+ /** A cell's text for TSV: its words on one line (a tab or a line break inside becomes a space), ends trimmed. */
61
+ export function cellText(cell) {
62
+ return String(cell?.textContent ?? "").replace(/[\t\r\n]+/g, " ").replace(/ /g, " ").trim();
63
+ }
64
+
65
+ /**
66
+ * A cell as a spreadsheet takes it. M-3326 (#4172 review; the leader's call): a cell that starts with = or @ would be a live
67
+ * formula once pasted (a Hub room carries other people's words: =IMPORTXML(…)), so it gets a leading ' (kept as text).
68
+ * #4175 review (the leader's call): + or - starts a formula too (+HYPERLINK(…), -1+IMPORTXML(…)) unless the rest is a plain
69
+ * number — "-5", "+1", "-3.5", "+12%", "-1,234", "-.5" stay numbers; a lone "-" (a table's "none") stays as it is.
70
+ */
71
+ const FORMULA = /^(?:[=@]|[+-](?!(?:\.?\d[\d.,]*%?)?$))/;
72
+ export function tsvCell(cell) {
73
+ const text = cellText(cell);
74
+ return FORMULA.test(text) ? `'${text}` : text;
75
+ }
76
+
77
+ /** Rows of cells as TSV: cells by tabs, rows by line breaks. */
78
+ export function toTsv(rows) {
79
+ return rows.map((row) => row.map(tsvCell).join("\t")).join("\n");
80
+ }
81
+
82
+ /**
83
+ * Install the cell selection on `list` (the thread element). `deps.phone()` → true on a phone (a coarse pointer): then
84
+ * nothing is selected as cells. Returns a function that removes everything (and clears a selection).
85
+ */
86
+ export function installTableSelection(list, deps = {}) {
87
+ const doc = list.ownerDocument;
88
+ const win = doc.defaultView;
89
+ // anchor: the cell pressed; focus: the far corner; cells: true once the drag left the anchor (a cell selection).
90
+ let anchor = null, focus = null, cells = false, dragging = false, painted = [];
91
+
92
+ const phone = () => { try { return !!deps.phone?.(); } catch { return false; } };
93
+ function unpaint() {
94
+ for (const c of painted) c.classList.remove(SEL);
95
+ painted = [];
96
+ }
97
+ function clear() {
98
+ unpaint();
99
+ anchor?.closest?.("table")?.classList.remove(ON);
100
+ anchor = null; focus = null; cells = false; dragging = false;
101
+ }
102
+ const active = () => {
103
+ if (cells && anchor && !anchor.isConnected) clear(); // the thread drew the table again
104
+ return cells && !!anchor;
105
+ };
106
+ function paint() {
107
+ unpaint();
108
+ const table = anchor.closest("table");
109
+ for (const row of rectCells(table, anchor, focus)) for (const c of row) { c.classList.add(SEL); painted.push(c); }
110
+ }
111
+ function toCells(cell) {
112
+ if (!cells) { cells = true; anchor.closest("table")?.classList.add(ON); }
113
+ focus = cell; paint();
114
+ doc.getSelection?.()?.removeAllRanges?.();
115
+ }
116
+
117
+ function onDown(e) {
118
+ const cell = e.button === 0 && e.pointerType === "mouse" && !phone() ? cellOf(list, e.target) : null;
119
+ // Shift+click in the same table: the far corner moves there (a selection already made, or from the cell pressed).
120
+ if (cell && e.shiftKey && anchor && anchor.isConnected && cell.closest("table") === anchor.closest("table")) {
121
+ e.preventDefault(); dragging = true; toCells(cell); return;
122
+ }
123
+ clear();
124
+ if (!cell) return;
125
+ anchor = cell; focus = cell; dragging = true;
126
+ }
127
+ function onMove(e) {
128
+ if (!dragging || !anchor) return;
129
+ if (!anchor.isConnected) { clear(); return; }
130
+ const cell = cellOf(list, e.target);
131
+ // Off the table (or in another): the corner stays where it was.
132
+ if (!cell || cell.closest("table") !== anchor.closest("table")) { if (cells) doc.getSelection?.()?.removeAllRanges?.(); return; }
133
+ if (cell === focus && cells) { doc.getSelection?.()?.removeAllRanges?.(); return; }
134
+ if (cell === anchor && !cells) return; // still in the cell pressed: the browser's text selection
135
+ toCells(cell);
136
+ }
137
+ function onUp() { dragging = false; }
138
+ // While cells are selected, a drag must not start the browser's own selection again.
139
+ function onSelectStart(e) { if (dragging && cells) e.preventDefault(); }
140
+ function onKey(e) {
141
+ if (e.key === "Escape" && active()) clear();
142
+ }
143
+ function onCopy(e) {
144
+ if (!active()) return;
145
+ // A field with its own selection (the composer) copies its own text.
146
+ const ae = doc.activeElement;
147
+ if (ae && (ae.isContentEditable || /^(INPUT|TEXTAREA)$/.test(ae.tagName || "")) && ae.selectionStart !== ae.selectionEnd) return;
148
+ const sel = doc.getSelection?.();
149
+ if (sel && !sel.isCollapsed && String(sel.toString() || "").trim()) return; // a text selection made since
150
+ const tsv = toTsv(rectCells(anchor.closest("table"), anchor, focus));
151
+ if (!e.clipboardData) return;
152
+ e.clipboardData.setData("text/plain", tsv);
153
+ e.preventDefault();
154
+ }
155
+
156
+ doc.addEventListener("pointerdown", onDown, true);
157
+ doc.addEventListener("pointermove", onMove, true);
158
+ doc.addEventListener("pointerup", onUp, true);
159
+ doc.addEventListener("pointercancel", onUp, true);
160
+ doc.addEventListener("selectstart", onSelectStart, true);
161
+ doc.addEventListener("keydown", onKey);
162
+ doc.addEventListener("copy", onCopy);
163
+ win?.addEventListener?.("blur", onUp);
164
+ return () => {
165
+ clear();
166
+ doc.removeEventListener("pointerdown", onDown, true);
167
+ doc.removeEventListener("pointermove", onMove, true);
168
+ doc.removeEventListener("pointerup", onUp, true);
169
+ doc.removeEventListener("pointercancel", onUp, true);
170
+ doc.removeEventListener("selectstart", onSelectStart, true);
171
+ doc.removeEventListener("keydown", onKey);
172
+ doc.removeEventListener("copy", onCopy);
173
+ win?.removeEventListener?.("blur", onUp);
174
+ };
175
+ }
@@ -175,3 +175,31 @@ a.hub-launch-pill { border: 1px solid var(--border); background: transparent; co
175
175
 
176
176
  /* Room context H1: a short public introduction stays readable on narrow screens. */
177
177
  .hub-chat-title .hub-agent-intro-line{white-space:normal;overflow-wrap:anywhere;text-overflow:clip}
178
+
179
+ /* M-3311 (1): the Fleet chat's drop card over a Hub conversation, shown while files are dragged over it (app.css's
180
+ .p-chat.dragging .drop-overlay; .drop-overlay is hidden and .drop-card drawn there). */
181
+ .hub-chat-main.dragging { position: relative; }
182
+ .hub-chat-main.dragging .drop-overlay {
183
+ display: flex; position: absolute; inset: var(--s-2); z-index: 20; align-items: center; justify-content: center; pointer-events: none;
184
+ border: 2px dashed var(--accent); border-radius: var(--r-lg); background: color-mix(in srgb, var(--bg) 85%, transparent);
185
+ }
186
+
187
+ /* M-3311 (3): the Fleet chat's 「全寬」 for a Hub conversation (app.css .p-chat[data-width="full"]), on a desk; and the lines
188
+ under the box: the Enter hint, then the conversation's own note on a line of its own (side by side, a phone squeezed the
189
+ first to nothing). */
190
+ @media (min-width: 900px) and (pointer: fine), (min-width: 900px) and (pointer: none), (min-width: 900px) and (min-height: 501px), (min-width: 1024px) {
191
+ .hub-chat[data-width="full"] .thread, .hub-chat[data-width="full"] .dock-col { max-width: none; }
192
+ }
193
+ .composer-row.hub-hints { flex-direction: column; align-items: flex-start; gap: 0; }
194
+ .composer-row.hub-hints > .hint { flex-shrink: 0; max-width: 100%; }
195
+
196
+ /* M-3311 (4): a phone's room header is one row, as the Fleet chat's — back, the room (its name, then one line of counts), the
197
+ members and ⋯. The purpose is in the members sheet there (hub-room-members.js), and text size and Notify are in ⋯; the name
198
+ no longer sits on the top edge (the header has room above and below), and the counts are no longer cut to "2 人 · 0 個 …". */
199
+ @media (max-width: 899px), (pointer: coarse) and (max-height: 500px) and (max-width: 1023px) {
200
+ .hub-room-page .hub-chat-head { padding-block: var(--s-1); }
201
+ .hub-room-page .hub-chat-head .hub-chat-title .hub-room-purpose-trigger { display: none; }
202
+ .hub-room-page .hub-chat-head .hub-head-tools { display: none; }
203
+ /* …and its members and ⋯ are full tap targets, as its back is (S-150). */
204
+ .hub-room-page .hub-chat-head .hub-room-menu > .icon-btn, .hub-room-page .hub-chat-head .hub-room-rail-toggle { min-width: var(--tap); min-height: var(--tap); }
205
+ }
@@ -74,3 +74,8 @@
74
74
  .hub-source-trigger { min-height: var(--tap); min-width: var(--tap); }
75
75
  .hub-room-page .msg .meta { align-items: center; }
76
76
  }
77
+
78
+ /* Purpose stays one line in the header; tapping reads the complete room content. */
79
+ .hub-room-purpose-trigger{display:block;max-width:100%;min-height:24px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:start;border:0;background:none;padding:0;color:var(--text-3);font:inherit;font-size:var(--fs-xs);cursor:pointer}
80
+ .hub-room-purpose-full,.hub-room-purpose-panel p{white-space:pre-wrap;overflow-wrap:anywhere}
81
+ @media(max-width:640px),(pointer:coarse){.hub-room-purpose-trigger{min-height:var(--tap)}}
@@ -17,6 +17,7 @@ import { html, useEffect, useLayoutEffect, useRef, useState } from "/assets/app-
17
17
  import { clampPan, fitView, pinchView, stageToImage, zoomAt, STEP } from "./image-zoom.js";
18
18
  import { register, t } from "/assets/app-i18n.js";
19
19
  import { Icon } from "/assets/ui-icons.js";
20
+ import { assetUrl } from "./asset-url.js";
20
21
 
21
22
  export const annotateV1 = true;
22
23
  register("annotate", {
@@ -129,7 +130,7 @@ export function fillMissingTokens(el) {
129
130
  export function linkAnnotateCss(doc = typeof document !== "undefined" ? document : null) {
130
131
  if (!doc || !doc.head || doc.querySelector('link[data-annotate-css="1"]')) return;
131
132
  const link = doc.createElement("link");
132
- link.setAttribute("rel", "stylesheet"); link.setAttribute("href", "/assets/image-annotate.css"); link.setAttribute("data-annotate-css", "1");
133
+ link.setAttribute("rel", "stylesheet"); link.setAttribute("href", assetUrl("/assets/image-annotate.css")); link.setAttribute("data-annotate-css", "1");
133
134
  doc.head.appendChild(link);
134
135
  }
135
136
 
@@ -0,0 +1,3 @@
1
+ export function closureOf(graph: Record<string, string[]> | null, entry: string): string[];
2
+ export function createWarmer(opts?: { doc?: Document; url?: string }): (entry: string) => number;
3
+ export const warmModules: (entry: string) => number;
@@ -0,0 +1,39 @@
1
+ // M-3314: a panel opened after the page loaded (Settings, Fleet…) asks for its whole module graph at once, not one
2
+ // import level at a time over a slow link. The shell carries the served modules' static imports (#agend-modules, a
3
+ // signed-in admin's page only) and loads this file under its version (/assets/v-<V>/); a preload names the same
4
+ // versioned URL the import map gives the import, so the browser fetches each file once. Anywhere else (no graph, a
5
+ // plain path) it does nothing and the import loads as before.
6
+
7
+ const VERSIONED = /\/assets\/(v-[0-9a-f]{12})\/module-warm\.js(?:[?#]|$)/;
8
+
9
+ function readGraph(doc) {
10
+ try { const el = doc && doc.getElementById("agend-modules"); return el ? JSON.parse(el.textContent || "null") : null; } catch { return null; }
11
+ }
12
+
13
+ /** The module URLs (plain) `entry` imports statically, itself included. */
14
+ export function closureOf(graph, entry) {
15
+ const seen = new Set(), stack = [entry];
16
+ while (stack.length) { const u = stack.pop(); if (seen.has(u) || !graph || !Object.prototype.hasOwnProperty.call(graph, u)) continue; seen.add(u); for (const d of graph[u]) stack.push(d); }
17
+ return [...seen];
18
+ }
19
+
20
+ /** A warmer over this page: `warm(entry)` adds one modulepreload per module of the entry's graph not asked for yet. */
21
+ export function createWarmer({ doc = globalThis.document, url = import.meta.url } = {}) {
22
+ const m = VERSIONED.exec(url);
23
+ const graph = m ? readGraph(doc) : null;
24
+ const version = m ? m[1] : null;
25
+ return function warm(entry) {
26
+ if (!graph || !version || !doc || !doc.head) return 0;
27
+ let added = 0;
28
+ for (const u of closureOf(graph, entry)) {
29
+ const href = u.replace(/^\/(assets|ui\/js)\//, `/$1/${version}/`);
30
+ if (doc.head.querySelector(`link[rel="modulepreload"][href="${href}"]`)) continue;
31
+ const link = doc.createElement("link");
32
+ link.setAttribute("rel", "modulepreload"); link.setAttribute("href", href);
33
+ doc.head.appendChild(link); added++;
34
+ }
35
+ return added;
36
+ };
37
+ }
38
+
39
+ export const warmModules = createWarmer();
@@ -2,11 +2,12 @@
2
2
  import { html } from "./app-html.js";
3
3
  import { Icon } from "./ui-icons.js";
4
4
  import { t } from "./app-i18n.js";
5
+ import { assetUrl } from "./asset-url.js";
5
6
 
6
7
  // Lazy panels can arrive in a shell with an older app.css. Keep the loading shapes in their own public stylesheet.
7
8
  function loadingStyles() {
8
- if (typeof document === "undefined" || !document.head || document.querySelector('link[href="/assets/loading.css"]')) return;
9
- const link = document.createElement("link"); link.setAttribute("rel", "stylesheet"); link.setAttribute("href", "/assets/loading.css");
9
+ if (typeof document === "undefined" || !document.head || document.querySelector(`link[href="${assetUrl("/assets/loading.css")}"]`)) return;
10
+ const link = document.createElement("link"); link.setAttribute("rel", "stylesheet"); link.setAttribute("href", assetUrl("/assets/loading.css"));
10
11
  document.head.appendChild(link);
11
12
  }
12
13
  /** Initial data only: retain populated content on refresh. Existing callers still get simple text lines. */
@@ -13,6 +13,7 @@
13
13
  // links its own stylesheet (/assets/view-history.css): nothing it needs lives in a long-lived module. A server without
14
14
  // the history (an older one answers the pane's text) makes `first()` say `unsupported`: the View stays as it was.
15
15
  import { register, t } from "./app-i18n.js";
16
+ import { assetUrl } from "./asset-url.js";
16
17
 
17
18
  register("viewHistory", {
18
19
  en: {
@@ -431,7 +432,7 @@ function ensureStylesheet(doc) {
431
432
  if (!doc.head || doc.querySelector('link[data-vh="1"]')) return;
432
433
  const link = doc.createElement("link");
433
434
  link.setAttribute("rel", "stylesheet");
434
- link.setAttribute("href", "/assets/view-history.css");
435
+ link.setAttribute("href", assetUrl("/assets/view-history.css"));
435
436
  link.setAttribute("data-vh", "1");
436
437
  doc.head.appendChild(link);
437
438
  } catch { /* the history still reads without it */ }