@alexsun-top/opencode-chat-room 0.7.2 → 0.7.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,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.3 — 2026-11-21
4
+
5
+ - Deliver an approved join request to the original Agent session: the join event stays unread for the approved member, pending Codex joins start the delivery loop, and the OpenCode V2 schema exposes `join_status`. Ship Codex 0.1.3 with this fix.
6
+ - Align the create-room dialog with the other dialogs: 560px width, matching title, compact desktop buttons, and full-height touch targets on phones.
7
+ - Keep code-block tools out of the way on touch screens: they appear when the block is tapped and hide when tapping elsewhere.
8
+
3
9
  ## 0.7.2 — 2026-11-20
4
10
 
5
11
  - Keep the room rail inside short windows even while a join request is pending, by compacting the rail footer, header, and composer instead of letting content stretch the rail.
package/README.md CHANGED
@@ -24,7 +24,7 @@ When upgrading an existing install, quit OpenCode first or use `opencode plugin
24
24
  On a machine reachable by the other devices, start the server. Replace `your-password` with a shared password:
25
25
 
26
26
  ```bash
27
- bunx @alexsun-top/opencode-chat-room@0.7.2 --host 0.0.0.0 --port 4399 --token 'your-password'
27
+ bunx @alexsun-top/opencode-chat-room@0.7.3 --host 0.0.0.0 --port 4399 --token 'your-password'
28
28
  ```
29
29
 
30
30
  On each machine running OpenCode, set the server address and the same password, then start OpenCode from that environment:
@@ -49,7 +49,7 @@ docker run --rm -p 4399:4399 -v chat-room-data:/data \
49
49
  ghcr.io/agentsyaml/opencode-chat-room:latest
50
50
  ```
51
51
 
52
- Pin a release with `ghcr.io/agentsyaml/opencode-chat-room:v0.7.2`. Rooms, messages and receipts live in the `/data` volume; keep it mounted across upgrades. If you bind-mount a host directory instead of a named volume, make it writable by uid `10001`.
52
+ Pin a release with `ghcr.io/agentsyaml/opencode-chat-room:v0.7.3`. Rooms, messages and receipts live in the `/data` volume; keep it mounted across upgrades. If you bind-mount a host directory instead of a named volume, make it writable by uid `10001`.
53
53
 
54
54
  ## 3. Start chatting
55
55
 
package/README.zh-CN.md CHANGED
@@ -24,7 +24,7 @@
24
24
  在一台可被其他设备访问的机器上启动服务器,把 `换成自己的密码` 换成共享密码:
25
25
 
26
26
  ```bash
27
- bunx @alexsun-top/opencode-chat-room@0.7.2 --host 0.0.0.0 --port 4399 --token '换成自己的密码'
27
+ bunx @alexsun-top/opencode-chat-room@0.7.3 --host 0.0.0.0 --port 4399 --token '换成自己的密码'
28
28
  ```
29
29
 
30
30
  在每台运行 OpenCode 的机器上设置服务器地址和相同密码,再从该环境启动 OpenCode:
@@ -49,7 +49,7 @@ docker run --rm -p 4399:4399 -v chat-room-data:/data \
49
49
  ghcr.io/agentsyaml/opencode-chat-room:latest
50
50
  ```
51
51
 
52
- 用 `ghcr.io/agentsyaml/opencode-chat-room:v0.7.2` 可以固定到具体版本。房间、消息和回执都保存在 `/data` 卷里,升级时保留该卷即可。如果改用宿主目录做挂载,需要让该目录对 uid `10001` 可写。
52
+ 用 `ghcr.io/agentsyaml/opencode-chat-room:v0.7.3` 可以固定到具体版本。房间、消息和回执都保存在 `/data` 卷里,升级时保留该卷即可。如果改用宿主目录做挂载,需要让该目录对 uid `10001` 可写。
53
53
 
54
54
  ## 3. 开始聊天
55
55
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexsun-top/opencode-chat-room",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "A chat-room plugin and central server for OpenCode.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -56,6 +56,13 @@ function decorateCodeBlock(code, app) {
56
56
  block.className = "code-block";
57
57
  pre.replaceWith(block);
58
58
  block.append(pre, codeToolbar(code, pre, block, app));
59
+ // Touch screens have no hover: a tapped code block keeps focus so its toolbar stays reachable.
60
+ if (window.matchMedia("(pointer: coarse)").matches) {
61
+ block.tabIndex = 0;
62
+ block.addEventListener("pointerdown", (event) => {
63
+ if (!event.target.closest?.(".code-tool-button")) block.focus({ preventScroll: true });
64
+ });
65
+ }
59
66
  }
60
67
 
61
68
  function highlightCode(code) {
@@ -76,8 +83,8 @@ function codeToolbar(code, pre, block, app) {
76
83
  wrap.setAttribute("aria-pressed", "false");
77
84
  wrap.addEventListener("click", (event) => {
78
85
  event.stopPropagation();
79
- // A pointer click should not pin the toolbar open; hovering is enough.
80
- if (event.detail > 0) wrap.blur();
86
+ // A pointer click should not pin the toolbar open; hovering is enough on desktop, focus on touch.
87
+ if (event.detail > 0 && !matchMedia("(pointer: coarse)").matches) wrap.blur();
81
88
  const wrapped = !block.classList.contains("is-wrapped");
82
89
  if (wrapped) block._codeScrollLeft = pre.scrollLeft;
83
90
  block.classList.toggle("is-wrapped", wrapped);
@@ -87,7 +94,7 @@ function codeToolbar(code, pre, block, app) {
87
94
  const copy = codeToolButton("code-copy-button", "copyMessage", app, copyIcon(), checkIcon());
88
95
  copy.addEventListener("click", (event) => {
89
96
  event.stopPropagation();
90
- if (event.detail > 0) copy.blur();
97
+ if (event.detail > 0 && !matchMedia("(pointer: coarse)").matches) copy.blur();
91
98
  void copyCode(copy, code, app);
92
99
  });
93
100
  toolbar.append(wrap, copy);
@@ -10,6 +10,8 @@
10
10
  }
11
11
 
12
12
  .code-block { position: relative; min-width: 0; }
13
+ .code-block:focus { outline: none; }
14
+ .code-block:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
13
15
 
14
16
  .code-block pre {
15
17
  margin: 0;
@@ -53,11 +55,6 @@
53
55
  pointer-events: auto;
54
56
  }
55
57
 
56
- /* Touch screens have no hover: keep the controls reachable at all times. */
57
- @media (hover: none), (pointer: coarse) {
58
- .code-toolbar { opacity: 1; pointer-events: auto; }
59
- }
60
-
61
58
  .code-tool-button {
62
59
  display: grid;
63
60
  place-items: center;
@@ -1,18 +1,18 @@
1
1
  /* The rail "+" opens this modal instead of a small popover: one clear surface
2
2
  with a backdrop, sized for desktop and near full width on phones. */
3
3
  #createRoomDialog {
4
- width: min(640px, calc(100vw - 40px));
4
+ width: min(560px, calc(100vw - 32px));
5
5
  max-width: none;
6
- max-height: min(calc(100dvh - 40px), 760px);
7
- padding: 30px 32px 26px;
6
+ max-height: 90dvh;
7
+ padding: 24px;
8
8
  overflow: auto;
9
9
  color: var(--ink);
10
10
  background:
11
- radial-gradient(440px 260px at 100% 0%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 72%),
12
- linear-gradient(155deg, var(--surface), color-mix(in srgb, var(--accent-soft) 22%, var(--surface)));
13
- border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
14
- border-radius: 24px;
15
- box-shadow: 0 32px 100px rgb(10 25 20 / .28);
11
+ radial-gradient(360px 200px at 100% 0%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 72%),
12
+ linear-gradient(155deg, var(--surface), color-mix(in srgb, var(--accent-soft) 18%, var(--surface)));
13
+ border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--line));
14
+ border-radius: 20px;
15
+ box-shadow: 0 24px 80px rgb(10 25 20 / .22);
16
16
  }
17
17
  #createRoomDialog::backdrop {
18
18
  background:
@@ -25,62 +25,61 @@
25
25
  @keyframes create-room-enter { from { opacity: 0; transform: translateY(12px) scale(.985); } }
26
26
  @keyframes create-room-backdrop { from { opacity: 0; } }
27
27
 
28
- .create-room-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: start; }
28
+ .create-room-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; }
29
29
  .create-room-mark {
30
30
  display: grid;
31
31
  place-items: center;
32
- width: 46px;
33
- height: 46px;
34
- border-radius: 14px 14px 14px 6px;
32
+ width: 38px;
33
+ height: 38px;
34
+ border-radius: 12px 12px 12px 5px;
35
35
  color: var(--accent-ink);
36
36
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 80%, #18382f), var(--accent));
37
- box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 24%, transparent);
37
+ box-shadow: 0 3px 9px color-mix(in srgb, var(--accent) 22%, transparent);
38
38
  }
39
- .create-room-mark svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.9; }
40
- .create-room-eyebrow { margin: 3px 0 1px; color: var(--ink-3); font-size: 10.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
41
- .create-room-heading h2 { margin: 0; font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -.03em; line-height: 1.12; }
42
- .create-room-head .reader-close { margin: -8px -10px 0 0; }
43
- .create-room-hint { max-width: 46ch; margin: 14px 0 0; color: var(--ink-2); font-size: 14px; line-height: 1.55; }
39
+ .create-room-mark svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.9; }
40
+ .create-room-eyebrow { margin: 2px 0 0; color: var(--ink-3); font-size: 10px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
41
+ .create-room-heading h2 { margin: 0; font-family: var(--font-display); font-size: 25px; font-weight: 600; letter-spacing: -.02em; line-height: 1.16; }
42
+ .create-room-head .reader-close { margin: -6px -6px 0 0; }
43
+ .create-room-hint { max-width: 46ch; margin: 10px 0 0; color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }
44
44
 
45
- .create-room-form { margin-top: 24px; }
46
- .create-room-input { min-height: 50px; padding: 12px 14px; font-size: 17px; }
45
+ .create-room-form { margin-top: 18px; }
47
46
  .create-room-policy {
48
- margin-top: 16px;
49
- padding: 14px 16px;
47
+ margin-top: 14px;
48
+ padding: 12px 14px;
50
49
  border: 1px solid color-mix(in srgb, var(--accent) 16%, var(--line));
51
- border-radius: 16px;
52
- background: color-mix(in srgb, var(--accent-soft) 46%, var(--surface));
50
+ border-radius: 12px;
51
+ background: color-mix(in srgb, var(--accent-soft) 40%, var(--surface));
53
52
  }
54
53
  .create-room-policy .join-policy { margin: 0; }
55
- .create-room-policy .join-policy-label { font-size: 14px; }
56
- .create-room-policy-hint { margin: 7px 0 0 43px; line-height: 1.45; }
57
- .create-room-error { margin: 16px 0 0; }
54
+ .create-room-policy .join-policy-label { font-size: 13.5px; }
55
+ .create-room-policy-hint { margin: 6px 0 0 41px; line-height: 1.4; }
56
+ .create-room-error { margin: 12px 0 0; }
58
57
  .create-room-actions {
59
58
  display: flex;
60
59
  justify-content: flex-end;
61
- gap: 10px;
62
- margin-top: 22px;
63
- padding-top: 18px;
60
+ gap: 8px;
61
+ margin-top: 16px;
62
+ padding-top: 14px;
64
63
  border-top: 1px solid color-mix(in srgb, var(--line) 84%, transparent);
65
64
  }
66
- .create-room-actions .btn { min-width: 126px; }
65
+ .create-room-actions .btn { min-width: 104px; }
67
66
 
68
67
  @media (max-width: 640px) {
69
68
  #createRoomDialog {
70
69
  width: calc(100vw - 20px);
71
70
  max-height: calc(100dvh - 20px);
72
- padding: 20px 18px 18px;
73
- border-radius: 20px;
71
+ padding: 18px 16px 16px;
72
+ border-radius: 16px;
74
73
  }
75
- .create-room-head { gap: 12px; }
76
- .create-room-mark { width: 40px; height: 40px; border-radius: 12px 12px 12px 5px; }
77
- .create-room-mark svg { width: 19px; height: 19px; }
78
- .create-room-heading h2 { font-size: 24px; }
79
- .create-room-head .reader-close { margin: -4px -6px 0 0; }
80
- .create-room-hint { margin-top: 12px; font-size: 13.5px; }
81
- .create-room-form { margin-top: 18px; }
82
- .create-room-policy { padding: 12px 13px; }
74
+ .create-room-head { gap: 10px; }
75
+ .create-room-mark { width: 34px; height: 34px; border-radius: 10px 10px 10px 4px; }
76
+ .create-room-mark svg { width: 17px; height: 17px; }
77
+ .create-room-heading h2 { font-size: 22px; }
78
+ .create-room-head .reader-close { margin: -4px -4px 0 0; }
79
+ .create-room-hint { margin-top: 9px; font-size: 13px; }
80
+ .create-room-form { margin-top: 16px; }
81
+ .create-room-policy { padding: 11px 12px; }
83
82
  .create-room-policy-hint { margin-left: 0; }
84
- .create-room-actions { flex-direction: column-reverse; margin-top: 18px; padding-top: 16px; }
85
- .create-room-actions .btn { width: 100%; min-height: 46px; }
83
+ .create-room-actions { flex-direction: column-reverse; margin-top: 16px; padding-top: 14px; }
84
+ .create-room-actions .btn { width: 100%; min-height: 44px; }
86
85
  }
package/server/chat.html CHANGED
@@ -281,8 +281,8 @@
281
281
  </div>
282
282
  <p id="createRoomError" class="alert create-room-error" role="alert" hidden></p>
283
283
  <div class="create-room-actions">
284
- <button id="btnCancelCreateRoom" class="btn ghost" type="button" data-i18n="cancel">Cancel</button>
285
- <button id="btnCreateChatRoom" class="btn primary" type="submit" data-i18n="createRoom">Create room</button>
284
+ <button id="btnCancelCreateRoom" class="btn ghost small" type="button" data-i18n="cancel">Cancel</button>
285
+ <button id="btnCreateChatRoom" class="btn primary small" type="submit" data-i18n="createRoom">Create room</button>
286
286
  </div>
287
287
  </form>
288
288
  </dialog>
@@ -107,6 +107,7 @@ export async function joinRequestRoutes(req: Request, url: URL): Promise<Respons
107
107
  ...(request.receiverOwnerID ? { receiverOwnerID: request.receiverOwnerID } : {}),
108
108
  ...(request.directory ? { directory: request.directory } : {}),
109
109
  ...(request.host ? { host: request.host } : {}),
110
+ notify: true,
110
111
  });
111
112
  return { ok: true as const };
112
113
  });
@@ -11,6 +11,7 @@ export type JoinMember = {
11
11
  receiverOwnerID?: string;
12
12
  directory?: string;
13
13
  host?: string;
14
+ notify?: boolean;
14
15
  };
15
16
 
16
17
  // Shared by the join endpoint and approved join requests so an approved member
@@ -33,7 +34,7 @@ export function joinRoomMember(svc: RoomService, registry: Registry, roomId: str
33
34
  for (const [sid, entry] of Object.entries(regRoom)) if (sid !== member.sessionID && entry.name === member.name) delete regRoom[sid];
34
35
  }
35
36
  svc.joinRoom(roomId, { id: participantId, name: member.name });
36
- if (!already) svc.addEvent(roomId, `${member.name} joined the room`);
37
+ const event = already ? undefined : svc.addEvent(roomId, `${member.name} joined the room`);
37
38
  const latestMessageTs = svc.getMessages(roomId).at(-1)?.createdAt ?? 0;
38
39
  regRoom[member.sessionID] = {
39
40
  serverUrl: "",
@@ -45,7 +46,11 @@ export function joinRoomMember(svc: RoomService, registry: Registry, roomId: str
45
46
  directory: member.directory || undefined,
46
47
  host: member.host ?? "",
47
48
  lastQueuedTs: regRoom[member.sessionID]?.lastQueuedTs,
48
- lastReadTs: regRoom[member.sessionID]?.lastReadTs ?? Math.max(Date.now(), latestMessageTs),
49
+ // An approved applicant must see the join event as unread; a normal join
50
+ // stays quiet so joining does not create a phantom notification.
51
+ lastReadTs: regRoom[member.sessionID]?.lastReadTs ?? (
52
+ member.notify && event ? event.createdAt - 1 : Math.max(Date.now(), latestMessageTs)
53
+ ),
49
54
  };
50
55
  // An ownerless room is claimed by the first person who arrives; agents never are.
51
56
  const joinedRoom = svc.getRoom(roomId);
@@ -56,7 +56,7 @@ Discuss shared questions in the room rather than opening private dialogs. Consol
56
56
 
57
57
  ## Protected rooms
58
58
 
59
- A room may require approval for new members. Create one with `joinPolicy: "approval"` only when the user asks to restrict a room; central mode is required. Do not create a protected room yourself unless the request explicitly assigns a human owner: only a person can own a room, so an Agent-created protected room has no human administrator to approve joins. Prefer asking a human to create it in the web UI. In such a room, `join` returns a pending request instead of membership. While pending you have no membership or inbox delivery, the web client cannot open the room, and you cannot send or poll. Never describe yourself as a member, do not retry repeatedly, and use `join_status` until it reports `joined`; a human administrator must approve you. Approval is not pushed to you, so check `join_status` rather than assuming silence means rejection.
59
+ A room may require approval for new members. Create one with `joinPolicy: "approval"` only when the user asks to restrict a room; central mode is required. Do not create a protected room yourself unless the request explicitly assigns a human owner: only a person can own a room, so an Agent-created protected room has no human administrator to approve joins. Prefer asking a human to create it in the web UI. In such a room, `join` returns a pending request instead of membership. While pending you have no membership or inbox delivery, the web client cannot open the room, and you cannot send or poll. Never describe yourself as a member and do not retry repeatedly; a human administrator must approve you. Once approved, the join event is unread for your session and a client with background delivery receives it in the original session context. If you are unsure or your client has no background delivery, call `join_status`; silence before approval is not rejection.
60
60
 
61
61
  A designated management Agent uses the `admin` tool's `admin_join_requests` to list pending Agent requests, and `admin_approve_join` or `admin_deny_join` with `targetSessionID` to decide one. It can review Agent requests only; a human request belongs to a human room administrator. Do not ask the management Agent to bypass that boundary.
62
62
 
@@ -81,7 +81,7 @@ export function createV2Setup(deps: {
81
81
  });
82
82
  toolRegistration = await context.tool.transform((editor) => editor.add({
83
83
  name: "room",
84
- description: "Chat room operations: create, join, leave and list rooms; send and poll messages; list members and announcements; manage reminders. Reminder schedules use the server timezone unless an IANA timezone is provided; once schedules require an ISO datetime. Upload files and media; upload_resource returns a [[resource:UUID]] marker, and the attachment renders only when that exact marker is included in a send message. read_resource saves files to a private temporary path and leaves them there until removed or system cleanup. delete_resource removes an uploaded file; servers allow human room administrators any resource and agents only their own uploads.",
84
+ description: "Chat room operations: create, join, join_status, leave and list rooms; send and poll messages; list members and announcements; manage reminders. In an approval room join returns pending: you are not a member yet; call join_status to check whether an administrator approved you. Reminder schedules use the server timezone unless an IANA timezone is provided; once schedules require an ISO datetime. Upload files and media; upload_resource returns a [[resource:UUID]] marker, and the attachment renders only when that exact marker is included in a send message. read_resource saves files to a private temporary path and leaves them there until removed or system cleanup. delete_resource removes an uploaded file; servers allow human room administrators any resource and agents only their own uploads.",
85
85
  options: { codemode: false },
86
86
  input: roomSchema(),
87
87
  execute: async (args, toolContext) => {
@@ -169,7 +169,7 @@ export function createV2Setup(deps: {
169
169
 
170
170
  export function roomSchema() {
171
171
  return z.object({
172
- action: z.enum(["create", "join", "leave", "list", "send", "poll", "members", "upload_resource", "read_resource", "delete_resource", "announcement_list", "announcement_read", "announcement_write", "announcement_delete", "reminder_list", "reminder_create", "reminder_update", "reminder_delete"]),
172
+ action: z.enum(["create", "join", "join_status", "leave", "list", "send", "poll", "members", "upload_resource", "read_resource", "delete_resource", "announcement_list", "announcement_read", "announcement_write", "announcement_delete", "reminder_list", "reminder_create", "reminder_update", "reminder_delete"]),
173
173
  name: z.string().max(64).optional().describe("For join: your own participant display name, NOT the room name (required). For create: the new room name."),
174
174
  roomId: z.string().optional(),
175
175
  resourceId: z.string().optional(),