@songsid/agend 2.4.0-beta.1 → 2.4.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-cli.js +1 -1
- package/dist/agent-token-header.d.ts +1 -1
- package/dist/agent-token-header.js +1 -1
- package/dist/backend/antigravity.js +10 -2
- package/dist/backend/antigravity.js.map +1 -1
- package/dist/backend/credential-profile.js +1 -1
- package/dist/backend/credential-profile.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/classic-channel-manager.d.ts +1 -1
- package/dist/classic-channel-manager.js +1 -1
- package/dist/daemon.d.ts +1 -1
- package/dist/daemon.js +3 -2
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-consumed-watch.d.ts +2 -0
- package/dist/delivery-consumed-watch.js +1 -1
- package/dist/delivery-consumed-watch.js.map +1 -1
- package/dist/event-log.d.ts +1 -1
- package/dist/event-log.js +1 -1
- package/dist/fleet-manager.d.ts +2 -2
- package/dist/fleet-manager.js +2 -2
- package/dist/general-knowledge/skills/credential-profiles/SKILL.md +10 -0
- package/dist/general-knowledge/skills/fleet-health/SKILL.md +10 -0
- package/dist/general-knowledge/skills/hub/SKILL.md +3 -2
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +10 -0
- package/dist/hub/http/compose.js +22 -3
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/schema.js +2 -0
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/member/room-ask.js +4 -2
- package/dist/hub/member/room-ask.js.map +1 -1
- package/dist/hub/person-prefs.d.ts +22 -0
- package/dist/hub/person-prefs.js +34 -0
- package/dist/hub/person-prefs.js.map +1 -0
- package/dist/hub/representative.js +1 -1
- package/dist/hub/representative.js.map +1 -1
- package/dist/locale.js +2 -0
- package/dist/locale.js.map +1 -1
- package/dist/transcript-needles.d.ts +4 -2
- package/dist/transcript-needles.js +35 -4
- package/dist/transcript-needles.js.map +1 -1
- package/dist/ui/hub-client.js +5 -0
- package/dist/ui/hub-room-composer.js +12 -6
- package/dist/ui/hub-room-favorites.js +63 -5
- package/dist/ui/hub-room-strings.js +1 -1
- package/dist/ui/hub-room-thread.js +5 -2
- package/dist/ui/panel-chat.js +91 -11
- package/dist/ui/panel-hub.js +3 -1
- package/dist/ui/shared/app-shell.js +55 -6
- package/dist/ui/shared/app.css +13 -0
- package/dist/ui/shared/chat-composer.js +6 -3
- package/dist/ui/shared/chat-work-bar.css +36 -0
- package/dist/ui/shared/hub-chat.css +10 -1
- package/dist/ui/shared/model-picker.css +4 -3
- package/dist/ui/shared/view-strings.js +2 -0
- package/dist/usage/i18n-keys.d.ts +1 -1
- package/dist/usage/i18n-keys.js +1 -1
- package/dist/usage/i18n-keys.js.map +1 -1
- package/dist/usage/providers.js +4 -4
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/quota-history.d.ts +1 -1
- package/dist/view-api.js +1 -1
- package/dist/view-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -61,11 +61,39 @@ function claudeAbsorbedText(value) {
|
|
|
61
61
|
export function transcriptDeltaDeliveryMarker(rawDelta, backend, deliveryId) {
|
|
62
62
|
return transcriptDeltaMarkerKind(rawDelta, backend, ENTER_MARKER(deliveryId));
|
|
63
63
|
}
|
|
64
|
+
/** AgEnD's own lead markers: a delivery's `[agend-delivery-id:…]`, a person's `[hid:…]` or `[agend-human-id:…]`. */
|
|
65
|
+
const AGEND_LEAD_MARKER = /^\[(?:agend-(?:delivery|human)-id|hid):[^\]\r\n]+\]/;
|
|
66
|
+
/**
|
|
67
|
+
* #3898: queued messages the CLI merged into ONE user entry. Claude Code re-sends a turn whose request had no answer
|
|
68
|
+
* yet with a message queued meanwhile appended (2.1.325: `…</pasted_content id="…">\n\n[hid:…]…`, one entry); Codex
|
|
69
|
+
* 0.16x submitted several queued messages as one input_text, back to back (`…)[agend-delivery-id:…]`). A later message's
|
|
70
|
+
* marker then never leads the entry. It counts only where the entry is AgEnD's own (it leads with one of AgEnD's
|
|
71
|
+
* markers) and holds this message's exact pasted text, whole — its unique marker with every byte after it — ending
|
|
72
|
+
* the entry or followed by whitespace or the next piece (`[`, `<`). A marker alone inside a body (a quote) never does.
|
|
73
|
+
*/
|
|
74
|
+
function mergedWithWire(texts, backend, marker, wire) {
|
|
75
|
+
const whole = wire.trimEnd();
|
|
76
|
+
const first = texts[0];
|
|
77
|
+
if (first === undefined || !whole.startsWith(marker))
|
|
78
|
+
return false;
|
|
79
|
+
const opened = backend === "claude-code" ? CLAUDE_PASTE_WRAPPER.exec(first) : null;
|
|
80
|
+
if (!AGEND_LEAD_MARKER.test(first.slice(opened ? opened[0].length : 0)))
|
|
81
|
+
return false;
|
|
82
|
+
return texts.some((text, block) => {
|
|
83
|
+
for (let at = text.indexOf(whole, block === 0 ? 1 : 0); at >= 0; at = text.indexOf(whole, at + 1)) {
|
|
84
|
+
const next = text.charAt(at + whole.length);
|
|
85
|
+
if (next === "" || /\s/.test(next) || next === "[" || next === "<")
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
64
91
|
/**
|
|
65
92
|
* #3030: the same reading for any unique leading marker — a delivery's `[agend-delivery-id:…]` or a person's
|
|
66
|
-
* `[hid:…] / [agend-human-id:…]` (both lead the pasted body).
|
|
93
|
+
* `[hid:…] / [agend-human-id:…]` (both lead the pasted body). With `wire` (the exact text pasted), also a message the
|
|
94
|
+
* CLI merged into one user entry with others (#3898, mergedWithWire).
|
|
67
95
|
*/
|
|
68
|
-
export function transcriptDeltaMarkerKind(rawDelta, backend, marker) {
|
|
96
|
+
export function transcriptDeltaMarkerKind(rawDelta, backend, marker, wire) {
|
|
69
97
|
let queued = false;
|
|
70
98
|
let absorbed = false;
|
|
71
99
|
for (const line of rawDelta.split(/\r?\n/)) {
|
|
@@ -73,9 +101,12 @@ export function transcriptDeltaMarkerKind(rawDelta, backend, marker) {
|
|
|
73
101
|
continue;
|
|
74
102
|
try {
|
|
75
103
|
const entry = JSON.parse(line);
|
|
76
|
-
const
|
|
104
|
+
const userTexts = userTextsFromEntry(entry, backend);
|
|
105
|
+
const firstUserText = userTexts[0];
|
|
77
106
|
if (firstUserText !== undefined && leadsWithMarker(firstUserText, backend, marker))
|
|
78
107
|
return "user";
|
|
108
|
+
if (wire !== undefined && mergedWithWire(userTexts, backend, marker, wire))
|
|
109
|
+
return "user";
|
|
79
110
|
const value = entry;
|
|
80
111
|
if (backend !== "claude-code" || !value || typeof value !== "object")
|
|
81
112
|
continue;
|
|
@@ -153,7 +184,7 @@ export function transcriptDeltaNeedle(rawDelta, backend, needle) {
|
|
|
153
184
|
if (typeof needle === "string")
|
|
154
185
|
return transcriptDeltaDeliveryMarker(rawDelta, backend, needle);
|
|
155
186
|
if ("marker" in needle)
|
|
156
|
-
return transcriptDeltaMarkerKind(rawDelta, backend, needle.marker);
|
|
187
|
+
return transcriptDeltaMarkerKind(rawDelta, backend, needle.marker, needle.wire);
|
|
157
188
|
return transcriptDeltaHasRawText(rawDelta, backend, needle.rawText) ? "user" : null;
|
|
158
189
|
}
|
|
159
190
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transcript-needles.js","sourceRoot":"","sources":["../src/transcript-needles.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,MAAM,YAAY,GAAG,CAAC,UAAkB,EAAE,EAAE,CAAC,sBAAsB,UAAU,GAAG,CAAC;AACjF,SAAS,kBAAkB,CAAC,KAAc,EAAE,OAAe;IACzD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACnD,MAAM,KAAK,GAAG,KAA4B,CAAC;IAC3C,IAAI,OAAO,KAAK,aAAa,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC9B,IAAI,KAAK,CAAC,IAAI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
|
|
361
361
|
async session() { const r = await call("GET", "/hub/v1/session"); if (r.ok) { csrf = r.signedIn ? r.csrf || null : null; codeNotices = r.signedIn === true && r.features?.includes("enrolment-code-v1") === true; roomsLive = r.signedIn === true && r.features?.includes(ROOMS_FEATURE) === true; teamsLive = r.signedIn === true && r.features?.includes(TEAMS_FEATURE) === true; } return r; },
|
|
362
362
|
async signIn(login, password) { retireReads(); teamsLive = false; const r = await call("POST", "/hub/v1/session", { login, password }); if (r.ok) { csrf = r.csrf || null; codeNotices = r.features?.includes("enrolment-code-v1") === true; roomsLive = r.features?.includes(ROOMS_FEATURE) === true; teamsLive = r.features?.includes(TEAMS_FEATURE) === true; } return r; },
|
|
363
363
|
async signOut() { retireReads(); const r = await call("DELETE", "/hub/v1/session"); csrf = null; codeNotices = false; roomsLive = false; teamsLive = false; return r; },
|
|
364
|
+
// A source captures the session CSRF: a queued write from a previous sign-in cannot use the new person's cookie.
|
|
365
|
+
personPrefs(sessionCsrf) { return sessionCsrf && sessionCsrf === csrf ? call("GET", "/hub/v1/me/prefs") : Promise.resolve(retired()); },
|
|
366
|
+
savePersonPrefs(sessionCsrf, favorites, onlyIfUnset = false) {
|
|
367
|
+
return sessionCsrf && sessionCsrf === csrf ? call("PUT", "/hub/v1/me/prefs", { favorites, onlyIfUnset }) : Promise.resolve(retired());
|
|
368
|
+
},
|
|
364
369
|
catalog() { return call("GET", "/hub/v1/exposures"); },
|
|
365
370
|
sharingPauseV1: true,
|
|
366
371
|
sharing(exposureId, revision, sharingEpoch, paused) { return call("POST", `/hub/v1/exposures/${id(exposureId)}/sharing`, { revision, sharingEpoch, paused }); },
|
|
@@ -71,8 +71,10 @@ export function refusalText(r) {
|
|
|
71
71
|
/**
|
|
72
72
|
* The composer. `store`: the room's (send); `detail`: the room GET; `reply`/`onReply`: the message being answered (the
|
|
73
73
|
* thread's Reply); `closed`: archived or no longer a member (the box says why, nothing is sent).
|
|
74
|
+
* M-3117 (for M-3125's files): `attach` is ComposerInput's own ({ title, onFiles } — the Fleet's + left of the box), `pending`
|
|
75
|
+
* the files waiting, drawn first in the box (where the 1:1 chat puts its PendingFiles). Neither given: no Attach.
|
|
74
76
|
*/
|
|
75
|
-
export function RoomComposer({ store, detail, reply = null, onReply = () => {}, closed = false, inputRef, insertRef }) {
|
|
77
|
+
export function RoomComposer({ store, detail, reply = null, onReply = () => {}, closed = false, inputRef, insertRef, attach = null, pending = null }) {
|
|
76
78
|
const [value, setValue] = useState(""), [msg, setMsg] = useState(null), [busy, setBusy] = useState(false), [pick, setPick] = useState(0);
|
|
77
79
|
const own = useRef(null), input = inputRef || own;
|
|
78
80
|
const [caret, setCaret] = useState(0);
|
|
@@ -80,6 +82,8 @@ export function RoomComposer({ store, detail, reply = null, onReply = () => {},
|
|
|
80
82
|
const palette = at && options.length ? options : null, chosen = palette ? palette[Math.min(pick, palette.length - 1)] : null;
|
|
81
83
|
const room = detail?.room || {}, group = room.kind === "group";
|
|
82
84
|
const short = useShortPlaceholder();
|
|
85
|
+
// M-3117: the Fleet chat's box takes the focus when its conversation opens (panel-chat.js Composer): a room's too.
|
|
86
|
+
useEffect(() => { if (!closed) input.current?.focus(); }, [room.id || "", closed]);
|
|
83
87
|
// 「在這裡 @ 它」 from the members panel: the mention goes into the box, after what is there.
|
|
84
88
|
if (insertRef) insertRef.current = (text) => { setValue((v) => `${v && !/\s$/.test(v) ? `${v} ` : v}${text} `); setTimeout(() => input.current?.focus(), 0); };
|
|
85
89
|
const complete = (o) => {
|
|
@@ -103,8 +107,10 @@ export function RoomComposer({ store, detail, reply = null, onReply = () => {},
|
|
|
103
107
|
};
|
|
104
108
|
const track = (v) => { setValue(v); setMsg(null); setCaret(input.current ? input.current.selectionStart ?? v.length : v.length); };
|
|
105
109
|
const paletteId = `hubMention-${room.id || "room"}`, optId = (o) => `${paletteId}-${o.key}`;
|
|
106
|
-
|
|
110
|
+
// M-3117: as the Fleet chat's dock has it — the box, then a failed send, then the line under it (its .composer-row).
|
|
111
|
+
if (closed) return html`<p class="hub-banner warn" role="status">${hroom(detail?.room?.archived ? "errArchived" : "errNotMember")}</p>`;
|
|
107
112
|
return html`<div class="composer-box hub-room-composer">
|
|
113
|
+
${pending}
|
|
108
114
|
${palette ? html`<ul data-trust="palette" class="cmd-palette" id=${paletteId} role="listbox" aria-label=${hroom("mentionAll")}>
|
|
109
115
|
${palette.map((o) => html`<li key=${o.key} id=${optId(o)} role="option" aria-selected=${o === chosen ? "true" : "false"} class=${o === chosen ? "on" : ""}
|
|
110
116
|
onMouseDown=${(e) => { e.preventDefault(); complete(o); }}>
|
|
@@ -113,11 +119,11 @@ export function RoomComposer({ store, detail, reply = null, onReply = () => {},
|
|
|
113
119
|
${group && value.includes(hroom("mentionAll")) ? html`<p class="note hub-room-allbar" role="status">${allBar(detail)}</p>` : null}
|
|
114
120
|
${reply ? html`<div class="reply-bar" data-trust="composer" role="status"><span class="reply-text">${reply.sender ? `${reply.sender} · ` : ""}${String(reply.text || "").slice(0, 80)}</span>
|
|
115
121
|
<button type="button" class="icon-btn reply-cancel" title=${hroom("cancel")} aria-label=${hroom("cancel")} onClick=${() => { onReply(null); input.current?.focus(); }}><${Icon} name="close" size=${14} /></button></div>` : null}
|
|
116
|
-
<${ComposerInput} inputRef=${input} value=${value} placeholder=${room.assistant ? hroom("composerAssistant") : group ? (short ? hroom("composerShort") : hroom("composer", room.name || "")) : hroom("composerDirect", room.name || "")} onValue=${track} onKeyDown=${onKeyDown}
|
|
122
|
+
<${ComposerInput} inputRef=${input} value=${value} attach=${attach} placeholder=${room.assistant ? hroom("composerAssistant") : group ? (short ? hroom("composerShort") : hroom("composer", room.name || "")) : hroom("composerDirect", room.name || "")} onValue=${track} onKeyDown=${onKeyDown}
|
|
117
123
|
controls=${palette ? paletteId : undefined} expanded=${!!palette} activeDescendant=${chosen ? optId(chosen) : undefined}
|
|
118
124
|
stop=${{ hidden: true, disabled: true, title: t("chat.stopReply"), label: t("chat.stopReply"), onClick: () => {} }}
|
|
119
125
|
send=${{ hidden: false, disabled: !value.trim() || busy, label: t("chat.send"), onClick: () => { void send(); } }} />
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
</div
|
|
126
|
+
</div>
|
|
127
|
+
${msg ? html`<p class="err" role="alert">${msg.text}${msg.retry ? html` <button type="button" class="btn btn-sm" onClick=${send}>${hroom("retrySend")}</button>` : null}</p>` : null}
|
|
128
|
+
${group ? html`<div class="composer-row"><span class="hint hub-room-hint">${hroom("composerHint")}</span></div>` : null}`;
|
|
123
129
|
}
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
// 「最愛」 above 「房間」 and 「Agent」 in the order they were starred (or moved in Edit), at most MAX_FAVORITES, and one that
|
|
4
4
|
// is gone from the list (left, removed) is dropped on the next change, never shown.
|
|
5
5
|
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// apart); another tab follows through the storage event. A Hub-side store replaces the source, not this module's rules.
|
|
6
|
+
// A Hub with person-prefs-v1 keeps them per directory person. This browser's old list seeds an unset Hub record once;
|
|
7
|
+
// an older Hub still uses local storage. The source changes, not the list's rules.
|
|
9
8
|
import { useEffect, useState } from "/assets/app-html.js";
|
|
10
9
|
import { createStore, useStore } from "/assets/app-store.js";
|
|
11
10
|
import { MAX_FAVORITES } from "/assets/instance-nav.js";
|
|
@@ -36,9 +35,68 @@ export const localFavoritesSource = {
|
|
|
36
35
|
};
|
|
37
36
|
|
|
38
37
|
let source = localFavoritesSource;
|
|
39
|
-
/** Tests
|
|
38
|
+
/** Tests swap where favourites are kept. */
|
|
40
39
|
export function setFavoritesSource(next) { source = next || localFavoritesSource; }
|
|
41
40
|
|
|
41
|
+
/** A session-owned cache: serialized writes, first-write migration, and refresh on focus or another tab's write. */
|
|
42
|
+
export function createHubFavoritesSource(client, session) {
|
|
43
|
+
let ids = [], ready = false, active = false, pending = null, writing = null, refreshing = null, revision = 0, edits = 0;
|
|
44
|
+
let changed = () => {};
|
|
45
|
+
const apply = (out) => {
|
|
46
|
+
if (!active || !out.ok || !Number.isSafeInteger(out.revision) || out.revision < revision) return;
|
|
47
|
+
revision = out.revision; ids = cleanIds(out.favorites); ready = true;
|
|
48
|
+
localFavoritesSource.write(session.login, ids);
|
|
49
|
+
changed();
|
|
50
|
+
};
|
|
51
|
+
const drain = () => writing ??= (async () => {
|
|
52
|
+
while (active && ready && pending) {
|
|
53
|
+
const sent = pending;
|
|
54
|
+
let out;
|
|
55
|
+
try { out = await client.savePersonPrefs(session.csrf, sent); } catch { break; }
|
|
56
|
+
if (!active || !out.ok) break; // retain the pending change for focus/the next edit
|
|
57
|
+
if (pending === sent) { pending = null; apply(out); }
|
|
58
|
+
else revision = Math.max(revision, out.revision || 0);
|
|
59
|
+
}
|
|
60
|
+
})().finally(() => { writing = null; });
|
|
61
|
+
const refresh = () => refreshing ??= (async () => {
|
|
62
|
+
await drain();
|
|
63
|
+
if (!active || pending) return;
|
|
64
|
+
const before = edits;
|
|
65
|
+
let out;
|
|
66
|
+
try {
|
|
67
|
+
out = await client.personPrefs(session.csrf);
|
|
68
|
+
if (!active || !out.ok || edits !== before) return;
|
|
69
|
+
if (!out.initialized) out = await client.savePersonPrefs(session.csrf, localFavoritesSource.read(session.login), true);
|
|
70
|
+
} catch { return; }
|
|
71
|
+
if (edits === before) apply(out);
|
|
72
|
+
})().finally(() => { refreshing = null; });
|
|
73
|
+
return {
|
|
74
|
+
ready: () => ready,
|
|
75
|
+
read: () => ids,
|
|
76
|
+
write(_login, value) { ids = cleanIds(value); pending = ids; edits++; void drain(); },
|
|
77
|
+
watch(_login, onChange) {
|
|
78
|
+
active = true; changed = onChange;
|
|
79
|
+
const unwatch = localFavoritesSource.watch(session.login, () => { void refresh(); });
|
|
80
|
+
const focus = () => { void refresh(); };
|
|
81
|
+
globalThis.addEventListener?.("focus", focus);
|
|
82
|
+
void refresh();
|
|
83
|
+
return () => { active = false; changed = () => {}; unwatch(); globalThis.removeEventListener?.("focus", focus); };
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let configuredClient, configuredCsrf;
|
|
89
|
+
/** Called by the session owner; optional from the shell so an older cached module still loads. */
|
|
90
|
+
export function configureHubFavorites(client, session) {
|
|
91
|
+
const remote = session?.features?.includes("person-prefs-v1") && typeof client.personPrefs === "function" && typeof client.savePersonPrefs === "function";
|
|
92
|
+
const csrf = remote ? session.csrf : null;
|
|
93
|
+
if (configuredClient === client && configuredCsrf === csrf) return;
|
|
94
|
+
configuredClient = client; configuredCsrf = csrf;
|
|
95
|
+
loadFavorites(null); // retire the previous person's listener and late responses
|
|
96
|
+
source = remote ? createHubFavoritesSource(client, session) : localFavoritesSource;
|
|
97
|
+
loadFavorites(session?.login);
|
|
98
|
+
}
|
|
99
|
+
|
|
42
100
|
/** { login, ids }: whose favourites are loaded, and their ids in order. */
|
|
43
101
|
export const favoritesStore = createStore({ login: null, ids: [] });
|
|
44
102
|
let unwatch = () => {};
|
|
@@ -83,7 +141,7 @@ export function useRoomStar(rooms, login) {
|
|
|
83
141
|
const fav = useStore(favoritesStore);
|
|
84
142
|
const [editing, setEditing] = useState(false);
|
|
85
143
|
useEffect(() => { loadFavorites(login); }, [login]);
|
|
86
|
-
if (!login || fav.login !== login) return null;
|
|
144
|
+
if (!login || fav.login !== login || source.ready?.(login) === false) return null;
|
|
87
145
|
const known = new Set((Array.isArray(rooms) ? rooms : []).map((r) => r && r.id).filter(Boolean));
|
|
88
146
|
return { ids: liveFavorites(known, fav.ids), editing, setEditing,
|
|
89
147
|
toggle: (id) => toggleFavorite(id, known), move: (id, delta) => moveFavorite(id, delta, known) };
|
|
@@ -159,7 +159,7 @@ register("hubRoom", {
|
|
|
159
159
|
stAssistantDown: "暫時無法回答",
|
|
160
160
|
stStopped: "已停止",
|
|
161
161
|
mentionHere: "在這裡 @ 它", chatOneToOne: "和它一對一對話", removeFromRoom: "從房間移除",
|
|
162
|
-
newRoomTitle: "新房間", name: "名稱", namePlaceholder: "
|
|
162
|
+
newRoomTitle: "新房間", name: "名稱", namePlaceholder: "例如:每週主管會議",
|
|
163
163
|
addPeople: "加入人、團隊或 AD 群組:輸入名稱搜尋",
|
|
164
164
|
addAgents: "加入自己的 Agent,或邀請別人的",
|
|
165
165
|
invitePending: "邀請 · 等擁有者同意",
|
|
@@ -277,8 +277,11 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
|
|
|
277
277
|
<${Thread} store=${store} name=${title} panelKey=${`hub-room:${roomId}`} threadRef=${threadRef} extra=${extra}
|
|
278
278
|
emptyView=${room.assistant ? html`<div class="hub-assistant-empty"><${Empty} icon="bot" title=${hroom("hubAssistant")} hint=${hroom("hubAssistantEmpty")} /></div>`
|
|
279
279
|
: group ? html`<p class="note">${hroom("composerHint")}</p>` : null} />
|
|
280
|
-
${
|
|
281
|
-
|
|
280
|
+
${/* M-3117: under the thread, the Fleet chat's dock — its column, its padding, the working line and the box in it. */ ""}
|
|
281
|
+
<div class="dock hub-dock" data-trust="composer"><div class="dock-col">
|
|
282
|
+
${working ? html`<${WorkBarView} kind="working" label=${working.text} elapsed="" elapsedTitle="" />` : null}
|
|
283
|
+
<${RoomComposer} store=${store} detail=${detail} reply=${reply} onReply=${setReply} closed=${store.closed()} inputRef=${input} insertRef=${insert} />
|
|
284
|
+
</div></div>
|
|
282
285
|
</section>
|
|
283
286
|
${showRail ? html`<${RailFrame} trust="hub-context" label=${hroom("members")} title=${hroom("members")} closeLabel=${hroom("cancel")} onClose=${() => setRail(false)}>${panel}</${RailFrame}>` : null}
|
|
284
287
|
${!wide && sheet && panel && group ? html`<${Dialog} title=${hroom("members")} label=${hroom("members")} onClose=${() => setSheet(false)}><div class="hub-rail-sheet">${panel}</div></${Dialog}>` : null}
|
package/dist/ui/panel-chat.js
CHANGED
|
@@ -11,13 +11,13 @@ import { GeneralLocation } from "./general-location.js";
|
|
|
11
11
|
import { html, Fragment, useEffect, useLayoutEffect, useRef, useState } from "/assets/app-html.js";
|
|
12
12
|
import { lang, register, t } from "/assets/app-i18n.js";
|
|
13
13
|
import { appStore, createStore, guestPage, guestTrusted, useStore } from "/assets/app-store.js";
|
|
14
|
-
import { ComposerAuth } from "/assets/web-authorize.js";
|
|
14
|
+
import { ComposerAuth, useWebAuthorization } from "/assets/web-authorize.js";
|
|
15
15
|
import { useLease } from "/assets/app-ctx.js";
|
|
16
16
|
import * as paneContext from "/assets/app-ctx.js";
|
|
17
17
|
import { backendLabel, modelText, namesOf, namesStore, navStore as instanceNavStore, supportsInstanceFeature } from "/assets/instance-nav.js";
|
|
18
18
|
import { machineName } from "/assets/machine-name.js";
|
|
19
|
-
import { PanelHeader, onPanelKey, setTitle, statusClass, statusLabel, openDrawer, requestNewInstance } from "/assets/app-shell.js";
|
|
20
|
-
import { detailsPath, textLinkSegments, sectionPath } from "/assets/app-route.js";
|
|
19
|
+
import { PanelHeader, onPanelKey, setTitle, statusClass, statusLabel, openDrawer, requestNewInstance, needsCount } from "/assets/app-shell.js";
|
|
20
|
+
import { detailsPath, textLinkSegments, sectionPath, NEEDS_PATH, fleetEntryPath, settingsPath } from "/assets/app-route.js";
|
|
21
21
|
import { InstanceSwitch } from "/assets/instance-switch.js";
|
|
22
22
|
import { HeaderTools } from "/assets/header-tools.js";
|
|
23
23
|
import { navigate, navStore } from "/assets/app-nav.js";
|
|
@@ -94,6 +94,51 @@ function CardMenu({ card, ownerKey }) {
|
|
|
94
94
|
];
|
|
95
95
|
return html`<${Menu} items=${items} label=${t("card.menu")} icon="idcard" cls="chat-card-menu" active=${prefs.open} ownerKey=${ownerKey} />`;
|
|
96
96
|
}
|
|
97
|
+
|
|
98
|
+
// M-3115 (phone v2): kept beside its caller — a retained chat dictionary has no such words.
|
|
99
|
+
register("chatPhone", {
|
|
100
|
+
en: { goTo: "Go to", thisChat: "This chat", verifiedUntil: "Verified · speaks as you until {0}", needsToast: "{0} needs you", ctxHide: "Hide this for now" },
|
|
101
|
+
"zh-TW": { goTo: "前往", thisChat: "這個對話", verifiedUntil: "已驗證 · 以你的身分發言到 {0}", needsToast: "{0} 正在等你回應", ctxHide: "這次先不提醒" },
|
|
102
|
+
});
|
|
103
|
+
const untilClock = (ms) => { try { return new Date(ms).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }); } catch { return ""; } };
|
|
104
|
+
/** A Needs-you item's identity: its nonce, else its id, else what it says. */
|
|
105
|
+
const needKey = (item) => String(item?.nonce || item?.id || JSON.stringify(item || null));
|
|
106
|
+
/**
|
|
107
|
+
* The chat's ⋯ (M-3115): on a phone, where an agent's pages have no bottom tabs, it starts with 「前往」 — Needs you (its
|
|
108
|
+
* count), Fleet, Settings — then this chat's items, and ends with 「✓ 已驗證」 (the line under the composer no longer
|
|
109
|
+
* says it). A Needs-you item that arrives meanwhile, for another agent, is a short toast. A desk's ⋯ is unchanged.
|
|
110
|
+
*/
|
|
111
|
+
function ChatMoreMenu({ items, name }) {
|
|
112
|
+
const app = useStore(appStore);
|
|
113
|
+
const auth = useWebAuthorization();
|
|
114
|
+
const seen = useRef(null);
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
// What Needs you held when last heard, and whether it had loaded then: the first load (or a reconnect's) is not news.
|
|
117
|
+
const snap = (a) => ({ keys: new Set([...(a.needs || [])].map(needKey)), loaded: a.needsLoaded === true });
|
|
118
|
+
seen.current = snap(appStore.get());
|
|
119
|
+
return appStore.subscribe((a) => {
|
|
120
|
+
const before = seen.current;
|
|
121
|
+
seen.current = snap(a);
|
|
122
|
+
if (!before?.loaded || !seen.current.loaded || !narrowScreen()) return;
|
|
123
|
+
const fresh = (a.needs || []).find((it) => !before.keys.has(needKey(it)) && it.instance && it.instance !== name);
|
|
124
|
+
if (fresh) toast(t("chatPhone.needsToast", fresh.instance));
|
|
125
|
+
});
|
|
126
|
+
}, [name]);
|
|
127
|
+
if (!narrowScreen()) return html`<${Menu} items=${items} label=${t("app.more")} />`;
|
|
128
|
+
const waiting = needsCount(app);
|
|
129
|
+
const route = navStore.get().route;
|
|
130
|
+
const verified = auth.st?.state === "verified";
|
|
131
|
+
const all = [
|
|
132
|
+
{ key: "goHead", heading: true, label: t("chatPhone.goTo") },
|
|
133
|
+
{ key: "goNeeds", label: waiting ? `${t("app.needsTab")} · ${waiting}` : t("app.needsTab"), icon: "inbox", onSelect: () => navigate(NEEDS_PATH) },
|
|
134
|
+
{ key: "goFleet", label: t("app.fleet"), icon: "fleet", onSelect: () => navigate(fleetEntryPath(route)) },
|
|
135
|
+
{ key: "goSettings", label: t("app.settings"), icon: "settings", onSelect: () => navigate(settingsPath()) },
|
|
136
|
+
{ key: "chatHead", heading: true, label: t("chatPhone.thisChat") },
|
|
137
|
+
...items,
|
|
138
|
+
...(verified ? [{ key: "verified", label: `✓ ${t("webauth.verifiedShort")}`, title: t("chatPhone.verifiedUntil", untilClock(auth.st.until)), icon: "check", disabled: true, onSelect: () => {} }] : []),
|
|
139
|
+
];
|
|
140
|
+
return html`<${Menu} items=${all} label=${t("app.more")} />`;
|
|
141
|
+
}
|
|
97
142
|
import "/assets/chat-strings.js";
|
|
98
143
|
import { confirmedWrite, selfConfirmed } from "./settings-confirm.js";
|
|
99
144
|
import { createChatStore } from "./chat-store.js";
|
|
@@ -566,7 +611,7 @@ function ChatView({ name, inst, lease, navKey, exec, awaiting }) {
|
|
|
566
611
|
<${PanelHeader} title=${inst.runtime === "windows" ? inst.display_name || name : headerName(namesOf(inst || { name }, names.primary))} sub=${sub}
|
|
567
612
|
pageControls=${{ CardMenu, card, navKey, usage: supportsInstanceFeature(inst,"usage") }} pageActions=${[
|
|
568
613
|
...items]}
|
|
569
|
-
nav=${guest ? (guestTrusted() ? html`<${InstanceSwitch} name=${name} instance=${inst} current="chat" guest=${true} />` : null) : html`<${InstanceSwitch} name=${name} instance=${inst} current="chat" />`}><${CardMenu} card=${card} /><${HeaderTools} navKey=${navKey} usage=${supportsInstanceFeature(inst,"usage")} />${guest ? null : html`<${
|
|
614
|
+
nav=${guest ? (guestTrusted() ? html`<${InstanceSwitch} name=${name} instance=${inst} current="chat" guest=${true} />` : null) : html`<${InstanceSwitch} name=${name} instance=${inst} current="chat" />`}><${CardMenu} card=${card} /><${HeaderTools} navKey=${navKey} usage=${supportsInstanceFeature(inst,"usage")} />${guest ? null : html`<${ChatMoreMenu} items=${items} name=${name} />`}</${PanelHeader}>
|
|
570
615
|
<${ChatCard} key=${name} name=${name} card=${card} />
|
|
571
616
|
<${AgentWidget} slot="chat_header" widget=${widgetFor(name, "chat_header")} binds=${instanceBinds(inst, exec, awaiting)} />
|
|
572
617
|
<div class="chat-split" ref=${split}>
|
|
@@ -832,8 +877,10 @@ function Thread({ name, label = name, th, bindings }) {
|
|
|
832
877
|
<div class="thread-host" ref=${host}></div>
|
|
833
878
|
${empty === "hidden" ? html`<${Empty} icon="chat" title=${t("chat.guestAllHidden")} hint=${t("chat.guestAllHiddenHint")} />`
|
|
834
879
|
: empty ? html`<${Empty} icon="chat" title=${t("chat.noMessages")} />` : null}
|
|
835
|
-
</div><div class="jump-dock">${jump.show ? html`<button data-trust="thread-control" type="button" class="jump-latest" onClick=${() => th.current && th.current.jumpLatest()}
|
|
836
|
-
|
|
880
|
+
</div><div class="jump-dock">${jump.show ? html`<button data-trust="thread-control" type="button" class="jump-latest" onClick=${() => th.current && th.current.jumpLatest()}
|
|
881
|
+
aria-label=${jump.unseen > 0 ? t("chat.newBelow", jump.unseen) : t("chat.jumpLatest")}>
|
|
882
|
+
<${Icon} name="down" size=${16} /><span class="jump-text">${jump.unseen > 0 ? t("chat.newBelow", jump.unseen) : t("chat.jumpLatest")}</span>${
|
|
883
|
+
/* The user (before 2.4.0-beta.3): no unread counts for now — a phone's round button has no badge. */ ""}</button>` : null}</div>
|
|
837
884
|
</${Fragment}>`;
|
|
838
885
|
}
|
|
839
886
|
|
|
@@ -922,15 +969,25 @@ function CommandCard({ name, lease }) {
|
|
|
922
969
|
}
|
|
923
970
|
|
|
924
971
|
/** #1269 quick actions: Compact and Clear… once the instance's context is 70% used (from the status it already has). */
|
|
972
|
+
/** M-3115 (phone v2): a phone's context hint put away (✕) for this agent, for this tab's session. */
|
|
973
|
+
const CTX_HINT_KEY = (name) => `agend_ctx_hint_hidden:${name}`;
|
|
974
|
+
const ctxHintHidden = (name) => { try { return sessionStorage.getItem(CTX_HINT_KEY(name)) === "1"; } catch { return false; } };
|
|
925
975
|
function QuickActions({ name, inst, lease }) {
|
|
976
|
+
const [, rerender] = useState(0);
|
|
926
977
|
const pct = inst && typeof inst.context_pct === "number" ? Math.round(inst.context_pct) : null;
|
|
927
978
|
if (pct == null || pct < 70) return null;
|
|
979
|
+
// M-3115: on a phone, one thin line in the status line's place (while the agent is idle) — the words, 壓縮 / 清空… as
|
|
980
|
+
// text, and ✕ that puts it away for this session (the ring by the box still shows the %). A desk is unchanged.
|
|
981
|
+
const line = narrowScreen() && !guestPage();
|
|
982
|
+
if (line && ctxHintHidden(name)) return null;
|
|
928
983
|
const busy = !!(store.state.commands[name] && store.state.commands[name].busy);
|
|
929
984
|
const run = (command) => store.runCommand(name, command, "", { alive: () => lease.current() });
|
|
930
|
-
|
|
985
|
+
const hide = () => { try { sessionStorage.setItem(CTX_HINT_KEY(name), "1"); } catch { /* this render only */ } rerender((n) => n + 1); };
|
|
986
|
+
return html`<div class=${`quick-actions${line ? " qa-line" : ""}`} role="group" aria-label=${t("chat.chipContext", pct)}>
|
|
931
987
|
<span class="qa-ctx">${t("chat.chipContext", pct)}</span>
|
|
932
988
|
<button type="button" class="btn btn-sm" disabled=${busy} onClick=${() => run("compact")}>${t("chat.chipCompact")}</button>
|
|
933
989
|
<button type="button" class="btn btn-sm" disabled=${busy} onClick=${() => run("clear")}>${t("chat.chipClear")}</button>
|
|
990
|
+
${line ? html`<button type="button" class="btn btn-sm qa-dismiss" title=${t("chatPhone.ctxHide")} aria-label=${t("chatPhone.ctxHide")} onClick=${hide}><${Icon} name="close" size=${12} /></button>` : null}
|
|
934
991
|
</div>`;
|
|
935
992
|
}
|
|
936
993
|
|
|
@@ -998,6 +1055,10 @@ function Composer({ name, inst, label = name, lease, busy, bindings, ids = {}, f
|
|
|
998
1055
|
const files = s.pendingFiles[name] || [];
|
|
999
1056
|
const reply = s.replies[name]; // #2272: the message this one will reply to
|
|
1000
1057
|
const content = !!value.trim() || files.length > 0;
|
|
1058
|
+
// M-3115 (phone v2): one row — the box, the context ring and the model picker beside it — and, while the agent works
|
|
1059
|
+
// with nothing typed, Send is Stop (typed: Send again, and Stop is the status line's).
|
|
1060
|
+
const phone = narrowScreen() && !guestPage();
|
|
1061
|
+
const stopNow = phone && busy && !content;
|
|
1001
1062
|
// A file waiting: what goes is a message with its file, never a command (no palette, no command line). #2855: a guest's
|
|
1002
1063
|
// palette offers only what it may run on this agent — the table's "anyone" commands (its status frame's `commands`).
|
|
1003
1064
|
const guest = guestPage();
|
|
@@ -1066,9 +1127,6 @@ function Composer({ name, inst, label = name, lease, busy, bindings, ids = {}, f
|
|
|
1066
1127
|
return html`<div class="composer-box" ref=${bindings.box}>
|
|
1067
1128
|
${machineUnavailable ? html`<p class="note runtime-machine-unavailable" role="status">${t(inst.machine_status === "revoked" ? "chat.machineRevokedHint" : "chat.machineUnavailable",machineName(inst.machine_id,inst.machine_name))}</p>` : null}
|
|
1068
1129
|
${inst?.native_busy && !busy && !inst?.native_blocked ? html`<p class="note" role="status">${t("chat.nativeBusy")}</p>` : null}
|
|
1069
|
-
${!guestPage() && supportsInstanceFeature(inst,"commands") ? html`<div class="model-entry-row" role="group" aria-label=${mw("model")}>
|
|
1070
|
-
<button type="button" class="btn btn-sm" onClick=${() => inst?.runtime === "windows" ? navigate(sectionPath("agents")) : store.runCommand(name, "backend", "", { alive: () => lease.current() })}>${backendLabel(inst?.backend)} ▾</button>
|
|
1071
|
-
<button type="button" class="btn btn-sm" onClick=${() => store.runCommand(name, "model", "", { alive: () => lease.current() })}>${modelLabel(inst?.model || modelText(inst || {}))} ▾</button></div>` : null}
|
|
1072
1130
|
${palette ? html`<ul data-trust="palette" class="cmd-palette" id=${paletteId} role="listbox" aria-label=${t("chat.cmdCommands")}>
|
|
1073
1131
|
${palette.length ? palette.map((c) => html`<li key=${c.name} id=${optId(c)} role="option" aria-selected=${c === pick ? "true" : "false"}
|
|
1074
1132
|
class=${c === pick ? "on" : ""} onMouseDown=${(e) => { e.preventDefault(); complete(c); }}>
|
|
@@ -1085,10 +1143,32 @@ function Composer({ name, inst, label = name, lease, busy, bindings, ids = {}, f
|
|
|
1085
1143
|
onKeyDown=${onKeyDown} onPaste=${onPaste} controls=${palette ? paletteId : undefined} expanded=${!!palette} activeDescendant=${pick ? optId(pick) : undefined}
|
|
1086
1144
|
attach=${attachmentsSupported ? { title: t("chat.attachTitle"), onFiles: (list) => store.addFiles(name, list) } : null}
|
|
1087
1145
|
stop=${HIDDEN_STOP}
|
|
1088
|
-
|
|
1146
|
+
tools=${phone ? html`<${ComposerTools} name=${name} inst=${inst} lease=${lease} />` : null}
|
|
1147
|
+
send=${stopNow ? { hidden: false, stop: true, disabled: !!s.cancelling[name], label: t("chat.stopReply"), title: t("chat.stopReplyTitle"), onClick: () => store.cancelReply(name) }
|
|
1148
|
+
: { hidden: false, disabled: !content || sendingBlocked, label: t("chat.send"), onClick: submit }} />
|
|
1089
1149
|
</div>`;
|
|
1090
1150
|
}
|
|
1091
1151
|
|
|
1152
|
+
/**
|
|
1153
|
+
* M-3115 (phone v2): beside the box — the context's ring (from 50%; amber from 70%: /ctx, its use, model and effort) and
|
|
1154
|
+
* one picker for the model and its effort (/model: a phone's list opens each model's efforts) that shows the model (its
|
|
1155
|
+
* name says the effort too; the row leaves the box its room). The backend stays in
|
|
1156
|
+
* Details. The ring's fill is painted through the CSSOM (no inline style attribute under the page's CSP).
|
|
1157
|
+
*/
|
|
1158
|
+
function ComposerTools({ name, inst, lease }) {
|
|
1159
|
+
const run = (command) => store.runCommand(name, command, "", { alive: () => lease.current() });
|
|
1160
|
+
const pct = inst?.context_pct == null ? null : Math.round(inst.context_pct);
|
|
1161
|
+
const effort = supportsInstanceFeature(inst, "effort") && effortChip(inst) ? effortWord(effortChip(inst)) : null;
|
|
1162
|
+
const model = modelLabel(inst?.model || modelText(inst || {}));
|
|
1163
|
+
const pickLabel = effort ? `${model} · ${effort}` : model;
|
|
1164
|
+
return html`<span class="composer-tools">
|
|
1165
|
+
${pct != null && pct >= 50 ? html`<button type="button" class=${`ctx-ring${pct >= 70 ? " warn" : ""}`} ref=${(el) => el?.style?.setProperty("--pct", String(pct))}
|
|
1166
|
+
title=${t("chat.chipContext", pct)} aria-label=${t("chat.chipContext", pct)} onClick=${() => run("ctx")}><span class="ctx-dial" aria-hidden="true"><span class="ctx-pct">${pct}</span></span></button>` : null}
|
|
1167
|
+
${supportsInstanceFeature(inst, "commands") ? html`<button type="button" class="composer-pick" title=${t("chat.chipModel", pickLabel)} aria-label=${t("chat.chipModel", pickLabel)}
|
|
1168
|
+
onClick=${() => (inst?.runtime === "windows" ? navigate(sectionPath("agents")) : run("model"))}><b>${model}</b><span class="chev" aria-hidden="true">⌄</span></button>` : null}
|
|
1169
|
+
</span>`;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1092
1172
|
function FileChip({ f, i, name, bindings }) {
|
|
1093
1173
|
const img = useRef(null);
|
|
1094
1174
|
const isImage = /^image\//.test(f.type) && typeof URL.createObjectURL === "function";
|
package/dist/ui/panel-hub.js
CHANGED
|
@@ -35,7 +35,8 @@ import { compareGroups, hubClient } from "./hub-client.js";
|
|
|
35
35
|
import { hw, linkHubCss } from "./hub-strings.js";
|
|
36
36
|
import { hc, linkHubChatCss } from "./hub-chat-strings.js";
|
|
37
37
|
import { HubRoomRows, readRoomList } from "./hub-room-list.js";
|
|
38
|
-
import
|
|
38
|
+
import * as roomFavorites from "./hub-room-favorites.js";
|
|
39
|
+
const { useRoomStar } = roomFavorites;
|
|
39
40
|
import { HubRoomPage } from "./hub-room-thread.js";
|
|
40
41
|
import { hroom } from "./hub-room-strings.js";
|
|
41
42
|
import { hr } from "./hub-read-strings.js";
|
|
@@ -102,6 +103,7 @@ const sessionSubs = new Set();
|
|
|
102
103
|
function setSession(next) {
|
|
103
104
|
const was = session;
|
|
104
105
|
session = next;
|
|
106
|
+
roomFavorites.configureHubFavorites?.(hubClient(), next);
|
|
105
107
|
// #3226 B: the conversation list is this person's: cleared when no one is signed in, read again when someone is.
|
|
106
108
|
if (!next) roomsStore.set({ loaded: false, rooms: [], error: null });
|
|
107
109
|
else if (!was || was.login !== next.login) void refreshRooms();
|
|
@@ -539,8 +539,19 @@ function PrefsPopover() {
|
|
|
539
539
|
* The header every panel shows: ☰ (phone, or a collapsed sidebar), its title and status, then its actions. `nav`
|
|
540
540
|
* (#1523 N2): an instance page's view switch — beside the title on a wide screen, a row of tabs under it on a phone.
|
|
541
541
|
*/
|
|
542
|
+
// M-3115 (phone v2): inside an agent's pages a phone has no bottom tabs; the header's first button goes back to the
|
|
543
|
+
// agents (the drawer) and carries what Needs you counts. Kept beside its caller: a retained dictionary has no such word.
|
|
544
|
+
register("phoneNav", {
|
|
545
|
+
en: { back: "Back to your agents", backCount: "Back to your agents · {0} waiting" },
|
|
546
|
+
"zh-TW": { back: "回到 Agent 清單", backCount: "回到 Agent 清單 · {0} 件待處理" },
|
|
547
|
+
});
|
|
548
|
+
/** What Needs you counts: its items and the agents' proposals (the tab's badge, the sidebar's). */
|
|
549
|
+
export function needsCount(app) { return (app.needs || []).length + (app.proposals || []).length; }
|
|
550
|
+
|
|
542
551
|
export function PanelHeader({ title, sub, children, headingRef, nav, notice, pageControls, pageActions }) {
|
|
543
552
|
const shell = useStore(shellStore);
|
|
553
|
+
const { route } = useStore(navStore), app = useStore(appStore);
|
|
554
|
+
const agent = !!openInstanceOf(route) && !guestPage(), waiting = agent ? needsCount(app) : 0;
|
|
544
555
|
const admin = useCanCreate();
|
|
545
556
|
const canCreate = admin && !!newInstanceOpener;
|
|
546
557
|
const pane = paneContext.usePane?.();
|
|
@@ -549,8 +560,10 @@ export function PanelHeader({ title, sub, children, headingRef, nav, notice, pag
|
|
|
549
560
|
if (pane?.Header) return html`<${pane.Header} title=${title} sub=${sub} headingRef=${headingRef} nav=${nav} notice=${notice}
|
|
550
561
|
pageControls=${pageControls} pageActions=${pageActions} />`;
|
|
551
562
|
return html`<header data-trust="header" class=${`panel-head${shell.collapsed ? " collapsed" : ""}`}>
|
|
552
|
-
<button type="button" id="sbOpen" class
|
|
553
|
-
aria-label=${narrow() ? t("
|
|
563
|
+
<button type="button" id="sbOpen" class=${`icon-btn sb-open${agent ? " sb-back" : ""}`} onClick=${() => (narrow() ? openDrawer() : toggleSidebar())}
|
|
564
|
+
aria-label=${narrow() ? agent ? (waiting ? t("phoneNav.backCount", waiting) : t("phoneNav.back")) : t("app.openMenu") : t("app.expand")}
|
|
565
|
+
title=${narrow() ? agent ? t("phoneNav.back") : t("app.openMenu") : t("app.expand")} aria-controls="sidebar" aria-expanded=${shell.drawer ? "true" : "false"}><${Icon} name="menu" cls="ic-menu" />${agent
|
|
566
|
+
? html`<${Icon} name="back" cls="ic-back" />${waiting ? html`<span class="sb-badge" aria-hidden="true">${waiting > 99 ? "99+" : waiting}</span>` : null}` : null}</button>
|
|
554
567
|
${canCreate && shell.collapsed ? html`<button type="button" class="icon-btn sb-new" onClick=${requestNewInstance} aria-label=${t("app.newAgent")} title=${t("app.newAgent")}><${Icon} name="plus" /></button>` : null}
|
|
555
568
|
${searchOffered(admin) ? html`<button type="button" class="icon-btn sb-search" onClick=${() => openSearch()} aria-label=${t("app.search")} title=${t("app.searchTitle", searchShortcut())}><${Icon} name="search" /></button>` : null}
|
|
556
569
|
<div class="panel-title"><h1 ref=${headingRef} tabindex="-1">${title}</h1>${sub ? html`<div class="panel-sub">${sub}</div>` : null}</div>
|
|
@@ -1215,6 +1228,35 @@ export function Shell({ panels, onNewInstance, viewOnly = false }) {
|
|
|
1215
1228
|
// in has lost focus or left the page (a composition can end without its compositionend: #2517 review).
|
|
1216
1229
|
let width = -1, tallest = 0, held = false, lowest = 0, upLowest = 0, composing = null;
|
|
1217
1230
|
const coarse = () => typeof matchMedia === "function" && matchMedia("(pointer: coarse)").matches;
|
|
1231
|
+
// M-3111 (iPhone, alpha.4): with the keyboard up, and while it rises or falls, the shell is the visible view itself —
|
|
1232
|
+
// its height and where the browser has panned it, set on the shell itself only then (its stylesheet height otherwise:
|
|
1233
|
+
// no transform the rest of the time, so nothing fixed inside it moves; a browser without dvh is untouched). The page's own height
|
|
1234
|
+
// (100dvh) is not that view then: iOS (under this page's interactive-widget=resizes-content) sized it a toolbar short of
|
|
1235
|
+
// the keyboard, so the page's background showed between the composer and the keyboard, and on the way down it stayed
|
|
1236
|
+
// short until the keyboard had gone, then snapped. Pinch-zoomed, the view is not the screen: nothing is set then.
|
|
1237
|
+
// The keyboard rises and falls over a few hundred ms, and the view's resize comes when it has settled (iOS): for that
|
|
1238
|
+
// long after a field gains or loses focus the shell follows the view every frame — both ways — instead of jumping.
|
|
1239
|
+
const FOLLOW_MS = 800;
|
|
1240
|
+
let raf = 0, followUntil = 0;
|
|
1241
|
+
const now = () => (typeof performance !== "undefined" ? performance.now() : Date.now());
|
|
1242
|
+
const frame = typeof requestAnimationFrame === "function" ? requestAnimationFrame : null;
|
|
1243
|
+
const unfit = (el) => { if (el?.style) { el.style.removeProperty("height"); el.style.removeProperty("transform"); } };
|
|
1244
|
+
const fit = () => {
|
|
1245
|
+
const el = root.current;
|
|
1246
|
+
if (!el?.style) return;
|
|
1247
|
+
const on = coarse() && (shellStore.get().keyboard || now() < followUntil) && Math.abs((Number(vv.scale) || 1) - 1) < 0.01;
|
|
1248
|
+
if (!on) { unfit(el); return; }
|
|
1249
|
+
el.style.setProperty("height", `${Math.round(vv.height)}px`);
|
|
1250
|
+
const top = Math.max(0, Math.round(Number(vv.offsetTop) || 0));
|
|
1251
|
+
if (top) el.style.setProperty("transform", `translateY(${top}px)`); else el.style.removeProperty("transform");
|
|
1252
|
+
};
|
|
1253
|
+
const follow = () => {
|
|
1254
|
+
if (!frame || !coarse()) return;
|
|
1255
|
+
followUntil = now() + FOLLOW_MS;
|
|
1256
|
+
if (raf) return;
|
|
1257
|
+
const step = () => { raf = 0; check(); if (now() < followUntil) raf = frame(step); };
|
|
1258
|
+
raf = frame(step);
|
|
1259
|
+
};
|
|
1218
1260
|
const check = () => {
|
|
1219
1261
|
if (composing && composing.isConnected !== false && document.activeElement === composing) return;
|
|
1220
1262
|
composing = null;
|
|
@@ -1234,17 +1276,22 @@ export function Shell({ panels, onNewInstance, viewOnly = false }) {
|
|
|
1234
1276
|
if (!up && was && typing && h - upLowest <= KEYBOARD_MIN_PX) up = true; // a bar's height, not the keyboard
|
|
1235
1277
|
upLowest = up ? (was ? Math.min(upLowest, h) : h) : 0;
|
|
1236
1278
|
if (up !== was) shellStore.set({ keyboard: up });
|
|
1279
|
+
fit();
|
|
1237
1280
|
};
|
|
1281
|
+
const focusChanged = () => { check(); follow(); };
|
|
1238
1282
|
const start = (e) => { composing = (e && e.target) || document.activeElement || null; };
|
|
1239
1283
|
const end = () => { composing = null; check(); };
|
|
1240
1284
|
check();
|
|
1241
1285
|
vv.addEventListener("resize", check);
|
|
1242
|
-
|
|
1243
|
-
document.addEventListener("
|
|
1286
|
+
vv.addEventListener("scroll", fit);
|
|
1287
|
+
document.addEventListener("focusin", focusChanged);
|
|
1288
|
+
document.addEventListener("focusout", focusChanged);
|
|
1244
1289
|
document.addEventListener("compositionstart", start, true);
|
|
1245
1290
|
document.addEventListener("compositionend", end, true);
|
|
1246
1291
|
return () => {
|
|
1247
|
-
vv.removeEventListener("resize", check); document.removeEventListener("focusin",
|
|
1292
|
+
vv.removeEventListener("resize", check); vv.removeEventListener("scroll", fit); document.removeEventListener("focusin", focusChanged); document.removeEventListener("focusout", focusChanged);
|
|
1293
|
+
if (raf && typeof cancelAnimationFrame === "function") cancelAnimationFrame(raf);
|
|
1294
|
+
unfit(root.current);
|
|
1248
1295
|
document.removeEventListener("compositionstart", start, true); document.removeEventListener("compositionend", end, true);
|
|
1249
1296
|
};
|
|
1250
1297
|
}, []);
|
|
@@ -1252,7 +1299,9 @@ export function Shell({ panels, onNewInstance, viewOnly = false }) {
|
|
|
1252
1299
|
// AgEnD Hub P1 (S3b): a Hub workspace has none of the fleet's lines, rails, tabs or bars (their endpoints are the fleet's).
|
|
1253
1300
|
const hub = hubMarks().hub;
|
|
1254
1301
|
const popout = shell.popout === true && !!openInstanceOf(nav.route);
|
|
1255
|
-
|
|
1302
|
+
// M-3115: an agent's own pages (its chat, View, Log, Details) — a phone shows them without the bottom tabs.
|
|
1303
|
+
const inAgent = !!openInstanceOf(nav.route) && !guest;
|
|
1304
|
+
const cls = ["shell", popout ? "chat-popout" : "", shell.collapsed ? "sb-collapsed" : "", shell.drawer ? "sb-open" : "", shell.keyboard ? "kb-open" : "", guest ? "guest" : "", inAgent ? "in-agent" : ""].filter(Boolean).join(" ");
|
|
1256
1305
|
return html`<div ref=${root} class=${cls}>
|
|
1257
1306
|
<a data-trust="navigation" class="skip" href="#main">${t("app.skip")}</a>
|
|
1258
1307
|
${popout ? null : html`<${Sidebar} route=${nav.route} onNewInstance=${onNewInstance} viewOnly=${viewOnly} />`}
|