@alexsun-top/opencode-chat-room 0.6.6 → 0.6.7

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/cli.ts +1 -1
  3. package/docs/administrator-rooms.md +5 -4
  4. package/index.ts +2 -2
  5. package/package.json +3 -2
  6. package/plugin.ts +21 -20
  7. package/server/admin-routes.ts +15 -7
  8. package/server/admin-state.ts +2 -2
  9. package/server/announcement-routes.ts +2 -2
  10. package/server/assets/attachments.css +25 -0
  11. package/server/assets/base.css +42 -30
  12. package/server/assets/chat/admin-badge.js +27 -0
  13. package/server/assets/chat/admin.js +71 -24
  14. package/server/assets/chat/announcements.js +27 -11
  15. package/server/assets/chat/attachments.js +50 -10
  16. package/server/assets/chat/events.js +31 -7
  17. package/server/assets/chat/image-zoom.js +57 -0
  18. package/server/assets/chat/index.js +2 -0
  19. package/server/assets/chat/markdown.js +33 -4
  20. package/server/assets/chat/members.js +14 -6
  21. package/server/assets/chat/message-polling.js +137 -0
  22. package/server/assets/chat/message-window.js +14 -0
  23. package/server/assets/chat/messages.js +6 -128
  24. package/server/assets/chat/panels.js +37 -0
  25. package/server/assets/chat/receipts.js +3 -1
  26. package/server/assets/chat/reminders.js +19 -5
  27. package/server/assets/chat/room-list.js +51 -0
  28. package/server/assets/chat/rooms.js +20 -80
  29. package/server/assets/chat/state.js +28 -14
  30. package/server/assets/chat/system-messages.js +25 -7
  31. package/server/assets/conversation.css +18 -26
  32. package/server/assets/responsive.css +25 -8
  33. package/server/chat-server.ts +38 -8
  34. package/server/chat.html +103 -67
  35. package/server/history-route.ts +1 -1
  36. package/server/inbox.ts +2 -2
  37. package/server/member-routes.ts +4 -4
  38. package/server/newrooms.ts +96 -13
  39. package/server/resource-routes.ts +19 -5
  40. package/server/room-owner.ts +89 -0
  41. package/server/room-payload.ts +4 -2
  42. package/server/room-reminders.ts +3 -3
  43. package/server/sw.js +1 -0
  44. package/server/wake.ts +5 -5
  45. package/skills/chatroom/SKILL.md +3 -1
  46. package/src/README.md +20 -0
  47. package/src/{admin-client.ts → agent/admin-client.ts} +15 -9
  48. package/src/{admin-credentials.ts → agent/admin-credentials.ts} +1 -1
  49. package/src/{agent-presence.ts → agent/agent-presence.ts} +2 -2
  50. package/src/{agent-receipts.ts → agent/agent-receipts.ts} +2 -2
  51. package/src/{announcement-tool.ts → agent/announcement-tool.ts} +2 -2
  52. package/src/{chatroom-skill.ts → agent/chatroom-skill.ts} +1 -1
  53. package/src/{center-client.ts → center/center-client.ts} +22 -9
  54. package/src/{center-inbox.ts → center/center-inbox.ts} +9 -9
  55. package/src/{center-wake.ts → center/center-wake.ts} +6 -6
  56. package/src/{mentions.ts → center/mentions.ts} +1 -1
  57. package/src/{queue-transport.ts → center/queue-transport.ts} +3 -3
  58. package/src/{queue.ts → center/queue.ts} +2 -2
  59. package/src/{reminder-client.ts → center/reminder-client.ts} +1 -1
  60. package/src/{session-delivery.ts → center/session-delivery.ts} +1 -1
  61. package/src/{announcements.ts → rooms/announcements.ts} +2 -2
  62. package/src/{resource-upload.ts → rooms/resource-upload.ts} +1 -1
  63. package/src/{resources.ts → rooms/resources.ts} +55 -9
  64. package/src/{room-service.ts → rooms/room-service.ts} +12 -1
  65. package/src/{background.ts → runtime/background.ts} +3 -3
  66. package/src/{plugin-notifications.ts → runtime/plugin-notifications.ts} +8 -8
  67. package/src/{v1-plugin.ts → runtime/v1-plugin.ts} +4 -4
  68. package/src/{v2-plugin.ts → runtime/v2-plugin.ts} +9 -9
  69. package/src/{v2-receiver.ts → runtime/v2-receiver.ts} +7 -7
  70. package/src/{watch.ts → runtime/watch.ts} +12 -12
  71. package/src/{member-state.ts → state/member-state.ts} +2 -2
  72. package/src/{sqlite-state.ts → state/sqlite-state.ts} +35 -15
  73. package/src/{store.ts → state/store.ts} +2 -2
  74. package/src/tests/announcement-board.ts +176 -0
  75. /package/src/{resource-read.ts → rooms/resource-read.ts} +0 -0
  76. /package/src/{receiver-owner.ts → state/receiver-owner.ts} +0 -0
  77. /package/src/{receiver-state.ts → state/receiver-state.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.7 — 2026-11-17
4
+
5
+ - Open an image full screen by clicking it, in a message or in the attachment tray. Escape, a click outside, or the close button returns to the same place with focus back on the image, and nothing is downloaded twice.
6
+ - Allow human room administrators to delegate administration, choose a successor and manage members; agents cannot become human administrators. The owner can transfer or dissolve the room. A designated management agent can remove members of its own room, except human administrators.
7
+ - Simplify the join page to two entries, join and create, over a nickname, with the key asked for once in a dialog when it is missing or rejected. A wide screen gets a two-column layout instead of a narrow card.
8
+ - Align the rail footer divider with the composer's divider at any composer height, including a five-line draft.
9
+ - Show upload failure details and use a bounded fallback for pasted files. The original intermittent paste failure has not been reproduced.
10
+ - Switch rooms with Alt+ArrowUp and Alt+ArrowDown: the selection cycles through the rooms this browser has joined, in the order the rail lists them, and stays put while a dialog is open.
11
+ - Put the room-list button on the left of the phone header, where a menu is expected, and keep the drawer opening from the left.
12
+ - Separate reminder and announcement lists from their editors, and identify management agents beside their messages and member entries.
13
+ - Let administrators delete room resources and agents delete their own uploads. Limit management-agent overview and history to their designated room.
14
+ - Organize source files by responsibility. Add experimental dsh and Codex plugin source; these packages are versioned separately and are not published with this release.
15
+
3
16
  ## 0.6.6 — 2026-11-16
4
17
 
5
18
  - Install the chat as an app: `/manifest.webmanifest` carries the name, icons, theme colour and `standalone` display, so a phone can add it to the home screen and open it without browser chrome.
package/cli.ts CHANGED
@@ -47,7 +47,7 @@ if (args[0] === "watch") {
47
47
  if (args.length !== 2 || !["run", "start", "status", "stop"].includes(action ?? "")) {
48
48
  fail("Expected watch run, start, status, or stop");
49
49
  }
50
- const watcher = await import("./src/watch");
50
+ const watcher = await import("./src/runtime/watch.ts");
51
51
  try {
52
52
  if (action === "run") await watcher.runWatcher();
53
53
  else if (action === "start") console.log(await watcher.startWatcher());
@@ -1,6 +1,6 @@
1
1
  # Administrator rooms
2
2
 
3
- An administrator room is a normal group room whose owner designates one registered Agent as its administrator. That Agent can inspect rooms and their history without joining them.
3
+ An administrator room is a normal group room whose owner designates one registered Agent as its administrator. That Agent can inspect its own room and its history.
4
4
 
5
5
  There is no separate operator credential. The room owner manages the designation from the room's **Options → Edit room** dialog: pick a registered Agent member as the administrator, or choose **None** to revoke. The change applies immediately and stays in effect until the owner revokes it or designates a different Agent.
6
6
 
@@ -12,8 +12,9 @@ The `admin` tool uses `roomId` for the administrator room.
12
12
 
13
13
  | Action | Additional arguments | Purpose |
14
14
  | --- | --- | --- |
15
- | `admin_overview` | None | Inspect rooms and members |
16
- | `admin_history` | `targetRoomId`, optional `limit` | Inspect bounded target-room history |
15
+ | `admin_overview` | None | Inspect the designated room and its members |
16
+ | `admin_history` | Optional `targetRoomId`, optional `limit` | Inspect bounded history in the designated room |
17
+ | `admin_remove_member` | `targetSessionID` | Remove a member of the designated room, except a human administrator |
17
18
 
18
19
  The server authorizes these calls from the designated Agent's native session and receiver owner identity; a normal room token, a mention, or room membership does not grant administrator privileges. Capabilities claimed by older versions keep working.
19
20
 
@@ -23,4 +24,4 @@ To assign work, send a message in the target room and mention the Agent. For sch
23
24
 
24
25
  Use HTTPS outside loopback. Keep legacy capability credentials out of room messages, URLs, logs, and shared screenshots. The server authenticates the Agent's native identity; caller-supplied session IDs are not credentials. Processes with unrestricted access to the same OS account can read one another's files, so private file modes do not provide sandbox isolation between such Agents.
25
26
 
26
- Back up server SQLite state to preserve designations, messages, and room reminders. Revoking a designation removes the Agent's administrator rights immediately; it does not change the room itself. Deleting an administrator room removes its designation along with the room.
27
+ Back up server SQLite state to preserve designations, messages, and room reminders. Revoking a designation removes the Agent's administrator rights immediately; it does not change the room itself. Deleting an administrator room removes its designation along with the room.
package/index.ts CHANGED
@@ -2,10 +2,10 @@
2
2
  // file persistence stay internal
3
3
  export { default } from "./plugin";
4
4
  export { id, server, setup } from "./plugin";
5
- export { default as RoomService, RoomError } from "./src/room-service";
5
+ export { default as RoomService, RoomError } from "./src/rooms/room-service.ts";
6
6
  export type {
7
7
  Message,
8
8
  Participant,
9
9
  Room,
10
10
  RoomErrorCode,
11
- } from "./src/room-service";
11
+ } from "./src/rooms/room-service.ts";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexsun-top/opencode-chat-room",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "A chat-room plugin and central server for OpenCode.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,6 +30,7 @@
30
30
  "server/inbox.ts",
31
31
  "server/history-route.ts",
32
32
  "server/room-payload.ts",
33
+ "server/room-owner.ts",
33
34
  "server/newrooms.ts",
34
35
  "server/member-routes.ts",
35
36
  "server/announcement-routes.ts",
@@ -54,7 +55,7 @@
54
55
  },
55
56
  "scripts": {
56
57
  "server": "bun run server/chat-server.ts",
57
- "test": "for file in src/*.test.ts server/*.test.ts; do bun test \"$file\" || exit; done",
58
+ "test": "for file in src/tests/*.test.ts server/*.test.ts; do bun test \"$file\" || exit; done",
58
59
  "typecheck": "tsc --noEmit"
59
60
  },
60
61
  "devDependencies": {
package/plugin.ts CHANGED
@@ -2,7 +2,7 @@ import { tool } from "@opencode-ai/plugin";
2
2
  import type { ToolContext as V1ToolContext } from "@opencode-ai/plugin";
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
4
  import { z } from "zod";
5
- import RoomService, { RoomError, type Message } from "./src/room-service";
5
+ import RoomService, { RoomError, type Message } from "./src/rooms/room-service.ts";
6
6
  import {
7
7
  formatRoom,
8
8
  acknowledgeReadWithReceipts,
@@ -16,23 +16,23 @@ import {
16
16
  timeOf,
17
17
  type Registry,
18
18
  type RegistryEntry,
19
- } from "./src/store";
20
- import { flushReceiptCandidates, receiptDestination } from "./src/agent-receipts";
21
- import { centerAction } from "./src/center-client";
22
- import { createQueueTransport, type QueueTransport } from "./src/queue-transport";
23
- import { checkCenterInbox } from "./src/center-inbox";
24
- import { assertDeliveryLease } from "./src/session-delivery";
25
- import { wakeSessions } from "./src/center-wake";
26
- import { clearPendingAdmission } from "./src/queue";
27
- import { createNotifier } from "./src/plugin-notifications";
28
- import { explicitlyAddresses } from "./src/mentions";
29
- import { createV2Setup, type V2Runtime } from "./src/v2-plugin";
30
- import { createV1Server } from "./src/v1-plugin";
31
- import { runAnnouncementTool } from "./src/announcement-tool";
32
- import { uploadAgentResource } from "./src/resource-upload";
33
- import { readAgentResource, resourceReadFailure } from "./src/resource-read";
34
- import { adminTool, adminToolDescription, adminToolSchema } from "./src/admin-client";
35
- import { runReminderTool } from "./src/reminder-client";
19
+ } from "./src/state/store.ts";
20
+ import { flushReceiptCandidates, receiptDestination } from "./src/agent/agent-receipts.ts";
21
+ import { centerAction, deleteAgentResource } from "./src/center/center-client.ts";
22
+ import { createQueueTransport, type QueueTransport } from "./src/center/queue-transport.ts";
23
+ import { checkCenterInbox } from "./src/center/center-inbox.ts";
24
+ import { assertDeliveryLease } from "./src/center/session-delivery.ts";
25
+ import { wakeSessions } from "./src/center/center-wake.ts";
26
+ import { clearPendingAdmission } from "./src/center/queue.ts";
27
+ import { createNotifier } from "./src/runtime/plugin-notifications.ts";
28
+ import { explicitlyAddresses } from "./src/center/mentions.ts";
29
+ import { createV2Setup, type V2Runtime } from "./src/runtime/v2-plugin.ts";
30
+ import { createV1Server } from "./src/runtime/v1-plugin.ts";
31
+ import { runAnnouncementTool } from "./src/agent/announcement-tool.ts";
32
+ import { uploadAgentResource } from "./src/rooms/resource-upload.ts";
33
+ import { readAgentResource, resourceReadFailure } from "./src/rooms/resource-read.ts";
34
+ import { adminTool, adminToolDescription, adminToolSchema } from "./src/agent/admin-client.ts";
35
+ import { runReminderTool } from "./src/center/reminder-client.ts";
36
36
  // ponytail: CHAT_ROOM_SERVER_URL switches to central mode (all state on a
37
37
  // central server); unset = standalone local-file mode
38
38
  const centerUrl = process.env.CHAT_ROOM_SERVER_URL ?? "";
@@ -246,7 +246,7 @@ export async function pollKnownSessions(
246
246
  const READ_ONLY_ACTIONS = new Set(["list", "members", "poll", "announcement_list", "announcement_read"]);
247
247
 
248
248
  export const roomArgs = z.object({
249
- action: z.enum(["create", "join", "leave", "list", "send", "poll", "members", "upload_resource", "read_resource", "announcement_list", "announcement_read", "announcement_write", "announcement_delete", "reminder_list", "reminder_create", "reminder_update", "reminder_delete"]),
249
+ 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"]),
250
250
  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."),
251
251
  roomId: z.string().optional(),
252
252
  resourceId: z.string().optional(),
@@ -275,6 +275,7 @@ const roomExecute = async (
275
275
  return await runReminderTool(runtime.center, args, context.sessionID);
276
276
  }
277
277
  if (args.action === "upload_resource") return uploadAgentResource(runtime.center, args.roomId ?? "", args.filePath ?? "", context.sessionID, context);
278
+ if (args.action === "delete_resource") return deleteAgentResource(runtime.center, args.roomId ?? "", args.resourceId ?? "", context.sessionID);
278
279
  if (args.action === "read_resource") {
279
280
  try {
280
281
  if (!context.ask) return "error: host webfetch permission is unavailable";
@@ -469,7 +470,7 @@ const roomExecute = async (
469
470
  }
470
471
  };
471
472
  const room = tool({
472
- 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.",
473
+ 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.",
473
474
  args: roomArgs.shape,
474
475
  execute: roomExecute,
475
476
  });
@@ -1,7 +1,7 @@
1
- import { databasePath } from "../src/store";
2
- import { readHistoryPage } from "../src/sqlite-state";
1
+ import { databasePath } from "../src/state/store.ts";
2
+ import { readHistoryPage } from "../src/state/sqlite-state.ts";
3
3
  import { hasAdminCapability } from "./admin-auth";
4
- import { binding, digest, ensureAdminSchema, exec, isAgentMember, many, matchesHash, newSecret, one, publicRoom, tx, validCurrent } from "./admin-state";
4
+ import { binding, digest, ensureAdminSchema, exec, isAgentMember, many, matchesHash, newSecret, publicRoom, tx, validCurrent } from "./admin-state";
5
5
 
6
6
  const json = (body: unknown, status = 200) => Response.json(body, { status, headers: { "Cache-Control": "no-store" } });
7
7
  const object = (value: unknown): value is Record<string, unknown> => !!value && typeof value === "object" && !Array.isArray(value);
@@ -59,8 +59,12 @@ async function overview(request: Request, roomID: string): Promise<Response> {
59
59
  const b = binding(db, roomID);
60
60
  if (!b) return { status: 404 as const };
61
61
  if (!hasAdminCapability(request, b)) return { status: 401 as const };
62
+ // A binding may only administer the room it points at; legacy rows targeting
63
+ // another room are stale and must not borrow that room's membership.
64
+ if (b.target_room_id !== roomID) return { status: 409 as const };
62
65
  if (!validCurrent(db, b)) return { status: 409 as const };
63
- const rooms = many<{ id: string; name: string; createdAt: number }>(db, "SELECT id,name,created_at AS createdAt FROM rooms ORDER BY created_at DESC LIMIT 200")
66
+ // The designation grants insight into its own room only.
67
+ const rooms = many<{ id: string; name: string; createdAt: number }>(db, "SELECT id,name,created_at AS createdAt FROM rooms WHERE id=?", roomID)
64
68
  .map(room => ({ ...room, members: many(db, "SELECT g.session_id AS sessionID,g.name,g.protocol,g.receiver_owner_id AS receiverOwnerID,g.work_state AS workState,g.last_seen_at AS lastSeenAt FROM registry g WHERE g.room_id=? ORDER BY g.name", room.id) }));
65
69
  return { rooms };
66
70
  });
@@ -69,16 +73,20 @@ async function overview(request: Request, roomID: string): Promise<Response> {
69
73
 
70
74
  async function history(request: Request, url: URL, roomID: string): Promise<Response> {
71
75
  const targetRoomID = url.searchParams.get("targetRoomId") ?? "";
76
+ if (!bounded(targetRoomID, 128)) return json({ error: "invalid history request" }, 400);
72
77
  const rawLimit = url.searchParams.get("limit");
73
78
  const limit = rawLimit === null ? 20 : Number(rawLimit);
74
- if (!bounded(targetRoomID, 128) || !Number.isSafeInteger(limit) || limit < 1 || limit > 50) return json({ error: "invalid history request" }, 400);
79
+ if (!Number.isSafeInteger(limit) || limit < 1 || limit > 50) return json({ error: "invalid history request" }, 400);
75
80
  const allowed = await tx(db => {
76
81
  const b = binding(db, roomID);
77
82
  if (!b) return 404;
78
83
  if (!hasAdminCapability(request, b)) return 401;
84
+ if (b.target_room_id !== roomID) return 409;
79
85
  if (!validCurrent(db, b)) return 409;
80
- return one(db, "SELECT 1 FROM rooms WHERE id=?", targetRoomID) ? 200 : 404;
86
+ return 200;
81
87
  });
82
88
  if (allowed !== 200) return json({ error: allowed === 401 ? "unauthorized" : allowed === 404 ? "room not found" : "binding is no longer active" }, allowed);
83
- return json(await readHistoryPage(databasePath(), targetRoomID, undefined, limit));
89
+ // The path room is the only scope; another target is never readable.
90
+ if (targetRoomID !== roomID) return json({ error: "room is outside this administrator's scope" }, 403);
91
+ return json(await readHistoryPage(databasePath(), roomID, undefined, limit));
84
92
  }
@@ -1,7 +1,7 @@
1
1
  import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
2
2
  import type { Database, SQLQueryBindings } from "bun:sqlite";
3
- import { databasePath } from "../src/store";
4
- import { initializeAdminSchema, withStateTransaction } from "../src/sqlite-state";
3
+ import { databasePath } from "../src/state/store.ts";
4
+ import { initializeAdminSchema, withStateTransaction } from "../src/state/sqlite-state.ts";
5
5
 
6
6
  const hash = (value: string) => createHash("sha256").update(value).digest("hex");
7
7
  const secret = () => randomBytes(32).toString("base64url");
@@ -1,5 +1,5 @@
1
- import { deleteAnnouncement, getAnnouncement, listAnnouncements, putAnnouncement, validateAnnouncement } from "../src/announcements";
2
- import { readState } from "../src/store";
1
+ import { deleteAnnouncement, getAnnouncement, listAnnouncements, putAnnouncement, validateAnnouncement } from "../src/rooms/announcements.ts";
2
+ import { readState } from "../src/state/store.ts";
3
3
 
4
4
  const json = (body: unknown, status = 200) => Response.json(body, { status });
5
5
  const object = (value: unknown): value is Record<string, unknown> => typeof value === "object" && value !== null && !Array.isArray(value);
@@ -0,0 +1,25 @@
1
+ /* Composer attachment tray: kept apart from the conversation layout. */
2
+ .attachment-button { flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 12px; color: var(--ink-2); background: var(--surface); font: inherit; font-size: 24px; cursor: pointer; }
3
+ .attachment-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
4
+ .attachment-button:hover { color: var(--accent); border-color: var(--accent); }
5
+ .attachment-button:disabled { opacity: .5; cursor: default; }
6
+ .attachment-tray { width: min(940px, 100%); margin: 0 auto; }
7
+ .attachment-volatile { margin: 0 0 3px; color: var(--ink-3); font-size: 10.5px; }
8
+ .attachment-status { display: inline-flex; width: fit-content; margin: 5px 0 0; padding: 3px 8px; border-radius: 999px; color: var(--accent); background: var(--accent-soft); font-size: 10.5px; }
9
+ .attachment-status.danger-text { color: var(--danger); background: var(--danger-soft); }
10
+ .attachment-status:empty { display: none; }
11
+ .attachment-list { display: grid; gap: 6px; max-height: 132px; overflow: auto; margin: 0; padding: 0; list-style: none; }
12
+ .attachment-item { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-width: 0; padding: 7px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); box-shadow: 0 1px 2px rgb(20 40 32 / .035); }
13
+ .attachment-preview { display: grid; place-items: center; width: 38px; height: 38px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--ink) 5%, transparent); border-radius: 8px; background: var(--surface-2); color: var(--ink-3); font-size: 11px; font-weight: 700; }
14
+ .attachment-preview img { width: 100%; height: 100%; object-fit: cover; }
15
+ .attachment-file { min-width: 0; }
16
+ .attachment-name { overflow: hidden; margin: 0; color: var(--ink); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
17
+ .attachment-detail { margin: 0; color: var(--ink-3); font-size: 10px; }
18
+ .attachment-item progress { display: block; width: 100%; height: 5px; accent-color: var(--accent); }
19
+ .attachment-actions { display: flex; gap: 4px; }
20
+ .attachment-actions button { min-width: 44px; min-height: 44px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink-2); background: var(--surface); font: inherit; font-size: 11px; cursor: pointer; }
21
+ .attachment-actions button:hover { border-color: var(--accent); color: var(--accent); }
22
+ .attachment-over-limit { color: var(--danger); }
23
+ #draftCount.over-limit { color: var(--danger); font-weight: 700; }
24
+ .attachment-drop-overlay { position: fixed; inset: 12px; z-index: 100; place-items: center; border: 2px dashed var(--accent); border-radius: 18px; color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 88%, transparent); font-size: clamp(18px, 4vw, 28px); font-weight: 700; pointer-events: none; }
25
+ #chatView.drag-over .attachment-drop-overlay { display: grid; }
@@ -4,7 +4,7 @@
4
4
 
5
5
  :root {
6
6
  --font-sans: "Avenir Next", "Segoe UI Variable", system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
7
- --font-display: "Iowan Old Style", "Baskerville", "Songti SC", Georgia, serif;
7
+ --font-display: var(--font-sans);
8
8
  --font-mono: ui-monospace,"SF Mono","Cascadia Mono","JetBrains Mono",Consolas,monospace;
9
9
  --bg: #f3f1ea;
10
10
  --surface: #fffefa;
@@ -88,18 +88,35 @@
88
88
  *, *::before, *::after { animation: none !important; transition: none !important; }
89
89
  }
90
90
 
91
- /* Join and create */
92
- .join-card {
93
- width: 100%;
94
- max-width: 424px;
91
+ /* Join and create: one bounded two-column composition, not a narrow column. */
92
+ .join-shell {
93
+ display: grid;
94
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
95
+ grid-template-areas: "side entries" "rooms entries";
96
+ grid-template-rows: auto 1fr;
97
+ gap: 22px 44px;
98
+ width: min(980px, 100%);
95
99
  margin: auto;
96
- padding: 38px 34px 32px;
97
- background: linear-gradient(155deg, color-mix(in srgb, var(--accent-soft) 32%, var(--surface)), var(--surface) 42%);
98
- border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
99
- border-radius: 22px;
100
- box-shadow: var(--shadow);
100
+ align-items: start;
101
+ }
102
+ .join-side { grid-area: side; display: grid; gap: 0; align-content: start; padding-top: 6px; }
103
+ .join-entries { grid-area: entries; display: grid; gap: 16px; align-content: start; }
104
+ .room-list { grid-area: rooms; margin-top: 0; }
105
+ .entry-card {
106
+ display: grid;
107
+ gap: 10px;
108
+ padding: 24px 24px 22px;
109
+ background: linear-gradient(158deg, color-mix(in srgb, var(--accent-soft) 30%, var(--surface)), var(--surface) 46%);
110
+ border: 1px solid color-mix(in srgb, var(--accent) 16%, var(--line));
111
+ border-radius: 20px;
112
+ box-shadow: 0 2px 5px rgb(34 53 47 / .04), 0 14px 34px rgb(34 53 47 / .07);
101
113
  }
102
- .locale-control { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-bottom: 20px; color: var(--ink-2); font-size: 12.5px; }
114
+ .entry-card h2 { margin: 0; font-family: var(--font-display); font-size: 23px; font-weight: 600; letter-spacing: -.02em; }
115
+ .entry-card .entry-hint { margin: -4px 0 2px; font-size: 12.5px; line-height: 1.5; color: var(--ink-3); }
116
+ .entry-card .field { margin-bottom: 6px; }
117
+ #joinForm .btn.primary, #createForm .btn.ghost { width: 100%; margin-top: 4px; padding: 12px 18px; }
118
+ .join-side .join-name { margin: 4px 0 0; }
119
+ .locale-control { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-bottom: 18px; color: var(--ink-2); font-size: 12.5px; }
103
120
  .locale-control label { font-weight: 600; }
104
121
  .locale-select { appearance: auto; min-height: 36px; font: inherit; font-size: 12.5px; line-height: 1.25; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; cursor: pointer; }
105
122
  .chat-head-actions .locale-control { margin: 0; }
@@ -165,8 +182,6 @@
165
182
  outline-offset: 2px;
166
183
  }
167
184
 
168
- #joinForm .btn.primary, #createForm .btn.ghost { width: 100%; margin-top: 4px; }
169
-
170
185
  .or { display: flex; align-items: center; gap: 12px; margin: 18px 0; font-size: 12.5px; color: var(--ink-3); }
171
186
  .or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
172
187
 
@@ -183,13 +198,16 @@
183
198
  .hint { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-3); }
184
199
 
185
200
  .panel.announcement-panel { width: min(390px, calc(100vw - 32px)); max-height: min(65dvh, 560px); overflow: auto; }
186
- .announcement-head, .announcement-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
201
+ .announcement-head, .announcement-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
187
202
  .announcement-head h3 { margin: 0; font-size: 15px; }
203
+ .announcement-tools { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
204
+ .panel .announcement-tools .btn, .panel .reminder-tools .btn { margin: 0; padding: 6px 9px; font-size: 12px; }
188
205
  .announcement-list { list-style: none; padding: 0; margin: 10px 0; max-height: 150px; overflow: auto; }
189
- .announcement-list button { width: 100%; padding: 8px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; font: inherit; cursor: pointer; }
206
+ .announcement-list button { width: 100%; padding: 8px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; font: inherit; overflow-wrap: anywhere; cursor: pointer; }
190
207
  .announcement-list button:hover, .announcement-list button[aria-current="true"] { background: var(--accent-soft); border-color: var(--line); }
191
208
  .announcement-list button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
192
209
  .announcement-form { border-top: 1px solid var(--line); padding-top: 10px; }
210
+ #announcementDialog .announcement-form { border: 0; padding: 16px; }
193
211
  .announcement-form .field { margin-bottom: 8px; }
194
212
  .announcement-form textarea { resize: vertical; min-height: 80px; max-height: 120px; }
195
213
  .announcement-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 8px; }
@@ -198,7 +216,11 @@
198
216
  .announcement-content { white-space: pre-wrap; overflow-wrap: anywhere; }
199
217
 
200
218
  .panel.reminder-panel { width: min(410px, calc(100vw - 32px)); max-height: min(72dvh, 640px); overflow: auto; }
219
+ .reminder-tools { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
201
220
  .reminder-form { border-top: 1px solid var(--line); padding-top: 10px; }
221
+ #reminderDialog .reminder-form { border: 0; padding: 16px; }
222
+ #reminderDialog .reminder-form .field { margin-bottom: 10px; }
223
+ #reminderDialog .reminder-form .announcement-actions { margin-top: 2px; }
202
224
  .reminder-form .field { margin: 0 0 9px; }
203
225
  .reminder-form textarea { resize: vertical; }
204
226
  .reminder-list { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 8px; }
@@ -207,21 +229,11 @@
207
229
  .reminder-list .hint { margin: 2px 0 7px; }
208
230
  .reminder-list .btn { margin: 0 6px 0 0; }
209
231
 
210
- .token-box { margin-top: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
211
- .token-box summary {
212
- cursor: pointer;
213
- padding: 11px 14px;
214
- font-size: 13.5px;
215
- font-weight: 600;
216
- color: var(--ink-2);
217
- list-style: none;
218
- }
219
- .token-box summary::-webkit-details-marker { display: none; }
220
- .token-box summary::marker { content: none; }
221
- .token-box summary::after { content: "▾"; margin-left: 6px; font-size: 11px; color: var(--ink-3); }
222
- .token-box[open] summary::after { content: "▴"; }
223
- .token-body { padding: 0 14px 14px; }
224
- .token-body .btn { margin-top: 10px; }
232
+ .key-dialog { width: min(420px, calc(100vw - 28px)); max-width: none; padding: 22px; color: var(--ink); background: linear-gradient(150deg, color-mix(in srgb, var(--accent-soft) 26%, var(--surface)), var(--surface) 54%); border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line)); border-radius: 18px; box-shadow: 0 24px 80px rgb(10 25 20 / .22); }
233
+ .key-dialog::backdrop { background: rgb(9 22 18 / .46); backdrop-filter: blur(3px); }
234
+ .key-dialog h2 { margin: 0 0 6px; font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
235
+ .key-dialog .hint { margin: 0 0 14px; }
236
+ .key-actions { display: flex; align-items: center; gap: 8px; }
225
237
 
226
238
  .room-list { margin-top: 22px; }
227
239
  .room-list h2 { margin: 0 0 8px; font-size: 13px; font-weight: 600; letter-spacing: .06em; color: var(--ink-2); }
@@ -0,0 +1,27 @@
1
+ // The administrator is one designated session, never every agent in the room.
2
+ export function isAdminAgent(app, sessionID) {
3
+ const admin = app.state.room?.adminSessionID;
4
+ return Boolean(admin) && sessionID === admin;
5
+ }
6
+
7
+ // Browser sessions are people; the backend binds the real membership and re-checks it.
8
+ export function isRoomAdmin(app) {
9
+ const room = app.state.room;
10
+ return Boolean(room) && (app.state.myName === room.ownerId || (room.adminIds ?? []).includes(app.state.myName));
11
+ }
12
+
13
+ // Human administrators may remove any non-owner member; the designated agent only ordinary members.
14
+ export function canRemoveMember(app, target, selfIsAgent, sessionID) {
15
+ const room = app.state.room;
16
+ if (!room || room.kind === "direct" || !target || target.name === room.ownerId) return false;
17
+ if (!selfIsAgent && isRoomAdmin(app)) return true;
18
+ return isAdminAgent(app, sessionID) && !(room.adminIds ?? []).includes(target.name);
19
+ }
20
+
21
+ export function adminAgentBadge(app) {
22
+ const badge = document.createElement("span");
23
+ badge.className = "admin-agent-badge";
24
+ badge.textContent = app.t("adminAgentLabel");
25
+ badge.title = app.t("adminAgentLabel");
26
+ return badge;
27
+ }
@@ -1,28 +1,40 @@
1
1
  import { LS } from "./state.js";
2
+ import { isRoomAdmin } from "./admin-badge.js";
2
3
 
3
- // Admin badges come from the room payload (adminSessionID); room owners manage
4
- // the designation through the edit-room dialog instead of an operator token.
4
+ // Owners and delegated humans manage settings; the agent designation comes from
5
+ // the room payload and room owners manage it here instead of an operator token.
5
6
  export function initAdmin(app) {
6
7
  const $ = app.$, dialog = $("#editRoomDialog");
7
- let agents = [], generation = 0, agentsReady = false;
8
+ let agents = [], people = [], generation = 0, agentsReady = false, rosterReady = false;
8
9
 
9
- const renderRoomOptions = app.renderRoomOptions;
10
- app.renderRoomOptions = (list, available) => {
11
- renderRoomOptions(list, available);
12
- const byId = new Map((available || []).map((room) => [room.id, room]));
13
- for (const button of list?.querySelectorAll(".room-row[data-room-id]") || []) {
14
- const room = app.state.rooms.get(button.dataset.roomId)?.room || byId.get(button.dataset.roomId);
15
- if (!room?.adminSessionID) continue;
16
- const badge = document.createElement("span"); badge.className = "room-admin-badge"; badge.textContent = app.t("adminRoomBadge");
17
- button.querySelector(".r-name")?.after(badge);
10
+ // Only people can own a room: agents carry a protocol, a host, or a receiver binding.
11
+ const isPerson = (entry) => Boolean(entry?.name) && !entry.protocol && !entry.host && !entry.receiverOwnerID;
12
+ function renderOwnerOptions(room) {
13
+ const select = $("#editRoomOwner");
14
+ const names = [...new Set(people.map((person) => person.name))];
15
+ if (room.ownerId && !names.includes(room.ownerId)) names.unshift(room.ownerId);
16
+ select.replaceChildren(...names.map((name) => new Option(name, name)));
17
+ select.value = room.ownerId || names[0] || "";
18
+ }
19
+
20
+ function renderAdminIds(room) {
21
+ const list = $("#editRoomAdminIds"), chosen = new Set(room.adminIds ?? []);
22
+ const names = [...new Set(people.map((person) => person.name))].filter((name) => name !== room.ownerId);
23
+ list.replaceChildren();
24
+ for (const name of names) {
25
+ const label = document.createElement("label"), input = document.createElement("input"), text = document.createElement("span");
26
+ label.className = "admin-check"; input.type = "checkbox"; input.value = name; input.checked = chosen.has(name); text.textContent = name;
27
+ label.append(input, text); list.append(label);
18
28
  }
19
- };
20
- const renderHead = app.renderHead;
21
- app.renderHead = () => {
22
- renderHead();
23
- const badge = $("#activeAdminBadge");
24
- if (badge) badge.hidden = !app.state.room?.adminSessionID;
25
- };
29
+ $("#editRoomAdminIdsEmpty").hidden = names.length > 0;
30
+ }
31
+
32
+ function renderSuccessorOptions(room) {
33
+ const select = $("#editRoomSuccessor");
34
+ const names = [...new Set(people.map((person) => person.name))].filter((name) => name !== room.ownerId);
35
+ select.replaceChildren(new Option(app.t("successorNone"), ""), ...names.map((name) => new Option(name, name)));
36
+ select.value = names.includes(room.successorId) ? room.successorId : "";
37
+ }
26
38
 
27
39
  async function loadAgents(gen) {
28
40
  const room = app.state.room; if (!room) return;
@@ -36,7 +48,11 @@ export function initAdmin(app) {
36
48
  .filter((agent) => agent.membershipID && (agent.protocol === "v1" || agent.protocol === "v2" || agent.receiverOwnerID || agent.host));
37
49
  for (const agent of agents) select.append(new Option(agent.name, agent.sessionID));
38
50
  select.value = agents.some((agent) => agent.sessionID === room.adminSessionID) ? room.adminSessionID : "";
39
- agentsReady = true;
51
+ people = Object.values(registry).filter(isPerson);
52
+ renderOwnerOptions(room);
53
+ renderAdminIds(room);
54
+ renderSuccessorOptions(room);
55
+ agentsReady = true; rosterReady = true;
40
56
  } catch (error) { if (gen === generation) $("#editRoomStatus").textContent = error.message; }
41
57
  }
42
58
 
@@ -45,11 +61,33 @@ export function initAdmin(app) {
45
61
  $("#editRoomName").value = room.name;
46
62
  $("#editRoomDescription").value = room.description || "";
47
63
  $("#editRoomStatus").textContent = "";
64
+ people = []; agentsReady = false; rosterReady = false;
65
+ renderOwnerOptions(room);
66
+ renderAdminIds(room);
67
+ $("#editRoomAdminIdsEmpty").hidden = true;
68
+ renderSuccessorOptions(room);
69
+ $("#editRoomOwnerOnly").hidden = !isOwner();
70
+ $("#editRoomOwnerOnlyNote").hidden = isOwner();
48
71
  dialog.showModal();
49
72
  void loadAgents(++generation);
50
73
  }
51
74
 
52
- $("#btnEditRoom").addEventListener("click", () => { app.closePanels(); open(); });
75
+ const isOwner = () => Boolean(app.state.room) && app.state.myName === app.state.room.ownerId;
76
+
77
+ const ownerDialog = $("#ownerOnlyDialog");
78
+ // The entry never disappears: a member who is neither owner nor admin gets a plain explanation.
79
+ function showOwnerOnly() {
80
+ app.setText($("#ownerOnlyNote"), "roomOwnerOnlyNote", { owner: app.state.room?.ownerId || "" });
81
+ ownerDialog.showModal();
82
+ }
83
+ $("#btnEditRoom").addEventListener("click", () => {
84
+ app.closePanels();
85
+ if (isRoomAdmin(app)) open();
86
+ else showOwnerOnly();
87
+ });
88
+ $("#btnCloseOwnerOnly").addEventListener("click", () => ownerDialog.close());
89
+ $("#btnOwnerOnlyOk").addEventListener("click", () => ownerDialog.close());
90
+ ownerDialog.addEventListener("click", (event) => { if (event.target === ownerDialog) ownerDialog.close(); });
53
91
  $("#btnCloseEditRoom").addEventListener("click", () => dialog.close());
54
92
  dialog.addEventListener("click", (event) => { if (event.target === dialog) dialog.close(); });
55
93
  $("#editRoomForm").addEventListener("submit", async (event) => {
@@ -57,17 +95,26 @@ export function initAdmin(app) {
57
95
  const room = app.state.room; if (!room) return;
58
96
  const name = $("#editRoomName").value.trim();
59
97
  if (!name) { $("#editRoomStatus").textContent = app.t("roomNameRequired"); return; }
60
- // Until the agent list loads, "None" is a placeholder, not a revocation.
61
- const body = { sessionID: LS.sessionID, name, description: $("#editRoomDescription").value.trim(), ...(agentsReady ? { adminSessionID: $("#editRoomAdmin").value || null } : {}) };
98
+ // Until the registry loads, empty rosters are placeholders, not revocations.
99
+ const owner = isOwner(), nextOwner = $("#editRoomOwner").value;
100
+ const checkedAdmins = [...$("#editRoomAdminIds").querySelectorAll("input:checked")].map((input) => input.value);
101
+ const body = {
102
+ sessionID: LS.sessionID, name, description: $("#editRoomDescription").value.trim(),
103
+ ...(owner && agentsReady ? { adminSessionID: $("#editRoomAdmin").value || null } : {}),
104
+ ...(owner && nextOwner && nextOwner !== room.ownerId ? { ownerId: nextOwner } : {}),
105
+ ...(rosterReady ? { adminIds: checkedAdmins, successorId: $("#editRoomSuccessor").value || null } : {}),
106
+ };
62
107
  const button = event.submitter; if (button) button.disabled = true;
63
108
  try {
64
109
  const updated = await app.api(`/rooms/${encodeURIComponent(room.id)}`, { method: "PATCH", body: JSON.stringify(body) });
65
- const meta = { name: updated.name, description: updated.description, adminSessionID: updated.adminSessionID, openQuestions: updated.openQuestions };
110
+ const meta = { name: updated.name, description: updated.description, adminSessionID: updated.adminSessionID, ownerId: updated.ownerId, adminIds: updated.adminIds ?? [], successorId: updated.successorId ?? null, openQuestions: updated.openQuestions };
66
111
  const entry = app.state.rooms.get(room.id);
67
112
  if (entry) { Object.assign(entry.room, meta); app.state.room = entry.room; }
68
113
  const listed = app.state.availableRooms?.find((item) => item.id === room.id);
69
114
  if (listed) Object.assign(listed, meta);
70
115
  app.renderHead();
116
+ app.renderMembers();
117
+ app.rerenderMessages();
71
118
  app.renderRoomOptions($("#roomList"), app.state.availableRooms || []);
72
119
  app.renderRoomOptions($("#roomListChat"), app.state.availableRooms || []);
73
120
  app.cacheRoomSoon?.(room.id);