@alexsun-top/opencode-chat-room 0.7.4 → 0.7.5
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 +9 -0
- package/README.md +4 -4
- package/README.zh-CN.md +4 -4
- package/package.json +1 -1
- package/server/assets/FLUENT-ICONS-LICENSE +25 -0
- package/server/assets/NOTICE.txt +2 -1
- package/server/assets/attachments.css +1 -1
- package/server/assets/base.css +29 -7
- package/server/assets/chat/files.js +11 -10
- package/server/assets/chat/history-loader.js +36 -26
- package/server/assets/chat/icons.js +15 -0
- package/server/assets/chat/index.js +1 -1
- package/server/assets/chat/locales/de.js +3 -2
- package/server/assets/chat/locales/es.js +3 -2
- package/server/assets/chat/locales/fr.js +3 -2
- package/server/assets/chat/locales/it.js +3 -2
- package/server/assets/chat/locales/ja.js +3 -2
- package/server/assets/chat/locales/ko.js +3 -2
- package/server/assets/chat/markdown.js +5 -33
- package/server/assets/chat/messages.js +4 -9
- package/server/assets/chat/palette.js +41 -29
- package/server/assets/chat/pwa.js +67 -9
- package/server/assets/chat/recall.js +3 -2
- package/server/assets/chat/replies.js +2 -1
- package/server/assets/chat/rooms.js +12 -4
- package/server/assets/chat/shortcuts.js +1 -1
- package/server/assets/chat/state.js +6 -4
- package/server/assets/code-highlight.css +0 -5
- package/server/assets/conversation.css +5 -4
- package/server/assets/files.css +0 -15
- package/server/assets/fluent-icons.svg +42 -0
- package/server/assets/icons.css +9 -0
- package/server/assets/palette.css +1 -15
- package/server/assets/recall.css +2 -2
- package/server/assets/responsive.css +4 -4
- package/server/assets/room-create.css +1 -1
- package/server/assets/settings.css +4 -4
- package/server/chat.html +60 -42
- package/server/sw.js +9 -1
- package/src/tui/main.mjs +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createRandomId, LS } from "./state.js";
|
|
2
2
|
import { isRoomAdmin } from "./admin-badge.js";
|
|
3
|
+
import { iconNode } from "./icons.js";
|
|
3
4
|
|
|
4
5
|
const mentionPattern = /<at>@([^<]+)<\/at>/g;
|
|
5
6
|
const resourcePattern = /\[\[resource:([\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})\]\]/gi;
|
|
6
7
|
let mermaidReady = false;
|
|
7
8
|
const previewUrls = new Map();
|
|
8
|
-
const svgNamespace = "http://www.w3.org/2000/svg";
|
|
9
9
|
let previewObserver;
|
|
10
10
|
|
|
11
11
|
export function renderMarkdown(root, text, app) {
|
|
@@ -113,36 +113,9 @@ function codeToolButton(className, key, app, ...icons) {
|
|
|
113
113
|
return button;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
svg.setAttribute("aria-hidden", "true");
|
|
120
|
-
svg.classList.add("code-tool-icon", className);
|
|
121
|
-
for (const [tag, attributes] of shapes) {
|
|
122
|
-
const node = document.createElementNS(svgNamespace, tag);
|
|
123
|
-
for (const [name, value] of Object.entries(attributes)) node.setAttribute(name, value);
|
|
124
|
-
svg.append(node);
|
|
125
|
-
}
|
|
126
|
-
return svg;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function wrapIcon() {
|
|
130
|
-
return codeIcon("code-wrap-icon", [
|
|
131
|
-
["path", { d: "M4 5h16M4 11h13a3.5 3.5 0 0 1 0 7h-4M4 18h5" }],
|
|
132
|
-
["path", { d: "m8 16-3 3 3 3" }],
|
|
133
|
-
]);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function copyIcon() {
|
|
137
|
-
return codeIcon("code-copy-icon", [
|
|
138
|
-
["rect", { x: "4", y: "3", width: "13", height: "15", rx: "2" }],
|
|
139
|
-
["rect", { x: "8", y: "7", width: "12", height: "14", rx: "2" }],
|
|
140
|
-
]);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function checkIcon() {
|
|
144
|
-
return codeIcon("code-check-icon", [["path", { d: "m5 12 4.5 4.5L19 7" }]]);
|
|
145
|
-
}
|
|
116
|
+
const wrapIcon = () => iconNode("text_wrap", "code-tool-icon code-wrap-icon");
|
|
117
|
+
const copyIcon = () => iconNode("copy", "code-tool-icon code-copy-icon");
|
|
118
|
+
const checkIcon = () => iconNode("checkmark", "code-tool-icon code-check-icon");
|
|
146
119
|
|
|
147
120
|
async function copyCode(button, code, app) {
|
|
148
121
|
const copied = await copyTextToClipboard(code.textContent);
|
|
@@ -280,8 +253,7 @@ function resourceSplit(app, resource, download, item) {
|
|
|
280
253
|
toggle.setAttribute("data-i18n-aria-label", "resourceMoreActions");
|
|
281
254
|
toggle._i18nValues = { name: resource.name };
|
|
282
255
|
toggle.setAttribute("aria-label", app.t("resourceMoreActions", { name: resource.name }));
|
|
283
|
-
|
|
284
|
-
icon.setAttribute("aria-hidden", "true"); icon.setAttribute("viewBox", "0 0 24 24"); path.setAttribute("d", "M6 9l6 6 6-6"); icon.append(path); toggle.append(icon);
|
|
256
|
+
toggle.append(iconNode("chevron_down"));
|
|
285
257
|
menu.className = "resource-split-menu"; menu.hidden = true; menu.setAttribute("role", "menu"); menu.append(item);
|
|
286
258
|
group.append(download, toggle, menu);
|
|
287
259
|
function close(focusToggle = false) {
|
|
@@ -5,6 +5,7 @@ import { formatSystemMessage, setRoomPreview } from "./system-messages.js";
|
|
|
5
5
|
import { installEditor } from "./editor.js";
|
|
6
6
|
import { adminAgentBadge, isAdminAgent } from "./admin-badge.js";
|
|
7
7
|
import { initMessagePolling } from "./message-polling.js";
|
|
8
|
+
import { iconNode } from "./icons.js";
|
|
8
9
|
|
|
9
10
|
export function initMessages(app) {
|
|
10
11
|
const $ = app.$;
|
|
@@ -241,13 +242,7 @@ export function initMessages(app) {
|
|
|
241
242
|
copy.dataset.i18nAriaLabel = "copyMessage";
|
|
242
243
|
copy.dataset.i18nTitle = "copyMessage";
|
|
243
244
|
copy.title = app.t("copyMessage");
|
|
244
|
-
const icon =
|
|
245
|
-
icon.classList.add("message-copy-icon"); icon.setAttribute("viewBox", "0 0 24 24"); icon.setAttribute("aria-hidden", "true");
|
|
246
|
-
const back = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
247
|
-
back.setAttribute("x", "4"); back.setAttribute("y", "3"); back.setAttribute("width", "13"); back.setAttribute("height", "15"); back.setAttribute("rx", "2");
|
|
248
|
-
const front = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
249
|
-
front.setAttribute("x", "8"); front.setAttribute("y", "7"); front.setAttribute("width", "12"); front.setAttribute("height", "14"); front.setAttribute("rx", "2");
|
|
250
|
-
icon.append(back, front);
|
|
245
|
+
const icon = iconNode("copy", "message-copy-icon");
|
|
251
246
|
const feedback = document.createElement("span");
|
|
252
247
|
feedback.className = "message-copy-feedback"; feedback.dataset.flashOutput = ""; feedback.dataset.i18n = "copyMessage";
|
|
253
248
|
feedback.hidden = true; feedback.setAttribute("role", "status"); feedback.setAttribute("aria-live", "polite"); feedback.textContent = app.t("copyMessage");
|
|
@@ -260,7 +255,7 @@ export function initMessages(app) {
|
|
|
260
255
|
return row;
|
|
261
256
|
};
|
|
262
257
|
|
|
263
|
-
app.renderMessages = (live = false) => {
|
|
258
|
+
app.renderMessages = (live = false, tailLimit = 0) => {
|
|
264
259
|
const thread = $("#thread"), list = $("#msgList"), messages = app.state.room.messages;
|
|
265
260
|
// A palette jump renders a window around the target instead of the newest
|
|
266
261
|
// tail. While that window is up, live appends stay off screen so the target
|
|
@@ -286,7 +281,7 @@ export function initMessages(app) {
|
|
|
286
281
|
let startIndex = 0;
|
|
287
282
|
const lastId = [...list.querySelectorAll("[data-msg-id]")].at(-1)?.dataset.msgId;
|
|
288
283
|
if (lastId) for (let index = messages.length - 1; index >= 0; index--) if (messages[index].id === lastId) { startIndex = index + 1; break; }
|
|
289
|
-
const renderStart = focus ? Math.max(0, focus.index - 120) : startIndex;
|
|
284
|
+
const renderStart = focus ? Math.max(0, focus.index - 120) : Math.max(startIndex, tailLimit ? messages.length - tailLimit : 0);
|
|
290
285
|
const renderEnd = focus ? Math.min(messages.length, focus.index + 120) : messages.length;
|
|
291
286
|
for (let index = renderStart; index < renderEnd; index++) {
|
|
292
287
|
const message = messages[index];
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
+
import { icon } from "./icons.js";
|
|
2
|
+
|
|
1
3
|
// Alt+Space opens one keyboard-first surface: message search plus common room commands.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
plus: '<svg aria-hidden="true" viewBox="0 0 24 24"><path d="M12 5v14M5 12h14"/></svg>',
|
|
5
|
-
gear: '<svg aria-hidden="true" viewBox="0 0 24 24"><path d="M4 7h9M17 7h3M4 17h3M11 17h9"/><circle cx="15" cy="7" r="2"/><circle cx="9" cy="17" r="2"/></svg>',
|
|
6
|
-
members: '<svg aria-hidden="true" viewBox="0 0 24 24"><circle cx="9" cy="8" r="3"/><path d="M3.5 19a5.5 5.5 0 0 1 11 0M16 5.5a3 3 0 0 1 0 5.8M17 14a4.5 4.5 0 0 1 3.5 4.4V19h-3"/></svg>',
|
|
7
|
-
questions: '<svg aria-hidden="true" viewBox="0 0 24 24"><path d="M9.5 9a2.5 2.5 0 1 1 4.6 1.4c-.7.9-2.1 1.3-2.1 2.8M12 17.5h.01"/><circle cx="12" cy="12" r="9"/></svg>',
|
|
8
|
-
announcements: '<svg aria-hidden="true" viewBox="0 0 24 24"><path d="M5 4h14v16H5zM8 8h8M8 12h8M8 16h5"/></svg>',
|
|
9
|
-
reminders: '<svg aria-hidden="true" viewBox="0 0 24 24"><path d="M18 8a6 6 0 1 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9"/><path d="M10 21a2 2 0 0 0 4 0"/></svg>',
|
|
10
|
-
leave: '<svg aria-hidden="true" viewBox="0 0 24 24"><path d="M10 4H5v16h5M15 8l4 4-4 4M19 12H9"/></svg>',
|
|
11
|
-
latest: '<svg aria-hidden="true" viewBox="0 0 24 24"><path d="M12 4v14M7 13l5 5 5-5M5 21h14"/></svg>',
|
|
12
|
-
command: '<svg aria-hidden="true" viewBox="0 0 24 24"><path d="M5 12h14M13 6l6 6-6 6"/></svg>',
|
|
13
|
-
};
|
|
4
|
+
|
|
5
|
+
const SEARCH_DEBOUNCE_MS = 220;
|
|
14
6
|
|
|
15
7
|
export function initPalette(app) {
|
|
16
8
|
const dialog = app.$("#paletteDialog");
|
|
@@ -27,18 +19,18 @@ export function initPalette(app) {
|
|
|
27
19
|
|
|
28
20
|
const commands = () => {
|
|
29
21
|
const available = [
|
|
30
|
-
{ id: "refresh", label: t("refreshRooms"), icon: "
|
|
31
|
-
{ id: "create", label: t("createRoom"), icon: "
|
|
22
|
+
{ id: "refresh", label: t("refreshRooms"), icon: "arrow_sync", keywords: "reload rooms", run: () => void app.refreshRoomList?.() },
|
|
23
|
+
{ id: "create", label: t("createRoom"), icon: "add", keywords: "new room", focusComposer: false,
|
|
32
24
|
run: () => room() ? app.openCreateRoomDialog?.() : app.$("#inRoomName")?.focus({ preventScroll: true }) },
|
|
33
|
-
{ id: "settings", label: t("settings"), icon: "
|
|
25
|
+
{ id: "settings", label: t("settings"), icon: "options", keywords: "preferences theme language", focusComposer: false, run: () => app.openSettings?.() },
|
|
34
26
|
];
|
|
35
27
|
if (room()) available.push(
|
|
36
|
-
{ id: "members", label: t("members"), icon: "
|
|
37
|
-
{ id: "questions", label: t("questions"), icon: "
|
|
38
|
-
{ id: "announcements", label: t("announcements"), icon: "
|
|
39
|
-
{ id: "reminders", label: t("reminders"), icon: "
|
|
40
|
-
{ id: "leave", label: t("paletteLeaveRoom"), icon: "
|
|
41
|
-
{ id: "latest", label: t("paletteJumpLatest"), icon: "
|
|
28
|
+
{ id: "members", label: t("members"), icon: "people", keywords: "people roster", focusComposer: false, run: () => app.$("#btnMembers")?.click() },
|
|
29
|
+
{ id: "questions", label: t("questions"), icon: "question_circle", keywords: "answers", focusComposer: false, run: () => app.$("#btnQuestions")?.click() },
|
|
30
|
+
{ id: "announcements", label: t("announcements"), icon: "megaphone", keywords: "notice board", focusComposer: false, run: () => app.$("#btnAnnouncements")?.click() },
|
|
31
|
+
{ id: "reminders", label: t("reminders"), icon: "alert", keywords: "schedule alarm", focusComposer: false, run: () => app.$("#btnReminders")?.click() },
|
|
32
|
+
{ id: "leave", label: t("paletteLeaveRoom"), icon: "arrow_exit", keywords: "exit quit", focusComposer: false, run: () => app.leaveRoom?.(false) },
|
|
33
|
+
{ id: "latest", label: t("paletteJumpLatest"), icon: "arrow_down", keywords: "bottom newest", run: () => app.jumpToBottom?.() },
|
|
42
34
|
);
|
|
43
35
|
return available;
|
|
44
36
|
};
|
|
@@ -74,7 +66,11 @@ export function initPalette(app) {
|
|
|
74
66
|
|
|
75
67
|
const syncSelection = () => {
|
|
76
68
|
const rows = [...list.querySelectorAll(".palette-row")];
|
|
77
|
-
rows.forEach((row, index) =>
|
|
69
|
+
rows.forEach((row, index) => {
|
|
70
|
+
row.setAttribute("aria-selected", String(index === selected));
|
|
71
|
+
const enter = row.querySelector(".palette-enter");
|
|
72
|
+
if (enter) enter.hidden = index !== selected;
|
|
73
|
+
});
|
|
78
74
|
input.setAttribute("aria-expanded", String(items.length > 0));
|
|
79
75
|
if (items.length && selected >= 0) input.setAttribute("aria-activedescendant", `palette-option-${selected}`);
|
|
80
76
|
else input.removeAttribute("aria-activedescendant");
|
|
@@ -92,9 +88,9 @@ export function initPalette(app) {
|
|
|
92
88
|
row.setAttribute("role", "option");
|
|
93
89
|
row.style.setProperty("--palette-i", String(Math.min(index, 9)));
|
|
94
90
|
if (item.kind === "command") {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
const badge = document.createElement("span");
|
|
92
|
+
badge.className = "palette-icon";
|
|
93
|
+
badge.innerHTML = icon(item.icon || "arrow_right");
|
|
98
94
|
const label = document.createElement("span");
|
|
99
95
|
label.className = "palette-label";
|
|
100
96
|
label.textContent = item.label;
|
|
@@ -102,7 +98,7 @@ export function initPalette(app) {
|
|
|
102
98
|
enter.className = "palette-enter";
|
|
103
99
|
enter.setAttribute("aria-hidden", "true");
|
|
104
100
|
enter.textContent = "↵";
|
|
105
|
-
row.append(
|
|
101
|
+
row.append(badge, label, enter);
|
|
106
102
|
} else {
|
|
107
103
|
const top = document.createElement("span");
|
|
108
104
|
top.className = "palette-result-top";
|
|
@@ -236,14 +232,17 @@ export function initPalette(app) {
|
|
|
236
232
|
const value = input.value;
|
|
237
233
|
if (!value.trim()) { showCommands(""); return; }
|
|
238
234
|
if (value.startsWith(">")) { showCommands(value.slice(1)); return; }
|
|
235
|
+
const wasSearch = dialog.dataset.mode === "search";
|
|
239
236
|
dialog.dataset.mode = "search";
|
|
240
237
|
dialog.dataset.state = "searching";
|
|
241
238
|
modeLabel.textContent = t("paletteSearchMode");
|
|
242
239
|
list.setAttribute("aria-busy", "true");
|
|
243
|
-
|
|
240
|
+
// Keep the previous hits visible while typing. Clearing them on every
|
|
241
|
+
// keystroke is what makes the result list flicker.
|
|
242
|
+
if (!wasSearch || !items.length) render([], null);
|
|
244
243
|
status.textContent = t("paletteSearching");
|
|
245
244
|
const text = value.trim();
|
|
246
|
-
searchTimer = setTimeout(() => { void executeSearch(text, token); },
|
|
245
|
+
searchTimer = setTimeout(() => { void executeSearch(text, token); }, SEARCH_DEBOUNCE_MS);
|
|
247
246
|
};
|
|
248
247
|
|
|
249
248
|
const highlightHit = (item) => {
|
|
@@ -316,7 +315,7 @@ export function initPalette(app) {
|
|
|
316
315
|
};
|
|
317
316
|
app.openPalette = openPalette;
|
|
318
317
|
|
|
319
|
-
input.addEventListener("input", scheduleSearch);
|
|
318
|
+
input.addEventListener("input", (event) => { if (!event.isComposing) scheduleSearch(); });
|
|
320
319
|
scopeButton.addEventListener("click", () => { toggleScope(); input.focus(); });
|
|
321
320
|
app.$("#btnClosePalette")?.addEventListener("click", () => closePalette());
|
|
322
321
|
dialog.addEventListener("click", (event) => { if (event.target === dialog) closePalette(); });
|
|
@@ -360,6 +359,19 @@ export function initPalette(app) {
|
|
|
360
359
|
if (!items.length || selected < 0) return;
|
|
361
360
|
event.preventDefault();
|
|
362
361
|
activate(items[selected]);
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
if (event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
|
|
365
|
+
const digit = /^(?:Digit|Numpad)([1-9])$/.exec(event.code)?.[1] ?? (/^[1-9]$/.test(event.key) ? event.key : null);
|
|
366
|
+
const index = digit ? Number(digit) - 1 : -1;
|
|
367
|
+
if (digit) {
|
|
368
|
+
event.preventDefault();
|
|
369
|
+
event.stopPropagation();
|
|
370
|
+
if (index >= 0 && index < items.length) {
|
|
371
|
+
selected = index;
|
|
372
|
+
syncSelection();
|
|
373
|
+
}
|
|
374
|
+
}
|
|
363
375
|
}
|
|
364
376
|
});
|
|
365
377
|
|
|
@@ -1,18 +1,76 @@
|
|
|
1
|
-
|
|
1
|
+
// A waiting worker means a new release is ready. Never reload on our own: a page can
|
|
2
|
+
// hold a draft or a reply in progress, so the person decides when to apply it.
|
|
3
|
+
const UPDATE_CHECK_MS = 30 * 60 * 1000;
|
|
4
|
+
|
|
5
|
+
export function initPwa(app) {
|
|
2
6
|
if (!("serviceWorker" in navigator) || !window.isSecureContext) return;
|
|
3
7
|
// Automated browsers do not model a worker's cache or its extra requests, so the browser
|
|
4
8
|
// tests would measure a page that no longer matches the code under test.
|
|
5
9
|
if (navigator.webdriver) return;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
const panel = app.$("#pwaUpdate"), accept = app.$("#btnPwaUpdate"), later = app.$("#btnPwaLater");
|
|
11
|
+
if (!panel || !accept || !later) return;
|
|
12
|
+
let registration = null;
|
|
13
|
+
let waiting = null;
|
|
14
|
+
let reloading = false;
|
|
9
15
|
let reloaded = false;
|
|
16
|
+
let lastCheck = 0;
|
|
17
|
+
|
|
18
|
+
const show = (worker) => {
|
|
19
|
+
// The first install claims this page too. It is not an upgrade, so it stays silent.
|
|
20
|
+
if (!worker || !navigator.serviceWorker.controller) return;
|
|
21
|
+
waiting = worker;
|
|
22
|
+
panel.hidden = false;
|
|
23
|
+
};
|
|
24
|
+
const hide = () => { panel.hidden = true; };
|
|
25
|
+
const watchWorker = (worker) => {
|
|
26
|
+
if (!worker) return;
|
|
27
|
+
if (worker.state === "installed") show(worker);
|
|
28
|
+
else worker.addEventListener("statechange", () => {
|
|
29
|
+
if (worker.state === "installed") show(worker);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
const watchRegistration = (next) => {
|
|
33
|
+
registration = next;
|
|
34
|
+
if (registration.waiting) show(registration.waiting);
|
|
35
|
+
registration.addEventListener("updatefound", () => watchWorker(registration.installing));
|
|
36
|
+
};
|
|
37
|
+
const checkForUpdate = () => {
|
|
38
|
+
if (!registration || document.visibilityState !== "visible" || !navigator.onLine) return;
|
|
39
|
+
const now = Date.now();
|
|
40
|
+
if (now - lastCheck < UPDATE_CHECK_MS) return;
|
|
41
|
+
lastCheck = now;
|
|
42
|
+
registration.update().catch(() => {});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
accept.addEventListener("click", () => {
|
|
46
|
+
if (!waiting) return;
|
|
47
|
+
reloading = true;
|
|
48
|
+
hide();
|
|
49
|
+
waiting.postMessage({ type: "SKIP_WAITING" });
|
|
50
|
+
});
|
|
51
|
+
// Later leaves the waiting worker in place. If every page closes it activates on the
|
|
52
|
+
// next open; otherwise this page keeps running without interruption.
|
|
53
|
+
later.addEventListener("click", hide);
|
|
10
54
|
navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
|
|
55
|
+
if (reloading && !reloaded) {
|
|
56
|
+
reloaded = true;
|
|
57
|
+
location.reload();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// Another tab may have applied the update. This page keeps its state and picks up
|
|
61
|
+
// the new release on the next reload.
|
|
62
|
+
waiting = null;
|
|
63
|
+
hide();
|
|
64
|
+
});
|
|
65
|
+
window.addEventListener("online", checkForUpdate);
|
|
66
|
+
window.addEventListener("focus", checkForUpdate);
|
|
67
|
+
document.addEventListener("visibilitychange", () => {
|
|
68
|
+
if (document.visibilityState === "visible") checkForUpdate();
|
|
14
69
|
});
|
|
15
70
|
window.addEventListener("load", () => {
|
|
16
|
-
navigator.serviceWorker.register("/sw.js").
|
|
71
|
+
navigator.serviceWorker.register("/sw.js").then((next) => {
|
|
72
|
+
lastCheck = Date.now();
|
|
73
|
+
watchRegistration(next);
|
|
74
|
+
}).catch(() => {});
|
|
17
75
|
});
|
|
18
|
-
}
|
|
76
|
+
}
|
|
@@ -3,9 +3,10 @@ import { renderMarkdown } from "./markdown.js";
|
|
|
3
3
|
import { isOwnMessage } from "./messages.js";
|
|
4
4
|
import { isRoomAdmin } from "./admin-badge.js";
|
|
5
5
|
import { formatSystemMessage, setRoomPreview } from "./system-messages.js";
|
|
6
|
+
import { icon } from "./icons.js";
|
|
6
7
|
|
|
7
|
-
const RECALL_ICON =
|
|
8
|
-
const RECALLED_ICON =
|
|
8
|
+
const RECALL_ICON = icon("arrow_undo", "message-recall-icon");
|
|
9
|
+
const RECALLED_ICON = icon("arrow_undo", "recalled-icon");
|
|
9
10
|
|
|
10
11
|
// Recall is a soft hide: the server keeps the text and members may reveal it.
|
|
11
12
|
export function initRecall(app) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LS } from "./state.js";
|
|
2
2
|
import { replaceEditorRange, setEditorSelection, setCaret } from "./editor.js";
|
|
3
|
+
import { icon } from "./icons.js";
|
|
3
4
|
|
|
4
5
|
export function initReplies(app) {
|
|
5
6
|
const $ = app.$, targets = new Map(Object.entries(LS.replyDrafts || {}).filter(([, item]) => validTarget(item)));
|
|
@@ -38,7 +39,7 @@ function bindMessageActions(app) {
|
|
|
38
39
|
if (copy) {
|
|
39
40
|
const actions = document.createElement("div"), reply = document.createElement("button");
|
|
40
41
|
actions.className = "message-actions";
|
|
41
|
-
reply.type = "button"; reply.className = "message-reply"; reply.innerHTML =
|
|
42
|
+
reply.type = "button"; reply.className = "message-reply"; reply.innerHTML = icon("arrow_reply", "message-reply-icon");
|
|
42
43
|
reply.setAttribute("aria-label", app.t("replyMessage")); reply.dataset.i18nAriaLabel = "replyMessage"; reply.dataset.replyMessage = message.id;
|
|
43
44
|
copy.before(actions); actions.append(copy, reply);
|
|
44
45
|
}
|
|
@@ -69,8 +69,12 @@ export function initRooms(app) {
|
|
|
69
69
|
|
|
70
70
|
app.enterRoom = (room, name, intent = app.state.navigationGeneration) => {
|
|
71
71
|
app.ensureJoinedRoom(room, name);
|
|
72
|
-
if (intent === app.state.navigationGeneration)
|
|
73
|
-
|
|
72
|
+
if (intent === app.state.navigationGeneration) {
|
|
73
|
+
app.activateRoom(room.id);
|
|
74
|
+
// Membership changed, so the rail needs one refresh. Plain room switches
|
|
75
|
+
// stay cache-only and do not reach the network here.
|
|
76
|
+
void app.refreshRoomList();
|
|
77
|
+
} else {
|
|
74
78
|
app.renderRoomOptions($("#roomList"), app.state.availableRooms || []);
|
|
75
79
|
app.renderRoomOptions($("#roomListChat"), app.state.availableRooms || []);
|
|
76
80
|
void app.refreshRoomList();
|
|
@@ -141,7 +145,9 @@ export function initRooms(app) {
|
|
|
141
145
|
app.renderHead();
|
|
142
146
|
$("#msgList").textContent = "";
|
|
143
147
|
app.state.listMetrics = { height: 0, top: 0, client: 0 };
|
|
144
|
-
|
|
148
|
+
// Cached history can hold thousands of messages. Render the newest window
|
|
149
|
+
// first so switching stays immediate; older rows are prepended on demand.
|
|
150
|
+
app.renderMessages(false, 300);
|
|
145
151
|
app.restoreReadingPosition?.(roomId);
|
|
146
152
|
app.state.readAnchorGuard = null;
|
|
147
153
|
app.startPolling();
|
|
@@ -173,7 +179,8 @@ export function initRooms(app) {
|
|
|
173
179
|
app.markActiveRoomRead();
|
|
174
180
|
app.renderRoomOptions($("#roomList"), app.state.availableRooms || []);
|
|
175
181
|
app.renderRoomOptions($("#roomListChat"), app.state.availableRooms || []);
|
|
176
|
-
|
|
182
|
+
// Switching must render from the local cache. The room watcher refreshes
|
|
183
|
+
// membership metadata in the background; do not start a room-list request here.
|
|
177
184
|
// Switching rooms replaces the clicked row; keep the composer ready to type.
|
|
178
185
|
app.focusComposer?.();
|
|
179
186
|
document.dispatchEvent(new CustomEvent("chat-room-activated", { detail: roomId }));
|
|
@@ -280,6 +287,7 @@ export function initRooms(app) {
|
|
|
280
287
|
$("#btnSend").disabled = true;
|
|
281
288
|
}
|
|
282
289
|
app.state.rooms.delete(roomId);
|
|
290
|
+
app.state.availableRooms = (app.state.availableRooms || []).filter((room) => room.id !== roomId);
|
|
283
291
|
void deleteCachedRoom(roomId);
|
|
284
292
|
app.state.memberSessions.delete(roomId);
|
|
285
293
|
app.state.joinedIds.delete(roomId);
|
|
@@ -127,7 +127,7 @@ export function initShortcuts(app) {
|
|
|
127
127
|
// Keep the motion in the room list: a vertical glide shows where the selection moved.
|
|
128
128
|
for (const row of document.querySelectorAll("#roomList .room-row.selected, #roomListChat .room-row.selected")) {
|
|
129
129
|
row.classList.remove("room-switch-enter");
|
|
130
|
-
row.style.setProperty("--room-switch-shift", `${direction > 0 ?
|
|
130
|
+
row.style.setProperty("--room-switch-shift", `${direction > 0 ? 3 : -3}px`);
|
|
131
131
|
void row.offsetWidth;
|
|
132
132
|
row.classList.add("room-switch-enter");
|
|
133
133
|
row.scrollIntoView({ block: "nearest" });
|
|
@@ -249,6 +249,7 @@ export const messages = {
|
|
|
249
249
|
reminderCreated: "Reminder created.", reminderUpdated: "Reminder updated.", reminderDeleted: "Reminder deleted.",
|
|
250
250
|
reminderInvalid: "Check the date, 5-field CRON expression, IANA timezone, and reminder text.", reminderLoadFailed: "Could not load reminders. Your draft is still here.",
|
|
251
251
|
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.",
|
|
252
|
+
pwaUpdateTitle: "Update available", pwaUpdateBody: "A new version is ready. Reload now, or update the next time you open the app.", pwaUpdateNow: "Update now", pwaUpdateLater: "Later",
|
|
252
253
|
announcementDelete: "Delete announcement",
|
|
253
254
|
announcementNew: "New announcement", announcementEmpty: "No announcements yet.", announcementLoading: "Loading announcements…",
|
|
254
255
|
announcementLoadFailed: "Could not load announcements. Your draft is still here.", announcementSaved: "Announcement saved.", announcementDeleted: "Announcement deleted.",
|
|
@@ -283,7 +284,7 @@ export const messages = {
|
|
|
283
284
|
shortcutsTitle: "Keyboard shortcuts", shortcutsLead: "ChatRoom shortcuts. Press {modifier} + / to open this list.",
|
|
284
285
|
shortcutsOpen: "All shortcuts",
|
|
285
286
|
shortcutsWriting: "Writing", shortcutsSend: "Send the message", shortcutsNewline: "Start a new line",
|
|
286
|
-
shortcutsMention: "Choose a member to mention", shortcutsRooms: "Rooms",
|
|
287
|
+
shortcutsMention: "Choose a member to mention", shortcutsRooms: "Rooms", shortcutsSearch: "Search and commands", shortcutsOpenPalette: "Open search and commands",
|
|
287
288
|
shortcutsSwitchRoom: "Switch to the previous or next room", shortcutsNumberRoom: "Switch to a joined room by number", shortcutsReading: "Reading",
|
|
288
289
|
shortcutsScroll: "Scroll messages while typing", shortcutsJump: "Jump to the start or end of the conversation", shortcutsMenus: "Menus and dialogs",
|
|
289
290
|
shortcutsClose: "Close the open menu, panel, or dialog",
|
|
@@ -292,7 +293,7 @@ export const messages = {
|
|
|
292
293
|
paletteScopeHint: "Tab switches between this room and all joined rooms", paletteSearchMode: "Search", paletteCommandMode: "Commands",
|
|
293
294
|
paletteSearching: "Searching…", paletteNoResults: "No messages found.", paletteNoCommands: "No matching commands.",
|
|
294
295
|
paletteResults: ({ count }) => `${count} result${count === 1 ? "" : "s"}`, paletteCommandsHint: "Common commands",
|
|
295
|
-
paletteHint: "↑↓ select · Enter open · Tab scope · Esc close", paletteSearchFailed: "Search failed. Try again.",
|
|
296
|
+
paletteHint: "↑↓ or Alt+1–9 select · Enter open · Tab scope · Esc close", paletteSearchFailed: "Search failed. Try again.",
|
|
296
297
|
paletteLeaveRoom: "Leave room", paletteJumpLatest: "Jump to latest",
|
|
297
298
|
filesTitle: "Files", filesEyebrow: "Room files", filesFilter: "Uploaded by", filesEveryone: "Everyone",
|
|
298
299
|
filesUnknownUploader: "Unknown uploader", filesSummary: ({ count, size }) => `${count} file${count === 1 ? "" : "s"} · ${size}`,
|
|
@@ -382,6 +383,7 @@ export const messages = {
|
|
|
382
383
|
reminderCreated: "提醒已创建。", reminderUpdated: "提醒已更新。", reminderDeleted: "提醒已删除。",
|
|
383
384
|
reminderInvalid: "请检查日期、5 字段 CRON 表达式、IANA 时区和提醒内容。", reminderLoadFailed: "无法加载提醒,草稿仍已保留。",
|
|
384
385
|
diagramLoading: "正在渲染图表…", diagramRenderFailed: "图表无法显示,以下为源代码。", resourceLoading: "正在加载文件…", resourceFailed: "无法加载此文件。", resourceDownload: "下载", resourceMoreActions: "{name} 的更多操作", resourcePreview: "预览", resourceHide: "收起预览", zoomImage: "查看大图", imagePreviewTitle: "图片预览", imageZoomControls: "图片缩放", zoomIn: "放大", zoomOut: "缩小", zoomReset: "重置缩放", installTitle: "安装 OC Chat", installBody: "添加到主屏幕,获得全屏聊天体验。", installAction: "安装", installHow: "如何安装", installNotNow: "暂不", installIosGuide: "点击共享按钮,然后选择“添加到主屏幕”。",
|
|
386
|
+
pwaUpdateTitle: "有可用更新", pwaUpdateBody: "新版本已准备好。可以立即刷新,或下次打开时再升级。", pwaUpdateNow: "立即升级", pwaUpdateLater: "稍后",
|
|
385
387
|
announcementDelete: "删除公告",
|
|
386
388
|
announcementNew: "新建公告", announcementEmpty: "暂无公告。", announcementLoading: "正在加载公告…",
|
|
387
389
|
announcementLoadFailed: "无法加载公告,草稿仍已保留。", announcementSaved: "公告已保存。", announcementDeleted: "公告已删除。",
|
|
@@ -412,7 +414,7 @@ export const messages = {
|
|
|
412
414
|
shortcutsTitle: "键盘快捷键", shortcutsLead: "ChatRoom 快捷键。按 {modifier} + / 打开此列表。",
|
|
413
415
|
shortcutsOpen: "全部快捷键",
|
|
414
416
|
shortcutsWriting: "输入", shortcutsSend: "发送消息", shortcutsNewline: "换行",
|
|
415
|
-
shortcutsMention: "选择要提及的成员", shortcutsRooms: "房间",
|
|
417
|
+
shortcutsMention: "选择要提及的成员", shortcutsRooms: "房间", shortcutsSearch: "搜索与命令", shortcutsOpenPalette: "打开搜索与命令面板",
|
|
416
418
|
shortcutsSwitchRoom: "切换到上一个或下一个房间", shortcutsNumberRoom: "按编号切换到已加入的房间", shortcutsReading: "阅读",
|
|
417
419
|
shortcutsScroll: "输入时滚动消息", shortcutsJump: "跳到会话开头或结尾", shortcutsMenus: "菜单和对话框",
|
|
418
420
|
shortcutsClose: "关闭当前菜单、面板或对话框",
|
|
@@ -421,7 +423,7 @@ export const messages = {
|
|
|
421
423
|
paletteScopeHint: "按 Tab 在当前房间和全部已加入房间之间切换", paletteSearchMode: "搜索", paletteCommandMode: "命令",
|
|
422
424
|
paletteSearching: "正在搜索…", paletteNoResults: "没有找到消息。", paletteNoCommands: "没有匹配的命令。",
|
|
423
425
|
paletteResults: ({ count }) => `${count} 条结果`, paletteCommandsHint: "常用命令",
|
|
424
|
-
paletteHint: "↑↓ 选择 · Enter 打开 · Tab 切换范围 · Esc 关闭", paletteSearchFailed: "搜索失败,请重试。",
|
|
426
|
+
paletteHint: "↑↓ 或 Alt+1–9 选择 · Enter 打开 · Tab 切换范围 · Esc 关闭", paletteSearchFailed: "搜索失败,请重试。",
|
|
425
427
|
paletteLeaveRoom: "离开房间", paletteJumpLatest: "跳到最新消息",
|
|
426
428
|
filesTitle: "文件", filesEyebrow: "房间文件", filesFilter: "上传者", filesEveryone: "所有人",
|
|
427
429
|
filesUnknownUploader: "未知上传者", filesSummary: ({ count, size }) => `${count} 个文件 · ${size}`,
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
.copy-id.copied .copy-ok { display: inline; color: var(--accent); }
|
|
35
35
|
|
|
36
36
|
.chat-head-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
|
|
37
|
-
.chat-head .action-icon { width: 19px; height: 19px;
|
|
37
|
+
.chat-head .action-icon { width: 19px; height: 19px; }
|
|
38
38
|
.panel.question-panel { width: min(720px, calc(100vw - 32px)); max-height: min(86vh, 820px); overflow: auto; }
|
|
39
39
|
.questions-trigger { position: relative; }
|
|
40
40
|
.question-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
|
|
@@ -189,6 +189,7 @@
|
|
|
189
189
|
box-shadow: var(--shadow);
|
|
190
190
|
transition: filter .12s, transform .1s;
|
|
191
191
|
}
|
|
192
|
+
.jump .fluent-icon { width: 18px; height: 18px; }
|
|
192
193
|
.jump:hover { filter: brightness(1.07); }
|
|
193
194
|
.jump:active { transform: translateY(1px); }
|
|
194
195
|
.jump .badge {
|
|
@@ -264,13 +265,13 @@
|
|
|
264
265
|
transition: color .14s, background .14s, border-color .14s;
|
|
265
266
|
}
|
|
266
267
|
.msg.own .message-copy { align-self: flex-end; margin-right: 4px; }
|
|
267
|
-
.message-copy-icon { display: block; width: 16px; height: 16px;
|
|
268
|
+
.message-copy-icon { display: block; width: 16px; height: 16px; }
|
|
268
269
|
.message-copy:hover, .message-copy:focus-visible, .message-copy.is-flashing { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 24%, var(--line)); }
|
|
269
270
|
.message-copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
|
|
270
271
|
.message-copy-feedback { position: absolute; z-index: 25; left: 0; bottom: calc(100% + 5px); width: max-content; max-width: min(260px, calc(100vw - 32px)); padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--surface); box-shadow: var(--shadow); font-size: 11px; font-weight: 500; line-height: 1.4; text-align: left; white-space: normal; overflow-wrap: anywhere; }
|
|
271
272
|
.message-actions { display: flex; align-items: center; gap: 2px; }
|
|
272
273
|
.message-reply { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid transparent; border-radius: 8px; color: var(--ink-3); background: transparent; cursor: pointer; }
|
|
273
|
-
.message-reply-icon { display: block; width: 16px; height: 16px;
|
|
274
|
+
.message-reply-icon { display: block; width: 16px; height: 16px; }
|
|
274
275
|
.message-reply:hover, .message-reply:focus-visible { border-color: var(--line); color: var(--accent); background: var(--accent-soft); }
|
|
275
276
|
.reply-preview { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: min(940px, 100%); min-width: 0; margin: 0 auto; padding: 8px 12px; border-left: 3px solid var(--accent); border-radius: 6px; background: var(--accent-soft); }
|
|
276
277
|
.reply-preview > div { min-width: 0; flex: 1; }
|
|
@@ -297,7 +298,7 @@
|
|
|
297
298
|
.reader-panel-head .hint { margin: 0 0 4px; }
|
|
298
299
|
.reader-close { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 1px solid transparent; border-radius: 10px; color: var(--ink-2); background: transparent; font: inherit; cursor: pointer; transition: background .14s, border-color .14s, color .14s; }
|
|
299
300
|
.reader-close:hover { border-color: var(--line); color: var(--ink); background: var(--surface-2); }
|
|
300
|
-
.close-icon { width: 20px; height: 20px;
|
|
301
|
+
.close-icon { width: 20px; height: 20px; }
|
|
301
302
|
.reader-panel .receipt-reader-list li { display: grid; gap: 3px; padding: 10px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
|
|
302
303
|
.image-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 20px; overflow: hidden; border: 0; background: transparent; }
|
|
303
304
|
.image-dialog[open] { display: flex; align-items: center; justify-content: center; }
|
package/server/assets/files.css
CHANGED
|
@@ -4,11 +4,6 @@
|
|
|
4
4
|
width: 15px;
|
|
5
5
|
height: 15px;
|
|
6
6
|
flex: none;
|
|
7
|
-
fill: none;
|
|
8
|
-
stroke: currentColor;
|
|
9
|
-
stroke-width: 1.7;
|
|
10
|
-
stroke-linecap: round;
|
|
11
|
-
stroke-linejoin: round;
|
|
12
7
|
}
|
|
13
8
|
|
|
14
9
|
#filesDialog {
|
|
@@ -115,11 +110,6 @@
|
|
|
115
110
|
.file-kind svg {
|
|
116
111
|
width: 18px;
|
|
117
112
|
height: 18px;
|
|
118
|
-
fill: none;
|
|
119
|
-
stroke: currentColor;
|
|
120
|
-
stroke-width: 1.7;
|
|
121
|
-
stroke-linecap: round;
|
|
122
|
-
stroke-linejoin: round;
|
|
123
113
|
}
|
|
124
114
|
.file-kind[data-kind="audio"] { color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, var(--surface)); }
|
|
125
115
|
.file-kind[data-kind="video"] { color: var(--mention-blue); background: color-mix(in srgb, var(--mention-blue) 12%, var(--surface)); }
|
|
@@ -175,11 +165,6 @@
|
|
|
175
165
|
.file-action svg {
|
|
176
166
|
width: 16px;
|
|
177
167
|
height: 16px;
|
|
178
|
-
fill: none;
|
|
179
|
-
stroke: currentColor;
|
|
180
|
-
stroke-width: 1.7;
|
|
181
|
-
stroke-linecap: round;
|
|
182
|
-
stroke-linejoin: round;
|
|
183
168
|
}
|
|
184
169
|
.file-action:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 24%, transparent); background: var(--accent-soft); }
|
|
185
170
|
.file-action.file-action-delete:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 28%, transparent); background: var(--danger-soft); }
|