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

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 (72) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +11 -4
  3. package/README.zh-CN.md +11 -4
  4. package/cli.ts +26 -6
  5. package/dist/cli.js +7804 -0
  6. package/package.json +19 -6
  7. package/plugin.ts +7 -4
  8. package/server/admin-auth.ts +1 -1
  9. package/server/admin-routes.ts +2 -2
  10. package/server/admin-state.ts +2 -1
  11. package/server/assets/chat/admin.js +43 -3
  12. package/server/assets/chat/announcements.js +5 -3
  13. package/server/assets/chat/confirm-dialog.js +12 -2
  14. package/server/assets/chat/create-room-dialog.js +5 -3
  15. package/server/assets/chat/events.js +32 -7
  16. package/server/assets/chat/files.js +368 -0
  17. package/server/assets/chat/index.js +6 -0
  18. package/server/assets/chat/locales/de.js +17 -1
  19. package/server/assets/chat/locales/es.js +17 -1
  20. package/server/assets/chat/locales/fr.js +17 -1
  21. package/server/assets/chat/locales/it.js +17 -1
  22. package/server/assets/chat/locales/ja.js +17 -1
  23. package/server/assets/chat/locales/ko.js +17 -1
  24. package/server/assets/chat/message-polling.js +61 -6
  25. package/server/assets/chat/message-window.js +28 -0
  26. package/server/assets/chat/messages.js +29 -4
  27. package/server/assets/chat/palette.js +384 -0
  28. package/server/assets/chat/rooms.js +8 -3
  29. package/server/assets/chat/search.js +137 -0
  30. package/server/assets/chat/settings.js +11 -5
  31. package/server/assets/chat/state.js +34 -2
  32. package/server/assets/edit-room.css +77 -0
  33. package/server/assets/files.css +237 -0
  34. package/server/assets/palette.css +277 -0
  35. package/server/assets/responsive.css +3 -2
  36. package/server/assets/settings.css +6 -3
  37. package/server/chat-server.ts +46 -29
  38. package/server/chat.html +127 -31
  39. package/server/http-server.ts +182 -0
  40. package/server/join-requests.ts +4 -4
  41. package/server/manifest.webmanifest +1 -1
  42. package/server/member-routes.ts +3 -3
  43. package/server/message-recall-routes.ts +1 -1
  44. package/server/newrooms.ts +4 -4
  45. package/server/resource-routes.ts +19 -4
  46. package/server/room-join.ts +1 -1
  47. package/server/room-payload.ts +1 -1
  48. package/server/sw.js +3 -0
  49. package/server/wake.ts +1 -1
  50. package/src/README.md +4 -2
  51. package/src/config/file-config.ts +294 -0
  52. package/src/rooms/resource-read.ts +2 -1
  53. package/src/rooms/resource-upload.ts +6 -3
  54. package/src/rooms/resources.ts +7 -2
  55. package/src/runtime/watch.ts +13 -8
  56. package/src/state/receiver-state.ts +3 -5
  57. package/src/state/sqlite-state.ts +11 -7
  58. package/src/state/sqlite.ts +80 -0
  59. package/src/state/store.ts +1 -0
  60. package/src/tui/app.mjs +417 -0
  61. package/src/tui/config.mjs +194 -0
  62. package/src/tui/http.mjs +103 -0
  63. package/src/tui/main.mjs +176 -0
  64. package/src/tui/messages.mjs +67 -0
  65. package/src/tui/palette-app.mjs +265 -0
  66. package/src/tui/palette.mjs +101 -0
  67. package/src/tui/session.mjs +40 -0
  68. package/src/tui/ui-content.mjs +426 -0
  69. package/src/tui/ui-theme.mjs +60 -0
  70. package/src/tui/ui-view.mjs +452 -0
  71. package/src/tui/ui.mjs +262 -0
  72. package/src/tests/announcement-board.ts +0 -186
@@ -135,6 +135,7 @@ export function initRooms(app) {
135
135
  app.rendered = 0;
136
136
  app.firstMessageId = null;
137
137
  app.state.pendingAction = null;
138
+ app.state.focusMessageId = null;
138
139
  LS.roomId = roomId;
139
140
  app.showChat();
140
141
  app.renderHead();
@@ -249,9 +250,12 @@ export function initRooms(app) {
249
250
  $("#btnCreate").disabled = busy;
250
251
  };
251
252
 
252
- app.leaveRoom = (silent = false) => {
253
- const roomId = app.state.room?.id;
254
- if (roomId) void app.removeJoinedRoom(roomId, { leaveServer: !silent });
253
+ app.leaveRoom = async (silent = false) => {
254
+ const room = app.state.room;
255
+ if (!room) return;
256
+ if (!silent && !(await app.confirmAction(app.t("leaveRoomConfirm", { name: room.name })))) return;
257
+ app.closePanels?.();
258
+ void app.removeJoinedRoom(room.id, { leaveServer: !silent });
255
259
  };
256
260
  app.removeJoinedRoom = async (roomId, { leaveServer = false, reason = false, reconcile = false } = {}) => {
257
261
  if (!reconcile) invalidateRoomList();
@@ -269,6 +273,7 @@ export function initRooms(app) {
269
273
  app.state.unread = 0;
270
274
  app.rendered = 0;
271
275
  app.firstMessageId = null;
276
+ app.state.focusMessageId = null;
272
277
  $("#msgList").textContent = "";
273
278
  $("#msgInput").contentEditable = "false";
274
279
  $("#msgInput").setAttribute("aria-disabled", "true"); $("#msgInput").tabIndex = -1;
@@ -0,0 +1,137 @@
1
+ import { LOADED_MESSAGE_LIMIT } from "./state.js";
2
+ import { flashMessageRow } from "./message-window.js";
3
+
4
+ // Palette search: local scan first, then lazy history pages until the room's
5
+ // loaded window fills up. There is no server-side search endpoint.
6
+ export const SEARCH_RESULT_LIMIT = 100;
7
+ export const SEARCH_MESSAGE_LIMIT = LOADED_MESSAGE_LIMIT;
8
+ const PAGE_LIMIT = 100;
9
+ const MAX_PAGES_PER_ROOM = Math.ceil(SEARCH_MESSAGE_LIMIT / PAGE_LIMIT);
10
+
11
+ export function initSearch(app) {
12
+ app.searchMessages = (query, scope = "room") => searchMessages(app, query, scope);
13
+ app.openSearchHit = (hit) => openSearchHit(app, hit);
14
+ }
15
+
16
+ export async function searchMessages(app, query, scope = "room") {
17
+ const needle = String(query ?? "").trim().toLocaleLowerCase();
18
+ if (!needle) return [];
19
+ const activeId = app.state.room?.id;
20
+ const roomIds = [...app.state.rooms.keys()]
21
+ .filter((roomId) => scope === "all" || roomId === activeId)
22
+ .sort((left, right) => {
23
+ if (left === activeId) return -1;
24
+ if (right === activeId) return 1;
25
+ return latestAt(app, right) - latestAt(app, left);
26
+ });
27
+ const hits = [];
28
+ for (const roomId of roomIds) {
29
+ await collectRoomHits(app, roomId, needle, hits);
30
+ // Keep the page responsive while several rooms are scanned.
31
+ await new Promise((resolve) => setTimeout(resolve, 0));
32
+ }
33
+ return hits
34
+ .sort((left, right) => right.createdAt - left.createdAt || (right.seq ?? 0) - (left.seq ?? 0))
35
+ .slice(0, SEARCH_RESULT_LIMIT);
36
+ }
37
+
38
+ export async function openSearchHit(app, hit) {
39
+ const roomId = hit?.roomId, messageId = hit?.messageId;
40
+ if (!roomId || !messageId) return false;
41
+ const entry = app.state.rooms.get(roomId);
42
+ if (!entry?.room) return false;
43
+ if (!entry.room.messages.some((message) => message.id === messageId)) {
44
+ const seq = Number(hit.seq);
45
+ // beforeSeq is exclusive: seq + 1 puts the target at the end of the page.
46
+ if (!Number.isSafeInteger(seq)) return false;
47
+ try {
48
+ const page = await app.api(`/rooms/${encodeURIComponent(roomId)}/history?beforeSeq=${seq + 1}&limit=${PAGE_LIMIT}`);
49
+ if (app.state.rooms.get(roomId) !== entry) return false;
50
+ const messages = Array.isArray(page.messages) ? page.messages : [];
51
+ mergeHistory(entry, roomId, messages);
52
+ if (page.hasMore) {
53
+ // Continue upward pagination from the oldest message now loaded.
54
+ const oldest = entry.room.messages.find((message) => Number.isSafeInteger(message.seq))?.seq;
55
+ if (Number.isSafeInteger(oldest)) entry.historyBeforeSeq = oldest;
56
+ } else {
57
+ entry.historyComplete = true;
58
+ entry.historyBeforeSeq = null;
59
+ }
60
+ app.cacheRoomSoon?.(roomId);
61
+ if (!entry.room.messages.some((message) => message.id === messageId)) return false;
62
+ } catch { return false; }
63
+ }
64
+ if (app.state.room?.id !== roomId) app.activateRoom(roomId);
65
+ if (app.state.room?.id !== roomId) return false;
66
+ app.state.room = app.state.rooms.get(roomId)?.room || app.state.room;
67
+ app.state.focusMessageId = messageId;
68
+ app.state.followBottom = false;
69
+ app.state.readAnchorGuard = null;
70
+ app.renderMessages(false);
71
+ const row = document.querySelector(`[data-msg-id="${CSS.escape(messageId)}"]`);
72
+ if (!row) return false;
73
+ flashMessageRow(app, row);
74
+ return true;
75
+ }
76
+
77
+ async function collectRoomHits(app, roomId, needle, hits) {
78
+ const entry = app.state.rooms.get(roomId);
79
+ if (!entry?.room) return;
80
+ const seen = new Set();
81
+ const scan = (messages) => {
82
+ for (const message of messages) {
83
+ if (seen.has(message.id)) continue;
84
+ seen.add(message.id);
85
+ if (message.recalledAt || message.pending || message.senderId === "system") continue;
86
+ const text = typeof message.text === "string" ? message.text : "";
87
+ if (!text || !text.toLocaleLowerCase().includes(needle)) continue;
88
+ hits.push({
89
+ roomId,
90
+ roomName: entry.room.name || roomId,
91
+ messageId: message.id,
92
+ seq: message.seq,
93
+ sender: message.senderId,
94
+ createdAt: message.createdAt,
95
+ text,
96
+ snippet: snippetFor(text, needle),
97
+ });
98
+ }
99
+ };
100
+ scan(entry.room.messages);
101
+ let pages = 0;
102
+ while (!entry.historyComplete && Number.isSafeInteger(entry.historyBeforeSeq)
103
+ && entry.room.messages.length < SEARCH_MESSAGE_LIMIT && pages++ < MAX_PAGES_PER_ROOM) {
104
+ try {
105
+ const page = await app.api(`/rooms/${encodeURIComponent(roomId)}/history?beforeSeq=${entry.historyBeforeSeq}&limit=${PAGE_LIMIT}`);
106
+ if (app.state.rooms.get(roomId) !== entry) return;
107
+ const messages = Array.isArray(page.messages) ? page.messages : [];
108
+ scan(messages);
109
+ mergeHistory(entry, roomId, messages);
110
+ const next = typeof page.nextBeforeSeq === "number" ? page.nextBeforeSeq : null;
111
+ entry.historyComplete = !page.hasMore;
112
+ if (entry.historyComplete) entry.historyBeforeSeq = null;
113
+ else if (next === null || next >= entry.historyBeforeSeq) break;
114
+ else entry.historyBeforeSeq = next;
115
+ } catch { break; }
116
+ }
117
+ }
118
+
119
+ function mergeHistory(entry, roomId, messages) {
120
+ const merged = new Map(entry.room.messages.map((message) => [message.id, message]));
121
+ for (const message of messages) if (!merged.has(message.id)) merged.set(message.id, { ...message, roomId });
122
+ entry.room.messages = [...merged.values()]
123
+ .sort((left, right) => left.createdAt - right.createdAt || (left.seq ?? 0) - (right.seq ?? 0))
124
+ .slice(-LOADED_MESSAGE_LIMIT);
125
+ }
126
+
127
+ function latestAt(app, roomId) {
128
+ return app.state.rooms.get(roomId)?.room.messages.at(-1)?.createdAt ?? 0;
129
+ }
130
+
131
+ function snippetFor(text, needle) {
132
+ const flat = text.replace(/\s+/g, " ").trim();
133
+ const index = flat.toLocaleLowerCase().indexOf(needle);
134
+ if (index < 0) return flat.slice(0, 140);
135
+ const start = Math.max(0, index - 40), end = Math.min(flat.length, index + needle.length + 60);
136
+ return `${start > 0 ? "…" : ""}${flat.slice(start, end)}${end < flat.length ? "…" : ""}`;
137
+ }
@@ -7,7 +7,7 @@ export function initSettings(app) {
7
7
  if (!dialog) return;
8
8
  const tokenInput = $("#inTokenChat"), tokenHint = $("#tokenHint");
9
9
  const contentInput = $("#inContentTransition");
10
- const pageInput = $("#inPageStep");
10
+ const pageInput = $("#inPageStep"), pageValue = $("#pageStepValue");
11
11
  const tabs = [...dialog.querySelectorAll('[role="tab"]')];
12
12
  const scheme = matchMedia("(prefers-color-scheme: dark)");
13
13
  let opener = null;
@@ -61,6 +61,7 @@ export function initSettings(app) {
61
61
  syncThemeInputs();
62
62
  if (contentInput) contentInput.checked = app.LS.contentTransition;
63
63
  if (pageInput) pageInput.value = String(app.LS.pageStep);
64
+ if (pageValue) pageValue.textContent = `${app.LS.pageStep}%`;
64
65
  tokenInput.value = app.LS.token;
65
66
  if (tokenHint) tokenHint.hidden = !token;
66
67
  if (dialog.open) {
@@ -88,21 +89,26 @@ export function initSettings(app) {
88
89
  $("#btnCloseSettings")?.addEventListener("click", close);
89
90
  dialog.addEventListener("click", (event) => { if (event.target === dialog) close(); });
90
91
  dialog.addEventListener("cancel", () => opener?.setAttribute("aria-expanded", "false"));
92
+ pageInput?.addEventListener("input", () => {
93
+ app.LS.pageStep = pageInput.value;
94
+ pageInput.value = String(app.LS.pageStep);
95
+ if (pageValue) pageValue.textContent = `${app.LS.pageStep}%`;
96
+ });
91
97
  dialog.addEventListener("change", (event) => {
92
98
  if (event.target instanceof HTMLInputElement && event.target.name === "theme") app.setTheme(event.target.value);
93
99
  if (event.target === contentInput) app.LS.contentTransition = contentInput.checked;
94
100
  if (event.target === pageInput) {
95
101
  app.LS.pageStep = pageInput.value;
96
102
  pageInput.value = String(app.LS.pageStep);
103
+ if (pageValue) pageValue.textContent = `${app.LS.pageStep}%`;
97
104
  }
98
105
  });
99
106
  dialog.addEventListener("close", () => {
100
107
  const target = opener;
101
108
  opener = null;
102
- if (target?.isConnected) {
103
- target.setAttribute("aria-expanded", "false");
104
- target.focus({ preventScroll: true });
105
- }
109
+ if (target?.isConnected) target.setAttribute("aria-expanded", "false");
110
+ if (app.focusChatComposer?.({ force: true })) return;
111
+ if (target?.isConnected) target.focus({ preventScroll: true });
106
112
  });
107
113
  // The palette follows the system through its media query; only the browser chrome needs a nudge.
108
114
  scheme.addEventListener("change", () => { if (app.LS.theme === "system") syncThemeColor(); });
@@ -231,7 +231,7 @@ export const messages = {
231
231
  tokenPlaceholder: "Enter if the server requires it", save: "Save",
232
232
  tokenHint: "If the server requires an access token (401), all requests will include it.",
233
233
  existingRooms: "Rooms", noRooms: "No rooms yet. Create one.", copyRoomId: "Copy room ID", loadingHistory: "Loading earlier messages",
234
- 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",
234
+ editRoom: "Edit room", editRoomSections: "Edit room sections", editRoomDetails: "Room details", editRoomJoining: "Joining & approval", editRoomMembers: "Members & roles", editRoomOwnership: "Ownership", 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",
235
235
  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.",
236
236
  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.",
237
237
  noAdminAgent: "None", openQuestions: ({ count }) => `${count} unanswered question${count === 1 ? "" : "s"}`,
@@ -287,6 +287,21 @@ export const messages = {
287
287
  shortcutsSwitchRoom: "Switch to the previous or next room", shortcutsNumberRoom: "Switch to a joined room by number", shortcutsReading: "Reading",
288
288
  shortcutsScroll: "Scroll messages while typing", shortcutsJump: "Jump to the start or end of the conversation", shortcutsMenus: "Menus and dialogs",
289
289
  shortcutsClose: "Close the open menu, panel, or dialog",
290
+ paletteTitle: "Search and commands", paletteSearchLabel: "Search messages",
291
+ palettePlaceholder: "Search messages, or type > for commands", paletteScopeRoom: "This room", paletteScopeAll: "All rooms",
292
+ paletteScopeHint: "Tab switches between this room and all joined rooms", paletteSearchMode: "Search", paletteCommandMode: "Commands",
293
+ paletteSearching: "Searching…", paletteNoResults: "No messages found.", paletteNoCommands: "No matching commands.",
294
+ 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
+ paletteLeaveRoom: "Leave room", paletteJumpLatest: "Jump to latest",
297
+ filesTitle: "Files", filesEyebrow: "Room files", filesFilter: "Uploaded by", filesEveryone: "Everyone",
298
+ filesUnknownUploader: "Unknown uploader", filesSummary: ({ count, size }) => `${count} file${count === 1 ? "" : "s"} · ${size}`,
299
+ filesLoading: "Loading files…", filesLoadFailed: "Could not load files. Try again.", filesEmpty: "No files in this room yet.",
300
+ filesEmptyFiltered: "No files from this uploader.", filesLoadMore: "Load more",
301
+ filesHint: "Preview images, audio, and video. Download any file.",
302
+ filesPreviewFailed: "Could not load this preview.", filesDownloadFailed: "Could not download this file.",
303
+ filesPreviewLabel: ({ name }) => `Preview ${name}`, filesDownloadLabel: ({ name }) => `Download ${name}`,
304
+ filesDeleteLabel: ({ name }) => `Delete ${name}`, filesRefresh: "Refresh files",
290
305
  earlierMessages: "Earlier messages omitted", messagesBetweenOmitted: "Messages between this reading point and latest are omitted.", you: "You", saved: "Saved",
291
306
  savedMemory: "Saved for this tab only", copyFailed: ({ id }) => `Copy failed. Copy manually: ${id}`,
292
307
  copyMessage: "Copy", copiedMessage: "Copied", copyMessageFailed: "Could not copy. Select and copy the message manually.", wrapCode: "Wrap code",
@@ -308,6 +323,7 @@ export const messages = {
308
323
  roomsMenu: "Open room list", closeRoomList: "Close room list",
309
324
  direct: "Direct", messagePrivately: "Message privately", removeMember: "Remove",
310
325
  kickConfirm: ({ name }) => `Remove ${name} from this room? They can rejoin with the room ID.`,
326
+ leaveRoomConfirm: ({ name }) => `Leave “${name}”? You will leave this room; you can rejoin later with its ID.`,
311
327
  deleteRoom: "Delete room", deleteConfirm: ({ name }) => `Delete “${name}” and all its messages? This cannot be undone.`,
312
328
  allMembers: "Everyone", messageCount: ({ count }) => `${count} / 5000`,
313
329
  pasteAsFile: ({ count }) => `Pasted ${count} characters saved as a text file`,
@@ -348,7 +364,7 @@ export const messages = {
348
364
  bearerToken: "Bearer Token", tokenPlaceholder: "服务器要求时填写", save: "保存",
349
365
  tokenHint: "若服务器设置了访问令牌(401),所有请求都会带上它。", existingRooms: "房间",
350
366
  noRooms: "还没有房间,创建一个吧。", copyRoomId: "复制房间 ID", loadingHistory: "正在加载更早的消息",
351
- editRoom: "编辑房间", roomOwnerOnlyTitle: "仅房主或管理员可修改", roomOwnerOnlyNote: ({ owner }) => `只有房主或房间管理员可以修改这些设置。这个房间属于 ${owner}。`, roomNameLabel: "房间名称", roomDescriptionLabel: "描述", adminAgentLabel: "管理员 Agent", roomOwnerBadge: "房主", roomAdminBadge: "管理员",
367
+ editRoom: "编辑房间", editRoomSections: "编辑房间分区", editRoomDetails: "房间信息", editRoomJoining: "加入与审核", editRoomMembers: "成员与角色", editRoomOwnership: "所有权", roomOwnerOnlyTitle: "仅房主或管理员可修改", roomOwnerOnlyNote: ({ owner }) => `只有房主或房间管理员可以修改这些设置。这个房间属于 ${owner}。`, roomNameLabel: "房间名称", roomDescriptionLabel: "描述", adminAgentLabel: "管理员 Agent", roomOwnerBadge: "房主", roomAdminBadge: "管理员",
352
368
  adminIdsLabel: "成员管理员", adminIdsHint: "这些成员可以修改房间信息、管理成员、删除文件并指定接任者。房主始终拥有这些权限。", adminIdsEmpty: "房间里暂无其他成员。", newOwnerLabel: "新房主", newOwnerHint: "可以把房间交给房间里的另一个人。只有房主可以操作;Agent 不能成为房主。",
353
369
  successorLabel: "房主离开后的接任者", successorNone: "最早加入的成员", successorHint: "房主离开后,此人接任房主;管理员离开后,此人接任管理员。留空则最早加入的成员接任房主。", ownerOnlySettingsNote: "只有房主可以更改管理员 Agent 或移交房间。", adminAgentHint: "被指定的 Agent 可用 admin 工具查看此房间及其历史。只有房主可以更改,留空表示不指定。",
354
370
  noAdminAgent: "不指定", openQuestions: ({ count }) => `${count} 个待回答的问题`,
@@ -400,6 +416,21 @@ export const messages = {
400
416
  shortcutsSwitchRoom: "切换到上一个或下一个房间", shortcutsNumberRoom: "按编号切换到已加入的房间", shortcutsReading: "阅读",
401
417
  shortcutsScroll: "输入时滚动消息", shortcutsJump: "跳到会话开头或结尾", shortcutsMenus: "菜单和对话框",
402
418
  shortcutsClose: "关闭当前菜单、面板或对话框",
419
+ paletteTitle: "搜索与命令", paletteSearchLabel: "搜索消息",
420
+ palettePlaceholder: "搜索消息,输入 > 使用命令", paletteScopeRoom: "当前房间", paletteScopeAll: "全部房间",
421
+ paletteScopeHint: "按 Tab 在当前房间和全部已加入房间之间切换", paletteSearchMode: "搜索", paletteCommandMode: "命令",
422
+ paletteSearching: "正在搜索…", paletteNoResults: "没有找到消息。", paletteNoCommands: "没有匹配的命令。",
423
+ paletteResults: ({ count }) => `${count} 条结果`, paletteCommandsHint: "常用命令",
424
+ paletteHint: "↑↓ 选择 · Enter 打开 · Tab 切换范围 · Esc 关闭", paletteSearchFailed: "搜索失败,请重试。",
425
+ paletteLeaveRoom: "离开房间", paletteJumpLatest: "跳到最新消息",
426
+ filesTitle: "文件", filesEyebrow: "房间文件", filesFilter: "上传者", filesEveryone: "所有人",
427
+ filesUnknownUploader: "未知上传者", filesSummary: ({ count, size }) => `${count} 个文件 · ${size}`,
428
+ filesLoading: "正在加载文件…", filesLoadFailed: "无法加载文件,请重试。", filesEmpty: "这个房间还没有文件。",
429
+ filesEmptyFiltered: "此上传者没有文件。", filesLoadMore: "加载更多",
430
+ filesHint: "可预览图片、音频和视频,所有文件都可下载。",
431
+ filesPreviewFailed: "无法加载预览。", filesDownloadFailed: "无法下载此文件。",
432
+ filesPreviewLabel: ({ name }) => `预览 ${name}`, filesDownloadLabel: ({ name }) => `下载 ${name}`,
433
+ filesDeleteLabel: ({ name }) => `删除 ${name}`, filesRefresh: "刷新文件",
403
434
  joined: "已加入", joinAction: "加入房间", unreadMessages: ({ count }) => `${count} 条未读`,
404
435
  today: "今天", yesterday: "昨天", earlierMessages: "更早的消息已省略", messagesBetweenOmitted: "此阅读位置与最新消息之间的部分消息已省略。", you: "我", saved: "已保存",
405
436
  savedMemory: "仅保存于当前标签页", copyFailed: ({ id }) => `复制失败,请手动复制:${id}`,
@@ -418,6 +449,7 @@ export const messages = {
418
449
  roomListError: "无法加载房间列表,可直接输入房间 ID 加入。", guest: "访客", roomsLabel: "房间列表",
419
450
  refreshRooms: "刷新房间", identityLabel: ({ name }) => `当前昵称:${name}`, roomsMenu: "打开房间列表", closeRoomList: "关闭房间列表", direct: "私聊",
420
451
  messagePrivately: "私聊", removeMember: "移除", kickConfirm: ({ name }) => `确定将 ${name} 移出此房间?对方仍可用房间 ID 重新加入。`,
452
+ leaveRoomConfirm: ({ name }) => `离开“${name}”?你将离开这个房间,之后可以用房间 ID 重新加入。`,
421
453
  deleteRoom: "删除房间", deleteConfirm: ({ name }) => `删除“${name}”及全部聊天记录?此操作无法撤销。`,
422
454
  allMembers: "所有人", messageCount: ({ count }) => `${count} / 5000`,
423
455
  pasteAsFile: ({ count }) => `已把粘贴的 ${count} 个字符保存为文本文件`,
@@ -0,0 +1,77 @@
1
+ /* Edit room: a settings-style tabbed dialog with a fixed footer. */
2
+ #editRoomDialog {
3
+ width: min(920px, calc(100vw - 32px));
4
+ max-width: none;
5
+ height: min(680px, calc(100dvh - 40px));
6
+ max-height: none;
7
+ margin: auto;
8
+ padding: 0;
9
+ overflow: hidden;
10
+ border-radius: 22px;
11
+ }
12
+ #editRoomDialog[open] { display: flex; flex-direction: column; animation: edit-room-in .18s ease-out both; }
13
+ @keyframes edit-room-in { from { opacity: 0; transform: translateY(8px); } }
14
+ #editRoomDialog::backdrop { background: rgb(8 20 16 / .52); backdrop-filter: blur(5px); }
15
+
16
+ #editRoomDialog .edit-room-head { flex: none; align-items: flex-start; padding: 22px 24px 14px; }
17
+ #editRoomDialog .edit-room-head h2 { margin: 0; }
18
+
19
+ #editRoomDialog .edit-room-form { display: flex; flex: 1; flex-direction: column; min-height: 0; }
20
+ #editRoomDialog .edit-room-body { display: grid; flex: 1; grid-template-columns: 224px minmax(0, 1fr); min-height: 0; }
21
+ #editRoomDialog .edit-room-nav { padding-top: 2px; }
22
+ #editRoomDialog .edit-room-content { min-width: 0; }
23
+ #editRoomDialog .edit-room-panel { padding-top: 2px; }
24
+
25
+ #editRoomDialog .edit-room-hint { margin: -2px 0 18px; }
26
+ #editRoomDialog .admin-fieldset .hint:last-child { margin-bottom: 0; }
27
+ #editRoomDialog .edit-room-owner-note {
28
+ margin: 4px 0 0;
29
+ padding: 10px 12px;
30
+ border-left: 2px solid var(--accent);
31
+ border-radius: 0 8px 8px 0;
32
+ background: color-mix(in srgb, var(--accent-soft) 58%, transparent);
33
+ line-height: 1.5;
34
+ }
35
+
36
+ #editRoomDialog .edit-room-footer {
37
+ display: grid;
38
+ flex: none;
39
+ gap: 6px;
40
+ padding: 10px 24px calc(14px + env(safe-area-inset-bottom));
41
+ border-top: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
42
+ background: color-mix(in srgb, var(--surface) 86%, var(--surface-2));
43
+ }
44
+ #editRoomDialog .edit-room-status { margin: 0; color: var(--danger); font-size: 12.5px; line-height: 1.45; }
45
+ #editRoomDialog .edit-room-status:empty { min-height: 0; }
46
+ #editRoomDialog .edit-room-actions { display: flex; justify-content: flex-end; gap: 8px; }
47
+ #editRoomDialog .edit-room-actions .btn { min-width: 96px; }
48
+
49
+ @media (max-width: 760px) {
50
+ #editRoomDialog { width: calc(100vw - 20px); height: calc(100dvh - 24px); border-radius: 18px; }
51
+ #editRoomDialog .edit-room-head { padding: 16px 16px 10px; }
52
+ #editRoomDialog .edit-room-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
53
+ #editRoomDialog .edit-room-nav {
54
+ display: grid;
55
+ grid-template-columns: repeat(4, minmax(0, 1fr));
56
+ gap: 4px;
57
+ padding: 0 10px 10px;
58
+ border-right: 0;
59
+ border-bottom: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
60
+ overflow: visible;
61
+ }
62
+ #editRoomDialog[data-owner="false"] .edit-room-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
63
+ #editRoomDialog .edit-room-nav .settings-tab {
64
+ flex-direction: column;
65
+ justify-content: center;
66
+ gap: 4px;
67
+ min-height: 58px;
68
+ padding: 6px 3px;
69
+ font-size: 10.5px;
70
+ line-height: 1.2;
71
+ text-align: center;
72
+ }
73
+ #editRoomDialog .edit-room-nav .settings-tab svg { width: 16px; height: 16px; }
74
+ #editRoomDialog .edit-room-panel { padding: 10px 16px 22px; }
75
+ #editRoomDialog .edit-room-footer { padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); }
76
+ #editRoomDialog .edit-room-actions .btn { flex: 1; min-height: 44px; }
77
+ }
@@ -0,0 +1,237 @@
1
+ /* Room files: a compact file browser that stays inside the dialog. */
2
+ #btnFiles { display: flex; align-items: center; gap: 8px; }
3
+ #btnFiles svg {
4
+ width: 15px;
5
+ height: 15px;
6
+ flex: none;
7
+ fill: none;
8
+ stroke: currentColor;
9
+ stroke-width: 1.7;
10
+ stroke-linecap: round;
11
+ stroke-linejoin: round;
12
+ }
13
+
14
+ #filesDialog {
15
+ width: min(820px, calc(100vw - 24px));
16
+ max-width: none;
17
+ height: min(720px, calc(100dvh - 40px));
18
+ max-height: none;
19
+ margin: auto;
20
+ padding: 0;
21
+ overflow: hidden;
22
+ border-radius: 22px;
23
+ }
24
+ #filesDialog[open] { display: flex; flex-direction: column; animation: files-in .18s ease-out both; }
25
+ @keyframes files-in { from { opacity: 0; transform: translateY(8px); } }
26
+ #filesDialog::backdrop { background: rgb(9 22 18 / .52); backdrop-filter: blur(4px); }
27
+
28
+ .files-head {
29
+ display: flex;
30
+ flex: none;
31
+ align-items: flex-start;
32
+ justify-content: space-between;
33
+ gap: 12px;
34
+ padding: 18px 20px 12px;
35
+ }
36
+ .files-heading { min-width: 0; }
37
+ .files-eyebrow {
38
+ margin: 0 0 2px;
39
+ color: var(--accent);
40
+ font: 700 10px/1.3 var(--font-mono);
41
+ letter-spacing: .1em;
42
+ text-transform: uppercase;
43
+ }
44
+ .files-heading h2 {
45
+ margin: 0;
46
+ font-family: var(--font-display);
47
+ font-size: 23px;
48
+ font-weight: 600;
49
+ letter-spacing: -.02em;
50
+ overflow-wrap: anywhere;
51
+ }
52
+ .files-room-name { color: var(--ink-3); font-weight: 500; }
53
+ .files-head-actions { display: flex; flex: none; align-items: center; gap: 4px; }
54
+
55
+ .files-toolbar {
56
+ display: flex;
57
+ flex: none;
58
+ flex-wrap: wrap;
59
+ align-items: center;
60
+ justify-content: space-between;
61
+ gap: 8px 12px;
62
+ padding: 0 20px 10px;
63
+ }
64
+ .files-filter { display: flex; align-items: center; gap: 8px; min-width: 0; }
65
+ .files-filter-label { color: var(--ink-3); font-size: 11px; font-weight: 600; white-space: nowrap; }
66
+ .files-select {
67
+ min-width: 150px;
68
+ max-width: 250px;
69
+ min-height: 34px;
70
+ padding: 4px 28px 4px 9px;
71
+ font-size: 12px;
72
+ }
73
+ .files-summary { margin: 0 0 0 auto; color: var(--ink-3); font-size: 11.5px; line-height: 1.4; }
74
+
75
+ .files-error { margin: 0 20px 8px; }
76
+ .files-scroll {
77
+ flex: 1 1 auto;
78
+ min-height: 0;
79
+ padding: 2px 20px 12px;
80
+ overflow-x: hidden;
81
+ overflow-y: auto;
82
+ overscroll-behavior: contain;
83
+ scrollbar-gutter: stable;
84
+ }
85
+ .file-list { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
86
+
87
+ .file-row {
88
+ display: grid;
89
+ grid-template-columns: 38px minmax(0, 1fr) auto;
90
+ align-items: center;
91
+ gap: 7px 10px;
92
+ min-width: 0;
93
+ padding: 8px 10px;
94
+ border: 1px solid var(--line);
95
+ border-radius: 12px;
96
+ background: var(--surface);
97
+ box-shadow: 0 1px 2px rgb(20 40 32 / .035);
98
+ animation: file-row-in .16s ease both;
99
+ animation-delay: calc(var(--file-i, 0) * 14ms);
100
+ }
101
+ .file-row.is-previewing { border-color: color-mix(in srgb, var(--accent) 38%, var(--line)); background: color-mix(in srgb, var(--accent-soft) 24%, var(--surface)); }
102
+ @keyframes file-row-in { from { opacity: 0; transform: translateY(3px); } }
103
+
104
+ .file-kind {
105
+ display: grid;
106
+ grid-row: 1;
107
+ place-items: center;
108
+ width: 38px;
109
+ height: 38px;
110
+ border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
111
+ border-radius: 9px;
112
+ color: var(--accent);
113
+ background: color-mix(in srgb, var(--accent-soft) 72%, var(--surface));
114
+ }
115
+ .file-kind svg {
116
+ width: 18px;
117
+ height: 18px;
118
+ fill: none;
119
+ stroke: currentColor;
120
+ stroke-width: 1.7;
121
+ stroke-linecap: round;
122
+ stroke-linejoin: round;
123
+ }
124
+ .file-kind[data-kind="audio"] { color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, var(--surface)); }
125
+ .file-kind[data-kind="video"] { color: var(--mention-blue); background: color-mix(in srgb, var(--mention-blue) 12%, var(--surface)); }
126
+
127
+ .file-main { min-width: 0; }
128
+ .file-name {
129
+ margin: 0;
130
+ overflow: hidden;
131
+ color: var(--ink);
132
+ font-size: 13px;
133
+ font-weight: 600;
134
+ line-height: 1.4;
135
+ text-overflow: ellipsis;
136
+ white-space: nowrap;
137
+ }
138
+ .file-meta {
139
+ display: flex;
140
+ align-items: center;
141
+ flex-wrap: wrap;
142
+ gap: 2px 6px;
143
+ min-width: 0;
144
+ margin: 1px 0 0;
145
+ color: var(--ink-3);
146
+ font-size: 10.5px;
147
+ line-height: 1.5;
148
+ }
149
+ .file-uploader {
150
+ max-width: 30ch;
151
+ overflow: hidden;
152
+ color: var(--ink-2);
153
+ font-weight: 600;
154
+ text-overflow: ellipsis;
155
+ white-space: nowrap;
156
+ }
157
+ .file-date { white-space: nowrap; font-family: var(--font-mono); }
158
+ .file-size { white-space: nowrap; }
159
+ .file-dot { color: color-mix(in srgb, var(--ink-3) 70%, transparent); }
160
+
161
+ .file-actions { display: flex; align-items: center; gap: 3px; }
162
+ .file-action {
163
+ display: grid;
164
+ place-items: center;
165
+ width: 34px;
166
+ height: 34px;
167
+ padding: 0;
168
+ border: 1px solid transparent;
169
+ border-radius: 8px;
170
+ color: var(--ink-3);
171
+ background: transparent;
172
+ cursor: pointer;
173
+ transition: color .12s, border-color .12s, background .12s;
174
+ }
175
+ .file-action svg {
176
+ width: 16px;
177
+ height: 16px;
178
+ fill: none;
179
+ stroke: currentColor;
180
+ stroke-width: 1.7;
181
+ stroke-linecap: round;
182
+ stroke-linejoin: round;
183
+ }
184
+ .file-action:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 24%, transparent); background: var(--accent-soft); }
185
+ .file-action.file-action-delete:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 28%, transparent); background: var(--danger-soft); }
186
+ .file-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
187
+ .file-action:disabled { opacity: .45; cursor: default; }
188
+
189
+ .file-preview {
190
+ grid-column: 2 / -1;
191
+ min-width: 0;
192
+ margin-top: 3px;
193
+ padding: 10px;
194
+ border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--line));
195
+ border-radius: 10px;
196
+ color: var(--ink-3);
197
+ background: color-mix(in srgb, var(--surface-2) 58%, var(--surface));
198
+ font-size: 11.5px;
199
+ text-align: center;
200
+ }
201
+ .file-preview.is-error { color: var(--danger); }
202
+ .file-preview-media { display: block; margin: 0 auto; }
203
+ .file-preview-image { width: auto; max-width: 100%; max-height: min(46dvh, 420px); border-radius: 8px; object-fit: contain; }
204
+ .file-preview-audio { width: 100%; }
205
+ .file-preview-video { width: 100%; max-height: min(46dvh, 420px); border-radius: 8px; background: #0c1512; }
206
+
207
+ .files-empty { margin: 0; padding: 34px 12px 42px; color: var(--ink-3); font-size: 12.5px; text-align: center; }
208
+ .files-more { display: block; min-width: 130px; margin: 12px auto 2px; }
209
+ .files-foot {
210
+ flex: none;
211
+ padding: 9px 20px calc(12px + env(safe-area-inset-bottom));
212
+ border-top: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
213
+ background: color-mix(in srgb, var(--surface) 84%, transparent);
214
+ }
215
+ .files-hint { margin: 0; color: var(--ink-3); font-size: 10.5px; }
216
+
217
+ @media (max-width: 620px) {
218
+ #filesDialog { width: calc(100vw - 12px); height: calc(100dvh - 16px); border-radius: 16px; }
219
+ .files-head { padding: 13px 13px 8px; }
220
+ .files-heading h2 { font-size: 19px; }
221
+ .files-toolbar { padding: 0 13px 8px; align-items: flex-start; }
222
+ .files-filter { flex-wrap: wrap; gap: 4px 8px; }
223
+ .files-select { min-width: 140px; max-width: calc(100vw - 60px); }
224
+ .files-summary { flex-basis: 100%; margin: 0; }
225
+ .files-error { margin: 0 13px 8px; }
226
+ .files-scroll { padding: 2px 8px 10px; scrollbar-gutter: auto; }
227
+ .file-row { grid-template-columns: 34px minmax(0, 1fr); padding: 8px; }
228
+ .file-kind { width: 34px; height: 34px; }
229
+ .file-actions { grid-column: 2; justify-content: flex-end; }
230
+ .file-preview { grid-column: 1 / -1; }
231
+ .file-uploader { max-width: 40vw; }
232
+ .files-foot { padding: 8px 13px calc(10px + env(safe-area-inset-bottom)); }
233
+ }
234
+
235
+ @media (prefers-reduced-motion: reduce) {
236
+ #filesDialog[open], .file-row { animation: none; }
237
+ }