@alexsun-top/opencode-chat-room 0.8.0 → 0.8.1
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.
- package/CHANGELOG.md +29 -0
- package/LICENSE +2 -2
- package/README.md +38 -6
- package/README.zh-CN.md +38 -6
- package/cli.ts +27 -1
- package/dist/cli.js +5074 -3212
- package/package.json +23 -3
- package/packages/chat-room-channeld/README.md +98 -25
- package/packages/chat-room-channeld/dist/feishu-adapter.js +912 -149
- package/packages/chat-room-channeld/src/adapter.ts +36 -2
- package/packages/chat-room-channeld/src/config.ts +63 -1
- package/packages/chat-room-channeld/src/delivery.ts +6 -1
- package/packages/chat-room-channeld/src/feishu-adapter.ts +122 -292
- package/packages/chat-room-channeld/src/feishu-card.ts +27 -0
- package/packages/chat-room-channeld/src/feishu-inbound.ts +158 -0
- package/packages/chat-room-channeld/src/feishu-live.ts +355 -0
- package/packages/chat-room-channeld/src/feishu-send.ts +342 -0
- package/packages/chat-room-channeld/src/feishu-ws-frames.ts +173 -0
- package/packages/chat-room-channeld/src/host-helpers.ts +11 -0
- package/packages/chat-room-channeld/src/host.ts +120 -2
- package/packages/chat-room-channeld/src/inbound.ts +26 -0
- package/packages/chat-room-channeld/src/state.ts +17 -0
- package/packages/chat-room-channeld/src/stats.ts +43 -1
- package/server/admin-state.ts +13 -13
- package/server/app.ts +95 -0
- package/server/assets/NOTICE.txt +2 -1
- package/server/assets/base.css +15 -9
- package/server/assets/chat/announcements.js +70 -7
- package/server/assets/chat/doc-preview.js +184 -35
- package/server/assets/chat/events.js +3 -0
- package/server/assets/chat/files.js +46 -4
- package/server/assets/chat/index.js +2 -0
- package/server/assets/chat/integration-editor.js +163 -0
- package/server/assets/chat/integration-values.js +124 -0
- package/server/assets/chat/integrations.js +498 -0
- package/server/assets/chat/locales/de.js +40 -4
- package/server/assets/chat/locales/es.js +40 -4
- package/server/assets/chat/locales/fr.js +40 -4
- package/server/assets/chat/locales/it.js +40 -4
- package/server/assets/chat/locales/ja.js +40 -4
- package/server/assets/chat/locales/ko.js +40 -4
- package/server/assets/chat/markdown.js +22 -8
- package/server/assets/chat/messages.js +5 -5
- package/server/assets/chat/office-preview.js +69 -0
- package/server/assets/chat/panels.js +36 -0
- package/server/assets/chat/recall.js +58 -7
- package/server/assets/chat/receipts.js +15 -3
- package/server/assets/chat/reminders.js +69 -8
- package/server/assets/chat/resource-format.js +11 -0
- package/server/assets/chat/settings.js +30 -2
- package/server/assets/chat/side-pane.js +1 -2
- package/server/assets/chat/state.js +93 -10
- package/server/assets/chat/system-events.js +32 -0
- package/server/assets/chat/system-messages.js +23 -14
- package/server/assets/chat/task-row.js +0 -6
- package/server/assets/chat/tasks.js +121 -33
- package/server/assets/code-highlight.css +55 -32
- package/server/assets/conversation.css +123 -23
- package/server/assets/doc-preview.css +35 -3
- package/server/assets/files.css +5 -0
- package/server/assets/fluent-icons.svg +2 -0
- package/server/assets/monaco/LICENSE +21 -0
- package/server/assets/monaco/ThirdPartyNotices.txt +448 -0
- package/server/assets/monaco/codicon-jdswhhtn.ttf +0 -0
- package/server/assets/monaco/editor.worker.js +45 -0
- package/server/assets/monaco/integration-rules.css +1 -0
- package/server/assets/monaco/integration-rules.js +1297 -0
- package/server/assets/monaco/json.worker.js +77 -0
- package/server/assets/office/THIRD-PARTY-NOTICES.txt +11 -0
- package/server/assets/office/docx.bundle.js +33 -0
- package/server/assets/office/licenses/docx-preview-LICENSE.txt +201 -0
- package/server/assets/office/licenses/echarts-LICENSE.txt +222 -0
- package/server/assets/office/licenses/jszip-LICENSE.txt +651 -0
- package/server/assets/office/licenses/lodash-LICENSE.txt +47 -0
- package/server/assets/office/licenses/pptx-preview-LICENSE.txt +8 -0
- package/server/assets/office/licenses/tslib-LICENSE.txt +12 -0
- package/server/assets/office/licenses/uuid-LICENSE.txt +9 -0
- package/server/assets/office/licenses/xlsx-LICENSE.txt +201 -0
- package/server/assets/office/licenses/zrender-LICENSE.txt +29 -0
- package/server/assets/office/pptx.bundle.js +104 -0
- package/server/assets/office/xlsx.bundle.js +141 -0
- package/server/assets/recall.css +5 -4
- package/server/assets/responsive.css +50 -11
- package/server/assets/settings.css +73 -1
- package/server/assets/tasks.css +57 -7
- package/server/channel-integration.ts +519 -0
- package/server/channel-settings.ts +77 -0
- package/server/channels.ts +261 -18
- package/server/chat-server.ts +32 -580
- package/server/chat.html +187 -21
- package/server/http-server.ts +3 -182
- package/server/resource-routes.ts +16 -16
- package/server/routes/inbox.ts +100 -0
- package/server/routes/pages.ts +83 -0
- package/server/routes/questions.ts +39 -0
- package/server/routes/room-actions.ts +162 -0
- package/server/routes/rooms.ts +160 -0
- package/server/startup.ts +84 -0
- package/server/sw.js +4 -0
- package/server/task-routes.ts +1 -1
- package/src/center/center-client.ts +2 -10
- package/src/config/file-config.ts +7 -54
- package/src/platform/http-server.ts +182 -0
- package/src/protocol/addressing.ts +21 -0
- package/src/protocol/config.ts +58 -0
- package/src/protocol/room.ts +51 -0
- package/src/rooms/resources.ts +26 -16
- package/src/rooms/room-service.ts +2 -48
- package/src/rooms/storage.ts +329 -0
- package/src/rooms/tasks.ts +21 -5
- package/src/runtime/watch.ts +1 -1
- package/src/state/pg-database.ts +183 -0
- package/src/state/pg-migrate.ts +175 -0
- package/src/state/pg-sql.mjs +175 -0
- package/src/state/pg-worker.mjs +148 -0
- package/src/state/sqlite-announcements.ts +25 -0
- package/src/state/sqlite-database.ts +121 -0
- package/src/state/sqlite-legacy.ts +90 -0
- package/src/state/sqlite-members.ts +155 -0
- package/src/state/sqlite-messages.ts +288 -0
- package/src/state/sqlite-resources.ts +39 -0
- package/src/state/sqlite-rooms.ts +87 -0
- package/src/state/sqlite-schema.ts +80 -0
- package/src/state/sqlite-state-store.ts +33 -0
- package/src/state/sqlite-state.ts +15 -897
- package/src/state/sqlite-tasks.ts +65 -0
- package/src/state/sqlite-transaction.ts +13 -0
- package/src/state/sqlite.ts +21 -1
- package/src/state/store.ts +5 -1
- package/src/tui/app.mjs +32 -19
- package/src/tui/config.mjs +12 -4
- package/src/tui/i18n.mjs +38 -0
- package/src/tui/info-app.mjs +50 -51
- package/src/tui/info-content.mjs +79 -44
- package/src/tui/join-app.mjs +9 -9
- package/src/tui/locales/en.mjs +349 -0
- package/src/tui/locales/zh-CN.mjs +349 -0
- package/src/tui/main.mjs +85 -37
- package/src/tui/markdown.mjs +3 -2
- package/src/tui/mentions.mjs +3 -1
- package/src/tui/message-app.mjs +22 -21
- package/src/tui/message-view.mjs +2 -1
- package/src/tui/palette-app.mjs +9 -8
- package/src/tui/palette.mjs +30 -24
- package/src/tui/prefs.mjs +92 -0
- package/src/tui/reminder-app.mjs +18 -17
- package/src/tui/room-settings-app.mjs +30 -28
- package/src/tui/settings-app.mjs +153 -0
- package/src/tui/ui-content.mjs +65 -86
- package/src/tui/ui-help.mjs +73 -0
- package/src/tui/ui-overlay-view.mjs +23 -7
- package/src/tui/ui-suggest.mjs +6 -5
- package/src/tui/ui-theme.mjs +37 -33
- package/src/tui/ui-view.mjs +22 -7
- package/src/tui/ui.mjs +15 -3
- package/src/web/editor.worker.ts +1 -0
- package/src/web/integration-rules-editor.ts +439 -0
- package/src/web/integration-rules.ts +22 -0
- package/src/web/integration-schema.ts +228 -0
- package/src/web/json.worker.ts +1 -0
- package/src/web/office-viewer.ts +221 -0
|
@@ -77,6 +77,7 @@ export function renderMarkdown(root, text, app) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
decorateLinks(fragment);
|
|
80
|
+
wrapTables(fragment);
|
|
80
81
|
fragment.querySelectorAll('input[type="checkbox"]').forEach((input) => { input.disabled = true; });
|
|
81
82
|
const codeBlocks = [...fragment.querySelectorAll("pre > code")];
|
|
82
83
|
for (const code of codeBlocks) decorateCodeBlock(code, app);
|
|
@@ -90,20 +91,32 @@ export function renderMarkdown(root, text, app) {
|
|
|
90
91
|
for (const resource of resources) void loadResourceCard(resource.card, resource.roomId, app);
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
// A narrow screen scrolls the table inside a frame instead of widening the message.
|
|
95
|
+
function wrapTables(fragment) {
|
|
96
|
+
for (const table of fragment.querySelectorAll("table")) {
|
|
97
|
+
const wrapper = document.createElement("div");
|
|
98
|
+
wrapper.className = "markdown-table";
|
|
99
|
+
table.replaceWith(wrapper);
|
|
100
|
+
wrapper.append(table);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
93
104
|
function decorateCodeBlock(code, app) {
|
|
94
105
|
const pre = code.parentElement;
|
|
95
106
|
if (!pre || pre.closest(".mermaid-diagram") || pre.parentElement?.classList.contains("code-block")) return;
|
|
96
|
-
const block = document.createElement("div");
|
|
107
|
+
const block = document.createElement("div"), head = document.createElement("div");
|
|
97
108
|
block.className = "code-block";
|
|
109
|
+
head.className = "code-block-head";
|
|
98
110
|
pre.replaceWith(block);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
});
|
|
111
|
+
const language = (/language-(\S+)/.exec(code.className) || [])[1];
|
|
112
|
+
if (language) {
|
|
113
|
+
const label = document.createElement("span");
|
|
114
|
+
label.className = "code-language";
|
|
115
|
+
label.textContent = language.toLowerCase();
|
|
116
|
+
head.append(label);
|
|
106
117
|
}
|
|
118
|
+
head.append(codeToolbar(code, pre, block, app));
|
|
119
|
+
block.append(head, pre);
|
|
107
120
|
}
|
|
108
121
|
|
|
109
122
|
function codeToolbar(code, pre, block, app) {
|
|
@@ -228,6 +241,7 @@ async function loadResourceCard(card, roomId, app) {
|
|
|
228
241
|
const preview = resourceButton("resourcePreview", resource.name, () => docFormat
|
|
229
242
|
? app.openDocPreview(roomId, resource, preview)
|
|
230
243
|
: previewResource(card, roomId, id, resource, type, preview, app, status), app);
|
|
244
|
+
preview.dataset.previewResource = resource.id;
|
|
231
245
|
actions.append(preview);
|
|
232
246
|
// Media you sent yourself is shown inline; other people's media stays collapsed.
|
|
233
247
|
if (!docFormat && card.closest(".msg.own")) void previewResource(card, roomId, id, resource, type, preview, app, status);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createRandomId, LS, LOADED_MESSAGE_LIMIT } from "./state.js";
|
|
2
2
|
import { renderMarkdown } from "./markdown.js";
|
|
3
3
|
import { hasMessageSelection, pruneMessageRows, trimMessages, focusedMessage } from "./message-window.js";
|
|
4
|
-
import {
|
|
4
|
+
import { setRoomPreview } from "./system-messages.js";
|
|
5
|
+
import { renderSystemRow } from "./system-events.js";
|
|
5
6
|
import { installEditor } from "./editor.js";
|
|
6
7
|
import { adminAgentBadge, isAdminAgent } from "./admin-badge.js";
|
|
7
8
|
import { initMessagePolling } from "./message-polling.js";
|
|
@@ -104,6 +105,8 @@ export function initMessages(app) {
|
|
|
104
105
|
}
|
|
105
106
|
};
|
|
106
107
|
app.jumpToBottom = () => {
|
|
108
|
+
app.cancelThreadScrollAnimation?.();
|
|
109
|
+
app.state.userScrollIntentUntil = 0;
|
|
107
110
|
app.state.readAnchorGuard = null;
|
|
108
111
|
app.state.followBottom = true;
|
|
109
112
|
if (app.state.focusMessageId) {
|
|
@@ -207,10 +210,7 @@ export function initMessages(app) {
|
|
|
207
210
|
row.dataset.ts = message.createdAt;
|
|
208
211
|
row.dataset.msgId = message.id;
|
|
209
212
|
if (message.senderId === "system") {
|
|
210
|
-
row
|
|
211
|
-
const text = document.createElement("span");
|
|
212
|
-
text.textContent = formatSystemMessage(message, app);
|
|
213
|
-
row.append(text);
|
|
213
|
+
renderSystemRow(row, message, app);
|
|
214
214
|
} else {
|
|
215
215
|
const direct = app.state.room.kind === "direct";
|
|
216
216
|
const own = isOwnMessage(message, app);
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Lazy Office preview bridge. The heavy renderer bundles live under /assets/office
|
|
2
|
+
// and are fetched the first time a matching resource is opened.
|
|
3
|
+
const MAX_OFFICE_BYTES = 20 * 1024 * 1024;
|
|
4
|
+
const FORMATS = {
|
|
5
|
+
docx: { url: new URL("../office/docx.bundle.js", import.meta.url).href, label: "Word document" },
|
|
6
|
+
xlsx: { url: new URL("../office/xlsx.bundle.js", import.meta.url).href, label: "Excel workbook" },
|
|
7
|
+
pptx: { url: new URL("../office/pptx.bundle.js", import.meta.url).href, label: "PowerPoint presentation" },
|
|
8
|
+
};
|
|
9
|
+
const loaded = new Map();
|
|
10
|
+
|
|
11
|
+
export class OfficePreviewError extends Error {
|
|
12
|
+
name = "OfficePreviewError";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function load(kind) {
|
|
16
|
+
let pending = loaded.get(kind);
|
|
17
|
+
if (!pending) {
|
|
18
|
+
pending = import(FORMATS[kind].url);
|
|
19
|
+
pending.catch(() => loaded.delete(kind));
|
|
20
|
+
loaded.set(kind, pending);
|
|
21
|
+
}
|
|
22
|
+
return pending;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function ensureStyles() {
|
|
26
|
+
if (document.getElementById("officePreviewStyles")) return;
|
|
27
|
+
const style = document.createElement("style");
|
|
28
|
+
style.id = "officePreviewStyles";
|
|
29
|
+
style.textContent = `
|
|
30
|
+
.office-preview { min-width: 0; }
|
|
31
|
+
.office-preview .docx-wrapper { align-items: center; align-items: safe center; }
|
|
32
|
+
.office-preview .office-xlsx-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
|
|
33
|
+
.office-preview .office-xlsx-tab { font: inherit; font-size: 12px; padding: 4px 10px; border: 1px solid var(--line, #dcded4); border-radius: 6px; background: var(--surface, #fff); color: var(--ink-2, #555); cursor: pointer; }
|
|
34
|
+
.office-preview .office-xlsx-tab[aria-selected="true"] { background: var(--accent-soft, #e1eee6); color: var(--ink, #222); font-weight: 600; }
|
|
35
|
+
.office-preview .office-xlsx-panel { overflow: auto; max-width: 100%; }
|
|
36
|
+
.office-preview .office-xlsx-table { border-collapse: collapse; font-size: 12px; }
|
|
37
|
+
.office-preview .office-xlsx-table td { border: 1px solid var(--line, #dcded4); padding: 3px 7px; vertical-align: top; white-space: pre-wrap; }
|
|
38
|
+
.office-preview .office-xlsx-note { margin: 6px 0 0; font-size: 12px; color: var(--ink-3, #777); }
|
|
39
|
+
`;
|
|
40
|
+
document.head.append(style);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function renderOffice(kind, blob, container, options = {}) {
|
|
44
|
+
const format = FORMATS[kind];
|
|
45
|
+
if (!format) throw new OfficePreviewError(`Unsupported Office preview format: ${kind}`);
|
|
46
|
+
if (!(blob instanceof Blob)) throw new OfficePreviewError("Office preview needs a file.");
|
|
47
|
+
if (blob.size === 0) throw new OfficePreviewError(`The ${format.label.toLowerCase()} is empty.`);
|
|
48
|
+
if (blob.size > MAX_OFFICE_BYTES) {
|
|
49
|
+
throw new OfficePreviewError(`${format.label} is too large to preview (limit 20 MiB).`);
|
|
50
|
+
}
|
|
51
|
+
if (!container) throw new OfficePreviewError("Office preview needs a container.");
|
|
52
|
+
ensureStyles();
|
|
53
|
+
container.replaceChildren();
|
|
54
|
+
container.classList.add("office-preview");
|
|
55
|
+
container.setAttribute("aria-busy", "true");
|
|
56
|
+
try {
|
|
57
|
+
const bundle = await load(kind);
|
|
58
|
+
await bundle.render(blob, container, options);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
container.replaceChildren();
|
|
61
|
+
if (error instanceof Error && error.name === "OfficePreviewError") throw error;
|
|
62
|
+
throw new OfficePreviewError(
|
|
63
|
+
`Could not preview this ${format.label}. The file may be damaged or use an unsupported feature.`,
|
|
64
|
+
{ cause: error },
|
|
65
|
+
);
|
|
66
|
+
} finally {
|
|
67
|
+
container.removeAttribute("aria-busy");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
// Panel and key-dialog plumbing: every overlay closes the same way.
|
|
2
|
+
const PANEL_DEFAULTS = { announcements: "dialog", files: "dialog", tasks: "pane", reminders: "dialog" };
|
|
3
|
+
const PANEL_MODES = ["dialog", "pane"];
|
|
4
|
+
const PANE_QUERY = "(min-width: 1100px) and (min-height: 560px)";
|
|
5
|
+
|
|
2
6
|
export function initPanels(app) {
|
|
3
7
|
const $ = app.$;
|
|
8
|
+
const pane = matchMedia(PANE_QUERY);
|
|
9
|
+
const watchers = new Map(), surfaces = new Map();
|
|
10
|
+
const readModes = () => {
|
|
11
|
+
const stored = app.LS.panelMode;
|
|
12
|
+
return Object.fromEntries(Object.entries(PANEL_DEFAULTS)
|
|
13
|
+
.map(([kind, fallback]) => [kind, PANEL_MODES.includes(stored[kind]) ? stored[kind] : fallback]));
|
|
14
|
+
};
|
|
15
|
+
const notify = (kind) => { for (const watcher of watchers.get(kind) || []) watcher(); };
|
|
16
|
+
app.panelMode = (kind) => readModes()[kind] || "dialog";
|
|
17
|
+
app.panelPlacement = (kind) => app.panelMode(kind) === "pane" && pane.matches ? "pane" : "dialog";
|
|
18
|
+
app.watchPanel = (kind, watcher) => {
|
|
19
|
+
if (!watchers.has(kind)) watchers.set(kind, new Set());
|
|
20
|
+
watchers.get(kind).add(watcher);
|
|
21
|
+
};
|
|
22
|
+
app.setPanelMode = (kind, mode) => {
|
|
23
|
+
if (!Object.hasOwn(PANEL_DEFAULTS, kind)) return;
|
|
24
|
+
const next = PANEL_MODES.includes(mode) ? mode : PANEL_DEFAULTS[kind];
|
|
25
|
+
app.LS.panelMode = { ...readModes(), [kind]: next };
|
|
26
|
+
// Settings is modal; layout changes behind it wait until it closes.
|
|
27
|
+
if (!app.settingsOpen?.()) notify(kind);
|
|
28
|
+
};
|
|
29
|
+
app.registerPanelSurface = (kind, handlers) => surfaces.set(kind, handlers);
|
|
30
|
+
app.closeOtherPanelSurfaces = (except) => {
|
|
31
|
+
for (const [kind, surface] of surfaces) if (kind !== except) surface.close?.();
|
|
32
|
+
app.closeDocPreview?.(false);
|
|
33
|
+
};
|
|
34
|
+
pane.addEventListener("change", () => {
|
|
35
|
+
// Keep the settings modal on top; its close listener re-syncs every surface.
|
|
36
|
+
if (app.settingsOpen?.()) return;
|
|
37
|
+
for (const kind of watchers.keys()) notify(kind);
|
|
38
|
+
});
|
|
39
|
+
$("#chatSettings")?.addEventListener("close", () => { for (const kind of watchers.keys()) notify(kind); });
|
|
4
40
|
app.closePanels = () => {
|
|
5
41
|
document.querySelectorAll(".panel").forEach((panel) => { panel.hidden = true; });
|
|
6
42
|
$("#btnMembers").setAttribute("aria-expanded", "false");
|
|
@@ -42,6 +42,12 @@ export function initRecall(app) {
|
|
|
42
42
|
if (revealTarget && app.state.room) {
|
|
43
43
|
const message = app.state.room.messages.find((item) => item.id === revealTarget.dataset.revealMessage);
|
|
44
44
|
if (message) void toggleOriginal(revealTarget, message, app);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const reeditTarget = event.target.closest?.("[data-reedit-message]");
|
|
48
|
+
if (reeditTarget && app.state.room) {
|
|
49
|
+
const message = app.state.room.messages.find((item) => item.id === reeditTarget.dataset.reeditMessage);
|
|
50
|
+
if (message) void reedit(message, reeditTarget, app);
|
|
45
51
|
}
|
|
46
52
|
});
|
|
47
53
|
|
|
@@ -195,7 +201,11 @@ function renderTombstone(row, message, app, live) {
|
|
|
195
201
|
const shown = Boolean(message._revealed) && message._revealedText !== undefined;
|
|
196
202
|
body.hidden = !shown;
|
|
197
203
|
setRevealButton(reveal, shown, app);
|
|
198
|
-
|
|
204
|
+
const actions = document.createElement("div");
|
|
205
|
+
actions.className = "recalled-actions";
|
|
206
|
+
actions.append(reveal);
|
|
207
|
+
if (isOwnMessage(message, app)) actions.append(reeditButton(message, app));
|
|
208
|
+
bubble.append(body, actions);
|
|
199
209
|
if (live) { row.classList.remove("recalled-in"); void row.offsetWidth; row.classList.add("recalled-in"); }
|
|
200
210
|
return row;
|
|
201
211
|
}
|
|
@@ -227,6 +237,15 @@ function renderSystemTombstone(row, message, app, live) {
|
|
|
227
237
|
return row;
|
|
228
238
|
}
|
|
229
239
|
|
|
240
|
+
function reeditButton(message, app) {
|
|
241
|
+
const button = document.createElement("button");
|
|
242
|
+
button.type = "button";
|
|
243
|
+
button.className = "recalled-reedit";
|
|
244
|
+
button.dataset.reeditMessage = message.id;
|
|
245
|
+
button.textContent = app.t("reeditMessage");
|
|
246
|
+
return button;
|
|
247
|
+
}
|
|
248
|
+
|
|
230
249
|
function fillRevealed(body, message, text, app) {
|
|
231
250
|
body.textContent = "";
|
|
232
251
|
if (message.senderId === "system") body.textContent = formatSystemMessage({ senderId: "system", text }, app);
|
|
@@ -240,7 +259,7 @@ function setRevealButton(button, shown, app) {
|
|
|
240
259
|
|
|
241
260
|
async function toggleOriginal(button, message, app) {
|
|
242
261
|
if (button.disabled) return;
|
|
243
|
-
const body = button.
|
|
262
|
+
const body = button.closest(".msg-text, .sys")?.querySelector(".recalled-body");
|
|
244
263
|
if (!body) return;
|
|
245
264
|
if (message._revealedText !== undefined) {
|
|
246
265
|
message._revealed = !message._revealed;
|
|
@@ -251,11 +270,7 @@ async function toggleOriginal(button, message, app) {
|
|
|
251
270
|
button.disabled = true;
|
|
252
271
|
setRevealButton(button, false, app);
|
|
253
272
|
try {
|
|
254
|
-
const
|
|
255
|
-
const result = await app.api(`/rooms/${encodeURIComponent(roomId)}/messages/${encodeURIComponent(message.id)}/content?sessionID=${encodeURIComponent(LS.sessionID)}`);
|
|
256
|
-
const text = typeof result?.message?.text === "string" ? result.message.text : typeof result?.text === "string" ? result.text : undefined;
|
|
257
|
-
if (text === undefined) throw new Error(app.t("revealFailed"));
|
|
258
|
-
message._revealedText = text;
|
|
273
|
+
const text = await loadOriginalText(message, app);
|
|
259
274
|
message._revealed = true;
|
|
260
275
|
fillRevealed(body, message, text, app);
|
|
261
276
|
body.hidden = false;
|
|
@@ -265,4 +280,40 @@ async function toggleOriginal(button, message, app) {
|
|
|
265
280
|
} finally {
|
|
266
281
|
button.disabled = false;
|
|
267
282
|
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async function loadOriginalText(message, app) {
|
|
286
|
+
if (message._revealedText !== undefined) return message._revealedText;
|
|
287
|
+
const roomId = app.state.room?.id;
|
|
288
|
+
const result = await app.api(`/rooms/${encodeURIComponent(roomId)}/messages/${encodeURIComponent(message.id)}/content?sessionID=${encodeURIComponent(LS.sessionID)}`);
|
|
289
|
+
const text = typeof result?.message?.text === "string" ? result.message.text : typeof result?.text === "string" ? result.text : undefined;
|
|
290
|
+
if (text === undefined) throw new Error(app.t("revealFailed"));
|
|
291
|
+
message._revealedText = text;
|
|
292
|
+
return text;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
async function reedit(message, button, app) {
|
|
296
|
+
const roomId = app.state.room?.id, input = app.$("#msgInput");
|
|
297
|
+
if (!roomId || !input || button.disabled || !isOwnMessage(message, app)) return;
|
|
298
|
+
if (input.draftValue.trim() && !(await app.confirmAction(app.t("reeditReplaceDraft")))) return;
|
|
299
|
+
button.disabled = true;
|
|
300
|
+
try {
|
|
301
|
+
const text = await loadOriginalText(message, app);
|
|
302
|
+
if (app.state.room?.id !== roomId) return;
|
|
303
|
+
input.draftValue = text;
|
|
304
|
+
app.saveDraft(roomId, text);
|
|
305
|
+
app.autoGrow(input);
|
|
306
|
+
app.updateDraftCount();
|
|
307
|
+
app.updateSendState();
|
|
308
|
+
// A click is explicit intent, so focus the editor even on touch layouts.
|
|
309
|
+
if (!app.focusChatComposer({ force: true })) {
|
|
310
|
+
input.focus({ preventScroll: true });
|
|
311
|
+
input.setCaret?.(input.value.length);
|
|
312
|
+
}
|
|
313
|
+
} catch (error) {
|
|
314
|
+
if (error.status === 401) app.openChatSettings();
|
|
315
|
+
app.showSendError(error.status === 401 ? "sendAuth" : "revealFailed", { message: error.message });
|
|
316
|
+
} finally {
|
|
317
|
+
button.disabled = false;
|
|
318
|
+
}
|
|
268
319
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { pointerOrSelectionActive } from "./message-window.js";
|
|
2
|
+
import { icon } from "./icons.js";
|
|
3
|
+
|
|
4
|
+
const READ_ALL_ICON = icon("checkmark", "message-read-check");
|
|
2
5
|
|
|
3
6
|
export function initReceipts(app) {
|
|
4
7
|
const $ = app.$, panel = $("#readerPanel");
|
|
@@ -96,14 +99,23 @@ export function initReceipts(app) {
|
|
|
96
99
|
}
|
|
97
100
|
function updateButton(button, message, own = button.dataset.ownMessage === "true") {
|
|
98
101
|
const readers = readersFor(message), count = readers.length, known = hasReceiptData(message);
|
|
99
|
-
const
|
|
102
|
+
const allRead = own && known && readByEveryone(message, readers);
|
|
103
|
+
const label = allRead ? app.t("receiptAllRead") : readerStatus(message, readers);
|
|
100
104
|
button.hidden = !own && count === 0;
|
|
101
|
-
button.
|
|
102
|
-
button.
|
|
105
|
+
if (allRead) button.innerHTML = READ_ALL_ICON;
|
|
106
|
+
else button.textContent = String(count || (known ? 0 : "…"));
|
|
107
|
+
button.dataset.readerState = allRead ? "all" : count ? "read" : known ? "empty" : "unknown";
|
|
103
108
|
button.setAttribute("aria-label", label);
|
|
104
109
|
button.setAttribute("aria-expanded", String(selectedID === message.id));
|
|
105
110
|
button.title = label;
|
|
106
111
|
}
|
|
112
|
+
function readByEveryone(message, readers) {
|
|
113
|
+
const senderID = message.senderSessionID || (app.state.room?.kind === "direct" ? message.senderId : "");
|
|
114
|
+
const eligible = (app.state.memberSessions.get(app.state.room?.id) || []).filter((member) => member.sessionID && member.sessionID !== senderID);
|
|
115
|
+
if (!eligible.length) return false;
|
|
116
|
+
const seen = new Set(readers.map((reader) => reader.sessionID));
|
|
117
|
+
return eligible.every((member) => seen.has(member.sessionID));
|
|
118
|
+
}
|
|
107
119
|
function readersFor(message) {
|
|
108
120
|
const key = receiptKey(message);
|
|
109
121
|
const senderID = message.senderSessionID || (app.state.room?.kind === "direct" ? message.senderId : "");
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { LS } from "./state.js";
|
|
2
2
|
|
|
3
3
|
export function initReminders(app) {
|
|
4
|
-
const $ = app.$,
|
|
5
|
-
const
|
|
4
|
+
const $ = app.$, surface = $("#remindersDialog"), trigger = $("#btnReminders"), list = $("#reminderList");
|
|
5
|
+
const dialog = $("#reminderDialog"), newButton = $("#btnNewReminder");
|
|
6
|
+
const heading = $("#reminderDialogHeading"), panelHeading = $("#reminderHeading"), submit = $("#btnSubmitReminder");
|
|
7
|
+
const chatView = $("#chatView");
|
|
6
8
|
app.setText($("#reminderTemplateHint"), "reminderTemplateHint", { time: "{time}", initiator: "{initiator}", room: "{room}" });
|
|
7
9
|
let reminders = [], generation = 0, roomGeneration = 0, activeRoomId, editing = null, createDraft = null, saving = false, saveToken = 0;
|
|
10
|
+
let opener = null, pendingReopen = false, restoreSurfaceFocus = true;
|
|
8
11
|
const drafts = new Map();
|
|
9
12
|
const roomId = () => app.state.room?.id;
|
|
10
13
|
const status = (text) => { $("#reminderStatus").textContent = text; };
|
|
@@ -23,6 +26,47 @@ export function initReminders(app) {
|
|
|
23
26
|
if (!dialog.open) dialog.showModal();
|
|
24
27
|
$("#reminderText").focus();
|
|
25
28
|
}
|
|
29
|
+
const clearPane = () => {
|
|
30
|
+
surface.classList.remove("is-pane");
|
|
31
|
+
if (chatView.dataset.sidePane !== "reminders") return;
|
|
32
|
+
delete chatView.dataset.sidePane;
|
|
33
|
+
chatView.classList.remove("has-pane");
|
|
34
|
+
};
|
|
35
|
+
const showSurface = () => {
|
|
36
|
+
if (app.panelPlacement("reminders") === "pane") {
|
|
37
|
+
app.closeOtherPanelSurfaces?.("reminders");
|
|
38
|
+
surface.classList.add("is-pane");
|
|
39
|
+
chatView.classList.add("has-pane");
|
|
40
|
+
chatView.dataset.sidePane = "reminders";
|
|
41
|
+
if (!surface.open) surface.show();
|
|
42
|
+
} else {
|
|
43
|
+
clearPane();
|
|
44
|
+
if (!surface.open) surface.showModal();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const syncMode = () => {
|
|
48
|
+
if (!surface.open || (app.panelPlacement("reminders") === "pane") === surface.classList.contains("is-pane")) return;
|
|
49
|
+
pendingReopen = true;
|
|
50
|
+
surface.close();
|
|
51
|
+
showSurface();
|
|
52
|
+
panelHeading.focus({ preventScroll: true });
|
|
53
|
+
};
|
|
54
|
+
const closeSurface = (focus = true) => {
|
|
55
|
+
restoreSurfaceFocus = focus;
|
|
56
|
+
if (surface.open) surface.close();
|
|
57
|
+
};
|
|
58
|
+
function openSurface() {
|
|
59
|
+
if (!roomId()) return;
|
|
60
|
+
if (app.panelPlacement("reminders") === "pane") app.closeDocPreview?.(false);
|
|
61
|
+
if (surface.open) { panelHeading.focus(); return; }
|
|
62
|
+
app.closePanels?.();
|
|
63
|
+
const active = document.activeElement;
|
|
64
|
+
opener = active instanceof HTMLElement && active !== document.body && !active.closest("dialog") && !$("#roomOptions")?.contains(active)
|
|
65
|
+
? active : $("#btnRoomOptions");
|
|
66
|
+
showSurface();
|
|
67
|
+
panelHeading.focus();
|
|
68
|
+
void load();
|
|
69
|
+
}
|
|
26
70
|
const current = (id, context) => roomId() === id && roomGeneration === context;
|
|
27
71
|
const invalidateLoads = () => { generation++; };
|
|
28
72
|
const errorText = (error) => error?.message || app.t("requestFailed", { status: error?.status || "?" });
|
|
@@ -142,16 +186,33 @@ export function initReminders(app) {
|
|
|
142
186
|
$("#btnCancelReminder").addEventListener("click", () => dialog.close());
|
|
143
187
|
dialog.addEventListener("click", (event) => { if (event.target === dialog) dialog.close(); });
|
|
144
188
|
dialog.addEventListener("close", () => { editing = null; });
|
|
145
|
-
trigger.addEventListener("click", () => {
|
|
146
|
-
|
|
147
|
-
|
|
189
|
+
trigger.addEventListener("click", () => { app.closePanels(); openSurface(); });
|
|
190
|
+
$("#btnCloseReminders").addEventListener("click", () => closeSurface());
|
|
191
|
+
surface.addEventListener("click", (event) => { if (event.target === surface) closeSurface(); });
|
|
192
|
+
surface.addEventListener("cancel", (event) => { event.preventDefault(); closeSurface(); });
|
|
193
|
+
surface.addEventListener("close", () => {
|
|
194
|
+
if (pendingReopen) { pendingReopen = false; return; }
|
|
195
|
+
clearPane();
|
|
196
|
+
const focus = restoreSurfaceFocus;
|
|
197
|
+
restoreSurfaceFocus = true;
|
|
198
|
+
const target = opener;
|
|
199
|
+
opener = null;
|
|
200
|
+
if (focus && target?.isConnected) target.focus({ preventScroll: true });
|
|
201
|
+
});
|
|
202
|
+
document.addEventListener("keydown", (event) => {
|
|
203
|
+
if (event.key !== "Escape" || !surface.open || !surface.classList.contains("is-pane")) return;
|
|
204
|
+
if (!surface.contains(document.activeElement)) return;
|
|
205
|
+
event.preventDefault();
|
|
206
|
+
closeSurface();
|
|
148
207
|
});
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
208
|
+
app.registerPanelSurface?.("reminders", { close: () => closeSurface(false) });
|
|
209
|
+
app.watchPanel?.("reminders", syncMode);
|
|
210
|
+
const closePanels = app.closePanels;
|
|
211
|
+
app.closePanels = () => { closePanels(); if (dialog.open) dialog.close(); };
|
|
152
212
|
document.addEventListener("chat-room-activated", (event) => {
|
|
153
213
|
if (activeRoomId) drafts.set(activeRoomId, createDraft ?? formDraft());
|
|
154
214
|
if (dialog.open) dialog.close();
|
|
215
|
+
if (surface.open && !surface.classList.contains("is-pane")) closeSurface(false);
|
|
155
216
|
formStatus("");
|
|
156
217
|
editing = null; createDraft = null; saving = false; saveToken++; submit.disabled = false;
|
|
157
218
|
activeRoomId = event.detail; restoreDraft(drafts.get(activeRoomId));
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
// sniffs text and PDF uploads as application/octet-stream, so the filename
|
|
3
3
|
// extension is a first-class signal alongside the MIME type.
|
|
4
4
|
export const TEXT_PREVIEW_LIMIT = 2 * 1024 * 1024;
|
|
5
|
+
// Office files are zipped XML packages; the viewer needs far more room than text.
|
|
6
|
+
export const OFFICE_PREVIEW_LIMIT = 20 * 1024 * 1024;
|
|
7
|
+
export const OFFICE_KINDS = new Set(["docx", "xlsx", "pptx"]);
|
|
8
|
+
const OFFICE_MIMES = {
|
|
9
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
10
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
|
|
11
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
|
|
12
|
+
};
|
|
5
13
|
|
|
6
14
|
const MIME_LANGUAGES = {
|
|
7
15
|
"application/json": "json", "application/ld+json": "json",
|
|
@@ -65,6 +73,9 @@ export function docPreviewFormat(resource) {
|
|
|
65
73
|
if (mime === "text/markdown" || mime === "text/x-markdown" || ext === "md" || ext === "markdown") {
|
|
66
74
|
return { kind: "markdown", language: "", label: "" };
|
|
67
75
|
}
|
|
76
|
+
// Server sniffing reports Office packages as octet-stream, so the extension counts.
|
|
77
|
+
const office = OFFICE_MIMES[mime] || (OFFICE_KINDS.has(ext) ? ext : "");
|
|
78
|
+
if (office) return { kind: office, language: "", label: office.toUpperCase() };
|
|
68
79
|
const knownExtension = Object.hasOwn(EXTENSION_LANGUAGES, ext);
|
|
69
80
|
if (!knownExtension && !isTextMime(mime)) return null;
|
|
70
81
|
const language = knownExtension ? EXTENSION_LANGUAGES[ext] : MIME_LANGUAGES[mime] || "";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Browser settings shared by the join page and the chat: language, theme, and the optional token.
|
|
1
|
+
// Browser settings shared by the join page and the chat: language, theme, window frame, and the optional token.
|
|
2
2
|
export const THEMES = ["system", "light", "dark", "forest", "sand"];
|
|
3
3
|
|
|
4
4
|
export function initSettings(app) {
|
|
@@ -8,19 +8,29 @@ export function initSettings(app) {
|
|
|
8
8
|
const tokenInput = $("#inTokenChat"), tokenHint = $("#tokenHint");
|
|
9
9
|
const contentInput = $("#inContentTransition");
|
|
10
10
|
const pageInput = $("#inPageStep"), pageValue = $("#pageStepValue");
|
|
11
|
+
const frameSelect = $("#inWindowFrame");
|
|
12
|
+
const panelInputs = [...dialog.querySelectorAll("[data-panel-mode]")];
|
|
13
|
+
if (document.body.dataset.integrationsAdmin !== "true") {
|
|
14
|
+
$("#settingsTabIntegrations")?.remove();
|
|
15
|
+
$("#settingsPanelIntegrations")?.remove();
|
|
16
|
+
}
|
|
11
17
|
const tabs = [...dialog.querySelectorAll('[role="tab"]')];
|
|
12
18
|
const scheme = matchMedia("(prefers-color-scheme: dark)");
|
|
13
19
|
let opener = null;
|
|
14
20
|
|
|
15
21
|
const syncThemeColor = () => {
|
|
16
22
|
const meta = document.querySelector('meta[name="theme-color"]');
|
|
17
|
-
const
|
|
23
|
+
const token = document.documentElement.dataset.windowFrame === "borderless" ? "--surface" : "--bg";
|
|
24
|
+
const background = getComputedStyle(document.documentElement).getPropertyValue(token).trim();
|
|
18
25
|
if (meta && background) meta.content = background;
|
|
19
26
|
};
|
|
20
27
|
const syncThemeInputs = () => {
|
|
21
28
|
const stored = THEMES.includes(app.LS.theme) ? app.LS.theme : "system";
|
|
22
29
|
for (const input of dialog.querySelectorAll('input[name="theme"]')) input.checked = input.value === stored;
|
|
23
30
|
};
|
|
31
|
+
const syncPanelInputs = () => {
|
|
32
|
+
for (const select of panelInputs) select.value = app.panelMode(select.dataset.panelMode);
|
|
33
|
+
};
|
|
24
34
|
const applyTheme = (value, persist) => {
|
|
25
35
|
const theme = THEMES.includes(value) ? value : "system";
|
|
26
36
|
document.documentElement.dataset.theme = theme;
|
|
@@ -31,6 +41,16 @@ export function initSettings(app) {
|
|
|
31
41
|
app.setTheme = (value) => applyTheme(value, true);
|
|
32
42
|
app.settingsOpen = () => dialog.open;
|
|
33
43
|
|
|
44
|
+
const framePreference = () => app.LS.windowFrame === "borderless" ? "borderless" : "framed";
|
|
45
|
+
const applyWindowFrame = (mode, persist) => {
|
|
46
|
+
const preference = mode === "borderless" ? "borderless" : "framed";
|
|
47
|
+
document.documentElement.dataset.windowFrame = preference;
|
|
48
|
+
if (frameSelect) frameSelect.value = preference;
|
|
49
|
+
if (persist) app.LS.windowFrame = preference;
|
|
50
|
+
syncThemeColor();
|
|
51
|
+
};
|
|
52
|
+
app.setWindowFrame = (value) => applyWindowFrame(value, true);
|
|
53
|
+
|
|
34
54
|
// One tab stop for the whole tablist; arrow keys move selection like a native tab widget.
|
|
35
55
|
const activateTab = (name, { focus = false } = {}) => {
|
|
36
56
|
for (const tab of tabs) {
|
|
@@ -41,6 +61,7 @@ export function initSettings(app) {
|
|
|
41
61
|
if (panel) panel.hidden = !selected;
|
|
42
62
|
if (selected && focus) tab.focus();
|
|
43
63
|
}
|
|
64
|
+
if (name === "integrations") app.loadIntegrations?.();
|
|
44
65
|
};
|
|
45
66
|
const onTabKey = (event) => {
|
|
46
67
|
const index = tabs.indexOf(event.target);
|
|
@@ -59,6 +80,8 @@ export function initSettings(app) {
|
|
|
59
80
|
const open = ({ token = false } = {}) => {
|
|
60
81
|
app.closePanels?.();
|
|
61
82
|
syncThemeInputs();
|
|
83
|
+
syncPanelInputs();
|
|
84
|
+
applyWindowFrame(framePreference(), false);
|
|
62
85
|
if (contentInput) contentInput.checked = app.LS.contentTransition;
|
|
63
86
|
if (pageInput) pageInput.value = String(app.LS.pageStep);
|
|
64
87
|
if (pageValue) pageValue.textContent = `${app.LS.pageStep}%`;
|
|
@@ -96,6 +119,10 @@ export function initSettings(app) {
|
|
|
96
119
|
});
|
|
97
120
|
dialog.addEventListener("change", (event) => {
|
|
98
121
|
if (event.target instanceof HTMLInputElement && event.target.name === "theme") app.setTheme(event.target.value);
|
|
122
|
+
if (event.target === frameSelect) app.setWindowFrame(frameSelect.value);
|
|
123
|
+
if (event.target instanceof HTMLSelectElement && event.target.dataset.panelMode) {
|
|
124
|
+
app.setPanelMode(event.target.dataset.panelMode, event.target.value);
|
|
125
|
+
}
|
|
99
126
|
if (event.target === contentInput) app.LS.contentTransition = contentInput.checked;
|
|
100
127
|
if (event.target === pageInput) {
|
|
101
128
|
app.LS.pageStep = pageInput.value;
|
|
@@ -114,4 +141,5 @@ export function initSettings(app) {
|
|
|
114
141
|
scheme.addEventListener("change", () => { if (app.LS.theme === "system") syncThemeColor(); });
|
|
115
142
|
|
|
116
143
|
applyTheme(app.LS.theme, false);
|
|
144
|
+
applyWindowFrame(framePreference(), false);
|
|
117
145
|
}
|
|
@@ -13,7 +13,6 @@ export function initSidePaneSplitter(app) {
|
|
|
13
13
|
const view = app.$("#chatView");
|
|
14
14
|
const handle = app.$("#sidePaneHandle");
|
|
15
15
|
const preview = app.$("#docPreview");
|
|
16
|
-
const tasks = app.$("#tasksDialog");
|
|
17
16
|
if (!view || !handle) return;
|
|
18
17
|
|
|
19
18
|
let stored = readStored();
|
|
@@ -23,7 +22,7 @@ export function initSidePaneSplitter(app) {
|
|
|
23
22
|
let drag = null;
|
|
24
23
|
|
|
25
24
|
const activePane = () => view.classList.contains("has-doc") ? preview
|
|
26
|
-
: view.classList.contains("has-
|
|
25
|
+
: view.classList.contains("has-pane") ? view.querySelector(":scope > dialog.is-pane[open]") : null;
|
|
27
26
|
|
|
28
27
|
// A wide task board must leave the conversation a full working column; the
|
|
29
28
|
// Markdown preview keeps the normal minimum.
|