@alexsun-top/opencode-chat-room 0.6.7 → 0.6.8
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/CHANGELOG.md +15 -0
- package/README.md +6 -3
- package/README.zh-CN.md +7 -3
- package/docs/administrator-rooms.md +7 -2
- package/package.json +4 -1
- package/plugin.ts +38 -8
- package/server/assets/base.css +228 -28
- package/server/assets/chat/admin-badge.js +28 -6
- package/server/assets/chat/admin.js +7 -1
- package/server/assets/chat/attachment-store.js +106 -0
- package/server/assets/chat/attachments.js +201 -21
- package/server/assets/chat/events.js +28 -8
- package/server/assets/chat/image-zoom.js +86 -2
- package/server/assets/chat/index.js +8 -0
- package/server/assets/chat/install-prompt.js +82 -0
- package/server/assets/chat/join-requests.js +355 -0
- package/server/assets/chat/markdown.js +54 -6
- package/server/assets/chat/members.js +4 -2
- package/server/assets/chat/message-polling.js +24 -3
- package/server/assets/chat/messages.js +6 -4
- package/server/assets/chat/questions.js +10 -6
- package/server/assets/chat/recall.js +279 -0
- package/server/assets/chat/reminders.js +52 -8
- package/server/assets/chat/replies.js +1 -1
- package/server/assets/chat/room-list.js +14 -5
- package/server/assets/chat/room-watcher.js +5 -1
- package/server/assets/chat/rooms.js +16 -4
- package/server/assets/chat/shortcuts.js +254 -0
- package/server/assets/chat/state.js +73 -14
- package/server/assets/chat/system-messages.js +3 -0
- package/server/assets/conversation.css +2 -2
- package/server/assets/keyboard-hints.css +51 -0
- package/server/assets/recall.css +29 -0
- package/server/assets/responsive.css +38 -13
- package/server/chat-server.ts +55 -66
- package/server/chat.html +146 -16
- package/server/inbox.ts +1 -1
- package/server/join-requests.ts +106 -0
- package/server/message-recall-routes.ts +37 -0
- package/server/newrooms.ts +9 -0
- package/server/room-join.ts +59 -0
- package/server/room-owner.ts +3 -20
- package/server/room-payload.ts +2 -0
- package/server/sw.js +1 -0
- package/server/wake.ts +45 -16
- package/skills/chatroom/SKILL.md +32 -0
- package/src/README.md +5 -3
- package/src/agent/admin-client.ts +28 -4
- package/src/center/center-client.ts +81 -4
- package/src/center/center-inbox.ts +35 -10
- package/src/center/center-wake.ts +25 -12
- package/src/center/message-ids.ts +7 -0
- package/src/center/notification-budget.ts +16 -0
- package/src/center/queue.ts +14 -4
- package/src/rooms/room-service.ts +10 -1
- package/src/runtime/plugin-notifications.ts +37 -11
- package/src/runtime/v2-plugin.ts +1 -1
- package/src/state/roles.ts +34 -0
- package/src/state/sqlite-state.ts +196 -27
- package/src/state/store.ts +22 -3
- package/src/tests/announcement-board.ts +9 -0
|
@@ -23,13 +23,17 @@ export async function watchRoom(roomId, app) {
|
|
|
23
23
|
if (message.createdAt >= entry.previewAt) setRoomPreview(entry, message);
|
|
24
24
|
}
|
|
25
25
|
entry.receivedTs = result.items.reduce((latest, message) => Number.isSafeInteger(message.createdAt) ? Math.max(latest, message.createdAt) : latest, previousReceivedTs);
|
|
26
|
+
const recallVersion = Number(result.recallVersion);
|
|
27
|
+
const recallVersionChanged = Number.isFinite(recallVersion) && recallVersion !== (entry.recallVersion ?? 0);
|
|
26
28
|
entry.unreadOverflow = Boolean(result.hasMore);
|
|
27
|
-
if (sawSystem || sawQuestion || result.hasMore) {
|
|
29
|
+
if (sawSystem || sawQuestion || result.hasMore || recallVersionChanged) {
|
|
28
30
|
const latest = await app.api(`/rooms/${encodeURIComponent(roomId)}`);
|
|
29
31
|
if (app.state.rooms.get(roomId) !== entry || app.state.room?.id === roomId) return;
|
|
32
|
+
if (Number.isFinite(Number(latest.recallVersion))) entry.recallVersion = Number(latest.recallVersion);
|
|
30
33
|
entry.room.participants = latest.participants;
|
|
31
34
|
entry.room.openQuestions = latest.openQuestions;
|
|
32
35
|
entry.room.messages = [...new Map([...entry.room.messages, ...latest.messages].map((message) => [message.id, message])).values()].sort((a, b) => a.createdAt - b.createdAt).slice(-LOADED_MESSAGE_LIMIT);
|
|
36
|
+
for (const message of latest.messages) if (message.recalledAt) app.applyRecall?.(roomId, { messageID: message.id, recalledAt: message.recalledAt, recalledBy: message.recalledBy });
|
|
33
37
|
const newest = latest.messages.at(-1);
|
|
34
38
|
if (newest && newest.createdAt >= entry.previewAt) setRoomPreview(entry, newest);
|
|
35
39
|
// A full refresh pages past the inbox window; count what arrived since the last look.
|
|
@@ -57,6 +57,7 @@ export function initRooms(app) {
|
|
|
57
57
|
const description = app.state.room.description || "";
|
|
58
58
|
$("#roomDescription").textContent = description;
|
|
59
59
|
$("#roomDescription").hidden = !description;
|
|
60
|
+
$("#roomPolicy").hidden = app.state.room.joinPolicy !== "approval";
|
|
60
61
|
// Everyone sees the settings entry; people who cannot manage the room get a
|
|
61
62
|
// secondary style and an explanation. Dissolving the room stays the owner's call.
|
|
62
63
|
const owner = app.state.myName === app.state.room.ownerId;
|
|
@@ -78,7 +79,7 @@ export function initRooms(app) {
|
|
|
78
79
|
|
|
79
80
|
app.ensureJoinedRoom = (room, name) => {
|
|
80
81
|
const existing = app.state.rooms.get(room.id);
|
|
81
|
-
const entry = existing || { unreadIds: new Map(), unreadOverflow: false, preview: "", previewAt: 0, position: 0, readTs: 0, receivedTs: room.messages.at(-1)?.createdAt ?? 0 };
|
|
82
|
+
const entry = existing || { unreadIds: new Map(), unreadOverflow: false, preview: "", previewAt: 0, position: 0, readTs: 0, receivedTs: room.messages.at(-1)?.createdAt ?? 0, recallVersion: 0 };
|
|
82
83
|
entry.unreadIds ||= new Map();
|
|
83
84
|
entry.unreadOverflow ||= false;
|
|
84
85
|
const latest = room.messages.at(-1), savedReadTs = app.state.lastReadTs.get(room.id) ?? (typeof room.lastReadTs === "number" ? room.lastReadTs : undefined);
|
|
@@ -104,6 +105,8 @@ export function initRooms(app) {
|
|
|
104
105
|
entry.unreadOverflow ||= Boolean(room.hasMore && entry.readTs < (room.messages[0]?.createdAt ?? Infinity));
|
|
105
106
|
}
|
|
106
107
|
entry.receivedTs ??= latest?.createdAt ?? 0;
|
|
108
|
+
entry.recallStale = Boolean(existing && (Number(room.recallVersion) || 0) > (existing.recallVersion || 0));
|
|
109
|
+
entry.recallVersion = Number(room.recallVersion) || entry.recallVersion || 0;
|
|
107
110
|
if (latest && (!existing || latest.createdAt >= entry.previewAt)) setRoomPreview(entry, latest);
|
|
108
111
|
app.state.rooms.set(room.id, entry);
|
|
109
112
|
app.state.roomNames.set(room.id, name);
|
|
@@ -140,6 +143,10 @@ export function initRooms(app) {
|
|
|
140
143
|
app.restoreReadingPosition?.(roomId);
|
|
141
144
|
app.state.readAnchorGuard = null;
|
|
142
145
|
app.startPolling();
|
|
146
|
+
if (entry.recallStale) {
|
|
147
|
+
entry.recallStale = false;
|
|
148
|
+
void app.syncLoadedHistory?.(roomId, app.state.pollGeneration);
|
|
149
|
+
}
|
|
143
150
|
app.renderMembers();
|
|
144
151
|
$("#msgInput").contentEditable = "true";
|
|
145
152
|
$("#msgInput").setAttribute("aria-disabled", "false"); $("#msgInput").tabIndex = 0;
|
|
@@ -173,13 +180,15 @@ export function initRooms(app) {
|
|
|
173
180
|
});
|
|
174
181
|
invalidateRoomList();
|
|
175
182
|
LS.name = name;
|
|
183
|
+
if (room?.status === "pending") { app.showJoinPending(roomId, name); return; }
|
|
176
184
|
app.enterRoom(room, name, intent);
|
|
177
185
|
} catch (error) {
|
|
178
186
|
if (error.status === 401) {
|
|
179
187
|
app.state.pendingAction = { type: "join", roomId, name };
|
|
180
188
|
if (app.state.room) { app.openChatSettings(); app.showSendError("sendAuth"); }
|
|
181
189
|
else { app.openTokenBox(); app.showJoinError("authRetry"); }
|
|
182
|
-
} else
|
|
190
|
+
} else if (error.status === 409) { app.showJoinError("joinNameTaken"); void app.refreshRoomList(); }
|
|
191
|
+
else { app.showJoinError(error.network ? "networkRetry" : "joinFailed", { message: error.message }); void app.refreshRoomList(); }
|
|
183
192
|
} finally { app.setJoinBusy(false); }
|
|
184
193
|
};
|
|
185
194
|
|
|
@@ -187,6 +196,7 @@ export function initRooms(app) {
|
|
|
187
196
|
const fromChat = pending?.fromChat ?? Boolean(app.state.room);
|
|
188
197
|
const name = pending?.name || (fromChat ? app.state.myName : $("#inName").value.trim()) || LS.name || app.t("guest");
|
|
189
198
|
const roomName = pending?.roomName || $(fromChat ? "#inRoomNameChat" : "#inRoomName").value.trim();
|
|
199
|
+
const joinPolicy = pending?.joinPolicy ?? ((fromChat ? $("#inApprovalRequiredChat").checked : $("#inApprovalRequired").checked) ? "approval" : "open");
|
|
190
200
|
if (!roomName) return fromChat ? app.showSendError("roomNameRequired") : app.showJoinError("roomNameRequired");
|
|
191
201
|
const intent = ++app.state.navigationGeneration; invalidateRoomList();
|
|
192
202
|
app.setJoinBusy(true);
|
|
@@ -196,10 +206,12 @@ export function initRooms(app) {
|
|
|
196
206
|
try {
|
|
197
207
|
const room = await app.api("/rooms", {
|
|
198
208
|
method: "POST",
|
|
199
|
-
body: JSON.stringify({ name: roomName, ownerId: name, sessionID: LS.sessionID }),
|
|
209
|
+
body: JSON.stringify({ name: roomName, ownerId: name, sessionID: LS.sessionID, joinPolicy }),
|
|
200
210
|
});
|
|
201
211
|
invalidateRoomList();
|
|
202
212
|
LS.name = name;
|
|
213
|
+
$("#inApprovalRequired").checked = false;
|
|
214
|
+
$("#inApprovalRequiredChat").checked = false;
|
|
203
215
|
if (fromChat) {
|
|
204
216
|
$("#inRoomNameChat").value = "";
|
|
205
217
|
$("#railRoomForm").hidden = true;
|
|
@@ -207,7 +219,7 @@ export function initRooms(app) {
|
|
|
207
219
|
app.enterRoom(room, name, intent);
|
|
208
220
|
} catch (error) {
|
|
209
221
|
if (error.status === 401) {
|
|
210
|
-
app.state.pendingAction = { type: "create", name, roomName, fromChat };
|
|
222
|
+
app.state.pendingAction = { type: "create", name, roomName, fromChat, joinPolicy };
|
|
211
223
|
if (fromChat) { app.openChatSettings(); app.showSendError("sendAuth"); }
|
|
212
224
|
else { app.openTokenBox(); app.showJoinError("authRetry"); }
|
|
213
225
|
} else if (fromChat) { app.showSendError("sendFailed", { message: error.message }); void app.refreshRoomList(); }
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
// Keyboard tags label every visible control with the keys that reach and use
|
|
2
|
+
// it. Generic controls say Tab then Enter/Space; only real shortcuts get a
|
|
3
|
+
// dedicated badge. Tags start on and follow scrolling; the '?' trigger opens
|
|
4
|
+
// the full shortcut sheet, and the legend can turn the tags off.
|
|
5
|
+
const FOCUSABLE = [
|
|
6
|
+
"a[href]", "button", "input:not([type='hidden'])", "select", "textarea", "summary",
|
|
7
|
+
"[contenteditable='true']", "[role='button']", "[role='link']", "[role='switch']",
|
|
8
|
+
"[role='checkbox']", "[role='radio']", "[role='tab']", "[role='menuitem']",
|
|
9
|
+
"[tabindex]:not([tabindex='-1'])",
|
|
10
|
+
].join(",");
|
|
11
|
+
|
|
12
|
+
export function initShortcuts(app) {
|
|
13
|
+
const dialog = app.$("#shortcutsDialog"), heading = app.$("#shortcutsHeading");
|
|
14
|
+
const overlay = app.$("#keyboardHints"), marks = app.$("#keyboardHintMarks"), legend = overlay?.querySelector(".keys-legend");
|
|
15
|
+
if (!dialog || !overlay || !marks || !legend) return;
|
|
16
|
+
const triggers = [...document.querySelectorAll("[data-shortcuts]")];
|
|
17
|
+
const sheetToggle = app.$("#btnToggleHints");
|
|
18
|
+
let active = false, badges = [], frame = 0, observer = null, controller = null;
|
|
19
|
+
|
|
20
|
+
const syncSheetToggle = () => {
|
|
21
|
+
if (sheetToggle) app.setText(sheetToggle, active ? "hintsHide" : "hintsShow");
|
|
22
|
+
};
|
|
23
|
+
const syncLegendVisibility = () => {
|
|
24
|
+
const next = Boolean(document.querySelector("#roomRail.drawer-open, .panel:not([hidden]), #readerPanel:not([hidden])"));
|
|
25
|
+
if (legend.hidden !== next) legend.hidden = next;
|
|
26
|
+
};
|
|
27
|
+
const syncVisibility = () => {
|
|
28
|
+
overlay.hidden = !active || Boolean(document.querySelector("dialog[open]"));
|
|
29
|
+
syncLegendVisibility();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const openSheet = () => {
|
|
33
|
+
if (dialog.open || document.querySelector("dialog[open]")) return;
|
|
34
|
+
app.closePanels?.();
|
|
35
|
+
app.closeMention?.();
|
|
36
|
+
dialog.showModal();
|
|
37
|
+
heading.focus();
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const realKeys = (node) => {
|
|
41
|
+
if (node.matches("#roomListChat .room-row.joined[data-room-id]")
|
|
42
|
+
&& innerWidth > 760 && document.querySelectorAll("#roomListChat .room-row.joined").length > 1) return ["↑", "↓"];
|
|
43
|
+
if (node.id === "msgInput" || node.matches("#msgList img[tabindex], #attachmentList img[tabindex], .chat-resource img[tabindex]")) return ["Enter"];
|
|
44
|
+
if (node.id === "btnCloseReaders") return ["Esc"];
|
|
45
|
+
return null;
|
|
46
|
+
};
|
|
47
|
+
const genericLabel = (node) => {
|
|
48
|
+
const switchKey = node.matches("input[type='checkbox'], input[type='radio'], [role='switch'], [role='checkbox'], [role='radio']") ? "Space" : "↵";
|
|
49
|
+
return node.getBoundingClientRect().width < 60 ? (switchKey === "Space" ? "Tab Space" : "Tab↵") : `Tab › ${switchKey}`;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const badgeFor = (node) => {
|
|
53
|
+
const real = realKeys(node);
|
|
54
|
+
const badge = document.createElement("span");
|
|
55
|
+
badge.className = real ? "keys-badge is-real" : "keys-badge is-generic";
|
|
56
|
+
if (node.id) badge.dataset.hintTarget = node.id;
|
|
57
|
+
if (!real) {
|
|
58
|
+
badge.textContent = genericLabel(node);
|
|
59
|
+
return badge;
|
|
60
|
+
}
|
|
61
|
+
real.forEach((key, index) => {
|
|
62
|
+
const separator = document.createElement("span");
|
|
63
|
+
if (index) { separator.className = "keys-badge-sep"; separator.textContent = "›"; badge.append(separator); }
|
|
64
|
+
const cap = document.createElement("kbd");
|
|
65
|
+
cap.className = "keys-key";
|
|
66
|
+
cap.textContent = key;
|
|
67
|
+
badge.append(cap);
|
|
68
|
+
});
|
|
69
|
+
return badge;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const usable = (node) => {
|
|
73
|
+
// The trigger already shows its own "?", and overlay chrome is not a target.
|
|
74
|
+
if (node.closest("#keyboardHints, #shortcutsDialog, [inert], [hidden], [data-shortcuts]")) return false;
|
|
75
|
+
if (node.id === "roomDrawerBackdrop" || node.tabIndex < 0) return false;
|
|
76
|
+
if (node.matches(":disabled, [aria-disabled='true']")) return false;
|
|
77
|
+
const rect = node.getBoundingClientRect();
|
|
78
|
+
if (rect.width < 2 || rect.height < 2) return false;
|
|
79
|
+
if (node.checkVisibility && !node.checkVisibility({ checkVisibilityCSS: true })) return false;
|
|
80
|
+
// Collect off-screen controls too: scrolling then only moves existing badges.
|
|
81
|
+
const onScreen = rect.bottom > 0 && rect.top < innerHeight && rect.right > 0 && rect.left < innerWidth;
|
|
82
|
+
if (!onScreen) return true;
|
|
83
|
+
const left = Math.max(rect.left, 0), top = Math.max(rect.top, 0);
|
|
84
|
+
const right = Math.min(rect.right, innerWidth), bottom = Math.min(rect.bottom, innerHeight);
|
|
85
|
+
if (right - left < 2 || bottom - top < 2) return false;
|
|
86
|
+
const hit = document.elementFromPoint((left + right) / 2, (top + bottom) / 2);
|
|
87
|
+
return Boolean(hit) && (hit === node || node.contains(hit));
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const overlaps = (a, b) => a.left < b.right && a.right > b.left && a.top < b.bottom && a.bottom > b.top;
|
|
91
|
+
|
|
92
|
+
const textRect = (element) => {
|
|
93
|
+
const range = document.createRange();
|
|
94
|
+
range.selectNodeContents(element);
|
|
95
|
+
const rect = range.getBoundingClientRect();
|
|
96
|
+
return rect.width > 0 && rect.height > 0 ? rect : null;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const textObstacles = () => {
|
|
100
|
+
const rects = [];
|
|
101
|
+
const skip = new Set(["SCRIPT", "STYLE", "SVG", "TEXTAREA", "SELECT"]);
|
|
102
|
+
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, {
|
|
103
|
+
acceptNode(node) {
|
|
104
|
+
if (!node.nodeValue?.trim()) return NodeFilter.FILTER_REJECT;
|
|
105
|
+
const parent = node.parentElement;
|
|
106
|
+
if (!parent || skip.has(parent.tagName) || parent.closest("#keyboardHints")) return NodeFilter.FILTER_REJECT;
|
|
107
|
+
if (parent.checkVisibility && !parent.checkVisibility({ checkVisibilityCSS: true })) return NodeFilter.FILTER_REJECT;
|
|
108
|
+
return NodeFilter.FILTER_ACCEPT;
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
112
|
+
const range = document.createRange();
|
|
113
|
+
range.selectNodeContents(node);
|
|
114
|
+
for (const rect of range.getClientRects()) {
|
|
115
|
+
if (rect.width > 0 && rect.height > 0 && rect.right > 0 && rect.left < innerWidth && rect.bottom > 0 && rect.top < innerHeight) rects.push(rect);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// The legend covers content too, so tags keep clear of it.
|
|
119
|
+
if (!legend.hidden) rects.push(legend.getBoundingClientRect());
|
|
120
|
+
return rects;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const place = () => {
|
|
124
|
+
if (!active) return;
|
|
125
|
+
syncLegendVisibility();
|
|
126
|
+
const obstacles = textObstacles();
|
|
127
|
+
const occupied = [];
|
|
128
|
+
const boxes = [];
|
|
129
|
+
const modal = document.querySelector("#roomRail.drawer-open, .panel:not([hidden]), #readerPanel:not([hidden])");
|
|
130
|
+
for (const { node, badge } of badges) {
|
|
131
|
+
const box = node.getBoundingClientRect();
|
|
132
|
+
if (box.width > 0 && box.height > 0) boxes.push([node, box]);
|
|
133
|
+
}
|
|
134
|
+
for (const { node, badge } of badges) {
|
|
135
|
+
if (!node.isConnected) { badge.remove(); continue; }
|
|
136
|
+
if (modal && !modal.contains(node)) { badge.hidden = true; continue; }
|
|
137
|
+
const rect = node.getBoundingClientRect();
|
|
138
|
+
if (rect.bottom <= 0 || rect.top >= innerHeight || rect.right <= 0 || rect.left >= innerWidth) { badge.hidden = true; continue; }
|
|
139
|
+
const leftEdge = Math.max(rect.left, 0), topEdge = Math.max(rect.top, 0);
|
|
140
|
+
const rightEdge = Math.min(rect.right, innerWidth), bottomEdge = Math.min(rect.bottom, innerHeight);
|
|
141
|
+
const hit = rightEdge - leftEdge > 1 && bottomEdge - topEdge > 1
|
|
142
|
+
? document.elementFromPoint((leftEdge + rightEdge) / 2, (topEdge + bottomEdge) / 2) : null;
|
|
143
|
+
if (!hit || !(hit === node || node.contains(hit))) { badge.hidden = true; continue; }
|
|
144
|
+
const width = badge.offsetWidth, height = badge.offsetHeight;
|
|
145
|
+
const centerY = rect.top + (rect.height - height) / 2;
|
|
146
|
+
const switchLike = node.matches("input[type='checkbox'], input[type='radio'], [role='switch'], [role='checkbox'], [role='radio']");
|
|
147
|
+
const candidates = [];
|
|
148
|
+
// A tag never covers label text: outside the control first, then a free
|
|
149
|
+
// inside corner, and hidden when neither fits.
|
|
150
|
+
if (switchLike) {
|
|
151
|
+
const label = node.labels?.[0] || node.closest(".join-policy")?.querySelector(".join-policy-label");
|
|
152
|
+
const labelText = label ? textRect(label) : null;
|
|
153
|
+
if (labelText) candidates.push([labelText.right + 8, centerY], [labelText.left, labelText.bottom + 4]);
|
|
154
|
+
candidates.push([rect.left - width - 4, centerY], [rect.right + 4, centerY],
|
|
155
|
+
[rect.right - width, rect.top - height - 4], [rect.right - width, rect.bottom + 4]);
|
|
156
|
+
} else {
|
|
157
|
+
candidates.push([rect.right - width, rect.top - height - 3], [rect.right - width, rect.bottom + 3],
|
|
158
|
+
[rect.right + 4, centerY], [rect.left - width - 4, centerY],
|
|
159
|
+
[rect.left, rect.top - height - 3], [rect.left, rect.bottom + 3],
|
|
160
|
+
[rect.right - width - 2, rect.bottom - height - 2], [rect.left + 2, rect.bottom - height - 2]);
|
|
161
|
+
}
|
|
162
|
+
let chosen = null;
|
|
163
|
+
for (const [left, top] of candidates) {
|
|
164
|
+
const box = { left, top, right: left + width, bottom: top + height };
|
|
165
|
+
if (left < 4 || top < 4 || box.right > innerWidth - 4 || box.bottom > innerHeight - 4) continue;
|
|
166
|
+
if (obstacles.some((other) => overlaps(box, other))) continue;
|
|
167
|
+
if (boxes.some(([other, otherBox]) => other !== node && !other.contains(node) && !node.contains(other) && overlaps(box, otherBox))) continue;
|
|
168
|
+
if (occupied.some((other) => overlaps(box, other))) continue;
|
|
169
|
+
chosen = box; break;
|
|
170
|
+
}
|
|
171
|
+
if (!chosen) { badge.hidden = true; continue; }
|
|
172
|
+
badge.hidden = false;
|
|
173
|
+
badge.style.left = `${Math.round(chosen.left)}px`;
|
|
174
|
+
badge.style.top = `${Math.round(chosen.top)}px`;
|
|
175
|
+
occupied.push(chosen);
|
|
176
|
+
}
|
|
177
|
+
const composer = [...document.querySelectorAll("#chatView .composer")].find((node) => node.offsetParent !== null);
|
|
178
|
+
const bottom = composer ? innerHeight - composer.getBoundingClientRect().top + 10 : 18;
|
|
179
|
+
legend.style.bottom = `${Math.max(12, Math.min(bottom, innerHeight - 90))}px`;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const collect = () => {
|
|
183
|
+
if (!active) return;
|
|
184
|
+
marks.textContent = "";
|
|
185
|
+
badges = [];
|
|
186
|
+
for (const node of document.querySelectorAll(FOCUSABLE)) {
|
|
187
|
+
if (!usable(node)) continue;
|
|
188
|
+
const badge = badgeFor(node);
|
|
189
|
+
marks.append(badge);
|
|
190
|
+
badges.push({ node, badge });
|
|
191
|
+
}
|
|
192
|
+
place();
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const schedule = (task) => {
|
|
196
|
+
if (!active || frame) return;
|
|
197
|
+
frame = requestAnimationFrame(() => { frame = 0; task(); });
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const setActive = (next) => {
|
|
201
|
+
active = next;
|
|
202
|
+
syncSheetToggle();
|
|
203
|
+
syncVisibility();
|
|
204
|
+
if (!active) {
|
|
205
|
+
controller?.abort(); controller = null;
|
|
206
|
+
observer?.disconnect(); observer = null;
|
|
207
|
+
cancelAnimationFrame(frame); frame = 0;
|
|
208
|
+
marks.textContent = "";
|
|
209
|
+
badges = [];
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
controller = new AbortController();
|
|
213
|
+
const { signal } = controller;
|
|
214
|
+
addEventListener("resize", () => schedule(place), { signal });
|
|
215
|
+
addEventListener("scroll", () => schedule(place), { capture: true, signal });
|
|
216
|
+
addEventListener("click", () => schedule(place), { capture: true, signal });
|
|
217
|
+
// View entrance animations move every control; collect once they settle.
|
|
218
|
+
addEventListener("animationend", (event) => {
|
|
219
|
+
if (event.target === app.$("#joinView") || event.target === app.$("#chatView")) schedule(collect);
|
|
220
|
+
}, { capture: true, signal });
|
|
221
|
+
window.visualViewport?.addEventListener("resize", () => schedule(place), { signal });
|
|
222
|
+
window.visualViewport?.addEventListener("scroll", () => schedule(place), { signal });
|
|
223
|
+
observer = new MutationObserver((records) => {
|
|
224
|
+
if (records.some((record) => record.target instanceof Element && record.target.matches("dialog") && record.attributeName === "open")) syncVisibility();
|
|
225
|
+
syncLegendVisibility();
|
|
226
|
+
if (records.some((record) => !(record.target instanceof Element) || !record.target.closest("#keyboardHints"))) schedule(collect);
|
|
227
|
+
});
|
|
228
|
+
observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ["hidden", "disabled", "aria-disabled", "aria-hidden", "inert", "open"] });
|
|
229
|
+
collect();
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
const enable = () => { app.LS.keyHintsOff = false; setActive(true); };
|
|
233
|
+
const disable = () => { app.LS.keyHintsOff = true; setActive(false); };
|
|
234
|
+
|
|
235
|
+
triggers.forEach((button) => button.addEventListener("click", () => openSheet()));
|
|
236
|
+
app.$("#btnAllShortcuts")?.addEventListener("click", () => openSheet());
|
|
237
|
+
app.$("#btnToggleHints")?.addEventListener("click", () => (active ? disable() : enable()));
|
|
238
|
+
app.$("#btnCloseHints")?.addEventListener("click", () => {
|
|
239
|
+
disable();
|
|
240
|
+
triggers.find((button) => button.offsetParent !== null)?.focus({ preventScroll: true });
|
|
241
|
+
});
|
|
242
|
+
app.$("#btnCloseShortcuts")?.addEventListener("click", () => dialog.close());
|
|
243
|
+
dialog.addEventListener("close", () => requestAnimationFrame(() => app.focusComposer?.()));
|
|
244
|
+
document.addEventListener("keydown", (event) => {
|
|
245
|
+
if (event.defaultPrevented || event.isComposing || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
246
|
+
if (event.key !== "?" && event.key !== "?") return;
|
|
247
|
+
const target = event.target;
|
|
248
|
+
if (target instanceof Element && target.closest("input, textarea, select, [contenteditable='true']")) return;
|
|
249
|
+
if (document.querySelector("dialog[open]")) return;
|
|
250
|
+
event.preventDefault();
|
|
251
|
+
openSheet();
|
|
252
|
+
});
|
|
253
|
+
if (app.LS.keyHintsOff) syncSheetToggle(); else setActive(true);
|
|
254
|
+
}
|
|
@@ -137,6 +137,7 @@ export function createAuth(storage, fetcher, translate = (key) => key, sessionSt
|
|
|
137
137
|
set name(value) { ensureIdentity(); browserIdentity.name = String(value ?? "").slice(0, 64); writeSession("chat.name", browserIdentity.name || null); saveIdentity(); },
|
|
138
138
|
get token() { return read("chat.token") || ""; }, set token(value) { write("chat.token", value || null); },
|
|
139
139
|
get locale() { return read("chat.locale") || "en"; }, set locale(value) { write("chat.locale", value || null); },
|
|
140
|
+
get keyHintsOff() { return read("chat.keyHintsOff") === "1"; }, set keyHintsOff(value) { write("chat.keyHintsOff", value ? "1" : null); },
|
|
140
141
|
get joinedRoomIds() {
|
|
141
142
|
try {
|
|
142
143
|
const ids = JSON.parse(readSession("chat.joinedRoomIds") || "[]");
|
|
@@ -207,12 +208,26 @@ const messages = {
|
|
|
207
208
|
or: "or", newRoomNameLabel: "New room name", newRoomNamePlaceholder: "e.g. Weekend movie night",
|
|
208
209
|
createRoom: "Create room", joinRoomTitle: "Join a room", joinRoomHint: "Someone shared a room ID with you? Paste it here.",
|
|
209
210
|
createRoomTitle: "Create a room", createRoomHint: "Start a new room and invite people with its ID.",
|
|
211
|
+
requireApproval: "Require approval to join", requireApprovalHint: "New members need a human administrator's approval. Agents may also be approved by the administrator agent.",
|
|
212
|
+
joinPolicyEditHint: "New members need a human administrator's approval. Turning this off clears all pending requests.", joinPolicyOpenConfirm: "Turn off approval? All pending join requests will be cleared.",
|
|
213
|
+
approvalRequired: "Approval required", joinRequired: "Approval required", joinPendingStatus: "Approval pending",
|
|
214
|
+
joinPendingTitle: "Waiting for approval", joinPendingBody: ({ name }) => `Your request to join “${name}” was sent. A human administrator must approve it before you can join.`,
|
|
215
|
+
joinPendingHint: "You can leave this page; the request stays pending. Check the room list later.", joinPendingNotice: ({ name }) => `Request sent to join “${name}”. Waiting for a human administrator.`, joinPendingCheck: "Check again", joinPendingStop: "Stop waiting",
|
|
216
|
+
joinPendingGoneTitle: "Request not pending", joinPendingGoneBody: "It may have been denied or cleared. You can send a new request.", joinPendingAgain: "Request again",
|
|
217
|
+
joinPendingError: "Could not check the request. Try again.", joinPendingRoomGone: "This room is gone, or you no longer have access.",
|
|
218
|
+
joinNameTaken: "That name is already used in this room. Choose another name.",
|
|
219
|
+
joinRequestsTitle: "Join requests", joinRequestsHint: "Agent requests can also be approved by the administrator agent.", joinRequestsEmpty: "No pending requests.",
|
|
220
|
+
joinRequestsLoadFailed: "Could not load join requests.", joinRequestAlreadyHandled: "This request was already handled.", joinRequestApprove: "Approve", joinRequestDeny: "Deny", joinRequestAgent: "Agent", joinRequestHuman: "Human",
|
|
221
|
+
joinRequestApproveLabel: ({ name }) => `Approve ${name}`, joinRequestDenyLabel: ({ name }) => `Deny ${name}`,
|
|
222
|
+
joinRequestTime: ({ time }) => `Requested ${time}`, joinRequestApproved: ({ name }) => `${name} approved.`, joinRequestDenied: ({ name }) => `${name} denied.`,
|
|
223
|
+
joinRequestActionFailed: ({ message }) => `Could not update the request: ${message}`, membersWithRequests: ({ count }) => `Members, ${count} join request${count === 1 ? "" : "s"} pending`,
|
|
224
|
+
joinRequestBadgeOne: " request", joinRequestBadgeMany: " requests",
|
|
210
225
|
accessKeyTitle: "Access key", accessKeyHint: "This server asks for an access key. It stays in this browser and is sent with each request.",
|
|
211
226
|
tokenOptional: "Access token (optional)", bearerToken: "Bearer token",
|
|
212
227
|
tokenPlaceholder: "Enter if the server requires it", save: "Save",
|
|
213
228
|
tokenHint: "If the server requires an access token (401), all requests will include it.",
|
|
214
229
|
existingRooms: "Rooms", noRooms: "No rooms yet. Create one.", copyRoomId: "Copy room ID", loadingHistory: "Loading earlier messages",
|
|
215
|
-
editRoom: "Edit room", roomOwnerOnlyTitle: "Owner or administrator only", roomOwnerOnlyNote: ({ owner }) => `Only the room owner or a room administrator can change these settings. This room belongs to ${owner}.`, roomNameLabel: "Room name", roomDescriptionLabel: "Description", adminAgentLabel: "Administrator agent",
|
|
230
|
+
editRoom: "Edit room", roomOwnerOnlyTitle: "Owner or administrator only", roomOwnerOnlyNote: ({ owner }) => `Only the room owner or a room administrator can change these settings. This room belongs to ${owner}.`, roomNameLabel: "Room name", roomDescriptionLabel: "Description", adminAgentLabel: "Administrator agent", roomOwnerBadge: "Owner", roomAdminBadge: "Admin",
|
|
216
231
|
adminIdsLabel: "Human administrators", adminIdsHint: "These members can edit room details, manage members, delete files, and choose a successor. The owner always has the same powers.", adminIdsEmpty: "No other members are in this room yet.", newOwnerLabel: "New owner", newOwnerHint: "Hand the room to another person who is in it. Only the owner can do this; agents cannot own a room.",
|
|
217
232
|
successorLabel: "Successor if the owner leaves", successorNone: "Longest-present member", successorHint: "If the owner leaves, this person becomes owner. If an administrator leaves, this person takes that role. Leave empty to use the longest-present member.", ownerOnlySettingsNote: "Only the owner can change the administrator agent or hand off the room.", adminAgentHint: "The designated agent can use the admin tool to inspect this room and its history. Only the owner can change this; leave empty for none.",
|
|
218
233
|
noAdminAgent: "None", roomNameRequired: "Room name is required", openQuestions: ({ count }) => `${count} unanswered question${count === 1 ? "" : "s"}`,
|
|
@@ -226,9 +241,10 @@ const messages = {
|
|
|
226
241
|
reminderText: "Reminder text", reminderTemplateHint: "Use {{time}}, {{initiator}}, and {{room}} in your message.", reminderCreate: "Create reminder",
|
|
227
242
|
reminderLoading: "Loading reminders…", reminderEmpty: "No reminders yet.", reminderPaused: "Paused", reminderNext: ({ time }) => `Next: ${time}`,
|
|
228
243
|
reminderPause: "Pause", reminderResume: "Resume", reminderDelete: "Delete", reminderDeleteConfirm: "Delete this reminder?",
|
|
244
|
+
reminderEdit: "Edit", reminderEditHeading: "Edit reminder", reminderSave: "Save changes",
|
|
229
245
|
reminderCreated: "Reminder created.", reminderUpdated: "Reminder updated.", reminderDeleted: "Reminder deleted.",
|
|
230
246
|
reminderInvalid: "Check the date, 5-field CRON expression, IANA timezone, and reminder text.", reminderLoadFailed: "Could not load reminders. Your draft is still here.",
|
|
231
|
-
diagramLoading: "Rendering diagram…", diagramRenderFailed: "Diagram unavailable; showing its source.", resourceLoading: "Loading file…", resourceFailed: "This file could not be loaded.", resourceDownload: "Download", resourcePreview: "Preview", resourceHide: "Hide preview", zoomImage: "Open image", imagePreviewTitle: "Image preview",
|
|
247
|
+
diagramLoading: "Rendering diagram…", diagramRenderFailed: "Diagram unavailable; showing its source.", resourceLoading: "Loading file…", resourceFailed: "This file could not be loaded.", resourceDownload: "Download", resourceMoreActions: "More actions for {name}", resourcePreview: "Preview", resourceHide: "Hide preview", zoomImage: "Open image", imagePreviewTitle: "Image preview", imageZoomControls: "Image zoom", zoomIn: "Zoom in", zoomOut: "Zoom out", zoomReset: "Reset zoom", installTitle: "Install OC Chat", installBody: "Add it to your home screen for a full-screen chat.", installAction: "Install", installHow: "How to install", installNotNow: "Not now", installIosGuide: "Tap Share, then Add to Home Screen.",
|
|
232
248
|
announcementDelete: "Delete announcement",
|
|
233
249
|
announcementNew: "New announcement", announcementEmpty: "No announcements yet.", announcementLoading: "Loading announcements…",
|
|
234
250
|
announcementLoadFailed: "Could not load announcements. Your draft is still here.", announcementSaved: "Announcement saved.", announcementDeleted: "Announcement deleted.",
|
|
@@ -236,7 +252,7 @@ const messages = {
|
|
|
236
252
|
questionsLoading: "Loading questions…", questionsEmpty: "No unanswered questions.",
|
|
237
253
|
questionsFailed: "Could not load questions. Try again.", questionsUnsupported: "Unanswered questions are unavailable on this server.", questionLabel: "Question",
|
|
238
254
|
answerQuestion: "Reply", answerPlaceholder: "Write a reply…", sendAnswer: "Send reply", selectQuestion: "Reply to question", copyQuestion: "Copy question", questionCopied: "Question copied.", questionCopyFailed: "Could not copy question.",
|
|
239
|
-
answerFailed: "Reply failed. Your draft is still here.", answerTooLong: "Reply must be
|
|
255
|
+
answerFailed: "Reply failed. Your draft is still here.", answerTooLong: "Reply must be 5,000 characters or fewer.", questionAlreadyAnswered: "This question was answered elsewhere.",
|
|
240
256
|
adminBindingGuide: "Choose a room and an Agent in it. Send the invitation privately to finish setup.", adminRoomLabel: "Administrator room", adminDesignateAgent: "Invite Agent",
|
|
241
257
|
settings: "Settings", adminAccess: "Administration", adminToken: "Administration token", openAdministration: "Open administration", administration: "Administration", designations: "Designations", adminRoom: "Administrator room", targetRoom: "Agent membership room", adminScopeNote: "Choose an Agent in the administrator room. Administrators can manage all rooms.", targetAgent: "Registered agent", designate: "Designate administrator", revokeDesignation: "Revoke designation", globalStatus: "Global status", adminTasks: "Tasks", taskText: "Task", dispatchTask: "Dispatch task", timers: "Timers", planName: "Timer name", createTimer: "Create timer", tokenRequired: "The server requires an access token (401).",
|
|
242
258
|
adminLoading: "Loading administration…", refreshAdmin: "Refresh", adminRoomBadge: "admin", chooseAdminRoom: "Choose a normal room", chooseTargetRoom: "Choose an agent room", chooseAgent: "Choose a registered agent", taskTargetRoom: "Target room", taskTargetAgent: "Target agent", createAdminRoomFirst: "Create a normal room first, then select it as the admin room.", noAgents: "No registered agents", selectAdminAgent: "Choose an admin room and registered agent.", adminDesignated: "Administrator designation is active immediately and stays until you revoke it.", revokeConfirm: "Revoke this admin designation? The normal room will remain.", updateTask: "Update task", task_pending: "Pending", task_working: "Working", task_blocked: "Blocked", task_completed: "Completed", task_cancelled: "Cancelled", nextRun: ({ time, minutes }) => `Every ${minutes} min · next ${time}`, paused: "Paused", pauseTimer: "Pause", resumeTimer: "Resume", deleteTimer: "Delete", deleteTimerConfirm: ({ name }) => `Delete timer “${name}”?`,
|
|
@@ -244,8 +260,8 @@ const messages = {
|
|
|
244
260
|
noMessages: "No messages yet. Say something.", latestMessages: "Back to latest messages",
|
|
245
261
|
mentionMembers: "Choose a member to mention", messagePlaceholder: "Message · Enter to send",
|
|
246
262
|
attachments: "Attachments", addFiles: "Add files", dropFilesHere: "Drop files here to attach",
|
|
247
|
-
attachmentVolatile: "
|
|
248
|
-
uploadQueued: "Waiting to upload", uploadReady: "Ready to send", uploadPercent: ({ percent }) => `Uploading ${percent}%`,
|
|
263
|
+
attachmentVolatile: "Pasted files are recovered after reload; picked files stay in this tab.", attachmentNotPersisted: "This file is too large to save for reload. Keep this tab open until it is sent.", retryUpload: "Retry", removeFile: "Remove",
|
|
264
|
+
uploadQueued: "Waiting to upload", uploadReady: "Ready to send", sendAsFileFailed: "Upload failed. Your text is still in the composer.", uploadPercent: ({ percent }) => `Uploading ${percent}%`,
|
|
249
265
|
uploadFailed: ({ reason } = {}) => reason ? `Upload failed (${reason}). Retry or remove the file.` : "Upload failed. Retry or remove the file.",
|
|
250
266
|
fileUnreadable: "This file cannot be read: it may be a temporary file from another app, or still in the cloud. Save it to disk (or take a screenshot) and attach that.",
|
|
251
267
|
fileTooLarge: "File exceeds the server's current size limit.",
|
|
@@ -253,10 +269,22 @@ const messages = {
|
|
|
253
269
|
joinArrow: "Join →", joinDirectTitle: "Click to join directly", mentionEmpty: "No matching members",
|
|
254
270
|
joined: "Joined", joinAction: "Join room", unreadMessages: ({ count }) => `${count} unread`,
|
|
255
271
|
mentionHint: "↑↓ Select · Enter to confirm · Esc to close", today: "Today", yesterday: "Yesterday",
|
|
272
|
+
keyboardHints: "Keyboard hints", shortcutsLabel: "Key hints",
|
|
273
|
+
shortcutsTitle: "Keyboard shortcuts", shortcutsLead: "Every control works from the keyboard. Tags show the keys that work.",
|
|
274
|
+
hintsLegend: "Tab reaches · Enter / Space activates",
|
|
275
|
+
allShortcuts: "All shortcuts", hintsHide: "Hide tags on controls", hintsShow: "Show tags on controls",
|
|
276
|
+
shortcutsWriting: "Writing", shortcutsSend: "Send the message", shortcutsNewline: "Start a new line",
|
|
277
|
+
shortcutsMention: "Choose a member to mention", shortcutsRooms: "Rooms",
|
|
278
|
+
shortcutsSwitchRoom: "Switch to the previous or next room", shortcutsReading: "Reading",
|
|
279
|
+
shortcutsScroll: "Scroll messages while typing", shortcutsMenus: "Menus and dialogs",
|
|
280
|
+
shortcutsClose: "Close the open menu, panel, or dialog", shortcutsEverywhere: "Everywhere",
|
|
281
|
+
shortcutsTab: "Move between controls", shortcutsActivate: "Use the focused control",
|
|
282
|
+
shortcutsOpen: "Open this shortcut list", switchRoomsHint: "Switch rooms",
|
|
256
283
|
earlierMessages: "Earlier messages omitted", messagesBetweenOmitted: "Messages between this reading point and latest are omitted.", you: "You", saved: "Saved",
|
|
257
284
|
savedMemory: "Saved for this tab only", copyFailed: ({ id }) => `Copy failed. Copy manually: ${id}`,
|
|
258
285
|
copyMessage: "Copy", copiedMessage: "Copied", copyMessageFailed: "Could not copy. Select and copy the message manually.",
|
|
259
|
-
replyMessage: "Reply", replyingTo: "Replying to", cancelReply: "Cancel reply", replyOpenOriginal: "View original message", replyOriginalUnavailable: "Original message is unavailable.",
|
|
286
|
+
replyMessage: "Reply", replyingTo: "Replying to", cancelReply: "Cancel reply", replyOpenOriginal: "View original message", replyOriginalUnavailable: "Original message is unavailable.", replyOriginalRecalled: "Original message was recalled.",
|
|
287
|
+
recallMessage: "Recall", recallSystemMessage: "Recall this room notice", recallSystemConfirm: "Recall this room notice? Everyone will see it as recalled.", recallConfirm: "Recall this message? Everyone will see it as recalled.", recallAdminConfirm: ({ name }) => `Recall ${name}'s message? Everyone will see it as recalled.`, recallFailed: "Could not recall this message.", messageRecalled: "Message recalled", recalledBy: ({ name }) => `Recalled by ${name}`, showRecalled: "View original", hideRecalled: "Hide original", revealFailed: "Load failed. Retry",
|
|
260
288
|
identityChanged: "This browser identity changed in another tab. Reload this tab before continuing.",
|
|
261
289
|
networkError: "Network connection failed", requestFailed: ({ status }) => `Request failed (HTTP ${status})`,
|
|
262
290
|
roomIdRequired: "Enter a room ID", nameRequired: "Enter your name", authRetry: "The server requires an access token. Enter it and try again.",
|
|
@@ -274,7 +302,9 @@ const messages = {
|
|
|
274
302
|
direct: "Direct", messagePrivately: "Message privately", removeMember: "Remove",
|
|
275
303
|
kickConfirm: ({ name }) => `Remove ${name} from this room? They can rejoin with the room ID.`,
|
|
276
304
|
deleteRoom: "Delete room", deleteConfirm: ({ name }) => `Delete “${name}” and all its messages? This cannot be undone.`,
|
|
277
|
-
allMembers: "Everyone", messageCount: ({ count }) => `${count} /
|
|
305
|
+
allMembers: "Everyone", messageCount: ({ count }) => `${count} / 5000`,
|
|
306
|
+
pasteAsFile: ({ count }) => `Pasted ${count} characters saved as a text file`,
|
|
307
|
+
sendAsFile: ({ count }) => `${count} characters exceed the limit; sending as a text file`,
|
|
278
308
|
privacyNote: "Anyone with the shared token can read direct messages and manage rooms; the server can read them too.",
|
|
279
309
|
resourceDelete: "Delete file", resourceDeleting: "Deleting…", resourceDeleteConfirm: ({ name }) => `Delete “${name}”? This cannot be undone.`, resourceDeleted: "File deleted.", resourceDeleteFailed: "Could not delete this file.",
|
|
280
310
|
systemJoined: ({ name }) => `${name} joined the room`, systemLeft: ({ name }) => `${name} left the room`, systemRemoved: ({ name }) => `${name} was removed from the room`,
|
|
@@ -293,11 +323,25 @@ const messages = {
|
|
|
293
323
|
newRoomNamePlaceholder: "例如:周末电影夜", createRoom: "创建新房间", tokenOptional: "访问令牌(可选)",
|
|
294
324
|
joinRoomTitle: "加入房间", joinRoomHint: "有人把房间 ID 分享给你?粘贴到这里。",
|
|
295
325
|
createRoomTitle: "创建房间", createRoomHint: "新建一个房间,再把房间 ID 发给别人。",
|
|
326
|
+
requireApproval: "加入需要审核", requireApprovalHint: "新成员需经人类管理员审核;Agent 也可以由管理员 Agent 审核。",
|
|
327
|
+
joinPolicyEditHint: "新成员需经人类管理员审核。关闭后,所有待审核申请都会被清除。", joinPolicyOpenConfirm: "关闭加入审核?所有待审核的加入申请都会被清除。",
|
|
328
|
+
approvalRequired: "需审核加入", joinRequired: "需审核加入", joinPendingStatus: "等待审核",
|
|
329
|
+
joinPendingTitle: "等待审核", joinPendingBody: ({ name }) => `加入“${name}”的申请已发送,需人类管理员审核通过后才能进入。`,
|
|
330
|
+
joinPendingHint: "可以离开此页面,申请会保留;稍后可在房间列表查看。", joinPendingNotice: ({ name }) => `已发送加入“${name}”的申请,正在等待人类管理员审核。`, joinPendingCheck: "再看一次", joinPendingStop: "不再等待",
|
|
331
|
+
joinPendingGoneTitle: "申请已不在等待", joinPendingGoneBody: "申请可能已被拒绝或清除,可以重新发送。", joinPendingAgain: "重新申请",
|
|
332
|
+
joinPendingError: "无法检查申请状态,请重试。", joinPendingRoomGone: "房间不存在,或你已无权访问。",
|
|
333
|
+
joinNameTaken: "这个昵称已被房间里的成员使用,请换一个。",
|
|
334
|
+
joinRequestsTitle: "加入申请", joinRequestsHint: "Agent 的申请也可以由管理员 Agent 审核。", joinRequestsEmpty: "暂无待审核申请。",
|
|
335
|
+
joinRequestsLoadFailed: "无法加载加入申请。", joinRequestAlreadyHandled: "这个申请已经被处理过了。", joinRequestApprove: "通过", joinRequestDeny: "拒绝", joinRequestAgent: "Agent", joinRequestHuman: "人类",
|
|
336
|
+
joinRequestApproveLabel: ({ name }) => `通过 ${name} 的加入申请`, joinRequestDenyLabel: ({ name }) => `拒绝 ${name} 的加入申请`,
|
|
337
|
+
joinRequestTime: ({ time }) => `申请于 ${time}`, joinRequestApproved: ({ name }) => `已通过 ${name} 的申请。`, joinRequestDenied: ({ name }) => `已拒绝 ${name} 的申请。`,
|
|
338
|
+
joinRequestActionFailed: ({ message }) => `操作失败:${message}`, membersWithRequests: ({ count }) => `成员,${count} 个待审核加入申请`,
|
|
339
|
+
joinRequestBadgeOne: " 个申请", joinRequestBadgeMany: " 个申请",
|
|
296
340
|
accessKeyTitle: "访问密钥", accessKeyHint: "这个服务器需要访问密钥。密钥保存在当前浏览器里,并随每个请求发送。",
|
|
297
341
|
bearerToken: "Bearer Token", tokenPlaceholder: "服务器要求时填写", save: "保存",
|
|
298
342
|
tokenHint: "若服务器设置了访问令牌(401),所有请求都会带上它。", existingRooms: "房间",
|
|
299
343
|
noRooms: "还没有房间,创建一个吧。", copyRoomId: "复制房间 ID", loadingHistory: "正在加载更早的消息",
|
|
300
|
-
editRoom: "编辑房间", roomOwnerOnlyTitle: "仅房主或管理员可修改", roomOwnerOnlyNote: ({ owner }) => `只有房主或房间管理员可以修改这些设置。这个房间属于 ${owner}。`, roomNameLabel: "房间名称", roomDescriptionLabel: "描述", adminAgentLabel: "管理员 Agent",
|
|
344
|
+
editRoom: "编辑房间", roomOwnerOnlyTitle: "仅房主或管理员可修改", roomOwnerOnlyNote: ({ owner }) => `只有房主或房间管理员可以修改这些设置。这个房间属于 ${owner}。`, roomNameLabel: "房间名称", roomDescriptionLabel: "描述", adminAgentLabel: "管理员 Agent", roomOwnerBadge: "房主", roomAdminBadge: "管理员",
|
|
301
345
|
adminIdsLabel: "成员管理员", adminIdsHint: "这些成员可以修改房间信息、管理成员、删除文件并指定接任者。房主始终拥有这些权限。", adminIdsEmpty: "房间里暂无其他成员。", newOwnerLabel: "新房主", newOwnerHint: "可以把房间交给房间里的另一个人。只有房主可以操作;Agent 不能成为房主。",
|
|
302
346
|
successorLabel: "房主离开后的接任者", successorNone: "最早加入的成员", successorHint: "房主离开后,此人接任房主;管理员离开后,此人接任管理员。留空则最早加入的成员接任房主。", ownerOnlySettingsNote: "只有房主可以更改管理员 Agent 或移交房间。", adminAgentHint: "被指定的 Agent 可用 admin 工具查看此房间及其历史。只有房主可以更改,留空表示不指定。",
|
|
303
347
|
noAdminAgent: "不指定", roomNameRequired: "房间名称不能为空", openQuestions: ({ count }) => `${count} 个待回答的问题`,
|
|
@@ -311,9 +355,10 @@ const messages = {
|
|
|
311
355
|
reminderText: "提醒内容", reminderTemplateHint: "可使用 {{time}}、{{initiator}} 和 {{room}}。", reminderCreate: "创建提醒",
|
|
312
356
|
reminderLoading: "正在加载提醒…", reminderEmpty: "暂无提醒。", reminderPaused: "已暂停", reminderNext: ({ time }) => `下次:${time}`,
|
|
313
357
|
reminderPause: "暂停", reminderResume: "恢复", reminderDelete: "删除", reminderDeleteConfirm: "确定删除此提醒?",
|
|
358
|
+
reminderEdit: "编辑", reminderEditHeading: "编辑提醒", reminderSave: "保存修改",
|
|
314
359
|
reminderCreated: "提醒已创建。", reminderUpdated: "提醒已更新。", reminderDeleted: "提醒已删除。",
|
|
315
360
|
reminderInvalid: "请检查日期、5 字段 CRON 表达式、IANA 时区和提醒内容。", reminderLoadFailed: "无法加载提醒,草稿仍已保留。",
|
|
316
|
-
diagramLoading: "正在渲染图表…", diagramRenderFailed: "图表无法显示,以下为源代码。", resourceLoading: "正在加载文件…", resourceFailed: "无法加载此文件。", resourceDownload: "下载", resourcePreview: "预览", resourceHide: "收起预览", zoomImage: "查看大图", imagePreviewTitle: "图片预览",
|
|
361
|
+
diagramLoading: "正在渲染图表…", diagramRenderFailed: "图表无法显示,以下为源代码。", resourceLoading: "正在加载文件…", resourceFailed: "无法加载此文件。", resourceDownload: "下载", resourceMoreActions: "{name} 的更多操作", resourcePreview: "预览", resourceHide: "收起预览", zoomImage: "查看大图", imagePreviewTitle: "图片预览", imageZoomControls: "图片缩放", zoomIn: "放大", zoomOut: "缩小", zoomReset: "重置缩放", installTitle: "安装 OC Chat", installBody: "添加到主屏幕,获得全屏聊天体验。", installAction: "安装", installHow: "如何安装", installNotNow: "暂不", installIosGuide: "点击共享按钮,然后选择“添加到主屏幕”。",
|
|
317
362
|
announcementDelete: "删除公告",
|
|
318
363
|
announcementNew: "新建公告", announcementEmpty: "暂无公告。", announcementLoading: "正在加载公告…",
|
|
319
364
|
announcementLoadFailed: "无法加载公告,草稿仍已保留。", announcementSaved: "公告已保存。", announcementDeleted: "公告已删除。",
|
|
@@ -321,7 +366,7 @@ const messages = {
|
|
|
321
366
|
questionsLoading: "正在加载问题…", questionsEmpty: "没有待回答的问题。",
|
|
322
367
|
questionsFailed: "无法加载问题,请重试。", questionsUnsupported: "此服务器不支持查看待回答问题。", questionLabel: "问题",
|
|
323
368
|
answerQuestion: "回复", answerPlaceholder: "写下回复…", sendAnswer: "发送回复", selectQuestion: "回复此问题", copyQuestion: "复制问题", questionCopied: "问题已复制。", questionCopyFailed: "无法复制问题。",
|
|
324
|
-
answerFailed: "回复失败,草稿仍已保留。", answerTooLong: "回复不能超过
|
|
369
|
+
answerFailed: "回复失败,草稿仍已保留。", answerTooLong: "回复不能超过 5,000 个字符。", questionAlreadyAnswered: "此问题已由其他人回答。",
|
|
325
370
|
adminBindingGuide: "选择管理员房间和其中的 Agent,再将邀请私下发送给该 Agent 完成设置。", adminRoomLabel: "管理员房间", adminDesignateAgent: "邀请 Agent",
|
|
326
371
|
adminAccess: "管理", adminToken: "管理令牌", openAdministration: "打开管理面板", administration: "管理面板", designations: "管理绑定", adminRoom: "管理员房间", targetRoom: "Agent 所属房间", adminScopeNote: "请选择管理员房间内的 Agent。管理员可以管理所有房间。", adminRoomBadge: "管理", targetAgent: "已注册 Agent", designate: "指定管理员", revokeDesignation: "撤销绑定", globalStatus: "全局状态", adminTasks: "任务", taskText: "任务内容", dispatchTask: "派发任务", timers: "定时任务", planName: "定时任务名称", createTimer: "创建定时任务",
|
|
327
372
|
adminLoading: "正在加载管理面板…", refreshAdmin: "刷新", adminRoomBadge: "管理", chooseAdminRoom: "选择普通房间", chooseTargetRoom: "选择 Agent 房间", chooseAgent: "选择已注册 Agent", taskTargetRoom: "任务目标房间", taskTargetAgent: "任务目标 Agent", createAdminRoomFirst: "请先按普通流程创建房间,再选作管理房间。", noAgents: "没有已注册的 Agent", selectAdminAgent: "请选择管理房间和已注册的 Agent。", adminDesignated: "管理员已立即生效,长期有效,直到撤销。", revokeConfirm: "撤销此管理绑定?普通房间会保留。", updateTask: "更新任务", task_pending: "待处理", task_working: "进行中", task_blocked: "受阻", task_completed: "已完成", task_cancelled: "已取消", nextRun: ({ time, minutes }) => `每 ${minutes} 分钟 · 下次 ${time}`, paused: "已暂停", pauseTimer: "暂停", resumeTimer: "恢复", deleteTimer: "删除", deleteTimerConfirm: ({ name }) => `删除定时任务“${name}”?`,
|
|
@@ -329,18 +374,30 @@ const messages = {
|
|
|
329
374
|
messageList: "消息列表", noMessages: "还没有消息,说点什么吧。", latestMessages: "回到最新消息",
|
|
330
375
|
mentionMembers: "选择要提及的成员", messagePlaceholder: "输入消息,Enter 发送",
|
|
331
376
|
attachments: "附件", addFiles: "添加文件", dropFilesHere: "将文件拖到这里添加",
|
|
332
|
-
attachmentVolatile: "
|
|
333
|
-
uploadQueued: "等待上传", uploadReady: "可以发送", uploadPercent: ({ percent }) => `正在上传 ${percent}%`,
|
|
377
|
+
attachmentVolatile: "粘贴的文件刷新后可恢复;文件选择器添加的文件仅在当前标签页有效。", attachmentNotPersisted: "文件过大,无法在刷新后恢复。发送完成前请保持此标签页打开。", retryUpload: "重试", removeFile: "移除",
|
|
378
|
+
uploadQueued: "等待上传", uploadReady: "可以发送", sendAsFileFailed: "上传失败,文字仍在输入框中。", uploadPercent: ({ percent }) => `正在上传 ${percent}%`,
|
|
334
379
|
uploadFailed: ({ reason } = {}) => reason ? `上传失败(${reason}),请重试或移除文件。` : "上传失败,请重试或移除文件。",
|
|
335
380
|
fileUnreadable: "这个文件读不出来:它可能是其他 App 的临时文件,或者还在云端。请先保存到本地(或截图)再发送。",
|
|
336
381
|
fileTooLarge: "文件超过服务器当前大小限制。",
|
|
337
382
|
send: "发送", roomMeta: ({ members, count }) => `${members} 人 · ${count} 条消息`, joinArrow: "加入 →",
|
|
338
383
|
joinDirectTitle: "点击直接加入", mentionEmpty: "没有匹配的成员", mentionHint: "↑↓ 选择 · Enter 确认 · Esc 关闭",
|
|
384
|
+
keyboardHints: "键盘提示", shortcutsLabel: "按键提示",
|
|
385
|
+
shortcutsTitle: "键盘快捷键", shortcutsLead: "所有控件都可以用键盘操作,标签显示可用的按键。",
|
|
386
|
+
hintsLegend: "Tab 定位 · Enter 或空格使用",
|
|
387
|
+
allShortcuts: "全部快捷键", hintsHide: "隐藏控件提示", hintsShow: "显示控件提示",
|
|
388
|
+
shortcutsWriting: "输入", shortcutsSend: "发送消息", shortcutsNewline: "换行",
|
|
389
|
+
shortcutsMention: "选择要提及的成员", shortcutsRooms: "房间",
|
|
390
|
+
shortcutsSwitchRoom: "切换到上一个或下一个房间", shortcutsReading: "阅读",
|
|
391
|
+
shortcutsScroll: "输入时滚动消息", shortcutsMenus: "菜单和对话框",
|
|
392
|
+
shortcutsClose: "关闭当前菜单、面板或对话框", shortcutsEverywhere: "通用",
|
|
393
|
+
shortcutsTab: "在控件之间移动", shortcutsActivate: "使用当前聚焦的控件",
|
|
394
|
+
shortcutsOpen: "打开这个快捷键列表", switchRoomsHint: "切换房间",
|
|
339
395
|
joined: "已加入", joinAction: "加入房间", unreadMessages: ({ count }) => `${count} 条未读`,
|
|
340
396
|
today: "今天", yesterday: "昨天", earlierMessages: "更早的消息已省略", messagesBetweenOmitted: "此阅读位置与最新消息之间的部分消息已省略。", you: "我", saved: "已保存",
|
|
341
397
|
savedMemory: "仅保存于当前标签页", copyFailed: ({ id }) => `复制失败,请手动复制:${id}`,
|
|
342
398
|
copyMessage: "复制", copiedMessage: "已复制", copyMessageFailed: "复制失败,请手动选择并复制消息。",
|
|
343
|
-
replyMessage: "回复", replyingTo: "回复给", cancelReply: "取消回复", replyOpenOriginal: "查看原始消息", replyOriginalUnavailable: "原始消息不可用。",
|
|
399
|
+
replyMessage: "回复", replyingTo: "回复给", cancelReply: "取消回复", replyOpenOriginal: "查看原始消息", replyOriginalUnavailable: "原始消息不可用。", replyOriginalRecalled: "原消息已撤回。",
|
|
400
|
+
recallMessage: "撤回", recallSystemMessage: "撤回这条房间通知", recallSystemConfirm: "撤回这条房间通知?所有人都会看到“消息已撤回”。", recallConfirm: "撤回这条消息?所有人都会看到“消息已撤回”。", recallAdminConfirm: ({ name }) => `撤回 ${name} 的消息?所有人都会看到“消息已撤回”。`, recallFailed: "撤回失败,请重试。", messageRecalled: "消息已撤回", recalledBy: ({ name }) => `${name} 撤回`, showRecalled: "查看原文", hideRecalled: "收起原文", revealFailed: "加载失败,重试",
|
|
344
401
|
identityChanged: "此浏览器身份已在另一个标签页中更改,请重新加载此标签页后继续。",
|
|
345
402
|
networkError: "网络连接失败", requestFailed: ({ status }) => `请求失败(HTTP ${status})`,
|
|
346
403
|
roomIdRequired: "请输入房间 ID", nameRequired: "请输入你的昵称", authRetry: "服务器要求访问令牌,请填写后重试",
|
|
@@ -354,7 +411,9 @@ const messages = {
|
|
|
354
411
|
refreshRooms: "刷新房间", identityLabel: ({ name }) => `当前昵称:${name}`, roomsMenu: "打开房间列表", closeRoomList: "关闭房间列表", direct: "私聊",
|
|
355
412
|
messagePrivately: "私聊", removeMember: "移除", kickConfirm: ({ name }) => `确定将 ${name} 移出此房间?对方仍可用房间 ID 重新加入。`,
|
|
356
413
|
deleteRoom: "删除房间", deleteConfirm: ({ name }) => `删除“${name}”及全部聊天记录?此操作无法撤销。`,
|
|
357
|
-
allMembers: "所有人", messageCount: ({ count }) => `${count} /
|
|
414
|
+
allMembers: "所有人", messageCount: ({ count }) => `${count} / 5000`,
|
|
415
|
+
pasteAsFile: ({ count }) => `已把粘贴的 ${count} 个字符保存为文本文件`,
|
|
416
|
+
sendAsFile: ({ count }) => `${count} 个字符超出上限,将作为文本文件发送`,
|
|
358
417
|
privacyNote: "持有共享令牌的人都可以读取私聊内容和管理房间;服务器也可以读取私聊内容。", resourceDelete: "删除文件", resourceDeleting: "正在删除…", resourceDeleteConfirm: ({ name }) => `确定删除“${name}”?此操作无法撤销。`, resourceDeleted: "文件已删除。", resourceDeleteFailed: "无法删除此文件。",
|
|
359
418
|
systemJoined: ({ name }) => `${name} 加入了房间`, systemLeft: ({ name }) => `${name} 离开了房间`, systemRemoved: ({ name }) => `${name} 被移出了房间`,
|
|
360
419
|
systemDesignated: ({ actor, name }) => `${actor} 指定 ${name} 为管理员`, systemRevoked: ({ actor }) => `${actor} 撤销了管理员指定`, systemRenamed: ({ actor, from, to }) => `${actor} 将房间名称从“${from}”改为“${to}”`, systemDescribed: ({ actor }) => `${actor} 更新了房间描述`, systemHanded: ({ actor, name }) => `${actor} 将房间移交给了 ${name}`, systemAdminsUpdated: ({ actor }) => `${actor} 更新了房间管理员`, systemSuccessorNamed: ({ actor, name }) => `${actor} 指定 ${name} 为房间继任者`, systemSuccessorCleared: ({ actor }) => `${actor} 清除了房间继任者`,
|
|
@@ -32,8 +32,11 @@ export function setRoomPreview(entry, message) {
|
|
|
32
32
|
entry.preview = message.text;
|
|
33
33
|
entry.previewAt = message.createdAt;
|
|
34
34
|
entry.previewSenderId = message.senderId;
|
|
35
|
+
entry.previewRecalled = Boolean(message.recalledAt);
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export function formatRoomPreview(entry, latest, app) {
|
|
39
|
+
// A recalled message must not leak its text through the room rail.
|
|
40
|
+
if (entry?.previewRecalled || latest?.recalledAt) return app.t("messageRecalled");
|
|
38
41
|
return formatSystemMessage(entry?.preview ? { senderId: entry.previewSenderId, text: entry.preview } : latest, app);
|
|
39
42
|
}
|
|
@@ -288,12 +288,12 @@
|
|
|
288
288
|
.reader-close:hover { border-color: var(--line); color: var(--ink); background: var(--surface-2); }
|
|
289
289
|
.close-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.8; }
|
|
290
290
|
.reader-panel .receipt-reader-list li { display: grid; gap: 3px; padding: 10px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
|
|
291
|
-
.image-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 20px; border: 0; background: transparent; }
|
|
291
|
+
.image-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 20px; overflow: hidden; border: 0; background: transparent; }
|
|
292
292
|
.image-dialog[open] { display: grid; place-items: center; }
|
|
293
293
|
.image-dialog::backdrop { background: rgb(9 16 22 / .84); backdrop-filter: blur(3px); }
|
|
294
294
|
.image-dialog img { display: block; max-width: 100%; max-height: calc(100dvh - 40px); width: auto; height: auto; object-fit: contain; border-radius: 8px; animation: image-zoom-in .16s ease both; }
|
|
295
295
|
@keyframes image-zoom-in { from { opacity: 0; transform: scale(.97); } }
|
|
296
|
-
.image-dialog-close { position: fixed; top: 14px; right: 14px; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid rgb(255 255 255 / .34); border-radius: 50%; color: #fff; background: rgb(9 16 22 / .58); font: inherit; line-height: 1; cursor: pointer; }
|
|
296
|
+
.image-dialog-close { position: fixed; z-index: 2; top: 14px; right: 14px; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid rgb(255 255 255 / .34); border-radius: 50%; color: #fff; background: rgb(9 16 22 / .58); font: inherit; line-height: 1; cursor: pointer; }
|
|
297
297
|
.image-dialog-close .close-icon { width: 22px; height: 22px; }
|
|
298
298
|
.image-dialog-close:hover, .image-dialog-close:focus-visible { background: rgb(9 16 22 / .82); outline: 2px solid #fff; outline-offset: 2px; }
|
|
299
299
|
.msg-text img, .chat-resource img, .attachment-preview img { cursor: zoom-in; }
|