@alexsun-top/opencode-chat-room 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,204 @@
1
+ import { LS } from "./state.js";
2
+
3
+ export function initQuestions(app) {
4
+ const $ = app.$, pending = new Map(), selected = new Map(), drafts = new Map(), questionMode = new Map(), submitting = new Set();
5
+ let request = 0;
6
+ const panel = $("#questionPanel"), trigger = $("#btnQuestions"), list = $("#questionList"), status = $("#questionStatus");
7
+ app.isQuestionSending = () => Boolean(questionMode.get(app.state.room?.id));
8
+ $("#questionToggle").addEventListener("change", (event) => {
9
+ if (app.state.room) questionMode.set(app.state.room.id, event.target.checked);
10
+ });
11
+
12
+ const renderMessage = app.renderMessage;
13
+ app.renderMessage = (message, live) => {
14
+ const row = renderMessage(message, live);
15
+ if (message.isQuestion) {
16
+ row.classList.add("question-message");
17
+ const mark = document.createElement("span");
18
+ mark.className = "question-mark";
19
+ mark.textContent = app.t("questionLabel");
20
+ mark.setAttribute("aria-label", app.t("questionLabel"));
21
+ row.querySelector(".msg-meta")?.append(mark);
22
+ }
23
+ return row;
24
+ };
25
+
26
+ function render(roomId) {
27
+ const items = pending.get(roomId) || [];
28
+ const active = app.state.room?.id === roomId;
29
+ if (active) {
30
+ $("#questionBadge").textContent = items.length > 99 ? "99+" : String(items.length);
31
+ $("#questionBadge").hidden = !items.length;
32
+ trigger.setAttribute("aria-label", `${app.t("questions")}: ${items.length}`);
33
+ list.textContent = "";
34
+ for (const question of items) {
35
+ const item = document.createElement("li"), button = document.createElement("button");
36
+ button.type = "button";
37
+ button.className = "question-item";
38
+ button.dataset.questionId = question.id;
39
+ button.setAttribute("aria-pressed", String(selected.get(roomId) === question.id));
40
+ button.textContent = question.text;
41
+ item.append(button);
42
+ list.append(item);
43
+ }
44
+ status.hidden = items.length > 0 || status.dataset.error === "true";
45
+ if (!items.length && status.dataset.error !== "true") app.setText(status, "questionsEmpty");
46
+ renderReply(roomId);
47
+ }
48
+ }
49
+
50
+ function renderReply(roomId) {
51
+ const box = $("#questionReply"), question = (pending.get(roomId) || []).find((item) => item.id === selected.get(roomId));
52
+ if (question && box.dataset.roomId === roomId && box.dataset.questionId === question.id) {
53
+ const key = `${roomId}\0${question.id}`, input = box.querySelector("textarea"), send = box.querySelector("button");
54
+ box.hidden = false;
55
+ if (input && send) send.disabled = !input.value.trim() || submitting.has(key);
56
+ return;
57
+ }
58
+ box.textContent = "";
59
+ box.dataset.roomId = question ? roomId : "";
60
+ box.dataset.questionId = question?.id || "";
61
+ box.hidden = !question;
62
+ if (!question) return;
63
+ const heading = document.createElement("p"), form = document.createElement("form"), input = document.createElement("textarea"), send = document.createElement("button");
64
+ heading.className = "question-reply-quote";
65
+ heading.textContent = question.text;
66
+ form.className = "question-reply-form";
67
+ input.className = "input";
68
+ input.rows = 2;
69
+ input.maxLength = 2000;
70
+ input.placeholder = app.t("answerPlaceholder");
71
+ input.setAttribute("aria-label", app.t("answerPlaceholder"));
72
+ input.value = drafts.get(`${roomId}\0${question.id}`) || "";
73
+ const key = `${roomId}\0${question.id}`;
74
+ send.type = "submit";
75
+ send.className = "btn primary small";
76
+ send.textContent = app.t("sendAnswer");
77
+ send.disabled = !input.value.trim() || submitting.has(key);
78
+ input.addEventListener("input", () => {
79
+ drafts.set(`${roomId}\0${question.id}`, input.value);
80
+ send.disabled = !input.value.trim() || submitting.has(key);
81
+ });
82
+ form.addEventListener("submit", (event) => {
83
+ event.preventDefault();
84
+ void answer(roomId, question.id, input.value.trim(), send);
85
+ });
86
+ form.append(input, send);
87
+ box.append(heading, form);
88
+ }
89
+
90
+ async function load(roomId = app.state.room?.id) {
91
+ if (!roomId) return;
92
+ const id = ++request;
93
+ if (app.state.room?.id === roomId && !pending.has(roomId)) {
94
+ app.setText(status, "questionsLoading");
95
+ status.hidden = false;
96
+ }
97
+ try {
98
+ const result = await app.api(`/rooms/${encodeURIComponent(roomId)}/questions`);
99
+ if (id !== request || app.state.room?.id !== roomId || !Array.isArray(result.questions)) return;
100
+ pending.set(roomId, result.questions);
101
+ status.dataset.error = "false";
102
+ status.hidden = true;
103
+ render(roomId);
104
+ } catch (error) {
105
+ if (id !== request || app.state.room?.id !== roomId) return;
106
+ if (error.status === 401) app.openChatSettings();
107
+ status.dataset.error = "true";
108
+ app.setText(status, "questionsFailed");
109
+ status.hidden = false;
110
+ render(roomId);
111
+ }
112
+ }
113
+
114
+ async function answer(roomId, questionId, text, button) {
115
+ const key = `${roomId}\0${questionId}`;
116
+ if (!text || submitting.has(key)) return;
117
+ submitting.add(key);
118
+ button.disabled = true;
119
+ renderReply(roomId);
120
+ try {
121
+ const result = await app.api(`/rooms/${encodeURIComponent(roomId)}/questions/${encodeURIComponent(questionId)}/answers`, {
122
+ method: "POST", body: JSON.stringify({ sessionID: LS.sessionID, text }),
123
+ });
124
+ const entry = app.state.rooms.get(roomId);
125
+ if (entry && result.answer && !entry.room.messages.some((item) => item.id === result.answer.id)) {
126
+ entry.room.messages.push({ ...result.answer, roomId });
127
+ entry.room.messages.sort((left, right) => left.createdAt - right.createdAt);
128
+ if (entry.room.messages.length > 500) entry.room.messages.splice(0, entry.room.messages.length - 500);
129
+ if (app.state.room?.id === roomId) app.renderMessages(true);
130
+ }
131
+ pending.set(roomId, (pending.get(roomId) || []).filter((item) => item.id !== result.questionID));
132
+ if (selected.get(roomId) === questionId) selected.delete(roomId);
133
+ drafts.delete(`${roomId}\0${questionId}`);
134
+ if (app.state.room?.id === roomId) render(roomId);
135
+ void load(roomId);
136
+ } catch (error) {
137
+ if (error.status === 409 || error.status === 404) {
138
+ await load(roomId);
139
+ if (error.status === 409 && app.state.room?.id === roomId && !(pending.get(roomId) || []).some((item) => item.id === questionId)) {
140
+ if (selected.get(roomId) === questionId) selected.delete(roomId);
141
+ drafts.delete(`${roomId}\0${questionId}`);
142
+ app.setText(status, "questionAlreadyAnswered");
143
+ status.dataset.error = "true";
144
+ status.hidden = false;
145
+ render(roomId);
146
+ }
147
+ } else if (error.status === 401 && app.state.room?.id === roomId) {
148
+ app.openChatSettings();
149
+ app.showSendError("sendAuth");
150
+ } else if (app.state.room?.id === roomId) {
151
+ app.setText(status, "answerFailed");
152
+ status.hidden = false;
153
+ }
154
+ } finally {
155
+ submitting.delete(key);
156
+ if (app.state.room?.id === roomId) renderReply(roomId);
157
+ }
158
+ }
159
+
160
+ trigger.addEventListener("click", () => {
161
+ const open = panel.hidden;
162
+ app.closePanels();
163
+ panel.hidden = !open;
164
+ trigger.setAttribute("aria-expanded", String(open));
165
+ if (open) {
166
+ void load();
167
+ $("#questionHeading").focus();
168
+ }
169
+ });
170
+ $("#btnRefreshQuestions").addEventListener("click", () => void load());
171
+ list.addEventListener("click", (event) => {
172
+ event.stopPropagation();
173
+ const button = event.target.closest("[data-question-id]");
174
+ if (!button || !app.state.room) return;
175
+ selected.set(app.state.room.id, button.dataset.questionId);
176
+ render(app.state.room.id);
177
+ $("#questionReply textarea")?.focus();
178
+ });
179
+
180
+ const closePanels = app.closePanels;
181
+ app.closePanels = () => {
182
+ closePanels();
183
+ panel.hidden = true;
184
+ trigger.setAttribute("aria-expanded", "false");
185
+ };
186
+ document.addEventListener("keydown", (event) => {
187
+ if (event.key === "Escape" && !panel.hidden) {
188
+ app.closePanels();
189
+ trigger.focus();
190
+ }
191
+ });
192
+ const activateRoom = app.activateRoom;
193
+ app.activateRoom = (roomId) => {
194
+ activateRoom(roomId);
195
+ $("#questionToggle").checked = Boolean(questionMode.get(roomId));
196
+ void load(roomId);
197
+ };
198
+ const applyLocale = app.applyLocale;
199
+ app.applyLocale = () => {
200
+ applyLocale();
201
+ if (app.state.room) render(app.state.room.id);
202
+ };
203
+ setInterval(() => { if (app.state.room) void load(); }, 5000);
204
+ }
@@ -0,0 +1,112 @@
1
+ export function initReceipts(app) {
2
+ const $ = app.$, panel = $("#readerPanel");
3
+ let selectedID = "", trigger = null;
4
+ app.createReceiptButton = (message, own) => {
5
+ const button = document.createElement("button");
6
+ button.type = "button";
7
+ button.className = "message-readers";
8
+ button.dataset.messageId = message.id;
9
+ button.dataset.ownMessage = String(own);
10
+ button.setAttribute("aria-haspopup", "true");
11
+ button.setAttribute("aria-controls", "readerPanel");
12
+ updateButton(button, message, own);
13
+ return button;
14
+ };
15
+ app.renderReceiptData = (roomId, receipts) => {
16
+ const thread = $("#thread"), edge = thread.getBoundingClientRect();
17
+ const atBottom = thread.scrollHeight - thread.scrollTop - thread.clientHeight <= 2;
18
+ const anchor = [...$("#msgList").querySelectorAll("[data-msg-id]")].find((node) => node.getBoundingClientRect().bottom > edge.top);
19
+ const anchorId = anchor?.dataset.msgId, anchorTop = anchor ? anchor.getBoundingClientRect().top - edge.top : 0;
20
+ for (const receipt of receipts) app.state.receipts.set(`${roomId}\0${receipt.messageID}`, receipt.readers);
21
+ for (const button of $("#msgList").querySelectorAll(".message-readers")) {
22
+ const message = app.state.room?.messages.find((item) => item.id === button.dataset.messageId);
23
+ if (message) updateButton(button, message);
24
+ }
25
+ if (atBottom) thread.scrollTop = thread.scrollHeight;
26
+ else if (anchorId) {
27
+ const next = $("#msgList").querySelector(`[data-msg-id="${CSS.escape(anchorId)}"]`);
28
+ if (next) thread.scrollTop += next.getBoundingClientRect().top - thread.getBoundingClientRect().top - anchorTop;
29
+ }
30
+ if (selectedID) renderPanel();
31
+ };
32
+ $("#msgList").addEventListener("click", (event) => {
33
+ const button = event.target.closest(".message-readers");
34
+ if (!button) return;
35
+ if (selectedID === button.dataset.messageId) close(true);
36
+ else open(button.dataset.messageId, button);
37
+ });
38
+ $("#btnCloseReaders").addEventListener("click", () => close(true));
39
+ document.addEventListener("click", (event) => {
40
+ if (selectedID && !event.target.closest("#readerPanel, .message-readers")) close(false);
41
+ });
42
+ document.addEventListener("keydown", (event) => {
43
+ if (event.key === "Escape" && selectedID) { event.preventDefault(); close(true); }
44
+ });
45
+
46
+ function open(id, button) {
47
+ selectedID = id; trigger = button;
48
+ button.setAttribute("aria-expanded", "true");
49
+ preservePosition(() => {
50
+ $("#chatView").classList.add("reader-open"); panel.hidden = false; renderPanel();
51
+ }, () => $("#btnCloseReaders").focus());
52
+ }
53
+ function close(restoreFocus) {
54
+ if (!selectedID) return;
55
+ const previous = trigger;
56
+ selectedID = ""; trigger = null;
57
+ previous?.setAttribute("aria-expanded", "false");
58
+ preservePosition(() => {
59
+ panel.hidden = true; $("#chatView").classList.remove("reader-open");
60
+ }, () => { if (restoreFocus && previous?.isConnected) previous.focus({ preventScroll: true }); });
61
+ }
62
+ function preservePosition(change, after) {
63
+ const thread = $("#thread"), edge = thread.getBoundingClientRect();
64
+ const anchor = [...$("#msgList").querySelectorAll("[data-msg-id]")].find((node) => node.getBoundingClientRect().bottom > edge.top);
65
+ const id = anchor?.dataset.msgId, top = anchor?.getBoundingClientRect().top;
66
+ change();
67
+ requestAnimationFrame(() => {
68
+ const next = id && $("#msgList").querySelector(`[data-msg-id="${CSS.escape(id)}"]`);
69
+ if (next) thread.scrollTop += next.getBoundingClientRect().top - top;
70
+ after();
71
+ });
72
+ }
73
+ function renderPanel() {
74
+ const message = app.state.room?.messages.find((item) => item.id === selectedID);
75
+ if (!message) return close(false);
76
+ const readers = readersFor(message);
77
+ $("#readerHeading").textContent = app.t("readerPanelTitle");
78
+ $("#readerCount").textContent = readerStatus(message, readers);
79
+ $("#readerExcerpt").textContent = message.text;
80
+ const list = $("#readerList"); list.textContent = "";
81
+ const members = app.state.memberSessions.get(app.state.room.id) || [];
82
+ for (const reader of readers) {
83
+ const row = document.createElement("li"), name = document.createElement("span"), evidence = document.createElement("span");
84
+ const duplicates = members.filter((member) => member.name === reader.name).length > 1 || readers.filter((item) => item.name === reader.name).length > 1;
85
+ name.textContent = `${reader.name}${duplicates ? ` · ${reader.sessionID.slice(0, 8)}` : ""}${reader.currentMember === false ? ` · ${app.t("departedMember")}` : ""}`;
86
+ evidence.textContent = app.t(`receiptEvidence_${reader.evidence}`);
87
+ row.dataset.readerSessionId = reader.sessionID;
88
+ row.append(name, evidence); list.append(row);
89
+ }
90
+ }
91
+ function updateButton(button, message, own = button.dataset.ownMessage === "true") {
92
+ const readers = readersFor(message), count = readers.length, known = hasReceiptData(message);
93
+ const label = readerStatus(message, readers);
94
+ button.hidden = !own && count === 0;
95
+ button.textContent = String(count || (known ? 0 : "…"));
96
+ button.dataset.readerState = count ? "read" : known ? "empty" : "unknown";
97
+ button.setAttribute("aria-label", label);
98
+ button.setAttribute("aria-expanded", String(selectedID === message.id));
99
+ button.title = label;
100
+ }
101
+ function readersFor(message) {
102
+ const key = receiptKey(message);
103
+ const senderID = message.senderSessionID || (app.state.room?.kind === "direct" ? message.senderId : "");
104
+ return (app.state.receipts.get(key) || []).filter((reader) => reader.sessionID !== senderID);
105
+ }
106
+ function hasReceiptData(message) { return app.state.receipts.has(receiptKey(message)); }
107
+ function receiptKey(message) { return `${app.state.room?.id || message.roomId || ""}\0${message.id}`; }
108
+ function readerStatus(message, readers) {
109
+ if (readers.length) return app.t("receiptCount", { count: readers.length });
110
+ return app.t(hasReceiptData(message) ? "receiptNone" : "receiptNotLoaded");
111
+ }
112
+ }
@@ -180,8 +180,8 @@ export function createAuth(storage, fetcher, translate = (key) => key, sessionSt
180
180
 
181
181
  const messages = {
182
182
  en: {
183
- brand: "Casual Chat", documentTitle: "Casual Chat · Lightweight Chatroom",
184
- roomTitle: ({ name }) => `${name} · Casual Chat`,
183
+ brand: "OC Chat", documentTitle: "OC Chat",
184
+ roomTitle: ({ name }) => `${name} · OC Chat`,
185
185
  tagline: "A lightweight chat room. Enter a room ID to join, or create a new one.",
186
186
  languageLabel: "Language", roomIdLabel: "Room ID", roomIdPlaceholder: "Paste or enter a room ID",
187
187
  nameLabel: "Your name", namePlaceholder: "What should we call you?", joinRoom: "Join room",
@@ -193,6 +193,12 @@ const messages = {
193
193
  newRoom: "Create a room",
194
194
  copyRoomIdTitle: ({ id }) => `Click to copy the full room ID: ${id}`, copied: "Copied",
195
195
  members: "Members", membersCount: ({ count }) => `Members (${count})`, noMembers: "No members yet.",
196
+ questions: "Questions", pendingQuestions: "Pending questions", refreshQuestions: "Refresh",
197
+ questionsLoading: "Loading questions…", questionsEmpty: "No unanswered questions.",
198
+ questionsFailed: "Could not load questions. Try again.", questionLabel: "Question",
199
+ answerQuestion: "Reply", answerPlaceholder: "Write a reply…", sendAnswer: "Send reply",
200
+ answerFailed: "Reply failed. Your draft is still here.", questionAlreadyAnswered: "This question was answered elsewhere.",
201
+ sendAsQuestion: "Send as a question",
196
202
  settings: "Settings", tokenRequired: "The server requires an access token (401).",
197
203
  leave: "Leave", reconnecting: "Connection lost. Retrying…", messageList: "Message list",
198
204
  noMessages: "No messages yet. Say something.", latestMessages: "Back to latest messages",
@@ -204,6 +210,7 @@ const messages = {
204
210
  earlierMessages: "Earlier messages omitted", you: "You", saved: "Saved",
205
211
  savedMemory: "Saved for this tab only", copyFailed: ({ id }) => `Copy failed. Copy manually: ${id}`,
206
212
  copyCode: "Copy code", copiedCode: "Copied", copyCodeFailed: "Could not copy code. Select and copy it manually.",
213
+ copyMessage: "Copy", copiedMessage: "Copied", copyMessageFailed: "Could not copy. Select and copy the message manually.",
207
214
  identityChanged: "This browser identity changed in another tab. Reload this tab before continuing.",
208
215
  networkError: "Network connection failed", requestFailed: ({ status }) => `Request failed (HTTP ${status})`,
209
216
  roomIdRequired: "Enter a room ID", nameRequired: "Enter your name", authRetry: "The server requires an access token. Enter it and try again.",
@@ -224,11 +231,11 @@ const messages = {
224
231
  systemJoined: ({ name }) => `${name} joined the room`, systemLeft: ({ name }) => `${name} left the room`, systemRemoved: ({ name }) => `${name} was removed from the room`,
225
232
  activity_working: "Working", activity_idle: "Foreground idle", activity_waiting: "Waiting", activity_unknown: "Status unknown", activity_offline: "Status stale",
226
233
  activityHint_working: "The agent reports active work.", activityHint_idle: "Foreground is idle; background work may continue.", activityHint_waiting: "The agent reports that it is waiting.", activityHint_unknown: "No activity report is available.", activityHint_offline: "The last status is stale; this does not prove the agent is offline.",
227
- receiptCount: ({ count }) => `Read by ${count}`, departedMember: "left",
234
+ receiptCount: ({ count }) => `Read by ${count}`, receiptNone: "No readers yet", receiptNotLoaded: "Read status not loaded", readerPanelTitle: "Message readers", close: "Close", departedMember: "left",
228
235
  receiptEvidence_displayed: "Shown on screen", receiptEvidence_tool: "Fetched with room tool", receiptEvidence_context: "Full message reached agent context preparation (not proof of understanding)",
229
236
  },
230
237
  "zh-CN": {
231
- brand: "闲叙", documentTitle: "闲叙 · 轻量聊天室", roomTitle: ({ name }) => `${name} · 闲叙`,
238
+ brand: "OC Chat", documentTitle: "OC Chat", roomTitle: ({ name }) => `${name} · OC Chat`,
232
239
  tagline: "一个轻量的聊天房间。输入房间 ID 加入,或直接新建一个。", languageLabel: "语言",
233
240
  roomIdLabel: "房间 ID", roomIdPlaceholder: "粘贴或输入房间 ID", nameLabel: "你的昵称",
234
241
  namePlaceholder: "怎么称呼你", joinRoom: "加入房间", or: "或", newRoomNameLabel: "新房间名称",
@@ -239,6 +246,12 @@ const messages = {
239
246
  newRoom: "创建房间",
240
247
  copyRoomIdTitle: ({ id }) => `点击复制完整房间 ID:${id}`, copied: "已复制", members: "成员",
241
248
  membersCount: ({ count }) => `成员 ${count}`, noMembers: "暂无成员", settings: "设置",
249
+ questions: "提问", pendingQuestions: "待回答的问题", refreshQuestions: "刷新",
250
+ questionsLoading: "正在加载问题…", questionsEmpty: "没有待回答的问题。",
251
+ questionsFailed: "无法加载问题,请重试。", questionLabel: "问题",
252
+ answerQuestion: "回复", answerPlaceholder: "写下回复…", sendAnswer: "发送回复",
253
+ answerFailed: "回复失败,草稿仍已保留。", questionAlreadyAnswered: "此问题已由其他人回答。",
254
+ sendAsQuestion: "作为问题发送",
242
255
  tokenRequired: "服务器要求访问令牌(401)。", leave: "离开", reconnecting: "连接中断,正在重试…",
243
256
  messageList: "消息列表", noMessages: "还没有消息,说点什么吧。", latestMessages: "回到最新消息",
244
257
  mentionMembers: "选择要提及的成员", messagePlaceholder: "输入消息,Enter 发送,Shift+Enter 换行",
@@ -248,6 +261,7 @@ const messages = {
248
261
  today: "今天", yesterday: "昨天", earlierMessages: "更早的消息已省略", you: "我", saved: "已保存",
249
262
  savedMemory: "仅保存于当前标签页", copyFailed: ({ id }) => `复制失败,请手动复制:${id}`,
250
263
  copyCode: "复制代码", copiedCode: "已复制", copyCodeFailed: "复制失败,请手动选择并复制代码。",
264
+ copyMessage: "复制", copiedMessage: "已复制", copyMessageFailed: "复制失败,请手动选择并复制消息。",
251
265
  identityChanged: "此浏览器身份已在另一个标签页中更改,请重新加载此标签页后继续。",
252
266
  networkError: "网络连接失败", requestFailed: ({ status }) => `请求失败(HTTP ${status})`,
253
267
  roomIdRequired: "请输入房间 ID", nameRequired: "请输入你的昵称", authRetry: "服务器要求访问令牌,请填写后重试",
@@ -265,7 +279,7 @@ const messages = {
265
279
  systemJoined: ({ name }) => `${name} 加入了房间`, systemLeft: ({ name }) => `${name} 离开了房间`, systemRemoved: ({ name }) => `${name} 被移出了房间`,
266
280
  activity_working: "工作中", activity_idle: "前台空闲", activity_waiting: "等待中", activity_unknown: "状态未知", activity_offline: "状态已过期",
267
281
  activityHint_working: "Agent 正在报告工作状态。", activityHint_idle: "前台空闲;后台任务仍可能继续。", activityHint_waiting: "Agent 正在报告等待状态。", activityHint_unknown: "暂无活动状态报告。", activityHint_offline: "最近的状态已过期;这不能证明 Agent 已离线。",
268
- receiptCount: ({ count }) => `已读 ${count} 人`, departedMember: "已离开",
282
+ receiptCount: ({ count }) => `已读 ${count} 人`, receiptNone: "尚无人已读", receiptNotLoaded: "尚未加载已读状态", readerPanelTitle: "消息已读情况", close: "关闭", departedMember: "已离开",
269
283
  receiptEvidence_displayed: "已显示在屏幕上", receiptEvidence_tool: "通过房间工具读取", receiptEvidence_context: "完整消息已进入 Agent 上下文准备阶段(不代表已理解)",
270
284
  },
271
285
  };
@@ -8,8 +8,8 @@
8
8
  border-bottom: 1px solid var(--line);
9
9
  background: var(--surface);
10
10
  }
11
- .chat-head-main h1 { margin: 0; font-family: var(--font-serif); font-size: 19px; letter-spacing: .02em; }
12
- .room-meta { margin: 2px 0 0; font-size: 12px; color: var(--ink-3); }
11
+ .chat-head-main h1 { margin: 0; font-family: var(--font-sans); font-size: 20px; font-weight: 650; line-height: 1.25; letter-spacing: -.02em; }
12
+ .room-meta { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); }
13
13
  .mono { font-family: var(--font-mono); }
14
14
  .copy-id {
15
15
  appearance: none;
@@ -29,10 +29,25 @@
29
29
  .copy-id.copied .copy-ok { display: inline; color: var(--accent); }
30
30
 
31
31
  .chat-head-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
32
+ .question-panel { width: min(390px, calc(100vw - 32px)); max-height: min(70vh, 620px); overflow: auto; }
33
+ .questions-trigger { position: relative; }
34
+ .question-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
35
+ .question-panel-head h3 { margin-bottom: 0; }
36
+ .question-refresh { border: 0; padding: 4px 7px; color: var(--accent); background: transparent; font: inherit; font-size: 12px; cursor: pointer; }
37
+ .question-list { list-style: none; max-height: 260px; overflow: auto; margin: 10px 0 0; padding: 0; }
38
+ .question-item { width: 100%; padding: 9px 10px; border: 1px solid transparent; border-radius: 9px; color: var(--ink); background: transparent; font: inherit; font-size: 13px; line-height: 1.5; text-align: left; overflow-wrap: anywhere; cursor: pointer; }
39
+ .question-item:hover, .question-item[aria-pressed="true"] { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); background: var(--accent-soft); }
40
+ .question-reply { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
41
+ .question-reply-quote { max-height: 72px; overflow: auto; margin: 0 0 8px; padding: 8px 10px; border-left: 3px solid var(--accent); border-radius: 4px; background: var(--surface-2); font-size: 12px; overflow-wrap: anywhere; }
42
+ .question-reply-form { display: grid; gap: 8px; }
43
+ .question-reply-form textarea { min-height: 62px; resize: vertical; }
44
+ .question-reply-form .btn { justify-self: end; }
45
+ .question-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 5px; padding: 0 4px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 10px; }
32
46
  .chip {
33
47
  appearance: none;
34
48
  font: inherit;
35
49
  font-size: 13px;
50
+ line-height: 1.25;
36
51
  font-weight: 600;
37
52
  color: var(--ink-2);
38
53
  background: var(--surface);
@@ -77,6 +92,7 @@
77
92
  #memberList .member-activity + .member-actions { grid-column: 2; grid-row: 2; }
78
93
  #memberList .member-action { white-space: normal; }
79
94
  #memberList li:last-child { border-bottom: none; }
95
+ #chatSettings [data-i18n="privacyNote"] { min-height: 63px; line-height: 21px; }
80
96
  .m-time { font-size: 11.5px; color: var(--ink-3); }
81
97
  .member-activity { flex: none; padding: 2px 6px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: 10px; }
82
98
  .member-activity.working { color: var(--accent); background: var(--accent-soft); }
@@ -164,29 +180,57 @@
164
180
  .msg.own { align-items: flex-end; }
165
181
  .msg.repeat { margin-bottom: 8px; }
166
182
  .msg-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
167
- .msg-name { font-size: 13px; font-weight: 600; color: var(--ink); }
183
+ .msg-name { font-size: 14px; font-weight: 600; color: var(--ink); }
168
184
  .msg.own .msg-name { color: var(--accent); }
185
+ .question-mark { padding: 1px 6px; border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 999px; color: var(--accent); background: var(--accent-soft); font-size: 10px; line-height: 1.5; }
169
186
  .msg.repeat .msg-name { display: none; }
170
- .msg-time { font-size: 11.5px; color: var(--ink-3); }
187
+ .msg-time { font-size: 12px; color: var(--ink-2); }
171
188
  .msg-text {
172
189
  display: inline-block;
190
+ width: max-content;
173
191
  max-width: min(86%, 540px);
174
192
  padding: 8px 12px;
175
193
  border-radius: 14px;
176
194
  background: var(--surface-2);
177
195
  border-bottom-left-radius: 4px;
178
- font-size: 15px;
179
- line-height: 1.65;
196
+ font-size: 16px;
197
+ line-height: 1.6;
180
198
  white-space: normal;
181
199
  overflow-wrap: anywhere;
182
200
  }
183
201
  .msg.own .msg-text { background: var(--accent-soft); border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
184
- .message-readers { margin-top: 4px; color: var(--ink-3); font-size: 11px; }
185
- .message-readers summary { cursor: pointer; }
186
- .receipt-reader-list { margin: 4px 0 0; padding: 5px 8px; list-style: none; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
202
+ .msg-content { position: relative; display: flex; align-items: flex-end; gap: 6px; width: 100%; max-width: 100%; }
203
+ .msg.own .msg-content { flex-direction: row-reverse; }
204
+ .message-copy {
205
+ align-self: flex-start;
206
+ margin: 2px 0 0 4px;
207
+ padding: 2px 6px;
208
+ border: 0;
209
+ border-radius: 5px;
210
+ color: var(--ink-3);
211
+ background: transparent;
212
+ font: inherit;
213
+ font-size: 11px;
214
+ cursor: pointer;
215
+ }
216
+ .msg.own .message-copy { align-self: flex-end; margin-right: 4px; }
217
+ .message-copy:hover, .message-copy:focus-visible { color: var(--ink); background: var(--surface-2); }
218
+ .message-copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
219
+ .message-readers { flex: 0 0 22px; align-self: flex-end; margin: 0 0 4px; padding: 0; width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink-3); background: var(--surface); font: inherit; font-size: 10px; cursor: pointer; }
220
+ .message-readers[data-reader-state="empty"], .message-readers[data-reader-state="unknown"] { background: var(--surface-2); }
221
+ .message-readers:hover, .message-readers[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
222
+ .message-readers:focus-visible, .reader-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
223
+ .receipt-reader-list { margin: 0; padding: 0; list-style: none; }
187
224
  .receipt-reader-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
188
225
  .receipt-reader-list li + li { margin-top: 4px; }
189
226
  .receipt-reader-list li span:last-child { color: var(--ink-3); }
227
+ .reader-panel { min-width: 0; grid-column: 3; grid-row: 2 / 5; overflow: auto; padding: 20px 16px; border-left: 1px solid var(--line); background: var(--surface); }
228
+ .reader-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
229
+ .reader-panel-head h2 { margin: 0; font-family: var(--font-sans); font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
230
+ .reader-panel-head .hint { margin: 0 0 4px; }
231
+ .reader-close { flex: none; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink-2); background: var(--surface); font: inherit; font-size: 21px; cursor: pointer; }
232
+ .reader-excerpt { max-height: 110px; overflow: auto; margin: 16px 0; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--surface-2); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
233
+ .reader-panel .receipt-reader-list li { display: grid; gap: 3px; padding: 10px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
190
234
 
191
235
  /* Markdown content */
192
236
  .msg-text p, .msg-text pre, .msg-text blockquote, .msg-text ul, .msg-text ol { margin: 0; }
@@ -297,15 +341,18 @@
297
341
  }
298
342
 
299
343
  .sys {
344
+ position: relative;
300
345
  display: flex;
346
+ flex-direction: column;
301
347
  align-items: center;
302
- gap: 12px;
348
+ gap: 8px;
303
349
  margin: 20px 0;
304
350
  font-size: 12.5px;
305
351
  color: var(--ink-2);
306
352
  }
307
- .sys::before, .sys::after { content: ""; flex: 1; height: 1px; background: var(--line); }
308
- .sys span { flex-shrink: 0; }
353
+ .sys::before { content: ""; position: absolute; top: 9px; left: 0; right: 0; height: 1px; background: var(--line); }
354
+ .sys span { position: relative; padding: 0 10px; background: var(--surface); }
355
+ .sys .message-copy { align-self: center; margin: -8px 0 0; }
309
356
 
310
357
  .day-sep {
311
358
  display: flex;
@@ -343,6 +390,8 @@
343
390
  background: var(--surface);
344
391
  }
345
392
  .composer-row { display: flex; gap: 10px; align-items: flex-end; }
393
+ .question-toggle { width: min(940px, 100%); margin: -2px auto 0; color: var(--ink-2); font-size: 12px; }
394
+ .question-toggle input { accent-color: var(--accent); vertical-align: -1px; }
346
395
  .composer .input { flex: 1; }
347
396
  .composer .input:disabled { opacity: .5; }
348
397
  #msgInput {
@@ -34,8 +34,8 @@
34
34
  background: linear-gradient(155deg, color-mix(in srgb, var(--accent) 11%, var(--surface)) 0%, var(--surface) 52%);
35
35
  border-right: 1px solid var(--line);
36
36
  }
37
- .rail-brand { display: flex; align-items: center; gap: 10px; margin: 0 0 35px 5px; font-family: var(--font-serif); font-size: 18px; font-weight: 700; letter-spacing: .04em; }
38
- .brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 11px 11px 11px 4px; background: var(--accent); color: var(--accent-ink); font: 700 17px var(--font-serif); }
37
+ .rail-brand { display: flex; align-items: center; gap: 10px; margin: 0 0 35px 5px; font-family: var(--font-sans); font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
38
+ .brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 11px 11px 11px 4px; background: var(--accent); color: var(--accent-ink); font: 700 11px var(--font-sans); }
39
39
  .rail-label { display: flex; align-items: center; justify-content: space-between; margin: 0 8px 10px; color: var(--ink-3); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
40
40
  .rail-tools { display: flex; align-items: center; gap: 7px; }
41
41
  .icon-btn { border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: 20px; cursor: pointer; }
@@ -63,6 +63,8 @@
63
63
  .msg-text { max-width: min(82%, 680px); padding: 10px 14px; }
64
64
  .composer { padding: 14px 24px calc(14px + env(safe-area-inset-bottom)); }
65
65
  .composer-row { max-width: 940px; width: 100%; margin: 0 auto; }
66
+ #chatView.reader-open { grid-template-columns: 252px minmax(0, 1fr) 320px; }
67
+ #chatView.reader-open > .chat-head { grid-column: 2 / 4; }
66
68
  .member-actions { display: flex; gap: 6px; }
67
69
  .member-action { border: 0; background: transparent; padding: 2px 4px; color: var(--accent); font: inherit; font-size: 11px; cursor: pointer; white-space: nowrap; }
68
70
  .member-action:hover { text-decoration: underline; }
@@ -94,18 +96,25 @@
94
96
  #chatView > .conn-bar { grid-column: 1; grid-row: 3; }
95
97
  #chatView > .msg-scroll { grid-column: 1; grid-row: 4; }
96
98
  #chatView > .composer { grid-column: 1; grid-row: 5; }
99
+ #chatView.reader-open { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr) minmax(140px, 34dvh) auto; }
100
+ #chatView.reader-open > .chat-head { grid-column: 1; }
101
+ #chatView.reader-open > .composer { grid-row: 6; }
102
+ .reader-panel { grid-column: 1; grid-row: 5; padding: 10px 14px; border-top: 1px solid var(--line); border-left: 0; }
103
+ .reader-excerpt { max-height: 46px; margin: 8px 0; padding: 6px 9px; }
97
104
  .chat-head-actions { flex: none; flex-wrap: nowrap; gap: 4px; }
98
105
  .chat-head-actions > .locale-control { display: none; }
99
106
  .chat-head-main { flex: 1; min-width: 0; }
100
107
  .chat-head-main h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; }
101
108
  .chat-head .chip { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; font-size: 0; }
109
+ #btnQuestions::before { content: "?"; font-size: 17px; }
110
+ #btnQuestions .question-badge { position: absolute; top: -5px; right: -5px; margin: 0; font-size: 10px; }
102
111
  #btnMembers::before { content: "♧"; font-size: 18px; }
103
112
  #btnSettings::before { content: "⋯"; font-size: 21px; }
104
113
  #btnDeleteRoom::before { content: "×"; font-size: 20px; }
105
114
  #btnLeave::before { content: "↪"; font-size: 17px; }
106
115
  .mobile-locale { display: block; }
107
116
  .thread { padding: 14px 12px 6px; }
108
- .msg-text { max-width: 92%; font-size: 14px; }
117
+ .msg-text { max-width: 92%; font-size: 15px; }
109
118
  .composer { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
110
119
  #msgInput { min-height: 70px; padding: 9px 11px; line-height: 1.45; }
111
120
  #btnSend { padding: 12px 15px; }
@@ -117,3 +126,8 @@
117
126
  .chat-head-actions .panel { position: fixed; top: calc(env(safe-area-inset-top) + 196px); left: 12px; right: 12px; width: auto; max-height: min(55dvh, 420px); overflow: auto; }
118
127
  .room-meta { max-width: 100px; overflow: hidden; }
119
128
  }
129
+ @media (max-width: 220px) {
130
+ #chatView > .chat-head { padding: 8px; gap: 4px; }
131
+ .chat-head-actions { gap: 2px; }
132
+ .chat-head-actions .chip { width: 28px; height: 28px; }
133
+ }