@alexsun-top/opencode-chat-room 0.6.2 → 0.6.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
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.3 — 2026-11-15
|
|
4
|
+
|
|
5
|
+
- Keep a room pinned to the live bottom while images, diagrams and attachments finish loading. Late rows used to push the thread down by their full height, so a room opened at the bottom could end up above the newest message; a growth-triggered scroll also counted as the reader scrolling away, which stopped the pin for good. Only real user scrolling ends the pin now.
|
|
6
|
+
|
|
3
7
|
## 0.6.2 — 2026-11-15
|
|
4
8
|
|
|
5
9
|
- Opening a room always lands on the live bottom, including when the previous visit ended mid-history. The saved-position and first-unread landing are gone; they reopened rooms above messages the reader had already seen.
|
package/package.json
CHANGED
|
@@ -19,6 +19,22 @@ export function initEvents(app) {
|
|
|
19
19
|
new ResizeObserver(syncHeadBottom).observe(chatHead);
|
|
20
20
|
syncHeadBottom();
|
|
21
21
|
}
|
|
22
|
+
// Images, diagrams and attachments grow the list after the first paint and the browser
|
|
23
|
+
// answers with a scroll that looks like the reader moving. Subtract the growth: only a
|
|
24
|
+
// reader who was already at the bottom gets pinned back.
|
|
25
|
+
const messageList = $("#msgList");
|
|
26
|
+
const rememberListMetrics = () => {
|
|
27
|
+
const thread = $("#thread");
|
|
28
|
+
app.state.listMetrics = { height: messageList.offsetHeight, top: thread.scrollTop, client: thread.clientHeight };
|
|
29
|
+
};
|
|
30
|
+
new ResizeObserver(() => {
|
|
31
|
+
const thread = $("#thread"), previous = app.state.listMetrics, growth = messageList.offsetHeight - previous.height;
|
|
32
|
+
// Judge the position before this growth: a reader who was at the bottom stays there,
|
|
33
|
+
// a reader in history is left alone, and a viewport resize keeps following the anchor.
|
|
34
|
+
const wasAtBottom = previous.height - previous.top - previous.client <= 80;
|
|
35
|
+
if (growth > 0 && wasAtBottom) thread.scrollTop = thread.scrollHeight;
|
|
36
|
+
rememberListMetrics();
|
|
37
|
+
}).observe(messageList);
|
|
22
38
|
app.showRestoreFailure = (message) => {
|
|
23
39
|
document.documentElement.classList.add("session-restore");
|
|
24
40
|
$("#joinView").hidden = $("#chatView").hidden = true;
|
|
@@ -232,6 +248,7 @@ export function initEvents(app) {
|
|
|
232
248
|
thread.addEventListener("scroll", () => {
|
|
233
249
|
const adjusting = (app.state.resizeScrollAdjusting || app.state.layoutScrollAdjusting)
|
|
234
250
|
&& performance.now() > app.state.userScrollIntentUntil;
|
|
251
|
+
if (!adjusting) rememberListMetrics();
|
|
235
252
|
if (!adjusting || performance.now() <= app.state.userScrollIntentUntil) captureReadingPosition();
|
|
236
253
|
if (!adjusting && thread.scrollHeight - thread.scrollTop - thread.clientHeight < 80) void app.markActiveRoomRead(performance.now() <= app.state.userScrollIntentUntil);
|
|
237
254
|
app.queueReceiptRefresh();
|
|
@@ -307,18 +307,8 @@ export function initMessages(app) {
|
|
|
307
307
|
if (anchor) thread.scrollTop += anchor.getBoundingClientRect().top - thread.getBoundingClientRect().top - anchorOffset;
|
|
308
308
|
else thread.scrollTop = oldTop;
|
|
309
309
|
}
|
|
310
|
-
//
|
|
311
|
-
//
|
|
312
|
-
// someone reading history is never yanked to the bottom.
|
|
313
|
-
for (const img of list.querySelectorAll(".msg-text img:not([data-load-guard])")) {
|
|
314
|
-
if (img.complete && img.naturalWidth) continue;
|
|
315
|
-
img.dataset.loadGuard = "1";
|
|
316
|
-
img.addEventListener("load", () => {
|
|
317
|
-
if (!img.isConnected) return;
|
|
318
|
-
const thread = $("#thread");
|
|
319
|
-
if (thread.scrollHeight - thread.scrollTop - thread.clientHeight - img.getBoundingClientRect().height <= 80) thread.scrollTop = thread.scrollHeight;
|
|
320
|
-
}, { once: true });
|
|
321
|
-
}
|
|
310
|
+
// Late growth (images, diagrams, attachments) is handled by the list ResizeObserver:
|
|
311
|
+
// it re-pins the thread while the reader is following the newest message.
|
|
322
312
|
app.queueReceiptRefresh?.();
|
|
323
313
|
app.queueReceiptObservation?.();
|
|
324
314
|
return { skipped };
|
|
@@ -123,6 +123,7 @@ export function initRooms(app) {
|
|
|
123
123
|
app.showChat();
|
|
124
124
|
app.renderHead();
|
|
125
125
|
$("#msgList").textContent = "";
|
|
126
|
+
app.state.listMetrics = { height: 0, top: 0, client: 0 };
|
|
126
127
|
app.renderMessages(false);
|
|
127
128
|
app.restoreReadingPosition?.(roomId);
|
|
128
129
|
app.state.readAnchorGuard = null;
|
|
@@ -11,7 +11,7 @@ export const app = {
|
|
|
11
11
|
memberApiUnavailable: new Set(), receiptApiUnavailable: new Set(),
|
|
12
12
|
receipts: new Map(), acknowledgedMessages: new Map(), pendingAcknowledgements: new Map(),
|
|
13
13
|
pendingAction: null, watcherTimer: 0, restored: false, resizeScrollAdjusting: false, layoutScrollAdjusting: false,
|
|
14
|
-
readAnchorGuard: null, userScrollIntentUntil: 0,
|
|
14
|
+
readAnchorGuard: null, userScrollIntentUntil: 0, listMetrics: { height: 0, top: 0, client: 0 },
|
|
15
15
|
},
|
|
16
16
|
rendered: 0,
|
|
17
17
|
firstMessageId: null,
|