@alexsun-top/opencode-chat-room 0.6.2 → 0.6.4
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,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.4 — 2026-11-15
|
|
4
|
+
|
|
5
|
+
- 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.
|
|
6
|
+
- 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.
|
|
7
|
+
- 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.
|
|
8
|
+
|
|
9
|
+
## 0.6.3 — 2026-11-15
|
|
10
|
+
|
|
11
|
+
- 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.
|
|
12
|
+
|
|
3
13
|
## 0.6.2 — 2026-11-15
|
|
4
14
|
|
|
5
15
|
- 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,25 @@ 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
|
+
const wasAtBottom = () => {
|
|
31
|
+
const previous = app.state.listMetrics;
|
|
32
|
+
return previous.height - previous.top - previous.client <= 80;
|
|
33
|
+
};
|
|
34
|
+
new ResizeObserver(() => {
|
|
35
|
+
const thread = $("#thread"), growth = messageList.offsetHeight - app.state.listMetrics.height;
|
|
36
|
+
// Judge the position before this growth: a reader who was at the bottom stays there,
|
|
37
|
+
// a reader in history is left alone, and a viewport resize keeps following the anchor.
|
|
38
|
+
if (growth > 0 && wasAtBottom()) thread.scrollTop = thread.scrollHeight;
|
|
39
|
+
rememberListMetrics();
|
|
40
|
+
}).observe(messageList);
|
|
22
41
|
app.showRestoreFailure = (message) => {
|
|
23
42
|
document.documentElement.classList.add("session-restore");
|
|
24
43
|
$("#joinView").hidden = $("#chatView").hidden = true;
|
|
@@ -232,6 +251,7 @@ export function initEvents(app) {
|
|
|
232
251
|
thread.addEventListener("scroll", () => {
|
|
233
252
|
const adjusting = (app.state.resizeScrollAdjusting || app.state.layoutScrollAdjusting)
|
|
234
253
|
&& performance.now() > app.state.userScrollIntentUntil;
|
|
254
|
+
if (!adjusting) rememberListMetrics();
|
|
235
255
|
if (!adjusting || performance.now() <= app.state.userScrollIntentUntil) captureReadingPosition();
|
|
236
256
|
if (!adjusting && thread.scrollHeight - thread.scrollTop - thread.clientHeight < 80) void app.markActiveRoomRead(performance.now() <= app.state.userScrollIntentUntil);
|
|
237
257
|
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,
|
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 () => {
|