@songsid/agend 2.4.0-beta.3 → 2.4.0-beta.4
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-endpoint.d.ts +1 -1
- package/dist/agent-endpoint.js +8 -2
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/auth-api.d.ts +3 -0
- package/dist/auth-api.js +15 -1
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/agy-model-switch.d.ts +22 -0
- package/dist/backend/agy-model-switch.js +62 -0
- package/dist/backend/agy-model-switch.js.map +1 -0
- package/dist/backend/antigravity.js +50 -1
- package/dist/backend/antigravity.js.map +1 -1
- package/dist/backend/cli-runtime-switch.d.ts +71 -0
- package/dist/backend/cli-runtime-switch.js +176 -0
- package/dist/backend/cli-runtime-switch.js.map +1 -0
- package/dist/backend/codex-model-switch.d.ts +41 -0
- package/dist/backend/codex-model-switch.js +170 -0
- package/dist/backend/codex-model-switch.js.map +1 -0
- package/dist/backend/grok-model-switch.d.ts +16 -0
- package/dist/backend/grok-model-switch.js +45 -0
- package/dist/backend/grok-model-switch.js.map +1 -0
- package/dist/backend/grok.js +1 -1
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/muse.d.ts +2 -0
- package/dist/backend/muse.js +7 -3
- package/dist/backend/muse.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/mcp-server.js +10 -1
- package/dist/channel/mcp-server.js.map +1 -1
- package/dist/channel/mcp-tools.js +8 -0
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/cli-audited.js +12 -12
- package/dist/cli-audited.js.map +1 -1
- package/dist/daemon.d.ts +47 -1
- package/dist/daemon.js +301 -20
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-consumed-watch.js +3 -0
- package/dist/delivery-consumed-watch.js.map +1 -1
- package/dist/fleet-manager.d.ts +102 -0
- package/dist/fleet-manager.js +663 -25
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +2 -0
- package/dist/general-knowledge/skills/fleet-health/SKILL.md +9 -1
- package/dist/general-knowledge/skills/hub/SKILL.md +154 -0
- package/dist/general-knowledge/skills/model-discovery/SKILL.md +4 -0
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +7 -3
- package/dist/hub/admin-dashboard.d.ts +85 -0
- package/dist/hub/admin-dashboard.js +161 -0
- package/dist/hub/admin-dashboard.js.map +1 -0
- package/dist/hub/attachments/store.d.ts +2 -0
- package/dist/hub/attachments/store.js +6 -0
- package/dist/hub/attachments/store.js.map +1 -1
- package/dist/hub/client.d.ts +10 -0
- package/dist/hub/client.js +72 -10
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.d.ts +20 -0
- package/dist/hub/compose/member.js +212 -17
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.d.ts +8 -0
- package/dist/hub/compose/server.js +13 -2
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/display-name.d.ts +10 -0
- package/dist/hub/display-name.js +35 -0
- package/dist/hub/display-name.js.map +1 -0
- package/dist/hub/execution/service.d.ts +1 -0
- package/dist/hub/execution/service.js +1 -1
- package/dist/hub/execution/service.js.map +1 -1
- package/dist/hub/fleet-info.d.ts +12 -0
- package/dist/hub/fleet-info.js +14 -0
- package/dist/hub/fleet-info.js.map +1 -0
- package/dist/hub/fleet-update-model.d.ts +100 -0
- package/dist/hub/fleet-update-model.js +15 -0
- package/dist/hub/fleet-update-model.js.map +1 -0
- package/dist/hub/fleet-updates.d.ts +46 -0
- package/dist/hub/fleet-updates.js +282 -0
- package/dist/hub/fleet-updates.js.map +1 -0
- package/dist/hub/fleet-versions.d.ts +28 -0
- package/dist/hub/fleet-versions.js +80 -0
- package/dist/hub/fleet-versions.js.map +1 -0
- package/dist/hub/http/compose.d.ts +2 -0
- package/dist/hub/http/compose.js +192 -16
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/deps.d.ts +1 -0
- package/dist/hub/http/schema.js +13 -1
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/member/display-name.d.ts +9 -0
- package/dist/hub/member/display-name.js +71 -0
- package/dist/hub/member/display-name.js.map +1 -0
- package/dist/hub/member/exposure-api.d.ts +4 -0
- package/dist/hub/member/exposure-api.js +8 -3
- package/dist/hub/member/exposure-api.js.map +1 -1
- package/dist/hub/member/exposures.d.ts +4 -0
- package/dist/hub/member/exposures.js +20 -0
- package/dist/hub/member/exposures.js.map +1 -1
- package/dist/hub/member/pairing-api.js +3 -2
- package/dist/hub/member/pairing-api.js.map +1 -1
- package/dist/hub/member/recommendations.d.ts +37 -0
- package/dist/hub/member/recommendations.js +129 -0
- package/dist/hub/member/recommendations.js.map +1 -0
- package/dist/hub/member/room-ask.d.ts +60 -1
- package/dist/hub/member/room-ask.js +250 -22
- package/dist/hub/member/room-ask.js.map +1 -1
- package/dist/hub/member/room-post-answers.d.ts +52 -0
- package/dist/hub/member/room-post-answers.js +152 -0
- package/dist/hub/member/room-post-answers.js.map +1 -0
- package/dist/hub/member/room-post-receipt.d.ts +21 -0
- package/dist/hub/member/room-post-receipt.js +49 -0
- package/dist/hub/member/room-post-receipt.js.map +1 -0
- package/dist/hub/member/room-post.d.ts +100 -0
- package/dist/hub/member/room-post.js +223 -0
- package/dist/hub/member/room-post.js.map +1 -0
- package/dist/hub/member/updates.d.ts +92 -0
- package/dist/hub/member/updates.js +316 -0
- package/dist/hub/member/updates.js.map +1 -0
- package/dist/hub/protocol.d.ts +658 -1
- package/dist/hub/protocol.js +90 -13
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/published-version.d.ts +3 -0
- package/dist/hub/published-version.js +35 -0
- package/dist/hub/published-version.js.map +1 -0
- package/dist/hub/recommendation-model.d.ts +36 -0
- package/dist/hub/recommendation-model.js +9 -0
- package/dist/hub/recommendation-model.js.map +1 -0
- package/dist/hub/recommendations.d.ts +58 -0
- package/dist/hub/recommendations.js +211 -0
- package/dist/hub/recommendations.js.map +1 -0
- package/dist/hub/representative.d.ts +3 -0
- package/dist/hub/representative.js +1 -0
- package/dist/hub/representative.js.map +1 -1
- package/dist/hub/room-context-model.d.ts +43 -0
- package/dist/hub/room-context-model.js +12 -0
- package/dist/hub/room-context-model.js.map +1 -0
- package/dist/hub/rooms/agents.d.ts +41 -9
- package/dist/hub/rooms/agents.js +183 -21
- package/dist/hub/rooms/agents.js.map +1 -1
- package/dist/hub/rooms/assistant.d.ts +1 -6
- package/dist/hub/rooms/assistant.js +7 -2
- package/dist/hub/rooms/assistant.js.map +1 -1
- package/dist/hub/rooms/automation.d.ts +24 -0
- package/dist/hub/rooms/automation.js +66 -0
- package/dist/hub/rooms/automation.js.map +1 -0
- package/dist/hub/rooms/buttons.d.ts +85 -0
- package/dist/hub/rooms/buttons.js +62 -0
- package/dist/hub/rooms/buttons.js.map +1 -0
- package/dist/hub/rooms/context-cursor.d.ts +18 -0
- package/dist/hub/rooms/context-cursor.js +61 -0
- package/dist/hub/rooms/context-cursor.js.map +1 -0
- package/dist/hub/rooms/context.d.ts +1 -1
- package/dist/hub/rooms/context.js +4 -4
- package/dist/hub/rooms/context.js.map +1 -1
- package/dist/hub/rooms/mentions.d.ts +15 -0
- package/dist/hub/rooms/mentions.js +43 -0
- package/dist/hub/rooms/mentions.js.map +1 -0
- package/dist/hub/rooms/post-replies.d.ts +23 -0
- package/dist/hub/rooms/post-replies.js +114 -0
- package/dist/hub/rooms/post-replies.js.map +1 -0
- package/dist/hub/rooms/schema.d.ts +9 -0
- package/dist/hub/rooms/schema.js +43 -0
- package/dist/hub/rooms/schema.js.map +1 -1
- package/dist/hub/rooms/service.d.ts +136 -1
- package/dist/hub/rooms/service.js +727 -18
- package/dist/hub/rooms/service.js.map +1 -1
- package/dist/hub/rooms/types.d.ts +27 -3
- package/dist/hub/rooms.js +1 -1
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/runtime.d.ts +1 -1
- package/dist/hub/runtime.js +12 -0
- package/dist/hub/runtime.js.map +1 -1
- package/dist/hub/server.d.ts +6 -1
- package/dist/hub/server.js +75 -5
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/settings-directory-proof.js +22 -1
- package/dist/hub/settings-directory-proof.js.map +1 -1
- package/dist/hub/types.d.ts +133 -2
- package/dist/hub-contact-windows.d.ts +11 -0
- package/dist/hub-contact-windows.js +56 -0
- package/dist/hub-contact-windows.js.map +1 -0
- package/dist/hub-pairing-summary.d.ts +1 -1
- package/dist/hub-room-conversation.d.ts +14 -0
- package/dist/hub-room-conversation.js +60 -0
- package/dist/hub-room-conversation.js.map +1 -0
- package/dist/hub-update-notice.d.ts +12 -0
- package/dist/hub-update-notice.js +35 -0
- package/dist/hub-update-notice.js.map +1 -0
- package/dist/locale.js +56 -2
- package/dist/locale.js.map +1 -1
- package/dist/native-mcp.js +9 -6
- package/dist/native-mcp.js.map +1 -1
- package/dist/outbound-handlers.d.ts +14 -4
- package/dist/outbound-handlers.js +54 -1
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +12 -0
- package/dist/outbound-schemas.js +12 -0
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/pane-port.d.ts +2 -0
- package/dist/queued-handoffs.d.ts +16 -4
- package/dist/queued-handoffs.js +18 -1
- package/dist/queued-handoffs.js.map +1 -1
- package/dist/runtime-cli-install.js +13 -10
- package/dist/runtime-cli-install.js.map +1 -1
- package/dist/settings-api.d.ts +1 -0
- package/dist/settings-api.js +87 -0
- package/dist/settings-api.js.map +1 -1
- package/dist/tmux-manager.d.ts +2 -0
- package/dist/tmux-manager.js +2 -0
- package/dist/tmux-manager.js.map +1 -1
- package/dist/tool-permissions.js +3 -0
- package/dist/tool-permissions.js.map +1 -1
- package/dist/ui/chat-msg-actions.js +3 -222
- package/dist/ui/hub-admin-overview.js +189 -0
- package/dist/ui/hub-client.js +36 -4
- package/dist/ui/hub-fleet-versions.js +393 -0
- package/dist/ui/hub-room-agent-strings.js +28 -0
- package/dist/ui/hub-room-composer.js +5 -3
- package/dist/ui/hub-room-members-strings.js +2 -2
- package/dist/ui/hub-room-members.js +3 -2
- package/dist/ui/hub-room-notify.js +161 -0
- package/dist/ui/hub-room-search.js +126 -0
- package/dist/ui/hub-room-strings.js +46 -0
- package/dist/ui/hub-room-thread.js +239 -34
- package/dist/ui/hub-room-unread.js +2 -1
- package/dist/ui/hub-strings.js +8 -0
- package/dist/ui/image-annotate.js +2 -283
- package/dist/ui/image-lightbox.js +2 -176
- package/dist/ui/image-zoom.js +2 -242
- package/dist/ui/notice-hub-update.js +94 -0
- package/dist/ui/panel-chat.js +35 -6
- package/dist/ui/panel-hub.js +133 -19
- package/dist/ui/panel-notices.js +3 -1
- package/dist/ui/panel-settings.js +1 -1
- package/dist/ui/settings-hub-updates.js +67 -0
- package/dist/ui/settings-hub.js +28 -3
- package/dist/ui/settings-registry.js +1 -0
- package/dist/ui/settings-update.js +11 -5
- package/dist/ui/settings-web-authority.js +1 -1
- package/dist/ui/shared/app-i18n.js +2 -0
- package/dist/ui/shared/app-nav.js +6 -2
- package/dist/ui/shared/app-prefs.js +2 -1
- package/dist/ui/shared/app-shell.js +11 -1
- package/dist/ui/shared/app-update.js +90 -8
- package/dist/ui/shared/app.css +20 -0
- package/dist/ui/shared/chat-msg-actions.js +225 -0
- package/dist/ui/shared/chat-thread.js +70 -5
- package/dist/ui/shared/chat-work-bar.css +25 -13
- package/dist/ui/shared/hub-chat.css +6 -1
- package/dist/ui/shared/hub-owner.css +104 -0
- package/dist/ui/shared/hub-rooms-u2.css +16 -0
- package/dist/ui/shared/hub.css +5 -0
- package/dist/ui/shared/image-annotate.js +306 -0
- package/dist/ui/shared/image-lightbox.js +183 -0
- package/dist/ui/shared/image-zoom.js +242 -0
- package/dist/ui/shared/instance-nav.js +36 -7
- package/dist/ui/shared/view-strings.js +6 -0
- package/dist/ui/shared/web-authorize.js +2 -2
- package/dist/update-dispatch.d.ts +8 -1
- package/dist/update-dispatch.js +16 -1
- package/dist/update-dispatch.js.map +1 -1
- package/dist/update-idle.d.ts +65 -0
- package/dist/update-idle.js +190 -0
- package/dist/update-idle.js.map +1 -0
- package/dist/update-launch.d.ts +1 -1
- package/dist/update-launch.js +9 -2
- package/dist/update-launch.js.map +1 -1
- package/dist/usage/profile-timeline.d.ts +2 -0
- package/dist/usage/profile-timeline.js +4 -0
- package/dist/usage/profile-timeline.js.map +1 -1
- package/dist/web-api.js +19 -2
- package/dist/web-api.js.map +1 -1
- package/dist/web-notices.d.ts +3 -0
- package/dist/web-notices.js +17 -2
- package/dist/web-notices.js.map +1 -1
- package/dist/web-prefs.js +1 -0
- package/dist/web-prefs.js.map +1 -1
- package/dist/web-update.d.ts +15 -1
- package/package.json +1 -1
|
@@ -73,6 +73,7 @@ register("app", {
|
|
|
73
73
|
brand: "AgEnD", fleet: "Fleet", fleetOverview: "Fleet", view: "View", settings: "Settings", instances: "Instances", newInstance: "New instance", newAgent: "New agent",
|
|
74
74
|
collapse: "Hide the sidebar", expand: "Show the sidebar", openMenu: "Open the sidebar", closeMenu: "Close the sidebar",
|
|
75
75
|
resizeSidebar: "Sidebar width", resizeSidebarHint: "Drag to resize · double-click to reset",
|
|
76
|
+
sidebarDensity: "Sidebar agent list", sidebarDetailed: "Detailed", sidebarCompact: "Compact",
|
|
76
77
|
names: "Names", namesNickname: "Nickname first", namesInstance: "Real name first",
|
|
77
78
|
theme: "Theme", themeSystem: "System", themeLight: "Light", themeDark: "Dark", language: "Language",
|
|
78
79
|
previews: "Allow HTML previews", tour: "Tour", tourTitle: "Show the web chat tour again",
|
|
@@ -123,6 +124,7 @@ register("app", {
|
|
|
123
124
|
brand: "AgEnD", fleet: "Fleet", fleetOverview: "Fleet 概覽", view: "檢視", settings: "設定", instances: "Agent", newInstance: "新增 Agent", newAgent: "新增 Agent",
|
|
124
125
|
collapse: "隱藏側邊欄", expand: "顯示側邊欄", openMenu: "打開側邊欄", closeMenu: "關閉側邊欄",
|
|
125
126
|
resizeSidebar: "側邊欄寬度", resizeSidebarHint: "拖曳調整寬度 · 按兩下恢復預設",
|
|
127
|
+
sidebarDensity: "側邊欄 Agent 清單", sidebarDetailed: "詳細", sidebarCompact: "精簡",
|
|
126
128
|
names: "名稱", namesNickname: "暱稱優先", namesInstance: "實際名稱優先",
|
|
127
129
|
theme: "主題", themeSystem: "跟隨系統", themeLight: "淺色", themeDark: "深色", language: "語言",
|
|
128
130
|
previews: "允許預覽 HTML", tour: "導覽", tourTitle: "再看一次網頁聊天導覽",
|
|
@@ -95,7 +95,11 @@ export function onLinkClick(e) {
|
|
|
95
95
|
if ((a.getAttribute("href") || "").startsWith("#")) return;
|
|
96
96
|
const url = new URL(a.getAttribute("href"), win.location.href);
|
|
97
97
|
if (url.hash && url.pathname === win.location.pathname && url.search === win.location.search) return;
|
|
98
|
-
|
|
98
|
+
const route = url.origin === win.location.origin ? parseRoute(url.pathname) : null;
|
|
99
|
+
if (!route) return;
|
|
99
100
|
e.preventDefault();
|
|
100
|
-
|
|
101
|
+
// M-3131: a place in Settings (/settings/access#webAuthority) keeps its hash — Settings reveals the tab that owns it
|
|
102
|
+
// (#2347), as it does for a typed or pasted address.
|
|
103
|
+
const keepHash = route.panel === "settings" || (navigation && (navStore.get().workspace || url.searchParams.has("compare")));
|
|
104
|
+
navigate(url.pathname + url.search + (keepHash ? url.hash : ""));
|
|
101
105
|
}
|
|
@@ -31,6 +31,7 @@ export const SYNCED = {
|
|
|
31
31
|
"nav.collapsed": { ls: "agend_instance_collapsed", ...json },
|
|
32
32
|
"nav.filter": { ls: "agend_instance_filter", ...json },
|
|
33
33
|
"nav.favorites": { ls: "agend_favorites", ...json }, // #1664
|
|
34
|
+
"nav.density": { ls: "agend_nav_density", toLocal: (v) => (v === "compact" ? v : null), fromLocal: (s) => (s === "compact" ? s : undefined) },
|
|
34
35
|
"nav.sort": { ls: "agend_nav_sort", ...json }, // #2179
|
|
35
36
|
"preview.optIn": { ls: "agend_html_preview", toLocal: (v) => (v ? "on" : null), fromLocal: (s) => (s === "on" ? true : undefined) },
|
|
36
37
|
"names.primary": { ls: "agend_names_primary", toLocal: (v) => (v === "instance" ? v : null), fromLocal: (s) => (s === "instance" ? s : undefined) }, // #1722
|
|
@@ -86,7 +87,7 @@ const listeners = new Set();
|
|
|
86
87
|
// this page's own in prefInForce) but not sent: `held` keeps it until savePrefsHeld sends them all, or discardHeldPrefs
|
|
87
88
|
// puts back what the host has (the same path as another device's change: apply and onPrefsChanged).
|
|
88
89
|
// Only keys Settings itself changes (a card's own size, card.sizeByInstance, is set from the card, outside Settings).
|
|
89
|
-
export const HELD_KEYS = Object.freeze(new Set(["theme", "lang", "names.primary", "preview.optIn", "fx.show", "color.show", "color.off", "card.size"]));
|
|
90
|
+
export const HELD_KEYS = Object.freeze(new Set(["theme", "lang", "names.primary", "nav.density", "preview.optIn", "fx.show", "color.show", "color.off", "card.size"]));
|
|
90
91
|
let holding = 0;
|
|
91
92
|
const held = new Map(); // key → value chosen in Settings, shown here, not saved yet
|
|
92
93
|
const heldFrom = new Map(); // key → its cached form before it was held (a choice back to it is no change)
|
|
@@ -17,7 +17,7 @@ import { applyPageTheme, pageNow, resolvedMode, themesStore } from "./app-themes
|
|
|
17
17
|
import { ErrorState, Skeleton } from "./ui-states.js";
|
|
18
18
|
import { StaleTabPrompt, isStaleModuleError } from "./stale-tab.js";
|
|
19
19
|
import { Dialog } from "./ui-dialog.js";
|
|
20
|
-
import { InstanceNav, RosterNav, namesStore, setNamesPrimary } from "./instance-nav.js";
|
|
20
|
+
import { InstanceNav, RosterNav, namesStore, setNamesPrimary, sidebarDensityStore, setSidebarDensity } from "./instance-nav.js";
|
|
21
21
|
import { usageRailStore } from "./header-tools.js";
|
|
22
22
|
import { RightRail, sidePanelStore } from "./side-panel.js";
|
|
23
23
|
import { OwnerCssKeepBar } from "./owner-css.js";
|
|
@@ -510,6 +510,7 @@ export function DevicePrefs({ labels = false, fields = ["theme", "language", "na
|
|
|
510
510
|
const [theme, setTheme] = useState(typeof AgendTheme !== "undefined" ? AgendTheme.get() : "system");
|
|
511
511
|
const [l, setL] = useState(lang());
|
|
512
512
|
const names = useStore(namesStore); // #1722
|
|
513
|
+
const density = useStore(sidebarDensityStore).value;
|
|
513
514
|
// #1665: what is in force, as it changes — another device's choice arriving while this is open is shown at once.
|
|
514
515
|
useEffect(() => (typeof AgendTheme !== "undefined" && typeof AgendTheme.onChange === "function" ? AgendTheme.onChange(setTheme) : undefined), []);
|
|
515
516
|
useEffect(() => onLang(setL), []);
|
|
@@ -524,6 +525,9 @@ export function DevicePrefs({ labels = false, fields = ["theme", "language", "na
|
|
|
524
525
|
${shows("names") ? html`<label class="pref"><${Icon} name="user" size=${16} /><span class=${labels ? "pref-label" : "sr-only"}>${t("app.names")}</span>
|
|
525
526
|
<select id=${labels ? "pref-names" : undefined} value=${names.primary} aria-label=${t("app.names")} onChange=${(e) => setNamesPrimary(e.target.value)}>
|
|
526
527
|
<option value="nickname">${t("app.namesNickname")}</option><option value="instance">${t("app.namesInstance")}</option></select></label>` : null}
|
|
528
|
+
${shows("density") ? html`<label class="pref"><${Icon} name="sidebar" size=${16} /><span class=${labels ? "pref-label" : "sr-only"}>${t("app.sidebarDensity")}</span>
|
|
529
|
+
<select id=${labels ? "pref-density" : undefined} value=${density} aria-label=${t("app.sidebarDensity")} onChange=${(e) => setSidebarDensity(e.target.value)}>
|
|
530
|
+
<option value="detailed">${t("app.sidebarDetailed")}</option><option value="compact">${t("app.sidebarCompact")}</option></select></label>` : null}
|
|
527
531
|
</div>`;
|
|
528
532
|
}
|
|
529
533
|
|
|
@@ -693,6 +697,8 @@ register("pendingSummary", {
|
|
|
693
697
|
"general_location.confirm_windows": "Run General on {0}? Its current process must stop first. The chat stays here. The host conversation is kept; Windows uses its own conversation. Pending or uncertain input will not be sent to the other conversation.",
|
|
694
698
|
"general_location.history": "Host and Windows conversations stay separate. Switching does not copy or merge their history.",
|
|
695
699
|
"hub.exposure.summary.share": "Share \"{0}\" with the Hub",
|
|
700
|
+
"hub.exposure.summary.contactLimited": "While answering a Hub question, this agent may not contact other agents",
|
|
701
|
+
"hub.exposure.summary.contactAllowed": "While answering a Hub question, this agent may contact other agents",
|
|
696
702
|
"hub.exposure.summary.context": "Hub questions go to this agent's own conversation, with its folder and Settings tools",
|
|
697
703
|
"hub.exposure.summary.revision": "Revision: {0}",
|
|
698
704
|
"hub.pairing.summary.connect": "Connect this fleet to the Hub at {0}",
|
|
@@ -734,6 +740,8 @@ register("pendingSummary", {
|
|
|
734
740
|
"general_location.confirm_windows": "要讓 General 在 {0} 執行嗎?必須先停止目前的程序。聊天位置不變。主機上的對話會保留,Windows 使用自己的對話。待處理或結果不明的輸入不會送到另一段對話。",
|
|
735
741
|
"general_location.history": "主機與 Windows 各自保留對話,切換時不會複製或合併對話紀錄。",
|
|
736
742
|
"hub.exposure.summary.share": "將「{0}」分享給 Hub",
|
|
743
|
+
"hub.exposure.summary.contactLimited": "回答 Hub 提問時,這個 Agent 不能聯絡其他 Agent",
|
|
744
|
+
"hub.exposure.summary.contactAllowed": "回答 Hub 提問時,這個 Agent 可以聯絡其他 Agent",
|
|
737
745
|
"hub.exposure.summary.context": "Hub 提問會送到這個 Agent 自己的對話,使用其資料夾與設定的工具",
|
|
738
746
|
"hub.exposure.summary.revision": "修訂版本:{0}",
|
|
739
747
|
"hub.pairing.summary.connect": "將這個 Fleet 連接到 {0} 的 Hub",
|
|
@@ -776,6 +784,8 @@ const pendingSummaryArguments = Object.fromEntries([
|
|
|
776
784
|
["general_location.confirm_windows", "s"],
|
|
777
785
|
["general_location.history", ""],
|
|
778
786
|
["hub.exposure.summary.share", "s"],
|
|
787
|
+
["hub.exposure.summary.contactLimited", ""],
|
|
788
|
+
["hub.exposure.summary.contactAllowed", ""],
|
|
779
789
|
["hub.exposure.summary.context", ""],
|
|
780
790
|
["hub.exposure.summary.revision", "n"],
|
|
781
791
|
["hub.pairing.summary.connect", "s"],
|
|
@@ -29,6 +29,9 @@ register("update", {
|
|
|
29
29
|
dismiss: "Dismiss", adminOnly: "Only a fleet admin can update AgEnD.", running: "An update is already running.",
|
|
30
30
|
upToDate: "AgEnD v{0} is up to date.", stableOnly: "v{0} (stable) is available. Updating from the web stays on this install's line.",
|
|
31
31
|
failedToStart: "The update could not be started: {0}", startedToast: "Update started.",
|
|
32
|
+
hubAvailable: "{0} recommends AgEnD v{1} (current v{2})", hubSub: "Some Hub features need it. Only admins see this.",
|
|
33
|
+
hubLine: "the version {0} recommends", recChanged: "The Hub's recommended version changed. Look at the banner again.",
|
|
34
|
+
hubAsked: "the version {0} ({1}) asked for", requestGone: "This update request is no longer waiting.",
|
|
32
35
|
},
|
|
33
36
|
"zh-TW": {
|
|
34
37
|
available: "AgEnD v{0} 已推出(目前 v{1})", availableSub: "{0} · 只有管理員看得到", now: "立即更新", later: "稍後",
|
|
@@ -47,6 +50,9 @@ register("update", {
|
|
|
47
50
|
dismiss: "關閉", adminOnly: "只有 fleet 管理員可以更新 AgEnD。", running: "已經有一個更新在進行中。",
|
|
48
51
|
upToDate: "AgEnD v{0} 已是最新版。", stableOnly: "v{0}(穩定版)已推出。網頁更新會留在這個安裝的版本線。",
|
|
49
52
|
failedToStart: "無法開始更新:{0}", startedToast: "已開始更新。",
|
|
53
|
+
hubAvailable: "{0} 建議更新到 AgEnD v{1}(目前 v{2})", hubSub: "部分 Hub 功能需要這個版本。只有管理員看得到。",
|
|
54
|
+
hubLine: "{0} 建議的版本", recChanged: "Hub 建議的版本已變更,請再看一次橫幅。",
|
|
55
|
+
hubAsked: "{0}({1})要求的版本", requestGone: "這個更新要求已經不在等待中。",
|
|
50
56
|
},
|
|
51
57
|
});
|
|
52
58
|
|
|
@@ -56,13 +62,47 @@ const STEP = { preparing: 1, downloading: 2, installed: 3, stopping: 3, starting
|
|
|
56
62
|
function remembered(key) { try { return localStorage.getItem(key); } catch { return null; } }
|
|
57
63
|
function remember(key, value) { try { localStorage.setItem(key, value); } catch { /* this page only */ } }
|
|
58
64
|
const LATER_KEY = "agend_update_later", DISMISSED_KEY = "agend_update_dismissed";
|
|
65
|
+
// M-3140: Later on the Hub's line hides it for a day ("<hubId>:<revision>@<ms>"); new advice shows at once.
|
|
66
|
+
const LATER_HUB_KEY = "agend_update_later_hub", LATER_HUB_MS = 24 * 60 * 60 * 1000;
|
|
59
67
|
|
|
60
68
|
/**
|
|
61
69
|
* `info`: GET /ui/update's answer (null: none — an older server, a guest, signed out). `loadedVersion`: the version this
|
|
62
70
|
* tab was loaded on (the first answer's): a later answer naming another one means this tab runs the old page.
|
|
63
71
|
*/
|
|
64
72
|
export const updateStore = createStore({ info: null, loadedVersion: null, skew: 0, starting: false, later: remembered(LATER_KEY),
|
|
65
|
-
dismissed: remembered(DISMISSED_KEY), reloadDismissed: null, log: null });
|
|
73
|
+
dismissed: remembered(DISMISSED_KEY), reloadDismissed: null, log: null, laterHub: remembered(LATER_HUB_KEY) });
|
|
74
|
+
|
|
75
|
+
/** Semver "a > b" (major.minor.patch, then a release over its prereleases, then prerelease identifiers) — the server's rule. */
|
|
76
|
+
export function newerVersion(a, b) {
|
|
77
|
+
const parse = (v) => { const m = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(String(v || "")); return m ? { core: [+m[1], +m[2], +m[3]], pre: m[4] ? m[4].split(".") : null } : null; };
|
|
78
|
+
const x = parse(a), y = parse(b);
|
|
79
|
+
if (!x || !y) return false;
|
|
80
|
+
for (let i = 0; i < 3; i++) if (x.core[i] !== y.core[i]) return x.core[i] > y.core[i];
|
|
81
|
+
if (!x.pre || !y.pre) return !x.pre && !!y.pre;
|
|
82
|
+
for (let i = 0; i < Math.max(x.pre.length, y.pre.length); i++) {
|
|
83
|
+
const p = x.pre[i], q = y.pre[i];
|
|
84
|
+
if (p === undefined) return false; if (q === undefined) return true;
|
|
85
|
+
const pn = /^\d+$/.test(p), qn = /^\d+$/.test(q);
|
|
86
|
+
if (pn && qn) { if (+p !== +q) return +p > +q; } else if (pn !== qn) return !pn; else if (p !== q) return p > q;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* M-3140: the Hub's advice this admin should be shown, or null. One banner (spec §3.3): when the install's own update
|
|
93
|
+
* already reaches the advised version, today's line says it; the Hub's line only when its version is the higher need.
|
|
94
|
+
*/
|
|
95
|
+
export function hubNeed(info) {
|
|
96
|
+
const rec = info && info.admin ? info.hubRecommendation : null;
|
|
97
|
+
if (!rec || typeof rec.version !== "string" || !newerVersion(rec.version, info.current)) return null;
|
|
98
|
+
const offer = info.offer;
|
|
99
|
+
if (offer && offer.installable && !newerVersion(rec.version, offer.version)) return null;
|
|
100
|
+
return rec;
|
|
101
|
+
}
|
|
102
|
+
function hubLaterActive(laterHub, rec, now = Date.now()) {
|
|
103
|
+
const m = /^(.*)@(\d+)$/.exec(laterHub || "");
|
|
104
|
+
return !!m && m[1] === `${rec.hubId}:${rec.revision}` && now - Number(m[2]) < LATER_HUB_MS && now >= Number(m[2]);
|
|
105
|
+
}
|
|
66
106
|
|
|
67
107
|
export function updateActive(info) { return !!(info && info.progress && ACTIVE.has(info.progress.stage)); }
|
|
68
108
|
|
|
@@ -96,22 +136,55 @@ function channelWord(channel) { return t(`update.channel_${channel === "alpha" |
|
|
|
96
136
|
function sameLine(channel) { return t(`update.same_${channel === "alpha" || channel === "latest" ? channel : "beta"}`); }
|
|
97
137
|
|
|
98
138
|
/** The one confirmation (the leader's D1: the admin's own, no General card), then the start. From the line, Settings or /update. */
|
|
99
|
-
export async function openUpdateDialog() {
|
|
139
|
+
export async function openUpdateDialog() { return startUpdate(null); }
|
|
140
|
+
/** M-3140: the same confirmation and start, pinned to the Hub's recommended version (the server re-reads its own advice). */
|
|
141
|
+
export async function openHubUpdateDialog() { return startUpdate("hub"); }
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* M-3145 (versions spec §4.4; M-3144 #3963): Update now on an owner's notice about an update this Hub's administrator
|
|
145
|
+
* asked for. The notice is not the authority: the page rereads the Fleet's own copy of the request
|
|
146
|
+
* (GET /api/settings/hub/fleet-updates/:id), asks the same question naming that version, and starts it by the
|
|
147
|
+
* request's id — never a version (`hubRequestId`). Waiting or expired only (an expired one starts as a new local update).
|
|
148
|
+
*/
|
|
149
|
+
export async function openHubRequestedUpdate({ requestId, hubName = "", requestedBy = "" } = {}) {
|
|
100
150
|
let info = updateStore.get().info;
|
|
101
151
|
if (!info) info = await refreshUpdate();
|
|
102
152
|
if (!info || !info.admin) { toast(t("update.adminOnly"), false); return { ok: false }; }
|
|
103
153
|
if (updateActive(info)) { toast(t("update.running")); return { ok: false }; }
|
|
154
|
+
let req = null;
|
|
155
|
+
try { const r = await fetch(`/api/settings/hub/fleet-updates/${encodeURIComponent(String(requestId || ""))}`, { cache: "no-store" }); if (r.ok) req = await r.json(); } catch { req = null; }
|
|
156
|
+
if (!req || (req.state !== "waiting" && req.state !== "expired") || typeof req.version !== "string") { toast(t("update.requestGone"), false); return { ok: false }; }
|
|
157
|
+
const yes = await confirmDialog({ title: t("update.confirmTitle"), confirmLabel: t("update.confirmGo"),
|
|
158
|
+
message: t("update.confirmBody", req.version, t("update.hubAsked", requestedBy, hubName)) });
|
|
159
|
+
if (!yes) return { ok: false };
|
|
160
|
+
return postStart({ hubRequestId: req.id || requestId });
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async function startUpdate(kind) {
|
|
164
|
+
let info = updateStore.get().info;
|
|
165
|
+
if (!info) info = await refreshUpdate();
|
|
166
|
+
if (!info || !info.admin) { toast(t("update.adminOnly"), false); return { ok: false }; }
|
|
167
|
+
if (updateActive(info)) { toast(t("update.running")); return { ok: false }; }
|
|
168
|
+
const rec = kind === "hub" ? hubNeed(info) : null;
|
|
169
|
+
if (kind === "hub" && !rec) { toast(t("update.recChanged"), false); return { ok: false }; }
|
|
104
170
|
const offer = info.offer;
|
|
105
|
-
if (!
|
|
106
|
-
|
|
171
|
+
if (!rec) {
|
|
172
|
+
if (!offer) { toast(t("update.upToDate", info.current)); return { ok: false }; }
|
|
173
|
+
if (!offer.installable) { toast(t("update.stableOnly", offer.version), false); return { ok: false }; }
|
|
174
|
+
}
|
|
107
175
|
const yes = await confirmDialog({ title: t("update.confirmTitle"), confirmLabel: t("update.confirmGo"),
|
|
108
|
-
message: t("update.confirmBody", offer.version, sameLine(offer.channel)) });
|
|
176
|
+
message: rec ? t("update.confirmBody", rec.version, t("update.hubLine", rec.hubName)) : t("update.confirmBody", offer.version, sameLine(offer.channel)) });
|
|
109
177
|
if (!yes) return { ok: false };
|
|
178
|
+
return postStart(rec ? { recommended: { version: rec.version, revision: rec.revision } } : {});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** The start itself, after the one question: what the update is pinned to (`extra`), the progress or why not. */
|
|
182
|
+
async function postStart(extra) {
|
|
110
183
|
updateStore.set({ starting: true });
|
|
111
184
|
const key = `update-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
112
185
|
let res = null, body = null;
|
|
113
186
|
try {
|
|
114
|
-
res = await fetch("/ui/update/start", { method: "POST", headers: { "Content-Type": "application/json", "Idempotency-Key": key }, body: JSON.stringify({ confirm: "update-agend" }) });
|
|
187
|
+
res = await fetch("/ui/update/start", { method: "POST", headers: { "Content-Type": "application/json", "Idempotency-Key": key }, body: JSON.stringify({ confirm: "update-agend", ...extra }) });
|
|
115
188
|
try { body = await res.json(); } catch { body = null; }
|
|
116
189
|
} catch { res = null; }
|
|
117
190
|
updateStore.set({ starting: false });
|
|
@@ -120,7 +193,8 @@ export async function openUpdateDialog() {
|
|
|
120
193
|
await refreshUpdate();
|
|
121
194
|
return { ok: true };
|
|
122
195
|
}
|
|
123
|
-
|
|
196
|
+
if (body && body.error === "recommendation_changed") toast(t("update.recChanged"), false);
|
|
197
|
+
else toast(t("update.failedToStart", (body && body.error) || (res ? String(res.status) : "network")), false);
|
|
124
198
|
await refreshUpdate();
|
|
125
199
|
return { ok: false };
|
|
126
200
|
}
|
|
@@ -155,6 +229,8 @@ function Dismiss({ onClick }) {
|
|
|
155
229
|
}
|
|
156
230
|
|
|
157
231
|
/** The updater's own words, on request (never on the line itself). */
|
|
232
|
+
/** The last update's log (the line's See the full log; an owner's rolled-back notice). */
|
|
233
|
+
export async function openUpdateLog() { return openLog(); }
|
|
158
234
|
async function openLog() {
|
|
159
235
|
let body = null;
|
|
160
236
|
try { const r = await fetch("/ui/update/log", { cache: "no-store" }); if (r.ok) body = await r.json(); } catch { body = null; }
|
|
@@ -205,7 +281,13 @@ export function UpdateLine() {
|
|
|
205
281
|
} else if (p && p.stage === "complete" && p.web && s.dismissed !== String(p.started_at)) {
|
|
206
282
|
line = html`<${Line} tone="ok" icon="check" title=${t("update.current", info.current)}>
|
|
207
283
|
<${Dismiss} onClick=${() => { remember(DISMISSED_KEY, String(p.started_at)); updateStore.set({ dismissed: String(p.started_at) }); }} /></${Line}>`;
|
|
208
|
-
} else if (info
|
|
284
|
+
} else if (hubNeed(info) && !hubLaterActive(s.laterHub, hubNeed(info))) {
|
|
285
|
+
// M-3140 (spec §3.3): who is asking, then today's buttons — Update now pinned to the advised version.
|
|
286
|
+
const rec = hubNeed(info);
|
|
287
|
+
line = html`<${Line} title=${t("update.hubAvailable", rec.hubName, rec.version, info.current)} sub=${[t("update.hubSub")]}>
|
|
288
|
+
<button type="button" class="btn btn-sm btn-primary" disabled=${s.starting} onClick=${() => { void openHubUpdateDialog(); }}>${t("update.now")}</button>
|
|
289
|
+
<button type="button" class="btn btn-sm" onClick=${() => { const v = `${rec.hubId}:${rec.revision}@${Date.now()}`; remember(LATER_HUB_KEY, v); updateStore.set({ laterHub: v }); }}>${t("update.later")}</button></${Line}>`;
|
|
290
|
+
} else if (info.offer && info.offer.installable && s.later !== info.offer.version && !hubNeed(info)) {
|
|
209
291
|
const o = info.offer;
|
|
210
292
|
line = html`<${Line} title=${t("update.available", o.version, info.current)} sub=${[t("update.availableSub", channelWord(o.channel))]}>
|
|
211
293
|
<button type="button" class="btn btn-sm btn-primary" disabled=${s.starting} onClick=${openUpdateDialog}>${t("update.now")}</button>
|
package/dist/ui/shared/app.css
CHANGED
|
@@ -1493,6 +1493,10 @@ img.amb-p { object-fit: contain; }
|
|
|
1493
1493
|
you counts) goes back to the agents, and ⋯ reaches Needs you, Fleet and Settings. The lists keep the tabs. */
|
|
1494
1494
|
.in-agent .tabs { display: none; }
|
|
1495
1495
|
.in-agent .main { padding-bottom: 0; }
|
|
1496
|
+
/* M-3166: …so nothing under the composer holds the home-indicator inset any more. Once ✓ Verified hides the line under it
|
|
1497
|
+
(below), the box sat in the screen's rounded corners. The dock keeps the inset itself, with the keyboard down (up, the
|
|
1498
|
+
keyboard covers that area, and the box sits on it: #2478). */
|
|
1499
|
+
.in-agent:not(.kb-open) .dock { padding-bottom: max(var(--s-2), env(safe-area-inset-bottom)); }
|
|
1496
1500
|
.sb-back .ic-menu { display: none; }
|
|
1497
1501
|
.sb-back .ic-back { display: inline-block; }
|
|
1498
1502
|
.sb-back { position: relative; }
|
|
@@ -1590,6 +1594,22 @@ img.amb-p { object-fit: contain; }
|
|
|
1590
1594
|
.inst.just:not(.active) { animation: inst-just 2.4s ease-out 1; }
|
|
1591
1595
|
@keyframes inst-just { from { box-shadow: inset 0 0 0 1.5px var(--accent); } to { box-shadow: inset 0 0 0 1.5px transparent; } }
|
|
1592
1596
|
@media (prefers-reduced-motion: reduce) { .inst.just:not(.active) { animation: none; } } /* as specific as the rule it stops */
|
|
1597
|
+
/* M-3129: v4 compact sidebar. Same tokens, links, hover/selection and group headers; no avatar. */
|
|
1598
|
+
.inst-nav.compact .v-li { height: 30px; }
|
|
1599
|
+
.inst-nav.compact .v-inst { height: 30px; min-height: 30px; padding-block: 0; gap: var(--s-2); }
|
|
1600
|
+
.inst-nav.compact .inst-text { flex-direction: row; align-items: center; gap: var(--s-2); }
|
|
1601
|
+
.inst-nav.compact .inst-line { flex: 1; min-width: 0; }
|
|
1602
|
+
.inst-nav.compact .inst-line2 { flex: none; }
|
|
1603
|
+
.inst-nav.compact .inst-when { color: var(--text-3); font-weight: var(--fw-normal); }
|
|
1604
|
+
.inst-nav.compact .inst-row-menu > .icon-btn { height: 28px; min-height: 28px; }
|
|
1605
|
+
.inst-status.off { background: var(--text-2); }
|
|
1606
|
+
.inst-status.hollow { box-sizing: border-box; background: var(--bg-sidebar); border: 2px solid var(--text-2); }
|
|
1607
|
+
@media (max-width: 899px), (pointer: coarse) {
|
|
1608
|
+
/* New Settings controls meet the phone tap minimum; existing smaller controls are grandfathered by the UI gate. */
|
|
1609
|
+
.p-settings .prefs.labelled #pref-density { min-height: var(--tap); }
|
|
1610
|
+
.inst-nav.compact .v-li, .inst-nav.compact .v-inst { height: 40px; min-height: 40px; }
|
|
1611
|
+
.inst-nav.compact .inst-row-menu > .icon-btn { height: 40px; min-height: 40px; min-width: 40px; }
|
|
1612
|
+
}
|
|
1593
1613
|
/* #2179: how the list sorts — the button says it (the accent while "Recent replies" is on); its menu under it. */
|
|
1594
1614
|
.inst-head { position: relative; }
|
|
1595
1615
|
.nav-sort { position: static; flex: none; } /* the menu spans the header's width, under it — never past the sidebar's edge */
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
// #2272: a chat message's own actions, beyond the hover strip — the message menu (right-click, long-press on a phone),
|
|
2
|
+
// swipe left to reply (as in Telegram), and R on a focused message. One install per thread element.
|
|
3
|
+
//
|
|
4
|
+
// - Right-click on a message opens Reply / Copy text / Copy link. Shift+right-click, a right-click with text selected,
|
|
5
|
+
// or one on a link, an image or a field keeps the browser's own menu.
|
|
6
|
+
// - A long press (500 ms without moving) opens the same menu; the click and the browser menu it would also cause are
|
|
7
|
+
// swallowed. M-2789 (the leader's ruling A, "text wins on text"): a long press on a message's WORDS, or one when a
|
|
8
|
+
// selection has already started inside the message, is the browser's — it selects text (then the 「引用」 pill,
|
|
9
|
+
// chat-quote.js); the menu still opens from a long press anywhere else on the message (its padding, header, an empty
|
|
10
|
+
// part of the bubble). Android starts its selection only after contextmenu's own default, so the press's place
|
|
11
|
+
// decides, not only a selection already made. Native long-press selection can't be shown headless: confirmed on a
|
|
12
|
+
// real phone before a beta.
|
|
13
|
+
// - Swipe left on a message: it follows the finger (up to 64 px); let go past 56 px and it is a reply. A mostly
|
|
14
|
+
// vertical move is scrolling, never a reply. A swipe right is the phone drawer's (app-swipe.js), on a message too: the
|
|
15
|
+
// two never fight.
|
|
16
|
+
// - R (no modifier) on a focused message replies; ↑/↓ move to the message before or after (one message is in the Tab
|
|
17
|
+
// order); Escape closes the menu.
|
|
18
|
+
|
|
19
|
+
const LONG_PRESS_MS = 500, MOVE_TOLERANCE = 10, SWIPE_REPLY_PX = 56, SWIPE_MAX_PX = 64;
|
|
20
|
+
/** How long after a touch on a message's words its contextmenu is still that press's (the browser's selection). */
|
|
21
|
+
const WORDS_PRESS_MS = 1500;
|
|
22
|
+
const clock = () => (typeof performance !== "undefined" && performance.now ? performance.now() : Date.now());
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* On a message's own words: the press at (x, y) lands on a glyph of its rendered text — not on the blank part of a
|
|
26
|
+
* line, its padding, its header or its action strip (a paragraph's box is wider than a short line's glyphs: #3555
|
|
27
|
+
* review P2-2). The browser's own hit test (caretPositionFromPoint / caretRangeFromPoint), then the glyph's box
|
|
28
|
+
* beside that caret; without either API, not words (the menu, as before).
|
|
29
|
+
*/
|
|
30
|
+
const GLYPH_SLACK = 2;
|
|
31
|
+
function onWords(target, x, y, doc) {
|
|
32
|
+
const e = target && (target.nodeType === 1 ? target : target.parentElement);
|
|
33
|
+
const md = e && e.closest ? e.closest(".msg[data-key] .md") : null;
|
|
34
|
+
if (!md || e.closest(".meta, .msg-actions") || !Number.isFinite(x) || !Number.isFinite(y)) return false;
|
|
35
|
+
let node = null, offset = 0;
|
|
36
|
+
if (typeof doc.caretPositionFromPoint === "function") { const p = doc.caretPositionFromPoint(x, y); if (p) { node = p.offsetNode; offset = p.offset; } }
|
|
37
|
+
else if (typeof doc.caretRangeFromPoint === "function") { const r = doc.caretRangeFromPoint(x, y); if (r) { node = r.startContainer; offset = r.startOffset; } }
|
|
38
|
+
if (!node || node.nodeType !== 3 || !md.contains(node) || typeof doc.createRange !== "function") return false;
|
|
39
|
+
// The caret sits between two characters: the press is on words when the glyph before or after it holds the point.
|
|
40
|
+
for (const at of [offset - 1, offset]) {
|
|
41
|
+
if (at < 0 || at >= node.data.length || !node.data[at].trim()) continue;
|
|
42
|
+
const rg = doc.createRange(); rg.setStart(node, at); rg.setEnd(node, at + 1);
|
|
43
|
+
for (const b of rg.getClientRects()) {
|
|
44
|
+
if (x >= b.left - GLYPH_SLACK && x <= b.right + GLYPH_SLACK && y >= b.top - GLYPH_SLACK && y <= b.bottom + GLYPH_SLACK) return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
/** A selection already started inside `el` (a message): the browser's, never ours. */
|
|
50
|
+
function selectionIn(el, doc) {
|
|
51
|
+
const sel = doc.getSelection ? doc.getSelection() : null;
|
|
52
|
+
if (!sel || sel.isCollapsed || !String(sel).trim()) return false;
|
|
53
|
+
return !!((sel.anchorNode && el.contains(sel.anchorNode)) || (sel.focusNode && el.contains(sel.focusNode)));
|
|
54
|
+
}
|
|
55
|
+
/** The message element an event is on (a person's or an agent's message of this thread), or null. */
|
|
56
|
+
function messageEl(list, target) {
|
|
57
|
+
const el = target && target.closest ? target.closest(".msg[data-key]") : null;
|
|
58
|
+
return el && list.contains(el) ? el : null;
|
|
59
|
+
}
|
|
60
|
+
/** The browser's own menu stays for: Shift, selected text, a link, an image, a field, code. */
|
|
61
|
+
function keepsNativeMenu(e, doc) {
|
|
62
|
+
if (e.shiftKey) return true;
|
|
63
|
+
const sel = doc.getSelection ? doc.getSelection() : null;
|
|
64
|
+
if (sel && !sel.isCollapsed && String(sel).trim()) return true;
|
|
65
|
+
return !!(e.target && e.target.closest && e.target.closest("a[href], img, video, input, textarea, select, pre, code, [contenteditable='true']"));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Install the gestures on `list` (the thread element). `deps`:
|
|
70
|
+
* messageOf(key) → the row; reply(row); copyText(text) → Promise<boolean>; linkOf(row) → string (S-152: optional — a
|
|
71
|
+
* page whose messages have no address, the Hub's, has no Copy link); notice(text);
|
|
72
|
+
* canReply() → boolean (false: no Reply — a page that cannot send); t(key).
|
|
73
|
+
* Returns a function that removes everything (and closes an open menu).
|
|
74
|
+
*/
|
|
75
|
+
export function installMessageActions(list, deps) {
|
|
76
|
+
const doc = list.ownerDocument, win = doc.defaultView;
|
|
77
|
+
let menu = null, press = null, swipe = null, swallowClick = false, wordsPressAt = -Infinity;
|
|
78
|
+
|
|
79
|
+
function closeMenu() {
|
|
80
|
+
if (!menu) return;
|
|
81
|
+
menu.remove(); menu = null;
|
|
82
|
+
doc.removeEventListener("pointerdown", outside, true);
|
|
83
|
+
doc.removeEventListener("keydown", onMenuKey, true);
|
|
84
|
+
win?.removeEventListener("scroll", closeMenu, true);
|
|
85
|
+
win?.removeEventListener("blur", closeMenu);
|
|
86
|
+
}
|
|
87
|
+
function outside(e) { if (menu && !menu.contains(e.target)) closeMenu(); }
|
|
88
|
+
function onMenuKey(e) {
|
|
89
|
+
if (!menu) return;
|
|
90
|
+
if (e.key === "Escape") { e.preventDefault(); e.stopPropagation(); closeMenu(); return; }
|
|
91
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
const items = [...menu.querySelectorAll("button")], i = items.indexOf(doc.activeElement);
|
|
94
|
+
items[(i + (e.key === "ArrowDown" ? 1 : items.length - 1)) % items.length]?.focus();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** The message menu at (x, y), within the window; focus on its first item. */
|
|
98
|
+
function openMenu(row, x, y) {
|
|
99
|
+
closeMenu();
|
|
100
|
+
const items = [];
|
|
101
|
+
if (deps.canReply?.() !== false) items.push(["reply", deps.t("chat.reply"), () => deps.reply(row)]);
|
|
102
|
+
// M-3127: a Hub room's messages take a reaction (deps.react: the thread's quick picker under that message); the Fleet passes none.
|
|
103
|
+
if (typeof deps.react === "function" && deps.canReact?.(row) !== false) items.push(["react", deps.reactLabel || "React", () => deps.react(row)]);
|
|
104
|
+
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); }]);
|
|
105
|
+
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); }]);
|
|
106
|
+
menu = doc.createElement("div");
|
|
107
|
+
menu.className = "msg-menu";
|
|
108
|
+
menu.setAttribute("role", "menu");
|
|
109
|
+
menu.setAttribute("aria-label", deps.t("chat.msgMenu"));
|
|
110
|
+
menu.setAttribute("data-trust", "menu");
|
|
111
|
+
for (const [id, label, run] of items) {
|
|
112
|
+
const b = doc.createElement("button");
|
|
113
|
+
b.type = "button"; b.className = "menu-item"; b.setAttribute("role", "menuitem"); b.dataset.item = id; b.textContent = label;
|
|
114
|
+
b.addEventListener("click", () => { closeMenu(); void run(); });
|
|
115
|
+
menu.append(b);
|
|
116
|
+
}
|
|
117
|
+
doc.body.append(menu);
|
|
118
|
+
const w = win?.innerWidth ?? 1024, h = win?.innerHeight ?? 768, r = menu.getBoundingClientRect();
|
|
119
|
+
menu.style.left = `${Math.max(4, Math.min(x, w - r.width - 4))}px`;
|
|
120
|
+
menu.style.top = `${Math.max(4, Math.min(y, h - r.height - 4))}px`;
|
|
121
|
+
doc.addEventListener("pointerdown", outside, true);
|
|
122
|
+
doc.addEventListener("keydown", onMenuKey, true);
|
|
123
|
+
win?.addEventListener("scroll", closeMenu, true);
|
|
124
|
+
win?.addEventListener("blur", closeMenu);
|
|
125
|
+
menu.querySelector("button")?.focus();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function onContextMenu(e) {
|
|
129
|
+
if (swallowClick) { e.preventDefault(); return; } // the long press already opened ours
|
|
130
|
+
cancelPress(); // Android's long press fires this itself: one menu
|
|
131
|
+
const el = messageEl(list, e.target);
|
|
132
|
+
if (!el || keepsNativeMenu(e, doc)) return;
|
|
133
|
+
// M-2789: a long press on the words (or a selection begun in this message) is the browser's — its selection.
|
|
134
|
+
if (selectionIn(el, doc) || (clock() - wordsPressAt < WORDS_PRESS_MS && onWords(e.target, e.clientX, e.clientY, doc))) return;
|
|
135
|
+
const row = deps.messageOf(el.dataset.key);
|
|
136
|
+
if (!row) return;
|
|
137
|
+
e.preventDefault();
|
|
138
|
+
openMenu(row, e.clientX, e.clientY);
|
|
139
|
+
}
|
|
140
|
+
function onKeyDown(e) {
|
|
141
|
+
// ↑/↓ on a focused message: the one before or after it (one message is in the Tab order: the thread's rove()).
|
|
142
|
+
if ((e.key === "ArrowUp" || e.key === "ArrowDown") && !e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey
|
|
143
|
+
&& e.target && e.target.matches && e.target.matches(".msg[data-key]") && list.contains(e.target)) {
|
|
144
|
+
const all = [...list.querySelectorAll(".msg[data-key]")], i = all.indexOf(e.target);
|
|
145
|
+
const to = all[i + (e.key === "ArrowDown" ? 1 : -1)];
|
|
146
|
+
if (to) { e.preventDefault(); deps.rove?.(to.dataset.key); to.focus(); to.scrollIntoView?.({ block: "nearest" }); }
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (e.key !== "r" && e.key !== "R") return;
|
|
150
|
+
if (e.ctrlKey || e.metaKey || e.altKey || deps.canReply?.() === false) return;
|
|
151
|
+
const el = e.target && e.target.matches && e.target.matches(".msg[data-key]") && list.contains(e.target) ? e.target : null;
|
|
152
|
+
const row = el ? deps.messageOf(el.dataset.key) : null;
|
|
153
|
+
if (!row) return;
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
deps.reply(row);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function onTouchStart(e) {
|
|
159
|
+
if (e.touches.length !== 1) { cancelPress(); cancelSwipe(); return; }
|
|
160
|
+
const el = messageEl(list, e.target);
|
|
161
|
+
if (!el) return;
|
|
162
|
+
const t0 = e.touches[0];
|
|
163
|
+
const native = keepsNativeMenu({ target: e.target, shiftKey: false }, doc); // a link, an image, code: the browser's
|
|
164
|
+
// M-2789: a press on the message's words is the browser's text selection, not our menu (swipe-left Reply stays).
|
|
165
|
+
const words = onWords(e.target, t0.clientX, t0.clientY, doc);
|
|
166
|
+
wordsPressAt = words ? clock() : -Infinity;
|
|
167
|
+
press = native || words ? null : { el, x: t0.clientX, y: t0.clientY, timer: setTimeout(() => {
|
|
168
|
+
const row = deps.messageOf(el.dataset.key);
|
|
169
|
+
press = null;
|
|
170
|
+
if (selectionIn(el, doc)) return; // a selection has started here: it stays the browser's
|
|
171
|
+
cancelSwipe();
|
|
172
|
+
if (!row) return;
|
|
173
|
+
swallowClick = true; setTimeout(() => { swallowClick = false; }, 700);
|
|
174
|
+
openMenu(row, t0.clientX, t0.clientY);
|
|
175
|
+
}, LONG_PRESS_MS) };
|
|
176
|
+
swipe = deps.canReply?.() === false || native ? null : { el, x: t0.clientX, y: t0.clientY, dx: 0, locked: null };
|
|
177
|
+
}
|
|
178
|
+
function onTouchMove(e) {
|
|
179
|
+
const p = e.touches[0];
|
|
180
|
+
if (press && (Math.abs(p.clientX - press.x) > MOVE_TOLERANCE || Math.abs(p.clientY - press.y) > MOVE_TOLERANCE)) cancelPress();
|
|
181
|
+
if (!swipe) return;
|
|
182
|
+
const dx = p.clientX - swipe.x, dy = p.clientY - swipe.y;
|
|
183
|
+
if (swipe.locked === null && (Math.abs(dx) > MOVE_TOLERANCE || Math.abs(dy) > MOVE_TOLERANCE)) swipe.locked = dx < 0 && Math.abs(dy) < -dx / 2 ? "x" : "no";
|
|
184
|
+
if (swipe.locked !== "x") return;
|
|
185
|
+
swipe.dx = Math.max(0, Math.min(-dx, SWIPE_MAX_PX)); // how far left, as a positive distance
|
|
186
|
+
swipe.el.style.transform = `translateX(${-swipe.dx}px)`;
|
|
187
|
+
swipe.el.classList.toggle("swipe-ready", swipe.dx >= SWIPE_REPLY_PX);
|
|
188
|
+
}
|
|
189
|
+
function onTouchEnd() {
|
|
190
|
+
cancelPress();
|
|
191
|
+
if (!swipe) return;
|
|
192
|
+
const { el, dx, locked } = swipe;
|
|
193
|
+
cancelSwipe();
|
|
194
|
+
if (locked === "x" && dx >= SWIPE_REPLY_PX) { const row = deps.messageOf(el.dataset.key); if (row) deps.reply(row); }
|
|
195
|
+
}
|
|
196
|
+
function cancelPress() { if (press) { clearTimeout(press.timer); press = null; } }
|
|
197
|
+
function cancelSwipe() {
|
|
198
|
+
if (!swipe) return;
|
|
199
|
+
swipe.el.style.transform = ""; swipe.el.classList.remove("swipe-ready");
|
|
200
|
+
swipe = null;
|
|
201
|
+
}
|
|
202
|
+
function onClickCapture(e) { if (swallowClick) { e.preventDefault(); e.stopPropagation(); } }
|
|
203
|
+
|
|
204
|
+
// A message focused by a click or a tap becomes the one Tab comes back to.
|
|
205
|
+
function onFocusIn(e) { const el = e.target && e.target.matches && e.target.matches(".msg[data-key]") ? e.target : null; if (el && list.contains(el)) deps.rove?.(el.dataset.key); }
|
|
206
|
+
list.addEventListener("focusin", onFocusIn);
|
|
207
|
+
list.addEventListener("contextmenu", onContextMenu);
|
|
208
|
+
list.addEventListener("keydown", onKeyDown);
|
|
209
|
+
list.addEventListener("touchstart", onTouchStart, { passive: true });
|
|
210
|
+
list.addEventListener("touchmove", onTouchMove, { passive: true });
|
|
211
|
+
list.addEventListener("touchend", onTouchEnd, { passive: true });
|
|
212
|
+
list.addEventListener("touchcancel", onTouchEnd, { passive: true });
|
|
213
|
+
list.addEventListener("click", onClickCapture, true);
|
|
214
|
+
return () => {
|
|
215
|
+
closeMenu(); cancelPress(); cancelSwipe();
|
|
216
|
+
list.removeEventListener("focusin", onFocusIn);
|
|
217
|
+
list.removeEventListener("contextmenu", onContextMenu);
|
|
218
|
+
list.removeEventListener("keydown", onKeyDown);
|
|
219
|
+
list.removeEventListener("touchstart", onTouchStart);
|
|
220
|
+
list.removeEventListener("touchmove", onTouchMove);
|
|
221
|
+
list.removeEventListener("touchend", onTouchEnd);
|
|
222
|
+
list.removeEventListener("touchcancel", onTouchEnd);
|
|
223
|
+
list.removeEventListener("click", onClickCapture, true);
|
|
224
|
+
};
|
|
225
|
+
}
|