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

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 (35) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +4 -4
  3. package/README.zh-CN.md +4 -4
  4. package/package.json +1 -1
  5. package/server/assets/base.css +4 -1
  6. package/server/assets/chat/create-room-dialog.js +49 -0
  7. package/server/assets/chat/editor.js +28 -9
  8. package/server/assets/chat/events.js +41 -23
  9. package/server/assets/chat/history-loader.js +1 -0
  10. package/server/assets/chat/image-zoom.js +49 -16
  11. package/server/assets/chat/index.js +2 -0
  12. package/server/assets/chat/locales/de.js +6 -2
  13. package/server/assets/chat/locales/es.js +6 -2
  14. package/server/assets/chat/locales/fr.js +6 -2
  15. package/server/assets/chat/locales/it.js +6 -2
  16. package/server/assets/chat/locales/ja.js +6 -2
  17. package/server/assets/chat/locales/ko.js +6 -2
  18. package/server/assets/chat/markdown.js +7 -1
  19. package/server/assets/chat/members.js +2 -0
  20. package/server/assets/chat/messages.js +1 -0
  21. package/server/assets/chat/questions.js +1 -0
  22. package/server/assets/chat/room-list.js +9 -1
  23. package/server/assets/chat/rooms.js +23 -9
  24. package/server/assets/chat/settings.js +40 -1
  25. package/server/assets/chat/shortcuts.js +137 -14
  26. package/server/assets/chat/state.js +14 -6
  27. package/server/assets/chat/viewport.js +3 -0
  28. package/server/assets/conversation.css +22 -19
  29. package/server/assets/responsive.css +52 -0
  30. package/server/assets/room-create.css +86 -0
  31. package/server/assets/settings.css +93 -35
  32. package/server/chat-server.ts +3 -3
  33. package/server/chat.html +138 -72
  34. package/server/sw.js +1 -0
  35. package/skills/chatroom/SKILL.md +2 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.2 — 2026-11-20
4
+
5
+ - Keep the room rail inside short windows even while a join request is pending, by compacting the rail footer, header, and composer instead of letting content stretch the rail.
6
+ - Open room creation in a large modal with a backdrop instead of the small rail popover, with focus returning to the `+` button when closed.
7
+ - Copying or cutting a mention, including selecting only the mention itself, keeps it a mention when pasted back; plain `@name` text stays plain, and a member who left the room is not restored as a mention.
8
+ - Scan the inbox every 500ms instead of every 2s, so new messages reach waiting clients with much less delay.
9
+ - Move Alt+Arrow room-switch motion into the room list; the conversation content switches without a fading or sliding transition. Alt+1…9 switches to a joined room by its position in the rail.
10
+ - Add an opt-in room content transition in Settings, off by default, which slides the old content out and the new content in with Alt+Arrow.
11
+ - Redesign Settings into General, Appearance, and Connection categories, keeping language, theme cards, content transition, page step, and access token in focused sections; opening Settings for a missing token goes straight to Connection.
12
+ - Show large images fitted to the window and report zoom relative to the image's natural pixels; 100% means original pixels, reset returns to fit, and small images are never enlarged.
13
+ - Keep the shortcut entry visible and the placeholder centered in short windows, and stop newline-only drafts from stretching the rail footer.
14
+ - Keep PageUp/PageDown animated and configurable: Settings sets the distance as a percentage of the conversation height (default 90%), and held keys extend the same target so the speed stays steady.
15
+ - Let the code toolbar hide with the same 140ms fade after a pointer click on wrap or copy, instead of the clicked button keeping it open.
16
+ - Ship Codex and dsh 0.1.2: dsh identifies itself as an Agent on create and join, dsh poll requires a room, and an approved join checked with `join_status` starts Codex delivery.
17
+
18
+ ## 0.7.1 — 2026-11-19
19
+
20
+ - Replace the PageUp/PageDown and Alt+Home/End flash with smooth scrolling of the conversation itself; room switching keeps its separate transition.
21
+ - Close the shortcut sheet when clicking outside it, with focus returning to the composer.
22
+ - Ask for confirmation before sending a join request to a protected room.
23
+ - Keep the room rail usable in very short windows by compacting its footer instead of squeezing the room list.
24
+ - Cap the app height to the live viewport so a stale saved height cannot push the header offscreen after browser restore or rotation.
25
+ - Document how an Agent renames itself: leave the room and rejoin it with the new name.
26
+
3
27
  ## 0.7.0 — 2026-11-19
4
28
 
5
29
  - Keep one compact shortcut entry under the composer. It shows `Alt + /` (`Option + /` on Mac) and opens the full shortcut sheet; all other per-control hints stay removed.
package/README.md CHANGED
@@ -24,7 +24,7 @@ When upgrading an existing install, quit OpenCode first or use `opencode plugin
24
24
  On a machine reachable by the other devices, start the server. Replace `your-password` with a shared password:
25
25
 
26
26
  ```bash
27
- bunx @alexsun-top/opencode-chat-room@0.7.0 --host 0.0.0.0 --port 4399 --token 'your-password'
27
+ bunx @alexsun-top/opencode-chat-room@0.7.2 --host 0.0.0.0 --port 4399 --token 'your-password'
28
28
  ```
29
29
 
30
30
  On each machine running OpenCode, set the server address and the same password, then start OpenCode from that environment:
@@ -35,7 +35,7 @@ export CHAT_ROOM_SERVER_TOKEN="your-password"
35
35
  opencode
36
36
  ```
37
37
 
38
- Open `http://SERVER_IP:4399/chat` in a browser and enter the same password in Settings. The same dialog, available before joining and from the chat menu, also selects the language and theme. Create or join a room there, and ask each agent to join it too.
38
+ Open `http://SERVER_IP:4399/chat` in a browser and enter the same password in Settings. The same dialog, available before joining and from the chat menu, groups language, theme, scrolling, and the access token under General, Appearance, and Connection. Create or join a room there, and ask each agent to join it too.
39
39
 
40
40
  **Security:** Anyone with the shared password can access and manage rooms, including direct chats. Share it only with trusted people and protect network access to the server. Join approval controls the normal join flow; it is not per-user authentication, so it does not stop a password holder from misrepresenting itself.
41
41
 
@@ -49,7 +49,7 @@ docker run --rm -p 4399:4399 -v chat-room-data:/data \
49
49
  ghcr.io/agentsyaml/opencode-chat-room:latest
50
50
  ```
51
51
 
52
- Pin a release with `ghcr.io/agentsyaml/opencode-chat-room:v0.7.0`. Rooms, messages and receipts live in the `/data` volume; keep it mounted across upgrades. If you bind-mount a host directory instead of a named volume, make it writable by uid `10001`.
52
+ Pin a release with `ghcr.io/agentsyaml/opencode-chat-room:v0.7.2`. Rooms, messages and receipts live in the `/data` volume; keep it mounted across upgrades. If you bind-mount a host directory instead of a named volume, make it writable by uid `10001`.
53
53
 
54
54
  ## 3. Start chatting
55
55
 
@@ -58,7 +58,7 @@ Pin a release with `ghcr.io/agentsyaml/opencode-chat-room:v0.7.0`. Rooms, messag
58
58
  - Use Reply to respond to a message. Mark a message as a question when you need an answer.
59
59
  - Use the room's reminder button for one-time or recurring reminders. Times default to the server's time zone.
60
60
  - Reminder text supports `{{time}}`, `{{initiator}}`, and `{{room}}`.
61
- - A compact shortcut chip under the composer shows Alt+/ (Option+/ on Mac); click it or press the keys to open the sheet. Alt+Home/Alt+End animate to the oldest/latest message, and PageUp/PageDown scrolls the conversation while you type.
61
+ - A compact shortcut chip under the composer shows Alt+/ (Option+/ on Mac); click it or press the keys to open the sheet. Alt+1…9 switches to a joined room by its position in the rail, Alt+Home/Alt+End smoothly scroll to the oldest/latest loaded message, and PageUp/PageDown scrolls the conversation in one animated step while you type, and Settings sets that step as a percentage of the conversation height (default 90%).
62
62
  - Attach files, drag them in, or paste images. The default limit is 500 MiB per file.
63
63
  - Fenced code blocks are syntax-highlighted locally. Hover or focus a block for icon-only wrap and copy controls.
64
64
  - Agents can recall a message by ID; the original stays available to current members.
package/README.zh-CN.md CHANGED
@@ -24,7 +24,7 @@
24
24
  在一台可被其他设备访问的机器上启动服务器,把 `换成自己的密码` 换成共享密码:
25
25
 
26
26
  ```bash
27
- bunx @alexsun-top/opencode-chat-room@0.7.0 --host 0.0.0.0 --port 4399 --token '换成自己的密码'
27
+ bunx @alexsun-top/opencode-chat-room@0.7.2 --host 0.0.0.0 --port 4399 --token '换成自己的密码'
28
28
  ```
29
29
 
30
30
  在每台运行 OpenCode 的机器上设置服务器地址和相同密码,再从该环境启动 OpenCode:
@@ -35,7 +35,7 @@ export CHAT_ROOM_SERVER_TOKEN="换成自己的密码"
35
35
  opencode
36
36
  ```
37
37
 
38
- 在浏览器打开 `http://服务器IP:4399/chat`,在设置窗口中填入相同密码。同一个设置窗口在加入房间前和聊天菜单中都能打开,也可以选择语言和主题。然后创建或加入房间,每个 Agent 也需要加入同一个房间。
38
+ 在浏览器打开 `http://服务器IP:4399/chat`,在设置窗口中填入相同密码。同一个设置窗口在加入房间前和聊天菜单中都能打开,按通用、外观、连接三个类别组织语言、主题、滚动选项和访问令牌。然后创建或加入房间,每个 Agent 也需要加入同一个房间。
39
39
 
40
40
  **安全提示:**共享密码的持有人可以访问和管理房间,包括私聊;请只分享给可信任的人,并保护服务器网络访问。加入审核只约束正常加入流程,不是按用户认证,无法阻止密码持有人伪装身份。
41
41
 
@@ -49,7 +49,7 @@ docker run --rm -p 4399:4399 -v chat-room-data:/data \
49
49
  ghcr.io/agentsyaml/opencode-chat-room:latest
50
50
  ```
51
51
 
52
- 用 `ghcr.io/agentsyaml/opencode-chat-room:v0.7.0` 可以固定到具体版本。房间、消息和回执都保存在 `/data` 卷里,升级时保留该卷即可。如果改用宿主目录做挂载,需要让该目录对 uid `10001` 可写。
52
+ 用 `ghcr.io/agentsyaml/opencode-chat-room:v0.7.2` 可以固定到具体版本。房间、消息和回执都保存在 `/data` 卷里,升级时保留该卷即可。如果改用宿主目录做挂载,需要让该目录对 uid `10001` 可写。
53
53
 
54
54
  ## 3. 开始聊天
55
55
 
@@ -58,7 +58,7 @@ docker run --rm -p 4399:4399 -v chat-room-data:/data \
58
58
  - 回复消息时点击回复;需要对方回答的问题可标记为「问题」。
59
59
  - 点击房间里的提醒按钮,可创建一次性或周期提醒。默认使用服务器时区。
60
60
  - 提醒正文支持 `{{time}}`、`{{initiator}}`、`{{room}}` 模板变量。
61
- - 输入框下方保留唯一快捷键入口,以紧凑标签显示 Alt+/(Mac 为 Option+/);点击或按快捷键都能打开面板。Alt+Home/Alt+End 平滑跳到最早/最新消息,输入时用 PageUp/PageDown 滚动会话。
61
+ - 输入框下方保留唯一快捷键入口,以紧凑标签显示 Alt+/(Mac 为 Option+/);点击或按快捷键都能打开面板。Alt+1…9 按房间在侧栏中的位置切换已加入房间,Alt+Home/Alt+End 平滑滚动到最早/最新的已加载消息,输入时用 PageUp/PageDown 按动画滚动一屏,步长可在设置中按会话高度百分比调整(默认 90%)。
62
62
  - 点击附件按钮、拖入文件或粘贴图片即可分享;默认单文件上限为 500 MiB。
63
63
  - 围栏代码块会在本地做语法高亮;鼠标悬停或键盘聚焦时显示纯图标的自动换行和复制按钮。
64
64
  - Agent 可按消息 ID 撤回;当前成员仍可查看原文。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexsun-top/opencode-chat-room",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "A chat-room plugin and central server for OpenCode.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,7 +42,8 @@
42
42
  #app {
43
43
  max-width: 760px;
44
44
  height: 100vh;
45
- height: var(--app-height, 100dvh);
45
+ /* A stale --app-height must never make the page taller than the live viewport. */
46
+ height: min(100dvh, var(--app-height, 100dvh));
46
47
  margin: 0 auto;
47
48
  display: flex;
48
49
  flex-direction: column;
@@ -325,6 +326,8 @@
325
326
  transition: background .12s, border-color .12s;
326
327
  }
327
328
  .room-row:hover { background: var(--surface-2); border-color: var(--line); }
329
+ .room-row.room-switch-enter { animation: room-switch-row .2s ease-out; }
330
+ @keyframes room-switch-row { from { transform: translateY(var(--room-switch-shift, 6px)); } }
328
331
  .r-name { font-weight: 600; font-size: 14px; }
329
332
  .r-meta { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
330
333
  .r-go {
@@ -0,0 +1,49 @@
1
+ // The rail "+" opens a large modal instead of a small popover, so the create
2
+ // form has room for its name, join policy, and inline validation.
3
+ export function initCreateRoomDialog(app) {
4
+ const dialog = app.$("#createRoomDialog");
5
+ const input = app.$("#inRoomNameChat");
6
+ const error = app.$("#createRoomError");
7
+ const trigger = app.$("#btnNewRoom");
8
+ if (!dialog || !input || !error || !trigger) return;
9
+ let opener = null;
10
+ let restoreFocus = true;
11
+
12
+ const close = (restore = true) => {
13
+ if (!dialog.open) return;
14
+ restoreFocus = restore;
15
+ trigger.setAttribute("aria-expanded", "false");
16
+ dialog.close();
17
+ };
18
+
19
+ app.showCreateRoomError = (key, values = {}) => {
20
+ app.setText(error, key, values);
21
+ error.dataset.errorKey = key;
22
+ error.hidden = false;
23
+ };
24
+ app.hideCreateRoomError = () => { error.hidden = true; delete error.dataset.errorKey; };
25
+ app.openCreateRoomDialog = () => {
26
+ opener = document.activeElement instanceof HTMLElement && document.activeElement !== document.body
27
+ ? document.activeElement : trigger;
28
+ app.hideCreateRoomError();
29
+ if (!dialog.open) dialog.showModal();
30
+ trigger.setAttribute("aria-expanded", "true");
31
+ input.focus();
32
+ input.select();
33
+ };
34
+ app.closeCreateRoomDialog = (restore = true) => close(restore);
35
+
36
+ dialog.addEventListener("click", (event) => { if (event.target === dialog) close(); });
37
+ dialog.addEventListener("cancel", () => trigger.setAttribute("aria-expanded", "false"));
38
+ dialog.addEventListener("close", () => {
39
+ const target = opener;
40
+ opener = null;
41
+ trigger.setAttribute("aria-expanded", "false");
42
+ app.hideCreateRoomError();
43
+ if (restoreFocus && target?.isConnected) target.focus({ preventScroll: true });
44
+ restoreFocus = true;
45
+ });
46
+ app.$("#btnCloseCreateRoom")?.addEventListener("click", () => close());
47
+ app.$("#btnCancelCreateRoom")?.addEventListener("click", () => close());
48
+ input.addEventListener("input", app.hideCreateRoomError);
49
+ }
@@ -63,8 +63,8 @@ export function setEditorText(editor, value, draft = false) {
63
63
  export function editorSelectionOffsets(editor) {
64
64
  const selection = getSelection();
65
65
  if (!selection?.rangeCount || !editor.contains(selection.anchorNode)) return [editorText(editor).length, editorText(editor).length];
66
- const selected = selection.getRangeAt(0);
67
- const offset = (node, position) => {
66
+ const selected = selection.getRangeAt(0), collapsed = selected.collapsed;
67
+ const offset = (node, position, isStart) => {
68
68
  const element = node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement;
69
69
  const chip = element?.closest(".editor-mention");
70
70
  const raw = lengthBefore(editor, node, position);
@@ -72,11 +72,13 @@ export function editorSelectionOffsets(editor) {
72
72
  const start = lengthBefore(editor, chip, 0), end = start + `<at>@${mentionName(chip)}</at>`.length;
73
73
  // A caret strictly inside a non-editable chip (e.g. left there by an
74
74
  // ESC-cancelled IME composition) is not a text position; snap to the end.
75
- if (raw > start && raw < end) return end;
75
+ // A selection edge inside a chip expands to the whole chip so copy and
76
+ // cut keep the mention token instead of falling back to plain text.
77
+ if (raw > start && raw < end) return collapsed || !isStart ? end : start;
76
78
  }
77
79
  return raw;
78
80
  };
79
- return [offset(selected.startContainer, selected.startOffset), offset(selected.endContainer, selected.endOffset)];
81
+ return [offset(selected.startContainer, selected.startOffset, true), offset(selected.endContainer, selected.endOffset, false)];
80
82
  }
81
83
 
82
84
  function lengthBefore(root, target, position) {
@@ -238,6 +240,10 @@ function sanitizeEditor(editor) {
238
240
  }
239
241
  }
240
242
 
243
+ function knownMentions(editor, text) {
244
+ // A copied mention only comes back if that name is still in the room.
245
+ return text.replace(/<at>@([^<]+)<\/at>/g, (token, name) => editor.isKnownMention && !editor.isKnownMention(name) ? `@${name}` : token);
246
+ }
241
247
  function escapeHTML(text) { return String(text).replace(/[&<>"']/g, (char) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[char]); }
242
248
  function textHTML(text) { return escapeHTML(text).replace(/\r\n|\r|\n/g, "<br>"); }
243
249
 
@@ -329,15 +335,25 @@ export function installEditor(editor) {
329
335
  // after it so a narrow or rounded chip cannot trap the caret before it.
330
336
  setCaret(editor, lengthBefore(editor, chip, 0) + `<at>@${mentionName(chip)}</at>`.length);
331
337
  });
332
- editor.addEventListener("copy", (event) => {
338
+ const copySelection = (event) => {
333
339
  const [start, end] = editorSelectionOffsets(editor);
334
- if (start === end) return;
340
+ if (start === end) return "";
335
341
  const text = editorText(editor).slice(start, end);
336
- if (!text) return;
342
+ if (!text) return "";
337
343
  // Copy mentions in their token form so a paste rebuilds the same chips.
338
344
  event.preventDefault();
339
345
  event.clipboardData?.setData("text/plain", text);
340
346
  if (/<at>@[^<]+<\/at>/.test(text)) event.clipboardData?.setData("text/html", `<div data-chatroom-mentions>${escapeHTML(text)}</div>`);
347
+ return text;
348
+ };
349
+ editor.addEventListener("copy", (event) => { copySelection(event); });
350
+ editor.addEventListener("cut", (event) => {
351
+ const [start, end] = editorSelectionOffsets(editor);
352
+ if (!copySelection(event)) return;
353
+ // The native cut would overwrite the token clipboard; delete the range here.
354
+ replaceEditorRange(editor, start, end, "", false);
355
+ sanitizeEditor(editor);
356
+ editor.dispatchEvent(new InputEvent("input", { bubbles: true, inputType: "deleteByCut" }));
341
357
  });
342
358
  editor.addEventListener("paste", (event) => {
343
359
  if (event.defaultPrevented || event.clipboardData?.files.length) return;
@@ -347,7 +363,8 @@ export function installEditor(editor) {
347
363
  // Rebuild chips only for copies this app marked; external text stays literal
348
364
  // and keeps the native insert path, which handles newlines correctly.
349
365
  const marked = (event.clipboardData?.getData("text/html") || "").includes("data-chatroom-mentions");
350
- replaceEditorRange(editor, start, end, text, marked && /<at>@[^<]+<\/at>/.test(text));
366
+ const value = marked ? knownMentions(editor, text) : text;
367
+ replaceEditorRange(editor, start, end, value, marked && /<at>@[^<]+<\/at>/.test(value));
351
368
  sanitizeEditor(editor);
352
369
  editor.dispatchEvent(new InputEvent("input", { bubbles: true, inputType: "insertFromPaste" }));
353
370
  });
@@ -360,7 +377,9 @@ export function installEditor(editor) {
360
377
  const range = document.caretRangeFromPoint?.(event.clientX, event.clientY), selection = getSelection();
361
378
  if (range && editor.contains(range.startContainer)) { selection.removeAllRanges(); selection.addRange(range); }
362
379
  const [start, end] = editorSelectionOffsets(editor);
363
- replaceEditorRange(editor, start, end, text, html.includes("data-chatroom-mentions") && /<at>@[^<]+<\/at>/.test(text));
380
+ const marked = html.includes("data-chatroom-mentions");
381
+ const value = marked ? knownMentions(editor, text) : text;
382
+ replaceEditorRange(editor, start, end, value, marked && /<at>@[^<]+<\/at>/.test(value));
364
383
  sanitizeEditor(editor);
365
384
  editor.dispatchEvent(new InputEvent("input", { bubbles: true, inputType: "insertFromDrop" }));
366
385
  });
@@ -27,8 +27,10 @@ export function initEvents(app) {
27
27
  if (composer) {
28
28
  const root = document.documentElement, editor = app.$("#msgInput");
29
29
  // A restored draft or staged files must not become the idle height people see on load.
30
- const idleComposer = () => !editor?.textContent?.trim()
31
- && !["#sendError", "#replyPreview", "#mentionPicker", "#attachmentTray"].some((selector) => { const node = app.$(selector); return node && !node.hidden; })
30
+ // Newline-only drafts are real drafts too: `trim()` would hide them and let the
31
+ // footer stretch with the composer.
32
+ const idleComposer = () => editor?.dataset.empty === "true"
33
+ && !["#joinNotice", "#sendError", "#replyPreview", "#mentionPicker", "#attachmentTray"].some((selector) => { const node = app.$(selector); return node && !node.hidden; })
32
34
  && !composer.querySelector(".failed-messages:not([hidden])");
33
35
  const syncComposerBlock = () => {
34
36
  const height = composer.getBoundingClientRect().height;
@@ -56,6 +58,12 @@ export function initEvents(app) {
56
58
  const thread = $("#thread");
57
59
  app.state.listMetrics = { height: messageList.offsetHeight, top: thread.scrollTop, client: thread.clientHeight };
58
60
  };
61
+ const scrollThread = $("#thread");
62
+ if (scrollThread) {
63
+ new ResizeObserver(() => {
64
+ if (followsBottom(app) && scrollThread.scrollHeight - scrollThread.scrollTop - scrollThread.clientHeight > 1) scrollThread.scrollTop = scrollThread.scrollHeight;
65
+ }).observe(scrollThread);
66
+ }
59
67
  new ResizeObserver(() => {
60
68
  const thread = $("#thread"), previous = app.state.listMetrics;
61
69
  const grew = messageList.offsetHeight > previous.height, sameBox = thread.clientHeight === previous.client;
@@ -166,6 +174,7 @@ export function initEvents(app) {
166
174
  });
167
175
  }
168
176
  syncRoomDrawer();
177
+ window.addEventListener("pageshow", () => { if (app.state.followBottom) $("#thread").scrollTop = $("#thread").scrollHeight; });
169
178
  window.addEventListener("resize", preserveReadingPosition);
170
179
  window.addEventListener("pagehide", () => { captureReadingPosition(); app.flushReadOnHide?.(); });
171
180
  document.addEventListener("visibilitychange", () => { if (document.hidden) { captureReadingPosition(); app.flushReadOnHide?.(); } });
@@ -221,11 +230,7 @@ export function initEvents(app) {
221
230
  try { sessionStorage.setItem("chat.keyPromptDismissed", "1"); } catch { /* Storage may be blocked. */ }
222
231
  });
223
232
  $("#btnRefreshRooms").addEventListener("click", () => void app.refreshRoomList());
224
- $("#btnNewRoom").addEventListener("click", () => {
225
- const form = $("#railRoomForm");
226
- form.hidden = !form.hidden;
227
- if (!form.hidden) $("#inRoomNameChat").focus();
228
- });
233
+ $("#btnNewRoom").addEventListener("click", () => app.openCreateRoomDialog());
229
234
  $("#railRoomForm").addEventListener("submit", (event) => { event.preventDefault(); void app.createRoom(); });
230
235
  $("#inRoomNameChat").addEventListener("input", app.hideSendError);
231
236
 
@@ -270,8 +275,12 @@ export function initEvents(app) {
270
275
  && !event.ctrlKey && !event.metaKey && !event.shiftKey && !event.isComposing) {
271
276
  event.preventDefault();
272
277
  markScrollIntent();
273
- thread.scrollTop += (event.key === "PageDown" ? 1 : -1) * Math.max(80, thread.clientHeight * 0.9);
274
- app.animateThreadJump?.(event.key === "PageDown");
278
+ const step = Number(app.LS.pageStep) || 90;
279
+ const delta = (event.key === "PageDown" ? 1 : -1) * Math.max(40, thread.clientHeight * step / 100);
280
+ // Repeated Page keys extend the same target, so holding them scrolls
281
+ // steadily instead of restarting the animation from zero each time.
282
+ if (app.animateThreadScrollBy) app.animateThreadScrollBy(delta);
283
+ else thread.scrollTop += delta;
275
284
  return;
276
285
  }
277
286
  handleMessageKey(event, app);
@@ -339,17 +348,25 @@ export function initEvents(app) {
339
348
  const messageButton = event.target.closest("[data-copy-message]");
340
349
  if (messageButton) void copyTextToClipboard(messageButton._copyText, true).then((copied) => app.flash(messageButton, copied ? "copiedMessage" : "copyMessageFailed"));
341
350
  });
342
- $("#msgList").addEventListener("copy", (event) => {
343
- // A plain browser copy of rendered messages loses the mention tokens. Rebuild
344
- // them only for chips inside the copied range, so external @text stays literal.
345
- const selection = getSelection(), list = $("#msgList");
351
+ document.addEventListener("copy", (event) => {
352
+ // A plain browser copy of rendered mentions loses their tokens. Rebuild them
353
+ // for any mention chip in the selection, including a double-clicked chip.
354
+ if (event.defaultPrevented) return;
355
+ const selection = getSelection();
346
356
  if (!selection || selection.isCollapsed || !selection.rangeCount) return;
347
357
  const range = selection.getRangeAt(0);
348
- if (!list.contains(range.startContainer) || !list.contains(range.endContainer)) return;
349
- const fragment = range.cloneContents();
350
- const chips = fragment.querySelectorAll(".mention-chip");
358
+ const chips = [...document.querySelectorAll(".mention-chip")].filter((chip) => range.intersectsNode(chip));
351
359
  if (!chips.length) return;
352
- chips.forEach((chip) => chip.replaceWith(document.createTextNode(`<at>@${chip.textContent?.slice(1) ?? ""}</at>`)));
360
+ // Extend a partial chip selection to its whole chip so the token can be rebuilt.
361
+ const copyRange = range.cloneRange();
362
+ const startChip = chips.find((chip) => chip.contains(copyRange.startContainer));
363
+ const endChip = chips.find((chip) => chip.contains(copyRange.endContainer));
364
+ if (startChip) copyRange.setStartBefore(startChip);
365
+ if (endChip) copyRange.setEndAfter(endChip);
366
+ const fragment = copyRange.cloneContents();
367
+ const selectedChips = fragment.querySelectorAll(".mention-chip");
368
+ if (!selectedChips.length) return;
369
+ selectedChips.forEach((chip) => chip.replaceWith(document.createTextNode(`<at>@${chip.textContent?.slice(1) ?? ""}</at>`)));
353
370
  const text = fragment.textContent ?? "";
354
371
  const html = `<div data-chatroom-mentions>${text.replace(/[&<>"]/g, (char) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[char])}</div>`;
355
372
  event.clipboardData?.setData("text/plain", text);
@@ -380,19 +397,17 @@ export function initEvents(app) {
380
397
  }
381
398
  if (app.mentionActive && !event.target.closest("#mentionPicker")) app.closeMention();
382
399
  if (!event.target.closest(".anchor, dialog")) app.closePanels();
383
- if (!event.target.closest("#railRoomForm, #btnNewRoom")) $("#railRoomForm").hidden = true;
384
400
  });
385
401
  document.addEventListener("keydown", (event) => {
386
- if (event.key === "Tab" && roomRail.classList.contains("drawer-open")) {
402
+ if (event.key === "Tab" && roomRail.classList.contains("drawer-open") && !document.querySelector("dialog[open]")) {
387
403
  const stops = [...roomRail.querySelectorAll("button:not(:disabled), input:not(:disabled)")].filter((node) => node.getClientRects().length);
388
404
  const first = stops[0], last = stops.at(-1);
389
405
  if (!roomRail.contains(document.activeElement)) { event.preventDefault(); first?.focus(); }
390
406
  else if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last?.focus(); }
391
407
  else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first?.focus(); }
392
408
  }
393
- if (event.key === "Escape" && roomRail.classList.contains("drawer-open")) { event.preventDefault(); closeRoomDrawer(); return; }
409
+ if (event.key === "Escape" && roomRail.classList.contains("drawer-open") && !document.querySelector("dialog[open]")) { event.preventDefault(); closeRoomDrawer(); return; }
394
410
  if (event.key === "Escape" && app.mentionActive) app.closeMention();
395
- if (event.key === "Escape" && !$("#railRoomForm").hidden) $("#railRoomForm").hidden = true;
396
411
  if (event.key === "Escape" && !$("#memberPanel").hidden) {
397
412
  app.closePanels();
398
413
  app.lastFocus?.focus();
@@ -404,8 +419,9 @@ export function initEvents(app) {
404
419
  if (event.defaultPrevented || joined.length < 2 || index < 0 || document.querySelector("dialog[open]")) return;
405
420
  event.preventDefault();
406
421
  const step = event.key === "ArrowDown" ? 1 : -1;
407
- app.activateRoom(joined[(index + step + joined.length) % joined.length].id);
408
- app.animateRoomSwitch?.(step);
422
+ const nextRoom = joined[(index + step + joined.length) % joined.length];
423
+ if (app.switchRoom) app.switchRoom(nextRoom.id, step);
424
+ else { app.activateRoom(nextRoom.id); app.animateRoomSwitch?.(step); }
409
425
  }
410
426
  });
411
427
 
@@ -427,6 +443,8 @@ function saveAccessToken(button, app) {
427
443
  if (LS.token) {
428
444
  app.hideJoinError();
429
445
  app.hideSendError();
446
+ const tokenHint = document.getElementById("tokenHint");
447
+ if (tokenHint) tokenHint.hidden = true;
430
448
  }
431
449
  // The key prompt is a one-time visit: a stored key gets out of the way again.
432
450
  if (LS.token) document.getElementById("tokenBox")?.close();
@@ -54,6 +54,7 @@ export function initHistoryLoader(app) {
54
54
  if (tailSep?.classList.contains("day-sep") && new Date(older.at(-1).createdAt).toDateString() === tailSep.dataset.day) tailSep.remove();
55
55
  entry.room.messages = [...older, ...entry.room.messages].sort((left, right) => left.createdAt - right.createdAt);
56
56
  if (entry.room.messages.length > LOADED_MESSAGE_LIMIT) entry.room.messages.splice(0, entry.room.messages.length - LOADED_MESSAGE_LIMIT);
57
+ app.cancelThreadScrollAnimation?.();
57
58
  thread.scrollTop = beforeTop + (thread.scrollHeight - beforeHeight);
58
59
  app.cacheRoomSoon?.(room.id);
59
60
  app.queueReceiptRefresh?.();
@@ -3,47 +3,72 @@
3
3
  export function initImageZoom(app) {
4
4
  const dialog = app.$("#imageDialog"), preview = app.$("#imageDialogImage");
5
5
  const zoomLevel = app.$("#zoomLevel"), zoomOut = app.$("#btnZoomOut"), zoomIn = app.$("#btnZoomIn"), zoomReset = app.$("#btnZoomReset");
6
- const MIN = 1, MAX = 4, STEP = 1.25;
7
- let trigger = null, scale = 1, panX = 0, panY = 0, drag = null;
6
+ const MAX = 4, STEP = 1.25;
7
+ let trigger = null, scale = 1, fitScale = 1, pendingFit = false, panX = 0, panY = 0, drag = null;
8
8
  const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
9
9
  const imageOf = (node) => node?.closest?.("#msgList img, #attachmentList img");
10
- function limits() {
10
+ function fitLimit() {
11
11
  const style = getComputedStyle(dialog);
12
12
  const width = dialog.clientWidth - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);
13
13
  const height = dialog.clientHeight - parseFloat(style.paddingTop) - parseFloat(style.paddingBottom);
14
- return { x: Math.max(0, (preview.offsetWidth * scale - width) / 2), y: Math.max(0, (preview.offsetHeight * scale - height) / 2) };
14
+ if (!preview.naturalWidth || !preview.naturalHeight) return 1;
15
+ return Math.min(1, width / preview.naturalWidth, height / preview.naturalHeight);
16
+ }
17
+ function limits() {
18
+ const style = getComputedStyle(dialog);
19
+ const box = dialog.getBoundingClientRect();
20
+ const left = box.left + parseFloat(style.paddingLeft), right = box.right - parseFloat(style.paddingRight);
21
+ const top = box.top + parseFloat(style.paddingTop), bottom = box.bottom - parseFloat(style.paddingBottom);
22
+ // Flex centering keeps an oversized image centered, so its untransformed
23
+ // layout box may start outside the dialog; offsetLeft still gives that
24
+ // position, while the live rect reflects the current scale and pan.
25
+ const layoutLeft = box.left + parseFloat(style.borderLeftWidth) + preview.offsetLeft;
26
+ const layoutTop = box.top + parseFloat(style.borderTopWidth) + preview.offsetTop;
27
+ const scaledWidth = preview.offsetWidth * scale, scaledHeight = preview.offsetHeight * scale;
28
+ const baseLeft = layoutLeft + preview.offsetWidth / 2 - scaledWidth / 2;
29
+ const baseTop = layoutTop + preview.offsetHeight / 2 - scaledHeight / 2;
30
+ const fitsX = scaledWidth <= right - left, fitsY = scaledHeight <= bottom - top;
31
+ const minX = fitsX ? 0 : right - baseLeft - scaledWidth;
32
+ const maxX = fitsX ? 0 : left - baseLeft;
33
+ const minY = fitsY ? 0 : bottom - baseTop - scaledHeight;
34
+ const maxY = fitsY ? 0 : top - baseTop;
35
+ return { minX, maxX, minY, maxY, x: maxX - minX, y: maxY - minY };
15
36
  }
16
37
  function apply() {
17
38
  const limit = limits();
18
- panX = clamp(panX, -limit.x, limit.x); panY = clamp(panY, -limit.y, limit.y);
19
- preview.style.transform = scale > 1 ? `translate3d(${panX}px, ${panY}px, 0) scale(${scale})` : "";
20
- preview.classList.toggle("is-zoomed", scale > 1);
39
+ panX = clamp(panX, limit.minX, limit.maxX); panY = clamp(panY, limit.minY, limit.maxY);
40
+ preview.style.transform = `translate3d(${panX}px, ${panY}px, 0) scale(${scale})`;
41
+ preview.classList.toggle("is-zoomed", limit.x > 0 || limit.y > 0);
21
42
  if (zoomLevel) zoomLevel.textContent = `${Math.round(scale * 100)}%`;
22
- if (zoomOut) zoomOut.disabled = scale <= MIN + .001;
43
+ if (zoomOut) zoomOut.disabled = scale <= fitScale + .001;
23
44
  if (zoomIn) zoomIn.disabled = scale >= MAX - .001;
24
45
  }
25
46
  function zoomTo(next, x = innerWidth / 2, y = innerHeight / 2) {
26
- const target = clamp(next, MIN, MAX);
47
+ const target = clamp(next, fitScale, MAX);
27
48
  if (Math.abs(target - scale) < .001) return apply();
28
49
  // Keep the point under the pointer fixed while scaling.
29
50
  const dx = x - innerWidth / 2, dy = y - innerHeight / 2, ratio = target / scale;
30
51
  panX = dx - ratio * (dx - panX); panY = dy - ratio * (dy - panY);
31
52
  scale = target;
32
- if (scale <= 1) { scale = 1; panX = 0; panY = 0; }
53
+ if (scale <= fitScale + .001) { scale = fitScale; panX = 0; panY = 0; }
33
54
  preview.style.animation = "none";
34
55
  apply();
35
56
  }
36
57
  const zoomBy = (factor) => zoomTo(scale * factor);
37
- const resetZoom = () => { scale = 1; panX = 0; panY = 0; apply(); };
58
+ function resetZoom() {
59
+ fitScale = fitLimit(); scale = fitScale; pendingFit = false; panX = 0; panY = 0; apply();
60
+ }
38
61
  function open(image) {
39
62
  if (!image || !dialog) return;
40
63
  trigger = image;
64
+ dialog.showModal();
41
65
  // Reuse the URL the list already loaded, so the overlay costs no second download.
42
66
  preview.src = image.currentSrc || image.src;
43
67
  preview.alt = image.alt || "";
44
68
  preview.style.animation = "";
45
- resetZoom();
46
- dialog.showModal();
69
+ scale = 1; panX = 0; panY = 0; fitScale = fitLimit();
70
+ pendingFit = !(preview.complete && preview.naturalWidth);
71
+ if (pendingFit) apply(); else resetZoom();
47
72
  }
48
73
  const close = () => { if (dialog.open) dialog.close(); };
49
74
  // A click that focuses the image makes the browser scroll it into view; the
@@ -80,7 +105,7 @@ export function initImageZoom(app) {
80
105
  if (event.key === "+" || event.key === "=") { event.preventDefault(); zoomBy(STEP); }
81
106
  else if (event.key === "-" || event.key === "_") { event.preventDefault(); zoomBy(1 / STEP); }
82
107
  else if (event.key === "0") { event.preventDefault(); resetZoom(); }
83
- else if (scale > 1 && event.key.startsWith("Arrow")) {
108
+ else if ((limits().x > 0 || limits().y > 0) && event.key.startsWith("Arrow")) {
84
109
  event.preventDefault();
85
110
  const step = event.shiftKey ? 120 : 40;
86
111
  if (event.key === "ArrowLeft") panX += step;
@@ -93,12 +118,20 @@ export function initImageZoom(app) {
93
118
  zoomIn?.addEventListener("click", () => zoomBy(STEP));
94
119
  zoomOut?.addEventListener("click", () => zoomBy(1 / STEP));
95
120
  zoomReset?.addEventListener("click", resetZoom);
96
- window.addEventListener("resize", () => { if (dialog.open) apply(); });
121
+ window.addEventListener("resize", () => {
122
+ if (!dialog.open) return;
123
+ const wasFit = Math.abs(scale - fitScale) < .001;
124
+ fitScale = fitLimit();
125
+ if (wasFit) { scale = fitScale; panX = 0; panY = 0; }
126
+ else scale = Math.max(scale, fitScale);
127
+ apply();
128
+ });
129
+ preview.addEventListener("load", () => { if (dialog.open && pendingFit) resetZoom(); });
97
130
  // Pointer dragging pans the zoomed image; the tool buttons are the touch and
98
131
  // keyboard alternative for changing the scale, and arrow keys pan to the edges.
99
132
  preview.draggable = false;
100
133
  preview.addEventListener("pointerdown", (event) => {
101
- if (scale <= 1 || event.button !== 0) return;
134
+ if ((limits().x <= 0 && limits().y <= 0) || event.button !== 0) return;
102
135
  drag = { id: event.pointerId, x: event.clientX, y: event.clientY, panX, panY };
103
136
  preview.setPointerCapture(event.pointerId);
104
137
  preview.classList.add("is-dragging");
@@ -4,6 +4,7 @@ import { initMentions } from "./mentions.js";
4
4
  import { initMessages } from "./messages.js";
5
5
  import { initMembers } from "./members.js";
6
6
  import { initRooms } from "./rooms.js";
7
+ import { initCreateRoomDialog } from "./create-room-dialog.js";
7
8
  import { initJoinRequests } from "./join-requests.js";
8
9
  import { initEvents } from "./events.js";
9
10
  import { initQuestions } from "./questions.js";
@@ -30,6 +31,7 @@ initAttachments(app);
30
31
  initReceipts(app);
31
32
  initMembers(app);
32
33
  initRooms(app);
34
+ initCreateRoomDialog(app);
33
35
  initJoinRequests(app);
34
36
  initHistoryLoader(app);
35
37
  initQuestions(app);
@@ -11,7 +11,7 @@ export const de = {
11
11
  requireApproval: "Beitritt nur mit Freigabe", requireApprovalHint: "Neue Mitglieder brauchen die Freigabe eines menschlichen Administrators. Agenten können auch vom Administrator-Agenten freigegeben werden.",
12
12
  joinPolicyEditHint: "Neue Mitglieder brauchen die Freigabe eines menschlichen Administrators. Beim Ausschalten werden alle offenen Anfragen gelöscht.", joinPolicyOpenConfirm: "Freigabe ausschalten? Alle offenen Beitrittsanfragen werden gelöscht.",
13
13
  approvalRequired: "Freigabe erforderlich", joinRequired: "Freigabe erforderlich", joinPendingStatus: "Freigabe ausstehend",
14
- joinPendingTitle: "Warten auf Freigabe", joinPendingBody: ({ name }) => `Ihre Anfrage für „${name}“ wurde gesendet. Ein menschlicher Administrator muss sie freigeben, bevor Sie beitreten können.`,
14
+ joinPendingTitle: "Warten auf Freigabe", joinApprovalPrompt: ({ name }) => `Beitritt zu „${name}“ anfragen? Ein menschlicher Administrator muss zustimmen.`, joinPendingBody: ({ name }) => `Ihre Anfrage für „${name}“ wurde gesendet. Ein menschlicher Administrator muss sie freigeben, bevor Sie beitreten können.`,
15
15
  joinPendingHint: "Sie können diese Seite verlassen; die Anfrage bleibt offen. Prüfen Sie später die Raumliste.", joinPendingNotice: ({ name }) => `Anfrage für „${name}“ gesendet. Warten auf einen menschlichen Administrator.`, joinPendingCancel: "Anfrage abbrechen", joinPendingCancelError: "Anfrage konnte nicht abgebrochen werden. Erneut versuchen.",
16
16
  joinPendingGoneTitle: "Anfrage nicht mehr offen", joinPendingGoneBody: "Sie wurde möglicherweise abgelehnt oder gelöscht. Sie können eine neue Anfrage senden.", joinPendingAgain: "Erneut anfragen",
17
17
  joinPendingError: "Anfrage konnte nicht geprüft werden. Erneut versuchen.", joinPendingRoomGone: "Dieser Raum existiert nicht mehr oder Sie haben keinen Zugriff mehr.",
@@ -57,6 +57,10 @@ export const de = {
57
57
  adminLoading: "Administration wird geladen…", refreshAdmin: "Aktualisieren", adminRoomBadge: "Admin", chooseAdminRoom: "Normalen Raum wählen", chooseTargetRoom: "Agentenraum wählen", chooseAgent: "Registrierten Agenten wählen", taskTargetRoom: "Zielraum", taskTargetAgent: "Zielagent", createAdminRoomFirst: "Erstellen Sie zuerst einen normalen Raum und wählen Sie ihn dann als Administrationsraum.", noAgents: "Keine registrierten Agenten", selectAdminAgent: "Wählen Sie einen Administrationsraum und einen registrierten Agenten.", adminDesignated: "Die Ernennung zum Administrator gilt sofort und bleibt bestehen, bis Sie sie widerrufen.", revokeConfirm: "Diese Ernennung zum Administrator widerrufen? Der normale Raum bleibt bestehen.", updateTask: "Aufgabe aktualisieren", task_pending: "Ausstehend", task_working: "In Arbeit", task_blocked: "Blockiert", task_completed: "Abgeschlossen", task_cancelled: "Abgebrochen", nextRun: ({ time, minutes }) => `Alle ${minutes} Min. · nächste Ausführung: ${time}`, paused: "Pausiert", pauseTimer: "Pausieren", resumeTimer: "Fortsetzen", deleteTimer: "Löschen", deleteTimerConfirm: ({ name }) => `Timer „${name}“ löschen?`,
58
58
  themeLabel: "Design", themeSystem: "System", themeLight: "Hell", themeDark: "Dunkel", themeForest: "Wald", themeSand: "Sand",
59
59
  settingsLocalHint: "Sprache und Design werden in diesem Browser gespeichert.",
60
+ settingsSections: "Einstellungsbereiche", settingsGeneral: "Allgemein", settingsAppearance: "Darstellung", settingsConnection: "Verbindung",
61
+ settingsLanguageHint: "Gilt sofort und wird in diesem Browser gespeichert.", settingsThemeHint: "Wird in diesem Browser gespeichert. System folgt Ihrem Gerät.", settingsTokenHint: "Nur in diesem Browser gespeichert. Nur nötig, wenn der Server danach fragt.",
62
+ contentTransition: "Inhaltsübergang", contentTransitionHint: "Blendet Nachrichten beim Raumwechsel mit Alt+Pfeiltasten richtungsabhängig ein. Standardmäßig aus.",
63
+ pageStep: "Blätterabstand", pageStepHint: "Wie weit PageUp und PageDown pro Tastendruck scrollen, als Prozent der Gesprächshöhe. Standard 90 %.",
60
64
  leave: "Verlassen", reconnecting: "Verbindung verloren. Neuer Versuch…", messageList: "Nachrichtenliste",
61
65
  noMessages: "Noch keine Nachrichten. Sagen Sie etwas.", latestMessages: "Zurück zu den neuesten Nachrichten",
62
66
  mentionMembers: "Mitglied zum Erwähnen wählen", messagePlaceholder: "Nachricht · Eingabetaste zum Senden",
@@ -75,7 +79,7 @@ export const de = {
75
79
  shortcutsOpen: "Alle Tastenkürzel",
76
80
  shortcutsWriting: "Schreiben", shortcutsSend: "Nachricht senden", shortcutsNewline: "Neue Zeile beginnen",
77
81
  shortcutsMention: "Mitglied zum Erwähnen wählen", shortcutsRooms: "Räume",
78
- shortcutsSwitchRoom: "Zum vorherigen oder nächsten Raum wechseln", shortcutsReading: "Lesen",
82
+ shortcutsSwitchRoom: "Zum vorherigen oder nächsten Raum wechseln", shortcutsNumberRoom: "Per Nummer zu einem beigetretenen Raum wechseln", shortcutsReading: "Lesen",
79
83
  shortcutsScroll: "Nachrichten beim Tippen scrollen", shortcutsJump: "Zum Anfang oder Ende der Unterhaltung springen", shortcutsMenus: "Menüs und Dialoge",
80
84
  shortcutsClose: "Geöffnetes Menü, Panel oder Dialog schließen",
81
85
  earlierMessages: "Frühere Nachrichten ausgelassen", messagesBetweenOmitted: "Nachrichten zwischen diesem Lesepunkt und den neuesten werden ausgelassen.", you: "Sie", saved: "Gespeichert",