@alexsun-top/opencode-chat-room 0.8.1 → 0.8.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 +33 -0
- package/README.md +18 -62
- package/README.zh-CN.md +25 -69
- package/dist/cli.js +1008 -274
- package/package.json +10 -7
- package/packages/chat-room-channeld/README.md +42 -15
- package/packages/chat-room-channeld/dist/mock-adapter.js +5 -5
- package/packages/chat-room-channeld/src/adapter.ts +150 -7
- package/packages/chat-room-channeld/src/cli.ts +72 -5
- package/packages/chat-room-channeld/src/host.ts +41 -11
- package/packages/chat-room-channeld/src/inbound.ts +13 -4
- package/packages/chat-room-channeld/src/pg/database.ts +187 -0
- package/packages/chat-room-channeld/src/pg/migrate.ts +150 -0
- package/packages/chat-room-channeld/src/pg/schema.ts +60 -0
- package/packages/chat-room-channeld/src/pg/sql.mjs +175 -0
- package/packages/chat-room-channeld/src/pg/sqlite.ts +100 -0
- package/packages/chat-room-channeld/src/pg/worker.mjs +133 -0
- package/packages/chat-room-channeld/src/protocol.ts +53 -1
- package/packages/chat-room-channeld/src/rules.ts +7 -2
- package/packages/chat-room-channeld/src/state.ts +73 -97
- package/packages/chat-room-channeld/src/stats.ts +140 -109
- package/plugin.ts +1 -1
- package/server/assets/base.css +11 -3
- package/server/assets/chat/admin-badge.js +32 -30
- package/server/assets/chat/admin.js +198 -163
- package/server/assets/chat/announcements.js +295 -210
- package/server/assets/chat/attachment-store.js +106 -75
- package/server/assets/chat/attachments.js +686 -441
- package/server/assets/chat/chat-background.js +206 -0
- package/server/assets/chat/clipboard.js +44 -25
- package/server/assets/chat/confirm-dialog.js +36 -34
- package/server/assets/chat/copy-action.js +40 -40
- package/server/assets/chat/create-room-dialog.js +50 -48
- package/server/assets/chat/diagram-viewer.js +293 -228
- package/server/assets/chat/doc-preview.js +510 -388
- package/server/assets/chat/editor.js +423 -335
- package/server/assets/chat/events.js +637 -502
- package/server/assets/chat/files.js +476 -426
- package/server/assets/chat/history-loader.js +79 -73
- package/server/assets/chat/icons.js +9 -11
- package/server/assets/chat/image-zoom.js +239 -169
- package/server/assets/chat/index.js +6 -5
- package/server/assets/chat/install-prompt.js +86 -66
- package/server/assets/chat/integration-account-schema.js +101 -0
- package/server/assets/chat/integration-editor.js +162 -153
- package/server/assets/chat/integration-values.js +109 -100
- package/server/assets/chat/integrations.js +696 -479
- package/server/assets/chat/join-requests.js +408 -358
- package/server/assets/chat/locales/de.js +193 -194
- package/server/assets/chat/locales/es.js +193 -194
- package/server/assets/chat/locales/fr.js +193 -194
- package/server/assets/chat/locales/index.js +1 -2
- package/server/assets/chat/locales/it.js +193 -194
- package/server/assets/chat/locales/ja.js +193 -193
- package/server/assets/chat/locales/ko.js +193 -193
- package/server/assets/chat/markdown-footnotes.js +134 -102
- package/server/assets/chat/markdown.js +553 -386
- package/server/assets/chat/members.js +236 -197
- package/server/assets/chat/mentions.js +157 -133
- package/server/assets/chat/message-cache.js +40 -33
- package/server/assets/chat/message-polling.js +280 -227
- package/server/assets/chat/message-window.js +74 -55
- package/server/assets/chat/messages.js +552 -479
- package/server/assets/chat/office-preview.js +46 -45
- package/server/assets/chat/palette.js +450 -412
- package/server/assets/chat/panels.js +94 -58
- package/server/assets/chat/pwa.js +144 -73
- package/server/assets/chat/questions.js +372 -302
- package/server/assets/chat/recall.js +320 -273
- package/server/assets/chat/receipts.js +149 -122
- package/server/assets/chat/reminders.js +331 -216
- package/server/assets/chat/replies.js +165 -136
- package/server/assets/chat/resource-format.js +59 -62
- package/server/assets/chat/room-list.js +58 -55
- package/server/assets/chat/room-watcher.js +72 -50
- package/server/assets/chat/rooms.js +623 -505
- package/server/assets/chat/search.js +136 -114
- package/server/assets/chat/settings.js +229 -140
- package/server/assets/chat/shiki.js +61 -62
- package/server/assets/chat/shortcuts.js +212 -190
- package/server/assets/chat/side-pane.js +166 -131
- package/server/assets/chat/state.js +851 -707
- package/server/assets/chat/system-events.js +55 -27
- package/server/assets/chat/system-messages.js +59 -49
- package/server/assets/chat/task-form.js +178 -182
- package/server/assets/chat/task-row.js +158 -155
- package/server/assets/chat/tasks.js +653 -593
- package/server/assets/chat/viewport.js +32 -29
- package/server/assets/chat/window-controls.js +37 -0
- package/server/assets/code-highlight.css +22 -6
- package/server/assets/conversation.css +65 -16
- package/server/assets/doc-preview.css +6 -1
- package/server/assets/files.css +3 -0
- package/server/assets/monaco/integration-rules.css +1 -1
- package/server/assets/monaco/integration-rules.js +841 -533
- package/server/assets/responsive.css +32 -2
- package/server/assets/settings.css +117 -13
- package/server/assets/window-controls.css +36 -0
- package/server/channel-attachments.ts +133 -0
- package/server/channel-integration.ts +79 -26
- package/server/channels.ts +15 -5
- package/server/chat-server.ts +9 -1
- package/server/chat.html +73 -38
- package/server/manifest.webmanifest +1 -0
- package/server/routes/pages.ts +7 -5
- package/server/sw.js +346 -267
- package/src/center/center-client.ts +1 -1
- package/src/state/pg-database.ts +5 -5
- package/src/state/pg-migrate.ts +7 -7
- package/src/state/pg-worker.mjs +2 -17
- package/src/state/sqlite-database.ts +14 -5
- package/src/state/sqlite-rooms.ts +130 -23
- package/src/state/sqlite-state-store.ts +6 -5
- package/src/state/sqlite.ts +3 -3
- package/src/web/integration-rules-editor.ts +141 -5
- package/src/web/integration-rules.ts +6 -2
- package/src/web/integration-schema.ts +7 -6
- package/packages/chat-room-channeld/dist/feishu-adapter.js +0 -1262
- package/packages/chat-room-channeld/src/feishu-adapter.ts +0 -303
- package/packages/chat-room-channeld/src/feishu-card.ts +0 -27
- package/packages/chat-room-channeld/src/feishu-inbound.ts +0 -158
- package/packages/chat-room-channeld/src/feishu-live.ts +0 -355
- package/packages/chat-room-channeld/src/feishu-send.ts +0 -342
- package/packages/chat-room-channeld/src/feishu-ws-frames.ts +0 -173
- package/server/assets/chat/forward.js +0 -69
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PgDatabase } from "./pg/database.ts";
|
|
2
|
+
import { Database, type SQLQueryBindings, type StateDatabase } from "./pg/sqlite.ts";
|
|
3
|
+
import { PUBLISHED_RESULT_PREFIX } from "./published.ts";
|
|
2
4
|
|
|
3
5
|
export type ChannelAccountState = "started" | "failed" | "disabled" | "unknown";
|
|
4
6
|
|
|
5
|
-
/** Live state supplied by a running host; stats itself only reads
|
|
7
|
+
/** Live state supplied by a running host; stats itself only reads the backend. */
|
|
6
8
|
export interface ChannelAccountRuntime {
|
|
7
9
|
state: ChannelAccountState;
|
|
8
10
|
lastError?: string;
|
|
@@ -57,12 +59,12 @@ export function sanitizeAccountError(value: string): string {
|
|
|
57
59
|
return redacted.replace(/[\r\n\t]+/g, " ").replace(/\s+/g, " ").trim().slice(0, MAX_LAST_ERROR);
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
function count(db:
|
|
61
|
-
const row = db.
|
|
62
|
+
function count(db: StateDatabase, sql: string, ...params: SQLQueryBindings[]): number {
|
|
63
|
+
const row = db.query(sql).get(...params) as Row;
|
|
62
64
|
return Number(row.count);
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
function accountKey(target: string): string {
|
|
67
|
+
export function accountKey(target: string): string {
|
|
66
68
|
const first = target.indexOf("/");
|
|
67
69
|
if (first < 0) return target;
|
|
68
70
|
const second = target.indexOf("/", first + 1);
|
|
@@ -71,139 +73,168 @@ function accountKey(target: string): string {
|
|
|
71
73
|
|
|
72
74
|
/**
|
|
73
75
|
* Read queue and integrity counts without touching message content.
|
|
74
|
-
* The
|
|
76
|
+
* The SQLite file is opened read-only, so a missing state file is never created.
|
|
75
77
|
*/
|
|
76
78
|
export function readChannelStats(
|
|
77
79
|
path: string,
|
|
78
80
|
now = Date.now(),
|
|
79
81
|
runtime: ReadonlyMap<string, ChannelAccountRuntime> = new Map(),
|
|
80
82
|
): ChannelStats {
|
|
81
|
-
let db:
|
|
83
|
+
let db: Database | undefined;
|
|
82
84
|
try {
|
|
83
|
-
db = new
|
|
85
|
+
db = new Database(path, { readOnly: true });
|
|
84
86
|
db.exec("PRAGMA busy_timeout = 2000");
|
|
85
|
-
|
|
86
87
|
const names = new Set(
|
|
87
|
-
(db.
|
|
88
|
+
(db.query("SELECT name FROM sqlite_master WHERE type = 'table'").all() as Row[]).map((row) =>
|
|
88
89
|
String(row.name)
|
|
89
90
|
),
|
|
90
91
|
);
|
|
91
92
|
if (REQUIRED_TABLES.some((table) => !names.has(table))) {
|
|
92
93
|
throw new Error(`channel state not found: ${path}`);
|
|
93
94
|
}
|
|
95
|
+
return buildStats(db, now, runtime);
|
|
96
|
+
} catch {
|
|
97
|
+
throw new Error(`channel state not found: ${path}`);
|
|
98
|
+
} finally {
|
|
99
|
+
try {
|
|
100
|
+
db?.close();
|
|
101
|
+
} catch {
|
|
102
|
+
// Keep the original result or error.
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
94
106
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
107
|
+
/** Read the same stats from PostgreSQL without echoing the connection string. */
|
|
108
|
+
export function readChannelStatsFromPostgres(
|
|
109
|
+
url: string,
|
|
110
|
+
now = Date.now(),
|
|
111
|
+
runtime: ReadonlyMap<string, ChannelAccountRuntime> = new Map(),
|
|
112
|
+
): ChannelStats {
|
|
113
|
+
let db: PgDatabase | undefined;
|
|
114
|
+
try {
|
|
115
|
+
db = new PgDatabase(url);
|
|
116
|
+
return buildStats(db, now, runtime);
|
|
117
|
+
} catch {
|
|
118
|
+
throw new Error("channel state not found: postgres");
|
|
119
|
+
} finally {
|
|
120
|
+
try {
|
|
121
|
+
db?.close();
|
|
122
|
+
} catch {
|
|
123
|
+
// Keep the original result or error.
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function buildStats(
|
|
129
|
+
db: StateDatabase,
|
|
130
|
+
now: number,
|
|
131
|
+
runtime: ReadonlyMap<string, ChannelAccountRuntime>,
|
|
132
|
+
): ChannelStats {
|
|
133
|
+
const stateCounts: Record<string, number> = {};
|
|
134
|
+
const accounts = new Map<string, ChannelAccountStats>();
|
|
135
|
+
let oldestBacklogAt: number | null = null;
|
|
136
|
+
const rows = db.query("SELECT target, state, created_at FROM channel_deliveries").all() as Row[];
|
|
99
137
|
|
|
100
138
|
for (const row of rows) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const key = accountKey(String(row.target));
|
|
105
|
-
let account = accounts.get(key);
|
|
106
|
-
if (!account) {
|
|
107
|
-
account = {
|
|
108
|
-
account: key,
|
|
109
|
-
state: "unknown",
|
|
110
|
-
queueDepth: 0,
|
|
111
|
-
oldestBacklogAt: null,
|
|
112
|
-
unknown: 0,
|
|
113
|
-
retryable: 0,
|
|
114
|
-
rateLimited: 0,
|
|
115
|
-
};
|
|
116
|
-
accounts.set(key, account);
|
|
117
|
-
}
|
|
118
|
-
if (state === "unknown") account.unknown += 1;
|
|
119
|
-
if (state === "retryable") account.retryable += 1;
|
|
120
|
-
if (state === "rate_limited") account.rateLimited += 1;
|
|
121
|
-
if (QUEUE_STATES.has(state)) {
|
|
122
|
-
const createdAt = Number(row.created_at);
|
|
123
|
-
account.queueDepth += 1;
|
|
124
|
-
if (account.oldestBacklogAt === null || createdAt < account.oldestBacklogAt) {
|
|
125
|
-
account.oldestBacklogAt = createdAt;
|
|
126
|
-
}
|
|
127
|
-
if (oldestBacklogAt === null || createdAt < oldestBacklogAt) {
|
|
128
|
-
oldestBacklogAt = createdAt;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
139
|
+
const state = String(row.state);
|
|
140
|
+
stateCounts[state] = (stateCounts[state] ?? 0) + 1;
|
|
132
141
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
142
|
+
const key = accountKey(String(row.target));
|
|
143
|
+
let account = accounts.get(key);
|
|
144
|
+
if (!account) {
|
|
145
|
+
account = {
|
|
137
146
|
account: key,
|
|
138
|
-
state: "unknown"
|
|
147
|
+
state: "unknown",
|
|
139
148
|
queueDepth: 0,
|
|
140
149
|
oldestBacklogAt: null,
|
|
141
150
|
unknown: 0,
|
|
142
151
|
retryable: 0,
|
|
143
152
|
rateLimited: 0,
|
|
144
153
|
};
|
|
145
|
-
account.state = live.state;
|
|
146
|
-
const lastError = live.lastError ? sanitizeAccountError(live.lastError) : "";
|
|
147
|
-
if (lastError) account.lastError = lastError;
|
|
148
154
|
accounts.set(key, account);
|
|
149
155
|
}
|
|
156
|
+
if (state === "unknown") account.unknown += 1;
|
|
157
|
+
if (state === "retryable") account.retryable += 1;
|
|
158
|
+
if (state === "rate_limited") account.rateLimited += 1;
|
|
159
|
+
if (QUEUE_STATES.has(state)) {
|
|
160
|
+
const createdAt = Number(row.created_at);
|
|
161
|
+
account.queueDepth += 1;
|
|
162
|
+
if (account.oldestBacklogAt === null || createdAt < account.oldestBacklogAt) {
|
|
163
|
+
account.oldestBacklogAt = createdAt;
|
|
164
|
+
}
|
|
165
|
+
if (oldestBacklogAt === null || createdAt < oldestBacklogAt) {
|
|
166
|
+
oldestBacklogAt = createdAt;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
150
170
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
db,
|
|
163
|
-
"SELECT COUNT(*) AS count FROM channel_events WHERE json_extract(payload, '$.kind') = 'result.published'",
|
|
164
|
-
),
|
|
165
|
-
eventsWithoutDeliveries: count(
|
|
166
|
-
db,
|
|
167
|
-
`SELECT COUNT(*) AS count FROM channel_events e
|
|
168
|
-
WHERE json_extract(e.payload, '$.kind') IS NOT 'result.published'
|
|
169
|
-
AND NOT EXISTS (SELECT 1 FROM channel_deliveries d WHERE d.event_id = e.event_id)`,
|
|
170
|
-
),
|
|
171
|
-
deliveriesWithoutEvent: count(
|
|
172
|
-
db,
|
|
173
|
-
`SELECT COUNT(*) AS count FROM channel_deliveries d
|
|
174
|
-
WHERE NOT EXISTS (SELECT 1 FROM channel_events e WHERE e.event_id = d.event_id)`,
|
|
175
|
-
),
|
|
176
|
-
receiptsWithoutDelivery: count(
|
|
177
|
-
db,
|
|
178
|
-
`SELECT COUNT(*) AS count FROM channel_receipts r
|
|
179
|
-
WHERE NOT EXISTS (SELECT 1 FROM channel_deliveries d WHERE d.delivery_id = r.delivery_id)`,
|
|
180
|
-
),
|
|
181
|
-
deliveries: {
|
|
182
|
-
total: rows.length,
|
|
183
|
-
pending,
|
|
184
|
-
inFlight: stateCounts.in_flight ?? 0,
|
|
185
|
-
retryable,
|
|
186
|
-
rateLimited,
|
|
187
|
-
paused: stateCounts.paused ?? 0,
|
|
188
|
-
unknown: stateCounts.unknown ?? 0,
|
|
189
|
-
sent: stateCounts.sent ?? 0,
|
|
190
|
-
failed,
|
|
191
|
-
},
|
|
192
|
-
queueDepth: pending + retryable + rateLimited,
|
|
193
|
-
oldestBacklogAt,
|
|
194
|
-
oldestBacklogAgeMs: oldestBacklogAt === null ? null : now - oldestBacklogAt,
|
|
195
|
-
accounts: [...accounts.values()].sort((left, right) =>
|
|
196
|
-
left.account < right.account ? -1 : left.account > right.account ? 1 : 0
|
|
197
|
-
),
|
|
171
|
+
// Runtime entries add configured accounts without deliveries and override
|
|
172
|
+
// the backend default of "unknown" for a running host.
|
|
173
|
+
for (const [key, live] of runtime) {
|
|
174
|
+
const account = accounts.get(key) ?? {
|
|
175
|
+
account: key,
|
|
176
|
+
state: "unknown" as const,
|
|
177
|
+
queueDepth: 0,
|
|
178
|
+
oldestBacklogAt: null,
|
|
179
|
+
unknown: 0,
|
|
180
|
+
retryable: 0,
|
|
181
|
+
rateLimited: 0,
|
|
198
182
|
};
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
try {
|
|
204
|
-
db?.close();
|
|
205
|
-
} catch {
|
|
206
|
-
// Keep the original result or error.
|
|
207
|
-
}
|
|
183
|
+
account.state = live.state;
|
|
184
|
+
const lastError = live.lastError ? sanitizeAccountError(live.lastError) : "";
|
|
185
|
+
if (lastError) account.lastError = lastError;
|
|
186
|
+
accounts.set(key, account);
|
|
208
187
|
}
|
|
188
|
+
|
|
189
|
+
const pending = stateCounts.pending ?? 0;
|
|
190
|
+
const retryable = stateCounts.retryable ?? 0;
|
|
191
|
+
const rateLimited = stateCounts.rate_limited ?? 0;
|
|
192
|
+
const failed = (stateCounts.permanent ?? 0)
|
|
193
|
+
+ (stateCounts.unsupported ?? 0)
|
|
194
|
+
+ (stateCounts.exhausted ?? 0);
|
|
195
|
+
|
|
196
|
+
const publishedPattern = `${PUBLISHED_RESULT_PREFIX}%`;
|
|
197
|
+
return {
|
|
198
|
+
generatedAt: now,
|
|
199
|
+
events: count(db, "SELECT COUNT(*) AS count FROM channel_events"),
|
|
200
|
+
publishedResults: count(
|
|
201
|
+
db,
|
|
202
|
+
"SELECT COUNT(*) AS count FROM channel_events WHERE dedup_key LIKE ?",
|
|
203
|
+
publishedPattern,
|
|
204
|
+
),
|
|
205
|
+
eventsWithoutDeliveries: count(
|
|
206
|
+
db,
|
|
207
|
+
`SELECT COUNT(*) AS count FROM channel_events e
|
|
208
|
+
WHERE e.dedup_key NOT LIKE ?
|
|
209
|
+
AND NOT EXISTS (SELECT 1 FROM channel_deliveries d WHERE d.event_id = e.event_id)`,
|
|
210
|
+
publishedPattern,
|
|
211
|
+
),
|
|
212
|
+
deliveriesWithoutEvent: count(
|
|
213
|
+
db,
|
|
214
|
+
`SELECT COUNT(*) AS count FROM channel_deliveries d
|
|
215
|
+
WHERE NOT EXISTS (SELECT 1 FROM channel_events e WHERE e.event_id = d.event_id)`,
|
|
216
|
+
),
|
|
217
|
+
receiptsWithoutDelivery: count(
|
|
218
|
+
db,
|
|
219
|
+
`SELECT COUNT(*) AS count FROM channel_receipts r
|
|
220
|
+
WHERE NOT EXISTS (SELECT 1 FROM channel_deliveries d WHERE d.delivery_id = r.delivery_id)`,
|
|
221
|
+
),
|
|
222
|
+
deliveries: {
|
|
223
|
+
total: rows.length,
|
|
224
|
+
pending,
|
|
225
|
+
inFlight: stateCounts.in_flight ?? 0,
|
|
226
|
+
retryable,
|
|
227
|
+
rateLimited,
|
|
228
|
+
paused: stateCounts.paused ?? 0,
|
|
229
|
+
unknown: stateCounts.unknown ?? 0,
|
|
230
|
+
sent: stateCounts.sent ?? 0,
|
|
231
|
+
failed,
|
|
232
|
+
},
|
|
233
|
+
queueDepth: pending + retryable + rateLimited,
|
|
234
|
+
oldestBacklogAt,
|
|
235
|
+
oldestBacklogAgeMs: oldestBacklogAt === null ? null : now - oldestBacklogAt,
|
|
236
|
+
accounts: [...accounts.values()].sort((left, right) =>
|
|
237
|
+
left.account < right.account ? -1 : left.account > right.account ? 1 : 0
|
|
238
|
+
),
|
|
239
|
+
};
|
|
209
240
|
}
|
package/plugin.ts
CHANGED
|
@@ -501,7 +501,7 @@ const roomExecute = async (
|
|
|
501
501
|
);
|
|
502
502
|
const room = svc.getRoom(args.roomId);
|
|
503
503
|
notifications.push({ roomId: args.roomId, roomName: room.name, messages: [...room.messages] });
|
|
504
|
-
return `sent: ${args.text}\
|
|
504
|
+
return `sent: ${args.text}\nmessage_id=${msg.id} room_id=${room.id}\n${formatRoom(svc, room)}`;
|
|
505
505
|
}
|
|
506
506
|
case "poll": {
|
|
507
507
|
if (!args.roomId) {
|
package/server/assets/base.css
CHANGED
|
@@ -186,6 +186,10 @@
|
|
|
186
186
|
|
|
187
187
|
.btn {
|
|
188
188
|
appearance: none;
|
|
189
|
+
display: inline-flex;
|
|
190
|
+
align-items: center;
|
|
191
|
+
justify-content: center;
|
|
192
|
+
gap: 6px;
|
|
189
193
|
border: none;
|
|
190
194
|
cursor: pointer;
|
|
191
195
|
font: inherit;
|
|
@@ -233,7 +237,8 @@
|
|
|
233
237
|
#announcementsDialog.is-pane .announcements-body, #remindersDialog.is-pane .reminders-body { padding: 0 14px 18px 18px; }
|
|
234
238
|
.announcements-dialog .announcement-list { margin: 0; max-height: none; }
|
|
235
239
|
.reminders-dialog .reminder-list { margin: 0; }
|
|
236
|
-
|
|
240
|
+
#announcementStatus { min-height: 1.4em; }
|
|
241
|
+
.announcement-list { list-style: none; padding: 0; margin: 10px 0; min-height: 120px; max-height: 150px; overflow: auto; }
|
|
237
242
|
.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; }
|
|
238
243
|
.announcement-list button:hover, .announcement-list button[aria-current="true"] { background: var(--accent-soft); border-color: var(--line); }
|
|
239
244
|
.announcement-list button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
@@ -271,8 +276,10 @@
|
|
|
271
276
|
#reminderDialog .reminder-form .announcement-actions { margin-top: 2px; }
|
|
272
277
|
.reminder-form .field { margin: 0 0 9px; }
|
|
273
278
|
.reminder-form textarea { resize: vertical; min-height: clamp(110px, 16dvh, 190px); max-height: 30dvh; line-height: 1.6; }
|
|
274
|
-
|
|
279
|
+
#reminderStatus { min-height: 1.4em; }
|
|
280
|
+
.reminder-list { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 8px; min-height: 96px; }
|
|
275
281
|
.reminder-list li { padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
|
|
282
|
+
.reminder-list li.is-disabled { color: var(--ink-3); background: color-mix(in srgb, var(--surface) 70%, var(--line)); opacity: .62; }
|
|
276
283
|
.reminder-list p { margin: 0 0 6px; overflow-wrap: anywhere; }
|
|
277
284
|
.reminder-list .hint { margin: 2px 0 7px; }
|
|
278
285
|
.reminder-list .btn { margin: 0 6px 0 0; }
|
|
@@ -325,7 +332,7 @@
|
|
|
325
332
|
.keys-list { display: grid; gap: 2px; list-style: none; margin: 0; padding: 0; }
|
|
326
333
|
.keys-list li { display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: 4px 16px; padding: 7px 0; border-top: 1px solid color-mix(in srgb, var(--line) 72%, transparent); font-size: 13px; }
|
|
327
334
|
.keys-list li:first-child { border-top: 0; }
|
|
328
|
-
.keys-list li > span:last-child { color: var(--ink-2); }
|
|
335
|
+
.keys-list li > span:last-child { color: var(--ink-2); text-align: right; }
|
|
329
336
|
.keys-group { display: inline-flex; align-items: center; gap: 6px; }
|
|
330
337
|
@media (max-width: 560px) {
|
|
331
338
|
.keys-dialog { padding: 18px; }
|
|
@@ -453,6 +460,7 @@
|
|
|
453
460
|
.footnotes ol { margin: 0; padding-left: 20px; }
|
|
454
461
|
.footnotes li { margin: 3px 0; }
|
|
455
462
|
.footnote-ref { font-size: .78em; line-height: 0; }
|
|
463
|
+
.footnote-ref + .footnote-ref { margin-left: .3em; }
|
|
456
464
|
.footnote-ref a { text-decoration: none; }
|
|
457
465
|
.footnote-backref { margin-left: 2px; text-decoration: none; }
|
|
458
466
|
|
|
@@ -1,49 +1,51 @@
|
|
|
1
1
|
// The administrator is one designated session, never every agent in the room.
|
|
2
2
|
export function isAdminAgent(app, sessionID) {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const admin = app.state.room?.adminSessionID;
|
|
4
|
+
return Boolean(admin) && sessionID === admin;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
6
|
// Browser sessions are people; the backend binds the real membership and re-checks it.
|
|
8
7
|
export function isRoomAdmin(app) {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const room = app.state.room;
|
|
9
|
+
return Boolean(room) && (app.state.myName === room.ownerId || (room.adminIds ?? []).includes(app.state.myName));
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
// Human administrators may remove any non-owner member; the designated agent only ordinary members.
|
|
14
12
|
export function canRemoveMember(app, target, selfIsAgent, sessionID) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
const room = app.state.room;
|
|
14
|
+
if (!room || room.kind === "direct" || !target || target.name === room.ownerId)
|
|
15
|
+
return false;
|
|
16
|
+
if (!selfIsAgent && isRoomAdmin(app))
|
|
17
|
+
return true;
|
|
18
|
+
return isAdminAgent(app, sessionID) && !(room.adminIds ?? []).includes(target.name);
|
|
19
19
|
}
|
|
20
|
-
|
|
21
20
|
// One label per member: the owner outranks human administrators, who outrank the
|
|
22
21
|
// designated agent. Names are the stable identity shared by rooms and members.
|
|
23
22
|
export function memberRole(app, member) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const room = app.state.room;
|
|
24
|
+
if (!room || !member || room.kind === "direct")
|
|
25
|
+
return "";
|
|
26
|
+
if (member.name === room.ownerId)
|
|
27
|
+
return "owner";
|
|
28
|
+
if ((room.adminIds ?? []).includes(member.name))
|
|
29
|
+
return "admin";
|
|
30
|
+
return isAdminAgent(app, member.sessionID) ? "agent" : "";
|
|
29
31
|
}
|
|
30
|
-
|
|
31
32
|
function badge(className, text) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
const node = document.createElement("span");
|
|
34
|
+
node.className = className;
|
|
35
|
+
node.textContent = text;
|
|
36
|
+
node.title = text;
|
|
37
|
+
return node;
|
|
37
38
|
}
|
|
38
|
-
|
|
39
39
|
export function adminAgentBadge(app) {
|
|
40
|
-
|
|
40
|
+
return badge("admin-agent-badge", app.t("adminAgentLabel"));
|
|
41
41
|
}
|
|
42
|
-
|
|
43
42
|
export function memberRoleBadge(app, member) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
const role = memberRole(app, member);
|
|
44
|
+
if (role === "owner")
|
|
45
|
+
return badge("admin-badge owner-badge", app.t("roomOwnerBadge"));
|
|
46
|
+
if (role === "admin")
|
|
47
|
+
return badge("admin-badge", app.t("roomAdminBadge"));
|
|
48
|
+
if (role === "agent")
|
|
49
|
+
return adminAgentBadge(app);
|
|
50
|
+
return null;
|
|
49
51
|
}
|