@alexsun-top/opencode-chat-room 0.6.3 → 0.6.5
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 +10 -0
- package/package.json +1 -1
- package/server/assets/chat/events.js +27 -6
- package/server/assets/chat/messages.js +1 -0
- package/server/assets/chat/replies.js +2 -0
- package/server/assets/chat/state.js +1 -1
- package/skills/chatroom/SKILL.md +7 -1
- package/src/v1-plugin.ts +18 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.5 — 2026-11-15
|
|
4
|
+
|
|
5
|
+
- Keep a room at the bottom while the reader is following it: any growth of the message list pins the view, instead of deciding from scroll events that arrive in an unpredictable order. Only the reader's own wheel, touch, key, or scrollbar drag ends following, and the view stays still while a pointer gesture or a text selection is in progress. Opening a room, jumping to the latest message, and landing after a resize still end at the bottom.
|
|
6
|
+
|
|
7
|
+
## 0.6.4 — 2026-11-15
|
|
8
|
+
|
|
9
|
+
- Forbid the host's built-in question, confirmation, and approval dialogs for any agent that belongs to a room: every question and every manual step goes into the room, even when the person who must answer is the operator of the current session. Native dialogs leave no room record and only reach one human.
|
|
10
|
+
- Refuse the host's question tool from a room member instead of only advising against it: the call fails with the room-tool instructions, so the agent asks where the answer is recorded. A center that cannot be reached leaves the tool untouched.
|
|
11
|
+
- Tell agents to reach a scheduled moment with a room reminder instead of `sleep`, a long foreground command, or a polling loop, and to run long work in the background. A wait held in a shell hides the schedule from the room and dies with the process.
|
|
12
|
+
|
|
3
13
|
## 0.6.3 — 2026-11-15
|
|
4
14
|
|
|
5
15
|
- 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.
|
package/package.json
CHANGED
|
@@ -28,11 +28,18 @@ export function initEvents(app) {
|
|
|
28
28
|
app.state.listMetrics = { height: messageList.offsetHeight, top: thread.scrollTop, client: thread.clientHeight };
|
|
29
29
|
};
|
|
30
30
|
new ResizeObserver(() => {
|
|
31
|
-
const thread = $("#thread"), previous = app.state.listMetrics
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
const thread = $("#thread"), previous = app.state.listMetrics;
|
|
32
|
+
const grew = messageList.offsetHeight > previous.height, sameBox = thread.clientHeight === previous.client;
|
|
33
|
+
// Rows arrive in bursts, so judging each burst on its own loses the reader after the
|
|
34
|
+
// first one. Follow while the reader has not scrolled away: then every growth pins.
|
|
35
|
+
// A changed viewport height (composer, window) is not list growth and keeps its anchor.
|
|
36
|
+
const selection = getSelection(), selecting = Boolean(selection && !selection.isCollapsed && messageList.contains(selection.anchorNode));
|
|
37
|
+
// A pointer held over the list is mid-gesture: dragging a selection or a click that
|
|
38
|
+
// must land where it started. Moving the content under it loses both.
|
|
39
|
+
if (grew && sameBox && app.state.followBottom && !selecting && !app.state.threadPointerDown
|
|
40
|
+
&& thread.scrollHeight - thread.scrollTop - thread.clientHeight > 1) {
|
|
41
|
+
thread.scrollTop = thread.scrollHeight;
|
|
42
|
+
}
|
|
36
43
|
rememberListMetrics();
|
|
37
44
|
}).observe(messageList);
|
|
38
45
|
app.showRestoreFailure = (message) => {
|
|
@@ -92,6 +99,7 @@ export function initEvents(app) {
|
|
|
92
99
|
// Entering a room always shows the newest messages. Restoring an old anchor
|
|
93
100
|
// leaves the reader above messages that already arrived or grew afterwards.
|
|
94
101
|
thread.scrollTop = thread.scrollHeight;
|
|
102
|
+
app.state.followBottom = true;
|
|
95
103
|
captureReadingPosition();
|
|
96
104
|
return { messageId: readingPosition?.messageId, atBottom: true };
|
|
97
105
|
};
|
|
@@ -244,11 +252,24 @@ export function initEvents(app) {
|
|
|
244
252
|
});
|
|
245
253
|
thread.addEventListener("pointerdown", (event) => {
|
|
246
254
|
if (event.clientX >= thread.getBoundingClientRect().right - 18) markScrollIntent();
|
|
255
|
+
app.state.threadPointerDown = true;
|
|
247
256
|
});
|
|
257
|
+
const releasePointer = () => { app.state.threadPointerDown = false; };
|
|
258
|
+
window.addEventListener("pointerup", releasePointer);
|
|
259
|
+
window.addEventListener("pointercancel", releasePointer);
|
|
260
|
+
window.addEventListener("blur", releasePointer);
|
|
248
261
|
thread.addEventListener("scroll", () => {
|
|
249
262
|
const adjusting = (app.state.resizeScrollAdjusting || app.state.layoutScrollAdjusting)
|
|
250
263
|
&& performance.now() > app.state.userScrollIntentUntil;
|
|
251
|
-
if (!adjusting)
|
|
264
|
+
if (!adjusting) {
|
|
265
|
+
// The growth baseline belongs to the observer alone. A scroll caused by the growth
|
|
266
|
+
// itself arrives before the observer sees the new height, and refreshing the
|
|
267
|
+
// baseline here would make that growth look like no growth at all.
|
|
268
|
+
// Only a scroll the reader started ends following; layout shifts do not.
|
|
269
|
+
const gap = thread.scrollHeight - thread.scrollTop - thread.clientHeight;
|
|
270
|
+
if (gap <= 80) app.state.followBottom = true;
|
|
271
|
+
else if (performance.now() <= app.state.userScrollIntentUntil) app.state.followBottom = false;
|
|
272
|
+
}
|
|
252
273
|
if (!adjusting || performance.now() <= app.state.userScrollIntentUntil) captureReadingPosition();
|
|
253
274
|
if (!adjusting && thread.scrollHeight - thread.scrollTop - thread.clientHeight < 80) void app.markActiveRoomRead(performance.now() <= app.state.userScrollIntentUntil);
|
|
254
275
|
app.queueReceiptRefresh();
|
|
@@ -98,6 +98,7 @@ export function initMessages(app) {
|
|
|
98
98
|
};
|
|
99
99
|
app.jumpToBottom = () => {
|
|
100
100
|
app.state.readAnchorGuard = null;
|
|
101
|
+
app.state.followBottom = true;
|
|
101
102
|
$("#thread").scrollTop = $("#thread").scrollHeight;
|
|
102
103
|
const entry = app.state.room && app.state.rooms.get(app.state.room.id);
|
|
103
104
|
app.state.unread = entry ? entry.unreadIds.size + (entry.unreadOverflow ? 100 : 0) : 0;
|
|
@@ -134,6 +134,8 @@ async function jumpToOriginal(roomId, messageId, app) {
|
|
|
134
134
|
} catch { return; }
|
|
135
135
|
if (!original) return markUnavailable(messageId, roomId, app);
|
|
136
136
|
app.state.positions.set(roomId, { messageId, offset: 0, atBottom: false }); app.savePosition(roomId, { messageId, offset: 0, atBottom: false });
|
|
137
|
+
// Jumping to an older message is the reader choosing history.
|
|
138
|
+
app.state.followBottom = false;
|
|
137
139
|
if (app.state.room?.id === roomId && app.state.navigationGeneration === generation) {
|
|
138
140
|
app.state.room = app.state.rooms.get(roomId)?.room || room; app.rerenderMessages();
|
|
139
141
|
const row = document.querySelector(`[data-msg-id="${CSS.escape(messageId)}"]`), thread = app.$("#thread");
|
|
@@ -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, listMetrics: { height: 0, top: 0, client: 0 },
|
|
14
|
+
readAnchorGuard: null, userScrollIntentUntil: 0, listMetrics: { height: 0, top: 0, client: 0 }, followBottom: true, threadPointerDown: false,
|
|
15
15
|
},
|
|
16
16
|
rendered: 0,
|
|
17
17
|
firstMessageId: null,
|
package/skills/chatroom/SKILL.md
CHANGED
|
@@ -26,9 +26,11 @@ Prefer a persistent room question over the agent's native question dialog for wo
|
|
|
26
26
|
|
|
27
27
|
Keep each question focused. Include concrete choices when useful. The human answers through OC Chat's Questions panel; ordinary chat messages do not dismiss a pending question.
|
|
28
28
|
|
|
29
|
+
While you belong to any room, do not call the host's built-in question, confirmation, or approval tool. This holds even when the human you need is the operator of the current session: a built-in dialog leaves no trace in the room, reaches only one human, and pushes the others to answer the same question again. Ask in the room instead, and route any manual step (restarts, credentials, releases) through the room as well.
|
|
30
|
+
|
|
29
31
|
Question messages require ChatRoom 0.4.0 or newer on the client and central server. If that workflow is unavailable, explain the limitation in the room rather than claiming a question was queued.
|
|
30
32
|
|
|
31
|
-
Discuss shared questions in the room rather than opening private dialogs. Consolidate unresolved decisions for the human. Continue independent work while awaiting an answer, without repeatedly polling or sending reminder duplicates.
|
|
33
|
+
Discuss shared questions in the room rather than opening private dialogs. Consolidate unresolved decisions for the human. Continue independent work while awaiting an answer, without repeatedly polling or sending reminder duplicates. The only exception is a session with no room at all.
|
|
32
34
|
|
|
33
35
|
## Room tool basics
|
|
34
36
|
|
|
@@ -82,6 +84,10 @@ Templates support `{{time}}`, `{{initiator}}`, and `{{room}}`. The server posts
|
|
|
82
84
|
|
|
83
85
|
When a scheduled reminder delivers a plan the human already approved, start executing it right away. Do not ask for a second confirmation of the schedule or the plan; report progress and results in the room instead. Still stop for a decision the plan never covered, such as a new destination or an irreversible action outside the agreed scope.
|
|
84
86
|
|
|
87
|
+
Waiting for a wall-clock time is what reminders are for. After joining a room, never block on `sleep`, a long foreground command, or a polling loop to reach a scheduled moment: create a reminder in the room instead and let the delivery wake the work. A `sleep` holds a shell and an agent slot for the whole wait, hides the schedule from the other members, and turns a missed wake-up into a silent failure; a reminder is recorded, visible to everyone, and survives restarts. Prefer a reminder even for short waits when the wait is part of the plan other people should see.
|
|
88
|
+
|
|
89
|
+
Run long work in the background rather than blocking on it, and let the completion notification resume the work. Reserve foreground execution for commands whose result the next step reads, and keep those short. When a task needs several minutes of waiting, say what you are waiting for in the room and schedule the check as a reminder instead of holding the turn.
|
|
90
|
+
|
|
85
91
|
## Share files and media
|
|
86
92
|
|
|
87
93
|
In central mode, upload a local file with the room tool:
|
package/src/v1-plugin.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Config, Plugin, PluginInput, ToolDefinition } from "@opencode-ai/p
|
|
|
2
2
|
import type { V2Runtime } from "./v2-plugin";
|
|
3
3
|
import type { QueueTransport } from "./queue-transport";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { request } from "./center-client";
|
|
5
6
|
|
|
6
7
|
const bundledSkillsPath = fileURLToPath(new URL("../skills", import.meta.url));
|
|
7
8
|
|
|
@@ -14,6 +15,7 @@ export function createV1Server(deps: {
|
|
|
14
15
|
checkInbox(runtime: V2Runtime, sessionID: string): Promise<void>;
|
|
15
16
|
wake(runtime: V2Runtime, sessions: ReadonlySet<string>): Promise<void>;
|
|
16
17
|
central: boolean;
|
|
18
|
+
hasRooms?(runtime: V2Runtime, sessionID: string): Promise<boolean>;
|
|
17
19
|
}) : Plugin {
|
|
18
20
|
return async (input) => {
|
|
19
21
|
const sessions = new Set<string>();
|
|
@@ -24,6 +26,10 @@ export function createV1Server(deps: {
|
|
|
24
26
|
};
|
|
25
27
|
const runtime = deps.runtime(input, transport);
|
|
26
28
|
const adminTool = deps.admin;
|
|
29
|
+
const hasRooms = deps.hasRooms ?? (async (runtime: V2Runtime, sessionID: string) => {
|
|
30
|
+
const rooms = await request(runtime.center, `/rooms?sessionID=${encodeURIComponent(sessionID)}`, "GET");
|
|
31
|
+
return Array.isArray(rooms) && rooms.length > 0;
|
|
32
|
+
});
|
|
27
33
|
let timer: ReturnType<typeof setInterval> | undefined;
|
|
28
34
|
if (deps.central) {
|
|
29
35
|
const sweep = (pollInbox: boolean) => void deps.run(runtime, async () => {
|
|
@@ -58,6 +64,18 @@ export function createV1Server(deps: {
|
|
|
58
64
|
};
|
|
59
65
|
},
|
|
60
66
|
dispose: async () => { if (timer) clearInterval(timer); },
|
|
67
|
+
// A session that belongs to a room must ask there, where the question is recorded
|
|
68
|
+
// and every member sees it. Questions asked through the host dialog reach one person.
|
|
69
|
+
"tool.execute.before": async (hook: { tool: string; sessionID: string }) => {
|
|
70
|
+
if (hook.tool !== "question") return;
|
|
71
|
+
let member = false;
|
|
72
|
+
try {
|
|
73
|
+
member = await deps.run(runtime, () => hasRooms(runtime, hook.sessionID));
|
|
74
|
+
} catch {
|
|
75
|
+
return; // A center that cannot answer must not block the agent's tooling.
|
|
76
|
+
}
|
|
77
|
+
if (member) throw new Error("Do not ask through the host dialog while this session belongs to a room. Send the question in the room instead: room tool, action send, isQuestion true, with the room ID and enough context for the human to answer.");
|
|
78
|
+
},
|
|
61
79
|
"chat.message": async (event: { sessionID: string }) => {
|
|
62
80
|
sessions.add(event.sessionID);
|
|
63
81
|
await deps.run(runtime, async () => {
|