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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +5 -5
  3. package/README.zh-CN.md +5 -5
  4. package/cli.ts +20 -0
  5. package/dist/cli.js +18 -0
  6. package/package.json +1 -1
  7. package/server/assets/chat/doc-preview.js +113 -0
  8. package/server/assets/chat/events.js +6 -0
  9. package/server/assets/chat/files.js +14 -6
  10. package/server/assets/chat/index.js +2 -0
  11. package/server/assets/chat/locales/de.js +3 -3
  12. package/server/assets/chat/locales/es.js +3 -3
  13. package/server/assets/chat/locales/fr.js +3 -3
  14. package/server/assets/chat/locales/it.js +3 -3
  15. package/server/assets/chat/locales/ja.js +3 -3
  16. package/server/assets/chat/locales/ko.js +3 -3
  17. package/server/assets/chat/markdown.js +12 -4
  18. package/server/assets/chat/palette.js +9 -5
  19. package/server/assets/chat/state.js +6 -6
  20. package/server/assets/chat/system-messages.js +7 -1
  21. package/server/assets/doc-preview.css +158 -0
  22. package/server/assets/edit-room.css +8 -0
  23. package/server/assets/settings.css +9 -2
  24. package/server/chat.html +33 -15
  25. package/server/sw.js +1 -0
  26. package/src/tui/app.mjs +16 -1
  27. package/src/tui/http.mjs +109 -10
  28. package/src/tui/info-app.mjs +435 -0
  29. package/src/tui/info-content.mjs +198 -0
  30. package/src/tui/join-app.mjs +71 -0
  31. package/src/tui/main.mjs +23 -4
  32. package/src/tui/markdown.mjs +269 -0
  33. package/src/tui/message-app.mjs +177 -0
  34. package/src/tui/message-view.mjs +128 -0
  35. package/src/tui/palette-app.mjs +85 -9
  36. package/src/tui/palette.mjs +17 -2
  37. package/src/tui/reminder-app.mjs +189 -0
  38. package/src/tui/room-settings-app.mjs +249 -0
  39. package/src/tui/ui-content.mjs +136 -93
  40. package/src/tui/ui-overlay-view.mjs +255 -0
  41. package/src/tui/ui-view.mjs +2 -190
  42. package/src/tui/ui.mjs +103 -1
@@ -231,7 +231,7 @@ export function initPalette(app) {
231
231
  const token = ++sequence;
232
232
  const value = input.value;
233
233
  if (!value.trim()) { showCommands(""); return; }
234
- if (value.startsWith(">")) { showCommands(value.slice(1)); return; }
234
+ if (value.startsWith("/")) { showCommands(value.slice(1)); return; }
235
235
  const wasSearch = dialog.dataset.mode === "search";
236
236
  dialog.dataset.mode = "search";
237
237
  dialog.dataset.state = "searching";
@@ -292,7 +292,7 @@ export function initPalette(app) {
292
292
  syncScope();
293
293
  const value = input.value;
294
294
  if (!value.trim()) showCommands("");
295
- else if (value.startsWith(">")) showCommands(value.slice(1));
295
+ else if (value.startsWith("/")) showCommands(value.slice(1));
296
296
  else scheduleSearch();
297
297
  };
298
298
 
@@ -331,8 +331,12 @@ export function initPalette(app) {
331
331
  // A stacked dialog keeps its own focus; otherwise the composer owns the page.
332
332
  if (document.querySelector("dialog[open]")) return;
333
333
  const composer = app.$("#msgInput");
334
- if (app.state.room && !app.$("#chatView")?.hidden && composer?.contentEditable === "true") composer.focus({ preventScroll: true });
335
- else if (!app.state.room) app.$("#inRoomId")?.focus({ preventScroll: true });
334
+ if (app.state.room && !app.$("#chatView")?.hidden && composer?.contentEditable === "true") {
335
+ const selection = getSelection();
336
+ const selectionInside = Boolean(selection?.anchorNode && composer.contains(selection.anchorNode));
337
+ composer.focus({ preventScroll: true });
338
+ if (!selectionInside) composer.setCaret?.(composer.value.length);
339
+ } else if (!app.state.room) app.$("#inRoomId")?.focus({ preventScroll: true });
336
340
  });
337
341
  });
338
342
 
@@ -390,7 +394,7 @@ export function initPalette(app) {
390
394
  syncScope();
391
395
  if (!dialog.open) return;
392
396
  const value = input.value;
393
- if (!value.trim() || value.startsWith(">")) showCommands(value.startsWith(">") ? value.slice(1) : "");
397
+ if (!value.trim() || value.startsWith("/")) showCommands(value.startsWith("/") ? value.slice(1) : "");
394
398
  else scheduleSearch();
395
399
  };
396
400
  }
@@ -248,7 +248,7 @@ export const messages = {
248
248
  reminderEdit: "Edit", reminderEditHeading: "Edit reminder", reminderSave: "Save changes",
249
249
  reminderCreated: "Reminder created.", reminderUpdated: "Reminder updated.", reminderDeleted: "Reminder deleted.",
250
250
  reminderInvalid: "Check the date, 5-field CRON expression, IANA timezone, and reminder text.", reminderLoadFailed: "Could not load reminders. Your draft is still here.",
251
- diagramLoading: "Rendering diagram…", diagramRenderFailed: "Diagram unavailable; showing its source.", resourceLoading: "Loading file…", resourceFailed: "This file could not be loaded.", resourceDownload: "Download", resourceMoreActions: "More actions for {name}", resourcePreview: "Preview", resourceHide: "Hide preview", zoomImage: "Open image", imagePreviewTitle: "Image preview", imageZoomControls: "Image zoom", zoomIn: "Zoom in", zoomOut: "Zoom out", zoomReset: "Reset zoom", installTitle: "Install OC Chat", installBody: "Add it to your home screen for a full-screen chat.", installAction: "Install", installHow: "How to install", installNotNow: "Not now", installIosGuide: "Tap Share, then Add to Home Screen.",
251
+ diagramLoading: "Rendering diagram…", diagramRenderFailed: "Diagram unavailable; showing its source.", resourceLoading: "Loading file…", resourceFailed: "This file could not be loaded.", resourceDownload: "Download", resourceMoreActions: "More actions for {name}", resourcePreview: "Preview", resourceHide: "Hide preview", docPreviewEyebrow: "Markdown preview", docPreviewFailed: "This document could not be loaded.", docPreviewEmpty: "This document is empty.", zoomImage: "Open image", imagePreviewTitle: "Image preview", imageZoomControls: "Image zoom", zoomIn: "Zoom in", zoomOut: "Zoom out", zoomReset: "Reset zoom", installTitle: "Install OC Chat", installBody: "Add it to your home screen for a full-screen chat.", installAction: "Install", installHow: "How to install", installNotNow: "Not now", installIosGuide: "Tap Share, then Add to Home Screen.",
252
252
  pwaUpdateTitle: "Update available", pwaUpdateBody: "A new version is ready. Reload now, or update the next time you open the app.", pwaUpdateNow: "Update now", pwaUpdateLater: "Later",
253
253
  announcementDelete: "Delete announcement",
254
254
  announcementNew: "New announcement", announcementEmpty: "No announcements yet.", announcementLoading: "Loading announcements…",
@@ -289,7 +289,7 @@ export const messages = {
289
289
  shortcutsScroll: "Scroll messages while typing", shortcutsJump: "Jump to the start or end of the conversation", shortcutsMenus: "Menus and dialogs",
290
290
  shortcutsClose: "Close the open menu, panel, or dialog",
291
291
  paletteTitle: "Search and commands", paletteSearchLabel: "Search messages",
292
- palettePlaceholder: "Search messages, or type > for commands", paletteScopeRoom: "This room", paletteScopeAll: "All rooms",
292
+ palettePlaceholder: "Search messages, or type / for commands", paletteScopeRoom: "This room", paletteScopeAll: "All rooms",
293
293
  paletteScopeHint: "Tab switches between this room and all joined rooms", paletteSearchMode: "Search", paletteCommandMode: "Commands",
294
294
  paletteSearching: "Searching…", paletteNoResults: "No messages found.", paletteNoCommands: "No matching commands.",
295
295
  paletteResults: ({ count }) => `${count} result${count === 1 ? "" : "s"}`, paletteCommandsHint: "Common commands",
@@ -299,7 +299,7 @@ export const messages = {
299
299
  filesUnknownUploader: "Unknown uploader", filesSummary: ({ count, size }) => `${count} file${count === 1 ? "" : "s"} · ${size}`,
300
300
  filesLoading: "Loading files…", filesLoadFailed: "Could not load files. Try again.", filesEmpty: "No files in this room yet.",
301
301
  filesEmptyFiltered: "No files from this uploader.", filesLoadMore: "Load more",
302
- filesHint: "Preview images, audio, and video. Download any file.",
302
+ filesHint: "Preview images, audio, video, and Markdown. Download any file.",
303
303
  filesPreviewFailed: "Could not load this preview.", filesDownloadFailed: "Could not download this file.",
304
304
  filesPreviewLabel: ({ name }) => `Preview ${name}`, filesDownloadLabel: ({ name }) => `Download ${name}`,
305
305
  filesDeleteLabel: ({ name }) => `Delete ${name}`, filesRefresh: "Refresh files",
@@ -382,7 +382,7 @@ export const messages = {
382
382
  reminderEdit: "编辑", reminderEditHeading: "编辑提醒", reminderSave: "保存修改",
383
383
  reminderCreated: "提醒已创建。", reminderUpdated: "提醒已更新。", reminderDeleted: "提醒已删除。",
384
384
  reminderInvalid: "请检查日期、5 字段 CRON 表达式、IANA 时区和提醒内容。", reminderLoadFailed: "无法加载提醒,草稿仍已保留。",
385
- diagramLoading: "正在渲染图表…", diagramRenderFailed: "图表无法显示,以下为源代码。", resourceLoading: "正在加载文件…", resourceFailed: "无法加载此文件。", resourceDownload: "下载", resourceMoreActions: "{name} 的更多操作", resourcePreview: "预览", resourceHide: "收起预览", zoomImage: "查看大图", imagePreviewTitle: "图片预览", imageZoomControls: "图片缩放", zoomIn: "放大", zoomOut: "缩小", zoomReset: "重置缩放", installTitle: "安装 OC Chat", installBody: "添加到主屏幕,获得全屏聊天体验。", installAction: "安装", installHow: "如何安装", installNotNow: "暂不", installIosGuide: "点击共享按钮,然后选择“添加到主屏幕”。",
385
+ diagramLoading: "正在渲染图表…", diagramRenderFailed: "图表无法显示,以下为源代码。", resourceLoading: "正在加载文件…", resourceFailed: "无法加载此文件。", resourceDownload: "下载", resourceMoreActions: "{name} 的更多操作", resourcePreview: "预览", resourceHide: "收起预览", docPreviewEyebrow: "Markdown 预览", docPreviewFailed: "无法加载此文档。", docPreviewEmpty: "此文档为空。", zoomImage: "查看大图", imagePreviewTitle: "图片预览", imageZoomControls: "图片缩放", zoomIn: "放大", zoomOut: "缩小", zoomReset: "重置缩放", installTitle: "安装 OC Chat", installBody: "添加到主屏幕,获得全屏聊天体验。", installAction: "安装", installHow: "如何安装", installNotNow: "暂不", installIosGuide: "点击共享按钮,然后选择“添加到主屏幕”。",
386
386
  pwaUpdateTitle: "有可用更新", pwaUpdateBody: "新版本已准备好。可以立即刷新,或下次打开时再升级。", pwaUpdateNow: "立即升级", pwaUpdateLater: "稍后",
387
387
  announcementDelete: "删除公告",
388
388
  announcementNew: "新建公告", announcementEmpty: "暂无公告。", announcementLoading: "正在加载公告…",
@@ -419,7 +419,7 @@ export const messages = {
419
419
  shortcutsScroll: "输入时滚动消息", shortcutsJump: "跳到会话开头或结尾", shortcutsMenus: "菜单和对话框",
420
420
  shortcutsClose: "关闭当前菜单、面板或对话框",
421
421
  paletteTitle: "搜索与命令", paletteSearchLabel: "搜索消息",
422
- palettePlaceholder: "搜索消息,输入 > 使用命令", paletteScopeRoom: "当前房间", paletteScopeAll: "全部房间",
422
+ palettePlaceholder: "搜索消息,输入 / 使用命令", paletteScopeRoom: "当前房间", paletteScopeAll: "全部房间",
423
423
  paletteScopeHint: "按 Tab 在当前房间和全部已加入房间之间切换", paletteSearchMode: "搜索", paletteCommandMode: "命令",
424
424
  paletteSearching: "正在搜索…", paletteNoResults: "没有找到消息。", paletteNoCommands: "没有匹配的命令。",
425
425
  paletteResults: ({ count }) => `${count} 条结果`, paletteCommandsHint: "常用命令",
@@ -429,7 +429,7 @@ export const messages = {
429
429
  filesUnknownUploader: "未知上传者", filesSummary: ({ count, size }) => `${count} 个文件 · ${size}`,
430
430
  filesLoading: "正在加载文件…", filesLoadFailed: "无法加载文件,请重试。", filesEmpty: "这个房间还没有文件。",
431
431
  filesEmptyFiltered: "此上传者没有文件。", filesLoadMore: "加载更多",
432
- filesHint: "可预览图片、音频和视频,所有文件都可下载。",
432
+ filesHint: "可预览图片、音频、视频和 Markdown,所有文件都可下载。",
433
433
  filesPreviewFailed: "无法加载预览。", filesDownloadFailed: "无法下载此文件。",
434
434
  filesPreviewLabel: ({ name }) => `预览 ${name}`, filesDownloadLabel: ({ name }) => `下载 ${name}`,
435
435
  filesDeleteLabel: ({ name }) => `删除 ${name}`, filesRefresh: "刷新文件",
@@ -23,7 +23,13 @@ function formatLine(line, app) {
23
23
 
24
24
  export function formatSystemMessage(message, app) {
25
25
  // `<at>@name</at>` is an editor token; system rows and previews show the plain mention.
26
- const text = String(message?.text ?? "").replace(/<at>([\s\S]*?)<\/at>/g, "$1");
26
+ let text = String(message?.text ?? "").replace(/<at>([\s\S]*?)<\/at>/g, "$1");
27
+ // Resource markers are internal IDs. A rail preview must not expose them.
28
+ const resources = /\[\[resource:[0-9a-f-]{36}\]\]/gi;
29
+ if (resources.test(text)) {
30
+ text = text.replace(resources, "").trim();
31
+ text = text ? `${text} · ${app.t("attachments")}` : app.t("attachments");
32
+ }
27
33
  if (message?.senderId !== "system") return text;
28
34
  // One edit can log several changes joined by "; "; translate each line.
29
35
  return text.split("; ").map((line) => formatLine(line, app)).join("; ");
@@ -0,0 +1,158 @@
1
+ /* Markdown document preview: a reading pane on wide windows, a modal overlay elsewhere. */
2
+ .doc-preview {
3
+ width: min(720px, calc(100vw - 24px));
4
+ max-width: none;
5
+ height: min(82dvh, 780px);
6
+ max-height: none;
7
+ margin: auto;
8
+ padding: 0;
9
+ overflow: hidden;
10
+ color: var(--ink);
11
+ background: linear-gradient(160deg, color-mix(in srgb, var(--surface) 94%, var(--accent-soft)), var(--surface));
12
+ border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
13
+ border-radius: 20px;
14
+ box-shadow: 0 24px 80px rgb(10 25 20 / .2);
15
+ }
16
+ .doc-preview[open] { display: flex; flex-direction: column; animation: doc-preview-in .18s ease-out both; }
17
+ .doc-preview::backdrop { background: rgb(9 22 18 / .52); backdrop-filter: blur(4px); }
18
+ @keyframes doc-preview-in { from { opacity: 0; transform: translateY(8px); } }
19
+
20
+ /* The pane is a third grid column inside the chat workspace, so the chat gets narrower
21
+ instead of being covered. Keep this query in sync with PANE_QUERY in doc-preview.js. */
22
+ .doc-preview.is-pane {
23
+ position: relative;
24
+ inset: auto;
25
+ grid-column: 3;
26
+ grid-row: 1 / -1;
27
+ width: auto;
28
+ height: auto;
29
+ min-width: 0;
30
+ min-height: 0;
31
+ margin: 0;
32
+ border: 0;
33
+ border-left: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
34
+ border-radius: 0;
35
+ background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 84%, var(--accent-soft)), var(--surface) 32%);
36
+ box-shadow: none;
37
+ animation: none;
38
+ }
39
+ @media (min-width: 1100px) and (min-height: 560px) {
40
+ #chatView.has-doc { grid-template-columns: 252px minmax(0, 1fr) clamp(380px, 30vw, 460px); }
41
+ }
42
+
43
+ .doc-preview-head {
44
+ display: flex;
45
+ flex: none;
46
+ align-items: flex-start;
47
+ justify-content: space-between;
48
+ gap: 10px;
49
+ padding: 16px 12px 12px 18px;
50
+ border-bottom: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
51
+ }
52
+ .doc-preview-heading { min-width: 0; }
53
+ .doc-preview-eyebrow {
54
+ display: flex;
55
+ align-items: center;
56
+ gap: 6px;
57
+ margin: 0 0 4px;
58
+ color: var(--accent);
59
+ font: 700 10px/1.3 var(--font-mono);
60
+ letter-spacing: .1em;
61
+ text-transform: uppercase;
62
+ }
63
+ .doc-preview-icon { width: 13px; height: 13px; }
64
+ .doc-preview-heading h2 {
65
+ margin: 0;
66
+ font-family: var(--font-display);
67
+ font-size: 19px;
68
+ font-weight: 650;
69
+ line-height: 1.3;
70
+ letter-spacing: -.015em;
71
+ overflow-wrap: anywhere;
72
+ }
73
+ /* The heading takes programmatic focus for screen readers; it does not need a ring. */
74
+ .doc-preview-heading h2:focus { outline: none; }
75
+ .doc-preview-meta { display: flex; flex-wrap: wrap; gap: 2px 10px; margin: 4px 0 0; color: var(--ink-3); font-size: 11.5px; line-height: 1.45; }
76
+ .doc-preview-actions { display: flex; flex: none; align-items: center; gap: 2px; }
77
+ .doc-preview-download { min-height: 36px; padding: 6px 12px; }
78
+ .doc-preview-actions .reader-close { width: 38px; height: 38px; }
79
+
80
+ .doc-preview-scroll {
81
+ flex: 1 1 auto;
82
+ min-height: 0;
83
+ padding: 20px 20px 32px;
84
+ overflow-x: hidden;
85
+ overflow-y: auto;
86
+ overscroll-behavior: contain;
87
+ -webkit-overflow-scrolling: touch;
88
+ scrollbar-gutter: stable;
89
+ }
90
+ .doc-preview.is-pane .doc-preview-scroll { padding: 18px 16px 28px 18px; }
91
+ .doc-preview-empty { margin: 0; padding: 28px 8px; text-align: center; }
92
+
93
+ /* Reuse the message typography without the chat bubble frame. */
94
+ .doc-preview-body {
95
+ display: block;
96
+ width: auto;
97
+ max-width: 100%;
98
+ min-width: 0;
99
+ margin: 0;
100
+ padding: 0;
101
+ border: 0;
102
+ border-radius: 0;
103
+ background: none;
104
+ box-shadow: none;
105
+ font-size: 15px;
106
+ line-height: 1.66;
107
+ white-space: normal;
108
+ overflow-wrap: anywhere;
109
+ }
110
+ .doc-preview-body > :first-child { margin-top: 0; }
111
+ .doc-preview-body h1, .doc-preview-body h2, .doc-preview-body h3, .doc-preview-body h4 {
112
+ margin: 1.4em 0 .45em;
113
+ font-family: var(--font-display);
114
+ font-weight: 650;
115
+ line-height: 1.28;
116
+ letter-spacing: -.02em;
117
+ }
118
+ .doc-preview-body h1 { margin-top: 0; font-size: 26px; }
119
+ .doc-preview-body h2 { padding-bottom: 6px; border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent); font-size: 21px; }
120
+ .doc-preview-body h3 { font-size: 17px; }
121
+ .doc-preview-body h4 { font-size: 15px; }
122
+ .doc-preview-body p { margin: 0 0 10px; }
123
+ .doc-preview-body ul, .doc-preview-body ol { padding-left: 24px; }
124
+ .doc-preview-body li { margin: 3px 0; }
125
+ .doc-preview-body li > p { margin: 0 0 4px; }
126
+ .doc-preview-body blockquote {
127
+ margin: 12px 0;
128
+ padding: 2px 0 2px 14px;
129
+ border-left: 3px solid color-mix(in srgb, var(--accent) 55%, var(--line));
130
+ color: var(--ink-2);
131
+ }
132
+ .doc-preview-body hr { margin: 18px 0; }
133
+ .doc-preview-body table { margin: 12px 0; font-size: 13px; }
134
+ .doc-preview-body .code-block { margin: 12px 0; }
135
+ .doc-preview-body pre { font-size: 12.5px; }
136
+ .doc-preview-body a { overflow-wrap: anywhere; text-underline-offset: 2px; }
137
+ .doc-preview-body img { max-width: 100%; height: auto; border-radius: 8px; cursor: default; }
138
+ .doc-preview-body .mermaid-diagram { margin: 12px 0; }
139
+
140
+ @media (max-width: 620px) {
141
+ .doc-preview { width: calc(100vw - 20px); height: min(84dvh, 780px); border-radius: 16px; }
142
+ .doc-preview-head { padding: 13px 8px 10px 14px; }
143
+ .doc-preview-heading h2 { font-size: 17px; }
144
+ .doc-preview-scroll { padding: 16px 14px 26px; }
145
+ .doc-preview-body { font-size: 14.5px; }
146
+ .doc-preview-body h1 { font-size: 23px; }
147
+ .doc-preview-body h2 { font-size: 19px; }
148
+ }
149
+ @media (max-width: 360px) {
150
+ .doc-preview { width: calc(100vw - 12px); }
151
+ .doc-preview-head { gap: 4px; padding: 11px 6px 9px 11px; }
152
+ .doc-preview-download { min-height: 32px; padding: 5px 8px; font-size: 11.5px; }
153
+ .doc-preview-actions .reader-close { width: 34px; height: 34px; }
154
+ .doc-preview-scroll { padding: 14px 11px 24px; }
155
+ }
156
+ @media (prefers-reduced-motion: reduce) {
157
+ .doc-preview[open] { animation: none; }
158
+ }
@@ -23,8 +23,15 @@
23
23
  #editRoomDialog .edit-room-panel { padding-top: 2px; }
24
24
 
25
25
  #editRoomDialog .edit-room-hint { margin: -2px 0 18px; }
26
+ /* Field labels line up their icon with the first line, matching the settings rows. */
27
+ #editRoomDialog .field-label:has(> .field-icon),
28
+ #editRoomDialog .join-policy-label:has(> .field-icon) { display: flex; align-items: center; gap: 8px; }
29
+ #editRoomDialog .field-icon { flex: none; width: 16px; height: 16px; color: var(--ink-3); }
26
30
  #editRoomDialog .admin-fieldset .hint:last-child { margin-bottom: 0; }
27
31
  #editRoomDialog .edit-room-owner-note {
32
+ display: flex;
33
+ align-items: flex-start;
34
+ gap: 8px;
28
35
  margin: 4px 0 0;
29
36
  padding: 10px 12px;
30
37
  border-left: 2px solid var(--accent);
@@ -32,6 +39,7 @@
32
39
  background: color-mix(in srgb, var(--accent-soft) 58%, transparent);
33
40
  line-height: 1.5;
34
41
  }
42
+ #editRoomDialog .edit-room-owner-note .field-icon { margin-top: 1px; }
35
43
 
36
44
  #editRoomDialog .edit-room-footer {
37
45
  display: grid;
@@ -127,8 +127,14 @@
127
127
  .settings-row:last-of-type { border-bottom: 0; }
128
128
  .settings-copy { min-width: 0; display: grid; gap: 4px; }
129
129
  .settings-label { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.35; }
130
+ /* One icon size and tone for every settings row, including the language row. */
131
+ .settings-label > .fluent-icon { flex: none; width: 16px; height: 16px; color: var(--ink-3); }
132
+ .field-icon { flex: none; width: 16px; height: 16px; color: var(--ink-3); }
130
133
  .settings-hint { margin: 0; color: var(--ink-3); font-size: 12.5px; line-height: 1.45; }
131
134
  .settings-warning { color: var(--warning); font-weight: 600; }
135
+ /* A caution hint keeps its icon on the first line at every width. */
136
+ .settings-icon-hint { display: flex; align-items: flex-start; gap: 6px; }
137
+ .settings-icon-hint .fluent-icon { flex: none; width: 14px; height: 14px; margin-top: 2px; }
132
138
  .settings-select { width: 168px; min-height: 38px; font-size: 13.5px; }
133
139
  .settings-range { display: flex; align-items: center; gap: 10px; width: 190px; }
134
140
  .settings-range input { flex: 1; min-width: 0; accent-color: var(--accent); cursor: pointer; }
@@ -142,7 +148,7 @@
142
148
  .settings-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
143
149
 
144
150
  .settings-block { min-width: 0; margin: 0; padding: 14px 0 4px; border: 0; }
145
- .settings-block legend.settings-label { display: block; margin: 0; padding: 0; }
151
+ .settings-block legend.settings-label { display: flex; align-items: center; gap: 8px; margin: 0; padding: 0; }
146
152
  .settings-block .settings-hint { margin-top: 4px; }
147
153
  .theme-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 10px; margin-top: 14px; }
148
154
  .theme-option { position: relative; display: grid; gap: 8px; min-width: 0; padding: 8px 8px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; }
@@ -167,7 +173,8 @@
167
173
  .settings-token-control { display: flex; align-items: center; gap: 8px; }
168
174
  .settings-token-control .input { width: 220px; min-height: 38px; }
169
175
  .settings-token-control .btn { flex: none; }
170
- .settings-note { margin: 18px 0 0; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--line) 82%, transparent); border-radius: 12px; background: color-mix(in srgb, var(--surface-2) 62%, var(--surface)); color: var(--ink-3); font-size: 12.5px; line-height: 1.5; }
176
+ .settings-note { display: flex; align-items: flex-start; gap: 8px; margin: 18px 0 0; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--line) 82%, transparent); border-radius: 12px; background: color-mix(in srgb, var(--surface-2) 62%, var(--surface)); color: var(--ink-3); font-size: 12.5px; line-height: 1.5; }
177
+ .settings-note-icon { flex: none; width: 16px; height: 16px; margin-top: 2px; }
171
178
 
172
179
  @media (max-width: 760px) {
173
180
  .settings-dialog { width: calc(100vw - 16px); height: calc(100dvh - 16px); border-radius: 18px; }
package/server/chat.html CHANGED
@@ -31,6 +31,7 @@
31
31
  <link rel="stylesheet" href="/assets/edit-room.css">
32
32
  <link rel="stylesheet" href="/assets/palette.css">
33
33
  <link rel="stylesheet" href="/assets/files.css">
34
+ <link rel="stylesheet" href="/assets/doc-preview.css">
34
35
  </head>
35
36
  <body>
36
37
 
@@ -177,14 +178,14 @@
177
178
  </div>
178
179
  <div class="settings-row">
179
180
  <div class="settings-copy">
180
- <label class="settings-label" for="inContentTransition" data-i18n="contentTransition">Room content transition</label>
181
+ <label class="settings-label" for="inContentTransition"><svg class="fluent-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-arrow_swap-24"></use></svg><span data-i18n="contentTransition">Room content transition</span></label>
181
182
  <p id="contentTransitionHint" class="settings-hint" data-i18n="contentTransitionHint">Slide messages in when switching rooms with Alt+Arrow. Off by default.</p>
182
183
  </div>
183
184
  <input id="inContentTransition" class="settings-switch" type="checkbox" role="switch" aria-describedby="contentTransitionHint">
184
185
  </div>
185
186
  <div class="settings-row settings-step-row">
186
187
  <div class="settings-copy">
187
- <label class="settings-label" for="inPageStep" data-i18n="pageStep">Page scroll distance</label>
188
+ <label class="settings-label" for="inPageStep"><svg class="fluent-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-arrow_down-24"></use></svg><span data-i18n="pageStep">Page scroll distance</span></label>
188
189
  <p id="pageStepHint" class="settings-hint" data-i18n="pageStepHint">How far PageUp and PageDown move per press, as a percentage of the conversation height. Default 90%.</p>
189
190
  </div>
190
191
  <div class="settings-range"><input id="inPageStep" type="range" min="20" max="200" step="5" value="90" aria-describedby="pageStepHint"><output id="pageStepValue" class="settings-range-value" for="inPageStep">90%</output></div>
@@ -192,7 +193,7 @@
192
193
  </section>
193
194
  <section id="settingsPanelAppearance" class="settings-panel" role="tabpanel" aria-labelledby="settingsTabAppearance" hidden>
194
195
  <fieldset class="settings-block">
195
- <legend class="settings-label" data-i18n="themeLabel">Theme</legend>
196
+ <legend class="settings-label"><svg class="fluent-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-circle_half_fill-24"></use></svg><span data-i18n="themeLabel">Theme</span></legend>
196
197
  <p class="settings-hint" data-i18n="settingsThemeHint">Saved in this browser. System follows your device.</p>
197
198
  <div class="theme-grid">
198
199
  <label class="theme-option" data-theme-choice="system">
@@ -226,16 +227,16 @@
226
227
  <section id="settingsPanelConnection" class="settings-panel" role="tabpanel" aria-labelledby="settingsTabConnection" hidden>
227
228
  <div class="settings-row settings-row-stack">
228
229
  <div class="settings-copy">
229
- <label class="settings-label" for="inTokenChat" data-i18n="tokenOptional">Access token (optional)</label>
230
+ <label class="settings-label" for="inTokenChat"><svg class="fluent-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-key-24"></use></svg><span data-i18n="tokenOptional">Access token (optional)</span></label>
230
231
  <p class="settings-hint" data-i18n="settingsTokenHint">Stored only in this browser. Needed only when the server asks for it.</p>
231
- <p id="tokenHint" class="settings-hint settings-warning" data-i18n="tokenRequired" hidden>The server requires an access token (401).</p>
232
+ <p id="tokenHint" class="settings-hint settings-warning settings-icon-hint" hidden><svg class="fluent-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-alert-24"></use></svg><span data-i18n="tokenRequired">The server requires an access token (401).</span></p>
232
233
  </div>
233
234
  <div class="settings-token-control">
234
235
  <input id="inTokenChat" class="input" type="password" placeholder="Enter if the server requires it" data-i18n-placeholder="tokenPlaceholder" autocomplete="off" spellcheck="false" aria-describedby="tokenHint">
235
236
  <button class="btn ghost small" type="button" data-token-save="inTokenChat" data-i18n="save">Save</button>
236
237
  </div>
237
238
  </div>
238
- <p class="settings-note" data-i18n="privacyNote">Anyone with the shared token can read direct messages and manage rooms; the server can read them too.</p>
239
+ <p class="settings-note"><svg class="fluent-icon settings-note-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-lock_closed-24"></use></svg><span data-i18n="privacyNote">Anyone with the shared token can read direct messages and manage rooms; the server can read them too.</span></p>
239
240
  </section>
240
241
  </div>
241
242
  </div>
@@ -317,27 +318,27 @@
317
318
  </nav>
318
319
  <div class="settings-content edit-room-content">
319
320
  <section id="editRoomPanelDetails" class="settings-panel edit-room-panel" role="tabpanel" aria-labelledby="editRoomTabDetails">
320
- <label class="field"><span class="field-label" data-i18n="roomNameLabel">Room name</span><input id="editRoomName" class="input" maxlength="64" autocomplete="off" required></label>
321
- <label class="field"><span class="field-label" data-i18n="roomDescriptionLabel">Description</span><textarea id="editRoomDescription" class="input" rows="3" maxlength="2000"></textarea></label>
321
+ <label class="field"><span class="field-label"><svg class="fluent-icon field-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-edit-24"></use></svg><span data-i18n="roomNameLabel">Room name</span></span><input id="editRoomName" class="input" maxlength="64" autocomplete="off" required></label>
322
+ <label class="field"><span class="field-label"><svg class="fluent-icon field-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-document-24"></use></svg><span data-i18n="roomDescriptionLabel">Description</span></span><textarea id="editRoomDescription" class="input" rows="3" maxlength="2000"></textarea></label>
322
323
  </section>
323
324
  <section id="editRoomPanelJoining" class="settings-panel edit-room-panel" role="tabpanel" aria-labelledby="editRoomTabJoining" hidden>
324
325
  <div class="join-policy admin-join-policy">
325
326
  <input id="editRoomJoinPolicy" type="checkbox" role="switch" aria-describedby="editRoomJoinPolicyHint">
326
- <label for="editRoomJoinPolicy" class="join-policy-label" data-i18n="requireApproval">Require approval to join</label>
327
+ <label for="editRoomJoinPolicy" class="join-policy-label"><svg class="fluent-icon field-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-shield_checkmark-24"></use></svg><span data-i18n="requireApproval">Require approval to join</span></label>
327
328
  </div>
328
329
  <p id="editRoomJoinPolicyHint" class="hint join-policy-hint" data-i18n="joinPolicyEditHint">New members need a human administrator's approval. Turning this off clears all pending requests.</p>
329
330
  </section>
330
331
  <section id="editRoomPanelMembers" class="settings-panel edit-room-panel" role="tabpanel" aria-labelledby="editRoomTabMembers" hidden>
331
- <fieldset class="admin-fieldset"><legend class="field-label" data-i18n="adminIdsLabel">Human administrators</legend><div id="editRoomAdminIds" class="admin-checklist"></div><p id="editRoomAdminIdsEmpty" class="hint" data-i18n="adminIdsEmpty" hidden>No other members are in this room yet.</p><p class="hint" data-i18n="adminIdsHint">These members can edit room details, manage members, delete files, and choose a successor. The owner always has the same powers.</p></fieldset>
332
- <label class="field"><span class="field-label" data-i18n="successorLabel">Successor if the owner leaves</span><select id="editRoomSuccessor" class="admin-select"></select></label>
332
+ <fieldset class="admin-fieldset"><legend class="field-label"><svg class="fluent-icon field-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-people-24"></use></svg><span data-i18n="adminIdsLabel">Human administrators</span></legend><div id="editRoomAdminIds" class="admin-checklist"></div><p id="editRoomAdminIdsEmpty" class="hint" data-i18n="adminIdsEmpty" hidden>No other members are in this room yet.</p><p class="hint" data-i18n="adminIdsHint">These members can edit room details, manage members, delete files, and choose a successor. The owner always has the same powers.</p></fieldset>
333
+ <label class="field"><span class="field-label"><svg class="fluent-icon field-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-arrow_swap-24"></use></svg><span data-i18n="successorLabel">Successor if the owner leaves</span></span><select id="editRoomSuccessor" class="admin-select"></select></label>
333
334
  <p class="hint edit-room-hint" data-i18n="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.</p>
334
- <p id="editRoomOwnerOnlyNote" class="hint edit-room-owner-note" data-i18n="ownerOnlySettingsNote" hidden>Only the owner can change the administrator agent or hand off the room.</p>
335
+ <p id="editRoomOwnerOnlyNote" class="hint edit-room-owner-note" hidden><svg class="fluent-icon field-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-lock_closed-24"></use></svg><span data-i18n="ownerOnlySettingsNote">Only the owner can change the administrator agent or hand off the room.</span></p>
335
336
  </section>
336
337
  <section id="editRoomPanelOwnership" class="settings-panel edit-room-panel" role="tabpanel" aria-labelledby="editRoomTabOwnership" hidden>
337
338
  <div id="editRoomOwnerOnly">
338
- <label class="field"><span class="field-label" data-i18n="adminAgentLabel">Administrator agent</span><select id="editRoomAdmin" class="admin-select"></select></label>
339
+ <label class="field"><span class="field-label"><svg class="fluent-icon field-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-options-24"></use></svg><span data-i18n="adminAgentLabel">Administrator agent</span></span><select id="editRoomAdmin" class="admin-select"></select></label>
339
340
  <p class="hint edit-room-hint" data-i18n="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.</p>
340
- <label class="field"><span class="field-label" data-i18n="newOwnerLabel">New owner</span><select id="editRoomOwner" class="admin-select"></select></label>
341
+ <label class="field"><span class="field-label"><svg class="fluent-icon field-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-key-24"></use></svg><span data-i18n="newOwnerLabel">New owner</span></span><select id="editRoomOwner" class="admin-select"></select></label>
341
342
  <p class="hint edit-room-hint" data-i18n="newOwnerHint">Hand the room to another person who is in it. Only the owner can do this; agents cannot own a room.</p>
342
343
  </div>
343
344
  </section>
@@ -525,6 +526,23 @@
525
526
  <p id="draftCount" class="draft-count">0 / 5000</p>
526
527
  </div>
527
528
  </footer>
529
+ <dialog id="docPreview" class="doc-preview" aria-labelledby="docPreviewTitle">
530
+ <header class="doc-preview-head">
531
+ <div class="doc-preview-heading">
532
+ <p class="doc-preview-eyebrow"><svg class="fluent-icon doc-preview-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-document-24"></use></svg><span data-i18n="docPreviewEyebrow">Markdown preview</span></p>
533
+ <h2 id="docPreviewTitle" tabindex="-1"></h2>
534
+ <p class="doc-preview-meta"><span id="docPreviewSize"></span><span id="docPreviewStatus" role="status" aria-live="polite"></span></p>
535
+ </div>
536
+ <div class="doc-preview-actions">
537
+ <button id="btnDocPreviewDownload" class="btn ghost small doc-preview-download" type="button" data-i18n="resourceDownload">Download</button>
538
+ <button id="btnCloseDocPreview" class="reader-close" type="button" aria-label="Close" data-i18n-aria-label="close"><svg class="fluent-icon close-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-dismiss-24"></use></svg></button>
539
+ </div>
540
+ </header>
541
+ <div class="doc-preview-scroll">
542
+ <article id="docPreviewBody" class="doc-preview-body msg-text"></article>
543
+ <p id="docPreviewEmpty" class="hint doc-preview-empty" data-i18n="docPreviewEmpty" hidden>This document is empty.</p>
544
+ </div>
545
+ </dialog>
528
546
  <div id="attachmentDropOverlay" class="attachment-drop-overlay" role="status" aria-live="polite" data-i18n="dropFilesHere" hidden></div>
529
547
  </section>
530
548
 
@@ -573,7 +591,7 @@
573
591
  </header>
574
592
  <div class="palette-search">
575
593
  <svg class="fluent-icon" aria-hidden="true" viewBox="0 0 24 24"><use href="/assets/fluent-icons.svg#fluent-search-24"></use></svg>
576
- <input id="paletteInput" class="input palette-input" type="text" role="combobox" aria-autocomplete="list" aria-expanded="true" aria-controls="paletteList" aria-describedby="paletteHint" aria-label="Search messages" data-i18n-aria-label="paletteSearchLabel" placeholder="Search messages, or type > for commands" data-i18n-placeholder="palettePlaceholder" autocomplete="off" autocapitalize="off" spellcheck="false" enterkeyhint="go">
594
+ <input id="paletteInput" class="input palette-input" type="text" role="combobox" aria-autocomplete="list" aria-expanded="true" aria-controls="paletteList" aria-describedby="paletteHint" aria-label="Search messages" data-i18n-aria-label="paletteSearchLabel" placeholder="Search messages, or type / for commands" data-i18n-placeholder="palettePlaceholder" autocomplete="off" autocapitalize="off" spellcheck="false" enterkeyhint="go">
577
595
  <span id="paletteMode" class="palette-mode" aria-hidden="true">Search</span>
578
596
  </div>
579
597
  <p id="paletteStatus" class="hint palette-status" role="status" aria-live="polite"></p>
package/server/sw.js CHANGED
@@ -16,6 +16,7 @@ const STATIC = [
16
16
  "/assets/edit-room.css",
17
17
  "/assets/palette.css",
18
18
  "/assets/files.css",
19
+ "/assets/doc-preview.css",
19
20
  "/assets/highlight-10.7.3.min.js",
20
21
  "/assets/icons/icon-192.png",
21
22
  "/assets/icons/icon-512.png",
package/src/tui/app.mjs CHANGED
@@ -2,6 +2,11 @@
2
2
  // the reducer can be tested against a fake api. Palette methods are attached
3
3
  // from palette-app.mjs.
4
4
  import { attachPalette } from "./palette-app.mjs";
5
+ import { attachInfo } from "./info-app.mjs";
6
+ import { attachReminders } from "./reminder-app.mjs";
7
+ import { attachRoomSettings } from "./room-settings-app.mjs";
8
+ import { attachMessageActions } from "./message-app.mjs";
9
+ import { attachJoinRequests } from "./join-app.mjs";
5
10
  import { mergeMessages, messageStamp, oldestSeq } from "./messages.mjs";
6
11
 
7
12
  const BACKOFF_MS = [1000, 2000, 4000, 8000, 15000];
@@ -16,12 +21,16 @@ const normalizeRoom = (room) => ({
16
21
  });
17
22
 
18
23
  export class ChatApp {
19
- constructor({ api, sessionID, participant, host = "", autoPoll = true, schedule = (fn, ms) => setTimeout(fn, ms) }) {
24
+ constructor({ api, sessionID, participant, host = "", autoPoll = true, settings = {}, downloadDir = process.cwd(), schedule = (fn, ms) => setTimeout(fn, ms) }) {
20
25
  this.api = api;
21
26
  this.sessionID = sessionID;
22
27
  this.participant = participant;
23
28
  this.autoPoll = autoPoll;
24
29
  this.schedule = schedule;
30
+ this.settings = { ...settings };
31
+ this.token = this.settings.token ?? "";
32
+ delete this.settings.token;
33
+ this.downloadDir = downloadDir;
25
34
  this.closed = false;
26
35
  this.pollToken = 0;
27
36
  this.timers = new Set();
@@ -35,6 +44,7 @@ export class ChatApp {
35
44
  this.state = {
36
45
  host,
37
46
  participant,
47
+ theme: "dark",
38
48
  connection: "connecting",
39
49
  rooms: [],
40
50
  selected: 0,
@@ -411,6 +421,11 @@ export class ChatApp {
411
421
  }
412
422
 
413
423
  attachPalette(ChatApp);
424
+ attachInfo(ChatApp);
425
+ attachReminders(ChatApp);
426
+ attachRoomSettings(ChatApp);
427
+ attachMessageActions(ChatApp);
428
+ attachJoinRequests(ChatApp);
414
429
 
415
430
  export function createApp(options) {
416
431
  return new ChatApp(options);