@alexsun-top/opencode-chat-room 0.8.1 → 0.8.3
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 +33 -0
- package/README.md +18 -62
- package/README.zh-CN.md +25 -69
- package/dist/cli.js +1008 -274
- package/package.json +10 -7
- package/packages/chat-room-channeld/README.md +42 -15
- package/packages/chat-room-channeld/dist/mock-adapter.js +5 -5
- package/packages/chat-room-channeld/src/adapter.ts +150 -7
- package/packages/chat-room-channeld/src/cli.ts +72 -5
- package/packages/chat-room-channeld/src/host.ts +41 -11
- package/packages/chat-room-channeld/src/inbound.ts +13 -4
- package/packages/chat-room-channeld/src/pg/database.ts +187 -0
- package/packages/chat-room-channeld/src/pg/migrate.ts +150 -0
- package/packages/chat-room-channeld/src/pg/schema.ts +60 -0
- package/packages/chat-room-channeld/src/pg/sql.mjs +175 -0
- package/packages/chat-room-channeld/src/pg/sqlite.ts +100 -0
- package/packages/chat-room-channeld/src/pg/worker.mjs +133 -0
- package/packages/chat-room-channeld/src/protocol.ts +53 -1
- package/packages/chat-room-channeld/src/rules.ts +7 -2
- package/packages/chat-room-channeld/src/state.ts +73 -97
- package/packages/chat-room-channeld/src/stats.ts +140 -109
- package/plugin.ts +1 -1
- package/server/assets/base.css +11 -3
- package/server/assets/chat/admin-badge.js +32 -30
- package/server/assets/chat/admin.js +198 -163
- package/server/assets/chat/announcements.js +295 -210
- package/server/assets/chat/attachment-store.js +106 -75
- package/server/assets/chat/attachments.js +686 -441
- package/server/assets/chat/chat-background.js +206 -0
- package/server/assets/chat/clipboard.js +44 -25
- package/server/assets/chat/confirm-dialog.js +36 -34
- package/server/assets/chat/copy-action.js +40 -40
- package/server/assets/chat/create-room-dialog.js +50 -48
- package/server/assets/chat/diagram-viewer.js +293 -228
- package/server/assets/chat/doc-preview.js +510 -388
- package/server/assets/chat/editor.js +423 -335
- package/server/assets/chat/events.js +637 -502
- package/server/assets/chat/files.js +476 -426
- package/server/assets/chat/history-loader.js +79 -73
- package/server/assets/chat/icons.js +9 -11
- package/server/assets/chat/image-zoom.js +239 -169
- package/server/assets/chat/index.js +6 -5
- package/server/assets/chat/install-prompt.js +86 -66
- package/server/assets/chat/integration-account-schema.js +101 -0
- package/server/assets/chat/integration-editor.js +162 -153
- package/server/assets/chat/integration-values.js +109 -100
- package/server/assets/chat/integrations.js +696 -479
- package/server/assets/chat/join-requests.js +408 -358
- package/server/assets/chat/locales/de.js +193 -194
- package/server/assets/chat/locales/es.js +193 -194
- package/server/assets/chat/locales/fr.js +193 -194
- package/server/assets/chat/locales/index.js +1 -2
- package/server/assets/chat/locales/it.js +193 -194
- package/server/assets/chat/locales/ja.js +193 -193
- package/server/assets/chat/locales/ko.js +193 -193
- package/server/assets/chat/markdown-footnotes.js +134 -102
- package/server/assets/chat/markdown.js +553 -386
- package/server/assets/chat/members.js +236 -197
- package/server/assets/chat/mentions.js +157 -133
- package/server/assets/chat/message-cache.js +40 -33
- package/server/assets/chat/message-polling.js +280 -227
- package/server/assets/chat/message-window.js +74 -55
- package/server/assets/chat/messages.js +552 -479
- package/server/assets/chat/office-preview.js +46 -45
- package/server/assets/chat/palette.js +450 -412
- package/server/assets/chat/panels.js +94 -58
- package/server/assets/chat/pwa.js +144 -73
- package/server/assets/chat/questions.js +372 -302
- package/server/assets/chat/recall.js +320 -273
- package/server/assets/chat/receipts.js +149 -122
- package/server/assets/chat/reminders.js +331 -216
- package/server/assets/chat/replies.js +165 -136
- package/server/assets/chat/resource-format.js +59 -62
- package/server/assets/chat/room-list.js +58 -55
- package/server/assets/chat/room-watcher.js +72 -50
- package/server/assets/chat/rooms.js +623 -505
- package/server/assets/chat/search.js +136 -114
- package/server/assets/chat/settings.js +229 -140
- package/server/assets/chat/shiki.js +61 -62
- package/server/assets/chat/shortcuts.js +212 -190
- package/server/assets/chat/side-pane.js +166 -131
- package/server/assets/chat/state.js +851 -707
- package/server/assets/chat/system-events.js +55 -27
- package/server/assets/chat/system-messages.js +59 -49
- package/server/assets/chat/task-form.js +178 -182
- package/server/assets/chat/task-row.js +158 -155
- package/server/assets/chat/tasks.js +653 -593
- package/server/assets/chat/viewport.js +32 -29
- package/server/assets/chat/window-controls.js +37 -0
- package/server/assets/code-highlight.css +22 -6
- package/server/assets/conversation.css +65 -16
- package/server/assets/doc-preview.css +6 -1
- package/server/assets/files.css +3 -0
- package/server/assets/monaco/integration-rules.css +1 -1
- package/server/assets/monaco/integration-rules.js +841 -533
- package/server/assets/responsive.css +32 -2
- package/server/assets/settings.css +117 -13
- package/server/assets/window-controls.css +36 -0
- package/server/channel-attachments.ts +133 -0
- package/server/channel-integration.ts +79 -26
- package/server/channels.ts +15 -5
- package/server/chat-server.ts +9 -1
- package/server/chat.html +73 -38
- package/server/manifest.webmanifest +1 -0
- package/server/routes/pages.ts +7 -5
- package/server/sw.js +346 -267
- package/src/center/center-client.ts +1 -1
- package/src/state/pg-database.ts +5 -5
- package/src/state/pg-migrate.ts +7 -7
- package/src/state/pg-worker.mjs +2 -17
- package/src/state/sqlite-database.ts +14 -5
- package/src/state/sqlite-rooms.ts +130 -23
- package/src/state/sqlite-state-store.ts +6 -5
- package/src/state/sqlite.ts +3 -3
- package/src/web/integration-rules-editor.ts +141 -5
- package/src/web/integration-rules.ts +6 -2
- package/src/web/integration-schema.ts +7 -6
- package/packages/chat-room-channeld/dist/feishu-adapter.js +0 -1262
- package/packages/chat-room-channeld/src/feishu-adapter.ts +0 -303
- package/packages/chat-room-channeld/src/feishu-card.ts +0 -27
- package/packages/chat-room-channeld/src/feishu-inbound.ts +0 -158
- package/packages/chat-room-channeld/src/feishu-live.ts +0 -355
- package/packages/chat-room-channeld/src/feishu-send.ts +0 -342
- package/packages/chat-room-channeld/src/feishu-ws-frames.ts +0 -173
- package/server/assets/chat/forward.js +0 -69
|
@@ -1,73 +1,92 @@
|
|
|
1
1
|
export function pruneMessageRows(list, messages) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
const ids = new Set(messages.map((message) => message.id));
|
|
3
|
+
for (const row of list.querySelectorAll("[data-msg-id]"))
|
|
4
|
+
if (!ids.has(row.dataset.msgId))
|
|
5
|
+
row.remove();
|
|
6
|
+
const days = new Set([...list.querySelectorAll("[data-msg-id]")].map((row) => row.dataset.day));
|
|
7
|
+
for (const separator of list.querySelectorAll(".day-sep"))
|
|
8
|
+
if (!days.has(separator.dataset.day))
|
|
9
|
+
separator.remove();
|
|
10
|
+
if (!days.size)
|
|
11
|
+
list.querySelectorAll(".gap").forEach((gap) => gap.remove());
|
|
7
12
|
}
|
|
8
|
-
|
|
9
13
|
export function hasMessageSelection(list) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
const selection = getSelection();
|
|
15
|
+
return Boolean(selection && !selection.isCollapsed
|
|
16
|
+
&& (list.contains(selection.anchorNode) || list.contains(selection.focusNode)));
|
|
13
17
|
}
|
|
14
|
-
|
|
15
18
|
// A held pointer or a live selection owns the viewport. Layout writes may only
|
|
16
19
|
// follow the bottom when neither gesture is active.
|
|
17
20
|
export function pointerOrSelectionActive(app) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
if (app.state.threadPointerDown)
|
|
22
|
+
return true;
|
|
23
|
+
const list = document.querySelector("#msgList");
|
|
24
|
+
return Boolean(list && hasMessageSelection(list));
|
|
21
25
|
}
|
|
22
|
-
|
|
23
26
|
export function followsBottom(app, threshold = -1) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
if (pointerOrSelectionActive(app))
|
|
28
|
+
return false;
|
|
29
|
+
const thread = document.querySelector("#thread");
|
|
30
|
+
return Boolean(app.state.followBottom || (thread && thread.scrollHeight - thread.scrollTop - thread.clientHeight <= threshold));
|
|
27
31
|
}
|
|
28
|
-
|
|
29
32
|
// A search jump parks one row near the top of the thread and flashes it briefly.
|
|
30
33
|
export function flashMessageRow(app, row) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
const thread = document.querySelector("#thread");
|
|
35
|
+
thread.scrollTop += row.getBoundingClientRect().top - (thread.getBoundingClientRect().top + thread.clientTop) - 12;
|
|
36
|
+
app.state.followBottom = false;
|
|
37
|
+
// Keep a programmatic search jump from being mistaken for the reader returning to the tail.
|
|
38
|
+
app.state.focusHoldUntil = performance.now() + 900;
|
|
39
|
+
clearTimeout(row._jumpFlashTimer);
|
|
40
|
+
row.classList.remove("jump-flash");
|
|
41
|
+
void row.offsetWidth;
|
|
42
|
+
row.classList.add("jump-flash");
|
|
43
|
+
row._jumpFlashTimer = setTimeout(() => row.classList.remove("jump-flash"), 900);
|
|
44
|
+
app.updateJump?.();
|
|
42
45
|
}
|
|
43
|
-
|
|
44
46
|
// Resolve app.state.focusMessageId against the loaded state and rendered rows.
|
|
45
47
|
export function focusedMessage(app, list, messages) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
const id = app.state.focusMessageId;
|
|
49
|
+
if (!id)
|
|
50
|
+
return null;
|
|
51
|
+
const index = messages.findIndex((message) => message.id === id);
|
|
52
|
+
if (index < 0) {
|
|
53
|
+
app.state.focusMessageId = null;
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return { id, index, existing: list.querySelector(`[data-msg-id="${CSS.escape(id)}"]`) };
|
|
51
57
|
}
|
|
52
|
-
|
|
53
58
|
export function trimMessages(list, app) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
if (list.children.length <= 400 || hasMessageSelection(list))
|
|
60
|
+
return;
|
|
61
|
+
// Trimming removes content above the reader. While they are browsing older
|
|
62
|
+
// history that would shift the viewport, so only trim near the newest tail.
|
|
63
|
+
const thread = document.querySelector("#thread");
|
|
64
|
+
if (thread && thread.scrollHeight - thread.scrollTop - thread.clientHeight > 80)
|
|
65
|
+
return;
|
|
66
|
+
const saved = app.state.positions.get(app.state.room?.id), rows = [...list.querySelectorAll("[data-msg-id]")];
|
|
67
|
+
const anchor = saved?.messageId && rows.find((row) => row.dataset.msgId === saved.messageId);
|
|
68
|
+
if (anchor && rows.indexOf(anchor) < rows.length - 280) {
|
|
69
|
+
const recent = rows.at(-300);
|
|
70
|
+
while (list.firstElementChild && list.firstElementChild !== anchor)
|
|
71
|
+
list.firstElementChild.remove();
|
|
72
|
+
let next = anchor.nextElementSibling;
|
|
73
|
+
while (next && next !== recent) {
|
|
74
|
+
const after = next.nextElementSibling;
|
|
75
|
+
next.remove();
|
|
76
|
+
next = after;
|
|
77
|
+
}
|
|
78
|
+
const gap = document.createElement("li");
|
|
79
|
+
gap.className = "gap";
|
|
80
|
+
app.setText(gap, "messagesBetweenOmitted");
|
|
81
|
+
anchor.after(gap);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
while (list.children.length > 300)
|
|
85
|
+
list.removeChild(list.firstChild);
|
|
86
|
+
if (list.firstElementChild && !list.firstElementChild.classList.contains("gap")) {
|
|
87
|
+
const gap = document.createElement("li");
|
|
88
|
+
gap.className = "gap";
|
|
89
|
+
app.setText(gap, "earlierMessages");
|
|
90
|
+
list.insertBefore(gap, list.firstChild);
|
|
91
|
+
}
|
|
73
92
|
}
|