@songsid/agend 2.4.0-beta.38 → 2.4.0-beta.39
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-whats-new.js +1 -1
- package/dist/agent-whats-new.js.map +1 -1
- package/dist/agent-workspace.js +5 -4
- package/dist/agent-workspace.js.map +1 -1
- package/dist/auth-api.js +2 -0
- package/dist/auth-api.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/fleet-manager.d.ts +15 -0
- package/dist/fleet-manager.js +38 -11
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/admin/SKILL.md +1 -1
- package/dist/general-knowledge/skills/hub/SKILL.md +50 -50
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +4 -0
- package/dist/hub/directory/directory.js +2 -2
- package/dist/hub/directory/directory.js.map +1 -1
- package/dist/hub/init/text.js +11 -11
- package/dist/hub/init/text.js.map +1 -1
- package/dist/hub/mcp/catalog.js +1 -1
- package/dist/hub/mcp/catalog.js.map +1 -1
- package/dist/hub/mcp/server.js +1 -1
- package/dist/hub/mcp/server.js.map +1 -1
- package/dist/locale.js +6 -6
- package/dist/locale.js.map +1 -1
- package/dist/office-share-page.js +1 -1
- package/dist/office-share-page.js.map +1 -1
- package/dist/runtime-personal-answer-only.js +1 -1
- package/dist/runtime-personal-answer-only.js.map +1 -1
- package/dist/runtime-transcript-delta-reader.js +6 -1
- package/dist/runtime-transcript-delta-reader.js.map +1 -1
- package/dist/tmux-rollback.js +21 -23
- package/dist/tmux-rollback.js.map +1 -1
- package/dist/tmux-server.d.ts +2 -0
- package/dist/tmux-server.js +31 -13
- package/dist/tmux-server.js.map +1 -1
- package/dist/ui/hub-admin-overview.js +2 -2
- package/dist/ui/hub-agent-intro.js +2 -2
- package/dist/ui/hub-ai-apps-strings.js +1 -1
- package/dist/ui/hub-chat-strings.js +2 -2
- package/dist/ui/hub-client.js +18 -5
- package/dist/ui/hub-company-join-strings.js +31 -31
- package/dist/ui/hub-company-join.js +2 -2
- package/dist/ui/hub-enrolment-code-strings.js +10 -10
- package/dist/ui/hub-grant-picker.js +3 -3
- package/dist/ui/hub-group-strings.js +2 -2
- package/dist/ui/hub-join-one-strings.js +12 -12
- package/dist/ui/hub-join-steps.js +10 -10
- package/dist/ui/hub-my-agents-strings.js +3 -3
- package/dist/ui/hub-personal-agent-strings.js +6 -6
- package/dist/ui/hub-roles-strings.js +1 -1
- package/dist/ui/hub-room-composer.js +21 -1
- package/dist/ui/hub-room-owner-requests-strings.js +2 -2
- package/dist/ui/hub-room-thread.js +116 -9
- package/dist/ui/hub-strings.js +4 -4
- package/dist/ui/hub-subject-picker.js +1 -1
- package/dist/ui/hub-teams-strings.js +1 -1
- package/dist/ui/settings-access-overview.js +104 -25
- package/dist/ui/settings-hub-member-address.js +6 -6
- package/dist/ui/settings-hub-web-address.js +6 -6
- package/dist/ui/settings-registry.js +1 -1
- package/dist/ui/shared/access-overview.css +6 -0
- package/dist/ui/shared/app-shell.js +7 -7
- package/dist/ui/shared/app.css +24 -3
- package/dist/ui/shared/info-tip.js +33 -8
- package/dist/ui/shared/update-card-ui.js +72 -25
- package/dist/ui/shared/usage-agents.js +99 -0
- package/dist/ui/shared/usage-dialog.js +15 -18
- package/dist/ui/shared/view-strings.js +1 -1
- package/dist/ui/workspace-diff-path.d.ts +1 -0
- package/dist/ui/workspace-diff-path.js +22 -0
- package/dist/ui/workspace-panel.js +4 -3
- package/dist/update-readiness-host.js +6 -2
- package/dist/update-readiness-host.js.map +1 -1
- package/dist/update-readiness.js +15 -2
- package/dist/update-readiness.js.map +1 -1
- package/dist/usage/providers.d.ts +4 -0
- package/dist/usage/providers.js +9 -2
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/usage-api.js +3 -2
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/web-api.js +2 -1
- package/dist/web-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// linked, never changed here) — then the other connections, each on its own page with its own disconnect or remove.
|
|
5
5
|
// Every action here is an existing route asked again by the server: a sign-out is POST /ui/devices/signout (#3553).
|
|
6
6
|
// The words are English and 繁體中文, as everything in src/ui (tests/i18n-ui-literals-2390.test.ts).
|
|
7
|
-
import { html, useEffect, useState } from "/assets/app-html.js";
|
|
7
|
+
import { html, useEffect, useRef, useState } from "/assets/app-html.js";
|
|
8
8
|
import { t, register } from "/assets/app-i18n.js";
|
|
9
9
|
import { Dialog } from "/assets/ui-dialog.js";
|
|
10
10
|
import { Icon } from "/assets/ui-icons.js";
|
|
@@ -35,6 +35,9 @@ register("accessov", {
|
|
|
35
35
|
otherTitle: "Other connections", otherLead: "Disconnect or remove each one on its own page.",
|
|
36
36
|
hub: "Hub", hubHint: "Your team's Hub and the agents shared there", windows: "Windows computers", windowsHint: "Windows computers connected to run agents",
|
|
37
37
|
hubOn: "Connected", paired: "{0} connected",
|
|
38
|
+
loading: "Checking…", unknown: "Couldn't check", checkAgain: "Check again",
|
|
39
|
+
signOutUnknown: "No answer came back, so it isn't known whether {0} was signed out. The list has been read again.",
|
|
40
|
+
closeUnknown: "No answer came back, so it isn't known whether the link closed. Its state has been read again.",
|
|
38
41
|
},
|
|
39
42
|
"zh-TW": {
|
|
40
43
|
tab: "總覽", devicesTitle: "已登入的裝置", devicesCount: "{0} 個登入", more: "另外 {0} 個,到「裝置與登入」查看", manageDevices: "裝置與登入", manageGuests: "訪客",
|
|
@@ -54,6 +57,9 @@ register("accessov", {
|
|
|
54
57
|
otherTitle: "其他連線", otherLead: "到各自的頁面中斷或移除。",
|
|
55
58
|
hub: "Hub", hubHint: "你的團隊 Hub,以及在那裡分享的 Agent", windows: "Windows 電腦", windowsHint: "連上這裡、用來執行 Agent 的 Windows 電腦",
|
|
56
59
|
hubOn: "已連接", paired: "已連上 {0} 台",
|
|
60
|
+
loading: "確認中…", unknown: "無法確認", checkAgain: "重新確認",
|
|
61
|
+
signOutUnknown: "沒有收到回應,不確定 {0} 是否已登出。已重新讀取清單。",
|
|
62
|
+
closeUnknown: "沒有收到回應,不確定連結是否已關閉。已重新讀取它的狀態。",
|
|
57
63
|
},
|
|
58
64
|
});
|
|
59
65
|
const to = (k, ...a) => t(`accessov.${k}`, ...a);
|
|
@@ -77,6 +83,19 @@ const SHOWN = 4;
|
|
|
77
83
|
const leftWords = (ms) => { const m = Math.max(1, Math.round(ms / 60_000)); return m >= 60 ? (m % 60 ? to("hm", Math.floor(m / 60), m % 60) : to("h", Math.floor(m / 60))) : to("m", m); };
|
|
78
84
|
const day = (ms) => { const d = new Date(ms); return `${d.getFullYear()}/${String(d.getMonth() + 1).padStart(2, "0")}/${String(d.getDate()).padStart(2, "0")}`; };
|
|
79
85
|
|
|
86
|
+
/**
|
|
87
|
+
* M-4028: a fact read from the server is one of three things — not read yet (null), unreadable (UNKNOWN: a refused or failed
|
|
88
|
+
* read, or no answer), or what the server said. Only the last is ever shown as a value; the other two say so, never as
|
|
89
|
+
* "off", "not set up", "0" or "none".
|
|
90
|
+
*/
|
|
91
|
+
const UNKNOWN = Object.freeze({ unknown: true });
|
|
92
|
+
const isFact = (v) => v !== null && v !== UNKNOWN;
|
|
93
|
+
const factWord = (v) => (v === null ? to("loading") : to("unknown"));
|
|
94
|
+
/** One read: its body when it answered ok with a usable body, else UNKNOWN (a refusal, a failure or no answer). */
|
|
95
|
+
const settle = async (path, usable) => {
|
|
96
|
+
try { const r = await api(path); return r.ok && r.body && usable(r.body) ? r.body : UNKNOWN; } catch { return UNKNOWN; }
|
|
97
|
+
};
|
|
98
|
+
|
|
80
99
|
function Row({ label, value, tone, hint }) {
|
|
81
100
|
return html`<div class="s-ov-row"><dt>${label}</dt><dd class=${tone ? `s-ov-${tone}` : ""}>${value}</dd>${hint ? html`<small class="s-ov-hint">${hint}</small>` : null}</div>`;
|
|
82
101
|
}
|
|
@@ -96,47 +115,100 @@ export function AccessOverview({ web = {}, hub, openTab, overPublicLink, active
|
|
|
96
115
|
const [closedFrame, setClosedFrame] = useState(null);
|
|
97
116
|
const [busy, setBusy] = useState(false);
|
|
98
117
|
const [note, setNote] = useState("");
|
|
118
|
+
// M-4028: every read stands on its own — one that fails or is refused makes its own facts unknown, never another's,
|
|
119
|
+
// and never a value ("0 signed in", "not set up", "off", "none"). The share count is a fact only when both lists answered.
|
|
120
|
+
// Prism on #4680: reads may overlap (Check again, a tab shown again, an action's re-read); only the newest one's answers
|
|
121
|
+
// are kept, so an older read finishing late never puts back a device the newer one saw signed out.
|
|
122
|
+
const loads = useRef(0);
|
|
99
123
|
const load = async () => {
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
124
|
+
const gen = ++loads.current;
|
|
125
|
+
const [d, o, os, ps, rt] = await Promise.all([
|
|
126
|
+
settle("/ui/devices", (b) => Array.isArray(b.devices)),
|
|
127
|
+
// The owner facts are known only when the answer carries them (an empty or partial body is not "not set up, off").
|
|
128
|
+
settle("/ui/outside", (b) => !Array.isArray(b) && typeof b.enrolled === "boolean" && typeof b.strict === "boolean"),
|
|
129
|
+
settle("/ui/office-share", (b) => Array.isArray(b.shares)), settle("/ui/page-share", (b) => Array.isArray(b.shares)),
|
|
130
|
+
settle("/ui/runtimes", (b) => typeof b === "object")]);
|
|
131
|
+
if (gen !== loads.current) return;
|
|
132
|
+
setDevices(d === UNKNOWN ? UNKNOWN : d.devices);
|
|
133
|
+
setOutside(o);
|
|
134
|
+
setShares(os === UNKNOWN || ps === UNKNOWN ? UNKNOWN : os.shares.length + ps.shares.length);
|
|
135
|
+
// The paired computers only label the Windows tile: unknown or off shows no state there.
|
|
136
|
+
setMachines(rt !== UNKNOWN && rt.enabled ? (rt.machines || []).length : null);
|
|
107
137
|
};
|
|
108
138
|
// Read again whenever the tab is shown: the tab panels stay mounted, so a device signed out on 裝置與登入 (or a link
|
|
109
139
|
// closed elsewhere) would otherwise still be listed here.
|
|
110
140
|
useEffect(() => { if (active) load(); }, [active]);
|
|
111
|
-
const rows = [...(devices
|
|
141
|
+
const rows = [...(isFact(devices) ? devices : [])].sort((a, b) => (b.current ? 1 : 0) - (a.current ? 1 : 0));
|
|
142
|
+
const known = (v) => (isFact(v) ? v : null); // what the server said, or null for "not known"
|
|
143
|
+
const out = known(outside);
|
|
112
144
|
const blockedWhy = (d) => to(d.signOutBlocked === "other_admin" ? "blockedOther" : "blockedOwner");
|
|
145
|
+
// M-4026: an answer that never comes (a dropped connection) leaves the outcome unknown: the dialog closes, the page says
|
|
146
|
+
// so, and the list is read again — and only then can another sign-out (or anything else here) start.
|
|
113
147
|
const signOut = async () => {
|
|
114
148
|
const d = ask; setBusy(true);
|
|
115
|
-
|
|
116
|
-
|
|
149
|
+
let r = null;
|
|
150
|
+
try { r = await api("/ui/devices/signout", { method: "POST", body: JSON.stringify({ handle: d.handle }) }); } catch { /* no answer */ }
|
|
151
|
+
setAsk(null);
|
|
152
|
+
// No answer, or a success whose body did not arrive whole (not its { ok: true }): the outcome is unknown.
|
|
153
|
+
if (!r || (r.ok && !(r.body && r.body.ok === true))) { setNote(to("signOutUnknown", d.label)); try { await load(); } finally { setBusy(false); } return; }
|
|
154
|
+
setBusy(false); setNote(r.ok ? to("signedOut", d.label) : (r.body && r.body.error) || `HTTP ${r.status}`);
|
|
117
155
|
load();
|
|
118
156
|
};
|
|
119
157
|
// The link's state: the shell's status frame (every fleet; a tab from before S-120 has none — then /ui/outside's).
|
|
120
158
|
const pub = web.public_link || {};
|
|
121
|
-
|
|
122
|
-
|
|
159
|
+
// Prism on #4680: after a close whose answer never came, what this page knew then is no evidence either way — the frame
|
|
160
|
+
// held then still says open, and /ui/outside names no ordinary public link. `check` ({ frame, polled }) marks that: while
|
|
161
|
+
// the shell still holds the same frame (whatever it is, none included), the link is what the re-read status said
|
|
162
|
+
// (`polled`, this page's alone — never applied over the shell's newer frames), else unknown with no Close button. Any newer
|
|
163
|
+
// frame from the stream ends it.
|
|
164
|
+
const [check, setCheck] = useState(null);
|
|
165
|
+
const unsure = !!check && publicLink === check.frame;
|
|
166
|
+
const shown = unsure ? check.polled : publicLink; // the frame this card trusts now (undefined while unknown)
|
|
167
|
+
const framed = shown && shown.state !== "closed" && shown !== closedFrame ? { ...shown, quick: !pub.hostname } : null;
|
|
168
|
+
// /ui/outside's link stands in only where the shell has no frame at all: a current frame saying closed wins over it.
|
|
169
|
+
const link = unsure ? framed : framed || (!publicLink && out && out.link) || null;
|
|
170
|
+
// Unknown: after a lost answer until a status is read, or with no frame and no readable /ui/outside either.
|
|
171
|
+
const linkUnknown = (unsure && !check.polled) || (!unsure && !publicLink && outside !== null && !isFact(outside));
|
|
172
|
+
/** The fleet's current status (GET /ui/poll with a cursor that is not one: the status only, no messages) — for this card only. */
|
|
173
|
+
const recheckLink = async (mark) => {
|
|
174
|
+
try {
|
|
175
|
+
const r = await api("/ui/poll?after=status");
|
|
176
|
+
const fresh = r.ok && r.body && r.body.status && typeof r.body.status === "object" ? r.body.status.publicLink : null;
|
|
177
|
+
if (fresh && typeof fresh.state === "string") setCheck((c) => (c === mark ? { ...c, polled: fresh } : c));
|
|
178
|
+
} catch { /* still unknown: Check again, or the next frame */ }
|
|
179
|
+
};
|
|
123
180
|
// A web-only fleet's outside link is the owner's switch (#3008): closed there, not here (the route answers 409).
|
|
124
|
-
const outsideOwned = !!(link &&
|
|
181
|
+
const outsideOwned = !!(link && out && out.webOnly && out.outside);
|
|
125
182
|
const closeLink = async () => {
|
|
126
183
|
setBusy(true);
|
|
127
|
-
const seen = publicLink;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
184
|
+
const seen = publicLink, trusted = shown; // the shell's frame now, and the one this card shows (a re-read's, after a lost answer)
|
|
185
|
+
let r = null;
|
|
186
|
+
try { r = await api("/ui/public-link/close", { method: "POST", body: "{}" }); } catch { /* no answer */ }
|
|
187
|
+
setAskClose(false);
|
|
188
|
+
// M-4026: no answer, or a success whose body did not arrive whole (not { closed } / { closing }) — not known whether it
|
|
189
|
+
// closed: say so, treat the frame held now as no evidence, and read the fleet's status again before anything can start.
|
|
190
|
+
const whole = r && r.ok && r.body && (typeof r.body.closed === "boolean" || r.body.closing === true);
|
|
191
|
+
if (!r || (r.ok && !whole)) {
|
|
192
|
+
const mark = { frame: seen, polled: undefined };
|
|
193
|
+
setLinkNote(to("closeUnknown")); setCheck(mark);
|
|
194
|
+
try { await Promise.all([recheckLink(mark), load()]); } finally { setBusy(false); }
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
setBusy(false);
|
|
198
|
+
if (r.ok && r.body && r.body.closed === true) setClosedFrame(trusted); // only a close that happened; a refusal changes nothing
|
|
131
199
|
setLinkNote(r.ok ? to("closed") : r.body && r.body.error === "outside_link" ? to("outsideOwned") : to("closeFailed"));
|
|
132
200
|
load();
|
|
133
201
|
};
|
|
134
|
-
const
|
|
202
|
+
const anyUnknown = [devices, outside, shares].some((v) => v === UNKNOWN);
|
|
203
|
+
const again = anyUnknown ? html`<button type="button" class="btn btn-sm s-ov-again" disabled=${busy} onClick=${() => load()}>${to("checkAgain")}</button>` : null;
|
|
204
|
+
const linkValue = linkUnknown ? html`<span class="s-ov-unknown">${to("unknown")}</span>`
|
|
205
|
+
: link ? html`<span class="tag tag-ok">${to("linkOpen")}</span> ${link.quick ? to("linkQuick") : to("linkNamed", pub.hostname || "")} · ${link.noExpiry ? to("linkNoExpiry") : link.expiresAt ? to("linkLeft", leftWords(link.expiresAt - Date.now())) : ""}`
|
|
135
206
|
: pub.allow_public === false ? to("linkNotAllowed") : pub.hostname ? `${to("linkClosed")} · ${to("linkNamed", pub.hostname)}` : to("linkClosed");
|
|
207
|
+
const linkAgain = unsure && !check.polled ? html`<button type="button" class="btn btn-sm s-ov-again" disabled=${busy} onClick=${async () => { setBusy(true); try { await recheckLink(check); } finally { setBusy(false); } }}>${to("checkAgain")}</button>` : null;
|
|
136
208
|
return html`<div class="s-ov" id="accessOverview">
|
|
137
209
|
<div class="s-ov-grid">
|
|
138
210
|
<section class="card s-ov-card s-ov-devices" id="ovDevices"><h3 class="s-ov-title"><${Icon} name="user" size=${18} />${to("devicesTitle")}</h3>
|
|
139
|
-
<p class="note">${to("devicesCount", rows.length)}</p>
|
|
211
|
+
<p class="note">${isFact(devices) ? to("devicesCount", rows.length) : html`<span class="s-ov-unknown">${factWord(devices)}</span>`}${devices === UNKNOWN ? again : null}</p>
|
|
140
212
|
<ul class="s-ov-devlist s-ov-list">${rows.slice(0, SHOWN).map((d) => html`<li class=${`s-ov-dev${d.current ? " current" : ""}`} key=${d.handle} data-handle=${d.handle}>
|
|
141
213
|
<div class="s-ov-dev-main"><span class="s-ov-dev-name">${d.label}${d.current ? html` <span class="tag">${t("app.thisDevice")}</span>` : null}</span>
|
|
142
214
|
<span class="s-ov-dev-meta"><span data-role=${d.tier === "admin" ? (d.verified ? "owner" : "admin") : d.tier}>${roleName(d.tier, d.verified)}</span> · ${t("app.lastActive", agoWords(d.lastSeen))}</span>
|
|
@@ -151,9 +223,14 @@ export function AccessOverview({ web = {}, hub, openTab, overPublicLink, active
|
|
|
151
223
|
<section class="card s-ov-card" id="ovEntry"><h3 class="s-ov-title"><${Icon} name="globe" size=${18} />${to("entryTitle")}</h3>
|
|
152
224
|
<dl class="s-ov-facts">
|
|
153
225
|
<${Row} label=${to("publicLink")} hint=${to("publicLinkHint")} value=${linkValue} />
|
|
154
|
-
${
|
|
155
|
-
|
|
226
|
+
${out && out.webOnly ? html`<${Row} label=${to("outside")} hint=${to("outsideHint")} value=${to(out.outside ? "allowed" : "off")} />`
|
|
227
|
+
// Unreadable: whether this fleet even has the switch is unknown — the row says so rather than vanishing.
|
|
228
|
+
: outside === UNKNOWN ? html`<${Row} label=${to("outside")} hint=${to("outsideHint")} value=${html`<span class="s-ov-unknown">${to("unknown")}</span>`} />` : null}
|
|
229
|
+
<${Row} label=${to("shares")} hint=${to("sharesHint")} value=${isFact(shares) ? (shares ? to("sharesCount", shares) : to("none")) : html`<span class="s-ov-unknown">${factWord(shares)}</span>`}
|
|
230
|
+
tone=${isFact(shares) && !shares ? "muted" : ""} />
|
|
156
231
|
</dl>
|
|
232
|
+
${shares === UNKNOWN ? html`<div class="s-ov-actions">${again}</div>` : null}
|
|
233
|
+
${linkAgain ? html`<div class="s-ov-actions">${linkAgain}</div>` : null}
|
|
157
234
|
${link && !overPublicLink ? outsideOwned
|
|
158
235
|
? html`<p class="note" id="ovOutsideOwned">${to("outsideOwned")} <${More} label=${to("goOwner")} onClick=${() => openTab("login", "outsideCard")} /></p>`
|
|
159
236
|
: html`<div class="s-ov-actions"><button type="button" class="btn btn-sm btn-danger" id="ovCloseLink" disabled=${busy} onClick=${() => setAskClose(true)}>${to("closeNow")}</button></div>` : null}
|
|
@@ -163,10 +240,12 @@ export function AccessOverview({ web = {}, hub, openTab, overPublicLink, active
|
|
|
163
240
|
<section class="card s-ov-card" id="ovTwoStep"><h3 class="s-ov-title"><${Icon} name="key" size=${18} />${to("twoStepTitle")}</h3>
|
|
164
241
|
<p class="note">${to("twoStepMine")}</p>
|
|
165
242
|
<dl class="s-ov-facts">
|
|
166
|
-
<${Row} label=${to("app")} value=${
|
|
167
|
-
|
|
243
|
+
<${Row} label=${to("app")} value=${!out ? html`<span class="s-ov-unknown">${factWord(outside)}</span>`
|
|
244
|
+
: out.enrolled ? html`<span class="tag tag-ok">${to("appSet", day(out.enrolledAt))}</span>` : html`<span class="tag">${to("appNone")}</span>`} />
|
|
245
|
+
<${Row} label=${to("askCode")} value=${!out ? html`<span class="s-ov-unknown">${factWord(outside)}</span>` : to(out.strict ? "on" : "off")} tone=${out && !out.strict ? "muted" : ""} />
|
|
168
246
|
</dl>
|
|
169
|
-
${
|
|
247
|
+
${out && !out.enrolled ? html`<p class="note">${to("twoStepNone")}</p>` : null}
|
|
248
|
+
${outside === UNKNOWN ? html`<div class="s-ov-actions">${again}</div>` : null}
|
|
170
249
|
<footer><${More} label=${to("goOwner")} onClick=${() => openTab("login", "outsideCard")} /></footer>
|
|
171
250
|
</section>
|
|
172
251
|
</div>
|
|
@@ -14,7 +14,7 @@ import { clockFormat } from "/assets/clock-text.js";
|
|
|
14
14
|
register("hubMemberAddress", {
|
|
15
15
|
en: {
|
|
16
16
|
title: "Fleet connection address",
|
|
17
|
-
lead: "Where connected Fleets reach this Hub. Most Hubs never change it; the Hub address
|
|
17
|
+
lead: "Where connected Fleets reach this Hub. Most Hubs never change it; the Hub address members use stays the same.",
|
|
18
18
|
address: "Address", listens: "Listens on", fleets: "Connected Fleets", none: "None yet",
|
|
19
19
|
change: "Change connection address", newAddress: "New connection address", newHint: "https:// is added for you. If the port isn't 443, add a colon and the port number, for example :9443.",
|
|
20
20
|
advanced: "Advanced", listenHost: "Listen on (interface)", listenPort: "Port",
|
|
@@ -41,8 +41,8 @@ register("hubMemberAddress", {
|
|
|
41
41
|
err_stale: "Something changed meanwhile (a Fleet connected, left or was revoked). Check again.",
|
|
42
42
|
err_expired: "That took too long. Check again.",
|
|
43
43
|
err_busy: "Another settings change is still in progress. Try again in a moment.",
|
|
44
|
-
err_joining: "A
|
|
45
|
-
err_joining_no_time: "A
|
|
44
|
+
err_joining: "A member's Fleet is joining this Hub right now, so the Hub address can't be changed. Try again after {0}.",
|
|
45
|
+
err_joining_no_time: "A member's Fleet is joining this Hub right now, so the Hub address can't be changed. Try again in a few minutes.",
|
|
46
46
|
err_denied: "Only this computer's own dashboard can change it. Reload this page and try again.",
|
|
47
47
|
err_unavailable: "It can't be changed right now. Reload this page and try again.",
|
|
48
48
|
err_recovery: "The change didn't finish. Reload this page to see the current address.",
|
|
@@ -50,7 +50,7 @@ register("hubMemberAddress", {
|
|
|
50
50
|
},
|
|
51
51
|
"zh-TW": {
|
|
52
52
|
title: "Fleet 連接位址",
|
|
53
|
-
lead: "已連接的 Fleet 連到這個 Hub 的位址。大多數 Hub
|
|
53
|
+
lead: "已連接的 Fleet 連到這個 Hub 的位址。大多數 Hub 不需要變更;成員使用的 Hub 位址不會改變。",
|
|
54
54
|
address: "位址", listens: "監聽於", fleets: "已連接的 Fleet", none: "目前沒有",
|
|
55
55
|
change: "變更連接位址", newAddress: "新連接位址", newHint: "會自動加上 https://。如果連接埠不是 443,請加上冒號和連接埠號碼,例如 :9443。",
|
|
56
56
|
advanced: "進階", listenHost: "監聽介面", listenPort: "連接埠",
|
|
@@ -77,8 +77,8 @@ register("hubMemberAddress", {
|
|
|
77
77
|
err_stale: "剛剛有變動(有 Fleet 連接、離開或被撤銷)。請再檢查一次。",
|
|
78
78
|
err_expired: "等候太久了,請再檢查一次。",
|
|
79
79
|
err_busy: "另一項設定變更還在進行,請稍候再試。",
|
|
80
|
-
err_joining: "
|
|
81
|
-
err_joining_no_time: "
|
|
80
|
+
err_joining: "有成員的 Fleet 正在加入這個 Hub,這段時間不能變更 Hub 位址。請在 {0} 之後再試一次。",
|
|
81
|
+
err_joining_no_time: "有成員的 Fleet 正在加入這個 Hub,這段時間不能變更 Hub 位址。請過幾分鐘再試一次。",
|
|
82
82
|
err_denied: "只有這台電腦自己的儀表板可以變更。請重新載入這個頁面後再試。",
|
|
83
83
|
err_unavailable: "目前無法變更。請重新載入這個頁面後再試。",
|
|
84
84
|
err_recovery: "變更沒有完成。請重新載入這個頁面查看目前的位址。",
|
|
@@ -13,7 +13,7 @@ import { clockFormat } from "/assets/clock-text.js";
|
|
|
13
13
|
register("hubWebAddress", {
|
|
14
14
|
en: {
|
|
15
15
|
title: "Hub address",
|
|
16
|
-
lead: "The address
|
|
16
|
+
lead: "The address members enter in AgEnD Settings → Hub and open in their browser.",
|
|
17
17
|
address: "Address", listens: "Listens on", certificate: "Certificate", expires: "expires {0}", selfSigned: "Self-signed",
|
|
18
18
|
change: "Change address", newAddress: "New address", newHint: "https:// is added for you. If the port isn't 443, add a colon and the port number, for example :8443.",
|
|
19
19
|
advanced: "Advanced", listenHost: "Listen on (interface)", listenPort: "Port",
|
|
@@ -37,8 +37,8 @@ register("hubWebAddress", {
|
|
|
37
37
|
err_stale: "The Hub's settings changed meanwhile. Check the address and try again.",
|
|
38
38
|
err_expired: "That took too long. Check again.",
|
|
39
39
|
err_busy: "Another settings change is still in progress. Try again in a moment.",
|
|
40
|
-
err_joining: "A
|
|
41
|
-
err_joining_no_time: "A
|
|
40
|
+
err_joining: "A member's Fleet is joining this Hub right now, so the Hub address can't be changed. Try again after {0}.",
|
|
41
|
+
err_joining_no_time: "A member's Fleet is joining this Hub right now, so the Hub address can't be changed. Try again in a few minutes.",
|
|
42
42
|
err_denied: "Only this computer's own dashboard can change the Hub's address. Reload this page and try again.",
|
|
43
43
|
err_unavailable: "The Hub's address can't be changed right now. Reload this page and try again.",
|
|
44
44
|
err_recovery: "The change didn't finish. Reload this page to see the Hub's current address.",
|
|
@@ -46,7 +46,7 @@ register("hubWebAddress", {
|
|
|
46
46
|
},
|
|
47
47
|
"zh-TW": {
|
|
48
48
|
title: "Hub 位址",
|
|
49
|
-
lead: "
|
|
49
|
+
lead: "成員在 AgEnD 設定 → Hub 輸入、並用瀏覽器開啟的位址。",
|
|
50
50
|
address: "位址", listens: "監聽於", certificate: "憑證", expires: "到期日 {0}", selfSigned: "自簽",
|
|
51
51
|
change: "變更位址", newAddress: "新位址", newHint: "會自動加上 https://。如果連接埠不是 443,請加上冒號和連接埠號碼,例如 :8443。",
|
|
52
52
|
advanced: "進階", listenHost: "監聽介面", listenPort: "連接埠",
|
|
@@ -70,8 +70,8 @@ register("hubWebAddress", {
|
|
|
70
70
|
err_stale: "Hub 的設定剛剛有變更。請確認位址後再試一次。",
|
|
71
71
|
err_expired: "等候太久了,請再檢查一次。",
|
|
72
72
|
err_busy: "另一項設定變更還在進行,請稍候再試。",
|
|
73
|
-
err_joining: "
|
|
74
|
-
err_joining_no_time: "
|
|
73
|
+
err_joining: "有成員的 Fleet 正在加入這個 Hub,這段時間不能變更 Hub 位址。請在 {0} 之後再試一次。",
|
|
74
|
+
err_joining_no_time: "有成員的 Fleet 正在加入這個 Hub,這段時間不能變更 Hub 位址。請過幾分鐘再試一次。",
|
|
75
75
|
err_denied: "只有這台電腦自己的儀表板可以變更 Hub 的位址。請重新載入這個頁面後再試。",
|
|
76
76
|
err_unavailable: "目前無法變更 Hub 的位址。請重新載入這個頁面後再試。",
|
|
77
77
|
err_recovery: "變更沒有完成。請重新載入這個頁面查看 Hub 目前的位址。",
|
|
@@ -27,7 +27,7 @@ const ROWS = [
|
|
|
27
27
|
// alpha.6 feedback (#2): "hub" found nothing — Settings → Hub's cards. Connect to a Hub is drawn once membership is on.
|
|
28
28
|
["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")],
|
|
29
29
|
["hub.page-sharing", "hub", "#hubShareFromHub", null, "hub_member.share_from_hub", ["hub", "share agents", "undo", "owner", "agent list"], ["Hub", "分享 Agent", "復原", "擁有者", "清單"], L("Let me share agents from the Hub page", "允許我從 Hub 頁面分享 Agent")],
|
|
30
|
-
["hub.company-address", "hub", "#hubCompanyAddress", null, null, ["hub", "company account", "company link", "sign in", "connect", "join"], ["Hub", "公司帳號", "公司連結", "登入", "連接", "加入"], L("Hub address", "Hub 位址")],
|
|
30
|
+
["hub.company-address", "hub", "#hubCompanyAddress", null, null, ["hub", "organization account", "organization link", "company account", "company link", "sign in", "connect", "join"], ["Hub", "組織帳號", "組織連結", "公司帳號", "公司連結", "登入", "連接", "加入"], L("Hub address", "Hub 位址")],
|
|
31
31
|
["hub.connect", "hub", "#hub-connect", null, null, ["hub", "connect to a hub", "pairing code", "hub address", "fingerprint", "pair", "unpair", "disconnect", "join"], ["Hub", "連線至 Hub", "配對碼", "Hub 位址", "指紋", "配對", "解除配對", "中斷連線", "加入"], L("Connect to a Hub", "連線至 Hub")],
|
|
32
32
|
["quota.notices", "notifications", "#quota-notices", null, "defaults.quota_notice", ["usage", "quota", "notifications", "remaining", "weekly"], ["用量", "額度", "提醒", "通知", "剩餘"], L("Quota notices", "用量提醒")],
|
|
33
33
|
// You · Preferences
|
|
@@ -46,3 +46,9 @@
|
|
|
46
46
|
/* S-120: a sign-out this session may not do reads as unavailable, not as a faded red: the shared muted text on the shared
|
|
47
47
|
inset surface at full opacity (its reason is the line under the device). */
|
|
48
48
|
.p-settings .s-ov-dev .btn:disabled { opacity: 1; color: var(--text-2); background: var(--surface-2); border-color: var(--border); }
|
|
49
|
+
/* M-4028: a fact the page could not read (or has not yet) says so in the muted text colour, never as "off" or "0"; its
|
|
50
|
+
card offers Check again (beside the devices count, or at the card's foot). */
|
|
51
|
+
.p-settings .s-ov-unknown { color: var(--text-3); font-style: italic; }
|
|
52
|
+
.p-settings .s-ov-again { margin-left: var(--s-2); }
|
|
53
|
+
.p-settings .s-ov-actions .s-ov-again { margin-left: 0; }
|
|
54
|
+
@media (max-width: 899px), (pointer: coarse) { .p-settings .s-ov-again { min-height: var(--tap); min-width: var(--tap); } }
|
|
@@ -699,8 +699,8 @@ const mmss = (ms) => { const s = Math.max(0, Math.ceil(ms / 1000)); return `${Ma
|
|
|
699
699
|
// #3511: the immutable diff stays in the Fleet's locale; this known line is display-only in the page's locale.
|
|
700
700
|
// Own dictionary also works when app-i18n.js was cached before the Hub connection flow shipped.
|
|
701
701
|
register("pendingHub", {
|
|
702
|
-
en: { connect: "Connect this Fleet to Hub {0} using your
|
|
703
|
-
"zh-TW": { connect: "
|
|
702
|
+
en: { connect: "Connect this Fleet to Hub {0} using your organization account. Agent sharing stays separate." },
|
|
703
|
+
"zh-TW": { connect: "以組織帳號將這個 Fleet 連接到 Hub {0}。分享 Agent 需另外選擇。" },
|
|
704
704
|
});
|
|
705
705
|
// Optional presentation only. Own namespace works with a retained app-i18n.js; no new import is required.
|
|
706
706
|
register("pendingSummary", {
|
|
@@ -727,8 +727,8 @@ register("pendingSummary", {
|
|
|
727
727
|
"hub.pageSharing.disable": "Turn off sharing from the Hub page and stop sending its agent list. Existing shares are unchanged.",
|
|
728
728
|
"hub.membership.enable": "Enable this fleet's Hub membership. Connecting and sharing an agent are separate choices.",
|
|
729
729
|
"hub.membership.disable": "Disable this fleet's Hub membership. New Hub work and answer disclosure stop; existing agent conversations remain.",
|
|
730
|
-
"hub.companyJoin.confirm": "Connect this Fleet to Hub {0} using your
|
|
731
|
-
"hub.companyJoin.repair": "Replace the saved identity of Hub {0} using the new
|
|
730
|
+
"hub.companyJoin.confirm": "Connect this Fleet to Hub {0} using your organization account. Agent sharing stays separate.",
|
|
731
|
+
"hub.companyJoin.repair": "Replace the saved identity of Hub {0} using the new organization link. This does not connect a Fleet.",
|
|
732
732
|
"general_location.confirm_host": "Run General on this host again? The Windows process must stop first. Its conversation is kept. General resumes this host’s saved conversation, or starts one if this host has none.",
|
|
733
733
|
"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.",
|
|
734
734
|
"general_location.history": "Host and Windows conversations stay separate. Switching does not copy or merge their history.",
|
|
@@ -775,8 +775,8 @@ register("pendingSummary", {
|
|
|
775
775
|
"hub.pageSharing.disable": "關閉從 Hub 頁面分享並停止傳送 Agent 清單,既有分享不變。",
|
|
776
776
|
"hub.membership.enable": "啟用這個 Fleet 的 Hub 成員功能。連接與分享 Agent 需另外選擇。",
|
|
777
777
|
"hub.membership.disable": "停用這個 Fleet 的 Hub 成員功能。停止新的 Hub 工作與回答傳送;既有 Agent 對話會保留。",
|
|
778
|
-
"hub.companyJoin.confirm": "
|
|
779
|
-
"hub.companyJoin.repair": "
|
|
778
|
+
"hub.companyJoin.confirm": "以組織帳號將這個 Fleet 連接到 Hub {0}。分享 Agent 需另外選擇。",
|
|
779
|
+
"hub.companyJoin.repair": "使用新的組織連結,更換 Hub {0} 已儲存的身分。這項操作不會連接 Fleet。",
|
|
780
780
|
"general_location.confirm_host": "要讓 General 回到這台主機執行嗎?必須先停止 Windows 程序,其對話會保留。General 會繼續這台主機儲存的對話;若主機沒有既有對話,才開啟新對話。",
|
|
781
781
|
"general_location.confirm_windows": "要讓 General 在 {0} 執行嗎?必須先停止目前的程序。聊天位置不變。主機上的對話會保留,Windows 使用自己的對話。待處理或結果不明的輸入不會送到另一段對話。",
|
|
782
782
|
"general_location.history": "主機與 Windows 各自保留對話,切換時不會複製或合併對話紀錄。",
|
|
@@ -845,7 +845,7 @@ const pendingSummaryArguments = Object.fromEntries([
|
|
|
845
845
|
["settings_confirm.summary.in_effect", "s"], ["settings_confirm.summary.inherit", "ns"], ["settings_confirm.summary.more", "n"],
|
|
846
846
|
]);
|
|
847
847
|
function legacyPendingSummaryLine(line) {
|
|
848
|
-
const known = /^(?:Connect this Fleet to Hub (.+) using your company account\. Agent sharing stays separate
|
|
848
|
+
const known = /^(?:Connect this Fleet to Hub (.+) using your (?:organization|company) account\. Agent sharing stays separate\.|以(?:組織|公司)帳號將這個 Fleet 連接到 Hub (.+)。分享 Agent 需另外選擇。)$/.exec(line); // M-4040: the old wording too (an older server)
|
|
849
849
|
return known ? t("pendingHub.connect", known[1] ?? known[2]) : line;
|
|
850
850
|
}
|
|
851
851
|
function pendingSummaryLine(line, descriptor) {
|
package/dist/ui/shared/app.css
CHANGED
|
@@ -147,13 +147,13 @@ html:has(.shell), html:has(.shell) body { overflow: hidden; }
|
|
|
147
147
|
tests/web-left-bar-2330.test.ts keeps a coloured border-left off rounded boxes. */
|
|
148
148
|
.lbar, .reply-bar, .msg-quote, .p-log .log-item.k-error, .p-log .log-item.s-failed, .org-node, .us-basis, .us-partial, .cmd-card.bad, .s-dirty,
|
|
149
149
|
.search-row.on, .search-recent-item:hover, .search-recent-item:focus-visible, .search-ctx-line.here, .tw-line:hover, .tw-line:focus-visible,
|
|
150
|
-
.u-crow:focus-visible, .p-settings .s-nav .seg-item.active, .s-find-item.on { position: relative; }
|
|
150
|
+
.u-crow:has(.u-crow-open:focus-visible), .p-settings .s-nav .seg-item.active, .s-find-item.on { position: relative; }
|
|
151
151
|
.lbar::before, .reply-bar::before, .msg-quote::before, .p-log .log-item.k-error::before, .p-log .log-item.s-failed::before, .org-node::before,
|
|
152
152
|
.us-basis::before, .us-partial::before, .cmd-card.bad::before, .s-dirty::before,
|
|
153
153
|
/* #2478 item 7 (the user's fixed template): a selected, hovered or keyboard-focused row is the straight bar and a flat
|
|
154
154
|
background at most — never a rounded fill, a curved inset edge or a rounded ring. */
|
|
155
155
|
.search-row.on::before, .search-recent-item:hover::before, .search-recent-item:focus-visible::before, .search-ctx-line.here::before,
|
|
156
|
-
.tw-line:hover::before, .tw-line:focus-visible::before, .u-crow:focus-visible::before,
|
|
156
|
+
.tw-line:hover::before, .tw-line:focus-visible::before, .u-crow:has(.u-crow-open:focus-visible)::before,
|
|
157
157
|
.p-settings .s-nav .seg-item.active::before, .s-find-item.on::before {
|
|
158
158
|
content: ""; position: absolute; left: var(--lbar-left, 0); top: var(--lbar-inset, var(--s-2)); bottom: var(--lbar-inset, var(--s-2)); width: 3px;
|
|
159
159
|
background: var(--lbar-color, var(--accent)); pointer-events: none; }
|
|
@@ -1952,6 +1952,17 @@ body.side-resizing, body.side-resizing * { cursor: col-resize !important; user-s
|
|
|
1952
1952
|
/* M-3248: "No agents on this profile" — a quiet ⓘ right of the login's name (the muted text colour, never a warning's). In the
|
|
1953
1953
|
full card it is the shared info icon (.info-tip); in a compact row only drawn (the row's name carries the words: M-3443). */
|
|
1954
1954
|
.u-profile.has-na { display: flex; align-items: center; gap: 6px; }
|
|
1955
|
+
/* M-4002: the agents' bubble (under the row, so its figures stay in view) — a title, then one line per agent: its name, and
|
|
1956
|
+
its state at the end in the secondary text colour, a running or crashed one marked by a coloured dot; "and N more"
|
|
1957
|
+
after twelve. */
|
|
1958
|
+
.u-agents-tip .info-tip-body { min-width: 12em; }
|
|
1959
|
+
.u-agents-title { display: block; margin-bottom: 2px; font-weight: var(--fw-semibold); }
|
|
1960
|
+
.u-agents-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
|
|
1961
|
+
.u-agents-name { min-width: 0; overflow-wrap: anywhere; }
|
|
1962
|
+
.u-agents-state { flex: none; color: var(--text-2); }
|
|
1963
|
+
.u-agents-state.is-running::before, .u-agents-state.is-crashed::before { content: "●"; margin-right: 4px; color: var(--ok); }
|
|
1964
|
+
.u-agents-state.is-crashed::before { color: var(--danger); }
|
|
1965
|
+
.u-agents-more { display: block; color: var(--text-3); }
|
|
1955
1966
|
.u-profile.has-na .u-profile-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
1956
1967
|
.u-na { flex: none; display: inline-grid; place-items: center; width: 18px; height: 18px; color: var(--text-3); }
|
|
1957
1968
|
.u-order { margin-left: auto; display: flex; gap: 2px; flex: none; }
|
|
@@ -2020,7 +2031,11 @@ body.side-resizing, body.side-resizing * { cursor: col-resize !important; user-s
|
|
|
2020
2031
|
/* #2478 (Prism r1): the compact rows sit in .u-cgroup, rounded and clipping (overflow: hidden) — the bar keeps clear of
|
|
2021
2032
|
its 12 px corners (4 px in, 6 px off the row's ends) and there is no full-width underline to be rounded at the ends:
|
|
2022
2033
|
the bar is the focus mark (hover has none). */
|
|
2023
|
-
.u-crow:focus-visible { outline: none; background: var(--surface-2); --lbar-left: var(--s-1); --lbar-inset: 6px; }
|
|
2034
|
+
.u-crow:has(.u-crow-open:focus-visible) { outline: none; background: var(--surface-2); --lbar-left: var(--s-1); --lbar-inset: 6px; }
|
|
2035
|
+
/* M-4002: the row's action is its name's button (its click reaches the row); drawn as the name, the row's bar its focus mark. */
|
|
2036
|
+
.u-crow-open { display: flex; flex: 0 1 auto; min-width: 0; margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit;
|
|
2037
|
+
text-align: left; cursor: pointer; }
|
|
2038
|
+
.u-crow-open:focus-visible { outline: none; }
|
|
2024
2039
|
/* The name never gives way to the plan (#2415); the reset keeps its room on the right. */
|
|
2025
2040
|
.u-crow-head { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-sm); }
|
|
2026
2041
|
.u-crow-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--fw-semibold); color: var(--text); }
|
|
@@ -2156,6 +2171,12 @@ body.side-resizing, body.side-resizing * { cursor: col-resize !important; user-s
|
|
|
2156
2171
|
font-size: var(--fs-xs); line-height: 1.5; font-weight: var(--fw-regular); text-transform: none; letter-spacing: 0; white-space: normal; text-align: left;
|
|
2157
2172
|
box-shadow: var(--shadow-2); cursor: default; }
|
|
2158
2173
|
.info-tip-body[hidden] { display: none; }
|
|
2174
|
+
/* M-4002: a bubble taller than the room on either side is bounded there and scrolls inside (info-tip.js measures it). */
|
|
2175
|
+
.info-tip-body { max-height: var(--tip-max, none); overflow-y: auto; overscroll-behavior: contain; }
|
|
2176
|
+
/* …and fades at its foot while more is below it: the cue to scroll, the same in every language (gone at the end). */
|
|
2177
|
+
.info-tip-body.is-capped::after { content: ""; position: sticky; bottom: calc(-1 * var(--s-2)); display: block; height: 28px; margin: -28px calc(-1 * var(--s-3)) calc(-1 * var(--s-2));
|
|
2178
|
+
background: linear-gradient(to bottom, transparent, var(--surface-2) 85%); pointer-events: none; }
|
|
2179
|
+
.info-tip-body.is-capped.at-end::after { display: none; }
|
|
2159
2180
|
.info-tip-body.above { top: auto; bottom: var(--tip-y); }
|
|
2160
2181
|
.s-shared .field { container-type: inline-size; }
|
|
2161
2182
|
.s-shared .field:has(.s-tipbody:not([hidden])) { position: relative; z-index: 5; }
|
|
@@ -20,8 +20,12 @@ let seq = 0;
|
|
|
20
20
|
const BUBBLE_MAX = 280;
|
|
21
21
|
const LEAVE_MS = 150;
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* `text`: the detail. `label`: the button's name ("About <what it explains>"). `cls`: a class for its place. `below`
|
|
25
|
+
* (M-4002): a selector of an ancestor the bubble opens under (or over) instead of the ⓘ itself — a usage row's, so the
|
|
26
|
+
* row's own figures stay in view while it is open.
|
|
27
|
+
*/
|
|
28
|
+
export function InfoTip({ text, label, cls = "", below = "" }) {
|
|
25
29
|
const [at, setAt] = useState(null);
|
|
26
30
|
const [pinned, setPinned] = useState(false);
|
|
27
31
|
const btn = useRef(null), bubble = useRef(null), id = useRef(null), wrap = useRef(null), leaving = useRef(null);
|
|
@@ -32,25 +36,45 @@ export function InfoTip({ text, label, cls = "" }) {
|
|
|
32
36
|
const r = mark && mark.getBoundingClientRect ? mark.getBoundingClientRect() : null;
|
|
33
37
|
const w = (typeof window !== "undefined" && window.innerWidth) || 0, h = (typeof window !== "undefined" && window.innerHeight) || 0;
|
|
34
38
|
if (!r || !w) { setAt({ x: 8, y: 8, above: false }); return; }
|
|
35
|
-
const
|
|
39
|
+
const host = below && btn.current && typeof btn.current.closest === "function" ? btn.current.closest(below) : null;
|
|
40
|
+
const v = host && host.getBoundingClientRect ? host.getBoundingClientRect() : r;
|
|
41
|
+
const above = !!h && v.bottom + 120 > h;
|
|
36
42
|
const width = Math.min(BUBBLE_MAX, w - 16);
|
|
37
|
-
setAt({ x: Math.round(Math.max(8, Math.min(r.left - 8, w - width - 8))), y: Math.round(above ? h -
|
|
43
|
+
setAt({ x: Math.round(Math.max(8, Math.min(r.left - 8, w - width - 8))), y: Math.round(above ? h - v.top + 6 : v.bottom + 6), above,
|
|
44
|
+
top: v.top, bottom: v.bottom });
|
|
38
45
|
};
|
|
39
46
|
const stay = () => { if (leaving.current) { clearTimeout(leaving.current); leaving.current = null; } };
|
|
40
47
|
const hide = () => { stay(); setAt(null); setPinned(false); };
|
|
41
48
|
useEffect(() => () => stay(), []);
|
|
42
49
|
useLayoutEffect(() => {
|
|
43
50
|
const b = bubble.current;
|
|
44
|
-
if (b
|
|
51
|
+
if (!b || !b.style || !at) return;
|
|
52
|
+
b.style.setProperty("--tip-x", `${at.x}px`); b.style.setProperty("--tip-y", `${at.y}px`);
|
|
53
|
+
if (at.max) b.style.setProperty("--tip-max", `${at.max}px`); else if (b.style.removeProperty) b.style.removeProperty("--tip-max");
|
|
54
|
+
// M-4002 (Prism on #4659): placed, its real height decides — below when it fits, else above when that fits, else the
|
|
55
|
+
// roomier side with its height bounded there (it scrolls inside; a scroll in it never closes it).
|
|
56
|
+
if (at.measured) return;
|
|
57
|
+
const tall = b.offsetHeight || 0, h = (typeof window !== "undefined" && window.innerHeight) || 0;
|
|
58
|
+
if (!tall || !h || typeof at.top !== "number") return;
|
|
59
|
+
const roomBelow = h - at.bottom - 14, roomAbove = at.top - 14;
|
|
60
|
+
const fitsBelow = tall <= roomBelow, fitsAbove = tall <= roomAbove;
|
|
61
|
+
const above = at.above ? (fitsAbove || (!fitsBelow && roomAbove >= roomBelow)) : (!fitsBelow && (fitsAbove || roomAbove > roomBelow));
|
|
62
|
+
const max = (above ? fitsAbove : fitsBelow) ? 0 : Math.max(48, Math.floor(above ? roomAbove : roomBelow));
|
|
63
|
+
setAt({ ...at, above, y: Math.round(above ? h - at.top + 6 : at.bottom + 6), max, measured: true });
|
|
45
64
|
}, [at]);
|
|
46
65
|
useEffect(() => {
|
|
47
66
|
if (!at) return undefined;
|
|
48
67
|
// Esc closes this bubble only: a dialog it sits in stays open (a native <dialog> cancels on the key's default action).
|
|
49
68
|
const esc = (e) => { if (e.key === "Escape") { e.stopPropagation(); e.preventDefault(); hide(); } };
|
|
50
69
|
const away = (e) => { if (wrap.current && !wrap.current.contains(e.target)) hide(); };
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
// A scroll elsewhere moves the ⓘ away from its bubble: close. A scroll inside a bounded bubble is reading it.
|
|
71
|
+
const scrolled = (e) => { if (!(bubble.current && e && e.target && typeof bubble.current.contains === "function" && bubble.current.contains(e.target))) hide(); };
|
|
72
|
+
document.addEventListener("keydown", esc, true); document.addEventListener("click", away); window.addEventListener("scroll", scrolled, true);
|
|
73
|
+
return () => { document.removeEventListener("keydown", esc, true); document.removeEventListener("click", away); window.removeEventListener("scroll", scrolled, true); };
|
|
53
74
|
}, [!!at]);
|
|
75
|
+
// M-4002: a bounded bubble fades at its foot while more of it is below (any language, any content); scrolled to its end,
|
|
76
|
+
// the fade goes.
|
|
77
|
+
const atEnd = (e) => { const b = e && e.currentTarget; if (b && b.classList) b.classList.toggle("at-end", b.scrollTop + b.clientHeight >= b.scrollHeight - 2); };
|
|
54
78
|
// A hover shows it unless the screen says it has none (a phone's tap also sends a mouseenter; the tap then pins it).
|
|
55
79
|
const canHover = () => typeof matchMedia !== "function" || !matchMedia("(hover: none)").matches;
|
|
56
80
|
const press = (e) => { e.stopPropagation(); e.preventDefault(); if (pinned) hide(); else { show(); setPinned(true); } };
|
|
@@ -60,5 +84,6 @@ export function InfoTip({ text, label, cls = "" }) {
|
|
|
60
84
|
return html`<span class=${`info-tip${cls ? ` ${cls}` : ""}`} ref=${wrap} onMouseEnter=${enter} onMouseLeave=${leave}><button type="button" class="info-tip-btn" ref=${btn} aria-label=${label}
|
|
61
85
|
aria-expanded=${at ? "true" : "false"} aria-describedby=${id.current}
|
|
62
86
|
onFocus=${show} onBlur=${hide} onClick=${press}><${Icon} name="info" size=${14} /></button><span
|
|
63
|
-
id=${id.current} ref=${bubble} role="tooltip" class=${`info-tip-body${at && at.above ? " above" : ""}`} hidden=${!at}
|
|
87
|
+
id=${id.current} ref=${bubble} role="tooltip" class=${`info-tip-body${at && at.above ? " above" : ""}${at && at.max ? " is-capped" : ""}`} hidden=${!at}
|
|
88
|
+
onScroll=${atEnd}>${text}</span></span>`;
|
|
64
89
|
}
|