@alexsun-top/opencode-chat-room 0.7.4 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +6 -6
  3. package/README.zh-CN.md +6 -6
  4. package/cli.ts +20 -0
  5. package/dist/cli.js +18 -0
  6. package/package.json +1 -1
  7. package/server/assets/FLUENT-ICONS-LICENSE +25 -0
  8. package/server/assets/NOTICE.txt +2 -1
  9. package/server/assets/attachments.css +1 -1
  10. package/server/assets/base.css +29 -7
  11. package/server/assets/chat/doc-preview.js +113 -0
  12. package/server/assets/chat/events.js +6 -0
  13. package/server/assets/chat/files.js +25 -16
  14. package/server/assets/chat/history-loader.js +36 -26
  15. package/server/assets/chat/icons.js +15 -0
  16. package/server/assets/chat/index.js +3 -1
  17. package/server/assets/chat/locales/de.js +6 -5
  18. package/server/assets/chat/locales/es.js +6 -5
  19. package/server/assets/chat/locales/fr.js +6 -5
  20. package/server/assets/chat/locales/it.js +6 -5
  21. package/server/assets/chat/locales/ja.js +6 -5
  22. package/server/assets/chat/locales/ko.js +6 -5
  23. package/server/assets/chat/markdown.js +17 -37
  24. package/server/assets/chat/messages.js +4 -9
  25. package/server/assets/chat/palette.js +50 -34
  26. package/server/assets/chat/pwa.js +67 -9
  27. package/server/assets/chat/recall.js +3 -2
  28. package/server/assets/chat/replies.js +2 -1
  29. package/server/assets/chat/rooms.js +12 -4
  30. package/server/assets/chat/shortcuts.js +1 -1
  31. package/server/assets/chat/state.js +12 -10
  32. package/server/assets/chat/system-messages.js +7 -1
  33. package/server/assets/code-highlight.css +0 -5
  34. package/server/assets/conversation.css +5 -4
  35. package/server/assets/doc-preview.css +158 -0
  36. package/server/assets/edit-room.css +8 -0
  37. package/server/assets/files.css +0 -15
  38. package/server/assets/fluent-icons.svg +42 -0
  39. package/server/assets/icons.css +9 -0
  40. package/server/assets/palette.css +1 -15
  41. package/server/assets/recall.css +2 -2
  42. package/server/assets/responsive.css +4 -4
  43. package/server/assets/room-create.css +1 -1
  44. package/server/assets/settings.css +13 -6
  45. package/server/chat.html +93 -57
  46. package/server/sw.js +10 -1
  47. package/src/tui/app.mjs +16 -1
  48. package/src/tui/http.mjs +109 -10
  49. package/src/tui/info-app.mjs +435 -0
  50. package/src/tui/info-content.mjs +198 -0
  51. package/src/tui/join-app.mjs +71 -0
  52. package/src/tui/main.mjs +23 -4
  53. package/src/tui/markdown.mjs +269 -0
  54. package/src/tui/message-app.mjs +177 -0
  55. package/src/tui/message-view.mjs +128 -0
  56. package/src/tui/palette-app.mjs +85 -9
  57. package/src/tui/palette.mjs +17 -2
  58. package/src/tui/reminder-app.mjs +189 -0
  59. package/src/tui/room-settings-app.mjs +249 -0
  60. package/src/tui/ui-content.mjs +136 -93
  61. package/src/tui/ui-overlay-view.mjs +255 -0
  62. package/src/tui/ui-view.mjs +2 -190
  63. package/src/tui/ui.mjs +103 -1
@@ -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
- const ICONS = {
3
- refresh: '<svg aria-hidden="true" viewBox="0 0 24 24"><path d="M20 7v5h-5M4 17v-5h5"/><path d="M5.6 9a7 7 0 0 1 11.8-2L20 12M4 12l2.6 5a7 7 0 0 0 11.8-2"/></svg>',
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: "refresh", keywords: "reload rooms", run: () => void app.refreshRoomList?.() },
31
- { id: "create", label: t("createRoom"), icon: "plus", keywords: "new room", focusComposer: false,
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: "gear", keywords: "preferences theme language", focusComposer: false, run: () => app.openSettings?.() },
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: "members", keywords: "people roster", focusComposer: false, run: () => app.$("#btnMembers")?.click() },
37
- { id: "questions", label: t("questions"), icon: "questions", keywords: "answers", focusComposer: false, run: () => app.$("#btnQuestions")?.click() },
38
- { id: "announcements", label: t("announcements"), icon: "announcements", keywords: "notice board", focusComposer: false, run: () => app.$("#btnAnnouncements")?.click() },
39
- { id: "reminders", label: t("reminders"), icon: "reminders", keywords: "schedule alarm", focusComposer: false, run: () => app.$("#btnReminders")?.click() },
40
- { id: "leave", label: t("paletteLeaveRoom"), icon: "leave", keywords: "exit quit", focusComposer: false, run: () => app.leaveRoom?.(false) },
41
- { id: "latest", label: t("paletteJumpLatest"), icon: "latest", keywords: "bottom newest", run: () => app.jumpToBottom?.() },
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) => row.setAttribute("aria-selected", String(index === selected)));
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 icon = document.createElement("span");
96
- icon.className = "palette-icon";
97
- icon.innerHTML = ICONS[item.icon] || ICONS.command;
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(icon, label, enter);
101
+ row.append(badge, label, enter);
106
102
  } else {
107
103
  const top = document.createElement("span");
108
104
  top.className = "palette-result-top";
@@ -235,15 +231,18 @@ export function initPalette(app) {
235
231
  const token = ++sequence;
236
232
  const value = input.value;
237
233
  if (!value.trim()) { showCommands(""); return; }
238
- if (value.startsWith(">")) { showCommands(value.slice(1)); return; }
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
- render([], null);
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); }, 120);
245
+ searchTimer = setTimeout(() => { void executeSearch(text, token); }, SEARCH_DEBOUNCE_MS);
247
246
  };
248
247
 
249
248
  const highlightHit = (item) => {
@@ -293,7 +292,7 @@ export function initPalette(app) {
293
292
  syncScope();
294
293
  const value = input.value;
295
294
  if (!value.trim()) showCommands("");
296
- else if (value.startsWith(">")) showCommands(value.slice(1));
295
+ else if (value.startsWith("/")) showCommands(value.slice(1));
297
296
  else scheduleSearch();
298
297
  };
299
298
 
@@ -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(); });
@@ -332,8 +331,12 @@ export function initPalette(app) {
332
331
  // A stacked dialog keeps its own focus; otherwise the composer owns the page.
333
332
  if (document.querySelector("dialog[open]")) return;
334
333
  const composer = app.$("#msgInput");
335
- if (app.state.room && !app.$("#chatView")?.hidden && composer?.contentEditable === "true") composer.focus({ preventScroll: true });
336
- else if (!app.state.room) app.$("#inRoomId")?.focus({ preventScroll: true });
334
+ if (app.state.room && !app.$("#chatView")?.hidden && composer?.contentEditable === "true") {
335
+ const selection = getSelection();
336
+ const selectionInside = Boolean(selection?.anchorNode && composer.contains(selection.anchorNode));
337
+ composer.focus({ preventScroll: true });
338
+ if (!selectionInside) composer.setCaret?.(composer.value.length);
339
+ } else if (!app.state.room) app.$("#inRoomId")?.focus({ preventScroll: true });
337
340
  });
338
341
  });
339
342
 
@@ -360,6 +363,19 @@ export function initPalette(app) {
360
363
  if (!items.length || selected < 0) return;
361
364
  event.preventDefault();
362
365
  activate(items[selected]);
366
+ return;
367
+ }
368
+ if (event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
369
+ const digit = /^(?:Digit|Numpad)([1-9])$/.exec(event.code)?.[1] ?? (/^[1-9]$/.test(event.key) ? event.key : null);
370
+ const index = digit ? Number(digit) - 1 : -1;
371
+ if (digit) {
372
+ event.preventDefault();
373
+ event.stopPropagation();
374
+ if (index >= 0 && index < items.length) {
375
+ selected = index;
376
+ syncSelection();
377
+ }
378
+ }
363
379
  }
364
380
  });
365
381
 
@@ -378,7 +394,7 @@ export function initPalette(app) {
378
394
  syncScope();
379
395
  if (!dialog.open) return;
380
396
  const value = input.value;
381
- if (!value.trim() || value.startsWith(">")) showCommands(value.startsWith(">") ? value.slice(1) : "");
397
+ if (!value.trim() || value.startsWith("/")) showCommands(value.startsWith("/") ? value.slice(1) : "");
382
398
  else scheduleSearch();
383
399
  };
384
400
  }
@@ -1,18 +1,76 @@
1
- export function initPwa() {
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
- // Only a worker that replaced an older one means a new release is ready; the first
7
- // install takes control too, and reloading then would throw away what the page just did.
8
- const replacing = Boolean(navigator.serviceWorker.controller);
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 (!replacing || reloaded) return;
12
- reloaded = true;
13
- location.reload();
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").catch(() => {});
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 = '<svg class="message-recall-icon" aria-hidden="true" viewBox="0 0 24 24"><path d="M20 12a8 8 0 1 1-2.34-5.66"/><path d="M20 4v6h-6"/></svg>';
8
- const RECALLED_ICON = '<svg class="recalled-icon" aria-hidden="true" viewBox="0 0 24 24"><path d="M20 12a8 8 0 1 1-2.34-5.66"/><path d="M20 4v6h-6"/></svg>';
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 = '<svg class="message-reply-icon" aria-hidden="true" viewBox="0 0 24 24"><path d="M9 10 4 15l5 5M4 15h9a7 7 0 0 0 7-7V5"/></svg>';
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) app.activateRoom(room.id);
73
- else {
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
- app.renderMessages(false);
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
- void app.refreshRoomList();
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 ? 6 : -6}px`);
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" });
@@ -248,7 +248,8 @@ export const messages = {
248
248
  reminderEdit: "Edit", reminderEditHeading: "Edit reminder", reminderSave: "Save changes",
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
- 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.",
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", docPreviewEyebrow: "Markdown preview", docPreviewFailed: "This document could not be loaded.", docPreviewEmpty: "This document is empty.", 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,22 +284,22 @@ 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",
290
291
  paletteTitle: "Search and commands", paletteSearchLabel: "Search messages",
291
- palettePlaceholder: "Search messages, or type > for commands", paletteScopeRoom: "This room", paletteScopeAll: "All rooms",
292
+ palettePlaceholder: "Search messages, or type / for commands", paletteScopeRoom: "This room", paletteScopeAll: "All rooms",
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}`,
299
300
  filesLoading: "Loading files…", filesLoadFailed: "Could not load files. Try again.", filesEmpty: "No files in this room yet.",
300
301
  filesEmptyFiltered: "No files from this uploader.", filesLoadMore: "Load more",
301
- filesHint: "Preview images, audio, and video. Download any file.",
302
+ filesHint: "Preview images, audio, video, and Markdown. Download any file.",
302
303
  filesPreviewFailed: "Could not load this preview.", filesDownloadFailed: "Could not download this file.",
303
304
  filesPreviewLabel: ({ name }) => `Preview ${name}`, filesDownloadLabel: ({ name }) => `Download ${name}`,
304
305
  filesDeleteLabel: ({ name }) => `Delete ${name}`, filesRefresh: "Refresh files",
@@ -381,7 +382,8 @@ export const messages = {
381
382
  reminderEdit: "编辑", reminderEditHeading: "编辑提醒", reminderSave: "保存修改",
382
383
  reminderCreated: "提醒已创建。", reminderUpdated: "提醒已更新。", reminderDeleted: "提醒已删除。",
383
384
  reminderInvalid: "请检查日期、5 字段 CRON 表达式、IANA 时区和提醒内容。", reminderLoadFailed: "无法加载提醒,草稿仍已保留。",
384
- diagramLoading: "正在渲染图表…", diagramRenderFailed: "图表无法显示,以下为源代码。", resourceLoading: "正在加载文件…", resourceFailed: "无法加载此文件。", resourceDownload: "下载", resourceMoreActions: "{name} 的更多操作", resourcePreview: "预览", resourceHide: "收起预览", zoomImage: "查看大图", imagePreviewTitle: "图片预览", imageZoomControls: "图片缩放", zoomIn: "放大", zoomOut: "缩小", zoomReset: "重置缩放", installTitle: "安装 OC Chat", installBody: "添加到主屏幕,获得全屏聊天体验。", installAction: "安装", installHow: "如何安装", installNotNow: "暂不", installIosGuide: "点击共享按钮,然后选择“添加到主屏幕”。",
385
+ diagramLoading: "正在渲染图表…", diagramRenderFailed: "图表无法显示,以下为源代码。", resourceLoading: "正在加载文件…", resourceFailed: "无法加载此文件。", resourceDownload: "下载", resourceMoreActions: "{name} 的更多操作", resourcePreview: "预览", resourceHide: "收起预览", docPreviewEyebrow: "Markdown 预览", docPreviewFailed: "无法加载此文档。", docPreviewEmpty: "此文档为空。", 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,22 +414,22 @@ 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: "关闭当前菜单、面板或对话框",
419
421
  paletteTitle: "搜索与命令", paletteSearchLabel: "搜索消息",
420
- palettePlaceholder: "搜索消息,输入 > 使用命令", paletteScopeRoom: "当前房间", paletteScopeAll: "全部房间",
422
+ palettePlaceholder: "搜索消息,输入 / 使用命令", paletteScopeRoom: "当前房间", paletteScopeAll: "全部房间",
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}`,
428
430
  filesLoading: "正在加载文件…", filesLoadFailed: "无法加载文件,请重试。", filesEmpty: "这个房间还没有文件。",
429
431
  filesEmptyFiltered: "此上传者没有文件。", filesLoadMore: "加载更多",
430
- filesHint: "可预览图片、音频和视频,所有文件都可下载。",
432
+ filesHint: "可预览图片、音频、视频和 Markdown,所有文件都可下载。",
431
433
  filesPreviewFailed: "无法加载预览。", filesDownloadFailed: "无法下载此文件。",
432
434
  filesPreviewLabel: ({ name }) => `预览 ${name}`, filesDownloadLabel: ({ name }) => `下载 ${name}`,
433
435
  filesDeleteLabel: ({ name }) => `删除 ${name}`, filesRefresh: "刷新文件",
@@ -23,7 +23,13 @@ function formatLine(line, app) {
23
23
 
24
24
  export function formatSystemMessage(message, app) {
25
25
  // `<at>@name</at>` is an editor token; system rows and previews show the plain mention.
26
- const text = String(message?.text ?? "").replace(/<at>([\s\S]*?)<\/at>/g, "$1");
26
+ let text = String(message?.text ?? "").replace(/<at>([\s\S]*?)<\/at>/g, "$1");
27
+ // Resource markers are internal IDs. A rail preview must not expose them.
28
+ const resources = /\[\[resource:[0-9a-f-]{36}\]\]/gi;
29
+ if (resources.test(text)) {
30
+ text = text.replace(resources, "").trim();
31
+ text = text ? `${text} · ${app.t("attachments")}` : app.t("attachments");
32
+ }
27
33
  if (message?.senderId !== "system") return text;
28
34
  // One edit can log several changes joined by "; "; translate each line.
29
35
  return text.split("; ").map((line) => formatLine(line, app)).join("; ");
@@ -78,11 +78,6 @@
78
78
  .code-tool-icon {
79
79
  width: 16px;
80
80
  height: 16px;
81
- fill: none;
82
- stroke: currentColor;
83
- stroke-width: 1.7;
84
- stroke-linecap: round;
85
- stroke-linejoin: round;
86
81
  }
87
82
 
88
83
  .code-check-icon { display: none; }
@@ -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; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
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; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
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; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
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; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.8; }
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; }