@songsid/agend 2.4.0-beta.16 → 2.4.0-beta.17

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 (112) hide show
  1. package/dist/auth-api.js +2 -0
  2. package/dist/auth-api.js.map +1 -1
  3. package/dist/backend/claude-code.d.ts +10 -1
  4. package/dist/backend/claude-code.js +1 -0
  5. package/dist/backend/claude-code.js.map +1 -1
  6. package/dist/backend/types.d.ts +6 -0
  7. package/dist/backend/types.js.map +1 -1
  8. package/dist/build-provenance.json +1 -1
  9. package/dist/claude-credential-launch.d.ts +1 -0
  10. package/dist/claude-credential-launch.js +13 -2
  11. package/dist/claude-credential-launch.js.map +1 -1
  12. package/dist/claude-credential-vault.d.ts +7 -1
  13. package/dist/claude-credential-vault.js +26 -1
  14. package/dist/claude-credential-vault.js.map +1 -1
  15. package/dist/claude-request-observation.d.ts +7 -0
  16. package/dist/claude-request-observation.js +26 -0
  17. package/dist/claude-request-observation.js.map +1 -0
  18. package/dist/cli-audited.js +8 -6
  19. package/dist/cli-audited.js.map +1 -1
  20. package/dist/daemon.js +6 -0
  21. package/dist/daemon.js.map +1 -1
  22. package/dist/fleet-manager.d.ts +14 -0
  23. package/dist/fleet-manager.js +128 -3
  24. package/dist/fleet-manager.js.map +1 -1
  25. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +9 -3
  26. package/dist/host-monitoring-config.d.ts +2 -1
  27. package/dist/host-monitoring-config.js +8 -3
  28. package/dist/host-monitoring-config.js.map +1 -1
  29. package/dist/host-monitoring-history-files.d.ts +2 -0
  30. package/dist/host-monitoring-history-files.js +16 -0
  31. package/dist/host-monitoring-history-files.js.map +1 -0
  32. package/dist/host-monitoring-history-policy.d.ts +55 -0
  33. package/dist/host-monitoring-history-policy.js +93 -0
  34. package/dist/host-monitoring-history-policy.js.map +1 -0
  35. package/dist/host-monitoring-history-store.d.ts +52 -0
  36. package/dist/host-monitoring-history-store.js +176 -0
  37. package/dist/host-monitoring-history-store.js.map +1 -0
  38. package/dist/host-monitoring-history-worker.d.ts +1 -0
  39. package/dist/host-monitoring-history-worker.js +50 -0
  40. package/dist/host-monitoring-history-worker.js.map +1 -0
  41. package/dist/host-monitoring-history.d.ts +71 -0
  42. package/dist/host-monitoring-history.js +265 -0
  43. package/dist/host-monitoring-history.js.map +1 -0
  44. package/dist/host-monitoring-platform.d.ts +73 -0
  45. package/dist/host-monitoring-platform.js +273 -0
  46. package/dist/host-monitoring-platform.js.map +1 -0
  47. package/dist/host-monitoring-runtime.d.ts +34 -0
  48. package/dist/host-monitoring-runtime.js +80 -0
  49. package/dist/host-monitoring-runtime.js.map +1 -0
  50. package/dist/host-monitoring-settings-store.d.ts +5 -0
  51. package/dist/host-monitoring-settings-store.js +49 -0
  52. package/dist/host-monitoring-settings-store.js.map +1 -0
  53. package/dist/host-monitoring.d.ts +106 -0
  54. package/dist/host-monitoring.js +157 -0
  55. package/dist/host-monitoring.js.map +1 -0
  56. package/dist/public-web-gateway.js +4 -0
  57. package/dist/public-web-gateway.js.map +1 -1
  58. package/dist/runtime-cli-install.js +17 -16
  59. package/dist/runtime-cli-install.js.map +1 -1
  60. package/dist/settings-api.d.ts +3 -0
  61. package/dist/settings-api.js +14 -7
  62. package/dist/settings-api.js.map +1 -1
  63. package/dist/settings-baseline.d.ts +1 -0
  64. package/dist/settings-baseline.js +5 -4
  65. package/dist/settings-baseline.js.map +1 -1
  66. package/dist/settings-change.js +8 -0
  67. package/dist/settings-change.js.map +1 -1
  68. package/dist/settings-effect.d.ts +2 -0
  69. package/dist/settings-effect.js +5 -3
  70. package/dist/settings-effect.js.map +1 -1
  71. package/dist/transcript-monitor.d.ts +1 -0
  72. package/dist/transcript-monitor.js +18 -0
  73. package/dist/transcript-monitor.js.map +1 -1
  74. package/dist/ui/accounts-view.js +7 -5
  75. package/dist/ui/claude-credentials.js +12 -1
  76. package/dist/ui/fleet-office-pack.js +2 -2
  77. package/dist/ui/fleet-office-play.js +142 -3
  78. package/dist/ui/fleet-office-skin.js +67 -2
  79. package/dist/ui/fleet-office-store.js +41 -0
  80. package/dist/ui/fleet-office-zones.js +15 -8
  81. package/dist/ui/fleet-office.js +126 -21
  82. package/dist/ui/host-health-model.js +42 -0
  83. package/dist/ui/host-health.js +74 -0
  84. package/dist/ui/panel-chat.js +99 -43
  85. package/dist/ui/panel-fleet.js +24 -11
  86. package/dist/ui/panel-hub.js +5 -1
  87. package/dist/ui/panel-settings.js +3 -3
  88. package/dist/ui/search-dialog.js +8 -1
  89. package/dist/ui/settings-capabilities.js +2 -0
  90. package/dist/ui/settings-host-monitoring.js +31 -13
  91. package/dist/ui/settings-registry.js +4 -1
  92. package/dist/ui/shared/accounts.css +8 -4
  93. package/dist/ui/shared/agent-sheet.js +5 -2
  94. package/dist/ui/shared/app-route.js +1 -1
  95. package/dist/ui/shared/app.css +37 -0
  96. package/dist/ui/shared/app.js +1 -0
  97. package/dist/ui/shared/chat-strings.js +2 -2
  98. package/dist/ui/shared/chat-thread.js +42 -10
  99. package/dist/ui/shared/instance-nav.js +47 -5
  100. package/dist/ui/shared/jump-idle.js +36 -0
  101. package/dist/ui/shared/theme.js +6 -2
  102. package/dist/ui/shared/ui-menu.js +17 -11
  103. package/dist/web-api.d.ts +2 -0
  104. package/dist/web-api.js +54 -0
  105. package/dist/web-api.js.map +1 -1
  106. package/dist/web-chat-history.d.ts +7 -1
  107. package/dist/web-chat-history.js +19 -3
  108. package/dist/web-chat-history.js.map +1 -1
  109. package/dist/web-shell-routes.d.ts +1 -1
  110. package/dist/web-shell-routes.js +1 -1
  111. package/dist/web-shell-routes.js.map +1 -1
  112. package/package.json +1 -1
@@ -10,8 +10,9 @@ import { GeneralLocation } from "./general-location.js";
10
10
  // The instance's own actions (details, start, stop, restart, delete) are in the header's ⋯ menu, and only the ones
11
11
  // that apply to its state are offered (#1408 rough edges 4 and 7).
12
12
  import { html, Fragment, useEffect, useLayoutEffect, useRef, useState } from "/assets/app-html.js";
13
+ import { JUMP_IDLE_MS, useJumpIdle } from "/assets/jump-idle.js";
13
14
  import { lang, register, t } from "/assets/app-i18n.js";
14
- import { AgentSheetButton } from "/assets/agent-sheet.js";
15
+ import { AgentSheetButton, AgentSheet } from "/assets/agent-sheet.js";
15
16
  import { appStore, createStore, guestPage, guestTrusted, useStore } from "/assets/app-store.js";
16
17
  import { ComposerAuth, useWebAuthorization } from "/assets/web-authorize.js";
17
18
  import { useLease } from "/assets/app-ctx.js";
@@ -19,7 +20,7 @@ import * as paneContext from "/assets/app-ctx.js";
19
20
  import { backendLabel, modelText, namesOf, namesStore, navStore as instanceNavStore, supportsInstanceFeature } from "/assets/instance-nav.js";
20
21
  import { machineName } from "/assets/machine-name.js";
21
22
  import { PanelHeader, onPanelKey, setTitle, statusClass, statusLabel, openDrawer, requestNewInstance, needsCount, openSearch } from "/assets/app-shell.js";
22
- import { detailsPath, textLinkSegments, sectionPath, NEEDS_PATH, fleetEntryPath, settingsPath, viewPath, logPath } from "/assets/app-route.js";
23
+ import { chatPath, detailsPath, textLinkSegments, sectionPath, NEEDS_PATH, fleetEntryPath, settingsPath, viewPath, logPath } from "/assets/app-route.js";
23
24
  import { InstanceSwitch } from "/assets/instance-switch.js";
24
25
  import { HeaderTools, setTextSize, textSizeStore, usageOffered, TEXT_SIZES } from "/assets/header-tools.js";
25
26
  import { UsageDialog } from "/assets/usage-dialog.js";
@@ -113,6 +114,49 @@ const needKey = (item) => String(item?.nonce || item?.id || JSON.stringify(item
113
114
  * count), Fleet, Settings — then this chat's items, and ends with 「✓ 已驗證」 (the line under the composer no longer
114
115
  * says it). A Needs-you item that arrives meanwhile, for another agent, is a short toast. A desk's ⋯ is unchanged.
115
116
  */
117
+ /** One target-bound action list for the header and sidebar; the server remains the authority. */
118
+ export function chatAgentMenuItems({ name, inst, wide, pinCount = 0, onPins, onDelete,
119
+ onDetails = () => navigate(detailsPath(name)), onSplit = () => appStore.get().chatWorkspace?.open(name) }) {
120
+ if (guestPage()) return [];
121
+ const running = inst.status === "running";
122
+ const action = async (verb) => {
123
+ let r;
124
+ try { const res = await fetch(`/ui/${verb}/${encodeURIComponent(name)}`, { method: "POST", headers: { "Content-Type": "application/json" } }); r = await res.json(); }
125
+ catch (err) { r = { error: err && err.message ? err.message : t("chat.disconnected") }; }
126
+ if (r && r.error) toast(r.error, false);
127
+ else if (r && r.held) toast(r.message);
128
+ else toast(t(verb === "start" ? "chat.started" : verb === "stop" ? "chat.stoppedInst" : "chat.restarted", name));
129
+ };
130
+ return [
131
+ // #1523 N2: Details is a page now (the Fleet side of this instance), not a dialog.
132
+ supportsInstanceFeature(inst,"details") ? { key: "details", label: t("chat.details"), icon: "info", onSelect: () => onDetails() } : null,
133
+ appStore.get().chatWorkspace ? { key: "splitChat", label: t("chatWorkspace.split"), icon: "sidebar", onSelect: () => onSplit() } : null,
134
+ inst.runtime === "windows" ? {key:"settings",label:t("app.settings"),icon:"settings",onSelect:() => navigate(sectionPath("agents"))} : null,
135
+ running || !supportsInstanceFeature(inst,"lifecycle") ? null : { key: "start", label: t("chat.start"), icon: "play", onSelect: () => action("start") },
136
+ running && supportsInstanceFeature(inst,"lifecycle") ? { key: "restart", label: t("chat.restart"), icon: "restart", onSelect: () => action("restart") } : null,
137
+ running && supportsInstanceFeature(inst,"lifecycle") ? { key: "stop", label: t("chat.stopInstance"), icon: "stop", onSelect: () => action("stop") } : null,
138
+ // #1958: its identity colour and where it shows (the public link too, as profile edits).
139
+ // #3153 P1: the folder it works in, read-only — an admin only (M-3278: over the public link too), and not an
140
+ // agent on another machine (the server also refuses General and coordinators: their folder is the fleet's own).
141
+ inst.runtime === "windows" || inst.machine_id || inst.general_topic === true ? null
142
+ : { key: "workspace", label: t("chat.wsOpen"), icon: "file", onSelect: () => openWorkspace({ key: `ws:${name}`, instance: name }) },
143
+ // M-3271: the pinned list — here too, for a phone (its header shows ← title ⋯ only) and a narrow pane.
144
+ pinCount ? { key: "pins", label: `${t("chat.pinsTitle")} · ${pinCount}`, icon: "pin", onSelect: onPins } : null,
145
+ colorMenuItem(name, inst),
146
+ // #1629: a person's control over this agent's theme — not over the public link (it only views themes).
147
+ ...themeMenuItems(name),
148
+ // #2117: its ambient — why it is not showing here (with the way to change that), and a person's Clear.
149
+ ...ambientMenuItems(name, { publicLink: false, clear: clearAmbient }), // M-3278
150
+ // AGEND-181: the activity timeline above each reply (this browser's choice), when the Log is on.
151
+ ...(activityOffered() && activityInfo(name)?.level !== "off" ? [
152
+ { key: "activity", checkbox: true, checked: activityPrefs.get().on, label: t("act.menuActivity"), onSelect: () => setActivityOn(!activityPrefs.get().on) },
153
+ ...(activityInfo(name)?.thinking ? [{ key: "thinking", checkbox: true, checked: activityPrefs.get().thinking, disabled: !activityPrefs.get().on, label: t("act.menuThinking"), onSelect: () => setActivityThinking(!activityPrefs.get().thinking) }] : []),
154
+ ] : []),
155
+ narrowScreen() ? null : { key: "fullWidth", checkbox: true, checked: wide, label: t("chat.fullWidth"), onSelect: () => setChatWide(!wide) },
156
+ { key: "delete", label: t("chat.delete"), icon: "trash", danger: true, onSelect: onDelete },
157
+ ];
158
+ }
159
+
116
160
  function ChatMoreMenu({ items, name, inst = null, card = null, navKey, lease = null }) {
117
161
  const app = useStore(appStore);
118
162
  const auth = useWebAuthorization();
@@ -596,43 +640,8 @@ function ChatView({ name, inst, lease, navKey, exec, awaiting }) {
596
640
  e.preventDefault();
597
641
  store.cancelReply(name);
598
642
  })), [lease]);
599
- const running = inst.status === "running";
600
- const action = async (verb) => {
601
- let r;
602
- try { const res = await fetch(`/ui/${verb}/${encodeURIComponent(name)}`, { method: "POST", headers: { "Content-Type": "application/json" } }); r = await res.json(); }
603
- catch (err) { r = { error: err && err.message ? err.message : t("chat.disconnected") }; }
604
- if (r && r.error) toast(r.error, false);
605
- else if (r && r.held) toast(r.message);
606
- else toast(t(verb === "start" ? "chat.started" : verb === "stop" ? "chat.stoppedInst" : "chat.restarted", name));
607
- };
608
- const items = [
609
- // #1523 N2: Details is a page now (the Fleet side of this instance), not a dialog.
610
- supportsInstanceFeature(inst,"details") ? { key: "details", label: t("chat.details"), icon: "info", onSelect: () => (paneNow.current?.navigate || navigate)(detailsPath(name)) } : null,
611
- appStore.get().chatWorkspace ? { key: "splitChat", label: t("chatWorkspace.split"), icon: "sidebar", onSelect: () => appStore.get().chatWorkspace.pick() } : null,
612
- inst.runtime === "windows" ? {key:"settings",label:t("app.settings"),icon:"settings",onSelect:() => navigate(sectionPath("agents"))} : null,
613
- running || !supportsInstanceFeature(inst,"lifecycle") ? null : { key: "start", label: t("chat.start"), icon: "play", onSelect: () => action("start") },
614
- running && supportsInstanceFeature(inst,"lifecycle") ? { key: "restart", label: t("chat.restart"), icon: "restart", onSelect: () => action("restart") } : null,
615
- running && supportsInstanceFeature(inst,"lifecycle") ? { key: "stop", label: t("chat.stopInstance"), icon: "stop", onSelect: () => action("stop") } : null,
616
- // #1958: its identity colour and where it shows (the public link too, as profile edits).
617
- // #3153 P1: the folder it works in, read-only — an admin only (M-3278: over the public link too), and not an
618
- // agent on another machine (the server also refuses General and coordinators: their folder is the fleet's own).
619
- inst.runtime === "windows" || inst.machine_id || inst.general_topic === true ? null
620
- : { key: "workspace", label: t("chat.wsOpen"), icon: "file", onSelect: () => openWorkspace({ key: `ws:${name}`, instance: name }) },
621
- // M-3271: the pinned list — here too, for a phone (its header shows ← title ⋯ only) and a narrow pane.
622
- pinCount ? { key: "pins", label: `${t("chat.pinsTitle")} · ${pinCount}`, icon: "pin", onSelect: openPins } : null,
623
- colorMenuItem(name, inst),
624
- // #1629: a person's control over this agent's theme — not over the public link (it only views themes).
625
- ...themeMenuItems(name),
626
- // #2117: its ambient — why it is not showing here (with the way to change that), and a person's Clear.
627
- ...ambientMenuItems(name, { publicLink: false, clear: clearAmbient }), // M-3278
628
- // AGEND-181: the activity timeline above each reply (this browser's choice), when the Log is on.
629
- ...(activityOffered() && activityInfo(name)?.level !== "off" ? [
630
- { key: "activity", checkbox: true, checked: activityPrefs.get().on, label: t("act.menuActivity"), onSelect: () => setActivityOn(!activityPrefs.get().on) },
631
- ...(activityInfo(name)?.thinking ? [{ key: "thinking", checkbox: true, checked: activityPrefs.get().thinking, disabled: !activityPrefs.get().on, label: t("act.menuThinking"), onSelect: () => setActivityThinking(!activityPrefs.get().thinking) }] : []),
632
- ] : []),
633
- narrowScreen() ? null : { key: "fullWidth", checkbox: true, checked: wide, label: t("chat.fullWidth"), onSelect: () => setChatWide(!wide) },
634
- { key: "delete", label: t("chat.delete"), icon: "trash", danger: true, onSelect: () => setDialog("delete") },
635
- ];
643
+ const items = chatAgentMenuItems({ name, inst, wide, pinCount, onPins: openPins, onDelete: () => setDialog("delete"),
644
+ onDetails: () => (paneNow.current?.navigate || navigate)(detailsPath(name)), onSplit: () => appStore.get().chatWorkspace.pick() });
636
645
  const cls = statusClass(inst, exec, awaiting);
637
646
  // #1920 phase 3: a guest has this chat only — no Details, View or Log to switch to, no lifecycle, colour, theme,
638
647
  // effect management or delete (a guest's status frame carries no model or effort either, so those chips do not show).
@@ -851,11 +860,14 @@ function follow(name, thread) {
851
860
  }
852
861
 
853
862
  /** The thread's view: Preact owns the scroller and the jump pill; the kept list (chat-thread.js) is put inside it. */
863
+ export { JUMP_IDLE_MS };
854
864
  function Thread({ name, label = name, th, bindings }) {
855
865
  const pane = paneContext.usePane?.(), paneNow = useRef(pane); paneNow.current = pane;
856
866
  const scroller = useRef(null), host = useRef(null);
857
867
  const [jump, setJump] = useState({ show: false, unseen: 0 });
858
868
  const [empty, setEmpty] = useState(false);
869
+ // M-3492/M-3493: 最新 fades out JUMP_IDLE_MS after the last scroll (shared with the Hub's threads: jump-idle.js).
870
+ const jumpIdle = useJumpIdle(scroller, jump.show, name);
859
871
  useLayoutEffect(() => { keptThreads.get(name)?.list.setAttribute("aria-label",t("chat.conversationWith",label)); },[name,label]);
860
872
  useLayoutEffect(() => {
861
873
  const doc = host.current.ownerDocument;
@@ -962,7 +974,8 @@ function Thread({ name, label = name, th, bindings }) {
962
974
  <div class="thread-host" ref=${host}></div>
963
975
  ${empty === "hidden" ? html`<${Empty} icon="chat" title=${t("chat.guestAllHidden")} hint=${t("chat.guestAllHiddenHint")} />`
964
976
  : empty ? html`<${Empty} icon="chat" title=${t("chat.noMessages")} />` : null}
965
- </div><div class="jump-dock">${jump.show ? html`<button data-trust="thread-control" type="button" class="jump-latest" onClick=${() => { const t2 = th.current; if (!t2) return; if (store.pagingState(name).detached) void store.backToLatest(name).then(() => t2.jumpLatest()); else t2.jumpLatest(); }}
977
+ </div><div class="jump-dock">${jump.show ? html`<button data-trust="thread-control" type="button" ref=${jumpIdle.ref} class=${`jump-latest${jumpIdle.idle ? " is-idle" : ""}`} onClick=${() => { const t2 = th.current; if (!t2) return; if (store.pagingState(name).detached) void store.backToLatest(name).then(() => t2.jumpLatest()); else t2.jumpLatest(); }}
978
+ onFocus=${jumpIdle.onFocus} onBlur=${jumpIdle.onBlur}
966
979
  aria-label=${jump.unseen > 0 ? t("chat.newBelow", jump.unseen) : t("chat.jumpLatest")}>
967
980
  <${Icon} name="down" size=${16} /><span class="jump-text">${jump.unseen > 0 ? t("chat.newBelow", jump.unseen) : t("chat.jumpLatest")}</span>${
968
981
  /* The user (before 2.4.0-beta.3): no unread counts for now — a phone's round button has no badge. */ ""}</button>` : null}</div>
@@ -1162,6 +1175,8 @@ function ModelMenu({ name, c, lease }) {
1162
1175
  return html`<div class="model-menu-scrim" onClick=${close}></div><div class="model-menu-pop" ref=${(el) => { pop.current = el; place(el); }} onKeyDown=${onKeys}>${body}</div>`;
1163
1176
  }
1164
1177
 
1178
+ const usesModelMenu = c => c?.command === "model" && (c.choices ? c.choices.step !== "backend" : c.busy && !c.error && !c.args);
1179
+
1165
1180
  function CommandCard({ name, lease }) {
1166
1181
  const c = store.state.commands[name];
1167
1182
  if (!c) return null;
@@ -1174,7 +1189,7 @@ function CommandCard({ name, lease }) {
1174
1189
  // bottom sheet on a phone — not a card above the box. A failure, its result text and /backend stay the card.
1175
1190
  // The menu is /model's list: shown with its choices, or while that list loads. A model being switched to (a pick from the
1176
1191
  // menu, a typed "/model <id>") is the card's, as before (#4003 review).
1177
- if (c.command === "model" && (c.choices ? c.choices.step !== "backend" : c.busy && !c.error && !c.args)) return html`<${ModelMenu} name=${name} c=${c} lease=${lease} />`;
1192
+ if (usesModelMenu(c)) return html`<${ModelMenu} name=${name} c=${c} lease=${lease} />`;
1178
1193
  const open = sub && sub.for === c.choices ? c.choices.options.find((o) => o.id === sub.id && o.effort) : null;
1179
1194
  const pickEffort = async (model, level) => {
1180
1195
  setSub(null);
@@ -1470,7 +1485,7 @@ function FileChip({ f, i, name, bindings }) {
1470
1485
 
1471
1486
  // ── Dialogs ──
1472
1487
 
1473
- function DeleteDialog({ name, inst, onClose }) {
1488
+ function DeleteDialog({ name, inst, onClose, onDeleted = () => navigate("/ui") }) {
1474
1489
  // The dialog's own lease: it ends when the dialog goes (closed, or the chat left for another page). The delete
1475
1490
  // may still finish on the server, and says so, but a dialog that is gone never closes or navigates the page the
1476
1491
  // person is on now (#1425 review).
@@ -1497,7 +1512,7 @@ function DeleteDialog({ name, inst, onClose }) {
1497
1512
  if (handedOver || !lease.current()) return;
1498
1513
  setBusy(false);
1499
1514
  onClose();
1500
- navigate("/ui");
1515
+ onDeleted();
1501
1516
  }
1502
1517
  return html`<${Dialog} title=${t("chat.deleteTitle", name)} onClose=${onClose} busy=${busy}
1503
1518
  actions=${html`<button type="button" class="btn" onClick=${onClose} disabled=${busy}>${t("chat.cancel")}</button>
@@ -1509,3 +1524,44 @@ function DeleteDialog({ name, inst, onClose }) {
1509
1524
  </${Dialog}>`;
1510
1525
  }
1511
1526
  ChatPanel.workspaceVersion = 1;
1527
+
1528
+ /** Session-only injection: public InstanceNav never imports this module. */
1529
+ export function SidebarChatMenu({ inst, context, onClose, favorite = null }) {
1530
+ const name = inst.name || inst.instance_name, lease = useLease(`sidebar-menu:${name}`);
1531
+ const [phase, setPhase] = useState("menu");
1532
+ const [, redraw] = useState(0);
1533
+ const wide = useStore(chatWide).on;
1534
+ useStore(themesStore); useStore(activityInfoStore); useStore(activityPrefs);
1535
+ const auth = useWebAuthorization(), card = useCard(name, inst.card_v);
1536
+ const pinCount = usePins(name).pins?.length || 0;
1537
+ useEffect(() => store?.subscribe(target => { if (target === name) redraw(n => n + 1); }), [name]);
1538
+ useEffect(() => {
1539
+ if (phase !== "menu" || !activityShown() || activityInfo(name)?.level !== undefined) return;
1540
+ const feed = observeActivity(name, { changed: () => feed.stop(), wantThinking: () => activityPrefs.get().thinking });
1541
+ feed.start(); return () => feed.stop();
1542
+ }, [name, phase, activityPrefs.get().on]);
1543
+ const command = store?.state.commands[name];
1544
+ useEffect(() => { if ((phase === "command" && !command) || (phase === "card" && !card)) setPhase(null); }, [phase, command, card]);
1545
+ useEffect(() => { if (!phase) onClose(); }, [phase]);
1546
+ const items = chatAgentMenuItems({ name, inst, wide, pinCount, onPins: () => setPhase("pins"), onDelete: () => setPhase("delete") });
1547
+ const run = command => { setPhase("command"); void store.runCommand(name, command, "", { alive: () => lease.current() && !guestPage() }); };
1548
+ const dismiss = () => setPhase(null);
1549
+ const chat = { card: !!card, onCard: () => setPhase("card"),
1550
+ ...(supportsInstanceFeature(inst, "commands") ? { onModel: () => run("model"),
1551
+ modelText: `${shortModelName(modelLabel(inst.model || modelText(inst)))}${supportsInstanceFeature(inst, "effort") && effortChip(inst) ? ` · ${effortChip(inst)}` : ""}`,
1552
+ onBackend: () => inst.runtime === "windows" ? navigate(sectionPath("agents")) : run("backend"), backendText: backendLabel(inst.backend) } : {}) };
1553
+ return html`${phase === "menu" ? narrowScreen()
1554
+ ? html`<${AgentSheet} name=${name} inst=${inst} current="chat" items=${items} extra=${[favorite, items.find(item => item?.key === "splitChat")].filter(Boolean)} chat=${chat} targetLabel=${inst.display_name || name}
1555
+ verifiedUntil=${auth.st?.state === "verified" ? auth.st.until : null} onUsage=${() => setPhase("usage")} onClose=${dismiss} />`
1556
+ : html`<${Menu} cls="agent-menu" fit=${true} topLayer=${true} ownerKey=${name} context=${{...context, onClose: dismiss}} items=${[favorite, ...items]} label=${t("agentRow.actions", inst.display_name || name)} />` : null}
1557
+ ${phase === "delete" ? html`<${DeleteDialog} name=${name} inst=${inst} onClose=${dismiss}
1558
+ onDeleted=${() => { if (navStore.get().route?.instance === name) navigate("/ui"); }} />` : null}
1559
+ ${phase === "pins" ? html`<${PinsDialog} name=${name} onClose=${dismiss} onJump=${pin => { dismiss(); navigate(`${chatPath(name)}#m=${encodeURIComponent(pin.key)}`); }} />` : null}
1560
+ ${phase === "usage" ? html`<${UsageDialog} owner=${`chat:${name}`} onClose=${dismiss} />` : null}
1561
+ ${phase === "card" && card ? html`<${Dialog} title=${t("card.label", inst.display_name || name)} onClose=${dismiss}><${IdentityCard} name=${name} card=${card} compact=${true} /></${Dialog}>` : null}
1562
+ ${phase === "command" && command ? usesModelMenu(command)
1563
+ ? html`<${CommandCard} name=${name} lease=${lease} />`
1564
+ : html`<${Dialog} title=${inst.display_name || name} onClose=${() => { store.dismissCommand(name); dismiss(); }}><${CommandCard} name=${name} lease=${lease} /></${Dialog}>` : null}`;
1565
+ }
1566
+
1567
+ SidebarChatMenu.contextVersion = Menu.contextVersion === 1 && AgentSheet.sidebarTargetVersion === 1 ? 1 : 0;
@@ -9,7 +9,7 @@ import { html, useEffect, useLayoutEffect, useRef, useState } from "/assets/app-
9
9
  import { t, register, lang } from "/assets/app-i18n.js";
10
10
  import { appStore, useStore } from "/assets/app-store.js";
11
11
  import { useLease } from "/assets/app-ctx.js";
12
- import { PanelHeader, setTitle } from "/assets/app-shell.js";
12
+ import { PanelHeader, setTitle, useCanCreate, retryable } from "/assets/app-shell.js";
13
13
  import { HeaderTools } from "/assets/header-tools.js";
14
14
  import { navigate, renavigate } from "/assets/app-nav.js";
15
15
  import { RuntimePicker, AgentDraftAssistant, NativeAgendToolsHint, tr } from "./agent-runtime.js";
@@ -47,7 +47,7 @@ register("fleet", {
47
47
  hostMemory_elevated: "Host memory pressure: elevated — new agents start one at a time, at least 5 s apart",
48
48
  hostMemory_critical: "Host memory pressure: critical — new agents wait for memory to recover",
49
49
  hostMemory_top: "Largest: {0}", hostMemory_ownerFleet: "the fleet", hostMemory_ownerTmux: "tmux", hostMemory_ownerOther: "not an instance",
50
- title: "Fleet", tasks: "Tasks", schedules: "Schedules", teams: "Teams", org: "Org chart", cache: "Cache", usage: "Usage",
50
+ title: "Fleet", tasks: "Tasks", schedules: "Schedules", teams: "Teams", org: "Org chart", cache: "Cache", usage: "Usage", "host-health": "Host health",
51
51
  docs: "Docs", docsNewTab: "Docs (opens in a new tab)",
52
52
  newSchedule: "New schedule", newTeam: "New team",
53
53
  noSchedules: "No schedules yet", noSchedulesHint: "Automate recurring work with cron.",
@@ -75,7 +75,7 @@ register("fleet", {
75
75
  hostMemory_elevated: "主機記憶體壓力偏高:新的 agent 一次啟動一個,至少間隔 5 秒",
76
76
  hostMemory_critical: "主機記憶體壓力嚴重:新的 agent 會等記憶體恢復再啟動",
77
77
  hostMemory_top: "最大:{0}", hostMemory_ownerFleet: "fleet 本身", hostMemory_ownerTmux: "tmux", hostMemory_ownerOther: "不屬於任何 Agent",
78
- title: "Fleet", tasks: "Tasks", schedules: "排程", teams: "Teams", org: "組織圖", cache: "快取", usage: "用量",
78
+ title: "Fleet", tasks: "Tasks", schedules: "排程", teams: "Teams", org: "組織圖", cache: "快取", usage: "用量", "host-health": "主機狀態",
79
79
  docs: "文件", docsNewTab: "文件(在新分頁開啟)",
80
80
  newSchedule: "新增排程", newTeam: "新增 team",
81
81
  noSchedules: "還沒有排程", noSchedulesHint: "用 cron 自動執行例行工作。",
@@ -105,7 +105,7 @@ const DOCS_SITE = "https://songsid.github.io/AgEnD";
105
105
  export function docsUrl(language = lang()) {
106
106
  return `${DOCS_SITE}${language === "zh-TW" ? "/zh-tw" : ""}/docs/web-guide/`;
107
107
  }
108
- const ICONS = { tasks: "tasks", schedules: "clock", teams: "team", org: "org", cache: "chart", usage: "chart", authorizations: "key" };
108
+ const ICONS = { tasks: "tasks", schedules: "clock", teams: "team", org: "org", cache: "chart", usage: "chart", authorizations: "key", "host-health": "chart" };
109
109
  const BACKENDS = ["claude-code", "codex", "opencode", "kiro-cli", "antigravity", "grok", "muse"];
110
110
 
111
111
  async function api(method, path, body, lease) {
@@ -213,7 +213,9 @@ export function FleetPanel({ route, navKey }) {
213
213
  const tab = route.tab;
214
214
  useEffect(() => { setTitle(`${t("fleet.title")} · ${t(`fleet.${tab}`)}`); }, [tab, navKey]);
215
215
  useEffect(() => { rememberFleetTab(tab); }, [tab]); // #2183: the sidebar's and the phone's Fleet reopen it
216
- const Body = { tasks: TaskBoardTab, schedules: Schedules, teams: Teams, org: Org, cache: Cache, usage: UsageTab, authorizations: ContactAuthorizations }[tab] || TaskBoardTab;
216
+ const admin=useCanCreate();
217
+ const visibleTabs=FLEET_TABS.filter(k=>k!=="host-health"||admin);
218
+ const Body = { tasks: TaskBoardTab, schedules: Schedules, teams: Teams, org: Org, cache: Cache, usage: UsageTab, authorizations: ContactAuthorizations, "host-health":admin?LazyHostHealth:HostAdminRequired }[tab] || TaskBoardTab;
217
219
  // #1685: host memory pressure slowing or holding new agents — shown here, where macOS's routine "elevated" is not a chat notice.
218
220
  const { hostMemory, hostMemoryTop } = useStore(appStore);
219
221
  // #2015: and which processes hold the most, and whose — text only (never chat, #1712).
@@ -221,15 +223,15 @@ export function FleetPanel({ route, navKey }) {
221
223
  const sub = hostMemory ? html`<span class=${`status host-mem ${hostMemory}`} role="status"><span class=${`dot ${hostMemory === "critical" ? "bad" : "warn"}`} aria-hidden="true"></span>${t(`fleet.hostMemory_${hostMemory}`)}${top ? html`<span class="host-mem-top" title=${top}>${top}</span>` : null}</span>` : null;
222
224
  const root = useRef(null);
223
225
  const wide = useTabsInHeader(root), phone = usePhoneWidth();
224
- // The phone's tab row scrolls sideways when it does not fit beside ☰: bring the open tab into view (用量 is the last).
226
+ // Keep the active tab visible after async administrator-only tabs arrive, on either tab row.
225
227
  useLayoutEffect(() => {
226
- const nav = phone ? root.current?.querySelector(".fleet-phone-tabs") : null, on = nav?.querySelector(".active");
228
+ const nav = root.current?.querySelector("nav[data-trust='panel-navigation']"), on = nav?.querySelector(".active");
227
229
  if (!nav || !on) return;
228
230
  const n = nav.getBoundingClientRect(), a = on.getBoundingClientRect();
229
231
  if (a.right > n.right) nav.scrollLeft += a.right - n.right;
230
232
  else if (a.left < n.left) nav.scrollLeft -= n.left - a.left;
231
- }, [phone, tab]);
232
- const tabs = (cls) => html`<nav data-trust="panel-navigation" class=${cls} aria-label=${t("fleet.title")}>${FLEET_TABS.map(k => html`<a key=${k} href=${fleetPath(k)} class=${`seg-item${k === tab ? " active" : ""}`}
233
+ }, [phone, tab, admin, wide]);
234
+ const tabs = (cls) => html`<nav data-trust="panel-navigation" class=${cls} aria-label=${t("fleet.title")}>${visibleTabs.map(k => html`<a key=${k} href=${fleetPath(k)} class=${`seg-item${k === tab ? " active" : ""}`}
233
235
  aria-current=${k === tab ? "page" : undefined}><${Icon} name=${ICONS[k]} size=${16} /><span>${t(`fleet.${k}`)}</span></a>`)}</nav>`;
234
236
  return html`<div ref=${root} data-effect-panel="fleet" class="panel p-fleet">
235
237
  ${/* M-2542: the tabs share the title row (PanelHeader's nav slot, as the instance tabs do) when everything fits
@@ -240,11 +242,22 @@ export function FleetPanel({ route, navKey }) {
240
242
  ${/* M-3166 (Argon 5, the user's OK of round 2): a phone's Fleet is two rows — its tabs in the header's row (☰, then the
241
243
  tabs; the title, search, docs and text size give way: app.css), then the page's own tools. */ ""}
242
244
  <${PanelHeader} title=${t("fleet.title")} sub=${sub} nav=${wide ? tabs("fleet-tabs") : phone ? tabs("seg fleet-phone-tabs") : null}><${DocsLink} /><${HeaderTools} navKey=${navKey} /></${PanelHeader}>
243
- ${wide || phone ? null : tabs("seg")}
244
- <div data-trust="panel-content" class="panel-body"><div class=${`col${tab === "tasks" || tab === "org" || tab === "cache" || tab === "usage" || tab === "authorizations" ? " col-wide" : ""}`}><${Body} lease=${lease} /></div></div>
245
+ ${wide || phone ? null : tabs("seg fleet-tabs-row")}
246
+ <div data-trust="panel-content" class="panel-body"><div class=${`col${tab === "tasks" || tab === "org" || tab === "cache" || tab === "usage" || tab === "authorizations" || tab === "host-health" ? " col-wide" : ""}`}><${Body} lease=${lease} /></div></div>
245
247
  </div>`;
246
248
  }
247
249
 
250
+ // Code and data load only for the active administrator tab; a failed import can retry.
251
+ const loadHostHealth=retryable(attempt=>import(attempt?`./host-health.js?retry=${attempt}`:'./host-health.js'));
252
+ function LazyHostHealth({lease}) {
253
+ const [component,setComponent]=useState(null),[error,setError]=useState(false),active=useRef(true),generation=useRef(0);
254
+ const load=()=>{const mine=++generation.current;setError(false);loadHostHealth().then(m=>{if(active.current&&lease.current()&&mine===generation.current)setComponent(()=>m.HostHealth);},()=>{if(active.current&&lease.current()&&mine===generation.current)setError(true);});};
255
+ useEffect(()=>{active.current=true;load();return()=>{active.current=false;generation.current++;};},[lease]);
256
+ return component?html`<${component} lease=${lease}/>`:error?html`<${ErrorState} onRetry=${load}/>`:html`<${Skeleton} lines=${5}/>`;
257
+ }
258
+ function HostAdminRequired(){return html`<section class="card"><h2>${t('fleet.host-health')}</h2><p>${t('hostHealthAccess.admin')}</p></section>`;}
259
+ register('hostHealthAccess',{en:{admin:'Administrator sign-in is required to view host health.'},'zh-TW':{admin:'請以管理員身分登入,才能查看主機狀態。'}});
260
+
248
261
  /** #1844: the project's docs, from the overview — a link out (a new tab, no opener), not a Fleet tab; in front of the shared controls. */
249
262
  function DocsLink() {
250
263
  return html`<a class="btn btn-ghost btn-sm hd-docs" href=${docsUrl()} target="_blank" rel="noopener noreferrer" aria-label=${t("fleet.docsNewTab")} title=${t("fleet.docsNewTab")}>
@@ -21,6 +21,7 @@ import { createStore, useStore } from "/assets/app-store.js";
21
21
  import { navigate, navStore } from "/assets/app-nav.js";
22
22
  import { Empty, ErrorState, Skeleton } from "/assets/ui-states.js";
23
23
  import { Icon } from "/assets/ui-icons.js";
24
+ import { useJumpIdle } from "/assets/jump-idle.js";
24
25
  import { confirmDialog } from "/assets/ui-confirm.js";
25
26
  import { Dialog } from "/assets/ui-dialog.js";
26
27
  import { PairingNotices } from "./hub-quick-pairing.js";
@@ -948,6 +949,8 @@ function HubThread({ store, name, panelKey, threadRef, extra = null, emptyView =
948
949
  thread.dispose(true); list.remove(); th.current = null; if (threadRef && threadRef.current === thread) threadRef.current = null;
949
950
  };
950
951
  }, [store]);
952
+ // M-3493: the Fleet chat's 最新 (M-3492): it fades out JUMP_IDLE_MS after the last scroll (shared/jump-idle.js).
953
+ const jumpIdle = useJumpIdle(scroller, jump.show, store);
951
954
  return html`<div class="scroller hub-scroller" ref=${scroller}>
952
955
  <div class="thread-host" ref=${host}></div>
953
956
  ${/* #3145: that every asker shares the agent's one conversation is said before anyone types. */ ""}
@@ -956,7 +959,8 @@ function HubThread({ store, name, panelKey, threadRef, extra = null, emptyView =
956
959
  : !loaded && store.error() ? html`<${ErrorState} message=${errText({ code: store.error() })} onRetry=${() => store.refresh()} />` : null}
957
960
  ${empty && loaded && !store.closed() && emptyView ? html`<div class="center hub-room-empty">${emptyView}</div>` : null}
958
961
  ${empty && loaded && !store.closed() && !emptyView ? html`<div class="center hub-room-empty"><${Empty} icon="chat" title=${hc("emptyRoom", name)} hint=${personalAgentQuestionHint(store.room())??`${hc("emptyRoomHint", store.room().ownerName || name)}${lang() === "zh-TW" ? "" : " "}${hw("roomShared")}`} /></div>` : null}
959
- <div class="jump-dock">${jump.show ? html`<button data-trust="thread-control" type="button" class="jump-latest" onClick=${() => th.current && th.current.jumpLatest()}>
962
+ <div class="jump-dock">${jump.show ? html`<button data-trust="thread-control" type="button" ref=${jumpIdle.ref} class=${`jump-latest${jumpIdle.idle ? " is-idle" : ""}`}
963
+ onClick=${() => th.current && th.current.jumpLatest()} onFocus=${jumpIdle.onFocus} onBlur=${jumpIdle.onBlur}>
960
964
  <${Icon} name="down" size=${16} />${jump.unseen > 0 ? t("chat.newBelow", jump.unseen) : t("chat.jumpLatest")}</button>` : null}</div>
961
965
  </div>`;
962
966
  }
@@ -528,7 +528,7 @@ export function SettingsPanel({ route, navKey }) {
528
528
  <button type="button" class="btn btn-ghost btn-sm" disabled=${!ctx || yamlStaged(staged)} title=${ctx && yamlStaged(staged) ? tn("yamlUnsaved") : undefined} onClick=${openWizard}><${Icon} name="wand" size=${16} /><span class="hide-narrow">${tn("wizardButton")}</span></button>
529
529
  <button type="button" class="icon-btn" aria-label=${tn("helpButton")} title=${tn("helpButton")} onClick=${() => setDialog({ kind: "help", key: navKey })}><${Icon} name="info" /></button>
530
530
  </${PanelHeader}>
531
- <nav data-trust="panel-navigation" class="seg s-nav" aria-label=${tn("title")}><${SettingsSearch} /><div class="s-nav-groups">${SETTINGS_GROUPS.map((g) => html`<div key=${g.id} class="s-nav-group" role="group" aria-labelledby=${`s-grp-${g.id}`}>
531
+ <nav data-trust="panel-navigation" class="seg s-nav" aria-label=${tn("title")}><${SettingsSearch} schema=${ctx?.schema} /><div class="s-nav-groups">${SETTINGS_GROUPS.map((g) => html`<div key=${g.id} class="s-nav-group" role="group" aria-labelledby=${`s-grp-${g.id}`}>
532
532
  <span class="s-nav-head" id=${`s-grp-${g.id}`}>${tn(`grp_${g.id}`)}</span>
533
533
  ${g.sections.map((k) => html`<a key=${k} href=${sectionPath(k)} class=${`seg-item${k === section ? " active" : ""}`} title=${tn(`sec_${k}`)}
534
534
  aria-current=${k === section ? "page" : undefined}><${Icon} name=${ICONS[k]} size=${16} /><span>${tn(`sec_${k}`)}</span></a>`)}</div>`)}</div></nav>
@@ -582,10 +582,10 @@ function marked(text, query) {
582
582
  * #2347 §6: search every setting — by its name, its config key, or the words people use (both languages: "token",
583
583
  * "語言", "port") — results grouped by section with where they are; Enter or a click goes there. "/" focuses it.
584
584
  */
585
- function SettingsSearch() {
585
+ function SettingsSearch({schema}) {
586
586
  const [q, setQ] = useState("");
587
587
  const [active, setActive] = useState(0);
588
- const hits = useMemo(() => searchSettings(q).slice(0, 40), [q]);
588
+ const hits = useMemo(() => searchSettings(q, schema).slice(0, 40), [q, schema]);
589
589
  // Grouped by section, the group of the best match first (its order is the ranking's): Enter takes the best.
590
590
  const groups = useMemo(() => [...new Set(hits.map((e) => e.section))].map((s) => ({ section: s, items: hits.filter((e) => e.section === s) })), [hits]);
591
591
  const flat = groups.flatMap((g) => g.items);
@@ -240,7 +240,14 @@ export function SearchDialog({ preset = {}, onClose }) {
240
240
  // While a new query runs, the last answer stays (dimmed) rather than flashing empty.
241
241
  const groups = useMemo(() => groupHits(res.hits || []), [res]);
242
242
  // #2347 §6: the settings matching the query, from the page's own registry (no request), above the messages.
243
- const settings = useMemo(() => (q.trim() && !guest ? searchSettings(q).slice(0, SETTINGS_SHOWN) : []), [q]);
243
+ const [settingsSchema,setSettingsSchema] = useState(null);
244
+ useEffect(() => {
245
+ if (guest) {setSettingsSchema(null);return;}
246
+ let current=true;const ac=new AbortController();
247
+ fetch("/api/settings/schema",{signal:ac.signal}).then(r=>r.ok?r.json():null).then(schema=>{if(current)setSettingsSchema(schema);},()=>{if(current)setSettingsSchema(null);});
248
+ return ()=>{current=false;ac.abort();};
249
+ },[guest]);
250
+ const settings = useMemo(() => (q.trim() && !guest ? searchSettings(q, settingsSchema).slice(0, SETTINGS_SHOWN) : []), [q, guest, settingsSchema]);
244
251
  const flat = useMemo(() => [...settings.map((entry) => ({ setting: entry })), ...flatHits(groups)], [settings, groups]);
245
252
  const activeFilters = (f.instance ? 1 : 0) + (f.team ? 1 : 0) + (f.since !== "any" ? 1 : 0) + (!guest && f.sources.length < SOURCES.length ? 1 : 0) + (f.mine ? 1 : 0);
246
253
 
@@ -0,0 +1,2 @@
1
+ // One visibility rule for the card, Settings search and Ctrl K. Unknown is hidden.
2
+ export const hostMonitoringVisible = schema => schema?.host_monitoring === true && schema?.host_monitoring_page === true;
@@ -1,36 +1,50 @@
1
- import { html, useEffect } from '/assets/app-html.js';
1
+ import { html, useEffect, useRef, useState } from '/assets/app-html.js';
2
2
  import { register, t } from '/assets/app-i18n.js';
3
3
  import { confirmDialog } from '/assets/ui-confirm.js';
4
4
  import { useDraft, syncStage } from './settings-draft.js';
5
+ import { fleetPath } from '/assets/app-route.js';
6
+ import { hostMonitoringVisible } from './settings-capabilities.js';
5
7
  register('hostMonitoring', {
6
- en: { title:'Host monitoring', enabled:'Monitor this computer', agents:'Include agent footprint',
7
- hint:'When on, samples every 30–60 seconds; estimated 2–4 MiB RAM and 1–4 MiB of local writes per hour.',
8
+ en: { open:'View host health',title:'Host monitoring', enabled:'Monitor this computer', agents:'Include agent footprint',
9
+ hint:'Samples every 30–60 seconds; keeps up to 64 MiB locally. Memory and write costs are being measured.',
8
10
  agentHint:'Optional process snapshot every minute; for 32 agents, an estimated extra 2–8 MiB RAM and 1–4 MiB of writes per hour.',
9
11
  off:'Off by default. While off, there is no monitoring collector, timer or history file.',
10
12
  agentUnavailable:'Agent footprint is not available in this version of AgEnD.',
11
- stopTitle:'Turn off host monitoring?', stopBody:'This stops monitoring and its alerts, and removes the recorded host history. Turning it on again starts a new history.', stop:'Turn off', },
12
- 'zh-TW': { title:'主機監測', enabled:'監測這台電腦', agents:'包含 Agent 資源用量',
13
- hint:'開啟後每 30–60 秒取樣;估計使用 2–4 MiB 記憶體,每小時本機寫入 1–4 MiB。',
13
+ stopTitle:'Turn off host monitoring?', stopBody:'This stops monitoring and its alerts, and removes the recorded host history. Turning it on again starts a new history.', stop:'Turn off',
14
+ drive:'Windows drive holding this WSL distribution', auto:'Identify automatically', refresh:'Refresh drive list', driveHint:'If automatic identification is unavailable, choose the drive that holds this distribution’s virtual disk. Mounted local drives are listed from the latest sample while monitoring is on; Refresh reads that sample without starting a probe.', },
15
+ 'zh-TW': { open:'查看主機狀態',title:'主機監測', enabled:'監測這台電腦', agents:'包含 Agent 資源用量',
16
+ hint:'每 30–60 秒取樣,本機資料最多 64 MiB;額外記憶體與寫入量仍在量測。',
14
17
  agentHint:'選用:每分鐘讀取行程資料;32 個 Agent 估計另用 2–8 MiB 記憶體,每小時寫入 1–4 MiB。',
15
18
  off:'預設關閉。關閉時沒有監測收集器、計時器或歷史檔案。',
16
19
  agentUnavailable:'這個 AgEnD 版本尚未提供 Agent 資源用量。',
17
- stopTitle:'關閉主機監測?', stopBody:'這會停止監測與通知,並移除已記錄的主機歷史。重新開啟時會建立新的歷史。', stop:'關閉', },
20
+ stopTitle:'關閉主機監測?', stopBody:'這會停止監測與通知,並移除已記錄的主機歷史。重新開啟時會建立新的歷史。', stop:'關閉',
21
+ drive:'這個 WSL 發行版本的 Windows 磁碟', auto:'自動辨識', refresh:'重新整理磁碟清單', driveHint:'無法自動辨識時,請選擇存放這個發行版本虛擬磁碟的磁碟。監測開啟後會依最新取樣列出已掛載的本機磁碟;重新整理只讀取該取樣,不會啟動探測。', },
18
22
  });
19
23
  const copy = k => t(`hostMonitoring.${k}`);
20
24
  export function HostMonitoringSettings({ ctx }) {
21
- const available = ctx.schema?.host_monitoring === true;
25
+ const available = hostMonitoringVisible(ctx.schema);
22
26
  useEffect(() => { if (!available) syncStage(ctx, 'host-monitoring', null); }, [available]);
23
- // Keep the dormant controls out of Settings until a real collector is wired.
27
+ // A collector alone is not a visible feature: S-207 must provide its page too.
24
28
  // A separate child keeps hook order stable across capability transitions.
25
29
  return available ? html`<${AvailableHostMonitoringSettings} ctx=${ctx} />` : null;
26
30
  }
27
31
  function AvailableHostMonitoringSettings({ ctx }) {
28
- const base = { enabled:ctx.fleet.monitoring?.enabled === true, agent_footprint:ctx.fleet.monitoring?.agent_footprint === true };
32
+ const base = { enabled:ctx.fleet.monitoring?.enabled === true, agent_footprint:ctx.fleet.monitoring?.agent_footprint === true,
33
+ ...(typeof ctx.fleet.monitoring?.wsl_drive === 'string' ? {wsl_drive:ctx.fleet.monitoring.wsl_drive} : {}) };
29
34
  const [form, setForm] = useDraft(ctx, 'host-monitoring', () => base);
35
+ const [health,setHealth] = useState(null), [reading,setReading] = useState(false);
36
+ const live=useRef(false),seq=useRef(0);
37
+ const refresh=async()=>{
38
+ const request=++seq.current;setReading(true);
39
+ try {const r=await fetch('/ui/host-health');const snapshot=r.ok?await r.json():null;if(live.current&&request===seq.current)setHealth(snapshot);}
40
+ catch {if(live.current&&request===seq.current)setHealth(null);}
41
+ finally {if(live.current&&request===seq.current)setReading(false);}
42
+ };
43
+ useEffect(()=>{live.current=true;void refresh();return()=>{live.current=false;seq.current++;};},[]);
30
44
  const agentsAvailable = ctx.schema?.host_monitoring_agents === true;
31
45
  useEffect(() => {
32
- const changed = form.enabled !== base.enabled || form.agent_footprint !== base.agent_footprint;
33
- syncStage(ctx, 'host-monitoring', changed ? {label:copy('title'), impact:'now', request:{method:'PUT',url:'/api/settings/fleet/monitoring',body:{enabled:form.enabled,agent_footprint:form.agent_footprint}}} : null);
46
+ const changed = form.enabled !== base.enabled || form.agent_footprint !== base.agent_footprint || (form.wsl_drive ?? '') !== (base.wsl_drive ?? '');
47
+ syncStage(ctx, 'host-monitoring', changed ? {label:copy('title'), impact:'now', request:{method:'PUT',url:'/api/settings/fleet/monitoring',body:{enabled:form.enabled,agent_footprint:form.agent_footprint,...(Object.hasOwn(form,'wsl_drive')?{wsl_drive:form.wsl_drive}:{})}}} : null);
34
48
  }, [form]);
35
49
  const setEnabled = async (checked, control) => {
36
50
  if (!checked && form.enabled && !(await confirmDialog({title:copy('stopTitle'),message:copy('stopBody'),confirmLabel:copy('stop'),danger:true}))) {
@@ -43,9 +57,13 @@ function AvailableHostMonitoringSettings({ ctx }) {
43
57
  };
44
58
  const row = (id,key,hint,disabled,change) => html`<div class="s-setting-row"><div class="s-setting-copy"><label for=${id}>${copy(key)}</label><p class="note" id=${`${id}-hint`}>${copy(hint)}</p></div>
45
59
  <input class="s-ui-toggle" type="checkbox" role="switch" id=${id} checked=${form[key === 'agents' ? 'agent_footprint':'enabled']} disabled=${disabled} aria-describedby=${`${id}-hint`} onChange=${e=>change(e.target.checked, e.target)} /></div>`;
46
- return html`<section class="card s-group" id="host-monitoring"><h3>${copy('title')}</h3>
60
+ return html`<section class="card s-group" id="host-monitoring"><div class="s-group-head"><h3>${copy('title')}</h3><a class="btn btn-sm" href=${fleetPath('host-health')}>${copy('open')}</a></div>
47
61
  ${row('hostMonitoringEnabled','enabled','hint',false,setEnabled)}
48
62
  ${row('hostMonitoringAgents','agents','agentHint',!agentsAvailable || !form.enabled,checked=>setForm(f=>({...f,agent_footprint:checked})))}
63
+ ${health?.platform === 'wsl' || base.wsl_drive ? html`<div class="field"><label for="hostMonitoringDrive">${copy('drive')}</label>
64
+ <select id="hostMonitoringDrive" value=${form.wsl_drive ?? ''} onChange=${e=>setForm(f=>({...f,wsl_drive:e.target.value}))}>
65
+ <option value="">${copy('auto')}</option>${[...new Set([...(health?.disks?.value?.availableDrives ?? []),form.wsl_drive])].filter(v=>typeof v==='string'&&/^[A-Z]$/.test(v)).slice(0,26).map(d=>html`<option value=${d}>${d}:</option>`)}</select>
66
+ <p class="note">${copy('driveHint')}</p><button type="button" class="btn btn-sm" disabled=${reading} onClick=${refresh}>${copy('refresh')}</button></div>` : null}
49
67
  ${!agentsAvailable ? html`<p class="note">${copy('agentUnavailable')}</p>` : null}
50
68
  <p class="note">${copy('off')}</p></section>`;
51
69
  }
@@ -12,6 +12,7 @@ import "./settings-public-session-strings.js"; // #3708: publicSessionAbsolute
12
12
  import "./settings-access-strings.js"; // …and this one (webLoginQr), added by Access & security (#3061)
13
13
  import "/assets/chat-strings.js";
14
14
  import { GUESTS_SETTINGS } from "./settings-guests-entries.js";
15
+ import { hostMonitoringVisible } from "./settings-capabilities.js";
15
16
  import { CLI_CAPS } from "./cli-caps.js";
16
17
 
17
18
  const L = (en, zh) => ({ en, "zh-TW": zh });
@@ -20,6 +21,7 @@ const L = (en, zh) => ({ en, "zh-TW": zh });
20
21
  const CLI_WORDS = Object.keys(CLI_CAPS).flatMap((id) => [id, id.split("-")[0]]);
21
22
  /** [id, section, target, labelKey | label, config key, words en, words zh] */
22
23
  const ROWS = [
24
+ ["host.monitoring", "notifications", "#host-monitoring", null, "monitoring.enabled", ["host", "health", "monitoring", "disk", "memory", "cpu", "agent footprint"], ["主機", "監測", "磁碟", "記憶體", "資源用量"], L("Host monitoring", "主機監測")],
23
25
  ["general.location", "agent-defaults", "#general-location", null, null, ["general", "windows", "paired PC", "host", "location"], ["General", "Windows", "電腦", "主機", "執行位置"], L("Run General on", "General 執行位置")],
24
26
  // alpha.6 feedback (#2): "hub" found nothing — Settings → Hub's cards. Connect to a Hub is drawn once membership is on.
25
27
  ["hub.membership", "hub", "#hubMemberEnabled", null, "hub_member.enabled", ["hub", "team hub", "membership", "connect", "join", "pair", "share agents"], ["Hub", "團隊 Hub", "成員", "連線", "加入", "配對", "分享"], L("Allow this fleet to connect to a Hub", "允許這個 Fleet 連線至 Hub")],
@@ -155,11 +157,12 @@ const fold = (s) => String(s || "").toLowerCase().normalize("NFKC");
155
157
  * Entries matching `query`: every word in it is found in the entry's name (either language), its config key, or its
156
158
  * words (either language). Ranked: a name that starts with it, then one that contains it, then a config key, then a word.
157
159
  */
158
- export function searchSettings(query) {
160
+ export function searchSettings(query, schema = null) {
159
161
  const terms = fold(query).split(/\s+/).filter(Boolean);
160
162
  if (!terms.length) return [];
161
163
  const scored = [];
162
164
  for (const entry of SETTINGS_REGISTRY) {
165
+ if (entry.id === "host.monitoring" && !hostMonitoringVisible(schema)) continue;
163
166
  const names = [settingLabel(entry, "en"), settingLabel(entry, "zh-TW")].map(fold);
164
167
  const keys = fold(entry.key || "");
165
168
  const words = [...(entry.words.en || []), ...(entry.words["zh-TW"] || [])].map(fold);
@@ -22,15 +22,19 @@
22
22
  curving into the row's rounded corners. Drawn here, on the row's own class, rather than by a class in the markup (#3407
23
23
  review): this sheet loads apart from the shell and its markup, so a tab holding either older half still draws one bar
24
24
  in its state's colour (older markup + this sheet: this bar; this markup is unchanged + an older sheet: the old edge),
25
- never two. The 3px the bar takes is added to the row's padding. */
26
- .s-accounts .s-account-row { display: block; position: relative; min-height: 0; padding: var(--s-3) var(--s-4) var(--s-3) calc(var(--s-4) + 3px); background: var(--bg); overflow: visible; }
25
+ never two. The absolute bar does not change the shared inner padding. */
26
+ .s-accounts .s-account-row { display: flex; flex-direction: column; align-items: stretch; gap: var(--s-2); position: relative; min-height: 0; padding: var(--s-3) var(--s-4); background: var(--bg); overflow: visible; }
27
27
  .s-accounts .s-account-row::before { content: ""; position: absolute; left: 0; top: var(--s-2); bottom: var(--s-2); width: 3px; background: var(--ok); pointer-events: none; }
28
28
  .s-account-row:has(.s-auth-state.is-not_signed_in)::before { background: var(--warn); }
29
29
  .s-account-row:has(.s-auth-state:is(.is-unknown, .is-not_installed, .is-too_old))::before { background: var(--text-3); }
30
30
  .s-account-row details { margin-top: var(--s-3); }
31
31
 
32
- /* Layer 1: the title bar — name, state, default tag on the left; the buttons (`.s-actions`) on the right. */
33
- .s-account-title-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-3); }
32
+ /* One spacing rhythm per box; the absolute state bar never shifts its content. */
33
+ .s-accounts .s-account-row > * { margin: 0; }
34
+
35
+ /* Layer 1: name/state, then a left-aligned wrapping action row at the same content edge. */
36
+ .s-account-title-bar { display: flex; flex-direction: column; align-items: stretch; gap: var(--s-2); }
37
+ .s-account-title-bar > .s-actions { margin: 0; justify-content: flex-start; gap: var(--s-2); }
34
38
  .s-account-title-left { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-2); }
35
39
  .s-account-title-left strong { font-size: var(--fs-md); line-height: 1.4; overflow-wrap: anywhere; }
36
40
  .s-account-default-tag { background: var(--accent-dim); color: var(--accent); font-weight: var(--fw-semibold); }
@@ -26,7 +26,7 @@ register("agentSheet", {
26
26
  en: { sheet: "{0}: more", search: "Search", files: "Files & changes", card: "Card", usage: "Usage", model: "Model & effort", backend: "CLI backend",
27
27
  textSize: "Text size", textSizes: "Small,Medium,Large", look: "Appearance", agent: "This agent", details: "Agent details",
28
28
  verifiedUntil: "Verified · speaks as you until {0}" },
29
- "zh-TW": { sheet: "{0}:更多", search: "搜尋", files: "檔案與變更", card: "卡片", usage: "用量", model: "模型與推理", backend: "CLI backend",
29
+ "zh-TW": { sheet: "{0}:更多", search: "搜尋", files: "檔案與變更", card: "卡片", usage: "用量", model: "模型與推理", backend: "CLI 後端",
30
30
  textSize: "文字大小", textSizes: "小,中,大", look: "外觀", agent: "這個 Agent", details: "Agent 詳細資料",
31
31
  verifiedUntil: "已驗證 · 以你的身分發言到 {0}" },
32
32
  });
@@ -77,7 +77,7 @@ export function AgentSheetButton({ name, inst, current, items = [], extra = [],
77
77
  ${usage ? html`<${UsageDialog} owner=${navKey} onClose=${() => setUsage(false)} />` : null}`;
78
78
  }
79
79
 
80
- export function AgentSheet({ name, inst, current, items = [], extra = [], chat = null, verifiedUntil = null, onUsage, onClose }) {
80
+ export function AgentSheet({ name, inst, current, items = [], extra = [], chat = null, verifiedUntil = null, onUsage, onClose, targetLabel = null }) {
81
81
  const [look, setLook] = useState(false);
82
82
  const size = useStore(textSizeStore).size;
83
83
  const by = (key) => items.find((i) => i && i.key === key);
@@ -94,6 +94,7 @@ export function AgentSheet({ name, inst, current, items = [], extra = [], chat =
94
94
  const details = by("details") || (current !== "details" && supportsInstanceFeature(inst, "details")
95
95
  ? { key: "details", icon: "info", onSelect: () => navigate(detailsPath(name)) } : null);
96
96
  return html`<${Dialog} title=${t("agentSheet.sheet", name)} onClose=${onClose} cls="chat-sheet">
97
+ ${targetLabel ? html`<h3 class="menu-heading chat-sheet-head">${targetLabel}</h3>` : null}
97
98
  <div class="chat-sheet-tiles">
98
99
  ${current !== "chat" ? tile("chat", t("app.chat"), () => navigate(chatPath(name))) : null}
99
100
  ${current !== "view" && supportsInstanceFeature(inst, "view") ? tile("view", t("app.view"), () => navigate(viewPath(name))) : null}
@@ -115,3 +116,5 @@ export function AgentSheet({ name, inst, current, items = [], extra = [], chat =
115
116
  ${verifiedUntil ? html`<div class="chat-sheet-foot">✓ ${t("agentSheet.verifiedUntil", untilClock(verifiedUntil))}</div>` : null}
116
117
  </${Dialog}>`;
117
118
  }
119
+
120
+ AgentSheet.sidebarTargetVersion = 1;
@@ -2,7 +2,7 @@
2
2
  // a test runs both over one list of cases). Pure: no DOM, no history.
3
3
 
4
4
  // #2347 §10: Config is gone from Fleet — each of its settings has one home in Settings (/ui/fleet/config leads there).
5
- export const FLEET_TABS = ["tasks", "schedules", "teams", "org", "cache", "usage", "authorizations"];
5
+ export const FLEET_TABS = ["tasks", "schedules", "teams", "org", "cache", "usage", "authorizations", "host-health"];
6
6
  // #2347: two groups — "You" changes only you or this browser; "Fleet" changes AgEnD for everyone.
7
7
  export const SETTINGS_GROUPS = Object.freeze([
8
8
  Object.freeze({ id: "you", sections: Object.freeze(["preferences", "look"]) }),