@alexsun-top/opencode-chat-room 0.6.9 → 0.7.0

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 (49) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +5 -4
  3. package/README.zh-CN.md +5 -4
  4. package/package.json +1 -1
  5. package/plugin.ts +49 -27
  6. package/server/assets/HIGHLIGHT-LICENSE +29 -0
  7. package/server/assets/NOTICE.txt +2 -1
  8. package/server/assets/base.css +5 -50
  9. package/server/assets/chat/editor.js +97 -16
  10. package/server/assets/chat/events.js +39 -6
  11. package/server/assets/chat/index.js +4 -0
  12. package/server/assets/chat/join-requests.js +37 -17
  13. package/server/assets/chat/locales/de.js +115 -0
  14. package/server/assets/chat/locales/es.js +115 -0
  15. package/server/assets/chat/locales/fr.js +115 -0
  16. package/server/assets/chat/locales/index.js +8 -0
  17. package/server/assets/chat/locales/it.js +115 -0
  18. package/server/assets/chat/locales/ja.js +115 -0
  19. package/server/assets/chat/locales/ko.js +115 -0
  20. package/server/assets/chat/markdown.js +100 -0
  21. package/server/assets/chat/members.js +1 -1
  22. package/server/assets/chat/mentions.js +1 -0
  23. package/server/assets/chat/message-polling.js +28 -5
  24. package/server/assets/chat/messages.js +20 -2
  25. package/server/assets/chat/panels.js +0 -9
  26. package/server/assets/chat/questions.js +11 -3
  27. package/server/assets/chat/recall.js +3 -3
  28. package/server/assets/chat/replies.js +1 -1
  29. package/server/assets/chat/room-watcher.js +4 -0
  30. package/server/assets/chat/settings.js +72 -0
  31. package/server/assets/chat/shortcuts.js +30 -5
  32. package/server/assets/chat/state.js +43 -21
  33. package/server/assets/chat/viewport.js +23 -0
  34. package/server/assets/code-highlight.css +124 -0
  35. package/server/assets/conversation.css +21 -3
  36. package/server/assets/highlight-10.7.3.min.js +1358 -0
  37. package/server/assets/responsive.css +3 -5
  38. package/server/assets/settings.css +138 -0
  39. package/server/chat-server.ts +4 -1
  40. package/server/chat.html +96 -30
  41. package/server/join-requests.ts +11 -0
  42. package/server/sw.js +3 -0
  43. package/skills/chatroom/SKILL.md +2 -1
  44. package/src/agent/admin-client.ts +13 -5
  45. package/src/agent/announcement-tool.ts +6 -6
  46. package/src/center/center-client.ts +17 -17
  47. package/src/center/reminder-client.ts +5 -5
  48. package/src/rooms/resource-read.ts +16 -9
  49. package/src/rooms/resource-upload.ts +2 -2
@@ -1,11 +1,18 @@
1
- // The shortcut sheet lists genuine ChatRoom shortcuts. Alt+/ opens it; no
2
- // per-control badges, no native Tab/Enter hints, and no background observers.
1
+ // The shortcut sheet lists genuine ChatRoom shortcuts. Alt+/ opens it; the
2
+ // composer keeps one visible entry and no per-control badges.
3
3
  export function initShortcuts(app) {
4
4
  const dialog = app.$("#shortcutsDialog");
5
5
  if (!dialog) return;
6
6
  const heading = app.$("#shortcutsHeading");
7
7
  const thread = app.$("#thread");
8
- const triggers = [...document.querySelectorAll("[data-shortcuts]")];
8
+ const modifier = /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent) ? "Option" : "Alt";
9
+ document.body.classList.toggle("is-mac", modifier === "Option");
10
+ document.querySelectorAll(".shortcut-mod").forEach((key) => { key.textContent = modifier; });
11
+ const lead = app.$("#shortcutsLead");
12
+ if (lead) {
13
+ lead._i18nValues = { modifier };
14
+ lead.textContent = app.t("shortcutsLead", { modifier });
15
+ }
9
16
 
10
17
  const openSheet = () => {
11
18
  if (dialog.open || document.querySelector("dialog[open]")) return;
@@ -15,17 +22,35 @@ export function initShortcuts(app) {
15
22
  heading?.focus();
16
23
  };
17
24
 
18
- triggers.forEach((button) => button.addEventListener("click", openSheet));
25
+ app.$("#btnShortcuts")?.addEventListener("mousedown", (event) => event.preventDefault());
26
+ app.$("#btnShortcuts")?.addEventListener("click", openSheet);
19
27
  app.$("#btnCloseShortcuts")?.addEventListener("click", () => dialog.close());
20
28
  dialog.addEventListener("close", () => requestAnimationFrame(() => app.focusComposer?.()));
21
29
  const scrollToEdge = (bottom) => {
22
30
  if (!thread) return;
31
+ const reduced = matchMedia("(prefers-reduced-motion: reduce)").matches;
23
32
  app.state.userScrollIntentUntil = performance.now() + 700;
24
33
  if (!bottom) {
25
34
  app.state.jumpToLoadedTop = true;
26
- setTimeout(() => { app.state.jumpToLoadedTop = false; }, 100);
35
+ clearTimeout(app.state.jumpToLoadedTopTimer);
36
+ app.state.jumpToLoadedTopTimer = setTimeout(() => { app.state.jumpToLoadedTop = false; }, reduced ? 100 : 800);
27
37
  }
28
38
  thread.scrollTop = bottom ? thread.scrollHeight : 0;
39
+ app.animateThreadJump?.(bottom);
40
+ };
41
+ app.animateThreadJump = (bottom) => {
42
+ const list = app.$("#msgList");
43
+ if (!list) return;
44
+ list.classList.remove("thread-jump-up", "thread-jump-down");
45
+ void list.offsetWidth;
46
+ list.classList.add(bottom ? "thread-jump-down" : "thread-jump-up");
47
+ };
48
+ app.animateRoomSwitch = (direction) => {
49
+ const list = app.$("#msgList");
50
+ if (!list) return;
51
+ list.classList.remove("room-switch-next", "room-switch-prev");
52
+ void list.offsetWidth;
53
+ list.classList.add(direction > 0 ? "room-switch-next" : "room-switch-prev");
29
54
  };
30
55
  document.addEventListener("keydown", (event) => {
31
56
  if (event.defaultPrevented || event.isComposing) return;
@@ -1,3 +1,5 @@
1
+ import { extraLocales } from "./locales/index.js";
2
+
1
3
  // Upper bound on messages kept in memory per open room; older pages load on scroll.
2
4
  export const LOADED_MESSAGE_LIMIT = 5000;
3
5
 
@@ -137,6 +139,7 @@ export function createAuth(storage, fetcher, translate = (key) => key, sessionSt
137
139
  set name(value) { ensureIdentity(); browserIdentity.name = String(value ?? "").slice(0, 64); writeSession("chat.name", browserIdentity.name || null); saveIdentity(); },
138
140
  get token() { return read("chat.token") || ""; }, set token(value) { write("chat.token", value || null); },
139
141
  get locale() { return read("chat.locale") || "en"; }, set locale(value) { write("chat.locale", value || null); },
142
+ get theme() { return read("chat.theme") || "system"; }, set theme(value) { write("chat.theme", value || null); },
140
143
 
141
144
  get joinedRoomIds() {
142
145
  try {
@@ -197,7 +200,7 @@ export function createAuth(storage, fetcher, translate = (key) => key, sessionSt
197
200
  return { LS: auth, saveToken, api, apiBlob };
198
201
  }
199
202
 
200
- const messages = {
203
+ export const messages = {
201
204
  en: {
202
205
  brand: "OC Chat", documentTitle: "OC Chat",
203
206
  roomTitle: ({ name }) => `${name} · OC Chat`,
@@ -212,7 +215,7 @@ const messages = {
212
215
  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
216
  approvalRequired: "Approval required", joinRequired: "Approval required", joinPendingStatus: "Approval pending",
214
217
  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",
218
+ 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.`, joinPendingCancel: "Cancel request", joinPendingCancelError: "Could not cancel the request. Try again.",
216
219
  joinPendingGoneTitle: "Request not pending", joinPendingGoneBody: "It may have been denied or cleared. You can send a new request.", joinPendingAgain: "Request again",
217
220
  joinPendingError: "Could not check the request. Try again.", joinPendingRoomGone: "This room is gone, or you no longer have access.",
218
221
  joinNameTaken: "That name is already used in this room. Choose another name.",
@@ -221,7 +224,6 @@ const messages = {
221
224
  joinRequestApproveLabel: ({ name }) => `Approve ${name}`, joinRequestDenyLabel: ({ name }) => `Deny ${name}`,
222
225
  joinRequestTime: ({ time }) => `Requested ${time}`, joinRequestApproved: ({ name }) => `${name} approved.`, joinRequestDenied: ({ name }) => `${name} denied.`,
223
226
  joinRequestActionFailed: ({ message }) => `Could not update the request: ${message}`, membersWithRequests: ({ count }) => `Members, ${count} join request${count === 1 ? "" : "s"} pending`,
224
- joinRequestBadgeOne: " request", joinRequestBadgeMany: " requests",
225
227
  accessKeyTitle: "Access key", accessKeyHint: "This server asks for an access key. It stays in this browser and is sent with each request.",
226
228
  tokenOptional: "Access token (optional)", bearerToken: "Bearer token",
227
229
  tokenPlaceholder: "Enter if the server requires it", save: "Save",
@@ -230,7 +232,7 @@ const messages = {
230
232
  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",
231
233
  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.",
232
234
  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.",
233
- noAdminAgent: "None", roomNameRequired: "Room name is required", openQuestions: ({ count }) => `${count} unanswered question${count === 1 ? "" : "s"}`,
235
+ noAdminAgent: "None", openQuestions: ({ count }) => `${count} unanswered question${count === 1 ? "" : "s"}`,
234
236
  newRoom: "Create a room",
235
237
  copyRoomIdTitle: ({ id }) => `Click to copy the full room ID: ${id}`, copied: "Copied",
236
238
  members: "Members", membersCount: ({ count }) => `Members (${count})`, noMembers: "No members yet.", profileMenu: "Your profile and settings",
@@ -255,6 +257,8 @@ const messages = {
255
257
  answerFailed: "Reply failed. Your draft is still here.", answerTooLong: "Reply must be 5,000 characters or fewer.", questionAlreadyAnswered: "This question was answered elsewhere.",
256
258
  adminBindingGuide: "Choose a room and an Agent in it. Send the invitation privately to finish setup.", adminRoomLabel: "Administrator room", adminDesignateAgent: "Invite Agent",
257
259
  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).",
260
+ themeLabel: "Theme", themeSystem: "System", themeLight: "Light", themeDark: "Dark", themeForest: "Forest", themeSand: "Sand",
261
+ settingsLocalHint: "Language and theme are saved in this browser.",
258
262
  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}”?`,
259
263
  leave: "Leave", reconnecting: "Connection lost. Retrying…", messageList: "Message list",
260
264
  noMessages: "No messages yet. Say something.", latestMessages: "Back to latest messages",
@@ -269,8 +273,9 @@ const messages = {
269
273
  joinArrow: "Join →", joinDirectTitle: "Click to join directly", mentionEmpty: "No matching members",
270
274
  joined: "Joined", joinAction: "Join room", unreadMessages: ({ count }) => `${count} unread`,
271
275
  mentionHint: "↑↓ Select · Enter to confirm · Esc to close", today: "Today", yesterday: "Yesterday",
272
- keyboardHints: "Keyboard shortcuts", shortcutsLabel: "Shortcuts",
273
- shortcutsTitle: "Keyboard shortcuts", shortcutsLead: "ChatRoom shortcuts. Press Alt + / to open this list.",
276
+
277
+ shortcutsTitle: "Keyboard shortcuts", shortcutsLead: "ChatRoom shortcuts. Press {modifier} + / to open this list.",
278
+ shortcutsOpen: "All shortcuts",
274
279
  shortcutsWriting: "Writing", shortcutsSend: "Send the message", shortcutsNewline: "Start a new line",
275
280
  shortcutsMention: "Choose a member to mention", shortcutsRooms: "Rooms",
276
281
  shortcutsSwitchRoom: "Switch to the previous or next room", shortcutsReading: "Reading",
@@ -278,7 +283,7 @@ const messages = {
278
283
  shortcutsClose: "Close the open menu, panel, or dialog",
279
284
  earlierMessages: "Earlier messages omitted", messagesBetweenOmitted: "Messages between this reading point and latest are omitted.", you: "You", saved: "Saved",
280
285
  savedMemory: "Saved for this tab only", copyFailed: ({ id }) => `Copy failed. Copy manually: ${id}`,
281
- copyMessage: "Copy", copiedMessage: "Copied", copyMessageFailed: "Could not copy. Select and copy the message manually.",
286
+ copyMessage: "Copy", copiedMessage: "Copied", copyMessageFailed: "Could not copy. Select and copy the message manually.", wrapCode: "Wrap code",
282
287
  replyMessage: "Reply", replyingTo: "Replying to", cancelReply: "Cancel reply", replyOpenOriginal: "View original message", replyOriginalUnavailable: "Original message is unavailable.", replyOriginalRecalled: "Original message was recalled.",
283
288
  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",
284
289
  identityChanged: "This browser identity changed in another tab. Reload this tab before continuing.",
@@ -324,7 +329,7 @@ const messages = {
324
329
  joinPolicyEditHint: "新成员需经人类管理员审核。关闭后,所有待审核申请都会被清除。", joinPolicyOpenConfirm: "关闭加入审核?所有待审核的加入申请都会被清除。",
325
330
  approvalRequired: "需审核加入", joinRequired: "需审核加入", joinPendingStatus: "等待审核",
326
331
  joinPendingTitle: "等待审核", joinPendingBody: ({ name }) => `加入“${name}”的申请已发送,需人类管理员审核通过后才能进入。`,
327
- joinPendingHint: "可以离开此页面,申请会保留;稍后可在房间列表查看。", joinPendingNotice: ({ name }) => `已发送加入“${name}”的申请,正在等待人类管理员审核。`, joinPendingCheck: "再看一次", joinPendingStop: "不再等待",
332
+ joinPendingHint: "可以离开此页面,申请会保留;稍后可在房间列表查看。", joinPendingNotice: ({ name }) => `已发送加入“${name}”的申请,正在等待人类管理员审核。`, joinPendingCancel: "取消申请", joinPendingCancelError: "取消申请失败,请重试。",
328
333
  joinPendingGoneTitle: "申请已不在等待", joinPendingGoneBody: "申请可能已被拒绝或清除,可以重新发送。", joinPendingAgain: "重新申请",
329
334
  joinPendingError: "无法检查申请状态,请重试。", joinPendingRoomGone: "房间不存在,或你已无权访问。",
330
335
  joinNameTaken: "这个昵称已被房间里的成员使用,请换一个。",
@@ -333,7 +338,6 @@ const messages = {
333
338
  joinRequestApproveLabel: ({ name }) => `通过 ${name} 的加入申请`, joinRequestDenyLabel: ({ name }) => `拒绝 ${name} 的加入申请`,
334
339
  joinRequestTime: ({ time }) => `申请于 ${time}`, joinRequestApproved: ({ name }) => `已通过 ${name} 的申请。`, joinRequestDenied: ({ name }) => `已拒绝 ${name} 的申请。`,
335
340
  joinRequestActionFailed: ({ message }) => `操作失败:${message}`, membersWithRequests: ({ count }) => `成员,${count} 个待审核加入申请`,
336
- joinRequestBadgeOne: " 个申请", joinRequestBadgeMany: " 个申请",
337
341
  accessKeyTitle: "访问密钥", accessKeyHint: "这个服务器需要访问密钥。密钥保存在当前浏览器里,并随每个请求发送。",
338
342
  bearerToken: "Bearer Token", tokenPlaceholder: "服务器要求时填写", save: "保存",
339
343
  tokenHint: "若服务器设置了访问令牌(401),所有请求都会带上它。", existingRooms: "房间",
@@ -341,7 +345,7 @@ const messages = {
341
345
  editRoom: "编辑房间", roomOwnerOnlyTitle: "仅房主或管理员可修改", roomOwnerOnlyNote: ({ owner }) => `只有房主或房间管理员可以修改这些设置。这个房间属于 ${owner}。`, roomNameLabel: "房间名称", roomDescriptionLabel: "描述", adminAgentLabel: "管理员 Agent", roomOwnerBadge: "房主", roomAdminBadge: "管理员",
342
346
  adminIdsLabel: "成员管理员", adminIdsHint: "这些成员可以修改房间信息、管理成员、删除文件并指定接任者。房主始终拥有这些权限。", adminIdsEmpty: "房间里暂无其他成员。", newOwnerLabel: "新房主", newOwnerHint: "可以把房间交给房间里的另一个人。只有房主可以操作;Agent 不能成为房主。",
343
347
  successorLabel: "房主离开后的接任者", successorNone: "最早加入的成员", successorHint: "房主离开后,此人接任房主;管理员离开后,此人接任管理员。留空则最早加入的成员接任房主。", ownerOnlySettingsNote: "只有房主可以更改管理员 Agent 或移交房间。", adminAgentHint: "被指定的 Agent 可用 admin 工具查看此房间及其历史。只有房主可以更改,留空表示不指定。",
344
- noAdminAgent: "不指定", roomNameRequired: "房间名称不能为空", openQuestions: ({ count }) => `${count} 个待回答的问题`,
348
+ noAdminAgent: "不指定", openQuestions: ({ count }) => `${count} 个待回答的问题`,
345
349
  newRoom: "创建房间",
346
350
  copyRoomIdTitle: ({ id }) => `点击复制完整房间 ID:${id}`, copied: "已复制", members: "成员",
347
351
  membersCount: ({ count }) => `成员 ${count}`, noMembers: "暂无成员", settings: "设置", profileMenu: "个人资料和设置",
@@ -367,7 +371,9 @@ const messages = {
367
371
  adminBindingGuide: "选择管理员房间和其中的 Agent,再将邀请私下发送给该 Agent 完成设置。", adminRoomLabel: "管理员房间", adminDesignateAgent: "邀请 Agent",
368
372
  adminAccess: "管理", adminToken: "管理令牌", openAdministration: "打开管理面板", administration: "管理面板", designations: "管理绑定", adminRoom: "管理员房间", targetRoom: "Agent 所属房间", adminScopeNote: "请选择管理员房间内的 Agent。管理员可以管理所有房间。", adminRoomBadge: "管理", targetAgent: "已注册 Agent", designate: "指定管理员", revokeDesignation: "撤销绑定", globalStatus: "全局状态", adminTasks: "任务", taskText: "任务内容", dispatchTask: "派发任务", timers: "定时任务", planName: "定时任务名称", createTimer: "创建定时任务",
369
373
  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}”?`,
370
- tokenRequired: "服务器要求访问令牌(401)。", leave: "离开", reconnecting: "连接中断,正在重试…",
374
+ tokenRequired: "服务器要求访问令牌(401)。",
375
+ themeLabel: "主题", themeSystem: "跟随系统", themeLight: "浅色", themeDark: "深色", themeForest: "森林", themeSand: "沙丘",
376
+ settingsLocalHint: "语言和主题保存在当前浏览器中。", leave: "离开", reconnecting: "连接中断,正在重试…",
371
377
  messageList: "消息列表", noMessages: "还没有消息,说点什么吧。", latestMessages: "回到最新消息",
372
378
  mentionMembers: "选择要提及的成员", messagePlaceholder: "输入消息,Enter 发送",
373
379
  attachments: "附件", addFiles: "添加文件", dropFilesHere: "将文件拖到这里添加",
@@ -378,8 +384,9 @@ const messages = {
378
384
  fileTooLarge: "文件超过服务器当前大小限制。",
379
385
  send: "发送", roomMeta: ({ members, count }) => `${members} 人 · ${count} 条消息`, joinArrow: "加入 →",
380
386
  joinDirectTitle: "点击直接加入", mentionEmpty: "没有匹配的成员", mentionHint: "↑↓ 选择 · Enter 确认 · Esc 关闭",
381
- keyboardHints: "键盘快捷键", shortcutsLabel: "快捷键",
382
- shortcutsTitle: "键盘快捷键", shortcutsLead: "ChatRoom 快捷键。按 Alt + / 打开此列表。",
387
+
388
+ shortcutsTitle: "键盘快捷键", shortcutsLead: "ChatRoom 快捷键。按 {modifier} + / 打开此列表。",
389
+ shortcutsOpen: "全部快捷键",
383
390
  shortcutsWriting: "输入", shortcutsSend: "发送消息", shortcutsNewline: "换行",
384
391
  shortcutsMention: "选择要提及的成员", shortcutsRooms: "房间",
385
392
  shortcutsSwitchRoom: "切换到上一个或下一个房间", shortcutsReading: "阅读",
@@ -388,7 +395,7 @@ const messages = {
388
395
  joined: "已加入", joinAction: "加入房间", unreadMessages: ({ count }) => `${count} 条未读`,
389
396
  today: "今天", yesterday: "昨天", earlierMessages: "更早的消息已省略", messagesBetweenOmitted: "此阅读位置与最新消息之间的部分消息已省略。", you: "我", saved: "已保存",
390
397
  savedMemory: "仅保存于当前标签页", copyFailed: ({ id }) => `复制失败,请手动复制:${id}`,
391
- copyMessage: "复制", copiedMessage: "已复制", copyMessageFailed: "复制失败,请手动选择并复制消息。",
398
+ copyMessage: "复制", copiedMessage: "已复制", copyMessageFailed: "复制失败,请手动选择并复制消息。", wrapCode: "自动换行",
392
399
  replyMessage: "回复", replyingTo: "回复给", cancelReply: "取消回复", replyOpenOriginal: "查看原始消息", replyOriginalUnavailable: "原始消息不可用。", replyOriginalRecalled: "原消息已撤回。",
393
400
  recallMessage: "撤回", recallSystemMessage: "撤回这条房间通知", recallSystemConfirm: "撤回这条房间通知?所有人都会看到“消息已撤回”。", recallConfirm: "撤回这条消息?所有人都会看到“消息已撤回”。", recallAdminConfirm: ({ name }) => `撤回 ${name} 的消息?所有人都会看到“消息已撤回”。`, recallFailed: "撤回失败,请重试。", messageRecalled: "消息已撤回", recalledBy: ({ name }) => `${name} 撤回`, showRecalled: "查看原文", hideRecalled: "收起原文", revealFailed: "加载失败,重试",
394
401
  identityChanged: "此浏览器身份已在另一个标签页中更改,请重新加载此标签页后继续。",
@@ -416,6 +423,7 @@ const messages = {
416
423
  confirmTitle: "请确认", cancel: "取消", confirmAction: "确认",
417
424
  receiptEvidence_displayed: "已显示在屏幕上", receiptEvidence_tool: "通过房间工具读取", receiptEvidence_context: "进入上下文",
418
425
  },
426
+ ...extraLocales,
419
427
  };
420
428
 
421
429
  app.t = (key, values = {}) => {
@@ -428,7 +436,9 @@ app.LS = LS;
428
436
  app.api = api;
429
437
  app.apiBlob = apiBlob;
430
438
  app.setToken = saveToken;
431
- app.locale = LS.locale === "zh-CN" ? "zh-CN" : "en";
439
+ export const SUPPORTED_LOCALES = ["en", "zh-CN", "ja", "ko", "fr", "de", "es", "it"];
440
+ const intlLocales = { en: "en-US", "zh-CN": "zh-CN", ja: "ja-JP", ko: "ko-KR", fr: "fr-FR", de: "de-DE", es: "es-ES", it: "it-IT" };
441
+ app.locale = messages[LS.locale] ? LS.locale : "en";
432
442
  app.state.joinedIds = new Set(LS.joinedRoomIds);
433
443
  app.state.drafts = new Map(Object.entries(LS.drafts));
434
444
  app.state.positions = new Map(Object.entries(LS.positions).map(([id, value]) => [id, value && typeof value === "object" ? value : Number(value) || 0]));
@@ -493,12 +503,12 @@ app.applyLocale = () => {
493
503
  } else app.updateTitle();
494
504
  };
495
505
  app.setLocale = (locale) => {
496
- app.locale = locale === "zh-CN" ? "zh-CN" : "en";
506
+ app.locale = messages[locale] ? locale : "en";
497
507
  LS.locale = app.locale;
498
508
  app.applyLocale();
499
509
  };
500
510
 
501
- app.intlLocale = () => app.locale === "zh-CN" ? "zh-CN" : "en-US";
511
+ app.intlLocale = () => intlLocales[app.locale] || "en-US";
502
512
  app.fmtTime = (timestamp) => {
503
513
  const date = new Date(timestamp);
504
514
  return date.toDateString() === new Date().toDateString()
@@ -540,12 +550,24 @@ app.updateTitle = () => {
540
550
  for (const [id, entry] of app.state.rooms) total += id === active ? app.state.unread : entry.unreadIds.size + (entry.unreadOverflow ? 100 : 0);
541
551
  document.title = total ? `(${total}) ${title}` : title;
542
552
  };
543
- app.setOnline = (online) => { app.$("#connBar").hidden = online; };
553
+ app.setOnline = (online) => {
554
+ app.$("#connBar").hidden = online;
555
+ // A recovered connection makes the network send warning stale, but an auth
556
+ // or validation error still needs the user's attention.
557
+ if (online) app.hideSendError("sendNetwork");
558
+ };
544
559
  app.showSendError = (key, values = {}) => {
545
- app.setText(app.$("#sendError"), key, values);
546
- app.$("#sendError").hidden = false;
560
+ const node = app.$("#sendError");
561
+ app.setText(node, key, values);
562
+ node.dataset.errorKey = key;
563
+ node.hidden = false;
564
+ };
565
+ app.hideSendError = (key) => {
566
+ const node = app.$("#sendError");
567
+ if (key && node.dataset.errorKey !== key) return;
568
+ node.hidden = true;
569
+ delete node.dataset.errorKey;
547
570
  };
548
- app.hideSendError = () => { app.$("#sendError").hidden = true; };
549
571
  app.showJoinError = (key, values = {}) => {
550
572
  app.setText(app.$("#joinError"), key, values);
551
573
  app.$("#joinError").hidden = false;
@@ -0,0 +1,23 @@
1
+ // Keep the app inside the visible area when a soft keyboard opens (iOS does not resize the layout viewport).
2
+ export function initViewport() {
3
+ const root = document.documentElement;
4
+ const viewport = window.visualViewport;
5
+ if (!viewport) return;
6
+ let lastHeight = viewport.height;
7
+
8
+ const sync = () => {
9
+ root.style.setProperty("--app-height", `${Math.round(viewport.height)}px`);
10
+ if (viewport.height < lastHeight - 80 && document.activeElement?.id === "msgInput") {
11
+ requestAnimationFrame(() => {
12
+ const thread = document.querySelector("#thread");
13
+ if (thread) thread.scrollTop = thread.scrollHeight;
14
+ });
15
+ }
16
+ lastHeight = viewport.height;
17
+ };
18
+ viewport.addEventListener("resize", sync);
19
+ viewport.addEventListener("scroll", sync);
20
+ window.addEventListener("resize", sync);
21
+ sync();
22
+ if (matchMedia("(pointer: coarse)").matches) document.querySelector("#msgInput")?.setAttribute("enterkeyhint", "enter");
23
+ }
@@ -0,0 +1,124 @@
1
+ /* Fenced code blocks: a quiet frame, a hover toolbar, and readable tokens in every palette. */
2
+
3
+ :root {
4
+ --code-bg: color-mix(in srgb, var(--ink) 5%, var(--surface));
5
+ --code-keyword: var(--accent);
6
+ --code-string: color-mix(in srgb, var(--mention-blue) 82%, var(--ink));
7
+ --code-number: color-mix(in srgb, var(--warning) 68%, var(--ink));
8
+ --code-title: color-mix(in srgb, var(--accent) 72%, var(--ink));
9
+ --code-comment: color-mix(in srgb, var(--ink-3) 78%, var(--ink));
10
+ }
11
+
12
+ .code-block { position: relative; min-width: 0; }
13
+
14
+ .code-block pre {
15
+ margin: 0;
16
+ padding: 10px 12px;
17
+ border: 1px solid var(--line);
18
+ border-radius: 10px;
19
+ background: var(--code-bg);
20
+ overflow-x: auto;
21
+ }
22
+
23
+ .code-block pre code {
24
+ display: block;
25
+ white-space: pre;
26
+ }
27
+
28
+ .code-block.is-wrapped pre { overflow-x: hidden; }
29
+ .code-block.is-wrapped pre code { white-space: pre-wrap; overflow-wrap: anywhere; }
30
+
31
+ .code-toolbar {
32
+ position: absolute;
33
+ z-index: 2;
34
+ top: 4px;
35
+ right: 4px;
36
+ display: flex;
37
+ gap: 2px;
38
+ padding: 2px;
39
+ border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
40
+ border-radius: 9px;
41
+ background: color-mix(in srgb, var(--surface) 52%, transparent);
42
+ -webkit-backdrop-filter: blur(8px);
43
+ backdrop-filter: blur(8px);
44
+ box-shadow: 0 1px 3px rgb(20 40 32 / .08);
45
+ opacity: 0;
46
+ pointer-events: none;
47
+ transition: opacity .14s ease;
48
+ }
49
+
50
+ .code-block:hover .code-toolbar,
51
+ .code-block:focus-within .code-toolbar {
52
+ opacity: 1;
53
+ pointer-events: auto;
54
+ }
55
+
56
+ /* Touch screens have no hover: keep the controls reachable at all times. */
57
+ @media (hover: none), (pointer: coarse) {
58
+ .code-toolbar { opacity: 1; pointer-events: auto; }
59
+ }
60
+
61
+ .code-tool-button {
62
+ display: grid;
63
+ place-items: center;
64
+ width: 32px;
65
+ height: 32px;
66
+ padding: 0;
67
+ border: 0;
68
+ border-radius: 7px;
69
+ color: var(--ink-2);
70
+ background: transparent;
71
+ cursor: pointer;
72
+ transition: color .14s, background .14s;
73
+ }
74
+
75
+ .code-tool-button:hover { color: var(--accent); background: var(--accent-soft); }
76
+ .code-tool-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
77
+ .code-tool-button[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
78
+ .code-tool-button.is-copied { color: var(--accent); background: var(--accent-soft); }
79
+ .code-tool-button.is-copy-failed { color: var(--danger); background: var(--danger-soft); }
80
+
81
+ .code-tool-icon {
82
+ width: 16px;
83
+ height: 16px;
84
+ fill: none;
85
+ stroke: currentColor;
86
+ stroke-width: 1.7;
87
+ stroke-linecap: round;
88
+ stroke-linejoin: round;
89
+ }
90
+
91
+ .code-check-icon { display: none; }
92
+ .code-tool-button.is-copied .code-copy-icon { display: none; }
93
+ .code-tool-button.is-copied .code-check-icon { display: block; }
94
+
95
+ /* highlight.js tokens use palette tokens, so dark, forest, and sand stay legible. */
96
+ .code-block .hljs { color: var(--ink); }
97
+ .code-block .hljs-comment,
98
+ .code-block .hljs-quote { color: var(--code-comment); font-style: italic; }
99
+ .code-block .hljs-keyword,
100
+ .code-block .hljs-selector-tag,
101
+ .code-block .hljs-literal,
102
+ .code-block .hljs-section,
103
+ .code-block .hljs-doctag { color: var(--code-keyword); font-weight: 650; }
104
+ .code-block .hljs-string,
105
+ .code-block .hljs-regexp,
106
+ .code-block .hljs-addition,
107
+ .code-block .hljs-template-tag,
108
+ .code-block .hljs-template-variable { color: var(--code-string); }
109
+ .code-block .hljs-number,
110
+ .code-block .hljs-symbol,
111
+ .code-block .hljs-bullet,
112
+ .code-block .hljs-built_in,
113
+ .code-block .hljs-type { color: var(--code-number); }
114
+ .code-block .hljs-title,
115
+ .code-block .hljs-title.function_,
116
+ .code-block .hljs-title.class_,
117
+ .code-block .hljs-attr,
118
+ .code-block .hljs-attribute,
119
+ .code-block .hljs-property,
120
+ .code-block .hljs-selector-class,
121
+ .code-block .hljs-selector-id { color: var(--code-title); }
122
+ .code-block .hljs-deletion { color: var(--danger); }
123
+ .code-block .hljs-emphasis { font-style: italic; }
124
+ .code-block .hljs-strong { font-weight: 700; }
@@ -76,6 +76,12 @@
76
76
  .profile-trigger .rail-avatar { width: 25px; height: 25px; font-size: 12px; font-weight: 700; }
77
77
  .chip.danger { color: var(--danger); }
78
78
  .chip.danger:hover { border-color: var(--danger); background: var(--danger-soft); }
79
+ .chip.keys-entry { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; font-size: 10.5px; line-height: 1; }
80
+ .composer-meta .chip.keys-entry { margin-right: auto; }
81
+ .composer-meta .chip.keys-entry .keys-key { min-width: 15px; height: 16px; padding: 0 3px; font-size: 9px; }
82
+ .composer-meta .chip.keys-entry .keys-sep { font-size: 9px; }
83
+ .chip.keys-entry .action-label { line-height: 1; }
84
+ @media (max-width: 560px) { .composer-meta .chip.keys-entry .action-label { display: none; } }
79
85
 
80
86
  .anchor { position: relative; }
81
87
  .panel {
@@ -111,7 +117,7 @@
111
117
  #memberList .member-activity + .member-actions { grid-column: 2; grid-row: 2; }
112
118
  #memberList .member-action { white-space: normal; }
113
119
  #memberList li:last-child { border-bottom: none; }
114
- #chatSettings [data-i18n="privacyNote"] { min-height: 63px; line-height: 21px; }
120
+
115
121
  .m-time { font-size: 11.5px; color: var(--ink-3); }
116
122
  .member-activity { flex: none; padding: 2px 6px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: 10px; }
117
123
  .member-activity.working { color: var(--accent); background: var(--accent-soft); }
@@ -201,6 +207,7 @@
201
207
  .msg { display: flex; flex-direction: column; margin-bottom: 16px; }
202
208
  .msg.in, .sys.in, .day-sep.in { animation: msg-in .25s ease both; }
203
209
  .msg.own { align-items: flex-end; }
210
+ .msg.pending .msg-text { opacity: .62; }
204
211
  .msg.repeat { margin-bottom: 8px; }
205
212
  .msg-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 3px; }
206
213
  .msg-name { font-size: 13px; font-weight: 650; color: var(--ink-2); }
@@ -483,9 +490,10 @@
483
490
  resize: none;
484
491
  overflow-y: hidden;
485
492
  }
486
- #msgInput:empty, #msgInput:has(> br:only-child), #msgInput:has(> div:only-child > br:only-child) { height: 50px !important; }
493
+ #msgInput[data-empty="true"] { height: 50px !important; }
487
494
  .message-editor { white-space: pre-wrap; overflow-wrap: anywhere; outline: none; }
488
- .message-editor:empty::before, .message-editor:has(> br:only-child)::before, .message-editor:has(> div:only-child > br:only-child)::before { content: attr(aria-placeholder); position: absolute; inset: 12px 13px auto; overflow: hidden; color: var(--ink-3); pointer-events: none; text-overflow: ellipsis; white-space: nowrap; }
495
+ #msgInput br[data-chat-tail] { line-height: 0; font-size: 0; }
496
+ .message-editor[data-empty="true"]::before { content: attr(aria-placeholder); position: absolute; inset: 12px 13px auto; overflow: hidden; color: var(--ink-3); pointer-events: none; text-overflow: ellipsis; white-space: nowrap; }
489
497
  .editor-mention { display: inline-block; padding: 1px 7px; border: 1px solid color-mix(in srgb, var(--mention-blue) 32%, transparent); border-radius: 999px; color: var(--mention-blue); background: color-mix(in srgb, var(--mention-blue) 14%, transparent); font-size: .92em; font-weight: 600; vertical-align: baseline; white-space: nowrap; }
490
498
  #btnSend { padding: 12px 22px; }
491
499
  .send-error { margin: 0; font-size: 12.5px; color: var(--danger); }
@@ -497,3 +505,13 @@
497
505
  .failed-reply-context { flex: 0 0 100%; overflow: hidden; color: var(--accent); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
498
506
  .failed-message button { flex: none; border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; background: var(--surface); color: var(--ink-2); font: inherit; font-size: 12px; cursor: pointer; }
499
507
  .failed-message button:disabled { opacity: .5; cursor: default; }
508
+
509
+ @keyframes room-switch-next { from { opacity: 0; transform: translateY(8px); } }
510
+ @keyframes room-switch-prev { from { opacity: 0; transform: translateY(-8px); } }
511
+ #msgList.room-switch-next { animation: room-switch-next .22s ease-out; }
512
+ #msgList.room-switch-prev { animation: room-switch-prev .22s ease-out; }
513
+
514
+ @keyframes thread-jump-up { from { opacity: .45; transform: translateY(6px); } }
515
+ @keyframes thread-jump-down { from { opacity: .45; transform: translateY(-6px); } }
516
+ #msgList.thread-jump-up { animation: thread-jump-up .18s ease-out; }
517
+ #msgList.thread-jump-down { animation: thread-jump-down .18s ease-out; }